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