]> Creatis software - cpPlugins.git/commitdiff
MPR finished
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 20 Nov 2015 23:24:14 +0000 (18:24 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Fri, 20 Nov 2015 23:24:14 +0000 (18:24 -0500)
appli/ImageMPR/ImageMPR.cxx
lib/cpExtensions/Visualization/ImageSliceActors.cxx
lib/cpExtensions/Visualization/ImageSliceActors.h
lib/cpExtensions/Visualization/MPRActors.cxx
lib/cpExtensions/Visualization/MPRActors.h
lib/cpExtensions/Visualization/MPRObjects.cxx
lib/cpExtensions/Visualization/MPRObjects.h
lib/cpPlugins/Interface/BaseMPRWidget.cxx

index c18fcd24fad447bd2d4c5fd23f49fd1d826ec4fa..5a9e414c9de2c584bfc5a5d88e4fd3168e15c49f 100644 (file)
@@ -173,6 +173,7 @@ _AssociatePluginsToMenu( )
       return;                                                           \
     TImage* image = this->m_Plugins.GetData< TImage >( name );          \
     this->m_UI->MPR->AddData( image, name, "" );                        \
+    this->m_UI->MPR->SetMainImage( name );                              \
     this->m_UI->MPR->ShowData( name );                                  \
   }                                                                     \
   catch( std::exception& err )                                          \
index 1c032d2817b628a0ddf61d46da39096e99712834..008117557ec5b48ba487ed9a7e23978183033713 100644 (file)
@@ -129,9 +129,6 @@ Clear( )
   this->m_BlenderActor->GetProperty( )->SetLookupTable( this->m_BlenderLUT );
   this->m_BlenderActor->GetProperty( )->UseLookupTableScalarRangeOn( );
 
-  // Remove associated objects
-  this->m_AssociatedSlices.clear( );
-
   // White cursor
   vtkSmartPointer< vtkPoints > cursor_points =
     vtkSmartPointer< vtkPoints >::New( );
@@ -1016,26 +1013,9 @@ UpdateText( const double& w, const double& l )
   this->Modified( );
 }
 
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageSliceActors::
-ImageSliceActors( )
-  : Superclass( ),
-    m_Window( NULL ),
-    m_Interpolate( false )
-{
-  this->Clear( );
-  this->_ConfigureStyle( );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::ImageSliceActors::
-~ImageSliceActors( )
-{
-}
-
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_Render( )
+Render( )
 {
   if( this->m_Window == NULL )
     return;
@@ -1049,7 +1029,7 @@ _Render( )
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
-_ResetCamera( )
+ResetCamera( )
 {
   if( this->m_Window == NULL )
     return;
@@ -1060,6 +1040,23 @@ _ResetCamera( )
   renderer->ResetCamera( );
 }
 
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageSliceActors::
+ImageSliceActors( )
+  : Superclass( ),
+    m_Window( NULL ),
+    m_Interpolate( false )
+{
+  this->Clear( );
+  this->_ConfigureStyle( );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageSliceActors::
+~ImageSliceActors( )
+{
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::ImageSliceActors::
 _ConfigureStyle( )
@@ -1156,7 +1153,7 @@ _MouseMoveCommand(
     // Just show the pixel information
     actors->SetCursor( pos );
     actors->UpdateText( pos );
-    actors->_Render( );
+    actors->Render( );
   }
   else if( btn == TStyle::ButtonID_Left )
   {
@@ -1164,7 +1161,7 @@ _MouseMoveCommand(
     {
       // Show axes in current renderer
       actors->SetAxesCursor( pos );
-      actors->_Render( );
+      actors->Render( );
 
       // Interactively move slices
       auto i = actors->m_SlicesCommands.begin( );
@@ -1194,7 +1191,7 @@ _MouseMoveCommand(
       dx += actors->m_StartWindowLevel[ 0 ];
       dy += actors->m_StartWindowLevel[ 1 ];
       actors->SetWindowLevel( dx, dy );
-      actors->_Render( );
+      actors->Render( );
 
       // Associate objects
       auto i = actors->m_WindowLevelCommands.begin( );
@@ -1243,7 +1240,7 @@ _MouseWheelCommand(
     if( slice > actors->GetSliceNumberMaxValue( ) )
       slice = actors->GetSliceNumberMaxValue( );
     actors->SetSliceNumber( slice );
-    actors->_Render( );
+    actors->Render( );
 
     auto a = actors->m_AssociatedSlices.begin( );
     for( ; a != actors->m_AssociatedSlices.end( ); ++a )
@@ -1269,8 +1266,8 @@ _KeyCommand( void* data, const char& key )
   {
   case 'r': case 'R':
   {
-    actors->_ResetCamera( );
-    actors->_Render( );
+    actors->ResetCamera( );
+    actors->Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1281,7 +1278,7 @@ _KeyCommand( void* data, const char& key )
   case 'w': case 'W':
   {
     actors->ResetWindowLevel( );
-    actors->_Render( );
+    actors->Render( );
 
     // Associate objects
     auto i = actors->m_RenderCommands.begin( );
@@ -1304,7 +1301,7 @@ _EnterCommand( void* data )
 
   actors->ResetCursor( );
   actors->m_CursorActor->VisibilityOn( );
-  actors->_Render( );
+  actors->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -1317,7 +1314,7 @@ _LeaveCommand( void* data )
 
   actors->ResetCursor( );
   actors->m_CursorActor->VisibilityOff( );
-  actors->_Render( );
+  actors->Render( );
 }
 
 // eof - $RCSfile$
index 396d2ae5280e7ce5fe3472612f45505db1db0aa7..81fc0e123b66ba26d611b3f17ed8cf3f65eb6c23 100644 (file)
@@ -51,6 +51,7 @@ namespace cpExtensions
       typedef void ( *TSlicesCommand )( double*, int, void* );
       typedef void ( *TWindowLevelCommand )( double, double, void* );
       typedef TVoidCommand TRenderCommand;
+      typedef TSlicesCommand TCursorAxesCommand;
 
       typedef cpExtensions::Visualization::ImageBlender TBlender;
 
@@ -60,6 +61,7 @@ namespace cpExtensions
       cpExtensions_BaseInteractorStyle_Commands( Slices );
       cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
       cpExtensions_BaseInteractorStyle_Commands( Render );
+      cpExtensions_BaseInteractorStyle_Commands( CursorAxes );
 
     public:
       // Creation
@@ -135,12 +137,13 @@ namespace cpExtensions
       void UpdateText( double pos[ 3 ] );
       void UpdateText( const double& w, const double& l );
 
+      void Render( );
+      void ResetCamera( );
+
     protected:
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
 
-      void _Render( );
-      void _ResetCamera( );
       void _ConfigureStyle( );
       void _ConfigureInputImage( );
       void _ConfigureBinaryImage(
index 25151abac3a4a2ea9f40b8700ec41667ed354030..47f1251bf214cd8bc4ea64a6df68e2e9d13898e1 100644 (file)
@@ -31,24 +31,34 @@ GetSliceActors( const int& i ) const
 void cpExtensions::Visualization::MPRActors::
 SetInputConnection( vtkAlgorithmOutput* aout )
 {
-  this->Slices[ 0 ][ 0 ]->SetInputConnection( aout );
-  this->Slices[ 0 ][ 1 ]->SetInputConnection( aout );
-  this->Slices[ 0 ][ 2 ]->SetInputConnection( aout );
-  this->Slices[ 1 ][ 0 ]->SetInputConnection( aout );
-  this->Slices[ 1 ][ 1 ]->SetInputConnection( aout );
-  this->Slices[ 1 ][ 2 ]->SetInputConnection( aout );
+  for( int i = 0; i < 2; ++i )
+  {
+    for( int j = 0; j < 3; ++j )
+    {
+      this->Slices[ i ][ j ]->SetInputConnection( aout );
+      this->Slices[ i ][ j ]->SetAxis( j );
+
+    } // rof
+
+  } // rof
+  this->_CreateBoundingBox( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRActors::
 SetInputImage( vtkImageData* data )
 {
-    this->Slices[ 0 ][ 0 ]->SetInputImage( data );
-    this->Slices[ 0 ][ 1 ]->SetInputImage( data );
-    this->Slices[ 0 ][ 2 ]->SetInputImage( data );
-    this->Slices[ 1 ][ 0 ]->SetInputImage( data );
-    this->Slices[ 1 ][ 1 ]->SetInputImage( data );
-    this->Slices[ 1 ][ 2 ]->SetInputImage( data );
+  for( int i = 0; i < 2; ++i )
+  {
+    for( int j = 0; j < 3; ++j )
+    {
+      this->Slices[ i ][ j ]->SetInputImage( data );
+      this->Slices[ i ][ j ]->SetAxis( j );
+
+    } // rof
+
+  } // rof
+  this->_CreateBoundingBox( );
 }
 
 // -------------------------------------------------------------------------
@@ -159,7 +169,13 @@ PushActorsInto(
   vtkRenderer* wren =
     ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
   if( wren != NULL )
+  {
     wren->AddViewProp( this->ImageOutlineActor );
+    wren->AddViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) );
+    wren->AddViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) );
+    wren->AddViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -181,7 +197,13 @@ PopActorsFrom(
   vtkRenderer* wren =
     ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL;
   if( wren != NULL )
+  {
     wren->RemoveViewProp( this->ImageOutlineActor );
+    wren->RemoveViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) );
+    wren->RemoveViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) );
+    wren->RemoveViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -328,6 +350,44 @@ SetSlice( const int& axis, double* pos )
   } // fi
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+Render( const int& axis )
+{
+  if( axis < 3 )
+  {
+    this->Slices[ 0 ][ axis ]->Render( );
+    this->Slices[ 1 ][ axis ]->Render( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+Render( )
+{
+  this->Render( 0 );
+  this->Render( 1 );
+  this->Render( 2 );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+ResetCamera( const int& axis )
+{
+  if( axis < 3 )
+    this->Slices[ 0 ][ axis ]->ResetCamera( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+ResetCameras( )
+{
+  this->ResetCamera( 0 );
+  this->ResetCamera( 1 );
+  this->ResetCamera( 2 );
+}
+
 // -------------------------------------------------------------------------
 cpExtensions::Visualization::MPRActors::
 MPRActors( )
@@ -396,8 +456,15 @@ _SlicesCommand( double* pos, int axis, void* data )
   if( actors == NULL )
     return;
   for( unsigned int j = 0; j < 3; ++j )
+  {
     if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis )
+    {
       actors->SetSlice( j, pos );
+      actors->Render( j );
+
+    } // fi
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------
@@ -408,6 +475,7 @@ _WindowLevelCommand( double window, double level, void* data )
   if( actors == NULL )
     return;
   actors->SetWindowLevel( window, level );
+  actors->Render( );
 }
 
 // -------------------------------------------------------------------------
@@ -417,6 +485,7 @@ _RenderCommand( void* data )
   MPRActors* actors = reinterpret_cast< MPRActors* >( data );
   if( actors == NULL )
     return;
+  actors->Render( );
 }
 
 // eof - $RCSfile$
index 34f373c9d4b690a2b148b80011ece8b2d367a304..e4d7bf61e62f040e4d1f981995f82e4ab0b02984 100644 (file)
@@ -90,6 +90,12 @@ namespace cpExtensions
       void SetSliceNumber( const int& axis, const int& slice );
       void SetSlice( const int& axis, double* pos );
 
+      // Rendering controls
+      void Render( const int& axis );
+      void Render( );
+      void ResetCamera( const int& axis );
+      void ResetCameras( );
+
     protected:
       MPRActors( );
       virtual ~MPRActors( );
index ccc3dc4680374ea4e0e1f0c0512cac79cad91381..0727f2223489628be5ba0f3a14aec0fbea026907 100644 (file)
@@ -74,6 +74,24 @@ AddBinaryImage(
   return( this->m_MPRActors->AddBinaryImage( data, r, g, b ) );
 }
 
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+Show( )
+{
+  this->m_MPRActors->PushActorsInto(
+    this->m_Windows[ 0 ],
+    this->m_Windows[ 1 ],
+    this->m_Windows[ 2 ],
+    this->m_Windows[ 3 ]
+    );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRObjects::
+Hide( )
+{
+}
+
 // -------------------------------------------------------------------------
 void cpExtensions::Visualization::MPRObjects::
 Clear( )
index a1ed436206578245922369eedadfbaadaf260ea4..c800fc1ce626b11602c066f54a10b7ed363341f3 100644 (file)
@@ -76,6 +76,8 @@ namespace cpExtensions
         vtkImageData* data,
         const double& r, const double& g, const double& b
         );
+      void Show( );
+      void Hide( );
       void Clear( );
 
       vtkImageData* GetInputImage( );
index ee6e5869075359e551bb07fdd31df17dcef3b850..b84d75c2b39aba1b488ea41fe7ae0807c732ded6 100644 (file)
@@ -180,8 +180,11 @@ ShowData( const std::string& name )
 
   if( iIt->second.Tag == Data::IMAGE )
   {
-    // TODO: this->m_MPRObjects->AddImage( iIt->second.Image );
-#error ACA VOY
+    if( name == this->m_MainImage )
+      this->m_MPRObjects->SetInputImage( iIt->second.Image );
+    else
+      this->m_MPRObjects->AddBinaryImage( iIt->second.Image, 1, 0, 0 );
+    this->m_MPRObjects->Show( );
   }
   else if( iIt->second.Tag == Data::MESH )
   {