]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/creaContoursFactory.cpp
6178a934b5e926b3f221451777f8e32d10af10ae
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / creaContoursFactory.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 "creaContoursFactory.h"
27
28 #include "manualContourControler.h"
29 #include "manualCircleControler.h"
30 #include "manualContourModelCircle.h"
31 #include "manualViewCircle.h"
32 #include "manualLineControler.h"
33 #include "manualContourModelLine.h"
34 #include "manualViewLine.h"
35 #include "manualRoiControler.h"
36 #include "manualViewRoi.h"
37 #include "manualContourModelRoi.h"
38 #include "manualViewBullEye.h"
39 #include "manualContourModelBullEye.h"
40 #include "manualViewPoints.h"
41 #include "manualRotationToolControler.h"
42 #include "manualContourModelRotationTool.h"
43 #include "manualViewRotationTool.h"
44 #include "manualContourModelPolygon.h"
45 #include "manualView3DContour.h"
46 #include "manualContour3DControler.h"
47 #include "manualContour3V3DControler.h"
48
49
50 creaContoursFactory::creaContoursFactory()
51 {
52
53 }
54
55
56 creaContoursFactory::~creaContoursFactory()
57 {
58
59 }
60
61 manualContourBaseControler* creaContoursFactory::getContourControler(int typeContour)
62 {
63         manualContourBaseControler *manContourControl = NULL;
64         //spline
65         if (typeContour==1)
66         {
67                 manContourControl       = new manualContourControler();
68         }
69
70         //rectangle
71         if (typeContour==2)
72         {
73                 manContourControl       = new manualRoiControler();
74         }
75
76         //circle
77         if (typeContour==3)
78         {
79                 manContourControl       = new manualCircleControler();
80         }
81
82         //bullEye
83         if (typeContour==4)
84         {
85                 manContourControl       = new manualRoiControler();
86         }
87
88         //line
89         if (typeContour==6)
90         {
91                 manContourControl       = new manualLineControler();
92         }
93
94         //points
95         if (typeContour==7)
96         {
97                 manContourControl       = new manualContourControler();
98         }
99
100         //rotationTool
101         if (typeContour==8)
102         {
103                 manContourControl       = new manualRotationToolControler();
104         }
105         
106         //polygon
107         if (typeContour==10)
108         {
109                 manContourControl       = new manualContourControler();
110         }
111
112
113         //JPReyes 13/04/2010
114         //Spline 3D
115         if(typeContour==12)
116         {
117                 printf("JPReyes %p creaContoursFactory::getContourControler pasando por el Contour 12 \n",this);
118                 manContourControl = new manualContour3V3DControler();
119         }
120
121         return manContourControl;
122
123 }
124
125 manualContourBaseControler* creaContoursFactory::getContourControler(std::string typeContour)
126 {
127         manualContourBaseControler *manContourControl = NULL;
128         if (typeContour.compare("spline")==0)
129         {
130                         manContourControl = getContourControler(1);
131         }
132
133         if (typeContour.compare("rectangle")==0)
134         {
135                 manContourControl = getContourControler(2);
136         }
137
138         if (typeContour.compare("circle")==0)
139         {
140                 manContourControl = getContourControler(3);
141         }
142
143         if (typeContour.compare("bullEye")==0)
144         {
145                 manContourControl = getContourControler(4);
146         }
147
148         if (typeContour.compare("line")==0)
149         {
150                 manContourControl = getContourControler(6);
151         }
152         
153         if (typeContour.compare("points")==0)
154         {
155                 manContourControl = getContourControler(7);
156         }
157
158         if (typeContour.compare("rotationTool")==0)
159         {
160                 manContourControl = getContourControler(8);
161         }
162         
163         if (typeContour.compare("polygon")==0)
164         {
165                 manContourControl       =  getContourControler(10);
166         }
167
168         //JPReyes 13/04/2010
169         //Spline 3D
170         if(typeContour.compare("spline3D")==0)
171         {
172                 manContourControl = getContourControler(12);
173         }
174         return manContourControl;
175 }
176
177 manualViewBaseContour* creaContoursFactory::getCountourView (int typeContour)
178 {
179         
180         manualViewBaseContour *manViewerContour = NULL;
181         //spline
182         if (typeContour==1)
183         {
184                 manViewerContour        = new manualViewContour();
185         }
186
187         //rectangle
188         if (typeContour==2)
189         {
190                 manViewerContour        = new manualViewRoi();
191         }
192
193         //circle
194         if (typeContour==3)
195         {
196                 manViewerContour        = new manualViewCircle();
197         }
198
199         //bullEye
200         if (typeContour==4)
201         {
202                 manViewerContour        = new manualViewBullEye();
203         }
204
205         //line
206         if (typeContour==6)
207         {
208                 manViewerContour        = new manualViewLine();
209         }
210         
211         //points
212         if (typeContour==7)
213         {
214                 manViewerContour        = new manualViewPoints();
215         }
216
217         //rotationTool
218         if (typeContour==8)
219         {
220                 manViewerContour        = new manualViewRotationTool();
221         }
222
223         //polygon
224         if (typeContour==10)
225         {
226                 manViewerContour        = new manualViewContour();
227         }
228
229         //JPReyes 13/04/2010
230         //Spline 3D
231         if(typeContour==12)
232         {
233                 manViewerContour        = new manualView3DContour();
234         }
235         return manViewerContour;
236 }
237
238 manualViewBaseContour* creaContoursFactory::getCountourView (std::string typeContour)
239 {
240
241         manualViewBaseContour *manViewerContour = NULL;
242
243         if (typeContour.compare("spline")==0)
244         {
245                 manViewerContour = getCountourView(1);
246         }
247
248         if (typeContour.compare("rectangle")==0)
249         {
250                 manViewerContour = getCountourView(2);
251         }
252
253         if (typeContour.compare("circle")==0)
254         {
255                 manViewerContour = getCountourView(3);
256         }
257
258         if (typeContour.compare("bullEye")==0)
259         {
260                 manViewerContour = getCountourView(4);
261         }
262
263         if (typeContour.compare("line")==0)
264         {
265                 manViewerContour = getCountourView(6);
266         }
267         
268         if (typeContour.compare("points")==0)
269         {
270                 manViewerContour = getCountourView(7);
271         }
272
273         if (typeContour.compare("rotationTool")==0)
274         {
275                 manViewerContour = getCountourView(8);
276         }
277
278         if (typeContour.compare("polygon")==0)
279         {
280                 manViewerContour = getCountourView(10);
281         }
282
283         //JPReyes 13/04/2010
284         //Spline 3D
285         if (typeContour.compare("spline3D")==0)
286         {
287                 manViewerContour = getCountourView(12);
288         }
289
290         return manViewerContour;
291
292 }
293
294 manualBaseModel* creaContoursFactory::getContourModel(int typeContour)
295 {
296         manualBaseModel *manModelContour=NULL;
297
298         // spline
299         if (typeContour==1)
300         {
301                 manModelContour = new manualContourModel();
302         }
303
304         // rectangle
305         if (typeContour==2)
306         {
307                 manModelContour = new manualContourModelRoi();
308         }
309
310         // circle
311         if (typeContour==3)
312         {
313                 manModelContour = new manualContourModelCircle();
314         }
315
316         //bullEye
317         if(typeContour==4)
318         {
319                 //Here we create a bullEye with 3 crowns and 5 sectors.
320                 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
321                         
322                 int iCrown,sizeCrowns,iSector,sizeSectors;
323                 double radioA,radioB,ang,angDelta,radioA2,radioB2 ;
324
325                 sizeCrowns = 3;
326                 radioA=33;
327                 radioB=0;
328                 angDelta= 72;
329                 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
330                 {
331                         sizeSectors = 5;
332                         radioB  = radioA;
333                         if (iCrown==sizeCrowns-1)
334                         {
335                                 radioA  = 0;
336                         } 
337                         else 
338                         {
339                                 radioA  = radioA+33;
340                         }
341                         radioA2=radioA/100.0;
342                         radioB2=radioB/100.0;
343                         ang=0;
344                         for ( iSector=0 ; iSector<sizeSectors  ; iSector++ )
345                         {               
346                                 ang     = ang+angDelta;
347                                 manModelContourBullEye->AddSector(radioA2,radioB2,ang,angDelta);
348                         } // for iSector
349                 }//for iCrown
350                 manModelContour         = manModelContourBullEye;
351         }
352
353         // line
354         if (typeContour==6)
355         {
356                 manModelContour = new manualContourModelLine();
357         }
358         
359         // points
360         if (typeContour==7)
361         {
362                 manModelContour = new manualBaseModel();
363         }
364
365         //rotationTool
366         if(typeContour==8)
367         {
368                 manModelContour = new manualContourModelRotationTool();
369         }
370
371         //polygon
372         if(typeContour==10)
373         {
374                 manModelContour = new manualContourModelPolygon();
375         }
376
377         
378         //JPReyes 13/04/2010
379         //Spline 3D
380         if(typeContour==12)
381         {
382                 manModelContour = new manualContourModel();
383         }
384
385         return manModelContour;
386 }
387
388
389 manualBaseModel* creaContoursFactory::getContourModel(std::string typeContour)
390 {
391         manualBaseModel *manModelContour=NULL;
392
393         if (typeContour.compare("spline")==0)
394         {
395                 manModelContour = getContourModel(1);
396         }
397
398         if (typeContour.compare("rectangle")==0)
399         {
400                 manModelContour = getContourModel(2);
401         }
402
403         if (typeContour.compare("circle")==0)
404         {
405                 manModelContour = getContourModel(3);
406         }
407
408         if (typeContour.compare("bullEye")==0)
409         {
410                 manModelContour = getContourModel(4);
411         
412         }
413
414         if (typeContour.compare("line")==0)
415         {
416                 manModelContour = getContourModel(6);
417         }
418         
419         if (typeContour.compare("points")==0)
420         {
421                 manModelContour = getContourModel(7);
422         }
423
424         if (typeContour.compare("rotationTool")==0)
425         {
426                 manModelContour = getContourModel(8);
427         }
428         
429         if (typeContour.compare("polygon")==0)
430         {
431                 manModelContour = getContourModel(10);
432         }
433
434         
435         //JPReyes 13/04/2010
436         //Spline 3D
437         if (typeContour.compare("spline3D")==0)
438         {
439                 manModelContour = getContourModel(12);
440         }
441
442         return manModelContour;
443 }