]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h
#3385 vtk9itk5wx3-macos
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxVtkBaseView_SceneManager.h
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
48 #include "ContourWrap_ViewControl.h"
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 /* EED 2022-09-30 
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()
87 */
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);
104
105 /** file wxVtkBaseView_SceneManager.h */
106
107
108 //------------------------------------------------------------------------------------------------------------
109 // Class definition
110 //------------------------------------------------------------------------------------------------------------
111 class wxVtkBaseView_SceneManager : public InteractorStyleMaracas {
112
113         public:
114
115         //------------------------------------------------------------------------------------------------------------
116         // Constructors & Destructors
117         //------------------------------------------------------------------------------------------------------------
118
119         wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc );
120         ~wxVtkBaseView_SceneManager();
121
122         //------------------------------------------------------------------------------------------------------------
123         // Methods for capturing events
124         //------------------------------------------------------------------------------------------------------------
125         
126         //------------------------------------------------------------------------------------------------------------
127         //  Methods for sending events
128         //------------------------------------------------------------------------------------------------------------
129         void sendEnvent( WXTYPE theEventType, std::string text );
130
131         //------------------------------------------------------------------------------------------------------------
132         //  Attributes getters and setters
133         //------------------------------------------------------------------------------------------------------------
134         
135         void setWxVtkViewBase( wxVtkBaseView * theBaseView );
136         void setWxEventHandler( wxEvtHandler * theEventHandler );
137         wxVtkBaseView * getWxVtkViewBase();
138
139         //
140         // Method which creates and associates view and controller to the contour model type pointed in parameter.
141         // The possible contour types are:
142         // 0-spline
143         // 1-spline
144         // 2-rectangle
145         // 3-circle
146         // 4-BullEye
147         // 5-BullEyeSector
148         // 6-Line
149         // 7-Points
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);
156
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(  );
172         bool get_waiting(  );
173         bool get_creatingROI();
174         void set_creatingROI( bool theCondition );
175
176         //------------------------------------------------------------------------------------------------------------
177         //  Other functional methods
178         //------------------------------------------------------------------------------------------------------------
179
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 );
193
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 );
202
203    // EED
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();
208
209         //------------------------------------------------------------------------------------------------------------
210         // Inherited Methods
211         //------------------------------------------------------------------------------------------------------------
212
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();
221
222         virtual bool  OnLeftDClick();
223         virtual bool  OnRightDClick();   
224         virtual bool  OnMiddleDClick();  
225         virtual bool  OnMouseWheel(); 
226
227         int                       GetImageDataSizeZ();
228         void              GetImageDataRange( double *range );
229         void              SetWidthContour(double width);
230         void              SetShowTextContour(bool show);
231
232 //JCP 21 - 09 - 08
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 );
239
240 private:
241         //------------------------------------------------------------------------------------------------------------
242         //  Private methods
243         //------------------------------------------------------------------------------------------------------------
244         void configureTextNumberOfContour();
245
246         
247         //------------------------------------------------------------------------------------------------------------
248         // Creational and initialization methods
249         //------------------------------------------------------------------------------------------------------------
250
251                 
252         //------------------------------------------------------------------------------------------------------------
253         // Attributtes
254         //------------------------------------------------------------------------------------------------------------
255         
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;
264         bool                                                                                            _editingROI;
265         bool                                                                                            _toIncludeAtInteractionGroup;
266         bool                                                                                            _waiting;
267         bool                                                                                            _creatingROI;
268         int                                                                                                     _enventID;
269         int                                                                                                     _leftClickCount;
270         int                                                                                                     _rigthClickCount;
271         int                                                                                                     clickX;
272         int                                                                                                     clickY;
273         char                                                                                            _lastKeyCode;
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;
282         bool                                                                                            _ctrlKey;
283         bool                                                                                            _shiftKey;
284         bool                                                                                            _showTextContour;
285         vtkTextActor                                                                            *_numberOfContoursTextActor;
286 };
287 #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__
288