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