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