]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx
a501b9193ff780b3f0c0c90acd6ffdaf54a11be2
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContourViewPanel.cxx
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
27 //----------------------------------------------------------------------------------------------------------------
28 // Class definition include
29 //----------------------------------------------------------------------------------------------------------------
30 #include "wxContourViewPanel.h"
31
32 #include "wxContourMainFrame.h"
33 //----------------------------------------------------------------------------------------------------------------
34 // Other includes
35 //----------------------------------------------------------------------------------------------------------------
36 //#include "ConceptDataWrap.h"
37
38 //this should be eliminated at some point
39 //#include "wxContourEventHandler.h"
40 //----------------------------------------------------------------------------------------------------------------
41 // Class implementation
42 //----------------------------------------------------------------------------------------------------------------
43 /** @file wxContourViewPanel.cxx */
44
45 //----------------------------------------------------------------------------------------------------------------
46 // Throwed Events definition
47 //----------------------------------------------------------------------------------------------------------------
48
49 DEFINE_EVENT_TYPE( wxINSTANT_CHANGE )
50
51
52         //------------------------------------------------------------------------------------------------------------
53         // Constructors & Destructors
54         //------------------------------------------------------------------------------------------------------------
55         /*{
56
57                 showingVID = theShowingImage;
58                 int gapH = 20;
59                 int gapV = 10;
60                 createHorizontalBar(1,80);
61                 createVerticalBar(1,200);
62                 createViewPanel();
63
64                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(3,1,0,0);
65                 panelSizer->AddSpacer(gapV);
66                 panelSizer -> AddGrowableCol(1);
67                 panelSizer->Add(theViewPanel, 1, wxEXPAND);
68                 panelSizer->AddSpacer(gapV);
69
70                 wxFlexGridSizer * downSizer = new wxFlexGridSizer(1,3,gapV,gapH);
71                 downSizer->Add(_verticalBar, 1, wxEXPAND);
72                 //downSizer->AddSpacer(gapH);
73                 downSizer -> AddGrowableCol(1);
74                 downSizer->Add(panelSizer, 1, wxEXPAND|wxALL|wxCENTER);
75                 //downSizer->AddSpacer(gapH);
76                 outSizer = new wxFlexGridSizer(3,1,1,1);
77                 outSizer->Add(_horizontalBar, 1, wxEXPAND);
78                 outSizer -> AddGrowableRow(1);
79                 outSizer -> AddGrowableCol(1);
80                 outSizer->Add(downSizer, 1, wxEXPAND);
81
82                 _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + gapH, gapV);
83                 _horizontalBar->setDeviceEndMargin( gapH+10 );
84
85                 //Connecting the events to the horizontal bar
86                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal );
87                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onActualChange_Bar_Horizontal );
88                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStartChange_Bar_Horizontal );
89                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onEndChange_Bar_Horizontal );
90                 Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onSelectionEnd_Horizontal );
91                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onMovedBar_Horizontal );
92
93                 //Connecting the events to the vertical bar
94                 Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical );
95                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onActualChange_Bar_Vertical );
96                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStartChange_Bar_Vertical );
97                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onEndChange_Bar_Vertical );
98                 Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onSelectionEnd_Vertical );
99                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onMovedBar_Vertical );
100
101
102                 this->SetAutoLayout( true );
103                 SetSizer( outSizer );
104                 this->Layout();
105
106                 SetSize(900,700);
107                 theViewPanel->SetSize(800,600);
108                 theViewPanel->GetWindow(1)->SetSize(800,600);
109
110                 outSizer->Fit( this );
111                 SetBackgroundColour(wxColour(255,0,0));
112
113         }*/
114         //:wxScrolledWindow(parent, -1, pos, size, style)
115         wxContourViewPanel::wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd )
116         :wxPanel(parent, -1, pos, size, style)
117         {
118 printf("EED wxContourViewPanel::wxContourViewPanel Start\n");
119                 theShowingImage->GetSpacing(last_spacing);
120                 showingVID                              = theShowingImage;
121                 int gapH                                = 20;
122                 int gapV                                = 10;
123                 _verticalConceptName    = "";
124                 _horizontalConceptName  = "";
125                 createHorizontalBar(1,80);
126                 createVerticalBar(1,200);
127                 createViewPanel();
128                 _eventHandler                   = NULL;
129
130 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
131 #if wxMAJOR_VERSION <= 2
132                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1,4,  gapV, gapH);
133                 panelSizer -> AddGrowableCol(2);
134                 panelSizer -> AddGrowableRow(2);
135 #else
136                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(4);
137                 panelSizer -> AddGrowableCol(2);
138 #endif
139 printf("EED wxContourViewPanel::wxContourViewPanel 01\n");
140 printf("EED wxContourViewPanel::wxContourViewPanel 1\n");
141                 panelSizer->Add(_verticalBar, 1, wxGROW);
142 printf("EED wxContourViewPanel::wxContourViewPanel 2\n");
143                 panelSizer->AddSpacer(gapV);
144 printf("EED wxContourViewPanel::wxContourViewPanel 3\n");
145                 panelSizer->Add(theViewPanel, 1, wxGROW);
146 printf("EED wxContourViewPanel::wxContourViewPanel 4\n");
147                 panelSizer->AddSpacer(gapV);
148
149 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
150 #if wxMAJOR_VERSION <= 2
151                 outSizer = new wxFlexGridSizer(3, 1, gapH, gapV);
152                 outSizer -> AddGrowableCol(1);
153                 outSizer -> AddGrowableRow(1);
154 #else
155                 outSizer = new wxFlexGridSizer(3);
156                 outSizer -> AddGrowableCol(1);
157 #endif
158 printf("EED wxContourViewPanel::wxContourViewPanel 5\n");
159 printf("EED wxContourViewPanel::wxContourViewPanel 7\n");
160                 outSizer->Add( _horizontalBar, 1, wxGROW);
161                 outSizer->Add( panelSizer, 1, wxGROW);
162                 outSizer->AddSpacer(gapH);
163
164                 _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + 2*gapH, gapV);
165                 _horizontalBar->setDeviceEndMargin( 2*gapH+10 );
166
167 printf("EED wxContourViewPanel::wxContourViewPanel 8\n");
168                 //Connecting the events to the horizontal bar
169                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal );
170                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onActualChange_Bar_Horizontal );
171                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStartChange_Bar_Horizontal );
172                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onEndChange_Bar_Horizontal );
173                 Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onSelectionEnd_Horizontal );
174                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onMovedBar_Horizontal );
175 printf("EED wxContourViewPanel::wxContourViewPanel 9\n");
176
177                 //Connecting the events to the vertical bar
178                 Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical );
179                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onActualChange_Bar_Vertical );
180                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStartChange_Bar_Vertical );
181                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onEndChange_Bar_Vertical );
182                 Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onSelectionEnd_Vertical );
183                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onMovedBar_Vertical );
184 printf("EED wxContourViewPanel::wxContourViewPanel 9.1\n");
185                 this->SetSizer( outSizer );
186 printf("EED wxContourViewPanel::wxContourViewPanel 9.2\n");
187                 this->SetAutoLayout( true );
188 printf("EED wxContourViewPanel::wxContourViewPanel 9.3\n");
189                 this->Layout();
190                 //SetSize(1900,1900);
191                 //theViewPanel->SetSize(800,600);
192                 //theViewPanel->GetWindow(1)->SetSize(800,600);
193                 //outSizer->Fit( this );
194 printf("EED wxContourViewPanel::wxContourViewPanel 10\n");
195                 initializeScenceManager();
196 printf("EED wxContourViewPanel::wxContourViewPanel End\n");
197         }
198
199
200         wxContourViewPanel :: ~wxContourViewPanel()
201         {
202                 delete _sceneManager;
203         }
204
205         void wxContourViewPanel::initializeScenceManager()
206         {
207                 //_theViewPanel = theViewPanel;
208                 //_theViewPanel->setWxEventHandler( this );
209                 double spc[3];
210                 this->getSpacing(spc);
211                 _sceneManager           = new wxVtkBaseView_SceneManager ( this->getWxVtkBaseView(), this, spc  );
212                 Connect( this->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onChangeInstant );
213         Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onCreateMultipleROI );
214                 Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onCreateROI );
215                 Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStopCreateROI );
216                 Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onChangedDeep );
217                 Connect( wxID_ANY,  wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourViewPanel :: onActionButtonPressed );
218         }
219
220         wxVtkBaseView_SceneManager* wxContourViewPanel::getSceneManager(){
221                 return _sceneManager;
222         }
223
224         //------------------------------------------------------------------------------------------------------------
225         // Creational and initialization methods
226         //------------------------------------------------------------------------------------------------------------
227
228         void wxContourViewPanel :: setWxEventHandler( wxEvtHandler * theEventHandler )
229         {
230                 _eventHandler = theEventHandler;
231         }
232
233         void wxContourViewPanel :: createHorizontalBar(int horzStart, int horzEnd)
234         {
235                 _horizontalBar = new mBarRange(this, 1500,80);
236                 _horizontalBar -> setVisibleLabels (true);
237                 _horizontalBar -> setRepresentedValues (horzStart, horzEnd);
238                 _horizontalBar -> setActiveStateTo(true);
239                 _horizontalBar -> SetActual( horzStart );
240                 _horizontalBar -> setDeviceBlitStart (10,10);
241                 _horizontalBar -> setDeviceEndMargin (10);
242         }
243
244         void wxContourViewPanel :: createVerticalBar(int vertStart, int vertEnd)
245         {
246                 _verticalBar = new mBarRange(this, 1500,40);
247                 _verticalBar -> SetOrientation(false);
248                 _verticalBar -> setVisibleLabels (false);
249                 _verticalBar -> setRepresentedValues (vertStart, vertEnd);
250                 _verticalBar -> setActiveStateTo(true);
251                 _verticalBar -> SetActual( vertStart );
252                 _verticalBar -> setDeviceBlitStart (10,10);
253                 _verticalBar -> setDeviceEndMargin (10);
254         }
255         //------------------------------------------------------------------------------------------------------------
256
257         void wxContourViewPanel::createViewPanel()
258         {
259                 std::vector<int> * numViews = new std::vector<int> ();
260                 numViews->push_back(0);
261                 theViewPanel = new wxMaracas_N_ViewersWidget( this, showingVID, numViews );
262                 SetVisibleAxis(false);
263
264                 theViewPanel->SetBackgroundColour(wxColour(0,0,0));
265
266                 theViewPanel->SetSize(800,600);
267                 theViewPanel->GetWindow(1)->SetSize(800,600);
268
269         }
270         //------------------------------------------------------------------------------------------------------------
271
272         void wxContourViewPanel::changeImage(vtkImageData* img){
273
274                 theViewPanel->SetImage(img);
275
276         }
277         wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView()
278         {
279                 return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1));
280         }
281
282         //------------------------------------------------------------------------------------------------------------
283         void wxContourViewPanel::SetVisibleAxis(bool ok)
284         {
285                 GetwxVtkMPR2DView()->SetVisibleAxis(ok);
286         }
287
288         //------------------------------------------------------------------------------------------------------------
289         int wxContourViewPanel::GetX()
290         {
291                 return  GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetX();
292         }
293         //------------------------------------------------------------------------------------------------------------
294         int wxContourViewPanel::GetY()
295         {
296                 return  GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetY();
297         }
298         //------------------------------------------------------------------------------------------------------------
299         int wxContourViewPanel::GetZ()
300         {
301                 return  GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetZ();
302         }
303
304         //------------------------------------------------------------------------------------------------------------
305         void wxContourViewPanel::Refresh()
306         {
307                 GetwxVtkMPR2DView()->GetRenWin()->Render();
308         }
309
310
311         //------------------------------------------------------------------------------------------------------------
312         // Methods for capturing events from the horizontal bar
313         //------------------------------------------------------------------------------------------------------------
314
315         /**
316         * Handles the event wxEVT_TSBAR from the horizontal bar
317         */
318         void wxContourViewPanel :: onBarrange_Horizontal(wxCommandEvent& event)
319         {
320
321         }
322         /**
323         * Handles the event wxEVT_TSBAR_ACTUAL from the horizontal bar
324         */
325         void wxContourViewPanel :: onActualChange_Bar_Horizontal(wxCommandEvent& event)
326         {
327
328                 int actual = getActualHorizontal();
329
330                 wxContourMainFrame::getInstance()->onChangeInstant(_horizontalConceptName, actual);
331
332                 //JCP 26 - 11 - 08
333                 //int nxActual_h = getActualHorizontal();
334
335
336                 //if (_eventHandler!=NULL)
337                 //{
338                         //-------------------------------------------------
339                         //  Sending the event of wxINSTANT_CHANGE
340                         //-------------------------------------------------
341                 //      wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
342
343                 //      ConceptDataWrap * cWrap = new ConceptDataWrap( _horizontalConceptName );
344                 //      cWrap->setActualValue( nxActual_h );
345
346                 //      newevent.SetClientData( (void *)cWrap );
347                 //      _eventHandler->ProcessEvent(newevent);
348
349                 //}
350                 //JCP 26 - 11 - 08
351         }
352         /**
353         * Handles the event wxEVT_TSBAR_START from the horizontal bar
354         */
355         void wxContourViewPanel :: onStartChange_Bar_Horizontal(wxCommandEvent& event)
356         {
357 //              int nxStart_h = getStartHorizontal();
358         }
359         /**
360         * Handles the event wxEVT_TSBAR_END from the horizontal bar
361         */
362         void wxContourViewPanel :: onEndChange_Bar_Horizontal(wxCommandEvent& event)
363         {
364 //              int nxEnd_h = getEndHorizontal();
365         }
366         /**
367         * Handles the event wxEVT_SELECTION_END from the horizontal bar
368         */
369         void wxContourViewPanel :: onSelectionEnd_Horizontal(wxCommandEvent& event)
370         {
371
372         }
373         /**
374         * Handles the event wxEVT_TSBAR_MOVED from the horizontal bar
375         */
376         void wxContourViewPanel :: onMovedBar_Horizontal(wxCommandEvent& event)
377         {
378 //              int nxStart_h = getStartHorizontal();
379 //              int nxEnd_h = getEndHorizontal();
380         }
381
382
383         //------------------------------------------------------------------------------------------------------------
384         // Methods for capturing events from the vertical bar
385         //------------------------------------------------------------------------------------------------------------
386
387         /**
388         * Handles the event wxEVT_TSBAR from the vertical bar
389         */
390         void wxContourViewPanel :: onBarrange_Vertical(wxCommandEvent& event)
391         {
392
393         }
394         /**
395         * Handles the event wxEVT_TSBAR_ACTUAL from the vertical bar
396         */
397         void wxContourViewPanel :: onActualChange_Bar_Vertical(wxCommandEvent& event)
398         {
399                 int actual = getActualVertical();
400                 wxContourMainFrame::getInstance()->onChangeInstant(_verticalConceptName, actual);
401                 //JCP 26 - 11 - 08
402                 /*
403                 int nxActual_v = getActualVertical();
404
405                 if (_eventHandler!=NULL)
406                 {
407                         //-------------------------------------------------
408                         //  Sending the event of wxINSTANT_CHANGE
409                         //-------------------------------------------------
410                         wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
411
412                         ConceptDataWrap * cWrap = new ConceptDataWrap( _verticalConceptName );
413                         cWrap->setActualValue( nxActual_v );
414
415                         newevent.SetClientData( (void *)cWrap );
416                         _eventHandler->ProcessEvent(newevent);
417                 }*/
418                 //JCP 26 - 11 - 08
419         }
420         /**
421         * Handles the event wxEVT_TSBAR_START from the vertical bar
422         */
423         void wxContourViewPanel :: onStartChange_Bar_Vertical(wxCommandEvent& event)
424         {
425 //              int nxStart_v = getStartVertical();
426         }
427         /**
428         * Handles the event wxEVT_TSBAR_END from the vertical bar
429         */
430         void wxContourViewPanel :: onEndChange_Bar_Vertical(wxCommandEvent& event)
431         {
432 //              int nxEnd_v = getEndVertical();
433         }
434         /**
435         * Handles the event wxEVT_SELECTION_END from the vertical bar
436         */
437         void wxContourViewPanel :: onSelectionEnd_Vertical(wxCommandEvent& event)
438         {
439
440         }
441         /**
442         * Handles the event wxEVT_TSBAR_MOVED from the vertical bar
443         */
444         void wxContourViewPanel :: onMovedBar_Vertical(wxCommandEvent& event)
445         {
446 //              int nxStart_v = getStartVertical();
447 //              int nxEnd_v = getEndVertical();
448         }
449
450
451         //------------------------------------------------------------------------------------------------------------
452         //  Methods for sending events
453         //------------------------------------------------------------------------------------------------------------
454
455         //------------------------------------------------------------------------------------------------------------
456         //  Attributes getters and setters
457         //------------------------------------------------------------------------------------------------------------
458
459         /**
460         * Sets the represented values of the vertical bar
461         * @param minRepresented In the minimum represented value of the bar
462         * @param maxRepresented In the maximum represented value of the bar
463         */
464         void wxContourViewPanel :: setVerticalRepresentedValues( int minRepresented, int maxRepresented )
465         {
466                 if( _verticalBar != NULL && _useVerticalBar )
467                 {
468                         _verticalBar -> setRepresentedValues( minRepresented, maxRepresented );
469                 }
470         }
471
472         /**
473         * Sets the represented values of the horizontal bar
474         * @param minRepresented In the minimum represented value of the bar
475         * @param maxRepresented In the maximum represented value of the bar
476         */
477         void wxContourViewPanel :: setHorizontalRepresentedValues( int minRepresented, int maxRepresented )
478         {
479                 if( _horizontalBar != NULL && _useHorizontalBar )
480                 {
481                         _horizontalBar -> setRepresentedValues( minRepresented, maxRepresented );
482                 }
483         }
484
485         /**
486         * Gets the StartVertical value
487         * @return The StartVertical
488         */
489         int wxContourViewPanel :: getStartVertical()
490         {
491                 return _verticalBar->GetActual();
492         }
493         /**
494         * Gets the EndVertical value
495         * @return The EndVertical
496         */
497         int wxContourViewPanel :: getEndVertical()
498         {
499                 return _verticalBar->GetEnd();
500         }
501         /**
502         * Gets the ActualVertical value
503         * @return The ActualVertical
504         */
505         int wxContourViewPanel :: getActualVertical()
506         {
507                 return _verticalBar->GetActual();//GetEnd();
508         }
509
510         /**
511         * Sets the StartVertical value
512         * @param nwValue The new value for the StartVertical
513         */
514         void wxContourViewPanel :: setStartVertical( int nwValue )
515         {
516                  _verticalBar->SetEnd( nwValue );
517         }
518         /**
519         * Sets the EndVertical value
520         * @param nwValue The new value for the EndVertical
521         */
522         void wxContourViewPanel :: setEndVertical( int nwValue )
523         {
524                  _verticalBar->SetEnd( nwValue );
525         }
526         /**
527         * Sets the ActualVertical value
528         * @param nwValue The new value for the ActualVertical
529         */
530         void wxContourViewPanel :: setActualVertical( int nwValue )
531         {
532                  _verticalBar->SetActual( nwValue );
533         }
534
535         /**
536         * Gets the StartHorizontal value
537         * @return The StartHorizontal
538         */
539         int wxContourViewPanel :: getStartHorizontal()
540         {
541                 return _horizontalBar->GetStart();
542         }
543         /**
544         * Gets the EndHorizontal value
545         * @return The EndHorizontal
546         */
547         int wxContourViewPanel :: getEndHorizontal()
548         {
549                 return _horizontalBar->GetEnd();
550         }
551         /**
552         * Gets the ActualHorizontal value
553         * @return The ActualHorizontal
554         */
555         int wxContourViewPanel :: getActualHorizontal()
556         {
557                 return _horizontalBar->GetActual();
558         }
559
560         /**
561         * Sets the StartHorizontal value
562         * @param nwValue The new value for the StartHorizontal
563         */
564         void wxContourViewPanel :: setStartHorizontal( int nwValue )
565         {
566                 _horizontalBar->SetStart( nwValue );
567         }
568         /**
569         * Sets the EndHorizontal value
570         * @param nwValue The new value for the EndHorizontal
571         */
572         void wxContourViewPanel :: setEndHorizontal( int nwValue )
573         {
574                 _horizontalBar->SetEnd( nwValue );
575         }
576         /**
577         * Sets the ActualHorizontal value
578         * @param nwValue The new value for the ActualHorizontal
579         */
580         void wxContourViewPanel :: setActualHorizontal( int nwValue )
581         {
582                 _horizontalBar->SetActual( nwValue );
583         }
584
585         /**
586         * Sets the horizontal concept values and name
587         * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
588         * @param minRepresent The minRepresent value of the concept for setting at the horizontal bar
589         * @param maxRepresent The maxRepresent value of the concept for setting at the horizontal bar
590         * @param minShowed The minShowed value of the concept for setting at the horizontal bar
591         * @param maxShowed The maxShowed value of the concept for setting at the horizontal bar
592         * @param actualShow The actualShow value of the concept for setting at the horizontal bar
593         */
594         void wxContourViewPanel :: setHorizontalConcept( std::string theHorizontalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow )
595         {
596                 setHorizontalConceptName( theHorizontalConcept );
597                 setHorizontalRepresentedValues( minRepresent, maxRepresent );
598                 setActualHorizontal( actualShow );
599                 setStartHorizontal( minShowed );
600                 setEndHorizontal( maxShowed );
601         }
602
603         /**
604         * Sets the vertical concept values and name
605         * @param theVerticalConcept The name of the concept for setting at the vertical bar
606         * @param minRepresent The minRepresent value of the concept for setting at the vertical bar
607         * @param maxRepresent The maxRepresent value of the concept for setting at the vertical bar
608         * @param minShowed The minShowed value of the concept for setting at the vertical bar
609         * @param maxShowed The maxShowed value of the concept for setting at the vertical bar
610         * @param actualShow The actualShow value of the concept for setting at the vertical bar
611         */
612         void wxContourViewPanel :: setVerticalConcept( std::string theVerticalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow )
613         {
614                 setVerticalConceptName( theVerticalConcept );
615                 setVerticalRepresentedValues( minRepresent, maxRepresent );
616                 setActualVertical( actualShow );
617                 setStartVertical( minShowed );
618                 setEndVertical( maxShowed );
619         }
620
621
622         /**
623         * Sets the horizontal concept name
624         * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
625         */
626         void wxContourViewPanel :: setHorizontalConceptName( std::string theHorizontalConcept )
627         {
628                 _horizontalConceptName = theHorizontalConcept;
629         }
630
631         /**
632         * Gets the horizontal concept name
633         * @return _horizontalConceptName The name of the concept for setting at the horizontal bar
634         */
635         std::string wxContourViewPanel :: getHorizontalConceptName(  )
636         {
637                 return _horizontalConceptName;
638         }
639
640         /**
641         * Sets the vertical concept name
642         * @param theVerticalConcept The name of the concept for setting at the vertical bar
643         */
644         void wxContourViewPanel :: setVerticalConceptName( std::string theVerticalConcept )
645         {
646                 _verticalConceptName = theVerticalConcept;
647         }
648
649         /**
650         * Gets the vertical concept name
651         * @return _verticalConceptName The name of the concept for setting at the vertical bar
652         */
653         std::string wxContourViewPanel :: getVerticalConceptName(  )
654         {
655                 return _verticalConceptName;
656         }
657
658         //------------------------------------------------------------------------------------------------------------
659         //  Other functional methods
660         //------------------------------------------------------------------------------------------------------------
661
662         void wxContourViewPanel :: getSpacing( double * spacing  )
663         {
664                 spacing[0] = last_spacing[0];
665                 spacing[1] = last_spacing[1];
666                 spacing[2] = last_spacing[2];
667         }
668
669         wxVtkBaseView* wxContourViewPanel :: getWxVtkBaseView()
670         {
671                 return theViewPanel->GetwxVtkBaseView(1);
672         }
673
674         double wxContourViewPanel :: getCurrentDeep()
675         {
676 //EED 08/04/2008
677 //              return theViewPanel->GetZ(1);
678                 return theViewPanel->GetZ();
679                 //return GetZ();
680         }
681
682
683         bool wxContourViewPanel::isEditableCControler(std::string theKeyName){
684                 return _sceneManager->isEditableCControler(theKeyName);
685         }
686
687         void wxContourViewPanel::removeFromScene(std::string theKeyName){
688
689                 _sceneManager->deleteCViewerCControler(theKeyName);
690
691
692         }
693
694         void wxContourViewPanel::onChangeInstant(wxCommandEvent& event){
695                 ConceptDataWrap * dataConcept = NULL;
696                 if ( GetId() == event.GetId() )
697                 {
698                         dataConcept = (ConceptDataWrap *)event.GetClientData();
699                         int value = dataConcept->getActualValue();
700                         //_instantPanel->setConceptValue( dataConcept->getName(), value );
701                         wxContourMainFrame::getInstance()->setConceptValue( dataConcept->getName(), value );
702                 }
703                 else
704                 {
705                         dataConcept = wxContourMainFrame::getInstance()->getLastConceptData();
706                         if( dataConcept->getName().compare( getVerticalConceptName() ) == 0)
707                         {
708                                 setActualVertical( dataConcept->getActualValue());
709                                 //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
710                         }
711                         else if( dataConcept->getName().compare( getHorizontalConceptName() ) == 0|| wxContourMainFrame::getInstance()->getIfConceptCheckedAt( dataConcept->getName(), 0 ) )
712                         {
713                                 setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
714                         }
715                 }
716                 wxContourMainFrame::getInstance()->changeInstant();
717         }
718
719         void wxContourViewPanel::onCreateMultipleROI (wxCommandEvent& event){
720         }
721         void wxContourViewPanel::onCreateROI (wxCommandEvent& event){
722         }
723         void wxContourViewPanel::onStopCreateROI (wxCommandEvent& event){
724         }
725         void wxContourViewPanel::onChangedDeep (wxCommandEvent& event){
726                 double val = getCurrentDeep();
727                 //setActualVertical( (int)val );
728                 wxContourMainFrame::getInstance()->onChangeDeep((int)val);
729                 //_instantPanel->setConceptValue( "Axe Depth", (int)val );
730
731 //              changeInstant();
732         }
733         void wxContourViewPanel::changeDeep(){
734                 double val = getCurrentDeep();
735                 setActualVertical( (int)val );
736         }
737         void wxContourViewPanel::onActionButtonPressed(wxCommandEvent& event){
738
739
740                 std::vector<std::string> currentSelection = _sceneManager->getSelectedObjects();
741 //              int elementsSelected = currentSelection.size();
742                 bool ctrlKey = _sceneManager->isCtrlPressed();
743                 char toolCommand = _sceneManager->getLastKeyCode();
744
745
746                 if ( toolCommand == 3 && ctrlKey ) //'C' || 'c'
747                 {
748                         wxContourMainFrame::getInstance()->onCopy();
749                 }
750                 else if(  toolCommand == 22 && ctrlKey ) //'V' || 'v'
751                 {
752                         wxContourMainFrame::getInstance()->onPaste();
753                 }
754                 else if(  toolCommand == 8 || (toolCommand==127) ) // backspace Delete
755                 {
756                         wxContourMainFrame::getInstance()->onDeleteContour();
757                 }
758                 else if(  toolCommand == 14 && ctrlKey ) //'N' || 'n'
759                 {
760                         //toolCommand = &(CREATE_CONTOUR_KEY);
761                 }
762                 else if(  toolCommand == 15 && ctrlKey ) //'O' || 'o'
763                 {
764                         wxContourMainFrame::getInstance()->onLoad();
765                 }
766                 else if(  toolCommand == 19 && ctrlKey ) //'S' || 's'
767                 {
768                         wxContourMainFrame::getInstance()->saveFileWithContoursAutomatique();
769                 }else if( toolCommand == 26 ){
770                         wxContourMainFrame::getInstance()->onUndo();
771                 }else if( toolCommand == 25 ){
772                         wxContourMainFrame::getInstance()->onRedo();
773                 }
774         }
775
776         void wxContourViewPanel::removeSceneContours(){
777                 _sceneManager->removeSceneContours();
778         }
779
780         void wxContourViewPanel::addNameWrapperToScene(){
781                 int size = wxContourMainFrame::getInstance()->getNamesWrappingSize();
782                 for(int i = 0; i < size;i++){
783                         std::string name = wxContourMainFrame::getInstance()->getNameWrapping(i);
784                         _sceneManager->addToScene(name, true, true, true, false, false );
785                 }
786         }
787
788         std::vector<std::string> wxContourViewPanel::getSelectedObjects(){
789                 return _sceneManager->getSelectedObjects();
790         }
791
792         void wxContourViewPanel::RefreshInterface(){
793                 getWxVtkBaseView()->Refresh();
794         }
795
796         vtkImageData* wxContourViewPanel::getImageData(){
797                 return _sceneManager->GetImageData();
798         }
799
800         void wxContourViewPanel::configureViewControlTo(std::string theName,manualBaseModel* manModelContour,double* spc,int typeofcontour)
801         {
802                 _sceneManager->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
803         }
804
805         int wxContourViewPanel::GetImageDataSizeZ()
806         {
807                 return _sceneManager->GetImageDataSizeZ();
808         }
809
810         void wxContourViewPanel::GetImageDataRange(double *range)
811         {
812                 _sceneManager->GetImageDataRange(range);
813         }
814
815         void wxContourViewPanel::SetWidthContour(double width )
816         {
817                 _sceneManager->SetWidthContour( width );
818         }
819
820         int wxContourViewPanel::getColorWindow()
821         {
822                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
823                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
824                 int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
825                 return colorwindow;
826         }
827
828         int wxContourViewPanel::getWindowLevel()
829         {
830                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
831                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
832                 int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
833                 return windowlevel;
834         }
835
836         void wxContourViewPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
837         {
838                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
839                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
840                 imageviewer->SetColorWindow(colorwindow);
841                 imageviewer->SetColorLevel(windowlevel);
842         }
843
844         void wxContourViewPanel::onInterpolation(bool interpolate)
845         {
846                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
847                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
848
849                 if (interpolate){
850                         imageviewer->GetImageActor()->InterpolateOn();
851                 } else {
852                         imageviewer->GetImageActor()->InterpolateOff();
853                 }
854         }
855
856         void wxContourViewPanel::GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ )
857         {
858                 _sceneManager->GetPointsOfActualContour(vecX, vecY, vecZ);
859         }
860
861         void wxContourViewPanel::setImageSlice(int z){
862                 vtkInteractorStyleBaseView* stylebaseview = (vtkInteractorStyleBaseView*) _sceneManager->getWxVtkViewBase()->GetInteractorStyleBaseView();
863                 wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)stylebaseview->GetWxVtk2DBaseView();
864                 baseview->SetActualSlice(z);
865                 RefreshInterface();
866         }
867