]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoints.cpp
192da1864e071604280d66c90857c99846df82c3
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewPoints.cpp
1 #include "manualViewPoints.h"
2
3 // ----------------------------------------------------------------------------
4 manualViewPoints::manualViewPoints()
5 {
6 }
7
8 // ----------------------------------------------------------------------------
9 manualViewPoints::~manualViewPoints()
10 {
11         int i,size=_copyViewPoints.size();
12         for (i=0;i<size; i++){
13                 delete _copyViewPoints[i];
14         }
15         _copyViewPoints.clear();
16 }
17
18
19 // ----------------------------------------------------------------------------
20 manualViewPoints * manualViewPoints :: Clone()
21 {
22         manualViewPoints * clone = new manualViewPoints();
23         CopyAttributesTo(clone);
24         return clone;
25 }
26
27 // ---------------------------------------------------------------------------
28 void manualViewPoints::CopyAttributesTo( manualViewPoints * cloneObject)
29 {
30         // Fathers object
31         manualViewBaseContour::CopyAttributesTo(cloneObject);
32 }
33
34 // ----------------------------------------------------------------------------
35 int manualViewPoints::GetType() // VIRTUAL
36 {
37         return 7;
38 }
39
40
41 // ----------------------------------------------------------------------------
42 bool manualViewPoints::ifTouchContour(int x,int y,int z) //VIRTUAL
43 {
44         bool result=false;
45         double xx=x;
46         double yy=y;
47         double zz=z;
48         TransfromCoordViewWorld(xx,yy,zz);
49
50 //EED 27 sep 2006
51         xx = xx * _spc[0];
52         yy = yy * _spc[1];
53         zz = zz * _spc[2];
54
55         int id = _manContModel->GetIdPoint(xx,yy,zz,_range,2);
56
57         if(id!=-1){
58                 result = true;
59         }
60         
61
62         return result;
63 }
64
65 // ----------------------------------------------------------------------------
66 void manualViewPoints::Refresh() // VIRTUAL
67 {
68         RefreshContour();
69         manualViewBaseContour::Refresh();
70 }
71
72 // ----------------------------------------------------------------------------
73 void manualViewPoints::RefreshContour()  // VIRTUAL
74 {
75         int np = GetNumberOfPoints();
76         int copynp= _copyViewPoints.size();
77
78         while(copynp!=np){
79
80                 if(copynp<np)
81                 {
82                         manualViewPoint *mvp = new manualViewPoint(_wxvtkbaseview);
83                         vtkActor *actor = mvp->CreateVtkPointActor();
84                         _wxvtkbaseview->GetRenderer()->AddActor( actor );       
85
86                         _copyViewPoints.push_back(mvp);
87                 }//if
88                 else if(copynp>np)
89                 {
90                         manualViewPoint *t = _copyViewPoints[0];
91                         _wxvtkbaseview->GetRenderer()->RemoveActor( t->GetVtkActor() );
92                         std::vector<manualViewPoint*>::iterator itNum = _copyViewPoints.begin();
93                         _copyViewPoints.erase(itNum);                   
94                         delete t;
95                 }// else if
96                 copynp= _copyViewPoints.size();
97
98         }// while
99
100         int i;
101         for(i=0;i<np;i++)
102         {
103                 double xx = _manContModel->GetManualPoint(i)->GetX();
104                 double yy = _manContModel->GetManualPoint(i)->GetY();
105                 double zz = 900; // RaC REVISAR !!
106
107                 manualViewPoint *mv = _copyViewPoints[i];
108
109                 //Paints new Rectangular points bigger than the actual control points
110                 mv->SetPositionXY(xx, yy, _range*2, zz);
111
112                 vtkActor *_pointVtkActor = mv->GetVtkActor();
113
114                 _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
115                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
116                 {
117                         _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
118                 }
119                 if( _selected )
120                 {
121                         _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
122                 }
123
124                 //IF you want to customize the points which are going to be painted
125                 //mv->UpdateColorActor(_colorViewPoints_r,_colorViewPoints_g,_colorViewPoints_b);
126                 //mv->SetWidthLine(1.3);
127         }
128 }
129
130 // ----------------------------------------------------------------------------
131 void manualViewPoints::ConstructVTKObjects() // VIRTUAL
132 {
133         InitTextActor();
134 }
135
136 // ----------------------------------------------------------------------------
137 void manualViewPoints::AddSplineActor()  // VIRTUAL
138 {
139         int i,size=_copyViewPoints.size();
140         for (i=0;i<size;i++)
141         {
142                 _wxvtkbaseview->GetRenderer()->AddActor( _copyViewPoints[i]->GetVtkActor() );
143         }
144 }
145
146 // ----------------------------------------------------------------------------
147 void manualViewPoints::RemoveSplineActor()  // VIRTUAL  
148 {
149         int i,size=_copyViewPoints.size();
150         for (i=0;i<size;i++)
151         {
152                 _wxvtkbaseview->GetRenderer()->RemoveActor(_copyViewPoints[i]->GetVtkActor());
153
154         }
155 }
156
157
158