From ec16c08da1f8eff92296631d4b2c20986dd71681 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Mon, 15 Feb 2016 16:10:54 -0500 Subject: [PATCH] Seeds widget updated --- .../Visualization/ImageSliceActors.cxx | 3 +-- lib/cpPlugins/Interface/PointList.cxx | 10 ++++++- lib/cpPlugins/Interface/PointList.h | 6 +++++ lib/cpPlugins/Interface/Workspace.cxx | 2 +- lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx | 26 +++++++++++++++---- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 90e0923..024fbe0 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -963,6 +963,7 @@ UpdateText( double pos[ 3 ] ) ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], n ); str << ")"; + #if defined(WIN32) sprintf_s( this->m_TextBuffer, 1024, "Axis: %c (%d)\nPixel %s", @@ -974,8 +975,6 @@ UpdateText( double pos[ 3 ] ) axis, slice, str.str( ).c_str( ) ); #endif // defined(WIN32) - - } // fi } else diff --git a/lib/cpPlugins/Interface/PointList.cxx b/lib/cpPlugins/Interface/PointList.cxx index 87a3570..8c3f232 100644 --- a/lib/cpPlugins/Interface/PointList.cxx +++ b/lib/cpPlugins/Interface/PointList.cxx @@ -1,5 +1,12 @@ #include +// ------------------------------------------------------------------------- +bool cpPlugins::Interface::PointList:: +HaveEuclideanPoints( ) const +{ + return( this->m_HaveEuclideanPoints ); +} + // ------------------------------------------------------------------------- unsigned long cpPlugins::Interface::PointList:: GetNumberOfPoints( ) const @@ -19,7 +26,8 @@ Clear( ) // ------------------------------------------------------------------------- cpPlugins::Interface::PointList:: PointList( ) - : Superclass( ) + : Superclass( ), + m_HaveEuclideanPoints( true ) { this->Clear( ); } diff --git a/lib/cpPlugins/Interface/PointList.h b/lib/cpPlugins/Interface/PointList.h index f41fb18..6f43b32 100644 --- a/lib/cpPlugins/Interface/PointList.h +++ b/lib/cpPlugins/Interface/PointList.h @@ -23,7 +23,12 @@ namespace cpPlugins itkTypeMacro( PointList, DataObject ); cpPlugins_Id_Macro( PointList, DataObject ); + itkBooleanMacro( HaveEuclideanPoints ); + itkGetConstMacro( HaveEuclideanPoints, bool ); + itkSetMacro( HaveEuclideanPoints, bool ); + public: + bool HaveEuclideanPoints( ) const; unsigned long GetNumberOfPoints( ) const; void Clear( ); @@ -45,6 +50,7 @@ namespace cpPlugins protected: unsigned long m_NumberOfPoints; + bool m_HaveEuclideanPoints; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index 7f7f7db..437b037 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -121,7 +121,7 @@ CreateFilter( const std::string& filter, const std::string& name ) { f->SetSingleInteractor( this->m_SingleInteractor ); f->SetMPRViewer( this->m_MPRViewer ); - + TObject::Pointer o = f.GetPointer( ); this->m_Graph->SetVertex( name, o ); diff --git a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx index f9bb4fb..58cbed5 100644 --- a/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx +++ b/lib/cpPlugins/Plugins/Widgets/SeedWidget.cxx @@ -25,7 +25,7 @@ SeedWidget( ) this->_AddOutput< cpPlugins::Interface::PointList >( "Output" ); this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" ); - this->m_Parameters->SetBool( "SeedsAreInRealSpace", true ); + this->m_Parameters->SetBool( "SeedsAreInRealSpace", false ); } // ------------------------------------------------------------------------- @@ -61,8 +61,6 @@ template< class I > std::string cpPlugins::Widgets::SeedWidget:: _GD0( itk::DataObject* image ) { - std::cout << "update seeds" << std::endl; - typedef cpExtensions::Interaction::ImageInteractorStyle _S; I* base_image = dynamic_cast< I* >( image ); @@ -70,8 +68,11 @@ _GD0( itk::DataObject* image ) this->GetOutputData< cpPlugins::Interface::PointList >( "Output" ); double aux_pnt[ 3 ]; unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3; + bool real_space = this->m_Parameters->GetBool( "SeedsAreInRealSpace" ); + // Prepare output out->Clear( ); + out->SetHaveEuclideanPoints( real_space ); // MPR if( this->m_MPRViewer != NULL ) @@ -92,7 +93,15 @@ _GD0( itk::DataObject* image ) typename I::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; - out->AddPoint( seed ); + + if( !real_space ) + { + typename I::IndexType index; + if( base_image->TransformPhysicalPointToIndex( seed, index ) ) + out->AddPoint( index ); + } + else + out->AddPoint( seed ); } // rof } @@ -117,7 +126,14 @@ _GD0( itk::DataObject* image ) typename I::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; - out->AddPoint( seed ); + if( !real_space ) + { + typename I::IndexType index; + if( base_image->TransformPhysicalPointToIndex( seed, index ) ) + out->AddPoint( index ); + } + else + out->AddPoint( seed ); } // rof } -- 2.47.1