mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-25 12:01:21 +00:00
Removed old lab 1 code
This commit is contained in:
parent
0977688583
commit
f72cdda386
@ -100,7 +100,7 @@ void Viewer::draw()
|
|||||||
// Traverse the Scene in order to draw its components
|
// Traverse the Scene in order to draw its components
|
||||||
|
|
||||||
modelStack.push(modelViewMatrix);
|
modelStack.push(modelViewMatrix);
|
||||||
root.accept(*this);
|
//root.accept(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::mouseMoveEvent(QMouseEvent* e) {
|
void Viewer::mouseMoveEvent(QMouseEvent* e) {
|
||||||
@ -110,6 +110,8 @@ void Viewer::mouseMoveEvent(QMouseEvent* e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::mousePressEvent(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;
|
cout << "Viewer::mouseMoveEvent(QMouseEvent* e) : " << e->button() << endl;
|
||||||
|
|
||||||
@ -203,12 +205,12 @@ void Viewer::mouseReleaseEvent(QMouseEvent* e) {
|
|||||||
void Viewer::init()
|
void Viewer::init()
|
||||||
{
|
{
|
||||||
// We want to restrict ourselves to a 2D viewer.
|
// 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::NoModifier, Qt::LeftButton, CAMERA, SCREEN_ROTATE);
|
||||||
setMouseBinding(Qt::AltModifier, Qt::LeftButton, CAMERA, NO_MOUSE_ACTION);*/
|
setMouseBinding(Qt::AltModifier, Qt::LeftButton, CAMERA, NO_MOUSE_ACTION);*/
|
||||||
setMouseBinding(Qt::NoModifier, 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::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::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).
|
// Our scene will be from -5 to 5 in X and Y (the grid will be 10x10).
|
||||||
setSceneRadius(5);
|
setSceneRadius(5);
|
||||||
@ -220,8 +222,8 @@ void Viewer::init()
|
|||||||
|
|
||||||
// Init shaders & geometry
|
// Init shaders & geometry
|
||||||
initShaders();
|
initShaders();
|
||||||
initGeometries();
|
initGeometries();
|
||||||
initGrid();
|
//initGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::initShaders()
|
void Viewer::initShaders()
|
||||||
@ -325,30 +327,6 @@ void Viewer::initGeometries()
|
|||||||
glEnableVertexAttribArray(m_vPositionLocation);
|
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)
|
void Viewer::visit(Square &s)
|
||||||
{
|
{
|
||||||
QMatrix4x4 modelViewMatrix = modelStack.top() * QMatrix4x4(s.transform);
|
QMatrix4x4 modelViewMatrix = modelStack.top() * QMatrix4x4(s.transform);
|
||||||
@ -406,39 +384,3 @@ void Viewer::changeColor(QColor c){
|
|||||||
activeColor = new QColor(c);
|
activeColor = new QColor(c);
|
||||||
this->update();
|
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;
|
|
||||||
};
|
|
||||||
|
|||||||
@ -50,8 +50,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void changeColor(QColor);
|
void changeColor(QColor);
|
||||||
void changeShape(int);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
int shapeSelected(int);
|
int shapeSelected(int);
|
||||||
@ -69,8 +68,7 @@ protected :
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void initShaders();
|
void initShaders();
|
||||||
void initGeometries();
|
void initGeometries();
|
||||||
void initGrid();
|
|
||||||
void deselect();
|
void deselect();
|
||||||
|
|
||||||
QOpenGLShaderProgram *m_program;
|
QOpenGLShaderProgram *m_program;
|
||||||
|
|||||||
@ -24,10 +24,6 @@ void MainWindow::addViewer(Viewer* viewer)
|
|||||||
layout->addWidget(viewer);
|
layout->addWidget(viewer);
|
||||||
ui->frame->setLayout(layout);
|
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(){
|
void MainWindow::onColorPickerActivate(){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user