]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/QT/SimpleMPRWidget.h
First dump for version 0.1.0
[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 <string>
10
11 #include <QWidget>
12
13 #include <vtkSmartPointer.h>
14 #include <vtkImageData.h>
15 #include <vtkPolyDataMapper.h>
16 #include <vtkPolyDataNormals.h>
17 #include <vtkQuadricLODActor.h>
18 #include <vtkStripper.h>
19
20 #include <cpExtensions/Visualization/MPRObjects.h>
21
22 // -------------------------------------------------------------------------
23 class QTreeWidgetItem;
24 class QVTKWidget;
25
26 namespace Ui
27 {
28   class SimpleMPRWidget;
29 }
30
31 // -------------------------------------------------------------------------
32 namespace cpExtensions
33 {
34   namespace QT
35   {
36     /**
37      */
38     class cpExtensions_EXPORT SimpleMPRWidget
39       : public QWidget
40     {
41       Q_OBJECT;
42
43     public:
44       typedef SimpleMPRWidget Self;
45
46       typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
47       typedef TMPRObjects::TStyle                     TStyle;
48       typedef TMPRObjects::TMouseCommand              TMouseCommand;
49       typedef TMPRObjects::TMouseWheelCommand         TMouseWheelCommand;
50       typedef TMPRObjects::TKeyCommand                TKeyCommand;
51       typedef TMPRObjects::TVoidCommand               TVoidCommand;
52       typedef TMPRObjects::TMouseMoveCommand          TMouseMoveCommand;
53       typedef TMPRObjects::TMouseClickCommand         TMouseClickCommand;
54       typedef TMPRObjects::TMouseDoubleClickCommand   TMouseDoubleClickCommand;
55       typedef TMPRObjects::TExposeCommand             TExposeCommand;
56       typedef TMPRObjects::TConfigureCommand          TConfigureCommand;
57       typedef TMPRObjects::TEnterCommand              TEnterCommand;
58       typedef TMPRObjects::TLeaveCommand              TLeaveCommand;
59
60     public:
61       explicit SimpleMPRWidget( QWidget* parent = 0 );
62       virtual ~SimpleMPRWidget( );
63
64       // Data management
65       unsigned int GetNumberOfData( ) const;
66       bool AddData(
67         vtkImageData* data, const std::string& name,
68         const std::string& parent
69         );
70       bool AddData(
71         vtkPolyData* data, const std::string& name
72         );
73       const std::string& GetMainImage( ) const;
74       bool SetMainImage( const std::string& name );
75       void DeleteData( const std::string& name );
76       void DeleteAllData( );
77
78       // Some qt accessors
79       void SetDataColor(
80         const std::string& name,
81         const double& r, const double& g, const double& b
82         );
83       void ShowData( const std::string& name );
84       void HideData( const std::string& name );
85
86       vtkRenderWindowInteractor* GetInteractor( unsigned int i );
87
88       // Visual objects accessors
89       std::string GetSelectedData( ) const;
90                                           
91     private slots:
92       void _SyncBottom( int a, int b );
93       void _SyncTop( int a, int b );
94
95     protected:
96       static double cm_Colors[ 8 ][ 3 ];
97
98       Ui::SimpleMPRWidget*           m_UI;
99       vtkSmartPointer< TMPRObjects > m_MPRObjects;
100       QVTKWidget*                    m_VTK[ 4 ];
101
102       struct PolyDataActor
103       {
104         vtkPolyData*        Mesh;
105         vtkPolyDataNormals* Normals;
106         vtkStripper*        Stripper;
107         vtkPolyDataMapper*  Mapper;
108         vtkQuadricLODActor* Actor;
109
110         PolyDataActor( );
111         virtual ~PolyDataActor( );
112         void Configure( vtkPolyData* pd );
113       };
114
115       struct Data
116       {
117         enum { IMAGE, MESH } Tag;
118         vtkImageData*        Image;
119         PolyDataActor        Mesh;
120
121         Data( );
122         virtual ~Data( );
123
124         Data& operator=( const Data& data );
125
126         void SetImageData( vtkImageData* data );
127         void SetPolyData( vtkPolyData* data );
128
129         vtkImageData* GetImage( );
130         vtkPolyData* GetMesh( );
131         vtkProp* GetMeshActor( );
132       };
133
134       std::string m_MainImage;
135       std::map< std::string, Data >        m_Data;
136       std::map< std::string, std::string > m_Tree;
137     };
138
139   } // ecapseman
140
141 } // ecapseman
142
143 #endif // cpExtensions_QT4
144
145 #endif // __CPEXTENSIONS__QT__SIMPLEMPRWIDGET__H__
146
147 // eof - $RCSfile$