Removed old lab 1 code

This commit is contained in:
Riku Avelar 2016-10-28 16:42:51 -04:00
parent 0977688583
commit f72cdda386
3 changed files with 11 additions and 75 deletions

View File

@ -100,7 +100,7 @@ void Viewer::draw()
// Traverse the Scene in order to draw its components
modelStack.push(modelViewMatrix);
root.accept(*this);
//root.accept(*this);
}
void Viewer::mouseMoveEvent(QMouseEvent* e) {
@ -110,6 +110,8 @@ void Viewer::mouseMoveEvent(QMouseEvent* e) {
}
void Viewer::mousePressEvent(QMouseEvent* e) {
// Auto Return, but old code left in as reference
return;
cout << "Viewer::mouseMoveEvent(QMouseEvent* e) : " << e->button() << endl;
@ -203,12 +205,12 @@ void Viewer::mouseReleaseEvent(QMouseEvent* e) {
void Viewer::init()
{
// We want to restrict ourselves to a 2D viewer.
camera()->setType(qglviewer::Camera::ORTHOGRAPHIC);
//camera()->setType(qglviewer::Camera::ORTHOGRAPHIC);
/*setMouseBinding(Qt::NoModifier, Qt::LeftButton, CAMERA, SCREEN_ROTATE);
setMouseBinding(Qt::AltModifier, Qt::LeftButton, CAMERA, NO_MOUSE_ACTION);*/
setMouseBinding(Qt::NoModifier, Qt::MouseButton(Qt::LeftButton + Qt::MidButton), CAMERA, NO_MOUSE_ACTION);
setMouseBinding(Qt::ControlModifier, Qt::MouseButton(Qt::LeftButton + Qt::MidButton), CAMERA, NO_MOUSE_ACTION);
setMouseBinding(Qt::ShiftModifier, Qt::MouseButton(Qt::LeftButton + Qt::MidButton), CAMERA, NO_MOUSE_ACTION);
// setMouseBinding(Qt::NoModifier, Qt::MouseButton(Qt::LeftButton + Qt::MidButton), CAMERA, NO_MOUSE_ACTION);
// setMouseBinding(Qt::ControlModifier, Qt::MouseButton(Qt::LeftButton + Qt::MidButton), CAMERA, NO_MOUSE_ACTION);
// setMouseBinding(Qt::ShiftModifier, Qt::MouseButton(Qt::LeftButton + Qt::MidButton), CAMERA, NO_MOUSE_ACTION);
// Our scene will be from -5 to 5 in X and Y (the grid will be 10x10).
setSceneRadius(5);
@ -220,8 +222,8 @@ void Viewer::init()
// Init shaders & geometry
initShaders();
initGeometries();
initGrid();
initGeometries();
//initGrid();
}
void Viewer::initShaders()
@ -325,30 +327,6 @@ void Viewer::initGeometries()
glEnableVertexAttribArray(m_vPositionLocation);
}
void Viewer::initGrid()
{
// Prepare construction loop. Also contains necessary translations
int i,j, limit;
limit = GRID_SIZE;
for(i = 0; i < limit ; i++) {
SceneGroup *row = new SceneGroup();
row->transform.translate(0, inc_offset * i);
for(j = 0; j < limit ; j++) {
SceneGroup *cell = new SceneGroup();
cell->transform.translate(inc_offset * j, 0);
row->addChild(cell);
}
root.addChild(row);
}
}
void Viewer::visit(Square &s)
{
QMatrix4x4 modelViewMatrix = modelStack.top() * QMatrix4x4(s.transform);
@ -406,39 +384,3 @@ void Viewer::changeColor(QColor c){
activeColor = new QColor(c);
this->update();
}
void Viewer::changeShape(int s){
std::cout << "Chaging active shape from " << activeShape << " to " << s << endl;
if(activeCell != nullptr && activeCell->getChildren()->size()){
std::cout << "Chaging cell-bound shape... " << endl;
Shape* shape = dynamic_cast<Shape*> (activeCell->childAt(0));
QColor c = shape->getColor();
// WARNING: CODE DEGEULASSE
Shape* newShape = nullptr;
if(s == 1){
newShape = new Triangle();
}else if(s == 2){
newShape = new Square();
}else if(s == 3){
newShape = new Circle();
}
if(newShape != nullptr){
newShape->setColor(c);
activeCell->getChildren()->at(0) = newShape;
}else{
activeCell->getChildren()->clear();
}
// WARNING: END OF CODE DEGEULASSE
this->update();
}else{
std::cout << "Cell has no children, ignoring change." << endl;
}
activeShape = s;
};

View File

@ -50,8 +50,7 @@ public:
public slots:
void cleanup();
void changeColor(QColor);
void changeShape(int);
void changeColor(QColor);
signals:
int shapeSelected(int);
@ -69,8 +68,7 @@ protected :
private:
void initShaders();
void initGeometries();
void initGrid();
void initGeometries();
void deselect();
QOpenGLShaderProgram *m_program;

View File

@ -24,10 +24,6 @@ void MainWindow::addViewer(Viewer* viewer)
layout->addWidget(viewer);
ui->frame->setLayout(layout);
connect(colordialog, SIGNAL(colorSelected(QColor)), viewer, SLOT(changeColor(QColor)));
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), viewer, SLOT(changeShape(int)));
connect(viewer, SIGNAL(shapeSelected(int)), ui->comboBox, SLOT(setCurrentIndex(int)));
}
void MainWindow::onColorPickerActivate(){