Commit 38138692 by Alisa Jung

fixed delete bug

parent 10d649c3
...@@ -264,8 +264,11 @@ void Controller::selectTransform(RigidBodyTransformation *rbt){ ...@@ -264,8 +264,11 @@ void Controller::selectTransform(RigidBodyTransformation *rbt){
void Controller::itemSelected(QModelIndex q){ void Controller::itemSelected(QModelIndex q){
qDebug() << "item selected. Row: " << q.row() << ", column: " << q.column(); qDebug() << "item selected. Row: " << q.row() << ", column: " << q.column();
qDebug("try to retrieve rbt"); TreeItem* t = scene->getItem(q);
TreeItem* t = scene->getItem(q); if (t->getChildrenCount() == 0) {
if (t->childNumber() == 0) t = t->getParent(); qDebug() << "Clicked item " << t->data(0) << " is leaf. get parent transform.";
selectTransform(static_cast<RigidBodyTransformation*>(t)); t = t->getParent();//Primitive haben keine Kinder.
}
selectTransform(static_cast<RigidBodyTransformation*>(t));
qDebug() << "selected name " << t->data(0);
} }
...@@ -173,7 +173,6 @@ void MyGLWidget::paintGL(){ ...@@ -173,7 +173,6 @@ void MyGLWidget::paintGL(){
Primitive* p = (*i)->getChildPrimitive(); Primitive* p = (*i)->getChildPrimitive();
int tesselation = p->getTesselation(); int tesselation = p->getTesselation();
Primitive::Type type = p->getType(); Primitive::Type type = p->getType();
qDebug() << "draw type " << type;
if (type == Primitive::Type::SPHERE){ if (type == Primitive::Type::SPHERE){
drawSphere(tesselation); drawSphere(tesselation);
}else if (type == Primitive::Type::BOX){ }else if (type == Primitive::Type::BOX){
...@@ -276,7 +275,6 @@ void MyGLWidget::keyPressEvent(QKeyEvent* event){ ...@@ -276,7 +275,6 @@ void MyGLWidget::keyPressEvent(QKeyEvent* event){
void MyGLWidget::keyReleaseEvent(QKeyEvent *event){ void MyGLWidget::keyReleaseEvent(QKeyEvent *event){
if (event->key() == Qt::Key_Control){ if (event->key() == Qt::Key_Control){
controller->setCtrlPressed(false); controller->setCtrlPressed(false);
qDebug("ctrl released");
} }
} }
......
...@@ -46,6 +46,7 @@ void RigidBodyTransformation::setRotation(QQuaternion newRotation){ ...@@ -46,6 +46,7 @@ void RigidBodyTransformation::setRotation(QQuaternion newRotation){
Primitive* RigidBodyTransformation::getChildPrimitive(){ Primitive* RigidBodyTransformation::getChildPrimitive(){
if (children.length() > 0){ if (children.length() > 0){
return static_cast<Primitive*>(children[0]);//TODO aufpassen falls höhere tiefe return static_cast<Primitive*>(children[0]);//TODO aufpassen falls höhere tiefe
} else{
qDebug("WAAAH - RBT has no chilren.");
} }
qDebug("WAAAH");
} }
...@@ -94,6 +94,7 @@ RigidBodyTransformation* SceneGraph::addPrimitive(Primitive* p){ ...@@ -94,6 +94,7 @@ RigidBodyTransformation* SceneGraph::addPrimitive(Primitive* p){
RigidBodyTransformation* r = new RigidBodyTransformation(); RigidBodyTransformation* r = new RigidBodyTransformation();
nodes.append(r); nodes.append(r);
model->addNewTransformToRoot(r,p); model->addNewTransformToRoot(r,p);
qDebug() << "added primitive to root. childlength: " << r->getChildren().length();
// model->insertRows(1,1,QModelIndex()); // model->insertRows(1,1,QModelIndex());
notifyViews(); notifyViews();
return r; return r;
......
...@@ -57,6 +57,8 @@ QVariant TreeItem::data(int column){ ...@@ -57,6 +57,8 @@ QVariant TreeItem::data(int column){
else return QVariant("ERROR column index"); else return QVariant("ERROR column index");
} }
//OWN index.
int TreeItem::childNumber(){ int TreeItem::childNumber(){
if (parent){ if (parent){
return parent->getChildren().indexOf(this); return parent->getChildren().indexOf(this);
......
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