]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.h
#3327 creaContours Feature New Normal - Jump Slice
[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 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
87 /** file wxVtkBaseView_SceneManager.h */
88
89
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 );
102         ~wxVtkBaseView_SceneManager();
103
104         //------------------------------------------------------------------------------------------------------------
105         // Methods for capturing events
106         //------------------------------------------------------------------------------------------------------------
107         
108         //------------------------------------------------------------------------------------------------------------
109         //  Methods for sending events
110         //------------------------------------------------------------------------------------------------------------
111         void sendEnvent( WXTYPE theEventType, std::string text );
112
113         //------------------------------------------------------------------------------------------------------------
114         //  Attributes getters and setters
115         //------------------------------------------------------------------------------------------------------------
116         
117         void setWxVtkViewBase( wxVtkBaseView * theBaseView );
118         void setWxEventHandler( wxEvtHandler * theEventHandler );
119         wxVtkBaseView * getWxVtkViewBase();
120
121         //
122         // Method which creates and associates view and controller to the contour model type pointed in parameter.
123         // The possible contour types are:
124         // 0-spline
125         // 1-spline
126         // 2-rectangle
127         // 3-circle
128         // 4-BullEye
129         // 5-BullEyeSector
130         // 6-Line
131         // 7-Points
132         // NOTE: The model is created in the KernelManagerContour class, factoryManualContourModel method
133         // @param typeContour - int
134         // @param theKeyName - string
135         // @param manContourControl - manualBaseModel
136         // @param spc - double*  3-pos Array 
137         void configureViewControlTo( std::string theKeyName, manualBaseModel * manContourControl, double * spc ,int typeContour);
138
139         void configureSelectionROI( double * spc );
140         ContourWrap_ViewControl * insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour  * manViewerContour ); 
141         void desconfigureViewControlOf( std::string theKeyName );
142         void removeWrap( std::string theKeyName );
143         ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName );
144         ContourWrap_ViewControl * getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap );
145         manualContourBaseControler * getControlerOf( std::string theName );
146         manualViewBaseContour * getViewerOf( std::string theName );
147         void set_creatingMULT_ROI( bool condition );
148         void set_editingROI( bool condition );
149         void set_toIncludeAtInteractionGroup( bool condition );
150         void set_waiting( bool condition );
151         bool get_creatingMULT_ROI(  );
152         bool get_editingROI(  );
153         bool get_toIncludeAtInteractionGroup(  );
154         bool get_waiting(  );
155         bool get_creatingROI();
156         void set_creatingROI( bool theCondition );
157
158         //------------------------------------------------------------------------------------------------------------
159         //  Other functional methods
160         //------------------------------------------------------------------------------------------------------------
161
162         void createCopyContourOf( std::string anExistingKName, std::string cloneName, manualBaseModel * manualModel, bool append = false );
163         void removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization = true, bool control = true );
164         void removeFromScene( std::string theKeyName, bool visualization = true, bool control = true );
165         void removeSceneContours( );
166         void removeAllOutlines();
167         void addToScene( std::string theKeyName, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
168         void addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
169         void removeFromScene( std::vector< std::string> theKeyNameVector, bool visualization = true, bool control = true );
170         void addToScene( std::vector< std::string> theKeyNameVector, bool append = true, bool visualization = true, bool control = true, bool ifActive = true, bool ifShowCtrlPoints = true );
171         void setControlActiveStateOfALL( bool stateCondition );
172         void setControlActiveStateOf( std::string theKeyName, bool stateCondition );
173         void setControlActiveStateOf( ContourWrap_ViewControl * contourWRP, bool stateCondition );
174         void setVisibleStateOf( std::string theKeyName, bool stateCondition );
175
176         std::vector< std::string >  getSelectedObjects();
177         void selectObjects( std::vector< std::string > theExistingObjectsToSelect );
178         void selectObjects( std::map<std::string, ContourWrap_ViewControl *> * theMap );
179         void setControlActiveStateOf( std::vector< std::string> &theKeyNameVector, bool controlCondition = false );
180         void setControlActiveStateOf( std::map<std::string, ContourWrap_ViewControl *> * theMap, bool controlCondition = false );
181         void drawSelectionROI();
182         void setSelection2DROIInternalOutlines( );
183         void writeCoords( std::string method );
184
185    // EED
186         void SaveThingName(FILE *ff, std::string nameThing);
187         void GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ );       
188         vtkImageData *GetImageData();
189         std::vector<std::string> GetlstContoursNameActualSlice();
190
191         //------------------------------------------------------------------------------------------------------------
192         // Inherited Methods
193         //------------------------------------------------------------------------------------------------------------
194
195         virtual bool  OnChar();
196         virtual bool  OnMouseMove();
197         virtual bool  OnLeftButtonDown(); 
198         virtual bool  OnLeftButtonUp();
199         virtual bool  OnMiddleButtonDown(); 
200         virtual bool  OnMiddleButtonUp();
201         virtual bool  OnRightButtonDown();
202         virtual bool  OnRightButtonUp();
203
204         virtual bool  OnLeftDClick();
205         virtual bool  OnRightDClick();   
206         virtual bool  OnMiddleDClick();  
207         virtual bool  OnMouseWheel(); 
208
209         int                       GetImageDataSizeZ();
210         void              GetImageDataRange( double *range );
211         void              SetWidthContour(double width);
212         void              SetShowTextContour(bool show);
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         void SetLabelNumberOfContours( std::string label );
221
222 private:
223         //------------------------------------------------------------------------------------------------------------
224         //  Private methods
225         //------------------------------------------------------------------------------------------------------------
226         void configureTextNumberOfContour();
227
228         
229         //------------------------------------------------------------------------------------------------------------
230         // Creational and initialization methods
231         //------------------------------------------------------------------------------------------------------------
232
233                 
234         //------------------------------------------------------------------------------------------------------------
235         // Attributtes
236         //------------------------------------------------------------------------------------------------------------
237         
238         std::map<std::string, ContourWrap_ViewControl *>        *_contours_ViewControl;
239         std::map<std::string, ContourWrap_ViewControl *>        *_sceneContours_ViewControl;
240         wxVtkBaseView                                                                           *_wxVtk_BaseView;
241         wxEvtHandler                                                                            *_eventHandler;
242         ContourWrap_ViewControl                                                         *_lastInteraction;
243         std::string                                                                                     _lastInteractionName;
244         std::map<std::string, ContourWrap_ViewControl *>        *_workingGroup;
245         bool                                                                                            _creatingMULT_ROI;
246         bool                                                                                            _editingROI;
247         bool                                                                                            _toIncludeAtInteractionGroup;
248         bool                                                                                            _waiting;
249         bool                                                                                            _creatingROI;
250         int                                                                                                     _enventID;
251         int                                                                                                     _leftClickCount;
252         int                                                                                                     _rigthClickCount;
253         int                                                                                                     clickX;
254         int                                                                                                     clickY;
255         char                                                                                            _lastKeyCode;
256         long int                                                                                        onCharCallBackTimeEnd;
257         long int                                                                                        onCharNeeded;
258         bool                                                                                            _drawingSelectionROI;
259         manualRoiControler                                                                      *_controlerSelectionROI;
260         manualViewRoi                                                                           *_viewerSelectionROI;
261         manualBaseModel                                                                         *_modelSelectionROI;
262         double                                                                                          _widthOfContour;
263         double                                                                                          _widthOfControlPoint;
264         bool                                                                                            _ctrlKey;
265         bool                                                                                            _shiftKey;
266         bool                                                                                            _showTextContour;
267         vtkTextActor                                                                            *_numberOfContoursTextActor;
268 };
269 #endif // __wxVtkBaseView_SceneManager_HEADER_FILE__
270