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