Commit f70eb5ee by Alisa Jung

added deleting selected primitive.

parent 503545c5
......@@ -233,7 +233,7 @@ void Controller::addBox(){
}
void Controller::addCylinder(){
currentTransform = scene->addCylinder(tesselation);
currentTransform = scene->addCylinder(tesselation);
}
void Controller::addCone(){
......@@ -243,3 +243,9 @@ void Controller::addCone(){
void Controller::addTorus(){
currentTransform = scene->addTorus(tesselation);
}
void Controller::deletePrimitive(){
qDebug("try deleting");
if (currentTransform) currentTransform = scene->deleteNode(currentTransform);
else qDebug("nothing selected. Did not call delete on scenegraph");
}
......@@ -86,6 +86,7 @@ public slots:
void addCylinder();
void addCone();
void addTorus();
void deletePrimitive();
};
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-11-21T20:37:36. -->
<!-- Written by QtCreator 3.5.1, 2015-11-21T20:51:27. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
......@@ -11,6 +11,7 @@
<file>grapa-a2-iconset/camera.png</file>
<file>grapa-a2-iconset/cone.png</file>
<file>grapa-a2-iconset/cylinder.png</file>
<file>grapa-a2-iconset/delete.png</file>
<file>grapa-a2-iconset/select.png</file>
<file>grapa-a2-iconset/sphere.png</file>
<file>grapa-a2-iconset/torus.png</file>
......
......@@ -210,18 +210,21 @@ MainWindow::MainWindow(QWidget *parent)
addCylinder = new QAction("Add Cylinder", toolBar);
addCone = new QAction("Add Cone", toolBar);
addTorus = new QAction("Add Torus", toolBar);
deletePrimitive = new QAction("Delete", toolBar);
addSphere->setIcon(QIcon(":/grapa-a2-iconset/sphere.png"));
addBox->setIcon(QIcon(":/grapa-a2-iconset/box.png"));
addCylinder->setIcon(QIcon(":/grapa-a2-iconset/cylinder.png"));
addCone->setIcon(QIcon(":/grapa-a2-iconset/cone.png"));
addTorus->setIcon(QIcon(":/grapa-a2-iconset/torus.png"));
deletePrimitive->setIcon(QIcon(":/grapa-a2-iconset/delete.png"));
addSphere->setCheckable(false);
addBox->setCheckable(false);
addCylinder->setCheckable(false);
addCone->setCheckable(false);
addTorus->setCheckable(false);
deletePrimitive->setCheckable(false);
toolBar->addAction(addSphere);
toolBar->insertSeparator(addSphere);
......@@ -229,12 +232,14 @@ MainWindow::MainWindow(QWidget *parent)
toolBar->addAction(addCylinder);
toolBar->addAction(addCone);
toolBar->addAction(addTorus);
toolBar->addAction(deletePrimitive);
connect(addSphere, SIGNAL(triggered(bool)),controller, SLOT(addSphere()));
connect(addBox, SIGNAL(triggered(bool)),controller, SLOT(addBox()));
connect(addCylinder, SIGNAL(triggered(bool)),controller, SLOT(addCylinder()));
connect(addCone, SIGNAL(triggered(bool)),controller, SLOT(addCone()));
connect(addTorus, SIGNAL(triggered(bool)),controller, SLOT(addTorus()));
connect(deletePrimitive, SIGNAL(triggered(bool)),controller, SLOT(deletePrimitive()));
}
......
......@@ -85,6 +85,8 @@ private:
QAction* addCone;
QAction* addTorus;
QAction* deletePrimitive;
public slots :
void showAboutBox ( ) ;
};
......
......@@ -8,6 +8,10 @@ RigidBodyTransformation::RigidBodyTransformation(Primitive* child)
// qDebug() << "new rbt " << tx << "," << ty << "," << tz << ", rot " << rotation;
}
RigidBodyTransformation::~RigidBodyTransformation(){
child->~Primitive();
}
void RigidBodyTransformation::addTranslation(QVector3D diff){
translation += diff;
......
......@@ -8,6 +8,7 @@ class RigidBodyTransformation
{
public:
RigidBodyTransformation(Primitive* child);
~RigidBodyTransformation();
void addTranslation(QVector3D diff);
void setRotation(QQuaternion newRotation);
......
......@@ -78,6 +78,19 @@ RigidBodyTransformation* SceneGraph::addPrimitive(Primitive* p){
return r;
}
RigidBodyTransformation* SceneGraph::deleteNode(RigidBodyTransformation *r){
if (r == 0){
qDebug("transform already 0");
return 0;
}
bool s = nodes.removeOne(r);
if (!s) qDebug("could not remove this. Delete r anyways.");
r->~RigidBodyTransformation();
notifyViews();
if (nodes.length() > 0) return nodes.back();
else return 0;
}
//transform something
void SceneGraph::addRotation(RigidBodyTransformation *r, QQuaternion diff){
r->addRotation(diff);
......
......@@ -26,6 +26,9 @@ public:
const QList<RigidBodyTransformation*> getGraph();
//automatically selects last added primitive. if none left, selects 0.
RigidBodyTransformation* deleteNode(RigidBodyTransformation* r);
//Hallo. Todos:
//Log selected name in status bar
//add remaining primitive types
......
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