From facaad3344c249be89268677a6cf1e35374a77d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 6 Oct 2009 12:46:06 +0000 Subject: [PATCH] Updated addNode Plugin Functions git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7323 383ad7c9-94d9-4d36-a494-682f7c89f535 --- BasePlugin/PluginFunctions.cc | 68 +++++++++++++++++++++---------- BasePlugin/PluginFunctions.hh | 27 +++++++++--- BasePlugin/PluginFunctionsCore.hh | 4 +- Core/Core.cc | 22 +++++++--- Core/Core.hh | 11 ++++- 5 files changed, 96 insertions(+), 36 deletions(-) diff --git a/BasePlugin/PluginFunctions.cc b/BasePlugin/PluginFunctions.cc index a9ebb2f0..f8f3af1c 100644 --- a/BasePlugin/PluginFunctions.cc +++ b/BasePlugin/PluginFunctions.cc @@ -83,15 +83,20 @@ static unsigned int activeExaminer_ = 0; /** \brief DONT USE DIRECTLY!! * - * The pointer to the beginning of the scenegraph nodes ( only visible part ) - * Between the actual root node ( sceneGraph_root_node_ ) and this node global nodes could be added + * The pointer to the beginning of the scenegraph nodes ( only the nodes belonging to objects ) + * Between the actual root node ( sceneGraphRootNode_ ) and this node global nodes could be added * This pointer is internally used to access the scenegraphs root node */ -static SeparatorNode* root_node_; +static SeparatorNode* dataRootNode_ = 0; + +/** This node is used to add nodes between the root node of the scenegraph and the objects separator node. +* It is directly below the sceneGraphRootNode_ +*/ +static SeparatorNode* dataSeparatorNode_ = 0; /** \brief Scenegraph root node */ -static SeparatorNode* sceneGraph_root_node_; +static SeparatorNode* sceneGraphRootNode_ = 0; /** \brief a dummy properties object returned as a reference if the real object does not exist * @@ -192,13 +197,28 @@ void setEncodedExaminerView(int _viewerId , QString _view ) { examiner_widgets_[_viewerId]->decodeView ( _view ); } +void setDataSeparatorNodes( SeparatorNode* _dataSeparatorNode ) { + + // The function should only be called once by the core. -void setRootNode( SeparatorNode* _root_node ) { - PluginFunctions::root_node_ = _root_node; + // Set the separatorNode + PluginFunctions::dataSeparatorNode_ = _dataSeparatorNode; + + + if ( PluginFunctions::dataSeparatorNode_->nChildren() != 1 ){ + std::cerr << "Only one child allowed for dataSeparatorNode on initialization!" << std::endl; + std::cerr << "The Core has initialized the scenegraph in a strange way!" << std::endl; + ACG::SceneGraph::BaseNode* child = *(PluginFunctions::dataSeparatorNode_->childrenBegin()); + } + + // Set the root node for the data objects + // which has to be a child of the dataSeparatorNode_ + PluginFunctions::dataRootNode_ = dynamic_cast (*(PluginFunctions::dataSeparatorNode_->childrenBegin()) ); + } void setSceneGraphRootNode( SeparatorNode* _root_node ) { - PluginFunctions::sceneGraph_root_node_ = _root_node; + PluginFunctions::sceneGraphRootNode_ = _root_node; } bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object) { @@ -428,7 +448,7 @@ bool scenegraphRegionPick( const unsigned int _examiner, //Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!! void traverse( ACG::SceneGraph::MouseEventAction &_action ) { - ACG::SceneGraph::traverse(sceneGraph_root_node_, + ACG::SceneGraph::traverse(sceneGraphRootNode_, _action,viewerProperties().glState() ); } @@ -440,7 +460,7 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction return; } - ACG::SceneGraph::traverse(sceneGraph_root_node_, _action,viewerProperties(_examiner).glState() ); + ACG::SceneGraph::traverse(sceneGraphRootNode_, _action,viewerProperties(_examiner).glState() ); } @@ -778,28 +798,32 @@ ViewObjectMarker * defaultViewObjectMarker() ACG::SceneGraph::BaseNode* getSceneGraphRootNode() { - return PluginFunctions::sceneGraph_root_node_; + return PluginFunctions::sceneGraphRootNode_; } ACG::SceneGraph::BaseNode* getRootNode() { - return PluginFunctions::root_node_; + return PluginFunctions::dataRootNode_; } -void addNode(ACG::SceneGraph::BaseNode* _node){ - if (PluginFunctions::root_node_) - _node->set_parent( PluginFunctions::root_node_ ); +void addGlobalNode(ACG::SceneGraph::BaseNode* _node){ + if (PluginFunctions::sceneGraphRootNode_) + _node->set_parent( PluginFunctions::sceneGraphRootNode_ ); } -void addGlobalNode(ACG::SceneGraph::BaseNode* _node){ - if (PluginFunctions::sceneGraph_root_node_){ - //set node as new parent for root's children - while( PluginFunctions::sceneGraph_root_node_->nChildren() > 0 ){ - ACG::SceneGraph::BaseNode* child = *(PluginFunctions::sceneGraph_root_node_->childrenBegin()); - child->set_parent( _node ); - } - _node->set_parent( PluginFunctions::sceneGraph_root_node_ ); +void addObjectRenderingNode(ACG::SceneGraph::BaseNode* _node){ + if (PluginFunctions::sceneGraphRootNode_){ + + // get the current parent Node + ACG::SceneGraph::BaseNode* parent = dataRootNode_->parent(); + + // Move the node to the new parent + _node->set_parent(parent); + + // move dataRootNode_ to the new parent + dataRootNode_->set_parent(_node); } + } int objectCount() { diff --git a/BasePlugin/PluginFunctions.hh b/BasePlugin/PluginFunctions.hh index 16cb78bc..1c9cfce9 100644 --- a/BasePlugin/PluginFunctions.hh +++ b/BasePlugin/PluginFunctions.hh @@ -279,21 +279,38 @@ void pickMode ( std::string _mode); DLLEXPORT void getCurrentViewImage(QImage& _image); -/// Get the root node +/** \brief get scenegraph root node +* +* Get the real root node of the scenegraph.This node is the topmost +* node of the scenegraph. Normally you do not need to use this node. +* All objects should be added below the data root node which you can get +* with getRootNode(). +*/ DLLEXPORT ACG::SceneGraph::BaseNode* getSceneGraphRootNode(); -/// Get the root node +/** \brief Get the root node for data objects +* +* Get the root node for the objects. This node is a separator node. +* All nodes belonging to objects have to be placed below this node. +* Add a separatornode for each object below this node! */ DLLEXPORT ACG::SceneGraph::BaseNode* getRootNode(); /// Add a node under the root node DLLEXPORT -void addNode(ACG::SceneGraph::BaseNode* _node); +void addGlobalNode(ACG::SceneGraph::BaseNode* _node); -/// Add a node between root node and its children +/** \brief Add scenegraph node modifing object rendering +* +* This function adds nodes in front of the object root node. +* Therefore all objects renderings will be modified by the +* state changes in the added node. This might be usefull for +* adding for example a slicing node, which adds clipping planes +* such that the objects will be sliced. +*/ DLLEXPORT -void addGlobalNode(ACG::SceneGraph::BaseNode* _node); +void addObjectRenderingNode(ACG::SceneGraph::BaseNode* _node); /// Set the current Action Mode (PickMode,ExamineMode,...) DLLEXPORT diff --git a/BasePlugin/PluginFunctionsCore.hh b/BasePlugin/PluginFunctionsCore.hh index 3fb03933..296cb732 100644 --- a/BasePlugin/PluginFunctionsCore.hh +++ b/BasePlugin/PluginFunctionsCore.hh @@ -87,9 +87,9 @@ void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProper DLLEXPORT void setSceneGraphRootNode( SeparatorNode* _root_node ); -/// Set the internal data root node pointer ( DO NOT USE!! ) +/// Set the internal data root node pointers ( DO NOT USE!! ) DLLEXPORT -void setRootNode( SeparatorNode* _root_node ); +void setDataSeparatorNodes( SeparatorNode* _dataRootNode ); /** @} */ diff --git a/Core/Core.cc b/Core/Core.cc index 5e2578fe..21e06ab3 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -127,11 +127,23 @@ Core() : //init nodes root_node_scenegraph_ = new ACG::SceneGraph::SeparatorNode(0, "SceneGraph Root Node"); - root_node_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_, "Data Root Node"); - coordsysMaterialNode_ = new ACG::SceneGraph::MaterialNode(root_node_scenegraph_,"Coordsys Material Node"); - coordsysNode_ = new ACG::SceneGraph::CoordsysNode(coordsysMaterialNode_,"Core Coordsys Node"); + + // This seperator will manage the cores nodes + core_nodes_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_, "Core Nodes"); + + // Coordsys rendering nodes + coordsysMaterialNode_ = new ACG::SceneGraph::MaterialNode(core_nodes_,"Coordsys Material Node"); + coordsysNode_ = new ACG::SceneGraph::CoordsysNode(coordsysMaterialNode_,"Core Coordsys Node"); coordsysNode_->setTraverseMode (BaseNode::NodeFirst | BaseNode::SecondPass); -// gridNode_ = new ACG::SceneGraph::GridNode(root_node_scenegraph_,"Grid Node"); + + // seperator handling the nodes for data + dataSeparatorNode_ = new ACG::SceneGraph::SeparatorNode(root_node_scenegraph_, "Data Separator Root Node"); + + // seperator handling the nodes for data + dataRootNode_ = new ACG::SceneGraph::SeparatorNode(dataSeparatorNode_, "Data Root Node"); + + +// gridNode_ = new ACG::SceneGraph::GridNode(core_nodes_,"Grid Node"); // gridNode_->hide(); // Add ViewMode All @@ -184,7 +196,7 @@ void Core::init() { // Make root_node available to the plugins ( defined in PluginFunctions.hh) - PluginFunctions::setRootNode( root_node_ ); + PluginFunctions::setDataSeparatorNodes( dataSeparatorNode_ ); PluginFunctions::setSceneGraphRootNode( root_node_scenegraph_ ); diff --git a/Core/Core.hh b/Core/Core.hh index e93dcbf7..507f98ce 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -587,8 +587,15 @@ private: /// Scenegraphs root node SeparatorNode* root_node_scenegraph_; - /// Data root node - SeparatorNode* root_node_; + /// Separator Node holding all core scenegraph nodes + SeparatorNode* core_nodes_; + + + ///Toplevel Nodes for data objects + SeparatorNode* dataSeparatorNode_; + + /// Root Node for data objects + SeparatorNode* dataRootNode_; /// Node for coordsys Material ACG::SceneGraph::MaterialNode* coordsysMaterialNode_; -- GitLab