]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h
2dafb31c8e49ccd3457bbfa0e1dec6b848ec40c8
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxVtkBaseView_SceneManager.h
1 #ifndef __wxVtkBaseView_SceneManager_h_INCLUDED_H__
2 #define __wxVtkBaseView_SceneManager_h_INCLUDED_H__
3
4
5 // -----------------------------------------------------------------------------------------------------------
6 // WX headers inclusion.
7 // For compilers that support precompilation, includes <wx/wx.h>.
8 // -----------------------------------------------------------------------------------------------------------
9
10 #include <wx/wxprec.h>
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14 #ifndef WX_PRECOMP
15 #include <wx/wx.h>
16 #endif
17
18
19 //------------------------------------------------------------------------------------------------------------
20 // Includes
21 //------------------------------------------------------------------------------------------------------------
22
23 #include "ContourWrap_ViewControl.h"
24 #include "wxVtkBaseView.h"
25 #include <iostream>
26 #include <map>
27 #include "manualContourModel.h"
28 #include "manualRoiControler.h"
29 #include "manualContourBaseControler.h"
30 #include "manualCircleControler.h"
31 #include "manualLineControler.h"
32 #include "manualViewBaseContour.h"
33 #include "manualViewBullEye.h"
34 #include "manualViewCircle.h"
35 #include "manualViewLine.h"
36 #include "manualViewPoints.h"
37 #include "manualViewRoi.h"
38 #include <wx/event.h>
39
40 //------------------------------------------------------------------------------------------------------------
41 // Events declaration
42 //------------------------------------------------------------------------------------------------------------
43 BEGIN_DECLARE_EVENT_TYPES()
44         DECLARE_EVENT_TYPE( wxEVT_START_CREATE_MULT_ROI, -1 )   
45         DECLARE_EVENT_TYPE( wxEVT_STOP_CREATE_MULT_ROI, -1 )    
46         DECLARE_EVENT_TYPE( wxEVT_SELECTED_MULT_ROI, -1 )       
47         DECLARE_EVENT_TYPE( wxEVT_START_CREATE_ROI, -1 )
48         DECLARE_EVENT_TYPE( wxEVT_STOP_CREATE_ROI, -1)
49         DECLARE_EVENT_TYPE( wxEVT_DELETE_ROI, -1 )
50         DECLARE_EVENT_TYPE( wxEVT_SELECTED_ROI, -1 )    
51         DECLARE_EVENT_TYPE( wxEVT_UNSLECTED_ROI, -1 )   
52         DECLARE_EVENT_TYPE( wxEVT_MANUAL_HIDED_ROI, -1 )        
53         DECLARE_EVENT_TYPE( wxEVT_MANUAL_SHOWED_ROI, -1 )
54         DECLARE_EVENT_TYPE( wxEVT_EDITING_ROI, -1 )     
55         DECLARE_EVENT_TYPE( wxEVT_MOVING_ROI, -1 )      
56         DECLARE_EVENT_TYPE( wxEVT_MOVING_ROI_POINT, -1 )        
57         DECLARE_EVENT_TYPE( wxEVT_SELECTED_ROI_POINT, -1 )      
58         DECLARE_EVENT_TYPE( wxEVT_UNSELECTED_ROI_POINT, -1 )                    
59         DECLARE_EVENT_TYPE( wxEVT_CHANGED_DEEP, -1 )
60 END_DECLARE_EVENT_TYPES()
61
62 /** file wxVtkBaseView_SceneManager.h */
63
64
65 //------------------------------------------------------------------------------------------------------------
66 // Class definition
67 //------------------------------------------------------------------------------------------------------------
68 class wxVtkBaseView_SceneManager : public InteractorStyleMaracas {
69
70         public:
71
72         //------------------------------------------------------------------------------------------------------------
73         // Constructors & Destructors
74         //------------------------------------------------------------------------------------------------------------
75
76         wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc );
77         ~wxVtkBaseView_SceneManager();
78
79         //------------------------------------------------------------------------------------------------------------
80         // Methods for capturing events
81         //------------------------------------------------------------------------------------------------------------
82         
83                 
84         //------------------------------------------------------------------------------------------------------------
85         //  Methods for sending events
86         //------------------------------------------------------------------------------------------------------------
87         void sendEnvent( WXTYPE theEventType, std::string text );
88
89         //------------------------------------------------------------------------------------------------------------
90         //  Attributes getters and setters
91         //------------------------------------------------------------------------------------------------------------
92         
93         void setWxVtkViewBase( wxVtkBaseView * theBaseView );
94         void setWxEventHandler( wxEvtHandler * theEventHandler );
95         wxVtkBaseView * getWxVtkViewBase();
96
97         //
98         // Method which creates and associates view and controller to the contour model type pointed in parameter.
99         // The possible contour types are:
100         // 0-spline
101         // 1-spline
102         // 2-rectangle
103         // 3-circle
104         // 4-BullEye
105         // 5-BullEyeSector
106         // 6-Line
107         // 7-Points
108         // NOTE: The model is created in the KernelManagerContour class, factoryManualContourModel method
109         // @param typeContour - int
110         // @param theKeyName - string
111         // @param manContourControl - manualBaseModel
112         // @param spc - double*  3-pos Array 
113         void configureViewControlTo( std::string theKeyName, manualBaseModel * manContourControl, double * spc ,int typeContour);
114
115         void configureSelectionROI( double * spc );
116         ContourWrap_ViewControl * insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour  * manViewerContour ); 
117         void desconfigureViewControlOf( std::string theKeyName );
118         void removeWrap( std::string theKeyName );
119         ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName );
120         ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap );
121         manualContourBaseControler * getControlerOf( std::string theName );
122         manualViewBaseContour * getViewerOf( std::string theName );
123         void set_creatingMULT_ROI( bool condition );
124         void set_editingROI( bool condition );
125         void set_toIncludeAtInteractionGroup( bool condition );
126         void set_waiting( bool condition );
127         bool get_creatingMULT_ROI(  );
128         bool get_editingROI(  );
129         bool get_toIncludeAtInteractionGroup(  );
130         bool get_waiting(  );
131         bool get_creatingROI();
132         void set_creatingROI( bool theCondition );
133
134         //------------------------------------------------------------------------------------------------------------
135         //  Other functional methods
136         //------------------------------------------------------------------------------------------------------------
137
138         void createCopyContourOf( std::string anExistingKName, std::string cloneName, manualBaseModel * manualModel, bool append = false );
139         void removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization = true, bool control = true );
140         void removeFromScene( std::string theKeyName, bool visualization = true, bool control = true );
141         void removeSceneContours( );
142         void removeAllOutlines();
143         void addToScene( std::string theKeyName, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
144         void addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
145         void removeFromScene( std::vector< std::string> theKeyNameVector, bool visualization = true, bool control = true );
146         void addToScene( std::vector< std::string> theKeyNameVector, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
147         void setControlActiveStateOfALL( bool stateCondition );
148         void setControlActiveStateOf( std::string theKeyName, bool stateCondition );
149         void setControlActiveStateOf( ContourWrap_ViewControl * contourWRP, bool stateCondition );
150         void setVisibleStateOf( std::string theKeyName, bool stateCondition );
151
152         std::vector< std::string >  getSelectedObjects();
153         void selectObjects( std::vector< std::string > theExistingObjectsToSelect );
154         void selectObjects( std::map<std::string, ContourWrap_ViewControl *> * theMap );
155         void setControlActiveStateOf( std::vector< std::string> &theKeyNameVector, bool controlCondition = false );
156         void setControlActiveStateOf( std::map<std::string, ContourWrap_ViewControl *> * theMap, bool controlCondition = false );
157         void drawSelectionROI();
158         void setSelection2DROIInternalOutlines( );
159         void writeCoords( std::string method );
160
161    // EED
162         void SaveThingName(FILE *ff, std::string nameThing);
163         void GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ );       
164         vtkImageData *GetImageData();
165         std::vector<std::string> GetlstContoursNameActualSlice();
166
167         //------------------------------------------------------------------------------------------------------------
168         // Inherited Methods
169         //------------------------------------------------------------------------------------------------------------
170
171         virtual bool  OnChar();
172         virtual bool  OnMouseMove();
173         virtual bool  OnLeftButtonDown(); 
174         virtual bool  OnLeftButtonUp();
175         virtual bool  OnMiddleButtonDown(); 
176         virtual bool  OnMiddleButtonUp();
177         virtual bool  OnRightButtonDown();
178         virtual bool  OnRightButtonUp();
179
180         virtual bool  OnLeftDClick();
181         virtual bool  OnRightDClick();   
182         virtual bool  OnMiddleDClick();  
183         virtual bool  OnMouseWheel(); 
184
185         int                       GetImageDataSizeZ();
186         void              GetImageDataRange( double *range );
187         void                    SetWidthContour(double width);
188
189 //JCP 21 - 09 - 08
190         bool isEditableCControler(std::string theKeyName);
191         void deleteCViewerCControler(std::string theKeyName);
192         bool isCtrlPressed();
193         bool isShiftPressed();
194         char getLastKeyCode();
195 private:
196         //------------------------------------------------------------------------------------------------------------
197         //  Private methods
198         //------------------------------------------------------------------------------------------------------------
199
200         
201         //------------------------------------------------------------------------------------------------------------
202         // Creational and initialization methods
203         //------------------------------------------------------------------------------------------------------------
204
205                 
206         //------------------------------------------------------------------------------------------------------------
207         // Attributtes
208         //------------------------------------------------------------------------------------------------------------
209         
210         std::map<std::string, ContourWrap_ViewControl *> * _contours_ViewControl;
211         std::map<std::string, ContourWrap_ViewControl *> * _sceneContours_ViewControl;
212         wxVtkBaseView                   *_wxVtk_BaseView;
213         wxEvtHandler                    *_eventHandler;
214         ContourWrap_ViewControl *_lastInteraction;
215         std::string                             _lastInteractionName;
216         std::map<std::string, ContourWrap_ViewControl *> * _workingGroup;
217         bool                                    _creatingMULT_ROI;
218         bool                                    _editingROI;
219         bool                                    _toIncludeAtInteractionGroup;
220         bool                                    _waiting;
221         bool                                    _creatingROI;
222         int                                             _enventID;
223         int                                             _leftClickCount;
224         int                                             _rigthClickCount;
225         int                                             clickX;
226         int                                             clickY;
227         char                                    _lastKeyCode;
228         long int                                onCharCallBackTimeEnd;
229         long int                                onCharNeeded;
230         bool                                    _drawingSelectionROI;
231         manualRoiControler              *_controlerSelectionROI;
232         manualViewRoi                   *_viewerSelectionROI;
233         manualBaseModel         *_modelSelectionROI;
234         double                                  _widthOfContour;
235
236         bool _ctrlKey;
237         bool _shiftKey;
238 };
239 #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__
240