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