]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageActor.cxx
yet another refactoring
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageActor.cxx
diff --git a/lib/cpExtensions/Visualization/ImageActor.cxx b/lib/cpExtensions/Visualization/ImageActor.cxx
new file mode 100644 (file)
index 0000000..d1f72ac
--- /dev/null
@@ -0,0 +1,94 @@
+#include <cpExtensions/Visualization/ImageActor.h>
+#include <cpExtensions/Visualization/ImageSliceMapper.h>
+
+#include <vtkCommand.h>
+#include <vtkImageData.h>
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageActor::
+Modified( )
+{
+  if( this->m_Mapper->GetNumberOfInputConnections( 0 ) > 0 )
+  {
+    this->m_Mapper->Modified( );
+    this->m_Mapper->Update( );
+    this->Superclass::Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::ImageActor::
+GetOrientation( ) const
+{
+  return( this->m_Mapper->GetOrientation( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageActor::
+SetOrientation( int orientation )
+{
+  this->m_Mapper->SetOrientation( ( orientation < 3 )? orientation: 2 );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+int cpExtensions::Visualization::ImageActor::
+GetSliceNumber( ) const
+{
+  return( this->m_Mapper->GetSliceNumber( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageActor::
+SetSliceNumber( int slice )
+{
+  static int s = 0;
+  auto image = this->m_Mapper->GetInput( );
+  if( image != NULL )
+  {
+    // Update slice
+    s = slice;
+    if( s < this->m_Mapper->GetSliceNumberMinValue( ) )
+      s = this->m_Mapper->GetSliceNumberMinValue( );
+    if( s > this->m_Mapper->GetSliceNumberMaxValue( ) )
+      s = this->m_Mapper->GetSliceNumberMaxValue( );
+    this->m_Mapper->SetSliceNumber( s );
+    this->InvokeEvent( vtkCommand::InteractionEvent, &s );
+
+    // Propagate modifications
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+vtkPlane* cpExtensions::Visualization::ImageActor::
+GetSlicePlane( )
+{
+  return( this->m_Mapper->GetSlicePlane( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkPlane* cpExtensions::Visualization::ImageActor::
+GetSlicePlane( ) const
+{
+  return( this->m_Mapper->GetSlicePlane( ) );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageActor::
+ImageActor( )
+  : Superclass( )
+{
+  this->m_Mapper = vtkSmartPointer< ImageSliceMapper >::New( );
+  this->SetMapper( this->m_Mapper );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::ImageActor::
+~ImageActor( )
+{
+}
+
+// eof - $RCSfile$