]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoints.cpp
8801adad45937f506e169f3cbfd45ae93a7aa984
[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                 delete _copyViewPoints[i];
39         }
40         _copyViewPoints.clear();
41 }
42
43  
44 // ----------------------------------------------------------------------------
45 manualViewPoints * manualViewPoints :: Clone()
46 {
47         manualViewPoints * clone = new manualViewPoints();
48         CopyAttributesTo(clone);
49         return clone;
50 }
51
52 // ---------------------------------------------------------------------------
53 void manualViewPoints::CopyAttributesTo( manualViewPoints * cloneObject)
54 {
55         // Fathers object
56         manualViewBaseContour::CopyAttributesTo(cloneObject);
57 }
58
59 // ----------------------------------------------------------------------------
60 int manualViewPoints::GetType() // VIRTUAL
61 {
62         return 7;
63 }
64
65
66 // ----------------------------------------------------------------------------
67 bool manualViewPoints::ifTouchContour(int x,int y,int z) //VIRTUAL
68 {
69         bool result=false;
70         double xx=x;
71         double yy=y;
72         double zz=z;
73         TransfromCoordViewWorld(xx,yy,zz);
74
75 //EED 27 sep 2006
76         xx = xx * _spc[0];
77         yy = yy * _spc[1];
78         zz = zz * _spc[2];
79
80         int id = _manContModel->GetIdPoint(xx,yy,zz,_range,2);
81
82         if(id!=-1){
83                 result = true;
84         }
85         
86
87         return result;
88 }
89
90 // ----------------------------------------------------------------------------
91 void manualViewPoints::Refresh() // VIRTUAL
92 {
93         RefreshContour();
94         manualViewBaseContour::Refresh();
95 }
96
97 // ----------------------------------------------------------------------------
98 void manualViewPoints::RefreshContour()  // VIRTUAL
99 {
100         int np = GetNumberOfPoints();
101         int copynp= _copyViewPoints.size();
102
103         while(copynp!=np){
104
105                 if(copynp<np)
106                 {
107                         manualViewPoint *mvp = new manualViewPoint(_wxvtkbaseview);
108                         vtkActor *actor = mvp->CreateVtkPointActor();
109                         _wxvtkbaseview->GetRenderer()->AddActor( actor );       
110
111                         _copyViewPoints.push_back(mvp);
112                 }//if
113                 else if(copynp>np)
114                 {
115                         manualViewPoint *t = _copyViewPoints[0];
116                         _wxvtkbaseview->GetRenderer()->RemoveActor( t->GetVtkActor() );
117                         std::vector<manualViewPoint*>::iterator itNum = _copyViewPoints.begin();
118                         _copyViewPoints.erase(itNum);                   
119                         delete t;
120                 }// else if
121                 copynp= _copyViewPoints.size();
122
123         }// while
124
125         int i;
126         for(i=0;i<np;i++)
127         {
128                 double xx = _manContModel->GetManualPoint(i)->GetX();
129                 double yy = _manContModel->GetManualPoint(i)->GetY();
130                 
131                 
132 //EED 21 mars 2012  FLIP probleme  ..PLOP..
133 //              double zz = 900; // RaC REVISAR !!
134                 
135                 double zz = -900; // RaC REVISAR !!
136
137                 manualViewPoint *mv = _copyViewPoints[i];
138
139                 //Paints new Rectangular points bigger than the actual control points
140                 mv->SetPositionXY(xx, yy, _range*2, zz);
141
142                 vtkActor *_pointVtkActor = mv->GetVtkActor();
143
144                 _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
145                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
146                 {
147                         _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
148                 }
149                 if( _selected )
150                 {
151                         _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
152                 }
153
154                 //IF you want to customize the points which are going to be painted
155                 //mv->UpdateColorActor(_colorViewPoints_r,_colorViewPoints_g,_colorViewPoints_b);
156                 //mv->SetWidthLine(1.3);
157         }
158 }
159
160 // ----------------------------------------------------------------------------
161 void manualViewPoints::ConstructVTKObjects() // VIRTUAL
162 {
163         InitTextActor();
164 }
165
166 // ----------------------------------------------------------------------------
167 void manualViewPoints::AddSplineActor()  // VIRTUAL
168 {
169         int i,size=_copyViewPoints.size();
170         for (i=0;i<size;i++)
171         {
172                 _wxvtkbaseview->GetRenderer()->AddActor( _copyViewPoints[i]->GetVtkActor() );
173         }
174 }
175
176 // ----------------------------------------------------------------------------
177 void manualViewPoints::RemoveSplineActor()  // VIRTUAL  
178 {
179         int i,size=_copyViewPoints.size();
180         for (i=0;i<size;i++)
181         {
182                 _wxvtkbaseview->GetRenderer()->RemoveActor(_copyViewPoints[i]->GetVtkActor());
183
184         }
185 }
186
187
188