]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContourViewPanel.cxx
no message
[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                 showingVID = theShowingImage;
95                 int gapH = 20;
96                 int gapV = 10;
97                 _verticalConceptName = "";
98                 _horizontalConceptName = "";
99                 createHorizontalBar(1,80);
100                 createVerticalBar(1,200);
101                 createViewPanel();
102                 _eventHandler = NULL;
103
104                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1, 4, gapV, gapH);
105                 panelSizer -> AddGrowableCol(2);
106                 panelSizer -> AddGrowableRow(2);
107                 panelSizer->Add(_verticalBar, 1, wxGROW);
108                 panelSizer->AddSpacer(gapV);
109                 panelSizer->Add(theViewPanel, 1, wxGROW);
110                 panelSizer->AddSpacer(gapV);
111
112                 outSizer = new wxFlexGridSizer(3, 1, gapH, gapV);
113                 outSizer -> AddGrowableCol(1);
114                 outSizer -> AddGrowableRow(1);
115                 outSizer->Add( _horizontalBar, 1, wxGROW);
116                 outSizer->Add( panelSizer, 1, wxGROW);
117                 outSizer->AddSpacer(gapH);
118
119                 _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + 2*gapH, gapV);
120                 _horizontalBar->setDeviceEndMargin( 2*gapH+10 );
121
122                 //Connecting the events to the horizontal bar
123                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal );
124                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onActualChange_Bar_Horizontal );
125                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStartChange_Bar_Horizontal );
126                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onEndChange_Bar_Horizontal );
127                 Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onSelectionEnd_Horizontal );
128                 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onMovedBar_Horizontal );
129
130                 //Connecting the events to the vertical bar
131                 Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical );
132                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onActualChange_Bar_Vertical );
133                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStartChange_Bar_Vertical );
134                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onEndChange_Bar_Vertical );
135                 Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onSelectionEnd_Vertical );
136                 Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onMovedBar_Vertical );
137
138
139                 this->SetSizer( outSizer );
140                 this->SetAutoLayout( true );
141                 this->Layout();
142
143                 //SetSize(1900,1900);
144                 //theViewPanel->SetSize(800,600);
145                 //theViewPanel->GetWindow(1)->SetSize(800,600);
146
147                 //outSizer->Fit( this );
148
149                 initializeScenceManager();
150         }
151
152
153         wxContourViewPanel :: ~wxContourViewPanel()
154         {
155                 delete _sceneManager;
156         }
157
158         void wxContourViewPanel::initializeScenceManager(){
159
160                 //_theViewPanel = theViewPanel;
161                 //_theViewPanel->setWxEventHandler( this );
162
163                 double spc[3];
164                 this->getSpacing(spc);
165                 _sceneManager           = new wxVtkBaseView_SceneManager ( this->getWxVtkBaseView(), this, spc  );
166
167                 Connect( this->GetId(), wxINSTANT_CHANGE, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onChangeInstant );
168         Connect( wxID_ANY, wxEVT_START_CREATE_MULT_ROI, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onCreateMultipleROI );
169                 Connect( wxID_ANY, wxEVT_START_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onCreateROI );
170                 Connect( wxID_ANY, wxEVT_STOP_CREATE_ROI, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onStopCreateROI );
171                 Connect( wxID_ANY, wxEVT_CHANGED_DEEP, (wxObjectEventFunction) (wxCommandEventFunction)  &wxContourViewPanel::onChangedDeep );
172                 Connect( wxID_ANY,  wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContourViewPanel :: onActionButtonPressed );
173
174         }
175
176         wxVtkBaseView_SceneManager* wxContourViewPanel::getSceneManager(){
177                 return _sceneManager;
178         }
179
180         //------------------------------------------------------------------------------------------------------------
181         // Creational and initialization methods
182         //------------------------------------------------------------------------------------------------------------
183
184         void wxContourViewPanel :: setWxEventHandler( wxEvtHandler * theEventHandler )
185         {
186                 _eventHandler = theEventHandler;
187         }
188
189         void wxContourViewPanel :: createHorizontalBar(int horzStart, int horzEnd)
190         {
191                 _horizontalBar = new mBarRange(this, 1500,80);
192                 _horizontalBar -> setVisibleLabels (true);
193                 _horizontalBar -> setRepresentedValues (horzStart, horzEnd);
194                 _horizontalBar -> setActiveStateTo(true);
195                 _horizontalBar -> SetActual( horzStart );
196                 _horizontalBar -> setDeviceBlitStart (10,10);
197                 _horizontalBar -> setDeviceEndMargin (10);
198         }
199
200         void wxContourViewPanel :: createVerticalBar(int vertStart, int vertEnd)
201         {
202                 _verticalBar = new mBarRange(this, 1500,40);
203                 _verticalBar -> SetOrientation(false);
204                 _verticalBar -> setVisibleLabels (false);
205                 _verticalBar -> setRepresentedValues (vertStart, vertEnd);
206                 _verticalBar -> setActiveStateTo(true);
207                 _verticalBar -> SetActual( vertStart );
208                 _verticalBar -> setDeviceBlitStart (10,10);
209                 _verticalBar -> setDeviceEndMargin (10);
210         }
211         //------------------------------------------------------------------------------------------------------------
212
213         void wxContourViewPanel::createViewPanel()
214         {
215                 std::vector<int> * numViews = new std::vector<int> ();
216                 numViews->push_back(0);
217                 theViewPanel = new wxMaracas_N_ViewersWidget( this, showingVID, numViews );
218                 SetVisibleAxis(false);
219
220                 theViewPanel->SetBackgroundColour(wxColour(0,0,0));
221
222                 theViewPanel->SetSize(800,600);
223                 theViewPanel->GetWindow(1)->SetSize(800,600);
224
225         }
226         //------------------------------------------------------------------------------------------------------------
227
228         void wxContourViewPanel::changeImage(vtkImageData* img){
229
230                 theViewPanel->SetImage(img);
231
232         }
233         wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView()
234         {
235                 return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1));
236         }
237
238         //------------------------------------------------------------------------------------------------------------
239         void wxContourViewPanel::SetVisibleAxis(bool ok)
240         {
241                 GetwxVtkMPR2DView()->SetVisibleAxis(ok);
242         }
243
244         //------------------------------------------------------------------------------------------------------------
245         int wxContourViewPanel::GetX()
246         {
247                 return  GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetX();
248         }
249         //------------------------------------------------------------------------------------------------------------
250         int wxContourViewPanel::GetY()
251         {
252                 return  GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetY();
253         }
254         //------------------------------------------------------------------------------------------------------------
255         int wxContourViewPanel::GetZ()
256         {
257                 return  GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetZ();
258         }
259
260         //------------------------------------------------------------------------------------------------------------
261         void wxContourViewPanel::Refresh()
262         {
263                 GetwxVtkMPR2DView()->GetRenWin()->Render();
264         }
265
266
267         //------------------------------------------------------------------------------------------------------------
268         // Methods for capturing events from the horizontal bar
269         //------------------------------------------------------------------------------------------------------------
270
271         /**
272         * Handles the event wxEVT_TSBAR from the horizontal bar
273         */
274         void wxContourViewPanel :: onBarrange_Horizontal(wxCommandEvent& event)
275         {
276
277         }
278         /**
279         * Handles the event wxEVT_TSBAR_ACTUAL from the horizontal bar
280         */
281         void wxContourViewPanel :: onActualChange_Bar_Horizontal(wxCommandEvent& event)
282         {
283
284                 int actual = getActualHorizontal();
285
286                 wxContourMainFrame::getInstance()->onChangeInstant(_horizontalConceptName, actual);
287
288                 //JCP 26 - 11 - 08
289                 //int nxActual_h = getActualHorizontal();
290
291
292                 //if (_eventHandler!=NULL)
293                 //{
294                         //-------------------------------------------------
295                         //  Sending the event of wxINSTANT_CHANGE
296                         //-------------------------------------------------
297                 //      wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
298
299                 //      ConceptDataWrap * cWrap = new ConceptDataWrap( _horizontalConceptName );
300                 //      cWrap->setActualValue( nxActual_h );
301
302                 //      newevent.SetClientData( (void *)cWrap );
303                 //      _eventHandler->ProcessEvent(newevent);
304
305                 //}
306                 //JCP 26 - 11 - 08
307         }
308         /**
309         * Handles the event wxEVT_TSBAR_START from the horizontal bar
310         */
311         void wxContourViewPanel :: onStartChange_Bar_Horizontal(wxCommandEvent& event)
312         {
313 //              int nxStart_h = getStartHorizontal();
314         }
315         /**
316         * Handles the event wxEVT_TSBAR_END from the horizontal bar
317         */
318         void wxContourViewPanel :: onEndChange_Bar_Horizontal(wxCommandEvent& event)
319         {
320 //              int nxEnd_h = getEndHorizontal();
321         }
322         /**
323         * Handles the event wxEVT_SELECTION_END from the horizontal bar
324         */
325         void wxContourViewPanel :: onSelectionEnd_Horizontal(wxCommandEvent& event)
326         {
327
328         }
329         /**
330         * Handles the event wxEVT_TSBAR_MOVED from the horizontal bar
331         */
332         void wxContourViewPanel :: onMovedBar_Horizontal(wxCommandEvent& event)
333         {
334 //              int nxStart_h = getStartHorizontal();
335 //              int nxEnd_h = getEndHorizontal();
336         }
337
338
339         //------------------------------------------------------------------------------------------------------------
340         // Methods for capturing events from the vertical bar
341         //------------------------------------------------------------------------------------------------------------
342
343         /**
344         * Handles the event wxEVT_TSBAR from the vertical bar
345         */
346         void wxContourViewPanel :: onBarrange_Vertical(wxCommandEvent& event)
347         {
348
349         }
350         /**
351         * Handles the event wxEVT_TSBAR_ACTUAL from the vertical bar
352         */
353         void wxContourViewPanel :: onActualChange_Bar_Vertical(wxCommandEvent& event)
354         {
355                 int actual = getActualVertical();
356                 wxContourMainFrame::getInstance()->onChangeInstant(_verticalConceptName, actual);
357                 //JCP 26 - 11 - 08
358                 /*
359                 int nxActual_v = getActualVertical();
360
361                 if (_eventHandler!=NULL)
362                 {
363                         //-------------------------------------------------
364                         //  Sending the event of wxINSTANT_CHANGE
365                         //-------------------------------------------------
366                         wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
367
368                         ConceptDataWrap * cWrap = new ConceptDataWrap( _verticalConceptName );
369                         cWrap->setActualValue( nxActual_v );
370
371                         newevent.SetClientData( (void *)cWrap );
372                         _eventHandler->ProcessEvent(newevent);
373                 }*/
374                 //JCP 26 - 11 - 08
375         }
376         /**
377         * Handles the event wxEVT_TSBAR_START from the vertical bar
378         */
379         void wxContourViewPanel :: onStartChange_Bar_Vertical(wxCommandEvent& event)
380         {
381 //              int nxStart_v = getStartVertical();
382         }
383         /**
384         * Handles the event wxEVT_TSBAR_END from the vertical bar
385         */
386         void wxContourViewPanel :: onEndChange_Bar_Vertical(wxCommandEvent& event)
387         {
388 //              int nxEnd_v = getEndVertical();
389         }
390         /**
391         * Handles the event wxEVT_SELECTION_END from the vertical bar
392         */
393         void wxContourViewPanel :: onSelectionEnd_Vertical(wxCommandEvent& event)
394         {
395
396         }
397         /**
398         * Handles the event wxEVT_TSBAR_MOVED from the vertical bar
399         */
400         void wxContourViewPanel :: onMovedBar_Vertical(wxCommandEvent& event)
401         {
402 //              int nxStart_v = getStartVertical();
403 //              int nxEnd_v = getEndVertical();
404         }
405
406
407         //------------------------------------------------------------------------------------------------------------
408         //  Methods for sending events
409         //------------------------------------------------------------------------------------------------------------
410
411         //------------------------------------------------------------------------------------------------------------
412         //  Attributes getters and setters
413         //------------------------------------------------------------------------------------------------------------
414
415         /**
416         * Sets the represented values of the vertical bar
417         * @param minRepresented In the minimum represented value of the bar
418         * @param maxRepresented In the maximum represented value of the bar
419         */
420         void wxContourViewPanel :: setVerticalRepresentedValues( int minRepresented, int maxRepresented )
421         {
422                 if( _verticalBar != NULL && _useVerticalBar )
423                 {
424                         _verticalBar -> setRepresentedValues( minRepresented, maxRepresented );
425                 }
426         }
427
428         /**
429         * Sets the represented values of the horizontal bar
430         * @param minRepresented In the minimum represented value of the bar
431         * @param maxRepresented In the maximum represented value of the bar
432         */
433         void wxContourViewPanel :: setHorizontalRepresentedValues( int minRepresented, int maxRepresented )
434         {
435                 if( _horizontalBar != NULL && _useHorizontalBar )
436                 {
437                         _horizontalBar -> setRepresentedValues( minRepresented, maxRepresented );
438                 }
439         }
440
441         /**
442         * Gets the StartVertical value
443         * @return The StartVertical
444         */
445         int wxContourViewPanel :: getStartVertical()
446         {
447                 return _verticalBar->GetActual();
448         }
449         /**
450         * Gets the EndVertical value
451         * @return The EndVertical
452         */
453         int wxContourViewPanel :: getEndVertical()
454         {
455                 return _verticalBar->GetEnd();
456         }
457         /**
458         * Gets the ActualVertical value
459         * @return The ActualVertical
460         */
461         int wxContourViewPanel :: getActualVertical()
462         {
463                 return _verticalBar->GetActual();//GetEnd();
464         }
465
466         /**
467         * Sets the StartVertical value
468         * @param nwValue The new value for the StartVertical
469         */
470         void wxContourViewPanel :: setStartVertical( int nwValue )
471         {
472                  _verticalBar->SetEnd( nwValue );
473         }
474         /**
475         * Sets the EndVertical value
476         * @param nwValue The new value for the EndVertical
477         */
478         void wxContourViewPanel :: setEndVertical( int nwValue )
479         {
480                  _verticalBar->SetEnd( nwValue );
481         }
482         /**
483         * Sets the ActualVertical value
484         * @param nwValue The new value for the ActualVertical
485         */
486         void wxContourViewPanel :: setActualVertical( int nwValue )
487         {
488                  _verticalBar->SetActual( nwValue );
489         }
490
491         /**
492         * Gets the StartHorizontal value
493         * @return The StartHorizontal
494         */
495         int wxContourViewPanel :: getStartHorizontal()
496         {
497                 return _horizontalBar->GetStart();
498         }
499         /**
500         * Gets the EndHorizontal value
501         * @return The EndHorizontal
502         */
503         int wxContourViewPanel :: getEndHorizontal()
504         {
505                 return _horizontalBar->GetEnd();
506         }
507         /**
508         * Gets the ActualHorizontal value
509         * @return The ActualHorizontal
510         */
511         int wxContourViewPanel :: getActualHorizontal()
512         {
513                 return _horizontalBar->GetActual();
514         }
515
516         /**
517         * Sets the StartHorizontal value
518         * @param nwValue The new value for the StartHorizontal
519         */
520         void wxContourViewPanel :: setStartHorizontal( int nwValue )
521         {
522                 _horizontalBar->SetStart( nwValue );
523         }
524         /**
525         * Sets the EndHorizontal value
526         * @param nwValue The new value for the EndHorizontal
527         */
528         void wxContourViewPanel :: setEndHorizontal( int nwValue )
529         {
530                 _horizontalBar->SetEnd( nwValue );
531         }
532         /**
533         * Sets the ActualHorizontal value
534         * @param nwValue The new value for the ActualHorizontal
535         */
536         void wxContourViewPanel :: setActualHorizontal( int nwValue )
537         {
538                 _horizontalBar->SetActual( nwValue );
539         }
540
541         /**
542         * Sets the horizontal concept values and name
543         * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
544         * @param minRepresent The minRepresent value of the concept for setting at the horizontal bar
545         * @param maxRepresent The maxRepresent value of the concept for setting at the horizontal bar
546         * @param minShowed The minShowed value of the concept for setting at the horizontal bar
547         * @param maxShowed The maxShowed value of the concept for setting at the horizontal bar
548         * @param actualShow The actualShow value of the concept for setting at the horizontal bar
549         */
550         void wxContourViewPanel :: setHorizontalConcept( std::string theHorizontalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow )
551         {
552                 setHorizontalConceptName( theHorizontalConcept );
553                 setHorizontalRepresentedValues( minRepresent, maxRepresent );
554                 setActualHorizontal( actualShow );
555                 setStartHorizontal( minShowed );
556                 setEndHorizontal( maxShowed );
557         }
558
559         /**
560         * Sets the vertical concept values and name
561         * @param theVerticalConcept The name of the concept for setting at the vertical bar
562         * @param minRepresent The minRepresent value of the concept for setting at the vertical bar
563         * @param maxRepresent The maxRepresent value of the concept for setting at the vertical bar
564         * @param minShowed The minShowed value of the concept for setting at the vertical bar
565         * @param maxShowed The maxShowed value of the concept for setting at the vertical bar
566         * @param actualShow The actualShow value of the concept for setting at the vertical bar
567         */
568         void wxContourViewPanel :: setVerticalConcept( std::string theVerticalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow )
569         {
570                 setVerticalConceptName( theVerticalConcept );
571                 setVerticalRepresentedValues( minRepresent, maxRepresent );
572                 setActualVertical( actualShow );
573                 setStartVertical( minShowed );
574                 setEndVertical( maxShowed );
575         }
576
577
578         /**
579         * Sets the horizontal concept name
580         * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
581         */
582         void wxContourViewPanel :: setHorizontalConceptName( std::string theHorizontalConcept )
583         {
584                 _horizontalConceptName = theHorizontalConcept;
585         }
586
587         /**
588         * Gets the horizontal concept name
589         * @return _horizontalConceptName The name of the concept for setting at the horizontal bar
590         */
591         std::string wxContourViewPanel :: getHorizontalConceptName(  )
592         {
593                 return _horizontalConceptName;
594         }
595
596         /**
597         * Sets the vertical concept name
598         * @param theVerticalConcept The name of the concept for setting at the vertical bar
599         */
600         void wxContourViewPanel :: setVerticalConceptName( std::string theVerticalConcept )
601         {
602                 _verticalConceptName = theVerticalConcept;
603         }
604
605         /**
606         * Gets the vertical concept name
607         * @return _verticalConceptName The name of the concept for setting at the vertical bar
608         */
609         std::string wxContourViewPanel :: getVerticalConceptName(  )
610         {
611                 return _verticalConceptName;
612         }
613
614         //------------------------------------------------------------------------------------------------------------
615         //  Other functional methods
616         //------------------------------------------------------------------------------------------------------------
617
618         void wxContourViewPanel :: getSpacing( double * spacing  )
619         {
620                 spacing[0] = last_spacing[0];
621                 spacing[1] = last_spacing[1];
622                 spacing[2] = last_spacing[2];
623         }
624
625         wxVtkBaseView* wxContourViewPanel :: getWxVtkBaseView()
626         {
627                 return theViewPanel->GetwxVtkBaseView(1);
628         }
629
630         double wxContourViewPanel :: getCurrentDeep()
631         {
632 //EED 08/04/2008
633 //              return theViewPanel->GetZ(1);
634                 return theViewPanel->GetZ();
635                 //return GetZ();
636         }
637
638
639         bool wxContourViewPanel::isEditableCControler(std::string theKeyName){
640                 return _sceneManager->isEditableCControler(theKeyName);
641         }
642
643         void wxContourViewPanel::removeFromScene(std::string theKeyName){
644
645                 _sceneManager->deleteCViewerCControler(theKeyName);
646
647
648         }
649
650         void wxContourViewPanel::onChangeInstant(wxCommandEvent& event){
651                 ConceptDataWrap * dataConcept = NULL;
652                 if ( GetId() == event.GetId() )
653                 {
654                         dataConcept = (ConceptDataWrap *)event.GetClientData();
655                         int value = dataConcept->getActualValue();
656                         //_instantPanel->setConceptValue( dataConcept->getName(), value );
657                         wxContourMainFrame::getInstance()->setConceptValue( dataConcept->getName(), value );
658                 }
659                 else
660                 {
661                         dataConcept = wxContourMainFrame::getInstance()->getLastConceptData();
662                         if( dataConcept->getName().compare( getVerticalConceptName() ) == 0)
663                         {
664                                 setActualVertical( dataConcept->getActualValue());
665                                 //_theViewPanel->setVerticalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
666                         }
667                         else if( dataConcept->getName().compare( getHorizontalConceptName() ) == 0|| wxContourMainFrame::getInstance()->getIfConceptCheckedAt( dataConcept->getName(), 0 ) )
668                         {
669                                 setHorizontalConcept( dataConcept->getName(), dataConcept->getMinShowedValue()/*dataConcept->getMinValue()*/, /*dataConcept->getMaxValue()*/ dataConcept->getMaxShowedValue(), dataConcept->getMinShowedValue(), dataConcept->getMaxShowedValue(), dataConcept->getActualValue());
670                         }
671                 }
672                 wxContourMainFrame::getInstance()->changeInstant();
673         }
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,manualBaseModel* manModelContour,double* spc,int typeofcontour)
757         {
758                 _sceneManager->configureViewControlTo(theName, manModelContour, spc, typeofcontour);
759         }
760
761         int wxContourViewPanel::GetImageDataSizeZ()
762         {
763                 return _sceneManager->GetImageDataSizeZ();
764         }
765
766         void wxContourViewPanel::GetImageDataRange(double *range)
767         {
768                 _sceneManager->GetImageDataRange(range);
769         }
770
771         void wxContourViewPanel::SetWidthContour(double width )
772         {
773                 _sceneManager->SetWidthContour( width );
774         }
775
776         int wxContourViewPanel::getColorWindow()
777         {
778                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
779                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
780                 int colorwindow = (int)imageviewer->GetWindowLevel()->GetLevel();
781                 return colorwindow;
782         }
783
784         int wxContourViewPanel::getWindowLevel()
785         {
786                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
787                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
788                 int windowlevel = (int)imageviewer->GetWindowLevel()->GetWindow();
789                 return windowlevel;
790         }
791
792         void wxContourViewPanel::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
793         {
794                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
795                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
796                 imageviewer->SetColorWindow(colorwindow);
797                 imageviewer->SetColorLevel(windowlevel);
798         }
799
800         void wxContourViewPanel::onInterpolation(bool interpolate)
801         {
802                 wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)getWxVtkBaseView();
803                 vtkImageViewer2 *imageviewer = wxvtk2dbaseview->_imageViewer2XYZ->GetVtkImageViewer2();
804
805                 if (interpolate){
806                         imageviewer->GetImageActor()->InterpolateOn();
807                 } else {
808                         imageviewer->GetImageActor()->InterpolateOff();
809                 }
810         }
811
812         void wxContourViewPanel::GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ )
813         {
814                 _sceneManager->GetPointsOfActualContour(vecX, vecY, vecZ);
815         }
816
817         void wxContourViewPanel::setImageSlice(int z){
818                 vtkInteractorStyleBaseView* stylebaseview = (vtkInteractorStyleBaseView*) _sceneManager->getWxVtkViewBase()->GetInteractorStyleBaseView();
819                 wxVtk2DBaseView* baseview = (wxVtk2DBaseView*)stylebaseview->GetWxVtk2DBaseView();
820                 baseview->SetActualSlice(z);
821                 RefreshInterface();
822         }
823