]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/BaseMPRWidget.h
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpPlugins / Interface / BaseMPRWidget.h
1 #ifndef __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__
2 #define __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__
3
4 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
5 #include <cpPlugins/Interface/Config.h>
6
7 #ifdef cpPlugins_Interface_QT4
8
9 #include <map>
10 #include <string>
11
12 #include <QWidget>
13
14 #include <vtkSmartPointer.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 BaseMPRWidget;
29 }
30
31 // -------------------------------------------------------------------------
32 namespace cpPlugins
33 {
34   namespace Interface
35   {
36     /**
37      */
38     class cpPlugins_Interface_EXPORT BaseMPRWidget
39       : public QWidget
40     {
41       Q_OBJECT;
42
43     public:
44       typedef cpExtensions::Visualization::MPRObjects TMPRObjects;
45
46       typedef TMPRObjects::TStyle                   TStyle;
47       typedef TMPRObjects::TMouseCommand            TMouseCommand;
48       typedef TMPRObjects::TMouseWheelCommand       TMouseWheelCommand;
49       typedef TMPRObjects::TKeyCommand              TKeyCommand;
50       typedef TMPRObjects::TVoidCommand             TVoidCommand;
51       typedef TMPRObjects::TMouseMoveCommand        TMouseMoveCommand;
52       typedef TMPRObjects::TMouseClickCommand       TMouseClickCommand;
53       typedef TMPRObjects::TMouseDoubleClickCommand TMouseDoubleClickCommand;
54       typedef TMPRObjects::TExposeCommand           TExposeCommand;
55       typedef TMPRObjects::TConfigureCommand        TConfigureCommand;
56       typedef TMPRObjects::TEnterCommand            TEnterCommand;
57       typedef TMPRObjects::TLeaveCommand            TLeaveCommand;
58
59     public:
60       explicit BaseMPRWidget( QWidget* parent = 0 );
61       virtual ~BaseMPRWidget( );
62
63       // Some visualization accessors
64       bool ShowImage(
65         vtkImageData* image,
66         const std::string& name,
67         const std::string& parent = ""
68         );
69       bool ShowImage(
70         vtkImageData* image,
71         const std::string& name,
72         const std::string& parent,
73         const double& r, const double& g, const double& b
74         );
75       bool ShowMesh(
76         vtkPolyData* mesh,
77         const std::string& name,
78         const std::string& parent
79         );
80       bool ShowMesh(
81         vtkPolyData* mesh,
82         const std::string& name,
83         const std::string& parent,
84         const double& r, const double& g, const double& b
85         );
86       void ClearAll( );
87
88       // Visual objects accessors
89       std::string GetSelectedData( ) const;
90
91     protected:
92       QTreeWidgetItem* _FindItem( const std::string& name ) const;
93       QTreeWidgetItem* _UpdateItem(
94         const std::string& name,
95         const std::string& parent
96         );
97       
98       void _Add3DActor( vtkProp3D* prop );
99
100     private slots:
101       void _SyncBottom( int a, int b );
102       void _SyncTop( int a, int b );
103
104     protected:
105       Ui::BaseMPRWidget*             m_UI;
106       vtkSmartPointer< TMPRObjects > m_MPRObjects;
107
108       struct PolyDataActor
109       {
110         vtkSmartPointer< vtkPolyDataNormals > Normals;
111         vtkSmartPointer< vtkStripper >        Stripper;
112         vtkSmartPointer< vtkPolyDataMapper >  Mapper;
113         vtkSmartPointer< vtkQuadricLODActor > Actor;
114
115         PolyDataActor( vtkPolyData* pd );
116       };
117
118       std::map< std::string, vtkImageData* >  m_Images;
119       std::map< std::string, PolyDataActor* > m_Meshes;
120       std::map< std::string, std::string >    m_Tree;
121
122       QVTKWidget* m_VTK[ 4 ];
123     };
124
125   } // ecapseman
126
127 } // ecapseman
128
129 #endif // cpPlugins_Interface_QT4
130
131 #endif // __CPPLUGINS__INTERFACE__BASEMPRWIDGET__H__
132
133 // eof - $RCSfile$