Commit 343154d7 by Alisa Jung

button to show/hide grid

parent 46873760
...@@ -18,5 +18,6 @@ ...@@ -18,5 +18,6 @@
<file>grapa-a2-iconset/view-dual.png</file> <file>grapa-a2-iconset/view-dual.png</file>
<file>grapa-a2-iconset/viewports.png</file> <file>grapa-a2-iconset/viewports.png</file>
<file>grapa-a2-iconset/view-single.png</file> <file>grapa-a2-iconset/view-single.png</file>
<file>grapa-a2-iconset/gridIcon.png</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -220,6 +220,12 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -220,6 +220,12 @@ MainWindow::MainWindow(QWidget *parent)
} }
showGridButton = new QToolButton(toolBar);
showGridButton->setIcon(QIcon(":/grapa-a2-iconset/gridIcon.png"));
toolBar->addWidget(showGridButton);
showGridButton->setCheckable(true);
gridSizeInput = new QSpinBox(toolBar); gridSizeInput = new QSpinBox(toolBar);
gridSizeInput->setRange(0,100); gridSizeInput->setRange(0,100);
gridSizeInput->setValue(5); gridSizeInput->setValue(5);
...@@ -231,9 +237,13 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -231,9 +237,13 @@ MainWindow::MainWindow(QWidget *parent)
toolBar->addWidget(gridStepInput); toolBar->addWidget(gridStepInput);
gridStepInput->setToolTip("Grid Step Size"); gridStepInput->setToolTip("Grid Step Size");
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
connect(gridSizeInput,SIGNAL(valueChanged(int)),allWidgets[i],SLOT(setGridSize(int))); connect(gridSizeInput,SIGNAL(valueChanged(int)),allWidgets[i],SLOT(setGridSize(int)));
connect(gridStepInput,SIGNAL(valueChanged(int)),allWidgets[i],SLOT(setGridStepSize(int))); connect(gridStepInput,SIGNAL(valueChanged(int)),allWidgets[i],SLOT(setGridStepSize(int)));
connect(showGridButton,SIGNAL(clicked(bool)),allWidgets[i],SLOT(showGrid(bool)));
} }
qDebug("Done initializing"); qDebug("Done initializing");
......
...@@ -95,6 +95,7 @@ private: ...@@ -95,6 +95,7 @@ private:
QSpinBox* gridSizeInput; QSpinBox* gridSizeInput;
QSpinBox* gridStepInput; QSpinBox* gridStepInput;
QToolButton* showGridButton;
public slots : public slots :
void showAboutBox ( ) ; void showAboutBox ( ) ;
......
...@@ -24,6 +24,7 @@ MyGLWidget::MyGLWidget(int index, Controller* c, bool isPerspective, QQuaternion ...@@ -24,6 +24,7 @@ MyGLWidget::MyGLWidget(int index, Controller* c, bool isPerspective, QQuaternion
gridSize = 5; gridSize = 5;
gridStepSize = 1; gridStepSize = 1;
doShowGrid = false;
} }
MyGLWidget::~MyGLWidget() MyGLWidget::~MyGLWidget()
...@@ -593,6 +594,7 @@ void MyGLWidget::drawTorus(int tesselation){ ...@@ -593,6 +594,7 @@ void MyGLWidget::drawTorus(int tesselation){
} }
void MyGLWidget::drawGrid(){ void MyGLWidget::drawGrid(){
if (!doShowGrid) return;
GLfloat specularColor[] = {0,0,0}; GLfloat specularColor[] = {0,0,0};
GLfloat shininess[] = {128}; GLfloat shininess[] = {128};
glMaterialfv(GL_FRONT,GL_SPECULAR,specularColor); glMaterialfv(GL_FRONT,GL_SPECULAR,specularColor);
...@@ -656,3 +658,8 @@ void MyGLWidget::setGridStepSize(int stepSize){ ...@@ -656,3 +658,8 @@ void MyGLWidget::setGridStepSize(int stepSize){
gridStepSize = stepSize; gridStepSize = stepSize;
updateGL(); updateGL();
} }
void MyGLWidget::showGrid(bool doShowGrid){
this->doShowGrid = doShowGrid;
updateGL();
}
...@@ -106,11 +106,13 @@ private: ...@@ -106,11 +106,13 @@ private:
int gridSize; int gridSize;
int gridStepSize; int gridStepSize;
bool doShowGrid;
public slots: public slots:
//4.1.1 slots for shading modes //4.1.1 slots for shading modes
void resetCamera(); void resetCamera();
void setGridSize(int size); void setGridSize(int size);
void setGridStepSize(int stepSize); void setGridStepSize(int stepSize);
void showGrid(bool doShowGrid);
}; };
#endif // GLWIDGET_H #endif // GLWIDGET_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment