Commit facaad33 authored by Jan Möbius's avatar Jan Möbius
Browse files

Updated addNode Plugin Functions

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7323 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cb79466d
...@@ -83,15 +83,20 @@ static unsigned int activeExaminer_ = 0; ...@@ -83,15 +83,20 @@ static unsigned int activeExaminer_ = 0;
/** \brief DONT USE DIRECTLY!! /** \brief DONT USE DIRECTLY!!
* *
* The pointer to the beginning of the scenegraph nodes ( only visible part ) * The pointer to the beginning of the scenegraph nodes ( only the nodes belonging to objects )
* Between the actual root node ( sceneGraph_root_node_ ) and this node global nodes could be added * 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 * 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 /** \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 /** \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 ) { ...@@ -192,13 +197,28 @@ void setEncodedExaminerView(int _viewerId , QString _view ) {
examiner_widgets_[_viewerId]->decodeView ( _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 ) { // Set the separatorNode
PluginFunctions::root_node_ = _root_node; 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<ACG::SceneGraph::SeparatorNode*> (*(PluginFunctions::dataSeparatorNode_->childrenBegin()) );
} }
void setSceneGraphRootNode( SeparatorNode* _root_node ) { void setSceneGraphRootNode( SeparatorNode* _root_node ) {
PluginFunctions::sceneGraph_root_node_ = _root_node; PluginFunctions::sceneGraphRootNode_ = _root_node;
} }
bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object) { bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object) {
...@@ -428,7 +448,7 @@ bool scenegraphRegionPick( const unsigned int _examiner, ...@@ -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!! //Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!!
void traverse( ACG::SceneGraph::MouseEventAction &_action ) { void traverse( ACG::SceneGraph::MouseEventAction &_action ) {
ACG::SceneGraph::traverse(sceneGraph_root_node_, ACG::SceneGraph::traverse(sceneGraphRootNode_,
_action,viewerProperties().glState() ); _action,viewerProperties().glState() );
} }
...@@ -440,7 +460,7 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction ...@@ -440,7 +460,7 @@ void traverse( const unsigned int _examiner, ACG::SceneGraph::MouseEventAction
return; 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() ...@@ -778,28 +798,32 @@ ViewObjectMarker * defaultViewObjectMarker()
ACG::SceneGraph::BaseNode* getSceneGraphRootNode() { ACG::SceneGraph::BaseNode* getSceneGraphRootNode() {
return PluginFunctions::sceneGraph_root_node_; return PluginFunctions::sceneGraphRootNode_;
} }
ACG::SceneGraph::BaseNode* getRootNode() { ACG::SceneGraph::BaseNode* getRootNode() {
return PluginFunctions::root_node_; return PluginFunctions::dataRootNode_;
} }
void addNode(ACG::SceneGraph::BaseNode* _node){ void addGlobalNode(ACG::SceneGraph::BaseNode* _node){
if (PluginFunctions::root_node_) if (PluginFunctions::sceneGraphRootNode_)
_node->set_parent( PluginFunctions::root_node_ ); _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() { int objectCount() {
......
...@@ -279,21 +279,38 @@ void pickMode ( std::string _mode); ...@@ -279,21 +279,38 @@ void pickMode ( std::string _mode);
DLLEXPORT DLLEXPORT
void getCurrentViewImage(QImage& _image); 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 DLLEXPORT
ACG::SceneGraph::BaseNode* getSceneGraphRootNode(); 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 DLLEXPORT
ACG::SceneGraph::BaseNode* getRootNode(); ACG::SceneGraph::BaseNode* getRootNode();
/// Add a node under the root node /// Add a node under the root node
DLLEXPORT 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 DLLEXPORT
void addGlobalNode(ACG::SceneGraph::BaseNode* _node); void addObjectRenderingNode(ACG::SceneGraph::BaseNode* _node);
/// Set the current Action Mode (PickMode,ExamineMode,...) /// Set the current Action Mode (PickMode,ExamineMode,...)
DLLEXPORT DLLEXPORT
......
...@@ -87,9 +87,9 @@ void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProper ...@@ -87,9 +87,9 @@ void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProper
DLLEXPORT DLLEXPORT
void setSceneGraphRootNode( SeparatorNode* _root_node ); 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 DLLEXPORT
void setRootNode( SeparatorNode* _root_node ); void setDataSeparatorNodes( SeparatorNode* _dataRootNode );
/** @} */ /** @} */
......
...@@ -127,11 +127,23 @@ Core() : ...@@ -127,11 +127,23 @@ Core() :
//init nodes //init nodes
root_node_scenegraph_ = new ACG::SceneGraph::SeparatorNode(0, "SceneGraph Root Node"); 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"); // This seperator will manage the cores nodes
coordsysNode_ = new ACG::SceneGraph::CoordsysNode(coordsysMaterialNode_,"Core Coordsys Node"); 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); 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(); // gridNode_->hide();
// Add ViewMode All // Add ViewMode All
...@@ -184,7 +196,7 @@ void ...@@ -184,7 +196,7 @@ void
Core::init() { Core::init() {
// Make root_node available to the plugins ( defined in PluginFunctions.hh) // Make root_node available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::setRootNode( root_node_ ); PluginFunctions::setDataSeparatorNodes( dataSeparatorNode_ );
PluginFunctions::setSceneGraphRootNode( root_node_scenegraph_ ); PluginFunctions::setSceneGraphRootNode( root_node_scenegraph_ );
......
...@@ -587,8 +587,15 @@ private: ...@@ -587,8 +587,15 @@ private:
/// Scenegraphs root node /// Scenegraphs root node
SeparatorNode* root_node_scenegraph_; SeparatorNode* root_node_scenegraph_;
/// Data root node /// Separator Node holding all core scenegraph nodes
SeparatorNode* root_node_; SeparatorNode* core_nodes_;
///Toplevel Nodes for data objects
SeparatorNode* dataSeparatorNode_;
/// Root Node for data objects
SeparatorNode* dataRootNode_;
/// Node for coordsys Material /// Node for coordsys Material
ACG::SceneGraph::MaterialNode* coordsysMaterialNode_; ACG::SceneGraph::MaterialNode* coordsysMaterialNode_;
......
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