Commit 343154d7 by Alisa Jung

button to show/hide grid

parent 46873760
......@@ -18,5 +18,6 @@
<file>grapa-a2-iconset/view-dual.png</file>
<file>grapa-a2-iconset/viewports.png</file>
<file>grapa-a2-iconset/view-single.png</file>
<file>grapa-a2-iconset/gridIcon.png</file>
</qresource>
</RCC>
......@@ -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->setRange(0,100);
gridSizeInput->setValue(5);
......@@ -231,9 +237,13 @@ MainWindow::MainWindow(QWidget *parent)
toolBar->addWidget(gridStepInput);
gridStepInput->setToolTip("Grid Step Size");
for(int i = 0; i < 4; i++){
connect(gridSizeInput,SIGNAL(valueChanged(int)),allWidgets[i],SLOT(setGridSize(int)));
connect(gridStepInput,SIGNAL(valueChanged(int)),allWidgets[i],SLOT(setGridStepSize(int)));
connect(showGridButton,SIGNAL(clicked(bool)),allWidgets[i],SLOT(showGrid(bool)));
}
qDebug("Done initializing");
......
......@@ -95,6 +95,7 @@ private:
QSpinBox* gridSizeInput;
QSpinBox* gridStepInput;
QToolButton* showGridButton;
public slots :
void showAboutBox ( ) ;
......
......@@ -24,6 +24,7 @@ MyGLWidget::MyGLWidget(int index, Controller* c, bool isPerspective, QQuaternion
gridSize = 5;
gridStepSize = 1;
doShowGrid = false;
}
MyGLWidget::~MyGLWidget()
......@@ -593,6 +594,7 @@ void MyGLWidget::drawTorus(int tesselation){
}
void MyGLWidget::drawGrid(){
if (!doShowGrid) return;
GLfloat specularColor[] = {0,0,0};
GLfloat shininess[] = {128};
glMaterialfv(GL_FRONT,GL_SPECULAR,specularColor);
......@@ -656,3 +658,8 @@ void MyGLWidget::setGridStepSize(int stepSize){
gridStepSize = stepSize;
updateGL();
}
void MyGLWidget::showGrid(bool doShowGrid){
this->doShowGrid = doShowGrid;
updateGL();
}
......@@ -106,11 +106,13 @@ private:
int gridSize;
int gridStepSize;
bool doShowGrid;
public slots:
//4.1.1 slots for shading modes
void resetCamera();
void setGridSize(int size);
void setGridStepSize(int stepSize);
void showGrid(bool doShowGrid);
};
#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