Details
-
Technical task
-
Resolution: Done
-
P2: Important
-
None
Description
Q3DSUipPresentation presentation; ... auto obs = [](Q3DSScene *scene, Q3DSGraphObject::DirtyFlag change, Q3DSGraphObject *obj) { if (change == Q3DSGraphObject::DirtyNodeAdded) qDebug(" added: %s", obj->id().constData()); else if (change == Q3DSGraphObject::DirtyNodeRemoved) qDebug(" removed: %s", obj->id().constData()); }; Q3DSScene *scene = presentation.object<Q3DSScene>("scene"); Q3DSModelNode *model1 = presentation.object<Q3DSModelNode>("model1"); scene->addSceneChangeObserver(obs); Q3DSModelNode *model2 = presentation.newObject<Q3DSModelNode>("model2"); model2->setMesh(presentation.mesh(QLatin1String("#Cylinder"))); Q3DSDefaultMaterial *mat2 = presentation.newObject<Q3DSDefaultMaterial>("mat2"); // this will not cause a notification since model2 does not have a parent // and so is not associated with the scene yet model2->appendChildNode(mat2); // this should trigger a DirtyNodeAdded model1->appendChildNode(model2);
or for slides:
Q3DSSlide *masterSlide = presentation.masterSlide(); auto obs = [](Q3DSSlide *master, Q3DSGraphObject::DirtyFlag change, Q3DSSlide *slide) { if (change == Q3DSGraphObject::DirtyNodeAdded) qDebug(" added: %s", obj->id().constData()); else if (change == Q3DSGraphObject::DirtyNodeRemoved) qDebug(" removed: %s", obj->id().constData()); }; masterSlide->addSlideGraphChangeObserver(obs);