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