]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/QT/MPR3DWidget.cxx
...
[cpPlugins.git] / lib / cpExtensions / QT / MPR3DWidget.cxx
index 3d5d50882ce915c98eb9b9c3b3c02af980f3fa39..f86992dfc21fd27ed61137544afc99b17c7ab510 100644 (file)
@@ -1,14 +1,10 @@
 #include <cpExtensions/QT/MPR3DWidget.h>
-
-#ifdef cpExtensions_QT4
-
 #include <cpExtensions/Visualization/ImageOutlineActor.h>
-#include <cpExtensions/Visualization/MPR3DActors.h>
-#include <cpExtensions/Visualization/LUTImageActor.h>
+#include <cpExtensions/Visualization/MeshActor.h>
 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
 
-#include <vtkActor.h>
 #include <vtkImageData.h>
+#include <vtkPlane.h>
 #include <vtkPolyData.h>
 
 // -------------------------------------------------------------------------
@@ -17,40 +13,51 @@ MPR3DWidget( QWidget* parent, Qt::WindowFlags f )
   : Superclass( parent, f ),
     m_ImageName( "" )
 {
-  this->m_Actors =
-    vtkSmartPointer< cpExtensions::Visualization::MPR3DActors >::New( );
 }
 
 // -------------------------------------------------------------------------
 cpExtensions::QT::MPR3DWidget::
 ~MPR3DWidget( )
 {
+  for( auto a = this->m_Actors.begin( ); a != this->m_Actors.end( ); ++a )
+    delete *a;
+  this->m_Actors.clear( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::MPR3DWidget::
+Clear( )
+{
+  this->RemoveViewProps( );
+  this->m_ImageName = "";
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::MPR3DWidget::
 SetImage( vtkImageData* image, const std::string& name )
 {
+  if( name == "" )
+    return;
   if( this->m_ImageName != "" )
+    this->Clear( );
+  this->m_ImageName = name;
+
+  for( unsigned int o = 0; o < 3; ++o )
   {
-    // TODO: Clear visualization
+    this->m_WLActors[ o ] = vtkSmartPointer< TWLActor >::New( );
+    this->m_WLActors[ o ]->SetImage( image );
+    this->m_WLActors[ o ]->SetOrientation( o );
 
-  } // fi
+    this->m_OLActors[ o ] = vtkSmartPointer< TOLActor >::New( );
+    this->m_OLActors[ o ]->SetBounds(
+      o, image->GetBounds( )[ o << 1 ], image->GetBounds( )
+      );
 
-  this->m_Actors->SetImage( image );
-  this->m_ImageName = name;
+    this->AddViewProp( this->m_WLActors[ o ], this->m_ImageName );
+    this->AddAuxViewProp( this->m_OLActors[ o ], this->m_ImageName );
+    this->ResetCamera( );
 
-  vtkSmartPointer< vtkPropCollection > props =
-    vtkSmartPointer< vtkPropCollection >::New( );
-  props->AddItem( this->m_Actors->GetWindowLevelImageActor( 0 ) );
-  props->AddItem( this->m_Actors->GetWindowLevelImageActor( 1 ) );
-  props->AddItem( this->m_Actors->GetWindowLevelImageActor( 2 ) );
-  this->AddViewProps( props, name );
-  this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 0 ), name );
-  this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 1 ), name );
-  this->AddAuxViewProp( this->m_Actors->GetImageOutlineActor( 2 ), name );
-  this->ResetCamera( );
-  this->Render( );
+  } // rof
 }
 
 // -------------------------------------------------------------------------
@@ -61,86 +68,73 @@ Add( vtkDataSet* data, const std::string& name )
   auto pdata = dynamic_cast< vtkPolyData* >( data );
   if( image != NULL )
   {
-    if( this->m_ImageName != "" )
-    {
-    }
-    else
-      this->SetImage( image, name );
+    /* TODO
+       if( this->m_ImageName != "" )
+       {
+       }
+       else
+       this->SetImage( image, name );
+    */
   }
   else if( pdata != NULL )
   {
-    this->AddViewProp( this->m_Actors->AddMesh( pdata ), name );
+    TActor* actor = new TActor( );
+    actor->SetMesh( pdata );
+    this->m_Actors.push_back( actor );
+    this->AddViewProp( actor->GetActor( ), name );
     this->Render( );
     if( this->m_ImageName == "" )
       this->ResetCamera( );
 
   } // fi
-
-  /* TODO
-     return;
-
-     auto image = dynamic_cast< vtkImageData* >( data );
-     auto pdata = dynamic_cast< vtkPolyData* >( data );
-     if( image != NULL )
-     {
-     this->m_Actors->AddLUTImage( image );
-     vtkSmartPointer< vtkPropCollection > coll =
-     vtkSmartPointer< vtkPropCollection >::New( );
-     coll->AddItem( this->m_Actors->GetLUTImageActor( 0 ) );
-     coll->AddItem( this->m_Actors->GetLUTImageActor( 1 ) );
-     coll->AddItem( this->m_Actors->GetLUTImageActor( 2 ) );
-     this->AddViewProps( coll, name );
-     this->Render( );
-     }
-     else if( pdata != NULL )
-     {
-
-     } // fi
-  */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::MPR3DWidget::
-SetSliceNumber( int orientation, int slice )
-{
-  this->m_Actors->SetSliceNumber( orientation, slice );
-  this->Render( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::MPR3DWidget::
-SetSlicesNumbers( int x, int y, int z )
-{
-  this->m_Actors->SetSliceNumber( 0, x );
-  this->m_Actors->SetSliceNumber( 1, y );
-  this->m_Actors->SetSliceNumber( 2, z );
-  this->Render( );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::MPR3DWidget::
-SetScalarRange( double r[ 2 ] )
+cpExtensions::QT::MPR3DWidget::
+TWLActor* cpExtensions::QT::MPR3DWidget::
+GetImageActor( int o )
 {
+  return( this->m_WLActors[ o % 3 ] );
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::QT::MPR3DWidget::
-SetWindowLevel( double wl[ 2 ] )
+const cpExtensions::QT::MPR3DWidget::
+TWLActor* cpExtensions::QT::MPR3DWidget::
+GetImageActor( int o ) const
 {
+  return( this->m_WLActors[ o % 3 ] );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::MPR3DWidget::
-SetImageOpacity( double o )
+SetSliceNumber( int orientation, int slice )
 {
+  int o = orientation % 3;
+  this->m_WLActors[ o ]->SetSliceNumber( slice );
+  this->m_OLActors[ o ]->SetBounds(
+    o,
+    this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ],
+    this->m_WLActors[ o ]->GetImage( )->GetBounds( )
+    );
+  this->Render( );
 }
 
 // -------------------------------------------------------------------------
 void cpExtensions::QT::MPR3DWidget::
-SetImageInterpolation( unsigned char i )
+SetSlicesNumbers( int x, int y, int z )
 {
+  int s[] = { x, y, z };
+  for( int o = 0; o < 3; ++o )
+  {
+    this->m_WLActors[ o ]->SetSliceNumber( s[ o ] );
+    this->m_OLActors[ o ]->SetBounds(
+      o,
+      this->m_WLActors[ o ]->GetSlicePlane( )->GetOrigin( )[ o ],
+      this->m_WLActors[ o ]->GetImage( )->GetBounds( )
+      );
+
+  } // rof
+  this->Render( );
 }
 
-#endif // cpExtensions_QT4
-
 // eof - $RCSfile$