creaContours_lib
wxVtkBaseView_SceneManager.h
Go to the documentation of this file.
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 # pour la Sant�)
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
8 #
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.
15 #
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
20 # liability.
21 #
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 # ------------------------------------------------------------------------ */
25 
26 #ifndef __wxVtkBaseView_SceneManager_h_INCLUDED_H__
27 #define __wxVtkBaseView_SceneManager_h_INCLUDED_H__
28 
29 
30 // -----------------------------------------------------------------------------------------------------------
31 // WX headers inclusion.
32 // For compilers that support precompilation, includes <wx/wx.h>.
33 // -----------------------------------------------------------------------------------------------------------
34 
35 #include <wx/wxprec.h>
36 #ifdef __BORLANDC__
37 #pragma hdrstop
38 #endif
39 #ifndef WX_PRECOMP
40 #include <wx/wx.h>
41 #endif
42 
43 
44 //------------------------------------------------------------------------------------------------------------
45 // Includes
46 //------------------------------------------------------------------------------------------------------------
47 
49 #include "wxVtkBaseView.h"
50 #include <iostream>
51 #include <map>
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"
63 #include <wx/event.h>
64 
65 //------------------------------------------------------------------------------------------------------------
66 // Events declaration
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()
86 
90 //------------------------------------------------------------------------------------------------------------
91 // Class definition
92 //------------------------------------------------------------------------------------------------------------
93 class wxVtkBaseView_SceneManager : public InteractorStyleMaracas {
94 
95  public:
96 
97  //------------------------------------------------------------------------------------------------------------
98  // Constructors & Destructors
99  //------------------------------------------------------------------------------------------------------------
100 
101  wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc );
103 
104  //------------------------------------------------------------------------------------------------------------
105  // Methods for capturing events
106  //------------------------------------------------------------------------------------------------------------
107 
108 
109  //------------------------------------------------------------------------------------------------------------
110  // Methods for sending events
111  //------------------------------------------------------------------------------------------------------------
112  void sendEnvent( WXTYPE theEventType, std::string text );
113 
114  //------------------------------------------------------------------------------------------------------------
115  // Attributes getters and setters
116  //------------------------------------------------------------------------------------------------------------
117 
118  void setWxVtkViewBase( wxVtkBaseView * theBaseView );
119  void setWxEventHandler( wxEvtHandler * theEventHandler );
120  wxVtkBaseView * getWxVtkViewBase();
121 
122  //
123  // Method which creates and associates view and controller to the contour model type pointed in parameter.
124  // The possible contour types are:
125  // 0-spline
126  // 1-spline
127  // 2-rectangle
128  // 3-circle
129  // 4-BullEye
130  // 5-BullEyeSector
131  // 6-Line
132  // 7-Points
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);
139 
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( );
155  bool get_waiting( );
156  bool get_creatingROI();
157  void set_creatingROI( bool theCondition );
158 
159  //------------------------------------------------------------------------------------------------------------
160  // Other functional methods
161  //------------------------------------------------------------------------------------------------------------
162 
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 );
176 
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 );
185 
186  // EED
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();
191 
192  //------------------------------------------------------------------------------------------------------------
193  // Inherited Methods
194  //------------------------------------------------------------------------------------------------------------
195 
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();
204 
205  virtual bool OnLeftDClick();
206  virtual bool OnRightDClick();
207  virtual bool OnMiddleDClick();
208  virtual bool OnMouseWheel();
209 
210  int GetImageDataSizeZ();
211  void GetImageDataRange( double *range );
212  void SetWidthContour(double width);
213 
214 //JCP 21 - 09 - 08
215  bool isEditableCControler(std::string theKeyName);
216  void deleteCViewerCControler(std::string theKeyName);
217  bool isCtrlPressed();
218  bool isShiftPressed();
219  char getLastKeyCode();
220 private:
221  //------------------------------------------------------------------------------------------------------------
222  // Private methods
223  //------------------------------------------------------------------------------------------------------------
224 
225 
226  //------------------------------------------------------------------------------------------------------------
227  // Creational and initialization methods
228  //------------------------------------------------------------------------------------------------------------
229 
230 
231  //------------------------------------------------------------------------------------------------------------
232  // Attributtes
233  //------------------------------------------------------------------------------------------------------------
234 
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;
240  std::string _lastInteractionName;
241  std::map<std::string, ContourWrap_ViewControl *> * _workingGroup;
245  bool _waiting;
250  int clickX;
251  int clickY;
254  long int onCharNeeded;
256  manualRoiControler *_controlerSelectionROI;
257  manualViewRoi *_viewerSelectionROI;
258  manualBaseModel *_modelSelectionROI;
261 
262  bool _ctrlKey;
263  bool _shiftKey;
264 };
265 #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__
266