]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/QT/SimpleMPRWidget.h
...
[cpPlugins.git] / lib / cpExtensions / QT / SimpleMPRWidget.h
1 #ifndef __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
2 #define __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
3
4 #include <cpExtensions/Config.h>
5
6 #ifdef cpExtensions_QT4
7
8 #include <map>
9 #include <set>
10 #include <QWidget>
11 #include <vtkInteractorStyleTrackballCamera.h>
12 #include <vtkRenderWindowInteractor.h>
13 #include <vtkProp.h>
14 #include <vtkSmartPointer.h>
15 #include <cpExtensions/Visualization/ImageSliceActors.h>
16
17 #define cpExtensions_MAX_POLYS 65535
18
19 // -------------------------------------------------------------------------
20 class QVTKWidget2;
21
22 namespace Ui
23 {
24   class SimpleMPRWidget;
25 }
26
27 // -------------------------------------------------------------------------
28 namespace cpExtensions
29 {
30   namespace QT
31   {
32     /**
33      */
34     class cpExtensions_EXPORT SimpleMPRWidget
35       : public QWidget
36     {
37       Q_OBJECT;
38
39     public:
40       typedef SimpleMPRWidget Self;
41
42       struct TActorCmp
43       {
44         bool operator()(
45           const vtkSmartPointer< vtkProp >& a,
46           const vtkSmartPointer< vtkProp >& b
47           ) const
48           { return( a.GetPointer( ) < b.GetPointer( ) ); }
49       };
50       typedef std::set< vtkSmartPointer< vtkProp >, TActorCmp >  TActors;
51       typedef std::map< std::string, TActors >              TNamedActors;
52       typedef cpExtensions::Visualization::ImageSliceActors TSliceActors;
53
54     protected:
55       /**
56        */
57       class _3DInteractorStyle
58         : public vtkInteractorStyleTrackballCamera
59       {
60       public:
61         vtkTypeMacro(
62           _3DInteractorStyle, vtkInteractorStyleTrackballCamera
63           );
64
65       public:
66         static _3DInteractorStyle* New( );
67  
68         virtual void OnChar( )       { }
69         virtual void OnKeyDown( )    { }
70         virtual void OnKeyUp( )      { }
71         virtual void OnKeyRelease( ) { }
72         virtual void OnKeyPress( );
73       };
74
75     public:
76       explicit SimpleMPRWidget( QWidget* parent = 0 );
77       virtual ~SimpleMPRWidget( );
78
79       // Data management
80       void Clear( );
81       void SetMainImage( vtkImageData* image, const std::string& name );
82       void SetMainActor( vtkImageActor* actor, const std::string& name );
83       void AddImage( vtkImageData* image, const std::string& name );
84       void AddImageActor( vtkImageActor* actor, const std::string& name );
85       void AddMesh( vtkPolyData* mesh, const std::string& name );
86       void AddMeshActor( vtkProp3D* actor, const std::string& name );
87       void AddActor( vtkProp* actor, const std::string& name );
88       const TActors& GetActors( const std::string& name ) const;
89
90       // Visual objects
91       vtkRenderWindowInteractor* GetInteractor( unsigned int i );
92       vtkRenderer* GetRenderer( unsigned int i );
93       vtkRenderWindow* GetRenderWindow( unsigned int i );
94
95     protected:
96       void _AssociateSlices( );
97
98     private slots:
99       void _SyncBottom( int a, int b );
100       void _SyncTop( int a, int b );
101
102     protected:
103       Ui::SimpleMPRWidget* m_UI;
104       QVTKWidget2*         m_VTK[ 4 ];
105
106       vtkSmartPointer< vtkRenderer >  m_Renderers[ 4 ];
107       vtkSmartPointer< TSliceActors > m_2DSlices[ 3 ];
108       vtkSmartPointer< TSliceActors > m_3DSlices[ 3 ];
109
110       TNamedActors m_NamedActors;
111     };
112
113   } // ecapseman
114
115 } // ecapseman
116
117 #endif // cpExtensions_QT4
118
119 #endif // __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
120
121 // eof - $RCSfile$