Commit 5278dcef authored by finetjul's avatar finetjul
Browse files

ENH: Add methods to derive Annotations displayable manager

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21539 3bd1e089-480b-0410-8dfb-8563597acbee
parent c05f7197
......@@ -114,14 +114,31 @@ void vtkMRMLAnnotationHierarchyNode::DeleteDirectChildren()
}
}
//---------------------------------------------------------------------------
void vtkMRMLAnnotationHierarchyNode::GetDirectChildren(vtkCollection *children)
{
this->GetChildren(children, 1);
}
//---------------------------------------------------------------------------
void vtkMRMLAnnotationHierarchyNode::GetAllChildren(vtkCollection *children)
{
this->GetChildren(children, -1);
}
//---------------------------------------------------------------------------
void vtkMRMLAnnotationHierarchyNode::GetChildren(vtkCollection *children, int level)
{
if (children == NULL)
{
return;
}
if (level-- == 0)
{
return;
}
vtkMRMLScene *scene = this->GetScene();
if (scene == NULL)
{
......@@ -158,7 +175,7 @@ void vtkMRMLAnnotationHierarchyNode::GetDirectChildren(vtkCollection *children)
children->AddItem(anode);
}
} // if user-created check
hnode->GetChildren(children, level);
} // check if it is a direct child of this
} // loop through all nodes
......
......@@ -36,9 +36,19 @@ public:
virtual const char* GetNodeTagName();
// Description:
// Get all children associated to this node
// Get all top level children associated to this node.
virtual void GetDirectChildren(vtkCollection *children);
/// Add into \a children all the children of the hierarchy node.
/// \sa GetDirectChildren(), GetChildren()
virtual void GetAllChildren(vtkCollection *children);
/// Add into \a children all children of the hierarchy node of the first
/// \a level nodes.
/// If \a level is <0, then all levels are added.
/// \sa GetAllChildren(), GetDirectChildren()
virtual void GetChildren(vtkCollection *children, int level);
// Description:
// Delete all children of this node
// If a child is another hierarchyNode, the parent of it gets set to this' parent
......
......@@ -382,7 +382,7 @@ void vtkMRMLAnnotationDisplayableManager::OnMRMLSceneNodeAdded(vtkMRMLNode* node
return;
}
if (!node->IsA(this->m_Focus))
if (!this->IsManageable(node))
{
// jump out
vtkDebugMacro("OnMRMLSceneNodeAddedEvent: Not the correct displayableManager for node " << node->GetID() << ", jumping out!")
......@@ -1502,10 +1502,22 @@ bool vtkMRMLAnnotationDisplayableManager::IsCorrectDisplayableManager()
return false;
}
// the purpose of the displayableManager is hardcoded
return !strcmp(selectionNode->GetActiveAnnotationID(), this->m_Focus);
return this->IsManageable(selectionNode->GetActiveAnnotationID());
}
//---------------------------------------------------------------------------
bool vtkMRMLAnnotationDisplayableManager::IsManageable(vtkMRMLNode* node)
{
return node->IsA(this->m_Focus);
}
//---------------------------------------------------------------------------
bool vtkMRMLAnnotationDisplayableManager::IsManageable(const char* nodeID)
{
return nodeID && !strcmp(nodeID, this->m_Focus);
}
//---------------------------------------------------------------------------
// Functions to overload!
//---------------------------------------------------------------------------
......
......@@ -147,11 +147,11 @@ protected:
void RemoveObserversFromInteractionNode();
/// Preset functions for certain events.
void OnMRMLAnnotationNodeModifiedEvent(vtkMRMLNode* node);
void OnMRMLAnnotationNodeTransformModifiedEvent(vtkMRMLNode* node);
void OnMRMLAnnotationNodeLockModifiedEvent(vtkMRMLNode* node);
void OnMRMLAnnotationDisplayNodeModifiedEvent(vtkMRMLNode *node);
void OnMRMLAnnotationControlPointModifiedEvent(vtkMRMLNode *node);
virtual void OnMRMLAnnotationNodeModifiedEvent(vtkMRMLNode* node);
virtual void OnMRMLAnnotationNodeTransformModifiedEvent(vtkMRMLNode* node);
virtual void OnMRMLAnnotationNodeLockModifiedEvent(vtkMRMLNode* node);
virtual void OnMRMLAnnotationDisplayNodeModifiedEvent(vtkMRMLNode *node);
virtual void OnMRMLAnnotationControlPointModifiedEvent(vtkMRMLNode *node);
//
// Handling of interaction within the RenderWindow
//
......@@ -202,7 +202,18 @@ protected:
vtkAbstractWidget * GetWidget(vtkMRMLAnnotationNode * node);
/// Check if it is the right displayManager
virtual bool IsCorrectDisplayableManager();
bool IsCorrectDisplayableManager();
/// Return true if this displayable manager supports(can manage) that node,
/// false otherwise.
/// Can be reimplemented to add more conditions.
/// \sa IsManageable(const char*), IsCorrectDisplayableManager()
virtual bool IsManageable(vtkMRMLNode* node);
/// Return true if this displayable manager supports(can manage) that node ID,
/// false otherwise.
/// Can be reimplemented to add more conditions.
/// \sa IsManageable(vtkMRMLNode*), IsCorrectDisplayableManager()
virtual bool IsManageable(const char* nodeID);
/// Focus of this displayableManager is set to a specific annotation type when inherited
const char* m_Focus;
......
......@@ -601,7 +601,7 @@ void qMRMLAnnotationTreeView::onLockColumnClicked(vtkMRMLNode* node)
void qMRMLAnnotationTreeView::mousePressEvent(QMouseEvent* event)
{
// skip qMRMLTreeView
this->QTreeView::mousePressEvent(event);
this->Superclass::mousePressEvent(event);
}
//------------------------------------------------------------------------------
......
......@@ -45,6 +45,7 @@ class Q_SLICER_MODULE_ANNOTATIONS_WIDGETS_EXPORT qMRMLAnnotationTreeView
Q_OBJECT
public:
typedef qMRMLTreeView Superclass;
qMRMLAnnotationTreeView(QWidget *parent=0);
virtual ~qMRMLAnnotationTreeView();
......
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