From dbc5b32e13cf4a299ce29a5666a8e0a2ff5e62a8 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 9 Dec 2015 21:37:41 -0500 Subject: [PATCH] Some bugs... --- .../Interaction/BaseInteractorStyle.cxx | 27 ++++++++ .../Interaction/BaseInteractorStyle.h | 5 ++ .../Visualization/ImageSliceActors.cxx | 1 + .../BasicFilters/DoubleFloodImageFilter.cxx | 61 +++++++++++-------- 4 files changed, 70 insertions(+), 24 deletions(-) diff --git a/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx b/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx index 7cc7178..6c0ebbe 100644 --- a/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx +++ b/lib/cpExtensions/Interaction/BaseInteractorStyle.cxx @@ -18,6 +18,32 @@ SetSetDoubleClickDelay( long delay ) Self::_TMouseButtonEvent::MaxDoubleClick = delay; } +// ------------------------------------------------------------------------- +vtkObject* cpExtensions::Interaction::BaseInteractorStyle:: +GetAssociatedObject( ) +{ + return( this->m_AssociatedObject ); +} + +// ------------------------------------------------------------------------- +const vtkObject* cpExtensions::Interaction::BaseInteractorStyle:: +GetAssociatedObject( ) const +{ + return( this->m_AssociatedObject ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Interaction::BaseInteractorStyle:: +SetAssociatedObject( vtkObject* obj ) +{ + if( this->m_AssociatedObject != obj ) + { + this->m_AssociatedObject = obj; + this->Modified( ); + + } // fi +} + // ------------------------------------------------------------------------- void cpExtensions::Interaction::BaseInteractorStyle:: DelegateTDxEvent( unsigned long event, void* calldata ) @@ -362,6 +388,7 @@ Pan( ) cpExtensions::Interaction::BaseInteractorStyle:: BaseInteractorStyle( ) : Superclass( ), + m_AssociatedObject( NULL ), m_MotionFactor( double( 10 ) ) { this->m_LeftButtonEvent.Reset( ); diff --git a/lib/cpExtensions/Interaction/BaseInteractorStyle.h b/lib/cpExtensions/Interaction/BaseInteractorStyle.h index 119668b..30c3ba3 100644 --- a/lib/cpExtensions/Interaction/BaseInteractorStyle.h +++ b/lib/cpExtensions/Interaction/BaseInteractorStyle.h @@ -93,6 +93,10 @@ namespace cpExtensions cpExtensions_BaseInteractorStyle_Commands( Leave ); public: + vtkObject* GetAssociatedObject( ); + const vtkObject* GetAssociatedObject( ) const; + void SetAssociatedObject( vtkObject* obj ); + static void SetSetDoubleClickDelay( long delay ); void DelegateTDxEvent( unsigned long event, void* calldata ); @@ -160,6 +164,7 @@ namespace cpExtensions Self& operator=( const Self& ); protected: + vtkObject* m_AssociatedObject; double m_MotionFactor; /** diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 24bae09..88a0a4b 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -1044,6 +1044,7 @@ _ConfigureStyle( ) { // Connect this view with a controller this->m_Style = vtkSmartPointer< TStyle >::New( ); + this->m_Style->SetAssociatedObject( this ); this->m_Style->AddMouseMoveCommand( Self::_MouseMoveCommand, this ); this->m_Style->AddMouseClickCommand( Self::_MouseClickCommand, this ); this->m_Style->AddMouseWheelCommand( Self::_MouseWheelCommand, this ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx index af44e53..2dbbf27 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -55,8 +56,10 @@ accept( ) return; typedef cpExtensions::Interaction::ImageInteractorStyle _TImageStyle; + typedef cpExtensions::Visualization::ImageSliceActors _TImageActors; - // Activate seed widgets + // Get seeds + unsigned int nTotalSeeds = 0; auto iIt = this->m_Filter->m_Interactors.begin( ); for( ; iIt != this->m_Filter->m_Interactors.end( ); ++iIt ) { @@ -66,27 +69,35 @@ accept( ) ); if( istyle == NULL ) continue; + + // Get window level + _TImageActors* actors = + dynamic_cast< _TImageActors* >( istyle->GetAssociatedObject( ) ); + if( actors != NULL ) + { + this->m_Filter->GetParameters( )->SetReal( "Window", actors->GetWindow( ) ); + this->m_Filter->GetParameters( )->SetReal( "Level", actors->GetLevel( ) ); + + } // fi + unsigned int nSeeds = istyle->GetNumberOfSeeds( ); for( unsigned int s = 0; s < nSeeds; ++s ) { - double seed[ 3 ]; - istyle->GetSeed( s, seed ); + if( nTotalSeeds < 2 ) + { + double seed[ 3 ]; + istyle->GetSeed( s, seed ); + if( nTotalSeeds == 0 ) + this->m_Filter->GetParameters( )->SetPoint( "Seed0", 3, seed ); + else + this->m_Filter->GetParameters( )->SetPoint( "Seed1", 3, seed ); + + } // fi + nTotalSeeds++; } // rof } // rof - /* - vtkPlaneWidget* wdg = this->m_Filter->m_PlaneWidget; - if( wdg == NULL ) - return; - - // Get/Set plane parameters - double center[ 3 ], normal[ 3 ]; - wdg->GetCenter( center ); - wdg->GetNormal( normal ); - - this->m_Filter->GetParameters( )->SetPoint( "PlaneCenter", 3, center ); - this->m_Filter->GetParameters( )->SetVector( "PlaneNormal", 3, normal ); // Update filter auto plugins = this->m_Filter->GetPlugins( ); @@ -97,7 +108,6 @@ accept( ) app->UpdateActualFilter( ); } // fi - */ } // ------------------------------------------------------------------------- @@ -293,14 +303,16 @@ template< class I, class O > inline std::string cpPlugins::BasicFilters::DoubleFloodImageFilter:: _RealGD( itk::DataObject* image ) { - /* typedef typename O::PixelType _OP; typedef cpPlugins_BasicFilters_DoubleFloodImageFilter_Function< I > _F; typedef itk::FloodFilledImageFunctionConditionalConstIterator< I, _F > _It; - typename I::PointType pseed; - pseed = this->m_Parameters->GetPoint< typename I::PointType >( - "Seed", I::ImageDimension + typename I::PointType pseed0, pseed1; + pseed0 = this->m_Parameters->GetPoint< typename I::PointType >( + "Seed0", I::ImageDimension + ); + pseed1 = this->m_Parameters->GetPoint< typename I::PointType >( + "Seed1", I::ImageDimension ); double window = this->m_Parameters->GetReal( "Window" ); double level = this->m_Parameters->GetReal( "Level" ); @@ -308,8 +320,9 @@ _RealGD( itk::DataObject* image ) _OP out_val = _OP( this->m_Parameters->GetUint( "OutsideValue" ) ); const I* in = dynamic_cast< const I* >( image ); - typename I::IndexType seed; - in->TransformPhysicalPointToIndex( pseed, seed ); + typename I::IndexType seed0, seed1; + in->TransformPhysicalPointToIndex( pseed0, seed0 ); + in->TransformPhysicalPointToIndex( pseed1, seed1 ); typename O::Pointer out = O::New( ); out->SetLargestPossibleRegion( in->GetLargestPossibleRegion( ) ); @@ -326,7 +339,8 @@ _RealGD( itk::DataObject* image ) f->SetWindow( window ); f->SetLevel( level ); _It i( in, f ); - i.AddSeed( seed ); + i.AddSeed( seed0 ); + i.AddSeed( seed1 ); for( i.GoToBegin( ); !i.IsAtEnd( ); ++i ) out->SetPixel( i.GetIndex( ), in_val ); @@ -340,7 +354,6 @@ _RealGD( itk::DataObject* image ) return( "" ); } else -*/ return( "DoubleFloodImageFilter: output not correctly created." ); } -- 2.47.1