wxVtkBaseView_SceneManager.cxx

Go to the documentation of this file.
00001 
00002 //----------------------------------------------------------------------------------------------------------------
00003 // Class definition include
00004 //----------------------------------------------------------------------------------------------------------------
00005 #include "wxVtkBaseView_SceneManager.h"
00006 #include "wxVtk2DBaseView.h"
00007 
00008 //----------------------------------------------------------------------------------------------------------------
00009 // Class implementation
00010 //----------------------------------------------------------------------------------------------------------------
00014 //------------------------------------------------------------------------------------------------------------
00015 // Includes
00016 //------------------------------------------------------------------------------------------------------------
00017 #include "wxContour_ActionCommandsID.h"
00018 
00019 //------------------------------------------------------------------------------------------------------------
00020 // Generated events declaration and definition
00021 //------------------------------------------------------------------------------------------------------------
00022 
00023 DEFINE_EVENT_TYPE( wxEVT_START_CREATE_MULT_ROI )        
00024 DEFINE_EVENT_TYPE( wxEVT_STOP_CREATE_MULT_ROI ) 
00025 DEFINE_EVENT_TYPE( wxEVT_START_CREATE_ROI )
00026 DEFINE_EVENT_TYPE( wxEVT_STOP_CREATE_ROI )
00027 DEFINE_EVENT_TYPE( wxEVT_DELETE_ROI )
00028 DEFINE_EVENT_TYPE( wxEVT_SELECTED_MULT_ROI )    
00029 DEFINE_EVENT_TYPE( wxEVT_SELECTED_ROI ) 
00030 DEFINE_EVENT_TYPE( wxEVT_UNSLECTED_ROI )        
00031 DEFINE_EVENT_TYPE( wxEVT_MANUAL_HIDED_ROI )
00032 DEFINE_EVENT_TYPE( wxEVT_MANUAL_SHOWED_ROI )
00033 DEFINE_EVENT_TYPE( wxEVT_EDITING_ROI )  
00034 DEFINE_EVENT_TYPE( wxEVT_MOVING_ROI )   
00035 DEFINE_EVENT_TYPE( wxEVT_MOVING_ROI_POINT )     
00036 DEFINE_EVENT_TYPE( wxEVT_SELECTED_ROI_POINT )   
00037 DEFINE_EVENT_TYPE( wxEVT_UNSELECTED_ROI_POINT ) 
00038 DEFINE_EVENT_TYPE( wxEVT_CHANGED_DEEP ) 
00039 
00040 
00041         wxVtkBaseView_SceneManager :: wxVtkBaseView_SceneManager( wxVtkBaseView * theWxBaseViewToManage, wxEvtHandler * theEventHandler, double * spc )
00042         {
00043                 
00044                 _lastInteraction                                = NULL;
00045                 _lastInteractionName                            = "";
00046                 _eventHandler                                   = theEventHandler;
00047                 _leftClickCount                                 = 0;
00048                 _rigthClickCount                                = 0;
00049                 
00050                 _contours_ViewControl                           = new std::map< std::string, ContourWrap_ViewControl * >();
00051                 _sceneContours_ViewControl                      = new std::map< std::string, ContourWrap_ViewControl * >();
00052                 _workingGroup                                   = new std::map< std::string, ContourWrap_ViewControl * >();
00053 
00054                 _creatingMULT_ROI                               = false;
00055                 _editingROI                                     = false;
00056                 _toIncludeAtInteractionGroup                    = false;
00057                 _waiting                                        = false;
00058                 _creatingROI                                    = false;
00059                 _drawingSelectionROI                            = false;
00060                 SetWidthContour(1.0);
00061                 
00062                 _wxVtk_BaseView = theWxBaseViewToManage;
00063                 if( _wxVtk_BaseView!=NULL )
00064                 {
00065                         vtkInteractorStyleBaseView* theInteractorStyleBaseView = (vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView();
00066                         theInteractorStyleBaseView->AddInteractorStyleMaracas( this );
00067                         SetVtkInteractorStyleBaseView( theInteractorStyleBaseView );                    
00068                 }
00069                 configureSelectionROI( spc );
00070         }
00071         //------------------------------------------------------------------------------------------------------------
00072         wxVtkBaseView_SceneManager :: ~wxVtkBaseView_SceneManager()
00073         {
00074                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->begin(); 
00075                 int size = _contours_ViewControl->size();
00076                 for ( int i = 0; i<size; iter++ )
00077                 {
00078                         _contours_ViewControl->erase( iter );
00079                         i++;
00080                 }
00081                 _contours_ViewControl->clear();         
00082                 delete _contours_ViewControl;           
00083                 _workingGroup->clear();
00084                 delete _lastInteraction;
00085                 delete _workingGroup;
00086                 //delete _contours_ViewControl;
00087         }
00088 
00089         //------------------------------------------------------------------------------------------------------------
00090         // Methods for capturing events
00091         //------------------------------------------------------------------------------------------------------------
00092 
00093                 
00094         //------------------------------------------------------------------------------------------------------------
00095         //  Methods for sending events
00096         //------------------------------------------------------------------------------------------------------------
00097         void wxVtkBaseView_SceneManager :: sendEnvent( WXTYPE theEventType, std::string text )
00098         {
00099                 if ( _eventHandler != NULL )
00100                 {
00101                         wxCommandEvent cevent( theEventType );
00102                         cevent.SetString( wxString( text.c_str(), wxConvUTF8) );
00103                         _eventHandler->ProcessEvent( cevent );
00104                 }
00105         }
00106 
00107 
00108         //------------------------------------------------------------------------------------------------------------
00109         //  Attributes getters and setters
00110         //------------------------------------------------------------------------------------------------------------
00111         void wxVtkBaseView_SceneManager :: setWxEventHandler( wxEvtHandler * theEventHandler )
00112         {
00113                 _eventHandler = theEventHandler;
00114         }
00115         //------------------------------------------------------------------------------------------------------------
00116         void wxVtkBaseView_SceneManager :: setWxVtkViewBase( wxVtkBaseView * theBaseView )
00117         {
00118                 _wxVtk_BaseView = theBaseView;
00119         }
00120 
00121         //------------------------------------------------------------------------------------------------------------
00122         wxVtkBaseView * wxVtkBaseView_SceneManager :: getWxVtkViewBase()
00123         {
00124                 return _wxVtk_BaseView;
00125         }
00126         //------------------------------------------------------------------------------------------------------------
00127         void wxVtkBaseView_SceneManager :: configureViewControlTo( std::string theKeyName, manualBaseModel * manModelContour, double * spc,int typeContour)
00128         {
00129                 //setControlActiveStateOfALL( false );
00130                 _creatingROI = true;
00131                 _waiting = false;       
00132                 if( _lastInteraction!=NULL )
00133                 {
00134                         _lastInteraction->getControler()->SetEditable( false );
00135                         _lastInteraction->getViewer()->Refresh();
00136                         _lastInteraction->getControler()->SetActive( false );
00137                         this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00138                 }
00139 
00140 
00141                 manualContourBaseControler *manContourControl;
00142                 manualViewBaseContour           *manViewerContour;
00143 
00144                 // Creating the view manualViewContour and the manualContourControler
00145                 // NOTE: The model is created in the KernelManagerContour class, factoryManualContourModel method
00146                 if (typeContour==1)
00147                 {
00148                         manContourControl       = new manualContourControler();
00149                         manViewerContour        = new manualViewContour();
00150                 }
00151 
00152                 if (typeContour==2)
00153                 {
00154                         manContourControl       = new manualRoiControler();
00155                         manViewerContour        = new manualViewRoi();
00156                 }
00157 
00158                 if (typeContour==3)
00159                 {
00160                         manContourControl       = new manualCircleControler();
00161                         manViewerContour        = new manualViewCircle();
00162                 }
00163 
00164                 if (typeContour==4)
00165                 {
00166                         manContourControl       = new manualRoiControler();
00167                         manViewerContour        = new manualViewBullEye();
00168                 }
00169 
00170                 if (typeContour==6)
00171                 {
00172                         manContourControl       = new manualLineControler();
00173                         manViewerContour        = new manualViewLine();
00174                 }
00175 
00176                 //Points
00177                 if (typeContour==7)
00178                 {
00179                         manContourControl       = new manualContourControler();
00180                         manViewerContour        = new manualViewPoints();
00181                 }
00182 
00183                 //Polygon
00184                 if (typeContour==10)
00185                 {
00186                         manContourControl       = new manualContourControler();
00187                         manViewerContour        = new manualViewContour();
00188                 }
00189 
00190 
00191 
00192         _lastInteraction = insertWrap( theKeyName, manContourControl, manViewerContour );
00193                 _lastInteractionName = theKeyName;
00194 
00195                 //Configuring the relations between the contour members representation                  
00196                 manViewerContour->SetModel( manModelContour );
00197                 manViewerContour->SetWxVtkBaseView( _wxVtk_BaseView );
00198                 manViewerContour->SetRange( _widthOfControlPoint );
00199                 manViewerContour->SetZ( -900 ); 
00200 
00201                 manViewerContour->SetSpacing(spc);
00202 
00203                 manViewerContour->SetColorNormalContour(0, 0, 1);
00204                 manViewerContour->SetColorEditContour(0.5, 0.5, 0.5);
00205                 manViewerContour->SetColorSelectContour(1, 0.8, 0);
00206                 manViewerContour->SetWidthLine(_widthOfContour);
00207 
00208                 manContourControl->SetModelView( manModelContour , manViewerContour );
00209                 manContourControl->Configure();
00210                 int i,sizeLstPoints = manModelContour->GetSizeLstPoints();
00211                 for ( i=0; i<sizeLstPoints; i++ )
00212                 {
00213                         manViewerContour->AddPoint();
00214                 }
00215 
00216                 manContourControl->CreateNewManualContour();
00217                 manViewerContour->RefreshContour();                     
00218                 addToScene( theKeyName );
00219         }
00220         //------------------------------------------------------------------------------------------------------------
00221         void wxVtkBaseView_SceneManager :: configureSelectionROI( double * spc )
00222         {
00223                 _controlerSelectionROI = new manualRoiControler();
00224                 _viewerSelectionROI = new manualViewRoi();
00225                 _modelSelectionROI = new manualContourModel();
00226                 
00227                 _viewerSelectionROI->SetModel( _modelSelectionROI );
00228                 _viewerSelectionROI->SetWxVtkBaseView( _wxVtk_BaseView );
00229                 _viewerSelectionROI->SetRange( 2 );
00230                 _viewerSelectionROI->SetZ( -900 );
00231                 _viewerSelectionROI->SetColorNormalContour(0.6, 0.8, 0);
00232 
00233                 _viewerSelectionROI->SetSpacing( spc );
00234 
00235                 _controlerSelectionROI->SetModelView( _modelSelectionROI , _viewerSelectionROI );
00236                 ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _controlerSelectionROI );
00237                 _controlerSelectionROI->SetActive(false);
00238         }
00239 
00240         //------------------------------------------------------------------------------------------------------------
00241         ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: insertWrap( std::string theKeyName, manualContourBaseControler * manContourControl, manualViewBaseContour  * manViewerContour )
00242         {       
00243                 ContourWrap_ViewControl * newContourWrap = new ContourWrap_ViewControl(manContourControl, manViewerContour);
00244                 if(_contours_ViewControl == NULL)
00245                 {
00246                         _contours_ViewControl = new std::map< std::string, ContourWrap_ViewControl * >();
00247                 }
00248                 _contours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, newContourWrap ));
00249                 return newContourWrap;
00250         } 
00251         //------------------------------------------------------------------------------------------------------------
00252         void wxVtkBaseView_SceneManager :: desconfigureViewControlOf( std::string theKeyName )
00253         {
00254                 
00255         }
00256         //------------------------------------------------------------------------------------------------------------
00257         void wxVtkBaseView_SceneManager :: removeWrap( std::string theKeyName )
00258         {
00259                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
00260                 iter = _contours_ViewControl->find( theKeyName );
00261                 _contours_ViewControl->erase( iter );
00262                 _lastInteraction=NULL;
00263                 _lastInteractionName = "";
00264                 _workingGroup->clear();
00265                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00266                 this->_vtkInteractorStyleBaseView->EvaluateToRefresh();
00267         } 
00268         //------------------------------------------------------------------------------------------------------------
00269         ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf ( std::string theName )
00270         {
00271                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
00272                 iter = _contours_ViewControl->find( theName );
00273                 return iter->second;
00274                 //return iter->first;
00275         }
00276         //------------------------------------------------------------------------------------------------------------
00277         ContourWrap_ViewControl * wxVtkBaseView_SceneManager :: getContourWrap_ViewControlOf ( std::string theName, std::map<std::string, ContourWrap_ViewControl *> * theMap )
00278         {
00279                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
00280                 iter = theMap->find( theName );
00281                 return iter->second;
00282         }
00283         //------------------------------------------------------------------------------------------------------------
00284         manualContourBaseControler * wxVtkBaseView_SceneManager :: getControlerOf( std::string theName )
00285         {
00286                 return getContourWrap_ViewControlOf ( theName )->getControler();
00287         }
00288         //------------------------------------------------------------------------------------------------------------
00289         manualViewBaseContour * wxVtkBaseView_SceneManager :: getViewerOf( std::string theName )
00290         {
00291                 return getContourWrap_ViewControlOf ( theName )->getViewer();
00292         }
00293         //------------------------------------------------------------------------------------------------------------
00294         void wxVtkBaseView_SceneManager :: set_creatingMULT_ROI( bool condition )
00295         {
00296                 _creatingMULT_ROI = condition;
00297         }
00298         //------------------------------------------------------------------------------------------------------------
00299         void wxVtkBaseView_SceneManager :: set_editingROI( bool condition )
00300         {
00301                 _editingROI = condition;
00302         }
00303         //------------------------------------------------------------------------------------------------------------
00304         void wxVtkBaseView_SceneManager :: set_toIncludeAtInteractionGroup( bool condition )
00305         {
00306                 _toIncludeAtInteractionGroup = condition;
00307         }
00308         //------------------------------------------------------------------------------------------------------------
00309         void wxVtkBaseView_SceneManager :: set_waiting( bool condition )
00310         {
00311                 _waiting = condition;
00312         }
00313         //------------------------------------------------------------------------------------------------------------
00314         bool wxVtkBaseView_SceneManager :: get_creatingMULT_ROI(  )
00315         {
00316                 return _creatingMULT_ROI;
00317         }
00318         //------------------------------------------------------------------------------------------------------------
00319         bool wxVtkBaseView_SceneManager :: get_editingROI(  )
00320         {
00321                 return _editingROI;
00322         }
00323         //------------------------------------------------------------------------------------------------------------
00324         bool wxVtkBaseView_SceneManager :: get_toIncludeAtInteractionGroup(  )
00325         {
00326                 return _toIncludeAtInteractionGroup;
00327         }
00328 
00329         //------------------------------------------------------------------------------------------------------------
00330         bool wxVtkBaseView_SceneManager :: get_waiting(  )
00331         {
00332                 return _waiting;
00333         }
00334 
00335         //------------------------------------------------------------------------------------------------------------
00336         bool wxVtkBaseView_SceneManager :: get_creatingROI()
00337         {
00338                 return _creatingROI;
00339         }
00340         //------------------------------------------------------------------------------------------------------------
00341         void wxVtkBaseView_SceneManager :: set_creatingROI( bool condition )
00342         {
00343                 _creatingROI = condition;
00344         }
00345 
00346         //------------------------------------------------------------------------------------------------------------
00347         //  Other functional methods
00348         //------------------------------------------------------------------------------------------------------------
00349 
00350         void wxVtkBaseView_SceneManager :: createCopyContourOf( std::string anExistingKName, std::string cloneName, manualBaseModel * manualModel, bool append )
00351         {
00352                 if ( !append )
00353                 {
00354                         setControlActiveStateOf( _workingGroup, false );
00355                         _workingGroup->clear();
00356                 }
00357         std::map <std::string, ContourWrap_ViewControl *>::iterator iter; 
00358 
00359 
00360                 iter = _contours_ViewControl->find( anExistingKName );
00361 
00362                 manualBaseModel                 *cModule        = manualModel;
00363                 manualViewBaseContour           *cViewer        = iter->second->getViewer()->Clone();
00364                 manualContourBaseControler      *cControl       = iter->second->getControler()->Clone(  );
00365 
00366                 cViewer->SetModel(cModule);
00367                 cControl->SetModelView( cModule , cViewer );
00368                 cControl->CreateNewManualContour();
00369                 cControl->SetActive( true );    
00370                 cControl->SetEditable( false );         
00371 
00372         cViewer->RefreshContour();     
00373                 cViewer->Refresh();
00374                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00375                 this->_vtkInteractorStyleBaseView->EvaluateToRefresh();
00376 
00377                 _lastInteraction = insertWrap( cloneName, cControl, cViewer );
00378                 _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( cloneName, _lastInteraction ));              
00379         addToScene( cloneName );
00380         }
00381 
00382         //------------------------------------------------------------------------------------------------------------
00383 
00384         void wxVtkBaseView_SceneManager :: removeFromScene( ContourWrap_ViewControl * contourWRP, bool visualization, bool control )
00385         {
00386                 if( contourWRP == _lastInteraction )
00387                 {
00388                         _lastInteraction = NULL;
00389                         _lastInteractionName = "";
00390                 }
00391 
00392 
00393                 ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->RemoveInteractorStyleMaracas( contourWRP->getControler() );
00394 
00395                 contourWRP->getControler()->SetActive( control );       
00396                 contourWRP->getControler()->SetEditable( false );               
00397 
00398                 if ( !visualization && control )
00399                 {
00400                         contourWRP->getViewer()->RemoveControlPoints( );
00401                         contourWRP->getViewer()->RemoveTextActor( );
00402                 }
00403                 if ( visualization )
00404                 {
00405                         contourWRP->getViewer()->RemoveCompleteContourActor();                  
00406                 }
00407                 
00408         }
00409         //------------------------------------------------------------------------------------------------------------
00410         void wxVtkBaseView_SceneManager :: removeFromScene( std::string theKeyName, bool visualization , bool control )
00411         {
00412 
00413                 std::map<std::string, ContourWrap_ViewControl *> :: iterator iter;
00414                 iter = _sceneContours_ViewControl->find( theKeyName );
00415                 if (iter != _sceneContours_ViewControl->end())
00416                 {
00417                         ContourWrap_ViewControl * contourWRP =   iter->second;
00418                         removeFromScene( contourWRP );  
00419                         _sceneContours_ViewControl->erase(iter);
00420                 }       
00421         }
00422 
00423 
00424         //------------------------------------------------------------------------------------------------------------
00425         std::vector<std::string> wxVtkBaseView_SceneManager::GetlstContoursNameActualSlice()
00426         {
00427                 std::vector<std::string> lstContoursNameActualSlice;
00428                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin(); 
00429                 int i,size = _sceneContours_ViewControl->size();
00430                 for ( i = 0; i<size; i++ )
00431                 {
00432                         lstContoursNameActualSlice.push_back( iter->first );
00433                         iter++;
00434                 }
00435                 return lstContoursNameActualSlice;
00436         }
00437 
00438         //------------------------------------------------------------------------------------------------------------
00439         void wxVtkBaseView_SceneManager :: removeSceneContours( )
00440         {
00441                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin(); 
00442                 int size = _sceneContours_ViewControl->size();
00443                 for ( int i = 0; i<size; i++ )
00444                 {
00445                         removeFromScene( iter->second );
00446                         iter++;
00447                 }
00448                 _sceneContours_ViewControl->clear();
00449 
00450 
00451                 //Removing the selection rectangle to avoid showing when it's innecesary
00452                 _controlerSelectionROI->SetActive( false );             
00453                 _viewerSelectionROI->RemoveCompleteContourActor();      
00454         }
00455 
00456         void wxVtkBaseView_SceneManager::removeAllOutlines()
00457         {
00458                 manualViewBaseContour           * cViewer;
00459                 manualContourBaseControler      * cControler;
00460 
00461                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter; 
00462                 int i,size=_contours_ViewControl->size();
00463                 for (i=0;i<size;i++)
00464                 {
00465                         iter = _contours_ViewControl->begin(); 
00466                         cControler      = iter->second->getControler();
00467                         cViewer         = iter->second->getViewer();
00468                         removeWrap( iter->first );
00469                         delete cViewer;
00470                         delete cControler;
00471                 }// for
00472 
00473         }
00474 
00475 
00476         //------------------------------------------------------------------------------------------------------------
00477         void wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
00478         {
00479                 if( !append )
00480                 {
00481                         removeSceneContours();                  
00482                 }
00483                 ContourWrap_ViewControl * contourWRP =  getContourWrap_ViewControlOf( theKeyName );
00484                 _sceneContours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, contourWRP ) );             
00485 
00486                 addToScene( theKeyName, contourWRP, true, visualization, control, ifActive, ifShowCtrlPoints);
00487         }
00488 
00489         //------------------------------------------------------------------------------------------------------------
00490         void wxVtkBaseView_SceneManager :: addToScene( std::string theKeyName, ContourWrap_ViewControl * contourWRP, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
00491         {
00492                 if( !append )
00493                 {
00494                         removeSceneContours();                  
00495                 }               
00496                 _sceneContours_ViewControl->insert(std::pair <std::string, ContourWrap_ViewControl *> ( theKeyName, contourWRP ) );             
00497                 if ( visualization )
00498                 {
00499                         contourWRP->getViewer()->AddCompleteContourActor( ifShowCtrlPoints );
00500                 }
00501 
00502                 if( control )
00503                 {
00504                         ((vtkInteractorStyleBaseView*)_wxVtk_BaseView->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( contourWRP->getControler() );
00505                 }
00506                 if( ifActive )
00507                 {
00508                         contourWRP->getControler()->SetActive( true );  
00509                         contourWRP->getViewer()->RemoveTextActor();
00510                 }
00511         }
00512 
00513         //------------------------------------------------------------------------------------------------------------
00514         void wxVtkBaseView_SceneManager :: removeFromScene( std::vector< std::string> theKeyNameVector, bool visualization, bool control  )
00515         {
00516                 int i, size = theKeyNameVector.size();
00517                 for( i=0; i< size; i++ )
00518                 {
00519                         removeFromScene( theKeyNameVector[i], visualization, control );
00520                 }
00521         }
00522 
00523         //------------------------------------------------------------------------------------------------------------
00524         void wxVtkBaseView_SceneManager :: addToScene( std::vector< std::string> theKeyNameVector, bool append, bool visualization, bool control, bool ifActive, bool ifShowCtrlPoints )
00525         {
00526                 int i, size = theKeyNameVector.size();
00527                 for( i=0; i< size; i++ )
00528                 {
00529                         addToScene( theKeyNameVector[i], append, visualization, control, ifActive, ifShowCtrlPoints );
00530                 }
00531         }
00532 
00533         //------------------------------------------------------------------------------------------------------------
00534         void wxVtkBaseView_SceneManager :: setControlActiveStateOfALL( bool stateCondition )
00535         {
00536                 setControlActiveStateOf( _contours_ViewControl, stateCondition );                       
00537         }
00538 
00539         //------------------------------------------------------------------------------------------------------------
00540         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( std::string theKeyName, bool stateCondition )
00541         {
00542                 ContourWrap_ViewControl * contourWRP =  getContourWrap_ViewControlOf( theKeyName );
00543                 setControlActiveStateOf( contourWRP, stateCondition );
00544         }
00545 
00546         //------------------------------------------------------------------------------------------------------------
00547         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( ContourWrap_ViewControl * contourWRP, bool stateCondition )
00548         {
00549                 contourWRP->getControler()->SetActive( stateCondition );        
00550                 contourWRP->getControler()->SetEditable( false );               
00551         }
00552 
00553         //------------------------------------------------------------------------------------------------------------
00554         void wxVtkBaseView_SceneManager :: setVisibleStateOf( std::string theKeyName, bool stateCondition )
00555         {
00556                 ContourWrap_ViewControl * contourWRP =  getContourWrap_ViewControlOf( theKeyName );
00557 //              contourWRP->getViewer()->SetVisible( stateCondition );
00558                 if ( contourWRP!=NULL )
00559                         removeFromScene( contourWRP, false, stateCondition );
00560         }
00561 
00562         //------------------------------------------------------------------------------------------------------------
00563         std::vector< std::string > wxVtkBaseView_SceneManager :: getSelectedObjects()
00564         {
00565                 std::vector< std::string > selectedObjects;
00566                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _workingGroup->begin(); 
00567                 int size = _workingGroup->size();
00568                 for ( int i = 0; i<size; i++ )
00569                 {
00570 //EED???                        manualViewBaseContour * viewer = iter->second->getViewer();
00571                         selectedObjects.push_back( iter->first);        
00572 
00573                         iter++;
00574                 }       
00575                 return selectedObjects;
00576         }
00577         //------------------------------------------------------------------------------------------------------------
00578         void wxVtkBaseView_SceneManager :: selectObjects( std::vector< std::string > theExistingObjectsToSelect )
00579         {
00580                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->begin(); 
00581 //EED???                int size = _contours_ViewControl->size();       
00582 //EED???                bool selected;
00583                 /*for ( int i = 0; i<size; i++ )
00584                 {
00585                         selected = false;
00586                         manualViewBaseContour * viewer = iter->second->getViewer();     
00587                         std::vector <std::string >::iterator iterIN;
00588                         int a = 0;
00589                         for( a = 0, iterIN = theExistingObjectsToSelect.begin() ; !selected && a < theExistingObjectsToSelect.size() ; a++ )
00590                         {
00591                                 if( iter->first.compare( theExistingObjectsToSelect[i] ) )
00592                                 {                                       
00593                                         viewer->SelectAllPoints( true );
00594                                         viewer->SelectPosibleContour( true );           
00595                                         selected = true;
00596                                         theExistingObjectsToSelect.erase( iterIN );                                     
00597                                 }
00598                                 if( !selected )
00599                                         iterIN++;
00600                         }
00601                 }       */
00602         }
00603 
00604         //------------------------------------------------------------------------------------------------------------
00605         void wxVtkBaseView_SceneManager :: selectObjects( std::map<std::string, ContourWrap_ViewControl *> * theMap )
00606         {
00607                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = theMap->begin(); 
00608                 int size = _contours_ViewControl->size();       
00609                 for ( int i = 0; i<size; i++ )
00610                 {
00611                         manualViewBaseContour * viewer = iter->second->getViewer();     
00612 
00613                         viewer->SetSelected( true );
00614                         /*viewer->SelectAllPoints( true );
00615                         viewer->SelectPosibleContour( true );*/         
00616                         
00617                         iter++;
00618                 }       
00619         }
00620 
00621         //------------------------------------------------------------------------------------------------------------
00622         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( std::vector< std::string> &theKeyNameVector, bool controlCondition )
00623         {
00624                 int i, size = theKeyNameVector.size();
00625                 for( i=0; i< size; i++ )
00626                 {
00627                         setControlActiveStateOf( theKeyNameVector[i], controlCondition );
00628                 }
00629         }
00630 
00631         //------------------------------------------------------------------------------------------------------------
00632         void wxVtkBaseView_SceneManager :: setControlActiveStateOf( std::map<std::string, ContourWrap_ViewControl *> * theMap, bool controlCondition )
00633         {
00634                 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = theMap->begin();
00635                 int i, size = theMap->size();
00636                 for( i=0; i< size; i++ )
00637                 {
00638                         removeFromScene( iter->second, false, controlCondition );               
00639                         iter++;
00640                 }               
00641         }
00642 
00643         //------------------------------------------------------------------------------------------------------------
00644         //  Private methods
00645         //------------------------------------------------------------------------------------------------------------
00646 
00647         //------------------------------------------------------------------------------------------------------------
00648         // Creational and initialization methods
00649         //------------------------------------------------------------------------------------------------------------
00650 
00651         //------------------------------------------------------------------------------------------------------------
00652         // Inherited Methods
00653         //------------------------------------------------------------------------------------------------------------
00654 
00655         bool  wxVtkBaseView_SceneManager :: isCtrlPressed()
00656         { 
00657                 return _ctrlKey;
00658         }
00659         bool  wxVtkBaseView_SceneManager :: isShiftPressed()
00660         { 
00661                 return _shiftKey;
00662         }
00663         char  wxVtkBaseView_SceneManager :: getLastKeyCode()
00664         { 
00665                 return _lastKeyCode;
00666         }
00667         bool  wxVtkBaseView_SceneManager :: OnChar()
00668         { 
00669 
00670                 _ctrlKey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey() == 1;
00671                 _shiftKey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey() == 1;
00672 
00673                 _lastKeyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
00674 
00675                 wxCommandEvent cevent( wxEVT_COMMAND_BUTTON_CLICKED );
00676                 _eventHandler->ProcessEvent( cevent );
00677                 
00678                                 
00679                 /*if( _eventHandler!=NULL )
00680                 {
00681                         char * toolCommand = NULL;
00682 
00683                         if ( _lastKeyCode == 3 && ctrlKey ) //'C' || 'c' 
00684                         {
00685                                 toolCommand = &(COPY_TOOL);
00686                         }
00687                         else if(  _lastKeyCode == 22 && ctrlKey ) //'V' || 'v' 
00688                         {
00689                                 toolCommand = &(PASTE_TOOL);
00690                         }
00691                         else if(  _lastKeyCode == 8 || (_lastKeyCode==127) ) // Delete 
00692                         {
00693                                 toolCommand = &(DELETE_KEY);
00694                         }
00695                         else if(  _lastKeyCode == 14 && ctrlKey ) //'N' || 'n' 
00696                         {
00697                                 toolCommand = &(CREATE_CONTOUR_KEY);
00698                         }
00699                         else if(  _lastKeyCode == 15 && ctrlKey ) //'O' || 'o' 
00700                         {
00701                                 toolCommand = &(OPEN_TOOL);
00702                         }
00703                         else if(  _lastKeyCode == 19 && ctrlKey ) //'S' || 's' 
00704                         {
00705                                 toolCommand = &(SAVE_KEY);
00706                         }
00707 
00708                         if ( toolCommand!=NULL )
00709                         {
00710                                 currentkey = toolCommand;
00711                                 wxCommandEvent cevent( wxEVT_COMMAND_BUTTON_CLICKED );
00712                                 cevent.SetClientData( (void *) toolCommand);
00713                                 _eventHandler->ProcessEvent( cevent );
00714                         }                               
00715                 }*/
00716                 
00717         
00718         //      long int endtime = clock();             
00719 
00720                 return true; 
00721         }
00722         //------------------------------------------------------------------------------------------------------------
00723 
00724         bool  wxVtkBaseView_SceneManager :: OnMouseMove()
00725         { 
00726 
00727                 bool condition = true;  
00728                 int X,Y;
00729                 wxVTKRenderWindowInteractor *_wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
00730                 _wxVTKiren->GetEventPosition( X , Y );
00731 
00732                 bool ctrlKey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey() == 1;
00733 //???           bool shiftKey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey() == 1;
00734 
00735                 if( _waiting && !ctrlKey )
00736                 {
00737                         sendEnvent( wxEVT_CHANGED_DEEP, "Update");
00738                         //toca ver como decirle al viewer que no se mueva mientras no se este esperando que se pueda mover                      
00739                 }
00740                 
00741                 if ( !_creatingROI && !_creatingMULT_ROI )
00742                 {
00743                         
00744                         /*if( ctrlKey || shiftKey )
00745                         {
00746                                 
00747                         }
00748                         else
00749                         {
00750                                 _toIncludeAtInteractionGroup = false;
00751                         }*/
00752                         
00753                         bool preserveState = _lastInteraction!=NULL? _lastInteraction->getViewer()->GetSelected() : false;
00754                         std::string preservingName = preserveState ? _lastInteractionName : "";
00755 
00756                         std::map<std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin();
00757                         int i, size = _sceneContours_ViewControl->size();
00758                         bool foundOne = false;
00759 
00760                         manualContourBaseControler      * control       = _lastInteraction != NULL ? _lastInteraction->getControler() : NULL;
00761                         manualViewBaseContour           * viewer        = NULL; 
00762                         
00763                         
00764                         bool singleMoving = true;
00765                         int selectionSize = _workingGroup->size();
00766                         if( selectionSize > 1 ) 
00767                         {
00768                                 //Multiple moving
00769                                 
00770 //EED???                                bool ckecking = false;
00771                                 for( i =0; i<size ; i++ ) 
00772                                 {
00773                                         control = iter->second->getControler();
00774                                         viewer = iter->second->getViewer();
00775                                         /*ckecking = */control->SetActive( true );
00776                                 }
00777                                 if (_lastInteraction != NULL)
00778                                 {
00779                                         singleMoving = !_lastInteraction->getViewer()->GetSelected();
00780 
00781                                 }
00782                                 if( !singleMoving )
00783                                 {
00784                                         size = selectionSize;
00785                                         iter = _workingGroup->begin();
00786                                 }
00787                         }                       
00788                         else
00789                         {
00790                                 
00791                                 _toIncludeAtInteractionGroup = false;
00792                         }
00793                         
00794                         if( ((_lastInteraction != NULL && !control->IsEditable() && !control->IsMoving() ) || _lastInteraction==NULL ))
00795                         {                                       
00796 
00797                                 _lastInteraction=NULL;
00798                                 for( i =0; i<size ; i++ )
00799                                 {
00800                                         control = iter->second->getControler();
00801                                         viewer = iter->second->getViewer();
00802 //                                      _wxVtk_BaseView->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( control );
00803                                         control->SetActive( true );                                     
00804                                         
00805                                         foundOne = control->OnMouseMove();
00806                                         foundOne &= viewer->GetPosibleSelected();                               
00807                                         
00808                                         if ( !foundOne && singleMoving )
00809                                         {
00810                                                 control->SetActive( false );
00811 //                                              _wxVtk_BaseView->GetInteractorStyleBaseView()->RemoveInteractorStyleMaracas( control );
00812                                                 control->SetPosibleToMove( false );
00813                                         }
00814                                         else
00815                                         {                                               
00816                                                 if( _toIncludeAtInteractionGroup && preserveState && _lastInteractionName.compare( preservingName)==0 )
00817                                                 {
00818                                                         _lastInteraction->getControler()->SetActive( true );
00819                                                 }
00820 
00821                                                 _lastInteraction                = iter->second;
00822                                                 _lastInteractionName    = iter->first;
00823 
00824                                                 viewer->UpdateColorActor();
00825                                                 control->SetPosibleToMove( true );
00826                                                 // viewer->AddCompleteContourActor();
00827                                         }
00828                                         iter++;
00829                                 }
00830                                 control = NULL;
00831                                 viewer = NULL;  
00832                         }                               
00833                 }
00834                 return condition;       
00835         }
00836 
00837 
00838 
00839 
00840 
00841         //------------------------------------------------------------------------------------------------------------
00842         bool  wxVtkBaseView_SceneManager :: OnLeftButtonDown()
00843         { 
00844 
00845 
00846 
00847 //EED???                char aa = _vtkInteractorStyleBaseView->GetInteractor()->GetKeyCode();
00848                 bool condition = false;  
00849                 //vtkCommand * theComand = _wxVtk_BaseView ->GetInteractorStyleBaseView()->GetCommand(
00850 //EED???                vtkRenderWindowInteractor               * vtkRWInteractor1      = _wxVtk_BaseView ->GetWxVTKRenderWindowInteractor(); 
00851 //EED???                wxVTKRenderWindowInteractor             * vtkRWInteractor2      = _wxVtk_BaseView ->GetWxVTKRenderWindowInteractor();//GetInteractorStyleBaseView()->GetInteractor();
00852 //EED??         wxVTKRenderWindowInteractorPlus * vtkRWInteractor3      = (wxVTKRenderWindowInteractorPlus*)_wxVtk_BaseView ->GetWxVTKRenderWindowInteractor();//GetInteractorStyleBaseView()->GetInteractor();
00853                 vtkRenderWindowInteractor               * vtkRWInteractor       = _vtkInteractorStyleBaseView->GetInteractor();
00854                 
00855                 bool ctrlKey = vtkRWInteractor->GetControlKey() == 1;
00856                 bool shftKey = vtkRWInteractor->GetShiftKey() == 1;
00857                 _toIncludeAtInteractionGroup = false;
00858                 if ( ctrlKey || shftKey )
00859                 {
00860                         _toIncludeAtInteractionGroup = true;                    
00861                 }
00862                 else
00863                 {
00864                         if( _lastInteraction!=NULL && !_toIncludeAtInteractionGroup )
00865                         {
00866                                 if( _lastInteraction->getControler()->GetIfCompleteCreation() && !_lastInteraction->getControler()->IsEditable()&& !_lastInteraction->getViewer()->GetPosibleSelected() )
00867                                 {
00868                                         _lastInteraction->getControler()->SetEditable( false );
00869                                         _lastInteraction->getControler()->SetActive( false ); 
00870                                         _lastInteraction->getControler()->SetPosibleToMove( false );
00871                                         _lastInteraction->getViewer()->Refresh();
00872                                         _lastInteraction=NULL;
00873                                 }
00874                         }
00875                 }
00876 
00877 
00878 
00879                 if( !_toIncludeAtInteractionGroup )
00880                 {
00881                         _workingGroup->clear();
00882                 }
00883 
00884                 if( _lastInteraction!=NULL )
00885                 {
00886                         _toIncludeAtInteractionGroup = !_lastInteraction->getControler()->IsEditable();
00887                         _toIncludeAtInteractionGroup &= _lastInteraction->getViewer()->GetSelected();
00888                         _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( _lastInteractionName, _lastInteraction ));   
00889                 }
00890                 if( _creatingMULT_ROI && !_creatingROI && !ctrlKey  && !shftKey )
00891                 {
00892                         _creatingROI = true;
00893                         //setControlActiveStateOf( _contours_ViewControl, false );
00894                         sendEnvent( wxEVT_START_CREATE_ROI, "");
00895                 }                       
00896                 condition = true; 
00897 
00898 // FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
00899 // fprintf(ff,"EED wxVtkBaseView_SceneManager::OnLeftButtonDown() contours=%d  sceneContour=%d  workingContours=%d\n",
00900 //                                      _contours_ViewControl->size(), _sceneContours_ViewControl->size(), _workingGroup->size() );
00901 // fclose(ff);
00902 
00903 
00904                 return condition;       
00905         } 
00906 
00907         //------------------------------------------------------------------------------------------------------------
00908         bool  wxVtkBaseView_SceneManager :: OnLeftButtonUp()
00909         {
00910                 bool condition = false; 
00911                 condition = true; 
00912                                 
00913                 if( _drawingSelectionROI )
00914                 {
00915                         setSelection2DROIInternalOutlines();
00916                 }
00917                 return condition;       
00918         }
00919         //------------------------------------------------------------------------------------------------------------
00920         bool  wxVtkBaseView_SceneManager :: OnMiddleButtonDown()
00921         {
00922                 bool condition = false; 
00923                 condition = true; 
00924                         
00925                 return condition;       
00926         }
00927         //------------------------------------------------------------------------------------------------------------
00928         bool  wxVtkBaseView_SceneManager :: OnMiddleButtonUp()
00929         {
00930                 bool condition = false; 
00931                 condition = true; 
00932                         
00933                 return condition;       
00934         }
00935         //------------------------------------------------------------------------------------------------------------
00936         bool  wxVtkBaseView_SceneManager :: OnRightButtonDown()
00937         {
00938                 bool condition = false; 
00939 //EED???                vtkRenderWindowInteractor * vtkRWInteractor = _vtkInteractorStyleBaseView->GetInteractor();
00940 //EED???                bool ctrlKey = vtkRWInteractor->GetControlKey() == 1;
00941                 _waiting = true; 
00942                 
00943                 condition = true;               
00944                 
00945                 return condition;       
00946         }
00947         //------------------------------------------------------------------------------------------------------------
00948         bool  wxVtkBaseView_SceneManager :: OnRightButtonUp()
00949         {
00950                 bool condition = false; 
00951                 condition = true; 
00952                 //setControlActiveStateOfALL( false );//************************************************
00953                 if ( _creatingMULT_ROI )
00954                 {
00955                         //setControlActiveStateOfALL( false );
00956                 }
00957                 if( _creatingROI )
00958                 {
00959                         sendEnvent( wxEVT_STOP_CREATE_ROI, "Activate");
00960                         _creatingROI = false;
00961                 }
00962                 else
00963                 {
00964                         if(_lastInteraction!=NULL && !_toIncludeAtInteractionGroup)
00965                         {
00966                                 manualContourBaseControler * control = _lastInteraction->getControler();
00967                                 //_lastInteraction->getControler()->SetPosibleToMove( false );
00968                                 control->SetActive( false );
00969                                 control->SetEditable( false );                          
00970                                 control->SetPosibleToMove( false );
00971 //                              _wxVtk_BaseView->GetInteractorStyleBaseView()->RemoveInteractorStyleMaracas( control );
00972                                 _lastInteraction->getViewer()->Refresh();                       
00973                                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00974                         }       
00975                 }
00976                 _waiting = false; 
00977                 return condition;       
00978         }
00979         //------------------------------------------------------------------------------------------------------------
00980 
00981         bool  wxVtkBaseView_SceneManager :: OnLeftDClick()
00982         {
00983                 bool condition = false; 
00984                 condition = true; 
00985                 
00986                 return condition;       
00987         }
00988         //------------------------------------------------------------------------------------------------------------
00989         bool  wxVtkBaseView_SceneManager :: OnRightDClick()
00990         { 
00991                 bool condition = false;  condition = true; 
00992 //EED???                vtkRenderWindowInteractor * vtkRWInteractor = _vtkInteractorStyleBaseView->GetInteractor();
00993                 /*vtkRenderWindowInteractor * vtkRWInteractor1 =*/ _vtkInteractorStyleBaseView->OnChar();
00994 //EED???                wxVTKRenderWindowInteractor * wxVtkRWInterator = _wxVtk_BaseView ->GetWxVTKRenderWindowInteractor();
00995                 
00996                 /*if( _waiting )
00997                 {
00998                         sendEnvent( wxEVT_START_CREATE_MULT_ROI, "Multiple");
00999                         set_creatingMULT_ROI( !_creatingMULT_ROI );
01000                         _waiting = false;
01001                 }
01002                 else
01003                         _waiting = true;*/
01004 
01005                 return condition;       
01006         }  
01007         //------------------------------------------------------------------------------------------------------------
01008         bool  wxVtkBaseView_SceneManager :: OnMiddleDClick()
01009         {
01010                 bool condition = false; 
01011                 condition = true; 
01012                 
01013                 return condition;       
01014         }
01015         //------------------------------------------------------------------------------------------------------------
01016         bool  wxVtkBaseView_SceneManager :: OnMouseWheel()
01017         {
01018                 bool condition = false; 
01019                 condition = true; 
01020                 return condition;       
01021         }
01022         //------------------------------------------------------------------------------------------------------------
01023 
01024         void wxVtkBaseView_SceneManager :: drawSelectionROI()
01025         {
01026                 _drawingSelectionROI = true;
01027                 _workingGroup->clear();
01028                 _controlerSelectionROI->CreateNewManualContour();       
01029                 if (_lastInteraction!=NULL)
01030                 {
01031                         _lastInteraction->getControler()->SetEditable( false );
01032                         _lastInteraction->getControler()->SetActive( false ); 
01033                         _lastInteraction->getControler()->SetPosibleToMove( false );
01034                         _lastInteraction->getViewer()->Refresh();
01035                 }
01036                 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = _workingGroup->begin();
01037                 int i, workSize = _workingGroup->size();
01038                 for( i=0; i< workSize; i++ )
01039                 {
01040                         manualContourBaseControler * control = iter->second->getControler();
01041                         control->SetEditable( false );
01042                         control->SetActive( false );
01043                         control->SetPosibleToMove( false );
01044                         iter->second->getViewer()->Refresh();
01045 
01046                         iter++;
01047                 }
01048                 _lastInteraction = NULL;
01049                 _lastInteractionName = "";
01050 
01051                 _viewerSelectionROI->AddCompleteContourActor( true );   
01052                 _controlerSelectionROI->SetActive( true );
01053                 
01054                 _viewerSelectionROI->RefreshContour();
01055                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
01056         }
01057         //------------------------------------------------------------------------------------------------------------
01058         void wxVtkBaseView_SceneManager :: setSelection2DROIInternalOutlines( )
01059         {
01060                 _drawingSelectionROI = false;
01061                 _workingGroup->clear();
01062                 double minX,minY,maxX,maxY, minX_ROI,minY_ROI,maxX_ROI,maxY_ROI;
01063                 double minZ = -1.0;
01064                 double maxZ = -1.0;
01065                 std::map<std::string, ContourWrap_ViewControl *>::iterator iter = _sceneContours_ViewControl->begin();
01066                 int i, size = _sceneContours_ViewControl->size();
01067                 _viewerSelectionROI->GetMinMax( minX_ROI, minY_ROI, maxX_ROI, maxY_ROI );
01068                 manualViewBaseContour * viewer;
01069                 bool insideRoi = false;
01070                 for ( i=0; i<size; i++ )
01071                 {
01072                         viewer = iter->second->getViewer();
01073                         viewer->GetMinMax( minX, minY, minZ, maxX, maxY, maxZ );
01074                         insideRoi = minX >= minX_ROI && maxX <= maxX_ROI && minY_ROI && maxY <= maxY_ROI;
01075                         if ( insideRoi )
01076                         {
01077                                 viewer->SetSelected( true );
01078                                 viewer->UpdateColorActor();
01079                                 setControlActiveStateOf( iter->second, true );
01080                                 _workingGroup->insert(std::pair <std::string, ContourWrap_ViewControl *> ( iter->first, iter->second ));
01081                         }
01082                         iter++;
01083                 }   
01084                 _viewerSelectionROI->RemoveCompleteContourActor( );     
01085                 _controlerSelectionROI->SetActive( false );
01086         }
01087         //------------------------------------------------------------------------------------------------------------
01088         void wxVtkBaseView_SceneManager :: writeCoords( std::string method )
01089         {
01090                 FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
01091                 long int start = clock();
01092 #if(WIN32)
01093                 double sg = (double)(start) / (double)CLK_TCK;
01094 #else
01095                 double sg = (double)(start) / CLOCKS_PER_SEC;
01096 #endif
01097                 int tmpPx,tmpPy;
01098                 wxVTKRenderWindowInteractor *wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
01099                 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
01100                 fprintf(ff,"::%s (x,y) = (%i, %i) t(sg): %f\n  \n",method.c_str(), tmpPx, tmpPy, sg);
01101                 fclose(ff);
01102         }
01103 
01104 
01105         //------------------------------------------------------------------------------------------------------------
01106         void wxVtkBaseView_SceneManager::SaveThingName(FILE *ff, std::string nameThing)
01107         {
01108                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter = _contours_ViewControl->find(nameThing); 
01109                 manualViewBaseContour           * cViewer;
01110                 manualContourBaseControler      * cControler;
01111                 ContourWrap_ViewControl *conwraviwcont=iter->second;
01112 
01113                 cViewer         = conwraviwcont->getViewer();
01114                 cViewer->Save(ff);
01115 
01116                 cControler      = conwraviwcont->getControler();
01117 //              cControler->Save(ff);
01118 
01119 //              cModel          = cControler->GetManualContourModel();
01120 //              cModel->Save(ff);
01121         }
01122 
01123 
01124         //------------------------------------------------------------------------------------------------------------
01125         void wxVtkBaseView_SceneManager::GetPointsOfActualContour( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ )
01126         {
01127                 std::vector<std::string> currentSelection = this->getSelectedObjects();
01128                 if (currentSelection.size()>=1){
01129                         
01130                         manualContourBaseControler *cControler  = this->getControlerOf( currentSelection[0] );
01131                         manualBaseModel *cModel                         = cControler->GetManualContourModel();
01132                         int i,size = cModel->GetNumberOfPointsSpline();
01133                         double x,y,z;
01134                         for (i=0; i<size; i++) 
01135                         {
01136                                 cModel->GetSpline_i_Point(i, &x, &y, &z);
01137                                 vecX->push_back(x);
01138                                 vecY->push_back(y);
01139                                 vecZ->push_back(z);
01140                         }
01141                 }
01142         }
01143 
01144         //------------------------------------------------------------------------------------------------------------
01145         vtkImageData *wxVtkBaseView_SceneManager::GetImageData()
01146         {
01147                 wxVtk2DBaseView *wxvtk2dbaseview =(wxVtk2DBaseView*)_wxVtk_BaseView;
01148                 return wxvtk2dbaseview->GetVtkBaseData()->GetImageData();
01149         }
01150 
01151         //------------------------------------------------------------------------------------------------------------
01152         int wxVtkBaseView_SceneManager::GetImageDataSizeZ()
01153         {
01154                         int ext[6];
01155                         vtkImageData    *imagedata      = GetImageData();
01156                         imagedata->GetExtent(ext);
01157                         int sizeZ = ext[5]-ext[4]+1;
01158 
01159 //EED OJO   Machete
01160 //                      sizeZ = sizeZ-1;
01161 
01162                         return sizeZ;
01163         }
01164 
01165         //------------------------------------------------------------------------------------------------------------
01166         void wxVtkBaseView_SceneManager::GetImageDataRange( double *range )
01167         {
01168                 int ext[6];
01169                 vtkImageData    *imagedata      = GetImageData();
01170                 imagedata->GetExtent(ext);
01171                 int sizeX       = ext[1]-ext[0]+1;
01172                 int sizeY       = ext[3]-ext[2]+1;
01173                 int sizeZ       = GetImageDataSizeZ();
01174                 int sizeXYZ = sizeX*sizeY*sizeZ;
01175                 long int i;
01176                 range[0]=9999999;
01177                 range[1]=-9999999;
01178                 unsigned short *p = (unsigned short *)imagedata->GetScalarPointer(0,0,0);
01179                 for (i=0;i<sizeXYZ;i++)
01180                 {
01181                         if ( p[i]<range[0] ) range[0]=p[i];
01182                         if ( p[i]>range[1] ) range[1]=p[i]; 
01183                 }
01184         }
01185 
01186         //------------------------------------------------------------------------------------------------------------
01187         void wxVtkBaseView_SceneManager::SetWidthContour(double width)
01188         {
01189                 _widthOfContour         = width;
01190                 _widthOfControlPoint    = _widthOfContour*_widthOfContour/2;
01191                 manualViewBaseContour           *cViewer;
01192                 ContourWrap_ViewControl         *conwraviwcont;
01193                 std::map <std::string, ContourWrap_ViewControl *>::iterator iter; 
01194         
01195                 if (_contours_ViewControl!=NULL)
01196                 {
01197                         for (iter=_contours_ViewControl->begin(); iter!=_contours_ViewControl->end(); iter++ )
01198                         {
01199                                 conwraviwcont           = iter->second;
01200                                 cViewer                 = conwraviwcont->getViewer();
01201                                 cViewer->SetShowText( false );                                  // EED 28Mars2011
01202                                 cViewer->SetWidthLine( _widthOfContour );
01203                                 cViewer->SetRange( _widthOfControlPoint );
01204                         } // for
01205                 } // if 
01206         }
01207 
01208         bool wxVtkBaseView_SceneManager::isEditableCControler(std::string theKeyName){
01209                 
01210                 ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName);
01211                 if(ccon != NULL ){
01212                         manualContourBaseControler* cControler = ccon->getControler();
01213                         if(cControler != NULL && cControler->IsEditable() == false){
01214                                 return true;
01215                         }
01216                 }
01217                 return false;
01218         }
01219 
01220         void wxVtkBaseView_SceneManager::deleteCViewerCControler(std::string theKeyName){
01221                 
01222 
01223                 ContourWrap_ViewControl* ccon = getContourWrap_ViewControlOf(theKeyName);
01224 
01225                 manualViewBaseContour       * cViewer = ccon->getViewer();
01226                 manualContourBaseControler  * cControler = ccon->getControler();
01227 
01228                 removeFromScene(theKeyName);
01229                 removeWrap(theKeyName);
01230 
01231                 delete cViewer;         
01232                 delete cControler;
01233         }
01234         
01235         
01236                 

Generated on Wed Jun 27 23:28:32 2012 for creaContours_lib by  doxygen 1.5.7.1