]> Creatis software - cpPlugins.git/commitdiff
Some bugs...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 10 Dec 2015 02:37:41 +0000 (21:37 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Thu, 10 Dec 2015 02:37:41 +0000 (21:37 -0500)
lib/cpExtensions/Interaction/BaseInteractorStyle.cxx
lib/cpExtensions/Interaction/BaseInteractorStyle.h
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpPlugins/Plugins/BasicFilters/DoubleFloodImageFilter.cxx

index 7cc717886f89fc6a9bfe560fe3eedf8c213164c7..6c0ebbe1ef3963be5c412c058d02f70b7cf99a47 100644 (file)
@@ -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( );
index 119668b5dd4a17d4e221435c38c04ecd77d915d5..30c3ba3086695108cb66010611a0b76392f5e9c0 100644 (file)
@@ -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;
 
       /**
index 24bae091f038ea2a653e2cb289e6ece20aedb171..88a0a4bc7d8a3c6cb47c0bd31239bec3781ced68 100644 (file)
@@ -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 );
index af44e53e27cc6df44be5a0a376f1ac2df6fcc4cb..2dbbf27501ca9d14801721e60f0f0ea44a75717f 100644 (file)
@@ -3,6 +3,7 @@
 #include <cpPlugins/Interface/BaseApplication.h>
 #include <cpPlugins/Interface/Plugins.h>
 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
+#include <cpExtensions/Visualization/ImageSliceActors.h>
 
 #include <vtkRenderWindowInteractor.h>
 
@@ -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." );
 }