[*] Refactoring of "draw axes" procedure.

[-] Removed not working part of code for reloading textures. That do nothing, just show checkbox. As Yoda said: "Do. Or do not. There is no try."
pull/1981/head
smalcom 2018-05-24 12:31:49 +03:00
parent e201fcf4f4
commit 6093769da1
4 changed files with 17 additions and 55 deletions

View File

@ -560,30 +560,6 @@ void CGLView::Enable_Textures(const bool pEnable)
} }
} }
void CGLView::Enable_Axes(const bool pEnable){
if(pEnable)
{
this->mAxesEnabled = true;
}
else
{
this->mAxesEnabled = false;
}
}
void CGLView::Enable_Reload_Textures(const bool pEnable)
{
if(pEnable)
{
this->mReloadTexturesEnabled = true;
// this->mScene->ImportTextures(this->mScene->pScenePath);
}
else
{
this->mReloadTexturesEnabled = false;
}
}
/********************************************************************/ /********************************************************************/
/*********************** Override functions ************************/ /*********************** Override functions ************************/
/********************************************************************/ /********************************************************************/
@ -619,6 +595,10 @@ void CGLView::resizeGL(int pWidth, int pHeight)
} }
void CGLView::drawCoordSystem() { void CGLView::drawCoordSystem() {
// Disable lighting. Colors must be bright and colorful)
if ( mLightingEnabled ) glDisable( GL_LIGHTING );///TODO: display list
// For same reason - disable textures.
glBindTexture(GL_TEXTURE_1D, 0); glBindTexture(GL_TEXTURE_1D, 0);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_3D, 0); glBindTexture(GL_TEXTURE_3D, 0);
@ -635,6 +615,8 @@ void CGLView::drawCoordSystem() {
qglColor(QColor(Qt::yellow)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, -100000.0); qglColor(QColor(Qt::yellow)), glVertex3f(0.0, 0.0, 0.0), glVertex3f(0.0, 0.0, -100000.0);
qglColor(QColor(Qt::white)); qglColor(QColor(Qt::white));
glEnd(); glEnd();
// Restore previous state of lighting.
if(mLightingEnabled) glEnable(GL_LIGHTING);
} }
void CGLView::paintGL() void CGLView::paintGL()
@ -651,17 +633,12 @@ void CGLView::paintGL()
glTranslatef(-mHelper_Camera.Translation_ToScene.x, -mHelper_Camera.Translation_ToScene.y, -mHelper_Camera.Translation_ToScene.z); glTranslatef(-mHelper_Camera.Translation_ToScene.x, -mHelper_Camera.Translation_ToScene.y, -mHelper_Camera.Translation_ToScene.z);
glMultMatrixf((GLfloat*)&mHelper_Camera.Rotation_Scene); glMultMatrixf((GLfloat*)&mHelper_Camera.Rotation_Scene);
// Coordinate system // Coordinate system
if ( mLightingEnabled ) { if (mScene_AxesEnabled == true)
glDisable( GL_LIGHTING );///TODO: display list
}
if (this->mAxesEnabled == true)
{ {
drawCoordSystem(); drawCoordSystem();
} }
glDisable(GL_COLOR_MATERIAL); glDisable(GL_COLOR_MATERIAL);
if(mLightingEnabled) glEnable(GL_LIGHTING);
// Scene // Scene
if(mScene != nullptr) if(mScene != nullptr)
{ {

View File

@ -75,9 +75,7 @@ private:
}; };
public: public:
bool mAxesEnabled = true;
// Textures
bool mReloadTexturesEnabled = false; // If true then textures will reload when the window is activated.
/// \enum ELightType /// \enum ELightType
/// Type of light source. /// Type of light source.
enum class ELightType { Directional, Point, Spot }; enum class ELightType { Directional, Point, Spot };
@ -146,6 +144,7 @@ private:
SBBox mScene_BBox;///< Bounding box of scene. SBBox mScene_BBox;///< Bounding box of scene.
aiVector3D mScene_Center;///< Coordinates of center of the scene. aiVector3D mScene_Center;///< Coordinates of center of the scene.
bool mScene_DrawBBox = false;///< Flag which control drawing scene BBox. bool mScene_DrawBBox = false;///< Flag which control drawing scene BBox.
bool mScene_AxesEnabled = true;///< Flag which control drawing axes of the coordinate system.
// Meshes // Meshes
size_t mHelper_Mesh_Quantity = 0;///< Quantity of meshes in scene. size_t mHelper_Mesh_Quantity = 0;///< Quantity of meshes in scene.
SHelper_Mesh** mHelper_Mesh = nullptr;///< Array of pointers to helper objects for drawing mesh. Sequence of meshes are equivalent to \ref aiScene::mMeshes. SHelper_Mesh** mHelper_Mesh = nullptr;///< Array of pointers to helper objects for drawing mesh. Sequence of meshes are equivalent to \ref aiScene::mMeshes.
@ -254,7 +253,11 @@ private:
/********************************************************************/ /********************************************************************/
protected: protected:
/// \fn void drawCoordSystem()
/// Draw axes of the coordinate system.
void drawCoordSystem(); void drawCoordSystem();
/// \fn void initializeGL() override /// \fn void initializeGL() override
/// Override function to initialise OpenGL. /// Override function to initialise OpenGL.
void initializeGL() override; void initializeGL() override;
@ -307,11 +310,8 @@ public:
/// \param [in] pEnable - if true then enable textures, false - disable textures. /// \param [in] pEnable - if true then enable textures, false - disable textures.
void Enable_Textures(const bool pEnable); void Enable_Textures(const bool pEnable);
void Enable_Axes(const bool pEnable); ///TODO: doc
/// \fn void Enable_Textures(const bool pEnable) void Enable_Axes(const bool pEnable) { this->mScene_AxesEnabled = pEnable; }
/// Control textures drawing.
/// \param [in] pEnable - if true then enable textures, false - disable textures.
void Enable_Reload_Textures(const bool pEnable);
/********************************************************************/ /********************************************************************/
/******************** Lighting control functions ********************/ /******************** Lighting control functions ********************/

View File

@ -48,7 +48,7 @@ QTime time_begin = QTime::currentTime();
ui->cbxLighting->setChecked(true); mGLView->Lighting_Enable(); ui->cbxLighting->setChecked(true); mGLView->Lighting_Enable();
ui->cbxBBox->setChecked(false); mGLView->Enable_SceneBBox(false); ui->cbxBBox->setChecked(false); mGLView->Enable_SceneBBox(false);
ui->cbxTextures->setChecked(true); mGLView->Enable_Textures(true); ui->cbxTextures->setChecked(true); mGLView->Enable_Textures(true);
ui->cbxReloadTextures->setChecked(true); mGLView->Enable_Reload_Textures(false);
// //
// Fill info labels // Fill info labels
// //
@ -195,13 +195,6 @@ GLfloat step;
/********************************************************************/ /********************************************************************/
/********************** Constructor/Destructor **********************/ /********************** Constructor/Destructor **********************/
/********************************************************************/ /********************************************************************/
bool MainWindow::event(QEvent *e)
{
if (e->type() == QEvent::WindowActivate && this->mGLView->mReloadTexturesEnabled == true) {
qInfo() << "Window Activated";
}
return QWidget::event(e);
}
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow), : QMainWindow(parent), ui(new Ui::MainWindow),
@ -378,12 +371,6 @@ void MainWindow::on_cbxDrawAxes_clicked(bool checked)
mGLView->updateGL(); mGLView->updateGL();
} }
void MainWindow::on_cbxReloadTextures_clicked(bool checked)
{
mGLView->Enable_Reload_Textures(checked);
mGLView->updateGL();
}
void MainWindow::on_cbxTextures_clicked(bool checked) void MainWindow::on_cbxTextures_clicked(bool checked)
{ {
mGLView->Enable_Textures(checked); mGLView->Enable_Textures(checked);

View File

@ -90,7 +90,6 @@ protected:
/// \param [in] pEvent - pointer to event data. /// \param [in] pEvent - pointer to event data.
void keyPressEvent(QKeyEvent* pEvent) override; void keyPressEvent(QKeyEvent* pEvent) override;
bool event(QEvent*);
public: public:
/********************************************************************/ /********************************************************************/
@ -134,5 +133,4 @@ private slots:
void on_cbxBBox_clicked(bool checked); void on_cbxBBox_clicked(bool checked);
void on_cbxTextures_clicked(bool checked); void on_cbxTextures_clicked(bool checked);
void on_cbxDrawAxes_clicked(bool checked); void on_cbxDrawAxes_clicked(bool checked);
void on_cbxReloadTextures_clicked(bool checked);
}; };