mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
Rotation and Toggle Normals
This commit is contained in:
parent
e3b690b42d
commit
1a04dd8db3
@ -63,6 +63,26 @@
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="cw_x">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-X</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="ccw_x">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>+X</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@ -70,18 +90,15 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="action_delete">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="text">
|
||||
<string>Delete Cube</string>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
@ -107,6 +124,13 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Forme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -120,12 +144,18 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Forme</string>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
@ -140,13 +170,43 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="action_delete">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="ccw_y">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete Cube</string>
|
||||
<string>+Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="cw_y">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="ccw_z">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>+Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="cw_z">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -236,8 +236,6 @@ void Viewer::mousePressEvent(QMouseEvent* e) {
|
||||
selectedObj.shape = selectedGeom.shape;
|
||||
selectedObj.shape->getParent()->addChild(selection);
|
||||
cubeSelected(true);
|
||||
|
||||
rotateSelected(X_CCW);
|
||||
}
|
||||
|
||||
if(!selectedGeom.position.isIdentity() && e->modifiers().testFlag(Qt::ShiftModifier))
|
||||
@ -847,6 +845,13 @@ void Viewer::toggleNormalMaps(bool state) {
|
||||
}
|
||||
|
||||
void Viewer::deleteSelected() {
|
||||
m_program->bind();
|
||||
int pointCLocs[3] = {m_c1Loc, m_c2Loc, m_c3Loc};
|
||||
|
||||
m_program->setUniformValue(pointCLocs[0], QColor(0,0,0));
|
||||
m_program->setUniformValue(pointCLocs[1], QColor(0,0,0));
|
||||
m_program->setUniformValue(pointCLocs[2], QColor(0,0,0));
|
||||
|
||||
// Remove Shape from its parent
|
||||
if(selectedObj.shape == nullptr) return;
|
||||
// selectedObj.shape->getParent()->getChildren()->erase(
|
||||
@ -887,6 +892,24 @@ void Viewer::startAniumation(){}
|
||||
|
||||
void Viewer::stopAnimation(){}
|
||||
|
||||
void Viewer::rotateSelectedObjXCCW() {
|
||||
rotateSelected(RotateDirection::X_CCW);
|
||||
}
|
||||
void Viewer::rotateSelectedObjXCW() {
|
||||
rotateSelected(RotateDirection::X_CW);
|
||||
}
|
||||
void Viewer::rotateSelectedObjYCCW() {
|
||||
rotateSelected(RotateDirection::Y_CCW);
|
||||
}
|
||||
void Viewer::rotateSelectedObjYCW() {
|
||||
rotateSelected(RotateDirection::Y_CW);
|
||||
}
|
||||
void Viewer::rotateSelectedObjZCCW() {
|
||||
rotateSelected(RotateDirection::Z_CCW);
|
||||
}
|
||||
void Viewer::rotateSelectedObjZCW() {
|
||||
rotateSelected(RotateDirection::Z_CW);
|
||||
}
|
||||
|
||||
void Viewer::rotateSelected(RotateDirection dir) {
|
||||
if(selectedObj.shape == nullptr || selectedObj.shape->getParent() == nullptr) return;
|
||||
|
||||
@ -56,6 +56,17 @@ public:
|
||||
virtual void visit(Cube &s);
|
||||
virtual void visit(Sphere &s);
|
||||
|
||||
|
||||
|
||||
enum RotateDirection {
|
||||
X_CCW,
|
||||
X_CW,
|
||||
Y_CCW,
|
||||
Y_CW,
|
||||
Z_CCW,
|
||||
Z_CW
|
||||
};
|
||||
|
||||
public slots:
|
||||
void cleanup();
|
||||
void changeColor(QColor);
|
||||
@ -64,6 +75,12 @@ public slots:
|
||||
void setMinLinear(bool);
|
||||
void deleteSelected();
|
||||
void toggleNormalMaps(bool);
|
||||
void rotateSelectedObjXCCW();
|
||||
void rotateSelectedObjXCW();
|
||||
void rotateSelectedObjYCCW();
|
||||
void rotateSelectedObjYCW();
|
||||
void rotateSelectedObjZCCW();
|
||||
void rotateSelectedObjZCW();
|
||||
|
||||
signals:
|
||||
int shapeSelected(int);
|
||||
@ -156,15 +173,6 @@ private:
|
||||
|
||||
Shape* generateShapeFromIndex(int);
|
||||
|
||||
enum RotateDirection {
|
||||
X_CCW,
|
||||
X_CW,
|
||||
Y_CCW,
|
||||
Y_CW,
|
||||
Z_CCW,
|
||||
Z_CW
|
||||
};
|
||||
|
||||
enum Textures{
|
||||
TEX_DRYGOUND,
|
||||
TEX_GRANITEFLOOR,
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <QBoxLayout>
|
||||
#include <QColorDialog>
|
||||
#include <QActionGroup>
|
||||
#include <QButtonGroup>
|
||||
|
||||
namespace {
|
||||
Viewer* view;
|
||||
@ -27,6 +28,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
magFilterGroup->addAction(ui->actionMagLinear);
|
||||
magFilterGroup->addAction(ui->actionMagNear);
|
||||
|
||||
controlGroup = new QButtonGroup(this);
|
||||
controlGroup->addButton(ui->action_delete);
|
||||
controlGroup->addButton(ui->ccw_x);
|
||||
controlGroup->addButton(ui->cw_x);
|
||||
controlGroup->addButton(ui->ccw_y);
|
||||
controlGroup->addButton(ui->cw_y);
|
||||
controlGroup->addButton(ui->ccw_z);
|
||||
controlGroup->addButton(ui->cw_z);
|
||||
|
||||
|
||||
connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(onColorPickerActivate()));
|
||||
}
|
||||
|
||||
@ -49,7 +60,21 @@ void MainWindow::addViewer(Viewer* viewer)
|
||||
connect(ui->actionNormal_Maps, SIGNAL(toggled(bool)), viewer, SLOT(toggleNormalMaps(bool)));
|
||||
|
||||
connect(ui->action_delete, SIGNAL(clicked(bool)), viewer, SLOT(deleteSelected()));
|
||||
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->action_delete, SLOT(setEnabled(bool)));
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->ccw_x, SLOT(setEnabled(bool)));
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->cw_x, SLOT(setEnabled(bool)));
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->ccw_y, SLOT(setEnabled(bool)));
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->cw_y, SLOT(setEnabled(bool)));
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->ccw_z, SLOT(setEnabled(bool)));
|
||||
connect(viewer, SIGNAL(cubeSelected(bool)), ui->cw_z, SLOT(setEnabled(bool)));
|
||||
|
||||
connect(ui->ccw_x, SIGNAL(clicked(bool)), viewer, SLOT(rotateSelectedObjXCCW()));
|
||||
connect(ui->cw_x, SIGNAL(clicked(bool)), viewer, SLOT(rotateSelectedObjXCW()));
|
||||
connect(ui->ccw_y, SIGNAL(clicked(bool)), viewer, SLOT(rotateSelectedObjYCCW()));
|
||||
connect(ui->cw_y, SIGNAL(clicked(bool)), viewer, SLOT(rotateSelectedObjYCW()));
|
||||
connect(ui->ccw_z, SIGNAL(clicked(bool)), viewer, SLOT(rotateSelectedObjZCCW()));
|
||||
connect(ui->cw_z, SIGNAL(clicked(bool)), viewer, SLOT(rotateSelectedObjZCW()));
|
||||
}
|
||||
|
||||
void MainWindow::onColorPickerActivate(){
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <QMainWindow>
|
||||
#include <QColorDialog>
|
||||
#include <QActionGroup>
|
||||
#include <QButtonGroup>
|
||||
#include "src/viewer/simpleViewer.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -30,6 +31,7 @@ private:
|
||||
QActionGroup *lightTypeGroup;
|
||||
QActionGroup *minFilterGroup;
|
||||
QActionGroup *magFilterGroup;
|
||||
QButtonGroup *controlGroup;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user