]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoints.cpp
#3093 creaMaracasVisu Feature New Normal - Contour Information in pixels and image...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewPoints.cpp
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "manualViewPoints.h"
27
28 // ----------------------------------------------------------------------------
29 manualViewPoints::manualViewPoints()
30 {
31 }
32
33 // ----------------------------------------------------------------------------
34 manualViewPoints::~manualViewPoints()
35 {
36         int i,size=_copyViewPoints.size();
37         for (i=0;i<size; i++)
38         {
39                 delete _copyViewPoints[i];
40         }
41         _copyViewPoints.clear();
42 }
43
44  
45 // ----------------------------------------------------------------------------
46 manualViewPoints * manualViewPoints :: Clone()
47 {
48         manualViewPoints * clone = new manualViewPoints();
49         CopyAttributesTo(clone);
50         return clone;
51 }
52
53 // ---------------------------------------------------------------------------
54 void manualViewPoints::CopyAttributesTo( manualViewPoints * cloneObject)
55 {
56         // Fathers object
57         manualViewBaseContour::CopyAttributesTo(cloneObject);
58 }
59
60 // ----------------------------------------------------------------------------
61 int manualViewPoints::GetType() // VIRTUAL
62 {
63         return 7;
64 }
65
66
67 // ----------------------------------------------------------------------------
68 bool manualViewPoints::ifTouchContour(int x,int y,int z) //VIRTUAL
69 {
70         bool result=false;
71         double xx=x;
72         double yy=y;
73         double zz=z;
74         TransfromCoordViewWorld(xx,yy,zz);
75
76 //EED 27 sep 2006
77         xx = xx * _spc[0];
78         yy = yy * _spc[1];
79         zz = zz * _spc[2];
80
81         int id = _manContModel->GetIdPoint(xx,yy,zz,_range,2);
82
83         if(id!=-1)
84         {
85                 result = true;
86         }
87         
88
89         return result;
90 }
91
92 // ----------------------------------------------------------------------------
93 void manualViewPoints::Refresh() // VIRTUAL
94 {
95         RefreshContour();
96         manualViewBaseContour::Refresh();
97 }
98
99 // ----------------------------------------------------------------------------
100 void manualViewPoints::RefreshContour()  // VIRTUAL
101 {
102         int np = GetNumberOfPoints();
103         int copynp= _copyViewPoints.size();
104
105         while(copynp!=np)
106         {
107
108                 if(copynp<np)
109                 {
110                         manualViewPoint *mvp = new manualViewPoint(_wxvtkbaseview);
111                         vtkActor *actor = mvp->CreateVtkPointActor();
112                         _wxvtkbaseview->GetRenderer()->AddActor( actor );       
113
114                         _copyViewPoints.push_back(mvp);
115                 }//if
116                 else if(copynp>np)
117                 {
118                         manualViewPoint *t = _copyViewPoints[0];
119                         _wxvtkbaseview->GetRenderer()->RemoveActor( t->GetVtkActor() );
120                         std::vector<manualViewPoint*>::iterator itNum = _copyViewPoints.begin();
121                         _copyViewPoints.erase(itNum);                   
122                         delete t;
123                 }// else if
124                 copynp= _copyViewPoints.size();
125
126         }// while
127
128         int i;
129         for(i=0;i<np;i++)
130         {
131                 double xx = _manContModel->GetManualPoint(i)->GetX();
132                 double yy = _manContModel->GetManualPoint(i)->GetY();
133                 
134                 
135 //EED 21 mars 2012  FLIP probleme  ..PLOP..
136 //              double zz = 900; // RaC REVISAR !!
137                 
138                 double zz = -900; // RaC REVISAR !!
139
140                 manualViewPoint *mv = _copyViewPoints[i];
141
142                 //Paints new Rectangular points bigger than the actual control points
143                 mv->SetPositionXY(xx, yy, _range*2, zz);
144
145                 vtkActor *_pointVtkActor = mv->GetVtkActor();
146
147                 _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
148                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
149                 {
150                         _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
151                 }
152                 if( _selected )
153                 {
154                         _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
155                 }
156
157                 //IF you want to customize the points which are going to be painted
158                 //mv->UpdateColorActor(_colorViewPoints_r,_colorViewPoints_g,_colorViewPoints_b);
159                 //mv->SetWidthLine(1.3);
160         }
161 }
162
163 // ----------------------------------------------------------------------------
164 void manualViewPoints::ConstructVTKObjects() // VIRTUAL
165 {
166         InitTextActor();
167 }
168
169 // ----------------------------------------------------------------------------
170 void manualViewPoints::AddSplineActor()  // VIRTUAL
171 {
172         int i,size=_copyViewPoints.size();
173         for (i=0;i<size;i++)
174         {
175                 _wxvtkbaseview->GetRenderer()->AddActor( _copyViewPoints[i]->GetVtkActor() );
176         }
177 }
178
179 // ----------------------------------------------------------------------------
180 void manualViewPoints::RemoveSplineActor()  // VIRTUAL  
181 {
182         int i,size=_copyViewPoints.size();
183         for (i=0;i<size;i++)
184         {
185                 _wxvtkbaseview->GetRenderer()->RemoveActor(_copyViewPoints[i]->GetVtkActor());
186
187         }
188 }
189
190
191