1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #ifndef __wxVtkBaseView_SceneManager_h_INCLUDED_H__
27 #define __wxVtkBaseView_SceneManager_h_INCLUDED_H__
30 // -----------------------------------------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // -----------------------------------------------------------------------------------------------------------
35 #include <wx/wxprec.h>
44 //------------------------------------------------------------------------------------------------------------
46 //------------------------------------------------------------------------------------------------------------
48 #include "ContourWrap_ViewControl.h"
49 #include "wxVtkBaseView.h"
52 #include "manualContourModel.h"
53 #include "manualRoiControler.h"
54 #include "manualContourBaseControler.h"
55 #include "manualCircleControler.h"
56 #include "manualLineControler.h"
57 #include "manualViewBaseContour.h"
58 #include "manualViewBullEye.h"
59 #include "manualViewCircle.h"
60 #include "manualViewLine.h"
61 #include "manualViewPoints.h"
62 #include "manualViewRoi.h"
65 //------------------------------------------------------------------------------------------------------------
67 //------------------------------------------------------------------------------------------------------------
69 BEGIN_DECLARE_EVENT_TYPES()
70 DECLARE_EVENT_TYPE( wxEVT_START_CREATE_MULT_ROI, -1 )
71 DECLARE_EVENT_TYPE( wxEVT_STOP_CREATE_MULT_ROI, -1 )
72 DECLARE_EVENT_TYPE( wxEVT_SELECTED_MULT_ROI, -1 )
73 DECLARE_EVENT_TYPE( wxEVT_START_CREATE_ROI, -1 )
74 DECLARE_EVENT_TYPE( wxEVT_STOP_CREATE_ROI, -1)
75 DECLARE_EVENT_TYPE( wxEVT_DELETE_ROI, -1 )
76 DECLARE_EVENT_TYPE( wxEVT_SELECTED_ROI, -1 )
77 DECLARE_EVENT_TYPE( wxEVT_UNSLECTED_ROI, -1 )
78 DECLARE_EVENT_TYPE( wxEVT_MANUAL_HIDED_ROI, -1 )
79 DECLARE_EVENT_TYPE( wxEVT_MANUAL_SHOWED_ROI, -1 )
80 DECLARE_EVENT_TYPE( wxEVT_EDITING_ROI, -1 )
81 DECLARE_EVENT_TYPE( wxEVT_MOVING_ROI, -1 )
82 DECLARE_EVENT_TYPE( wxEVT_MOVING_ROI_POINT, -1 )
83 DECLARE_EVENT_TYPE( wxEVT_SELECTED_ROI_POINT, -1 )
84 DECLARE_EVENT_TYPE( wxEVT_UNSELECTED_ROI_POINT, -1 )
85 DECLARE_EVENT_TYPE( wxEVT_CHANGED_DEEP, -1 )
86 END_DECLARE_EVENT_TYPES()
88 wxDECLARE_EVENT(wxEVT_START_CREATE_MULT_ROI, wxCommandEvent);
89 wxDECLARE_EVENT(wxEVT_STOP_CREATE_MULT_ROI, wxCommandEvent);
90 wxDECLARE_EVENT(wxEVT_SELECTED_MULT_ROI, wxCommandEvent);
91 wxDECLARE_EVENT(wxEVT_START_CREATE_ROI, wxCommandEvent);
92 wxDECLARE_EVENT(wxEVT_STOP_CREATE_ROI, wxCommandEvent);
93 wxDECLARE_EVENT(wxEVT_DELETE_ROI, wxCommandEvent);
94 wxDECLARE_EVENT(wxEVT_SELECTED_ROI, wxCommandEvent);
95 wxDECLARE_EVENT(wxEVT_UNSLECTED_ROI, wxCommandEvent);
96 wxDECLARE_EVENT(wxEVT_MANUAL_HIDED_ROI, wxCommandEvent);
97 wxDECLARE_EVENT(wxEVT_MANUAL_SHOWED_ROI, wxCommandEvent);
98 wxDECLARE_EVENT(wxEVT_EDITING_ROI, wxCommandEvent);
99 wxDECLARE_EVENT(wxEVT_MOVING_ROI, wxCommandEvent);
100 wxDECLARE_EVENT(wxEVT_MOVING_ROI_POINT, wxCommandEvent);
101 wxDECLARE_EVENT(wxEVT_SELECTED_ROI_POINT, wxCommandEvent);
102 wxDECLARE_EVENT(wxEVT_UNSELECTED_ROI_POINT, wxCommandEvent);
103 wxDECLARE_EVENT(wxEVT_CHANGED_DEEP, wxCommandEvent);
105 /** file wxVtkBaseView_SceneManager.h */
108 //------------------------------------------------------------------------------------------------------------
110 //------------------------------------------------------------------------------------------------------------
111 class wxVtkBaseView_SceneManager : public InteractorStyleMaracas {
115 //------------------------------------------------------------------------------------------------------------
116 // Constructors & Destructors
117 //------------------------------------------------------------------------------------------------------------
119 wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc );
120 ~wxVtkBaseView_SceneManager();
122 //------------------------------------------------------------------------------------------------------------
123 // Methods for capturing events
124 //------------------------------------------------------------------------------------------------------------
126 //------------------------------------------------------------------------------------------------------------
127 // Methods for sending events
128 //------------------------------------------------------------------------------------------------------------
129 void sendEnvent( WXTYPE theEventType, std::string text );
131 //------------------------------------------------------------------------------------------------------------
132 // Attributes getters and setters
133 //------------------------------------------------------------------------------------------------------------
135 void setWxVtkViewBase( wxVtkBaseView * theBaseView );
136 void setWxEventHandler( wxEvtHandler * theEventHandler );
137 wxVtkBaseView * getWxVtkViewBase();
140 // Method which creates and associates view and controller to the contour model type pointed in parameter.
141 // The possible contour types are:
150 // NOTE: The model is created in the KernelManagerContour class, factoryManualContourModel method
151 // @param typeContour - int
152 // @param theKeyName - string
153 // @param manContourControl - manualBaseModel
154 // @param spc - double* 3-pos Array
155 void configureViewControlTo( std::string theKeyName, manualBaseModel * manContourControl, double * spc ,int typeContour);
157 void configureSelectionROI( double * spc );
158 ContourWrap_ViewControl * insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour * manViewerContour );
159 void desconfigureViewControlOf( std::string theKeyName );
160 void removeWrap( std::string theKeyName );
161 ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName );
162 ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap );
163 manualContourBaseControler * getControlerOf( std::string theName );
164 manualViewBaseContour * getViewerOf( std::string theName );
165 void set_creatingMULT_ROI( bool condition );
166 void set_editingROI( bool condition );
167 void set_toIncludeAtInteractionGroup( bool condition );
168 void set_waiting( bool condition );
169 bool get_creatingMULT_ROI( );
170 bool get_editingROI( );
171 bool get_toIncludeAtInteractionGroup( );
173 bool get_creatingROI();
174 void set_creatingROI( bool theCondition );
176 //------------------------------------------------------------------------------------------------------------
177 // Other functional methods
178 //------------------------------------------------------------------------------------------------------------
180 void createCopyContourOf( std::string anExistingKName, std::string cloneName, manualBaseModel * manualModel, bool append = false );
181 void removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization = true, bool control = true );
182 void removeFromScene( std::string theKeyName, bool visualization = true, bool control = true );
183 void removeSceneContours( );
184 void removeAllOutlines();
185 void addToScene( std::string theKeyName, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
186 void addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
187 void removeFromScene( std::vector< std::string> theKeyNameVector, bool visualization = true, bool control = true );
188 void addToScene( std::vector< std::string> theKeyNameVector, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
189 void setControlActiveStateOfALL( bool stateCondition );
190 void setControlActiveStateOf( std::string theKeyName, bool stateCondition );
191 void setControlActiveStateOf( ContourWrap_ViewControl * contourWRP, bool stateCondition );
192 void setVisibleStateOf( std::string theKeyName, bool stateCondition );
194 std::vector< std::string > getSelectedObjects();
195 void selectObjects( std::vector< std::string > theExistingObjectsToSelect );
196 void selectObjects( std::map<std::string, ContourWrap_ViewControl *> * theMap );
197 void setControlActiveStateOf( std::vector< std::string> &theKeyNameVector, bool controlCondition = false );
198 void setControlActiveStateOf( std::map<std::string, ContourWrap_ViewControl *> * theMap, bool controlCondition = false );
199 void drawSelectionROI();
200 void setSelection2DROIInternalOutlines( );
201 void writeCoords( std::string method );
204 void SaveThingName(FILE *ff, std::string nameThing);
205 void GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ );
206 vtkImageData *GetImageData();
207 std::vector<std::string> GetlstContoursNameActualSlice();
209 //------------------------------------------------------------------------------------------------------------
211 //------------------------------------------------------------------------------------------------------------
213 virtual bool OnChar();
214 virtual bool OnMouseMove();
215 virtual bool OnLeftButtonDown();
216 virtual bool OnLeftButtonUp();
217 virtual bool OnMiddleButtonDown();
218 virtual bool OnMiddleButtonUp();
219 virtual bool OnRightButtonDown();
220 virtual bool OnRightButtonUp();
222 virtual bool OnLeftDClick();
223 virtual bool OnRightDClick();
224 virtual bool OnMiddleDClick();
225 virtual bool OnMouseWheel();
227 int GetImageDataSizeZ();
228 void GetImageDataRange( double *range );
229 void SetWidthContour(double width);
230 void SetShowTextContour(bool show);
233 bool isEditableCControler(std::string theKeyName);
234 void deleteCViewerCControler(std::string theKeyName);
235 bool isCtrlPressed();
236 bool isShiftPressed();
237 char getLastKeyCode();
238 void SetLabelNumberOfContours( std::string label );
241 //------------------------------------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------------------------------------
244 void configureTextNumberOfContour();
247 //------------------------------------------------------------------------------------------------------------
248 // Creational and initialization methods
249 //------------------------------------------------------------------------------------------------------------
252 //------------------------------------------------------------------------------------------------------------
254 //------------------------------------------------------------------------------------------------------------
256 std::map<std::string, ContourWrap_ViewControl *> *_contours_ViewControl;
257 std::map<std::string, ContourWrap_ViewControl *> *_sceneContours_ViewControl;
258 wxVtkBaseView *_wxVtk_BaseView;
259 wxEvtHandler *_eventHandler;
260 ContourWrap_ViewControl *_lastInteraction;
261 std::string _lastInteractionName;
262 std::map<std::string, ContourWrap_ViewControl *> *_workingGroup;
263 bool _creatingMULT_ROI;
265 bool _toIncludeAtInteractionGroup;
270 int _rigthClickCount;
274 long int onCharCallBackTimeEnd;
275 long int onCharNeeded;
276 bool _drawingSelectionROI;
277 manualRoiControler *_controlerSelectionROI;
278 manualViewRoi *_viewerSelectionROI;
279 manualBaseModel *_modelSelectionROI;
280 double _widthOfContour;
281 double _widthOfControlPoint;
284 bool _showTextContour;
285 vtkTextActor *_numberOfContoursTextActor;
287 #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__