Index: mitk/Applications/Tutorial/Step5.cpp =================================================================== --- mitk/Applications/Tutorial/Step5.cpp (revision 27420) +++ mitk/Applications/Tutorial/Step5.cpp (working copy) @@ -26,12 +26,14 @@ #include "mitkGlobalInteraction.h" #include "mitkPointSet.h" -#include "mitkPointSetInteractor.h" +#include "mitkNodeDepententPointSetInteractor.h" #include #include #include +#include "mitkNodePredicateDataType.h" + //##Documentation //## @brief Interactively add points //## @@ -79,6 +81,7 @@ // Create a DataNodeFactory to read a data format supported // by the DataNodeFactory (many image formats, surface formats, etc.) mitk::DataNodeFactory::Pointer nodeReader=mitk::DataNodeFactory::New(); + const char * filename = argv[i]; try { @@ -90,8 +93,8 @@ // Since the DataNodeFactory directly creates a node, // use the iterator to add the read node to the tree - mitk::DataNode::Pointer node = nodeReader->GetOutput(); - ds->Add(node); + mitk::DataNode::Pointer imageNode = nodeReader->GetOutput(); + ds->Add(imageNode); } catch(...) { @@ -100,6 +103,15 @@ } } + + mitk::NodePredicateDataType::Pointer predicate(mitk::NodePredicateDataType::New("Image")); + mitk::DataStorage::SetOfObjects::ConstPointer allImagesInDS = ds->GetSubset(predicate); + if (allImagesInDS->Size()<2) + { + fprintf( stderr, "please specify two images in command line \n"); + exit(2); + } + // ******************************************************* // ****************** START OF NEW PART ****************** // ******************************************************* @@ -109,19 +121,25 @@ //************************************************************************* // Create PointSet and a node for it - mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); - mitk::DataNode::Pointer pointSetNode = mitk::DataNode::New(); - pointSetNode->SetData(pointSet); + mitk::PointSet::Pointer pointSet1 = mitk::PointSet::New(); + mitk::DataNode::Pointer pointSetNode1 = mitk::DataNode::New(); + pointSetNode1->AddProperty( "unselectedcolor", mitk::ColorProperty::New(0.0f, 1.0f, 0.0f)); + pointSetNode1->SetData(pointSet1); + mitk::NodeDepententPointSetInteractor::Pointer interactor1 = mitk::NodeDepententPointSetInteractor::New("pointsetinteractor", pointSetNode1, allImagesInDS->GetElement(0)); + // Add the node to the tree + ds->Add(pointSetNode1); + mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor1); + + mitk::PointSet::Pointer pointSet2 = mitk::PointSet::New(); + mitk::DataNode::Pointer pointSetNode2 = mitk::DataNode::New(); + pointSetNode2->AddProperty( "unselectedcolor", mitk::ColorProperty::New(0.0f, 0.0f, 1.0f)); + pointSetNode2->SetData(pointSet2); + mitk::NodeDepententPointSetInteractor::Pointer interactor2 = mitk::NodeDepententPointSetInteractor::New("pointsetinteractor", pointSetNode2, allImagesInDS->GetElement(1)); // Add the node to the tree - ds->Add(pointSetNode); + ds->Add(pointSetNode2); + mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor2); - // Create PointSetInteractor, associate to pointSetNode and add as - // interactor to GlobalInteraction - mitk::GlobalInteraction::GetInstance()->AddInteractor( - mitk::PointSetInteractor::New("pointsetinteractor", pointSetNode) - ); - // ******************************************************* // ******************* END OF NEW PART ******************* // ******************************************************* @@ -151,6 +169,9 @@ // Use it as a 3D view renderWindow.GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard3D); + allImagesInDS->GetElement(0)->SetBoolProperty("visible", true, renderWindow.GetRenderer()); + allImagesInDS->GetElement(1)->SetBoolProperty("visible", true, renderWindow.GetRenderer()); + //************************************************************************* // Part Vb: 2D view for slicing transversally //************************************************************************* @@ -169,6 +190,9 @@ // slice itself in 3D: add it to the tree! ds->Add(view2.GetRenderer()->GetCurrentWorldGeometry2DNode()); + allImagesInDS->GetElement(0)->SetBoolProperty("visible", true, view2.GetRenderer()); + allImagesInDS->GetElement(1)->SetBoolProperty("visible", false, view2.GetRenderer()); + //************************************************************************* // Part Vc: 2D view for slicing sagitally //************************************************************************* @@ -187,6 +211,11 @@ // slice itself in 3D: add it to the tree! ds->Add(view3.GetRenderer()->GetCurrentWorldGeometry2DNode()); + //set property visibility + allImagesInDS->GetElement(0)->SetBoolProperty("visible", false, view3.GetRenderer()); + allImagesInDS->GetElement(1)->SetBoolProperty("visible", true, view3.GetRenderer()); + + //************************************************************************* //Part VII: Qt-specific initialization //************************************************************************* Index: mitk/Core/Code/files.cmake =================================================================== --- mitk/Core/Code/files.cmake (revision 27420) +++ mitk/Core/Code/files.cmake (working copy) @@ -139,6 +139,7 @@ Interactions/mitkInteractor.cpp Interactions/mitkMouseMovePointSetInteractor.cpp Interactions/mitkMoveSurfaceInteractor.cpp + Interactions/mitkNodeDepententPointSetInteractor.cpp Interactions/mitkPointSetInteractor.cpp Interactions/mitkPositionEvent.cpp Interactions/mitkPositionTracker.cpp Index: mitk/Core/Code/Interactions/mitkNodeDepententPointSetInteractor.cpp =================================================================== --- mitk/Core/Code/Interactions/mitkNodeDepententPointSetInteractor.cpp (revision 0) +++ mitk/Core/Code/Interactions/mitkNodeDepententPointSetInteractor.cpp (revision 0) @@ -0,0 +1,54 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-09-14 09:48:51 +0200 (Di, 14 Sep 2010) $ +Version: $Revision: 26074 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include "mitkNodeDepententPointSetInteractor.h" +#include "mitkStateEvent.h" +#include "mitkEvent.h" + +mitk::NodeDepententPointSetInteractor +::NodeDepententPointSetInteractor(const char * type, DataNode* dataNode, DataNode* dependentDataNode, int n) +:PointSetInteractor(type, dataNode, n), m_DependentDataNode(dependentDataNode) +{ +} + +mitk::NodeDepententPointSetInteractor::~NodeDepententPointSetInteractor() +{ +} + +float mitk::NodeDepententPointSetInteractor::CanHandleEvent(StateEvent const* stateEvent) const +{ + if (m_DependentDataNode.IsNull()) + return 0; + + // use sender to check if the specified dependentDataNode is visible there + mitk::BaseRenderer* sender = stateEvent->GetEvent()->GetSender(); + if (sender == NULL) + return 0; + + bool value = false; + + if ( m_DependentDataNode->GetPropertyList(sender)->GetBoolProperty("visible", value) == false)//property doesn't exist + return 0; + if (value == false) //the dependent node is invisible + return 0; + + //ok, it is visible, so check the standard way. + return Superclass::CanHandleEvent(stateEvent); +} + + Property changes on: mitk\Core\Code\Interactions\mitkNodeDepententPointSetInteractor.cpp ___________________________________________________________________ Added: svn:eol-style + native Index: mitk/Core/Code/Interactions/mitkNodeDepententPointSetInteractor.h =================================================================== --- mitk/Core/Code/Interactions/mitkNodeDepententPointSetInteractor.h (revision 0) +++ mitk/Core/Code/Interactions/mitkNodeDepententPointSetInteractor.h (revision 0) @@ -0,0 +1,74 @@ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date: 2010-10-04 14:49:09 +0200 (Mo, 04 Okt 2010) $ +Version: $Revision: 26576 $ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#ifndef MITKNodeDepententPointSetInteractor_H_HEADER_INCLUDED +#define MITKNodeDepententPointSetInteractor_H_HEADER_INCLUDED + +#include "mitkCommon.h" +#include "mitkVector.h" +#include +#include +#include + + +namespace mitk +{ + + /** + * \brief PointSetInteraction that is dependent on a node. + * + * Dependent on a node means, that the interactor checks if the + * specified node (e.g. image) for instance is visible in the renderwindow the event comes from. + * Thus a image specific pointsetinteraction for registration can be built up. + * \ingroup Interaction + */ + class MITK_CORE_EXPORT NodeDepententPointSetInteractor : public PointSetInteractor + { + public: + mitkClassMacro(NodeDepententPointSetInteractor, PointSetInteractor); + mitkNewMacro4Param(Self, const char*, DataNode*, DataNode*, int); + mitkNewMacro3Param(Self, const char*, DataNode*, DataNode*); + + /** + * \brief Checks visibility of the specified node (e.g. image), + * returns 0 if node is not visible in sending render window + * If Sender within stateEvent is NULL a value of 0 is returned. + */ + virtual float CanHandleEvent(StateEvent const* stateEvent) const; + + protected: + /** + * \brief Constructor with Param n for limited Set of Points + * + * If no n is set, then the number of points is unlimited + * n=0 is not supported. In this case, n is set to 1. + */ + NodeDepententPointSetInteractor(const char * type, DataNode* dataNode, DataNode* dependentDataNode, int n = -1); + + /** + * \brief Default Destructor + **/ + virtual ~NodeDepententPointSetInteractor(); + + public: + + mitk::DataNode::Pointer m_DependentDataNode; + + }; +} +#endif /* MITKNodeDepententPointSetInteractor_H_HEADER_INCLUDED */ Property changes on: mitk\Core\Code\Interactions\mitkNodeDepententPointSetInteractor.h ___________________________________________________________________ Added: svn:eol-style + native Index: mitk/Core/Code/Interactions/StateMachine.xml =================================================================== --- mitk/Core/Code/Interactions/StateMachine.xml (revision 27420) +++ mitk/Core/Code/Interactions/StateMachine.xml (working copy) @@ -2055,9 +2055,8 @@ - + - @@ -2065,14 +2064,12 @@ - + - - + - @@ -2088,12 +2085,10 @@ - + - - + - @@ -2106,41 +2101,33 @@ - + - - + - - + - - + - - + - - + - - + - - + - @@ -2164,32 +2151,26 @@ - + - - + - - + - - + - - + - - + - @@ -2207,16 +2188,17 @@ + + - + - @@ -2229,18 +2211,25 @@ - + + + - + + + + + - + +