manualContourControler.cpp

Go to the documentation of this file.
00001 #include "manualContourControler.h"
00002 
00003 // ----------------------------------------------------------------------------
00004 // ----------------------------------------------------------------------------
00005 // ----------------------------------------------------------------------------
00006 
00007 // _state = 0  // ..nothing..
00008 // _state = 1  // move with add point
00009 // _state = 5  // move
00010 // _state = 6  // move with insert point
00011 // _state = 7  // move with non selection
00012 
00013 manualContourControler::manualContourControler()
00014 {
00015         _easyCreation = true;
00016 
00017 }
00018 // ----------------------------------------------------------------------------
00019 manualContourControler::~manualContourControler()
00020 {
00021 }
00022 // ----------------------------------------------------------------------------
00023 manualContourControler * manualContourControler :: Clone()  // virtual
00024 {
00025         manualContourControler * clone = new manualContourControler();
00026         CopyAttributesTo(clone);
00027         return clone;
00028 }
00029 // ---------------------------------------------------------------------------
00030 void manualContourControler::CopyAttributesTo( manualContourControler * cloneObject)
00031 {
00032         // Fathers object
00033         manualContourBaseControler::CopyAttributesTo(cloneObject);
00034         cloneObject->SetEasyCreation( this->GetEasyCreation() );
00035 }
00036 
00037 // ----------------------------------------------------------------------------
00038 void manualContourControler::Configure() //virtual
00039 {
00040  //     this->_manContModel->SetNumberOfPointsSpline(100);
00041 }
00042 
00043 // ----------------------------------------------------------------------------
00044 void manualContourControler::MouseClickLeft(int x, int y){
00045 
00046         bool ok = false;
00047         int z   = GetZ();
00048         int size= GetManualViewBaseContour()->GetNumberOfPoints();
00049 
00050         // Insert a Control Point with shift+ClickLeft
00051         vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
00052 
00053         if( IsEditable() )
00054         {
00055                 if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
00056                 {
00057                         ok=true;
00058                         InsertPoint(x,y,z);
00059                         size++;
00060                 }
00061                 // Start to Insert Control Points with ClickLeft (Empty contour)
00062                 if ((GetState()==0) && (size==0) && (_easyCreation==true) )
00063                 {
00064                         ok=true;
00065                         SetState(1);
00066                         GetManualContourModel()->SetCloseContour(false);
00067                         AddPoint(x,y,z);
00068                 }
00069                 // Continuie to Insert Control Points with ClickLeft (After being empty the contour)
00070                 if ((GetState()==1) && (_easyCreation==true) )
00071                 {
00072                         ok=true;
00073                         AddPoint(x,y,z);
00074                         _bakIdPoint=GetNumberOfPointsManualContour() - 1;
00075                 }
00076                 // Insert Control Points IF Contour si Selected
00077                 if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
00078                 {
00079                         ok=true;
00080                         InsertPoint(x,y,z);
00081                         _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00082                         SetState(6);
00083                 }
00084                 // Chose id of Control Point to be move
00085                 if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
00086                 {
00087                         ok=true;
00088                         _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00089                         SetState(5);
00090                 }
00091                 // If nothing selected _state=7
00092                 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
00093                 {
00094                         //ok=true;
00095                         _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00096                         SetState(7);
00097                 }
00098         }else{
00099                 SetPosibleToMove( true );
00100                 GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
00101         } // IsEditable
00102         
00103         if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
00104         {
00105                 SetMoving( true );
00106                 ok=true;
00107                 GetManualViewBaseContour()->InitMove(x,y,z);
00108                 SetState(6);
00109         }
00110         if (ok==true)
00111         {
00112                 GetManualViewBaseContour()->Refresh();
00113         }
00114 }
00115 // ----------------------------------------------------------------------------
00116 void manualContourControler::MouseMove(int x, int y) // virtual
00117 {
00118         int z=GetZ();
00119         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
00120         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
00121         if (GetState()==1){     SetPoint( _bakIdPoint , x , y ,z); }
00122         if (GetState()==5){     SetPoint( _bakIdPoint , x , y ,z); }
00123         if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
00124         {
00125                 GetManualViewBaseContour()->MoveContour(x,y,z);
00126         }
00127         if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
00128                 GetManualViewBaseContour()->Refresh();
00129                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00130         }
00131         if (!IsEditable())
00132         {
00133                 GetManualViewBaseContour()->RemoveControlPoints();
00134 //              GetManualViewBaseContour()->RemoveTextActor();
00135                 GetManualViewBaseContour()->Refresh();
00136                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00137         }
00138 
00139 }
00140 
00141 // ----------------------------------------------------------------------------
00142 void manualContourControler::MouseDLeft( int x, int y)//virtual
00143 {
00144         manualContourBaseControler::MouseDLeft( x, y);
00145         if ( IsEditable() )
00146         {
00147                 
00148                 GetManualViewBaseContour()->AddControlPoints();
00149                 GetManualViewBaseContour()->AddTextActor();
00150                 GetManualViewBaseContour()->Refresh();
00151                 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
00152         }
00153 }
00154 // ----------------------------------------------------------------------------
00155 void manualContourControler::SetEasyCreation(bool easyCreation)
00156 {
00157         _easyCreation=easyCreation;
00158 }
00159 // ----------------------------------------------------------------------------
00160 bool manualContourControler::GetEasyCreation()
00161 {
00162         return _easyCreation;
00163 }
00164 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1