Commit 11a73823 by Alisa Jung

display name of currently selected primitive in statusbar

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