manualViewPoints.cpp
Go to the documentation of this file.00001 #include "manualViewPoints.h"
00002
00003
00004 manualViewPoints::manualViewPoints()
00005 {
00006 }
00007
00008
00009 manualViewPoints::~manualViewPoints()
00010 {
00011 int i,size=_copyViewPoints.size();
00012 for (i=0;i<size; i++){
00013 delete _copyViewPoints[i];
00014 }
00015 _copyViewPoints.clear();
00016 }
00017
00018
00019
00020 manualViewPoints * manualViewPoints :: Clone()
00021 {
00022 manualViewPoints * clone = new manualViewPoints();
00023 CopyAttributesTo(clone);
00024 return clone;
00025 }
00026
00027
00028 void manualViewPoints::CopyAttributesTo( manualViewPoints * cloneObject)
00029 {
00030
00031 manualViewBaseContour::CopyAttributesTo(cloneObject);
00032 }
00033
00034
00035 int manualViewPoints::GetType()
00036 {
00037 return 7;
00038 }
00039
00040
00041
00042 bool manualViewPoints::ifTouchContour(int x,int y,int z)
00043 {
00044 bool result=false;
00045 double xx=x;
00046 double yy=y;
00047 double zz=z;
00048 TransfromCoordViewWorld(xx,yy,zz);
00049
00050
00051 xx = xx * _spc[0];
00052 yy = yy * _spc[1];
00053 zz = zz * _spc[2];
00054
00055 int id = _manContModel->GetIdPoint(xx,yy,zz,_range,2);
00056
00057 if(id!=-1){
00058 result = true;
00059 }
00060
00061
00062 return result;
00063 }
00064
00065
00066 void manualViewPoints::Refresh()
00067 {
00068 RefreshContour();
00069 manualViewBaseContour::Refresh();
00070 }
00071
00072
00073 void manualViewPoints::RefreshContour()
00074 {
00075 int np = GetNumberOfPoints();
00076 int copynp= _copyViewPoints.size();
00077
00078 while(copynp!=np){
00079
00080 if(copynp<np)
00081 {
00082 manualViewPoint *mvp = new manualViewPoint(_wxvtkbaseview);
00083 vtkActor *actor = mvp->CreateVtkPointActor();
00084 _wxvtkbaseview->GetRenderer()->AddActor( actor );
00085
00086 _copyViewPoints.push_back(mvp);
00087 }
00088 else if(copynp>np)
00089 {
00090 manualViewPoint *t = _copyViewPoints[0];
00091 _wxvtkbaseview->GetRenderer()->RemoveActor( t->GetVtkActor() );
00092 std::vector<manualViewPoint*>::iterator itNum = _copyViewPoints.begin();
00093 _copyViewPoints.erase(itNum);
00094 delete t;
00095 }
00096 copynp= _copyViewPoints.size();
00097
00098 }
00099
00100 int i;
00101 for(i=0;i<np;i++)
00102 {
00103 double xx = _manContModel->GetManualPoint(i)->GetX();
00104 double yy = _manContModel->GetManualPoint(i)->GetY();
00105 double zz = 900;
00106
00107 manualViewPoint *mv = _copyViewPoints[i];
00108
00109
00110 mv->SetPositionXY(xx, yy, _range*2, zz);
00111
00112 vtkActor *_pointVtkActor = mv->GetVtkActor();
00113
00114 _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
00115 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
00116 {
00117 _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
00118 }
00119 if( _selected )
00120 {
00121 _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
00122 }
00123
00124
00125
00126
00127 }
00128 }
00129
00130
00131 void manualViewPoints::ConstructVTKObjects()
00132 {
00133 InitTextActor();
00134 }
00135
00136
00137 void manualViewPoints::AddSplineActor()
00138 {
00139 int i,size=_copyViewPoints.size();
00140 for (i=0;i<size;i++)
00141 {
00142 _wxvtkbaseview->GetRenderer()->AddActor( _copyViewPoints[i]->GetVtkActor() );
00143 }
00144 }
00145
00146
00147 void manualViewPoints::RemoveSplineActor()
00148 {
00149 int i,size=_copyViewPoints.size();
00150 for (i=0;i<size;i++)
00151 {
00152 _wxvtkbaseview->GetRenderer()->RemoveActor(_copyViewPoints[i]->GetVtkActor());
00153
00154 }
00155 }
00156
00157
00158