[osg-users] Creating tree model of scenegraph for use in QTreeView
Greetings, I would like to create some qt-based scene edit components beginning with a scenegraph explorer (a tree widget which lists the scenegraph objects). Can anyone provide some advice for how to create a tree data model of an existing scenegraph for use in a QTreeView? P.S. I'm moving from OGRE and have been surprised that there is very little OSG development for up-to-date qt-based scene editors and tools (like Ogitor or Delta3d's stage). Perhaps I'm mistaken...but are there any out there (other than those listed on the wiki)? Very grateful for your hints and suggestions, JB -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21682#21682 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating tree model of scenegraph for use in QTreeView
Hi, I am not a QT expert but has done this in the past with MFC. You simply create nodevisitior that will traverse the scene and create your tree items Nick http://www.linkedin.com/in/tnick On Fri, Dec 18, 2009 at 11:32 PM, Jason Bellone jbell...@unog.ch wrote: Greetings, I would like to create some qt-based scene edit components beginning with a scenegraph explorer (a tree widget which lists the scenegraph objects). Can anyone provide some advice for how to create a tree data model of an existing scenegraph for use in a QTreeView? P.S. I'm moving from OGRE and have been surprised that there is very little OSG development for up-to-date qt-based scene editors and tools (like Ogitor or Delta3d's stage). Perhaps I'm mistaken...but are there any out there (other than those listed on the wiki)? Very grateful for your hints and suggestions, JB -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21682#21682 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating tree model of scenegraph for use in QTreeView
HI #include osgViewer/Viewer #include osgViewer/CompositeViewer #include osgViewer/ViewerEventHandlers #include osgGA/TrackballManipulator #include osgDB/ReadFile #include osgDB/ReadFile #include osgUtil/Optimizer #include osg/CoordinateSystemNode #include osg/PositionAttitudeTransform #include osg/MatrixTransform #include iostream #include QMessageBox #include QtCore/QString #include QtCore/QTimer #include QtGui/QKeyEvent #include QtGui/QApplication #include QtOpenGL/QGLWidget #include QTreeWidget class BuildTreeNodeVisitor : public osg::NodeVisitor { public: BuildTreeNodeVisitor( QTreeWidget* tree): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),_tree(tree) { setTraversalMask(0x); setNodeMaskOverride(0x); } //virtual void apply(osg::Node node); virtual void apply(osg::MatrixTransform node); //virtual void apply(osg::Group group); //!!! //typedef std::vector osg::ref_ptrosg::Node NodeList; typedef std::vector osg::ref_ptrosg::MatrixTransform NodeList; void CreateSubTree(osg::NodePath list); QTreeWidget* _tree; }; #include BuildTreeVisitor.h void BuildTreeNodeVisitor::apply(osg::MatrixTransform node) { std::string name = node.getName(); if (true)//(!name.empty()) { //иерархия osg::NodePath other = getNodePath(); CreateSubTree (other); // } traverse(node); } void BuildTreeNodeVisitor::CreateSubTree(osg::NodePath list) { QTreeWidgetItem* subTree = _tree-topLevelItem(0); for(osg::NodePath::iterator pitr=list.begin(); pitr!=list.end(); ++pitr) { std::string name = (*pitr)-getName(); //Смотрим, есть ли такая ветка в самом начале дерева, если есть входим в нее и проверяем дальше, если нет создаем. bool find =false; if (!subTree) { QTreeWidgetItem *added = new QTreeWidgetItem(); added-setText(0, QString::fromLocal8Bit(Структура сцены)); _tree-addTopLevelItem (added); subTree = _tree-topLevelItem(0); } for (int i = 0; i subTree-childCount(); i++) { if (subTree-child(i)-text(0)==QString::fromStdString(name)) { find = true; subTree = subTree-child(i); break; } } if (!find) { QTreeWidgetItem *added = new QTreeWidgetItem(); added-setText(0, QString::fromLocal8Bit (name.c_str())); subTree-addChild (added); } //QMessageBox::critical(0, QString())), QString::fromStdString (name)); } return; } 2009/12/21 Trajce Nikolov nikolov.tra...@gmail.com Hi, I am not a QT expert but has done this in the past with MFC. You simply create nodevisitior that will traverse the scene and create your tree items Nick http://www.linkedin.com/in/tnick On Fri, Dec 18, 2009 at 11:32 PM, Jason Bellone jbell...@unog.ch wrote: Greetings, I would like to create some qt-based scene edit components beginning with a scenegraph explorer (a tree widget which lists the scenegraph objects). Can anyone provide some advice for how to create a tree data model of an existing scenegraph for use in a QTreeView? P.S. I'm moving from OGRE and have been surprised that there is very little OSG development for up-to-date qt-based scene editors and tools (like Ogitor or Delta3d's stage). Perhaps I'm mistaken...but are there any out there (other than those listed on the wiki)? Very grateful for your hints and suggestions, JB -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21682#21682 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Maxim Gammer ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating tree model of scenegraph for use in QTreeView
If the tree control you're referring to is like most 2D UI tree controls, then each node can have only one parent. This is not the case in OSG, nodes can have multiple parents. So you'll need to figure out a way to represent this. Paul Martz Skew Matrix Software LLC _http://www.skew-matrix.com_ http://www.skew-matrix.com/ +1 303 859 9466 Jason Bellone wrote: Greetings, I would like to create some qt-based scene edit components beginning with a scenegraph explorer (a tree widget which lists the scenegraph objects). Can anyone provide some advice for how to create a tree data model of an existing scenegraph for use in a QTreeView? P.S. I'm moving from OGRE and have been surprised that there is very little OSG development for up-to-date qt-based scene editors and tools (like Ogitor or Delta3d's stage). Perhaps I'm mistaken...but are there any out there (other than those listed on the wiki)? Very grateful for your hints and suggestions, JB -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21682#21682 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating tree model of scenegraph for use in QTreeView
I simply started from the TreeModel in http://qt.nokia.com/doc/4.6/itemviews-simpletreemodel.html I have a QTreeitem which contains a pointer to the parent QTreeItem and a list of children and a osg::Node pointer to the actual scene node. This slightly duplicates the structure of the osg::scene in the tree pointers but it was easier and in my case the gui 'knows' when the scene changes so can recalc the tree. Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=21761#21761 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org