]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.h
#3383 NDimension changeImage
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourViewPanel.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 __wxContourViewPaneL_h_INCLUDED_H__
27 #define __wxContourViewPaneL_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 #include <wx/scrolwin.h>
44
45 //------------------------------------------------------------------------------------------------------------
46 // Includes
47 //------------------------------------------------------------------------------------------------------------
48
49 #include "mBarRange.h"
50 #include "wxMaracas_N_ViewersWidget.h"
51 #include "vtkImageData.h"
52 #include "wxVtkBaseView.h"
53 #include <iostream>
54 #include <wx/event.h>
55 #include "wxVtkBaseView_SceneManager.h"
56 #include "manualContourModel.h"
57
58 #include <vtkImageMapToWindowLevelColors.h>
59
60
61 //------------------------------------------------------------------------------------------------------------
62 // Events declaration
63 //------------------------------------------------------------------------------------------------------------
64
65 BEGIN_DECLARE_EVENT_TYPES()
66         DECLARE_EVENT_TYPE(wxINSTANT_CHANGE,400)
67 END_DECLARE_EVENT_TYPES()
68
69
70 /** file wx
71
72 ViewPanel.h */
73
74 //------------------------------------------------------------------------------------------------------------
75 // Class definition
76 //------------------------------------------------------------------------------------------------------------
77
78 class wxContourViewPanel : public wxPanel 
79 {
80         public:
81         //------------------------------------------------------------------------------------------------------------
82         // Constructors & Destructors
83         //------------------------------------------------------------------------------------------------------------
84         wxContourViewPanel( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos=wxDefaultPosition, const wxSize& size = wxDefaultSize,long style= wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER, int vertStart=1, int vertEnd=1, int horzStart=1, int horzEnd=1 );
85         ~wxContourViewPanel();
86         //------------------------------------------------------------------------------------------------------------
87         // Creational and initialization methods
88         //------------------------------------------------------------------------------------------------------------
89         void setWxEventHandler( wxEvtHandler * theEventHandler );
90         void createHorizontalBar(int horzStart, int horzEnd);
91         void createVerticalBar(int vertStart, int vertEnd);
92         void createViewPanel();
93         //------------------------------------------------------------------------------------------------------------
94         // Methods for capturing events from the horizontal bar
95         //------------------------------------------------------------------------------------------------------------
96         /**
97         * Handles the event wxEVT_TSBAR from the horizontal bar 
98         */
99         void onBarrange_Horizontal(wxCommandEvent& event);
100         /**
101         * Handles the event wxEVT_TSBAR_ACTUAL from the horizontal bar  
102         */
103         void onActualChange_Bar_Horizontal(wxCommandEvent& event);
104         /**
105         * Handles the event wxEVT_TSBAR_START from the horizontal bar   
106         */
107         void onStartChange_Bar_Horizontal(wxCommandEvent& event);
108         /**
109         * Handles the event wxEVT_TSBAR_END from the horizontal bar     
110         */
111         void onEndChange_Bar_Horizontal(wxCommandEvent& event);
112         /**
113         * Handles the event wxEVT_SELECTION_END from the horizontal bar 
114         */
115         void onSelectionEnd_Horizontal(wxCommandEvent& event);
116         /**
117         * Handles the event wxEVT_TSBAR_MOVED from the horizontal bar   
118         */
119         void onMovedBar_Horizontal(wxCommandEvent& event);
120
121
122         //------------------------------------------------------------------------------------------------------------
123         // Methods for capturing events from the vertical bar
124         //------------------------------------------------------------------------------------------------------------
125
126         /**
127         * Handles the event wxEVT_TSBAR from the vertical bar   
128         */
129         void onBarrange_Vertical(wxCommandEvent& event);
130         /**
131         * Handles the event wxEVT_TSBAR_ACTUAL from the vertical bar    
132         */
133         void onActualChange_Bar_Vertical(wxCommandEvent& event);
134         /**
135         * Handles the event wxEVT_TSBAR_START from the vertical bar     
136         */
137         void onStartChange_Bar_Vertical(wxCommandEvent& event);
138         /**
139         * Handles the event wxEVT_TSBAR_END from the vertical bar       
140         */
141         void onEndChange_Bar_Vertical(wxCommandEvent& event);
142         /**
143         * Handles the event wxEVT_SELECTION_END from the vertical bar   
144         */
145         void onSelectionEnd_Vertical(wxCommandEvent& event);
146         /**
147         * Handles the event wxEVT_TSBAR_MOVED from the vertical bar     
148         */
149         void onMovedBar_Vertical(wxCommandEvent& event);
150
151
152         //------------------------------------------------------------------------------------------------------------
153         //  Methods for sending events
154         //------------------------------------------------------------------------------------------------------------
155
156         //------------------------------------------------------------------------------------------------------------
157         //  Attributes getters and setters
158         //------------------------------------------------------------------------------------------------------------
159         
160         /**
161         * Sets the represented values of the vertical bar
162         * @param minRepresented In the minimum represented value of the bar
163         * @param maxRepresented In the maximum represented value of the bar
164         */
165         void setVerticalRepresentedValues( int minRepresented, int maxRepresented );
166
167         /**
168         * Sets the represented values of the horizontal bar
169         * @param minRepresented In the minimum represented value of the bar
170         * @param maxRepresented In the maximum represented value of the bar
171         */
172         void setHorizontalRepresentedValues( int minRepresented, int maxRepresented );
173
174         /**
175         * Gets the StartVertical value
176         * @return The StartVertical
177         */
178         int getStartVertical();
179         /**
180         * Gets the EndVertical value
181         * @return The EndVertical
182         */
183         int getEndVertical();
184         /**
185         * Gets the ActualVertical value
186         * @return The ActualVertical
187         */
188         int getActualVertical();
189
190         /**
191         * Sets the StartVertical value
192         * @param nwValue The new value for the StartVertical
193         */
194         void setStartVertical( int nwValue);
195         /**
196         * Sets the EndVertical value
197         * @param nwValue The new value for the EndVertical
198         */
199         void setEndVertical( int nwValue);
200         /**
201         * Sets the ActualVertical value
202         * @param nwValue The new value for the ActualVertical
203         */
204         void setActualVertical( int nwValue);
205
206         /**
207         * Gets the StartHorizontal value
208         * @return The StartHorizontal
209         */
210         int getStartHorizontal();
211         /**
212         * Gets the EndHorizontal value
213         * @return The EndHorizontal
214         */
215         int getEndHorizontal();
216         /**
217         * Gets the ActualHorizontal value
218         * @return The ActualHorizontal
219         */
220         int getActualHorizontal();
221
222         /**
223         * Sets the StartHorizontal value
224         * @param nwValue The new value for the StartHorizontal
225         */
226         void setStartHorizontal( int nwValue);
227         /**
228         * Sets the EndHorizontal value
229         * @param nwValue The new value for the EndHorizontal
230         */
231         void setEndHorizontal( int nwValue);
232         /**
233         * Sets the ActualHorizontal value
234         * @param nwValue The new value for the ActualHorizontal
235         */
236         void setActualHorizontal( int nwValue);
237
238         /**
239         * Sets the horizontal concept values and name
240         * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
241         * @param minRepresent The minRepresent value of the concept for setting at the horizontal bar
242         * @param maxRepresent The maxRepresent value of the concept for setting at the horizontal bar
243         * @param minShowed The minShowed value of the concept for setting at the horizontal bar
244         * @param maxShowed The maxShowed value of the concept for setting at the horizontal bar
245         * @param actualShow The actualShow value of the concept for setting at the horizontal bar
246         */
247         void setHorizontalConcept( std::string theHorizontalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow ); 
248
249         /**
250         * Sets the vertical concept values and name
251         * @param theVerticalConcept The name of the concept for setting at the vertical bar
252         * @param minRepresent The minRepresent value of the concept for setting at the vertical bar
253         * @param maxRepresent The maxRepresent value of the concept for setting at the vertical bar
254         * @param minShowed The minShowed value of the concept for setting at the vertical bar
255         * @param maxShowed The maxShowed value of the concept for setting at the vertical bar
256         * @param actualShow The actualShow value of the concept for setting at the vertical bar
257         */
258         void setVerticalConcept( std::string theVerticalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow );
259         
260         /**
261         * Sets the horizontal concept name
262         * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
263         */
264         void setHorizontalConceptName( std::string theHorizontalConcept );
265
266         /**
267         * Gets the horizontal concept name
268         * @return _horizontalConcept The name of the concept for setting at the horizontal bar
269         */
270         std::string  getHorizontalConceptName(  );
271
272         /**
273         * Sets the vertical concept name
274         * @param theVerticalConcept The name of the concept for setting at the vertical bar
275         */
276         void setVerticalConceptName( std::string theVerticalConcept );
277
278         /**
279         * Gets the vertical concept name
280         * @return _verticalConcept The name of the concept for setting at the vertical bar
281         */
282         std::string     getVerticalConceptName(  );
283         //------------------------------------------------------------------------------------------------------------
284         //  Other functional methods
285         //------------------------------------------------------------------------------------------------------------
286         void                    getSpacing( double * spacing );
287         wxVtkBaseView*  getWxVtkBaseView();
288         double                  getCurrentDeep();
289         void                    SetVisibleAxis(bool ok);
290         int                             GetX();
291         int                             GetY();
292         int                             GetZ();
293         void                    SetXY(int x, int y);
294         void                    Refresh();
295
296
297 //this method should be deleted
298         wxVtkBaseView_SceneManager* getSceneManager();
299 ////////////7
300         void initializeScenceManager();
301         bool isEditableCControler(std::string theKeyName);
302         void removeFromScene(std::string theKeyName);
303
304 /////////////////////////////////////////////////////
305         void onChangeInstant(wxCommandEvent& event);
306     void onCreateMultipleROI (wxCommandEvent& event);
307         void onCreateROI (wxCommandEvent& event);
308         void onStopCreateROI (wxCommandEvent& event);
309         void onChangedDeep (wxCommandEvent& event);
310         void onActionButtonPressed(wxCommandEvent& event);
311         void removeSceneContours();
312         void addNameWrapperToScene();
313         std::vector<std::string> getSelectedObjects();
314         void RefreshInterface();
315         vtkImageData* getImageData();
316         void configureViewControlTo(std::string theName,manualBaseModel* manModelContour,double* spc,int typeofcontour);
317         int  GetImageDataSizeZ();
318         void GetImageDataRange(double *range);
319         void SetWidthContour(double width );
320         int  getColorWindow();
321         int  getWindowLevel();
322         void onBrigthnessColorWindowLevel(int colorwindow,int windowlevel);
323         void onInterpolation(bool interpolate);
324         void onShowTextContour(bool show);
325         void onBeforeAfterContour(bool before, bool after);
326         void GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ );
327         void changeImage(vtkImageData* img);
328         void changeDeep();
329         void setImageSlice(int z);
330
331 private:        
332         //------------------------------------------------------------------------------------------------------------
333         // Attributtes
334         //------------------------------------------------------------------------------------------------------------
335         wxVtkBaseView_SceneManager              *_sceneManager;
336         /*
337         * Represents the outer sizer of the ContourViewPanel
338         */
339         wxFlexGridSizer                                 *outSizer;
340
341         /*
342         * Represents the panel for viewing
343         */
344         wxMaracas_N_ViewersWidget               *theViewPanel;
345         /*
346         * Represents the vertical barrange
347         */
348         mBarRange                                               *_verticalBar;
349
350         /*
351         * Represents the horizontal barrange
352         */
353         mBarRange                                               *_horizontalBar;
354         vtkImageData                                    *showingVID;    
355         std::string                                     _verticalConceptName;
356         std::string                                     _horizontalConceptName;
357         double                                                  last_spacing[3];
358         bool                                                    _useVerticalBar;
359         bool                                                    _useHorizontalBar;
360         wxEvtHandler                                    *_eventHandler;
361         bool                                                    _showBeforeContour;
362         bool                                                    _showAfterContour;
363         
364 //EED
365         //------------------------------------------------------------------------------------------------------------
366         //  Private methods
367         //------------------------------------------------------------------------------------------------------------
368         wxVtkMPR2DView *GetwxVtkMPR2DView();
369 //      DECLARE_CLASS(wxContourViewPanel)
370         // any class wishing to process wxWindows events must use this macro
371         //DECLARE_EVENT_TABLE()
372 };
373 #endif // __wxContour_ViewPanel__
374