]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxVtkBaseView_SceneManager.cxx
no message
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxVtkBaseView_SceneManager.cxx
1
2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "wxVtkBaseView_SceneManager.h"
6 #include "wxVtk2DBaseView.h"
7
8 //----------------------------------------------------------------------------------------------------------------
9 // Class implementation
10 //----------------------------------------------------------------------------------------------------------------
11 /** @file wxVtkBaseView_SceneManager.cxx */
12
13
14 //------------------------------------------------------------------------------------------------------------
15 // Includes
16 //------------------------------------------------------------------------------------------------------------
17 #include "wxContour_ActionCommandsID.h"
18
19 //------------------------------------------------------------------------------------------------------------
20 // Generated events declaration and definition
21 //------------------------------------------------------------------------------------------------------------
22
23 DEFINE_EVENT_TYPE( wxEVT_START_CREATE_MULT_ROI )        
24 DEFINE_EVENT_TYPE( wxEVT_STOP_CREATE_MULT_ROI ) 
25 DEFINE_EVENT_TYPE( wxEVT_START_CREATE_ROI )
26 DEFINE_EVENT_TYPE( wxEVT_STOP_CREATE_ROI )
27 DEFINE_EVENT_TYPE( wxEVT_DELETE_ROI )
28 DEFINE_EVENT_TYPE( wxEVT_SELECTED_MULT_ROI )    
29 DEFINE_EVENT_TYPE( wxEVT_SELECTED_ROI ) 
30 DEFINE_EVENT_TYPE( wxEVT_UNSLECTED_ROI )        
31 DEFINE_EVENT_TYPE( wxEVT_MANUAL_HIDED_ROI )
32 DEFINE_EVENT_TYPE( wxEVT_MANUAL_SHOWED_ROI )
33 DEFINE_EVENT_TYPE( wxEVT_EDITING_ROI )  
34 DEFINE_EVENT_TYPE( wxEVT_MOVING_ROI )   
35 DEFINE_EVENT_TYPE( wxEVT_MOVING_ROI_POINT )     
36 DEFINE_EVENT_TYPE( wxEVT_SELECTED_ROI_POINT )   
37 DEFINE_EVENT_TYPE( wxEVT_UNSELECTED_ROI_POINT ) 
38 DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) 
39
40
41         wxVtkBaseView_SceneManager :: wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc )
42         {
43                 _widthOfContour                                 = 1.0;
44                 _lastInteraction                                = NULL;
45                 _lastInteractionName                    = "";
46                 _eventHandler                                   = theEventHandler;
47                 _leftClickCount                                 = 0;
48                 _rigthClickCount                                = 0;
49                 
50                 _contours_ViewControl                   = new std::map< std::string, ContourWrap_ViewControl * >();
51                 _sceneContours_ViewControl              = new std::map< std::string, ContourWrap_ViewControl * >();
52                 _workingGroup                                   = new std::map< std::string, ContourWrap_ViewControl * >();
53
54                 _creatingMULT_ROI                               = false;
55                 _editingROI                                             = false;
56                 _toIncludeAtInteractionGroup    = false;
57                 _waiting                                                = false;
58                 _creatingROI                                    = false;
59                 _drawingSelectionROI                    = false;
60
61                 
62                 _wxVtk_BaseView = theWxBaseViewToManage;
63                 if( _wxVtk_BaseView!=NULL )
64                 {
65                         vtkInteractorStyleBaseView* theInteractorStyleBaseView = (vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView();
66                         theInteractorStyleBaseView->AddInteractorStyleMaracas( this );
67                         SetVtkInteractorStyleBaseView( theInteractorStyleBaseView );                    
68                 }
69                 configureSelectionROI( spc );
70         }
71         //------------------------------------------------------------------------------------------------------------
72         wxVtkBaseView_SceneManager :: ~wxVtkBaseView_SceneManager()
73         {
74                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->begin(); 
75                 int size = _contours_ViewControl->size();
76                 for ( int i = 0; i<size; iter++ )
77                 {
78                         _contours_ViewControl->erase( iter );
79                         i++;
80                 }
81                 _contours_ViewControl->clear();         
82                 delete _contours_ViewControl;           
83                 _workingGroup->clear();
84                 delete _lastInteraction;
85                 delete _workingGroup;
86                 //delete _contours_ViewControl;
87         }
88
89         //------------------------------------------------------------------------------------------------------------
90         // Methods for capturing events
91         //------------------------------------------------------------------------------------------------------------
92
93                 
94         //------------------------------------------------------------------------------------------------------------
95         //  Methods for sending events
96         //------------------------------------------------------------------------------------------------------------
97         void wxVtkBaseView_SceneManager :: sendEnvent( WXTYPE theEventType, std::string text )
98         {
99                 if ( _eventHandler != NULL )
100                 {
101                         wxCommandEvent cevent( theEventType );
102                         cevent.SetString( wxString( text.c_str(), wxConvUTF8) );
103                         _eventHandler->ProcessEvent( cevent );
104                 }
105         }
106
107
108         //------------------------------------------------------------------------------------------------------------
109         //  Attributes getters and setters
110         //------------------------------------------------------------------------------------------------------------
111         void wxVtkBaseView_SceneManager :: setWxEventHandler( wxEvtHandler * theEventHandler )
112         {
113                 _eventHandler = theEventHandler;
114         }
115         //------------------------------------------------------------------------------------------------------------
116         void wxVtkBaseView_SceneManager :: setWxVtkViewBase( wxVtkBaseView * theBaseView )
117         {
118                 _wxVtk_BaseView = theBaseView;
119         }
120
121         //------------------------------------------------------------------------------------------------------------
122         wxVtkBaseView * wxVtkBaseView_SceneManager :: getWxVtkViewBase()
123         {
124                 return _wxVtk_BaseView;
125         }
126         //------------------------------------------------------------------------------------------------------------
127         void wxVtkBaseView_SceneManager :: configureViewControlTo( std::string theKeyName, manualContourModel * manModelContour, double * spc,int typeContour)
128         {
129                 //setControlActiveStateOfALL( false );
130                 _creatingROI = true;
131                 _waiting = false;       
132                 if( _lastInteraction!=NULL )
133                 {
134                         _lastInteraction->getControler()->SetEditable( false );
135                         _lastInteraction->getViewer()->Refresh();
136                         _lastInteraction->getControler()->SetActive( false );
137                         this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
138                 }
139
140
141                 manualContourBaseControler *manContourControl;
142                 manualViewBaseContour           *manViewerContour;
143
144                 // Creating the view manualViewContour and the manualContourControler
145                 if (typeContour==1)
146                 {
147                         manContourControl       = new manualContourControler();
148                         manViewerContour        = new manualViewContour();
149                 }
150
151                 if (typeContour==2)
152                 {
153                         manContourControl       = new manualRoiControler();
154                         manViewerContour        = new manualViewRoi();
155                 }
156
157                 if (typeContour==3)
158                 {
159                         manContourControl       = new manualCircleControler();
160                         manViewerContour        = new manualViewCircle();
161                 }
162
163                 if (typeContour==4)
164                 {
165                         manContourControl       = new manualRoiControler();
166                         manViewerContour        = new manualViewBullEye();
167                 }
168
169                 if (typeContour==6)
170                 {
171                         manContourControl       = new manualLineControler();
172                         manViewerContour        = new manualViewLine();
173                 }
174
175
176
177         _lastInteraction = insertWrap( theKeyName, manContourControl, manViewerContour );
178                 _lastInteractionName = theKeyName;
179
180                 //Configuring the relations between the contour members representation                  
181                 manViewerContour->SetModel( manModelContour );
182                 manViewerContour->SetWxVtkBaseView( _wxVtk_BaseView );
183                 manViewerContour->SetRange( 0.5 );
184                 manViewerContour->SetZ( 1000 );
185
186                 manViewerContour->SetSpacing(spc);
187
188                 manViewerContour->SetColorNormalContour(0, 0, 1);
189                 manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
190                 manViewerContour->SetColorSelectContour(1, 0.8, 0);
191                 manViewerContour->SetWidthLine(_widthOfContour);
192
193                 manContourControl->SetModelView( manModelContour , manViewerContour );
194                 manContourControl->Configure();
195                 int i,sizeLstPoints = manModelContour->GetSizeLstPoints();
196                 for ( i=0; i<sizeLstPoints; i++ )
197                 {
198                         manViewerContour->AddPoint();
199                 }
200
201                 manContourControl->CreateNewManualContour();
202                 manViewerContour->RefreshContour();                     
203                 addToScene( theKeyName );
204         }
205         //------------------------------------------------------------------------------------------------------------
206         void wxVtkBaseView_SceneManager :: configureSelectionROI( double * spc )
207         {
208                 _controlerSelectionROI = new manualRoiControler();
209                 _viewerSelectionROI = new manualViewRoi();
210                 _modelSelectionROI = new manualContourModel();
211                 
212                 _viewerSelectionROI->SetModel( _modelSelectionROI );
213                 _viewerSelectionROI->SetWxVtkBaseView( _wxVtk_BaseView );
214                 _viewerSelectionROI->SetRange( 2 );
215                 _viewerSelectionROI->SetZ( 1000 );
216                 _viewerSelectionROI->SetColorNormalContour(0.6, 0.8, 0);
217
218                 _viewerSelectionROI->SetSpacing( spc );
219
220                 _controlerSelectionROI->SetModelView( _modelSelectionROI , _viewerSelectionROI );
221                 ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _controlerSelectionROI );
222                 _controlerSelectionROI->SetActive(false);
223         }
224
225         //------------------------------------------------------------------------------------------------------------
226         ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour  * manViewerContour )
227         {       
228                 ContourWrap_ViewControl * newContourWrap = new ContourWrap_ViewControl(manContourControl, manViewerContour);
229                 _contours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, newContourWrap ));
230                 return newContourWrap;
231         } 
232         //------------------------------------------------------------------------------------------------------------
233         void wxVtkBaseView_SceneManager :: desconfigureViewControlOf( std::string theKeyName )
234         {
235                 
236         }
237         //------------------------------------------------------------------------------------------------------------
238         void wxVtkBaseView_SceneManager :: removeWrap( std::string theKeyName )
239         {
240                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
241                 iter = _contours_ViewControl->find( theKeyName );
242                 _contours_ViewControl->erase( iter );
243                 _lastInteraction=NULL;
244                 _lastInteractionName = "";
245                 _workingGroup->clear();
246                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
247                 this->_vtkInteractorStyleBaseView->EvaluateToRefresh();
248         } 
249         //------------------------------------------------------------------------------------------------------------
250         ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf ( std::string theName )
251         {
252                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
253                 iter = _contours_ViewControl->find( theName );
254                 return iter->second;
255                 //return iter->first;
256         }
257         //------------------------------------------------------------------------------------------------------------
258         ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap )
259         {
260                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
261                 iter = theMap->find( theName );
262                 return iter->second;
263         }
264         //------------------------------------------------------------------------------------------------------------
265         manualContourBaseControler * wxVtkBaseView_SceneManager :: getControlerOf( std::string theName )
266         {
267                 return getContourWrap_ViewControlOf ( theName )->getControler();
268         }
269         //------------------------------------------------------------------------------------------------------------
270         manualViewBaseContour * wxVtkBaseView_SceneManager :: getViewerOf( std::string theName )
271         {
272                 return getContourWrap_ViewControlOf ( theName )->getViewer();
273         }
274         //------------------------------------------------------------------------------------------------------------
275         void wxVtkBaseView_SceneManager :: set_creatingMULT_ROI( bool condition )
276         {
277                 _creatingMULT_ROI = condition;
278         }
279         //------------------------------------------------------------------------------------------------------------
280         void wxVtkBaseView_SceneManager :: set_editingROI( bool condition )
281         {
282                 _editingROI = condition;
283         }
284         //------------------------------------------------------------------------------------------------------------
285         void wxVtkBaseView_SceneManager :: set_toIncludeAtInteractionGroup( bool condition )
286         {
287                 _toIncludeAtInteractionGroup = condition;
288         }
289         //------------------------------------------------------------------------------------------------------------
290         void wxVtkBaseView_SceneManager :: set_waiting( bool condition )
291         {
292                 _waiting = condition;
293         }
294         //------------------------------------------------------------------------------------------------------------
295         bool wxVtkBaseView_SceneManager :: get_creatingMULT_ROI(  )
296         {
297                 return _creatingMULT_ROI;
298         }
299         //------------------------------------------------------------------------------------------------------------
300         bool wxVtkBaseView_SceneManager :: get_editingROI(  )
301         {
302                 return _editingROI;
303         }
304         //------------------------------------------------------------------------------------------------------------
305         bool wxVtkBaseView_SceneManager :: get_toIncludeAtInteractionGroup(  )
306         {
307                 return _toIncludeAtInteractionGroup;
308         }
309
310         //------------------------------------------------------------------------------------------------------------
311         bool wxVtkBaseView_SceneManager :: get_waiting(  )
312         {
313                 return _waiting;
314         }
315
316         //------------------------------------------------------------------------------------------------------------
317         bool wxVtkBaseView_SceneManager :: get_creatingROI()
318         {
319                 return _creatingROI;
320         }
321         //------------------------------------------------------------------------------------------------------------
322         void wxVtkBaseView_SceneManager :: set_creatingROI( bool condition )
323         {
324                 _creatingROI = condition;
325         }
326
327         //------------------------------------------------------------------------------------------------------------
328         //  Other functional methods
329         //------------------------------------------------------------------------------------------------------------
330
331         void wxVtkBaseView_SceneManager :: createCopyContourOf( std::string anExistingKName, std::string cloneName, manualContourModel * manualModel, bool append )
332         {
333                 if ( !append )
334                 {
335                         setControlActiveStateOf( _workingGroup, false );
336                         _workingGroup->clear();
337                 }
338         std::map <std::string, ContourWrap_ViewControl *>::iterator iter; 
339
340
341                 iter = _contours_ViewControl->find( anExistingKName );
342
343                 manualContourModel                      *cModule        = manualModel;
344                 manualViewBaseContour           *cViewer        = iter->second->getViewer()->Clone();
345                 manualContourBaseControler      *cControl       = iter->second->getControler()->Clone(  );
346
347                 cViewer->SetModel(cModule);
348                 cControl->SetModelView( cModule , cViewer );
349                 cControl->CreateNewManualContour();
350                 cControl->SetActive( true );    
351                 cControl->SetEditable( false );         
352
353         cViewer->RefreshContour();     
354                 cViewer->Refresh();
355                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
356                 this->_vtkInteractorStyleBaseView->EvaluateToRefresh();
357
358                 _lastInteraction = insertWrap( cloneName, cControl, cViewer );
359                 _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( cloneName, _lastInteraction ));              
360         addToScene( cloneName );
361         }
362
363         //------------------------------------------------------------------------------------------------------------
364
365         void wxVtkBaseView_SceneManager :: removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization, bool control )
366         {
367                 if( contourWRP == _lastInteraction )
368                 {
369                         _lastInteraction = NULL;
370                         _lastInteractionName = "";
371                 }
372
373
374                 ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->RemoveInteractorStyleMaracas( contourWRP->getControler() );
375
376                 contourWRP->getControler()->SetActive( control );       
377                 contourWRP->getControler()->SetEditable( false );               
378
379                 if ( !visualization && control )
380                 {
381                         contourWRP->getViewer()->RemoveControlPoints( );
382                         contourWRP->getViewer()->RemoveTextActor( );
383                 }
384                 if ( visualization )
385                 {
386                         contourWRP->getViewer()->RemoveCompleteContourActor();                  
387                 }
388                 
389         }
390         //------------------------------------------------------------------------------------------------------------
391         void wxVtkBaseView_SceneManager :: removeFromScene( std::string theKeyName, bool visualization , bool control )
392         {
393
394                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
395                 iter = _sceneContours_ViewControl->find( theKeyName );
396                 if (iter != _sceneContours_ViewControl->end())
397                 {
398                         ContourWrap_ViewControl * contourWRP =   iter->second;
399                         removeFromScene( contourWRP );  
400                         _sceneContours_ViewControl->erase(iter);
401                 }       
402         }
403
404
405         //------------------------------------------------------------------------------------------------------------
406         std::vector<std::string> wxVtkBaseView_SceneManager::GetlstContoursNameActualSlice()
407         {
408                 std::vector<std::string> lstContoursNameActualSlice;
409                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin(); 
410                 int i,size = _sceneContours_ViewControl->size();
411                 for ( i = 0; i<size; i++ )
412                 {
413                         lstContoursNameActualSlice.push_back( iter->first );
414                         iter++;
415                 }
416                 return lstContoursNameActualSlice;
417         }
418
419         //------------------------------------------------------------------------------------------------------------
420         void wxVtkBaseView_SceneManager :: removeSceneContours( )
421         {
422                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin(); 
423                 int size = _sceneContours_ViewControl->size();
424                 for ( int i = 0; i<size; i++ )
425                 {
426                         removeFromScene( iter->second );
427                         iter++;
428                 }
429                 _sceneContours_ViewControl->clear();
430
431
432                 //Removing the selection rectangle to avoid showing when it's innecesary
433                 _controlerSelectionROI->SetActive( false );             
434                 _viewerSelectionROI->RemoveCompleteContourActor();      
435         }
436
437         void wxVtkBaseView_SceneManager::removeAllOutlines()
438         {
439                 manualViewBaseContour           * cViewer;
440                 manualContourBaseControler      * cControler;
441
442                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter; 
443                 int i,size=_contours_ViewControl->size();
444                 for (i=0;i<size;i++)
445                 {
446                         iter = _contours_ViewControl->begin(); 
447                         cControler      = iter->second->getControler();
448                         cViewer         = iter->second->getViewer();
449                         removeWrap( iter->first );
450                         delete cViewer;
451                         delete cControler;
452                 }// for
453
454         }
455
456
457         //------------------------------------------------------------------------------------------------------------
458         void wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
459         {
460                 if( !append )
461                 {
462                         removeSceneContours();                  
463                 }
464                 ContourWrap_ViewControl * contourWRP =  getContourWrap_ViewControlOf( theKeyName );
465                 _sceneContours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, contourWRP ) );             
466
467                 addToScene( theKeyName, contourWRP, true, visualization, control, ifActive, ifShowCtrlPoints);
468         }
469
470         //------------------------------------------------------------------------------------------------------------
471         void wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
472         {
473                 if( !append )
474                 {
475                         removeSceneContours();                  
476                 }               
477                 _sceneContours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, contourWRP ) );             
478                 if ( visualization )
479                 {
480                         contourWRP->getViewer()->AddCompleteContourActor( ifShowCtrlPoints );
481                 }
482
483                 if( control )
484                 {
485                         ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( contourWRP->getControler() );
486                 }
487                 if( ifActive )
488                 {
489                         contourWRP->getControler()->SetActive( true );  
490                         contourWRP->getViewer()->RemoveTextActor();
491                 }
492         }
493
494         //------------------------------------------------------------------------------------------------------------
495         void wxVtkBaseView_SceneManager :: removeFromScene( std::vector< std::string> theKeyNameVector, bool visualization, bool control  )
496         {
497                 int i, size = theKeyNameVector.size();
498                 for( i=0; i< size; i++ )
499                 {
500                         removeFromScene( theKeyNameVector[i], visualization, control );
501                 }
502         }
503
504         //------------------------------------------------------------------------------------------------------------
505         void wxVtkBaseView_SceneManager :: addToScene( std::vector< std::string> theKeyNameVector, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
506         {
507                 int i, size = theKeyNameVector.size();
508                 for( i=0; i< size; i++ )
509                 {
510                         addToScene( theKeyNameVector[i], append, visualization, control, ifActive, ifShowCtrlPoints );
511                 }
512         }
513
514         //------------------------------------------------------------------------------------------------------------
515         void wxVtkBaseView_SceneManager :: setControlActiveStateOfALL( bool stateCondition )
516         {
517                 setControlActiveStateOf( _contours_ViewControl, stateCondition );                       
518         }
519
520         //------------------------------------------------------------------------------------------------------------
521         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( std::string theKeyName, bool stateCondition )
522         {
523                 ContourWrap_ViewControl * contourWRP =  getContourWrap_ViewControlOf( theKeyName );
524                 setControlActiveStateOf( contourWRP, stateCondition );
525         }
526
527         //------------------------------------------------------------------------------------------------------------
528         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( ContourWrap_ViewControl * contourWRP, bool stateCondition )
529         {
530                 contourWRP->getControler()->SetActive( stateCondition );        
531                 contourWRP->getControler()->SetEditable( false );               
532         }
533
534         //------------------------------------------------------------------------------------------------------------
535         void wxVtkBaseView_SceneManager :: setVisibleStateOf( std::string theKeyName, bool stateCondition )
536         {
537                 ContourWrap_ViewControl * contourWRP =  getContourWrap_ViewControlOf( theKeyName );
538 //              contourWRP->getViewer()->SetVisible( stateCondition );
539                 if ( contourWRP!=NULL )
540                         removeFromScene( contourWRP, false, stateCondition );
541         }
542
543         //------------------------------------------------------------------------------------------------------------
544         std::vector< std::string > wxVtkBaseView_SceneManager :: getSelectedObjects()
545         {
546                 std::vector< std::string > selectedObjects;
547                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _workingGroup->begin(); 
548                 int size = _workingGroup->size();
549                 for ( int i = 0; i<size; i++ )
550                 {
551 //EED???                        manualViewBaseContour * viewer = iter->second->getViewer();
552                         selectedObjects.push_back( iter->first);        
553
554                         iter++;
555                 }       
556                 return selectedObjects;
557         }
558         //------------------------------------------------------------------------------------------------------------
559         void wxVtkBaseView_SceneManager :: selectObjects( std::vector< std::string > theExistingObjectsToSelect )
560         {
561                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->begin(); 
562 //EED???                int size = _contours_ViewControl->size();       
563 //EED???                bool selected;
564                 /*for ( int i = 0; i<size; i++ )
565                 {
566                         selected = false;
567                         manualViewBaseContour * viewer = iter->second->getViewer();     
568                         std::vector <std::string >::iterator iterIN;
569                         int a = 0;
570                         for( a = 0, iterIN = theExistingObjectsToSelect.begin() ; !selected && a < theExistingObjectsToSelect.size() ; a++ )
571                         {
572                                 if( iter->first.compare( theExistingObjectsToSelect[i] ) )
573                                 {                                       
574                                         viewer->SelectAllPoints( true );
575                                         viewer->SelectPosibleContour( true );           
576                                         selected = true;
577                                         theExistingObjectsToSelect.erase( iterIN );                                     
578                                 }
579                                 if( !selected )
580                                         iterIN++;
581                         }
582                 }       */
583         }
584
585         //------------------------------------------------------------------------------------------------------------
586         void wxVtkBaseView_SceneManager :: selectObjects( std::map<std::string, ContourWrap_ViewControl *> * theMap )
587         {
588                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = theMap->begin(); 
589                 int size = _contours_ViewControl->size();       
590                 for ( int i = 0; i<size; i++ )
591                 {
592                         manualViewBaseContour * viewer = iter->second->getViewer();     
593
594                         viewer->SetSelected( true );
595                         /*viewer->SelectAllPoints( true );
596                         viewer->SelectPosibleContour( true );*/         
597                         
598                         iter++;
599                 }       
600         }
601
602         //------------------------------------------------------------------------------------------------------------
603         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( std::vector< std::string> &theKeyNameVector, bool controlCondition )
604         {
605                 int i, size = theKeyNameVector.size();
606                 for( i=0; i< size; i++ )
607                 {
608                         setControlActiveStateOf( theKeyNameVector[i], controlCondition );
609                 }
610         }
611
612         //------------------------------------------------------------------------------------------------------------
613         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( std::map<std::string, ContourWrap_ViewControl *> * theMap, bool controlCondition )
614         {
615                 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = theMap->begin();
616                 int i, size = theMap->size();
617                 for( i=0; i< size; i++ )
618                 {
619                         removeFromScene( iter->second, false, controlCondition );               
620                         iter++;
621                 }               
622         }
623
624         //------------------------------------------------------------------------------------------------------------
625         //  Private methods
626         //------------------------------------------------------------------------------------------------------------
627
628         //------------------------------------------------------------------------------------------------------------
629         // Creational and initialization methods
630         //------------------------------------------------------------------------------------------------------------
631
632         //------------------------------------------------------------------------------------------------------------
633         // Inherited Methods
634         //------------------------------------------------------------------------------------------------------------
635
636         bool  wxVtkBaseView_SceneManager :: isCtrlPressed()
637         { 
638                 return _ctrlKey;
639         }
640         bool  wxVtkBaseView_SceneManager :: isShiftPressed()
641         { 
642                 return _shiftKey;
643         }
644         char  wxVtkBaseView_SceneManager :: getLastKeyCode()
645         { 
646                 return _lastKeyCode;
647         }
648         bool  wxVtkBaseView_SceneManager :: OnChar()
649         { 
650
651                 _ctrlKey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey() == 1;
652                 _shiftKey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey() == 1;
653
654                 _lastKeyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
655
656                 wxCommandEvent cevent( wxEVT_COMMAND_BUTTON_CLICKED );
657                 _eventHandler->ProcessEvent( cevent );
658                 
659                                 
660                 /*if( _eventHandler!=NULL )
661                 {
662                         char * toolCommand = NULL;
663
664                         if ( _lastKeyCode == 3 && ctrlKey ) //'C' || 'c' 
665                         {
666                                 toolCommand = &(COPY_TOOL);
667                         }
668                         else if(  _lastKeyCode == 22 && ctrlKey ) //'V' || 'v' 
669                         {
670                                 toolCommand = &(PASTE_TOOL);
671                         }
672                         else if(  _lastKeyCode == 8 || (_lastKeyCode==127) ) // Delete 
673                         {
674                                 toolCommand = &(DELETE_KEY);
675                         }
676                         else if(  _lastKeyCode == 14 && ctrlKey ) //'N' || 'n' 
677                         {
678                                 toolCommand = &(CREATE_CONTOUR_KEY);
679                         }
680                         else if(  _lastKeyCode == 15 && ctrlKey ) //'O' || 'o' 
681                         {
682                                 toolCommand = &(OPEN_TOOL);
683                         }
684                         else if(  _lastKeyCode == 19 && ctrlKey ) //'S' || 's' 
685                         {
686                                 toolCommand = &(SAVE_KEY);
687                         }
688
689                         if ( toolCommand!=NULL )
690                         {
691                                 currentkey = toolCommand;
692                                 wxCommandEvent cevent( wxEVT_COMMAND_BUTTON_CLICKED );
693                                 cevent.SetClientData( (void *) toolCommand);
694                                 _eventHandler->ProcessEvent( cevent );
695                         }                               
696                 }*/
697                 
698         
699         //      long int endtime = clock();             
700
701                 return true; 
702         }
703         //------------------------------------------------------------------------------------------------------------
704
705         bool  wxVtkBaseView_SceneManager :: OnMouseMove()
706         { 
707
708                 bool condition = true;  
709                 int X,Y;
710                 wxVTKRenderWindowInteractor *_wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
711                 _wxVTKiren->GetEventPosition( X , Y );
712
713                 bool ctrlKey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey() == 1;
714 //???           bool shiftKey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey() == 1;
715
716                 if( _waiting && !ctrlKey )
717                 {
718                         sendEnvent( wxEVT_CHANGED_DEEP, "Update");
719                         //toca ver como decirle al viewer que no se mueva mientras no se este esperando que se pueda mover                      
720                 }
721                 
722                 if ( !_creatingROI && !_creatingMULT_ROI )
723                 {
724                         
725                         /*if( ctrlKey || shiftKey )
726                         {
727                                 
728                         }
729                         else
730                         {
731                                 _toIncludeAtInteractionGroup = false;
732                         }*/
733                         
734                         bool preserveState = _lastInteraction!=NULL? _lastInteraction->getViewer()->GetSelected() : false;
735                         std::string preservingName = preserveState ? _lastInteractionName : "";
736
737                         std::map<std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin();
738                         int i, size = _sceneContours_ViewControl->size();
739                         bool foundOne = false;
740
741                         manualContourBaseControler      * control       = _lastInteraction != NULL ? _lastInteraction->getControler() : NULL;
742                         manualViewBaseContour           * viewer        = NULL; 
743                         
744                         
745                         bool singleMoving = true;
746                         int selectionSize = _workingGroup->size();
747                         if( selectionSize > 1 ) 
748                         {
749                                 //Multiple moving
750                                 
751 //EED???                                bool ckecking = false;
752                                 for( i =0; i<size ; i++ ) 
753                                 {
754                                         control = iter->second->getControler();
755                                         viewer = iter->second->getViewer();
756                                         /*ckecking = */control->SetActive( true );
757                                 }
758                                 if (_lastInteraction != NULL)
759                                 {
760                                         singleMoving = !_lastInteraction->getViewer()->GetSelected();
761
762                                 }
763                                 if( !singleMoving )
764                                 {
765                                         size = selectionSize;
766                                         iter = _workingGroup->begin();
767                                 }
768                         }                       
769                         else
770                         {
771                                 
772                                 _toIncludeAtInteractionGroup = false;
773                         }
774                         
775                         if( ((_lastInteraction != NULL && !control->IsEditable() && !control->IsMoving() ) || _lastInteraction==NULL ))
776                         {                                       
777
778                                 _lastInteraction=NULL;
779                                 for( i =0; i<size ; i++ )
780                                 {
781                                         control = iter->second->getControler();
782                                         viewer = iter->second->getViewer();
783 //                                      _wxVtk_BaseView->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( control );
784                                         control->SetActive( true );                                     
785                                         
786                                         foundOne = control->OnMouseMove();
787                                         foundOne &= viewer->GetPosibleSelected();                               
788                                         
789                                         if ( !foundOne && singleMoving )
790                                         {
791                                                 control->SetActive( false );
792 //                                              _wxVtk_BaseView->GetInteractorStyleBaseView()->RemoveInteractorStyleMaracas( control );
793                                                 control->SetPosibleToMove( false );
794                                         }
795                                         else
796                                         {                                               
797                                                 if( _toIncludeAtInteractionGroup && preserveState && _lastInteractionName.compare( preservingName)==0 )
798                                                 {
799                                                         _lastInteraction->getControler()->SetActive( true );
800                                                 }
801
802                                                 _lastInteraction                = iter->second;
803                                                 _lastInteractionName    = iter->first;
804
805                                                 viewer->UpdateColorActor();
806                                                 control->SetPosibleToMove( true );
807                                                 // viewer->AddCompleteContourActor();
808                                         }
809                                         iter++;
810                                 }
811                                 control = NULL;
812                                 viewer = NULL;  
813                         }                               
814                 }
815                 return condition;       
816         }
817
818
819
820
821
822         //------------------------------------------------------------------------------------------------------------
823         bool  wxVtkBaseView_SceneManager :: OnLeftButtonDown()
824         { 
825
826
827
828 //EED???                char aa = _vtkInteractorStyleBaseView->GetInteractor()->GetKeyCode();
829                 bool condition = false;  
830                 //vtkCommand * theComand = _wxVtk_BaseView ->GetInteractorStyleBaseView()->GetCommand(
831 //EED???                vtkRenderWindowInteractor               * vtkRWInteractor1      = _wxVtk_BaseView ->GetWxVTKRenderWindowInteractor(); 
832 //EED???                wxVTKRenderWindowInteractor             * vtkRWInteractor2      = _wxVtk_BaseView ->GetWxVTKRenderWindowInteractor();//GetInteractorStyleBaseView()->GetInteractor();
833 //EED??         wxVTKRenderWindowInteractorPlus * vtkRWInteractor3      = (wxVTKRenderWindowInteractorPlus*)_wxVtk_BaseView ->GetWxVTKRenderWindowInteractor();//GetInteractorStyleBaseView()->GetInteractor();
834                 vtkRenderWindowInteractor               * vtkRWInteractor       = _vtkInteractorStyleBaseView->GetInteractor();
835                 
836                 bool ctrlKey = vtkRWInteractor->GetControlKey() == 1;
837                 bool shftKey = vtkRWInteractor->GetShiftKey() == 1;
838                 _toIncludeAtInteractionGroup = false;
839                 if ( ctrlKey || shftKey )
840                 {
841                         _toIncludeAtInteractionGroup = true;                    
842                 }
843                 else
844                 {
845                         if( _lastInteraction!=NULL && !_toIncludeAtInteractionGroup )
846                         {
847                                 if( _lastInteraction->getControler()->GetIfCompleteCreation() && !_lastInteraction->getControler()->IsEditable()&& !_lastInteraction->getViewer()->GetPosibleSelected() )
848                                 {
849                                         _lastInteraction->getControler()->SetEditable( false );
850                                         _lastInteraction->getControler()->SetActive( false ); 
851                                         _lastInteraction->getControler()->SetPosibleToMove( false );
852                                         _lastInteraction->getViewer()->Refresh();
853                                         _lastInteraction=NULL;
854                                 }
855                         }
856                 }
857
858
859
860                 if( !_toIncludeAtInteractionGroup )
861                 {
862                         _workingGroup->clear();
863                 }
864
865                 if( _lastInteraction!=NULL )
866                 {
867                         _toIncludeAtInteractionGroup = !_lastInteraction->getControler()->IsEditable();
868                         _toIncludeAtInteractionGroup &= _lastInteraction->getViewer()->GetSelected();
869                         _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( _lastInteractionName, _lastInteraction ));   
870                 }
871                 if( _creatingMULT_ROI && !_creatingROI && !ctrlKey  && !shftKey )
872                 {
873                         _creatingROI = true;
874                         //setControlActiveStateOf( _contours_ViewControl, false );
875                         sendEnvent( wxEVT_START_CREATE_ROI, "");
876                 }                       
877                 condition = true; 
878
879 // FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
880 // fprintf(ff,"EED wxVtkBaseView_SceneManager::OnLeftButtonDown() contours=%d  sceneContour=%d  workingContours=%d\n",
881 //                                      _contours_ViewControl->size(), _sceneContours_ViewControl->size(), _workingGroup->size() );
882 // fclose(ff);
883
884
885                 return condition;       
886         } 
887
888         //------------------------------------------------------------------------------------------------------------
889         bool  wxVtkBaseView_SceneManager :: OnLeftButtonUp()
890         {
891                 bool condition = false; 
892                 condition = true; 
893                                 
894                 if( _drawingSelectionROI )
895                 {
896                         setSelection2DROIInternalOutlines();
897                 }
898                 return condition;       
899         }
900         //------------------------------------------------------------------------------------------------------------
901         bool  wxVtkBaseView_SceneManager :: OnMiddleButtonDown()
902         {
903                 bool condition = false; 
904                 condition = true; 
905                         
906                 return condition;       
907         }
908         //------------------------------------------------------------------------------------------------------------
909         bool  wxVtkBaseView_SceneManager :: OnMiddleButtonUp()
910         {
911                 bool condition = false; 
912                 condition = true; 
913                         
914                 return condition;       
915         }
916         //------------------------------------------------------------------------------------------------------------
917         bool  wxVtkBaseView_SceneManager :: OnRightButtonDown()
918         {
919                 bool condition = false; 
920 //EED???                vtkRenderWindowInteractor * vtkRWInteractor = _vtkInteractorStyleBaseView->GetInteractor();
921 //EED???                bool ctrlKey = vtkRWInteractor->GetControlKey() == 1;
922                 _waiting = true; 
923                 
924                 condition = true;               
925                 
926                 return condition;       
927         }
928         //------------------------------------------------------------------------------------------------------------
929         bool  wxVtkBaseView_SceneManager :: OnRightButtonUp()
930         {
931                 bool condition = false; 
932                 condition = true; 
933                 //setControlActiveStateOfALL( false );//************************************************
934                 if ( _creatingMULT_ROI )
935                 {
936                         //setControlActiveStateOfALL( false );
937                 }
938                 if( _creatingROI )
939                 {
940                         sendEnvent( wxEVT_STOP_CREATE_ROI, "Activate");
941                         _creatingROI = false;
942                 }
943                 else
944                 {
945                         if(_lastInteraction!=NULL && !_toIncludeAtInteractionGroup)
946                         {
947                                 manualContourBaseControler * control = _lastInteraction->getControler();
948                                 //_lastInteraction->getControler()->SetPosibleToMove( false );
949                                 control->SetActive( false );
950                                 control->SetEditable( false );                          
951                                 control->SetPosibleToMove( false );
952 //                              _wxVtk_BaseView->GetInteractorStyleBaseView()->RemoveInteractorStyleMaracas( control );
953                                 _lastInteraction->getViewer()->Refresh();                       
954                                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
955                         }       
956                 }
957                 _waiting = false; 
958                 return condition;       
959         }
960         //------------------------------------------------------------------------------------------------------------
961
962         bool  wxVtkBaseView_SceneManager :: OnLeftDClick()
963         {
964                 bool condition = false; 
965                 condition = true; 
966                 
967                 return condition;       
968         }
969         //------------------------------------------------------------------------------------------------------------
970         bool  wxVtkBaseView_SceneManager :: OnRightDClick()
971         { 
972                 bool condition = false;  condition = true; 
973 //EED???                vtkRenderWindowInteractor * vtkRWInteractor = _vtkInteractorStyleBaseView->GetInteractor();
974                 /*vtkRenderWindowInteractor * vtkRWInteractor1 =*/ _vtkInteractorStyleBaseView->OnChar();
975 //EED???                wxVTKRenderWindowInteractor * wxVtkRWInterator = _wxVtk_BaseView ->GetWxVTKRenderWindowInteractor();
976                 
977                 /*if( _waiting )
978                 {
979                         sendEnvent( wxEVT_START_CREATE_MULT_ROI, "Multiple");
980                         set_creatingMULT_ROI( !_creatingMULT_ROI );
981                         _waiting = false;
982                 }
983                 else
984                         _waiting = true;*/
985
986                 return condition;       
987         }  
988         //------------------------------------------------------------------------------------------------------------
989         bool  wxVtkBaseView_SceneManager :: OnMiddleDClick()
990         {
991                 bool condition = false; 
992                 condition = true; 
993                 
994                 return condition;       
995         }
996         //------------------------------------------------------------------------------------------------------------
997         bool  wxVtkBaseView_SceneManager :: OnMouseWheel()
998         {
999                 bool condition = false; 
1000                 condition = true; 
1001                 return condition;       
1002         }
1003         //------------------------------------------------------------------------------------------------------------
1004
1005         void wxVtkBaseView_SceneManager :: drawSelectionROI()
1006         {
1007                 _drawingSelectionROI = true;
1008                 _workingGroup->clear();
1009                 _controlerSelectionROI->CreateNewManualContour();       
1010                 if (_lastInteraction!=NULL)
1011                 {
1012                         _lastInteraction->getControler()->SetEditable( false );
1013                         _lastInteraction->getControler()->SetActive( false ); 
1014                         _lastInteraction->getControler()->SetPosibleToMove( false );
1015                         _lastInteraction->getViewer()->Refresh();
1016                 }
1017                 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = _workingGroup->begin();
1018                 int i, workSize = _workingGroup->size();
1019                 for( i=0; i< workSize; i++ )
1020                 {
1021                         manualContourBaseControler * control = iter->second->getControler();
1022                         control->SetEditable( false );
1023                         control->SetActive( false );
1024                         control->SetPosibleToMove( false );
1025                         iter->second->getViewer()->Refresh();
1026
1027                         iter++;
1028                 }
1029                 _lastInteraction = NULL;
1030                 _lastInteractionName = "";
1031
1032                 _viewerSelectionROI->AddCompleteContourActor( true );   
1033                 _controlerSelectionROI->SetActive( true );
1034                 
1035                 _viewerSelectionROI->RefreshContour();
1036                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1037         }
1038         //------------------------------------------------------------------------------------------------------------
1039         void wxVtkBaseView_SceneManager :: setSelection2DROIInternalOutlines( )
1040         {
1041                 _drawingSelectionROI = false;
1042                 _workingGroup->clear();
1043                 double minX,minY,maxX,maxY, minX_ROI,minY_ROI,maxX_ROI,maxY_ROI;
1044                 double minZ = -1.0;
1045                 double maxZ = -1.0;
1046                 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin();
1047                 int i, size = _sceneContours_ViewControl->size();
1048                 _viewerSelectionROI->GetMinMax( minX_ROI, minY_ROI, maxX_ROI, maxY_ROI );
1049                 manualViewBaseContour * viewer;
1050                 bool insideRoi = false;
1051                 for ( i=0; i<size; i++ )
1052                 {
1053                         viewer = iter->second->getViewer();
1054                         viewer->GetMinMax( minX, minY, minZ, maxX, maxY, maxZ );
1055                         insideRoi = minX >= minX_ROI && maxX <= maxX_ROI && minY_ROI && maxY <= maxY_ROI;
1056                         if ( insideRoi )
1057                         {
1058                                 viewer->SetSelected( true );
1059                                 viewer->UpdateColorActor();
1060                                 setControlActiveStateOf( iter->second, true );
1061                                 _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( iter->first, iter->second ));
1062                         }
1063                         iter++;
1064                 }   
1065                 _viewerSelectionROI->RemoveCompleteContourActor( );     
1066                 _controlerSelectionROI->SetActive( false );
1067         }
1068         //------------------------------------------------------------------------------------------------------------
1069         void wxVtkBaseView_SceneManager :: writeCoords( std::string method )
1070         {
1071                 FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
1072                 long int start = clock();
1073 #if(WIN32)
1074                 double sg = (double)(start) / (double)CLK_TCK;
1075 #else
1076                 double sg = (double)(start) / CLOCKS_PER_SEC;
1077 #endif
1078                 int tmpPx,tmpPy;
1079                 wxVTKRenderWindowInteractor *wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1080                 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
1081                 fprintf(ff,"::%s (x,y) = (%i, %i) t(sg): %f\n  \n",method.c_str(), tmpPx, tmpPy, sg);
1082                 fclose(ff);
1083         }
1084
1085
1086         //------------------------------------------------------------------------------------------------------------
1087         void wxVtkBaseView_SceneManager::SaveThingName(FILE *ff, std::string nameThing)
1088         {
1089                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->find(nameThing); 
1090                 manualViewBaseContour           * cViewer;
1091                 manualContourBaseControler      * cControler;
1092                 ContourWrap_ViewControl *conwraviwcont=iter->second;
1093
1094                 cViewer         = conwraviwcont->getViewer();
1095                 cViewer->Save(ff);
1096
1097                 cControler      = conwraviwcont->getControler();
1098 //              cControler->Save(ff);
1099
1100 //              cModel          = cControler->GetManualContourModel();
1101 //              cModel->Save(ff);
1102         }
1103
1104
1105         //------------------------------------------------------------------------------------------------------------
1106         void wxVtkBaseView_SceneManager::GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ )
1107         {
1108                 std::vector<std::string> currentSelection = this->getSelectedObjects();
1109                 if (currentSelection.size()>=1){
1110                         
1111                         manualContourBaseControler *cControler  = this->getControlerOf( currentSelection[0] );
1112                         manualContourModel *cModel                              = cControler->GetManualContourModel();
1113                         int i,size = cModel->GetNumberOfPointsSpline();
1114                         double x,y,z;
1115                         for (i=0; i<size; i++) 
1116                         {
1117                                 cModel->GetSpline_i_Point(i, &x, &y, &z);
1118                                 vecX->push_back(x);
1119                                 vecY->push_back(y);
1120                                 vecZ->push_back(z);
1121                         }
1122                 }
1123         }
1124
1125         //------------------------------------------------------------------------------------------------------------
1126         vtkImageData *wxVtkBaseView_SceneManager::GetImageData()
1127         {
1128                 wxVtk2DBaseView *wxvtk2dbaseview =(wxVtk2DBaseView*)_wxVtk_BaseView;
1129                 return wxvtk2dbaseview->GetVtkBaseData()->GetImageData();
1130         }
1131
1132         //------------------------------------------------------------------------------------------------------------
1133         int wxVtkBaseView_SceneManager::GetImageDataSizeZ()
1134         {
1135                         int ext[6];
1136                         vtkImageData    *imagedata      = GetImageData();
1137                         imagedata->GetExtent(ext);
1138                         int sizeZ = ext[5]-ext[4]+1;
1139
1140 //EED OJO   Machete
1141 //                      sizeZ = sizeZ-1;
1142
1143                         return sizeZ;
1144         }
1145
1146         //------------------------------------------------------------------------------------------------------------
1147         void wxVtkBaseView_SceneManager::GetImageDataRange( double *range )
1148         {
1149                 int ext[6];
1150                 vtkImageData    *imagedata      = GetImageData();
1151                 imagedata->GetExtent(ext);
1152                 int sizeX       = ext[1]-ext[0]+1;
1153                 int sizeY       = ext[3]-ext[2]+1;
1154                 int sizeZ       = GetImageDataSizeZ();
1155                 int sizeXYZ = sizeX*sizeY*sizeZ;
1156                 long int i;
1157                 range[0]=9999999;
1158                 range[1]=-9999999;
1159                 unsigned short *p = (unsigned short *)imagedata->GetScalarPointer(0,0,0);
1160                 for (i=0;i<sizeXYZ;i++)
1161                 {
1162                         if ( p[i]<range[0] ) range[0]=p[i];
1163                         if ( p[i]>range[1] ) range[1]=p[i]; 
1164                 }
1165         }
1166
1167         //------------------------------------------------------------------------------------------------------------
1168         void wxVtkBaseView_SceneManager::SetWidthContour(double width)
1169         {
1170                 _widthOfContour = width;
1171                 manualViewBaseContour           *cViewer;
1172                 ContourWrap_ViewControl         *conwraviwcont;
1173                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter;; 
1174
1175                 for (iter=_contours_ViewControl->begin(); iter!=_contours_ViewControl->end(); iter++ )
1176                 {
1177                         conwraviwcont   = iter->second;
1178                         cViewer                 = conwraviwcont->getViewer();
1179                         cViewer->SetWidthLine(_widthOfContour);
1180                 }
1181         }
1182
1183         bool wxVtkBaseView_SceneManager::isEditableCControler(std::string theKeyName){
1184                 
1185                 ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName);
1186                 if(ccon != NULL ){
1187                         manualContourBaseControler* cControler = ccon->getControler();
1188                         if(cControler != NULL && cControler->IsEditable() == false){
1189                                 return true;
1190                         }
1191                 }
1192                 return false;
1193         }
1194
1195         void wxVtkBaseView_SceneManager::deleteCViewerCControler(std::string theKeyName){
1196                 
1197
1198                 ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName);
1199
1200                 manualViewBaseContour                   * cViewer = ccon->getViewer();
1201                 manualContourBaseControler      * cControler = ccon->getControler();
1202
1203                 removeFromScene(theKeyName);
1204                 removeWrap(theKeyName);
1205
1206                 delete cViewer;         
1207                 delete cControler;
1208         }
1209