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 //------------------------------------------------------------------------------------------------------------
68 BEGIN_DECLARE_EVENT_TYPES()
69 DECLARE_EVENT_TYPE( wxEVT_START_CREATE_MULT_ROI, -1 )
70 DECLARE_EVENT_TYPE( wxEVT_STOP_CREATE_MULT_ROI, -1 )
71 DECLARE_EVENT_TYPE( wxEVT_SELECTED_MULT_ROI, -1 )
72 DECLARE_EVENT_TYPE( wxEVT_START_CREATE_ROI, -1 )
73 DECLARE_EVENT_TYPE( wxEVT_STOP_CREATE_ROI, -1)
74 DECLARE_EVENT_TYPE( wxEVT_DELETE_ROI, -1 )
75 DECLARE_EVENT_TYPE( wxEVT_SELECTED_ROI, -1 )
76 DECLARE_EVENT_TYPE( wxEVT_UNSLECTED_ROI, -1 )
77 DECLARE_EVENT_TYPE( wxEVT_MANUAL_HIDED_ROI, -1 )
78 DECLARE_EVENT_TYPE( wxEVT_MANUAL_SHOWED_ROI, -1 )
79 DECLARE_EVENT_TYPE( wxEVT_EDITING_ROI, -1 )
80 DECLARE_EVENT_TYPE( wxEVT_MOVING_ROI, -1 )
81 DECLARE_EVENT_TYPE( wxEVT_MOVING_ROI_POINT, -1 )
82 DECLARE_EVENT_TYPE( wxEVT_SELECTED_ROI_POINT, -1 )
83 DECLARE_EVENT_TYPE( wxEVT_UNSELECTED_ROI_POINT, -1 )
84 DECLARE_EVENT_TYPE( wxEVT_CHANGED_DEEP, -1 )
85 END_DECLARE_EVENT_TYPES()
87 /** file wxVtkBaseView_SceneManager.h */
90 //------------------------------------------------------------------------------------------------------------
92 //------------------------------------------------------------------------------------------------------------
93 class wxVtkBaseView_SceneManager : public InteractorStyleMaracas {
97 //------------------------------------------------------------------------------------------------------------
98 // Constructors & Destructors
99 //------------------------------------------------------------------------------------------------------------
101 wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc );
102 ~wxVtkBaseView_SceneManager();
104 //------------------------------------------------------------------------------------------------------------
105 // Methods for capturing events
106 //------------------------------------------------------------------------------------------------------------
109 //------------------------------------------------------------------------------------------------------------
110 // Methods for sending events
111 //------------------------------------------------------------------------------------------------------------
112 void sendEnvent( WXTYPE theEventType, std::string text );
114 //------------------------------------------------------------------------------------------------------------
115 // Attributes getters and setters
116 //------------------------------------------------------------------------------------------------------------
118 void setWxVtkViewBase( wxVtkBaseView * theBaseView );
119 void setWxEventHandler( wxEvtHandler * theEventHandler );
120 wxVtkBaseView * getWxVtkViewBase();
123 // Method which creates and associates view and controller to the contour model type pointed in parameter.
124 // The possible contour types are:
133 // NOTE: The model is created in the KernelManagerContour class, factoryManualContourModel method
134 // @param typeContour - int
135 // @param theKeyName - string
136 // @param manContourControl - manualBaseModel
137 // @param spc - double* 3-pos Array
138 void configureViewControlTo( std::string theKeyName, manualBaseModel * manContourControl, double * spc ,int typeContour);
140 void configureSelectionROI( double * spc );
141 ContourWrap_ViewControl * insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour * manViewerContour );
142 void desconfigureViewControlOf( std::string theKeyName );
143 void removeWrap( std::string theKeyName );
144 ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName );
145 ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap );
146 manualContourBaseControler * getControlerOf( std::string theName );
147 manualViewBaseContour * getViewerOf( std::string theName );
148 void set_creatingMULT_ROI( bool condition );
149 void set_editingROI( bool condition );
150 void set_toIncludeAtInteractionGroup( bool condition );
151 void set_waiting( bool condition );
152 bool get_creatingMULT_ROI( );
153 bool get_editingROI( );
154 bool get_toIncludeAtInteractionGroup( );
156 bool get_creatingROI();
157 void set_creatingROI( bool theCondition );
159 //------------------------------------------------------------------------------------------------------------
160 // Other functional methods
161 //------------------------------------------------------------------------------------------------------------
163 void createCopyContourOf( std::string anExistingKName, std::string cloneName, manualBaseModel * manualModel, bool append = false );
164 void removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization = true, bool control = true );
165 void removeFromScene( std::string theKeyName, bool visualization = true, bool control = true );
166 void removeSceneContours( );
167 void removeAllOutlines();
168 void addToScene( std::string theKeyName, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
169 void addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
170 void removeFromScene( std::vector< std::string> theKeyNameVector, bool visualization = true, bool control = true );
171 void addToScene( std::vector< std::string> theKeyNameVector, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
172 void setControlActiveStateOfALL( bool stateCondition );
173 void setControlActiveStateOf( std::string theKeyName, bool stateCondition );
174 void setControlActiveStateOf( ContourWrap_ViewControl * contourWRP, bool stateCondition );
175 void setVisibleStateOf( std::string theKeyName, bool stateCondition );
177 std::vector< std::string > getSelectedObjects();
178 void selectObjects( std::vector< std::string > theExistingObjectsToSelect );
179 void selectObjects( std::map<std::string, ContourWrap_ViewControl *> * theMap );
180 void setControlActiveStateOf( std::vector< std::string> &theKeyNameVector, bool controlCondition = false );
181 void setControlActiveStateOf( std::map<std::string, ContourWrap_ViewControl *> * theMap, bool controlCondition = false );
182 void drawSelectionROI();
183 void setSelection2DROIInternalOutlines( );
184 void writeCoords( std::string method );
187 void SaveThingName(FILE *ff, std::string nameThing);
188 void GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ );
189 vtkImageData *GetImageData();
190 std::vector<std::string> GetlstContoursNameActualSlice();
192 //------------------------------------------------------------------------------------------------------------
194 //------------------------------------------------------------------------------------------------------------
196 virtual bool OnChar();
197 virtual bool OnMouseMove();
198 virtual bool OnLeftButtonDown();
199 virtual bool OnLeftButtonUp();
200 virtual bool OnMiddleButtonDown();
201 virtual bool OnMiddleButtonUp();
202 virtual bool OnRightButtonDown();
203 virtual bool OnRightButtonUp();
205 virtual bool OnLeftDClick();
206 virtual bool OnRightDClick();
207 virtual bool OnMiddleDClick();
208 virtual bool OnMouseWheel();
210 int GetImageDataSizeZ();
211 void GetImageDataRange( double *range );
212 void SetWidthContour(double width);
215 bool isEditableCControler(std::string theKeyName);
216 void deleteCViewerCControler(std::string theKeyName);
217 bool isCtrlPressed();
218 bool isShiftPressed();
219 char getLastKeyCode();
221 //------------------------------------------------------------------------------------------------------------
223 //------------------------------------------------------------------------------------------------------------
226 //------------------------------------------------------------------------------------------------------------
227 // Creational and initialization methods
228 //------------------------------------------------------------------------------------------------------------
231 //------------------------------------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------------------------------------
235 std::map<std::string, ContourWrap_ViewControl *> * _contours_ViewControl;
236 std::map<std::string, ContourWrap_ViewControl *> * _sceneContours_ViewControl;
237 wxVtkBaseView *_wxVtk_BaseView;
238 wxEvtHandler *_eventHandler;
239 ContourWrap_ViewControl *_lastInteraction;
240 std::string _lastInteractionName;
241 std::map<std::string, ContourWrap_ViewControl *> * _workingGroup;
242 bool _creatingMULT_ROI;
244 bool _toIncludeAtInteractionGroup;
249 int _rigthClickCount;
253 long int onCharCallBackTimeEnd;
254 long int onCharNeeded;
255 bool _drawingSelectionROI;
256 manualRoiControler *_controlerSelectionROI;
257 manualViewRoi *_viewerSelectionROI;
258 manualBaseModel *_modelSelectionROI;
259 double _widthOfContour;
260 double _widthOfControlPoint;
265 #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__