Commit 11a73823 by Alisa Jung

display name of currently selected primitive in statusbar

parent f000cfdd
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
#include "myglwidget.h" #include "myglwidget.h"
#include "scenegraph.h" #include "scenegraph.h"
Controller::Controller() Controller::Controller(QStatusBar* bar)
{ {
statusBar = bar;
modeCamera = true; modeCamera = true;
currentWidgetIndex = 0; currentWidgetIndex = 0;
scene = new SceneGraph(); scene = new SceneGraph();
currentTransform = 0;
tesselation = 1; tesselation = 1;
selectTransform(0);
} }
Controller::~Controller(){ Controller::~Controller(){
...@@ -225,27 +226,37 @@ QQuaternion Controller::computeRotation(QPoint newPosition){ ...@@ -225,27 +226,37 @@ QQuaternion Controller::computeRotation(QPoint newPosition){
} }
void Controller::addSphere(){ void Controller::addSphere(){
currentTransform = scene->addSphere(tesselation); selectTransform(scene->addSphere(tesselation));
} }
void Controller::addBox(){ void Controller::addBox(){
currentTransform = scene->addBox(tesselation); selectTransform(scene->addBox(tesselation));
} }
void Controller::addCylinder(){ void Controller::addCylinder(){
currentTransform = scene->addCylinder(tesselation); selectTransform(scene->addCylinder(tesselation));
} }
void Controller::addCone(){ void Controller::addCone(){
currentTransform = scene->addCone(tesselation); selectTransform(scene->addCone(tesselation));
} }
void Controller::addTorus(){ void Controller::addTorus(){
currentTransform = scene->addTorus(tesselation); selectTransform(scene->addTorus(tesselation));
} }
void Controller::deletePrimitive(){ void Controller::deletePrimitive(){
qDebug("try deleting"); qDebug("try deleting");
if (currentTransform) currentTransform = scene->deleteNode(currentTransform); if (currentTransform) selectTransform(scene->deleteNode(currentTransform));
else qDebug("nothing selected. Did not call delete on scenegraph"); else qDebug("nothing selected. Did not call delete on scenegraph");
} }
void Controller::selectTransform(RigidBodyTransformation *rbt){
currentTransform = rbt;
if (currentTransform){
statusBar->showMessage(currentTransform->getChild()->getName());
}
else {
statusBar->showMessage("None selected");
}
}
...@@ -27,7 +27,7 @@ class Controller : public QObject ...@@ -27,7 +27,7 @@ class Controller : public QObject
Q_OBJECT Q_OBJECT
public: public:
Controller(); Controller(QStatusBar* bar);
~Controller(); ~Controller();
void initActions(QAction* cam, QAction* manipulate); void initActions(QAction* cam, QAction* manipulate);
...@@ -51,6 +51,8 @@ private: ...@@ -51,6 +51,8 @@ private:
QAction *modeManipulateAction; QAction *modeManipulateAction;
int currentWidgetIndex; int currentWidgetIndex;
//Status Bar
QStatusBar *statusBar;
QWidget* quadViewWidget; QWidget* quadViewWidget;
QWidget* doubleViewWidget; QWidget* doubleViewWidget;
...@@ -72,6 +74,8 @@ private: ...@@ -72,6 +74,8 @@ private:
SceneGraph* scene; SceneGraph* scene;
void selectTransform(RigidBodyTransformation* rbt);
public slots: public slots:
void switchToModeCamera(); void switchToModeCamera();
void switchToModeManipulate(); void switchToModeManipulate();
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-11-21T21:01:34. --> <!-- Written by QtCreator 3.5.1, 2015-11-21T21:18:46. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
......
...@@ -78,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -78,7 +78,7 @@ MainWindow::MainWindow(QWidget *parent)
//4.0 Widget //Assignment 2: Multiple Widgets. //4.0 Widget //Assignment 2: Multiple Widgets.
qDebug("widgets..."); qDebug("widgets...");
{ {
controller = new Controller(); controller = new Controller(statusBar);
myGLWidget = new MyGLWidget(0,controller, true, QQuaternion(),this); myGLWidget = new MyGLWidget(0,controller, true, QQuaternion(),this);
setCentralWidget(myGLWidget); setCentralWidget(myGLWidget);
......
...@@ -21,7 +21,8 @@ void SceneGraph::registerView(MyGLWidget* view){ ...@@ -21,7 +21,8 @@ void SceneGraph::registerView(MyGLWidget* view){
//add primitives to sceneGraph //add primitives to sceneGraph
RigidBodyTransformation* SceneGraph::addSphere(int tesselation){ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
nextSphereName = "Sphere " + sphereIndex; nextSphereName = "Sphere ";
nextSphereName.append(QString::number(sphereIndex));
//tesselation < 3 makes no sense (except for box) //tesselation < 3 makes no sense (except for box)
int t = tesselation; int t = tesselation;
if (t < 3) t = 3; if (t < 3) t = 3;
...@@ -36,7 +37,8 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){ ...@@ -36,7 +37,8 @@ RigidBodyTransformation* SceneGraph::addSphere(int tesselation){
RigidBodyTransformation* SceneGraph::addBox(int tesselation){ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
nextBoxName = "Box " + boxIndex; nextBoxName = "Box ";
nextBoxName.append(QString::number(boxIndex));
Primitive* p = new Primitive(idCounter, nextBoxName, tesselation, Primitive::Type::BOX); Primitive* p = new Primitive(idCounter, nextBoxName, tesselation, Primitive::Type::BOX);
idCounter++; idCounter++;
boxIndex++; boxIndex++;
...@@ -47,7 +49,8 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){ ...@@ -47,7 +49,8 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
} }
RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
nextCylName = "Cylinder " + cylIndex; nextCylName = "Cylinder ";
nextCylName.append(QString::number(cylIndex));
int t = tesselation; int t = tesselation;
if (t < 3) t = 3; if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter,nextCylName, t, Primitive::Type::CYLINDER); Primitive* p = new Primitive(idCounter,nextCylName, t, Primitive::Type::CYLINDER);
...@@ -59,7 +62,8 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){ ...@@ -59,7 +62,8 @@ RigidBodyTransformation* SceneGraph::addCylinder(int tesselation){
RigidBodyTransformation* SceneGraph::addCone(int tesselation){ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
nextConeName = "Cone " + coneIndex; nextConeName = "Cone ";
nextConeName.append(QString::number(coneIndex));
int t = tesselation; int t = tesselation;
if (t < 3) t = 3; if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter,nextConeName, t, Primitive::Type::CONE); Primitive* p = new Primitive(idCounter,nextConeName, t, Primitive::Type::CONE);
...@@ -70,7 +74,8 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){ ...@@ -70,7 +74,8 @@ RigidBodyTransformation* SceneGraph::addCone(int tesselation){
RigidBodyTransformation* SceneGraph::addTorus(int tesselation){ RigidBodyTransformation* SceneGraph::addTorus(int tesselation){
nextTorusName = "Torus " + torusIndex; nextTorusName = "Torus ";
nextTorusName.append(QString::number(torusIndex));
int t = tesselation; int t = tesselation;
if (t < 3) t = 3; if (t < 3) t = 3;
Primitive* p = new Primitive(idCounter,nextTorusName, t, Primitive::Type::TORUS); Primitive* p = new Primitive(idCounter,nextTorusName, t, Primitive::Type::TORUS);
......
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