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