]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/QT/SimpleMPRWidget.h
Cast image filter added. ROI filter modified.
[cpPlugins.git] / lib / cpExtensions / QT / SimpleMPRWidget.h
index 04ed994898f710f698a629205ffbead51c8b759e..4760bb34e565e9cb1b4b22ca12597f1ee519460d 100644 (file)
-#ifndef __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
-#define __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
+#ifndef __cpExtensions__QT__SimpleMPRWidget__h__
+#define __cpExtensions__QT__SimpleMPRWidget__h__
 
 #include <cpExtensions/Config.h>
 
 #ifdef cpExtensions_QT4
 
-#include <map>
-#include <set>
+#include <cpExtensions/QT/ActorsWidgetInterface.h>
 #include <QWidget>
-#include <vtkInteractorStyleTrackballCamera.h>
-#include <vtkRenderWindowInteractor.h>
-#include <vtkProp.h>
 #include <vtkSmartPointer.h>
-#include <cpExtensions/Visualization/ImageSliceActors.h>
-
-#define cpExtensions_MAX_POLYS 65535
+#include <map>
+#include <set>
 
 // -------------------------------------------------------------------------
-class QVTKWidget;
+class vtkDataSet;
+class vtkProp;
+class vtkPropCollection;
 
-namespace Ui
-{
-  class SimpleMPRWidget;
-}
+namespace Ui { class SimpleMPRWidget; }
 
 // -------------------------------------------------------------------------
 namespace cpExtensions
 {
   namespace QT
   {
+    class MPR3DWidget;
+    class ImageWidget;
+
     /**
      */
     class cpExtensions_EXPORT SimpleMPRWidget
-      : public QWidget
+      : public QWidget,
+        public ActorsWidgetInterface
     {
       Q_OBJECT;
 
     public:
-      typedef SimpleMPRWidget Self;
-
-      struct TActorCmp
-      {
-        bool operator()(
-          const vtkSmartPointer< vtkProp >& a,
-          const vtkSmartPointer< vtkProp >& b
-          ) const
-          { return( a.GetPointer( ) < b.GetPointer( ) ); }
-      };
-      typedef std::set< vtkSmartPointer< vtkProp >, TActorCmp >  TActors;
-      typedef std::map< std::string, TActors >              TNamedActors;
-      typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
+      typedef SimpleMPRWidget       Self;
+      typedef QWidget               Superclass;
+      typedef ActorsWidgetInterface Superclass2;
 
-    protected:
-      /**
-       */
-      class _3DInteractorStyle
-        : public vtkInteractorStyleTrackballCamera
-      {
-      public:
-        vtkTypeMacro(
-          _3DInteractorStyle, vtkInteractorStyleTrackballCamera
-          );
-
-      public:
-        static _3DInteractorStyle* New( );
-        virtual void OnChar( )       { }
-        virtual void OnKeyDown( )    { }
-        virtual void OnKeyUp( )      { }
-        virtual void OnKeyRelease( ) { }
-        virtual void OnKeyPress( );
-      };
+      typedef vtkSmartPointer< vtkPropCollection > TProp;
+      typedef std::set< TProp >                    TProps;
+
+      // typedef cpExtensions::Visualization::MeshActor TMeshActor;
 
     public:
-      explicit SimpleMPRWidget( QWidget* parent = 0 );
+      explicit SimpleMPRWidget( QWidget* parent = NULL, Qt::WindowFlags f = 0 );
       virtual ~SimpleMPRWidget( );
 
-      // Data management
-      void Clear( );
-      void SetMainImage( vtkImageData* image, const std::string& name );
-      void SetMainActor( vtkImageActor* actor, const std::string& name );
-      void AddImage( vtkImageData* image, const std::string& name );
-      void AddImageActor( vtkImageActor* actor, const std::string& name );
-      void AddMesh( vtkPolyData* mesh, const std::string& name );
-      void AddMeshActor( vtkProp3D* actor, const std::string& name );
-      void AddActor( vtkProp* actor, const std::string& name );
-      const TActors& GetActors( const std::string& name ) const;
-
-      // Visual objects
-      vtkRenderWindowInteractor* GetInteractor( unsigned int i );
-      vtkRenderer* GetRenderer( unsigned int i );
-      vtkRenderWindow* GetRenderWindow( unsigned int i );
-
-    protected:
-      void _AssociateSlices( );
+      void Configure( char q1, char q2, char q3, char q4 );
+
+      bool HasImage( ) const;
+      void SetImage( vtkImageData* image, const std::string& name );
+
+      bool Add( vtkDataSet* data, const std::string& name );
+
+      TProps GetViewProps( const std::string& name ) const;
+      TProps GetImageProps( ) const;
+
+      vtkRenderWindowInteractor* GetXInteractor( );
+      const vtkRenderWindowInteractor* GetXInteractor( ) const;
+      vtkRenderWindowInteractor* GetYInteractor( );
+      const vtkRenderWindowInteractor* GetYInteractor( ) const;
+      vtkRenderWindowInteractor* GetZInteractor( );
+      const vtkRenderWindowInteractor* GetZInteractor( ) const;
+      vtkRenderWindowInteractor* GetWInteractor( );
+      const vtkRenderWindowInteractor* GetWInteractor( ) const;
+
+      vtkRenderWindow* GetXRenderWindow( );
+      const vtkRenderWindow* GetXRenderWindow( ) const;
+      vtkRenderWindow* GetYRenderWindow( );
+      const vtkRenderWindow* GetYRenderWindow( ) const;
+      vtkRenderWindow* GetZRenderWindow( );
+      const vtkRenderWindow* GetZRenderWindow( ) const;
+      vtkRenderWindow* GetWRenderWindow( );
+      const vtkRenderWindow* GetWRenderWindow( ) const;
+
+      void ResetCameras( );
+      void Render( );
+
+      virtual std::set< vtkRenderWindowInteractor* > GetInteractors( ) const cpExtensions_OVERRIDE;
+      virtual std::set< std::string > GetActorsNames( ) const cpExtensions_OVERRIDE;
+      virtual bool IsWindowLevelImageActor( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual bool IsLUTImageActor( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual bool Is3DActor( const std::string& name ) const cpExtensions_OVERRIDE;
+
+      virtual void GetScalarRange( const std::string& name, double r[ 2 ] ) const cpExtensions_OVERRIDE;
+      virtual void GetWindowLevel( const std::string& name, double wl[ 2 ] ) const cpExtensions_OVERRIDE;
+      virtual double GetWindow( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual double GetLevel( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual char GetImageInterpolation( const std::string& name ) const cpExtensions_OVERRIDE;
+
+      virtual void GetColor( const std::string& name, double& r, double& g, double& b ) const cpExtensions_OVERRIDE;
+      virtual double GetOpacity( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual double GetPointSize( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual double GetLineWidth( const std::string& name ) const cpExtensions_OVERRIDE;
+      virtual int GetRepresentation( const std::string& name ) const cpExtensions_OVERRIDE;
+
+      virtual void SetScalarRange( const std::string& name, double r[ 2 ] ) cpExtensions_OVERRIDE;
+      virtual void SetScalarRange( const std::string& name, double min, double max ) cpExtensions_OVERRIDE;
+      virtual void SetWindowLevel( const std::string& name, double wl[ 2 ] ) cpExtensions_OVERRIDE;
+      virtual void SetWindowLevel( const std::string& name, double w, double l ) cpExtensions_OVERRIDE;
+      virtual void SetWindow( const std::string& name, double w ) cpExtensions_OVERRIDE;
+      virtual void SetLevel( const std::string& name, double l ) cpExtensions_OVERRIDE;
+      virtual void SetImageInterpolation( const std::string& name, char i ) cpExtensions_OVERRIDE;
+
+      virtual void SetColor( const std::string& name, double r, double g, double b ) cpExtensions_OVERRIDE;
+      virtual void SetOpacity( const std::string& name, double o ) cpExtensions_OVERRIDE;
+      virtual void SetPointSize( const std::string& name, double s ) cpExtensions_OVERRIDE;
+      virtual void SetLineWidth( const std::string& name, double w ) cpExtensions_OVERRIDE;
+      virtual void SetRepresentationToPoints( const std::string& name ) cpExtensions_OVERRIDE;
+      virtual void SetRepresentationToSurface( const std::string& name ) cpExtensions_OVERRIDE;
+      virtual void SetRepresentationToWireframe( const std::string& name ) cpExtensions_OVERRIDE;
 
     private slots:
       void _SyncBottom( int a, int b );
@@ -101,13 +119,14 @@ namespace cpExtensions
 
     protected:
       Ui::SimpleMPRWidget* m_UI;
-      QVTKWidget*          m_VTK[ 4 ];
 
-      vtkSmartPointer< vtkRenderer >  m_Renderers[ 4 ];
-      vtkSmartPointer< TSliceActors > m_2DSlices[ 3 ];
-      vtkSmartPointer< TSliceActors > m_3DSlices[ 3 ];
+      ImageWidget* m_XImage;
+      ImageWidget* m_YImage;
+      ImageWidget* m_ZImage;
+      MPR3DWidget* m_3DView;
 
-      TNamedActors m_NamedActors;
+      std::string m_MainImageName;
+      vtkSmartPointer< vtkImageData > m_MainImage;
     };
 
   } // ecapseman
@@ -116,6 +135,6 @@ namespace cpExtensions
 
 #endif // cpExtensions_QT4
 
-#endif // __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
+#endif // __cpExtensions__QT__SimpleMPRWidget__h__
 
 // eof - $RCSfile$