Commit 38138692 by Alisa Jung

fixed delete bug

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