]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/creaContoursFactory.cpp
#2976 creaMaracasVisu Feature New Normal - ManualContourModel_Box
[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                 manContourControl = new manualContour3V3DControler();
118         }
119
120         return manContourControl;
121
122 }
123
124 manualContourBaseControler* creaContoursFactory::getContourControler(std::string typeContour)
125 {
126         manualContourBaseControler *manContourControl = NULL;
127         if (typeContour.compare("spline")==0)
128         {
129                         manContourControl = getContourControler(1);
130         }
131
132         if (typeContour.compare("rectangle")==0)
133         {
134                 manContourControl = getContourControler(2);
135         }
136
137         if (typeContour.compare("circle")==0)
138         {
139                 manContourControl = getContourControler(3);
140         }
141
142         if (typeContour.compare("bullEye")==0)
143         {
144                 manContourControl = getContourControler(4);
145         }
146
147         if (typeContour.compare("line")==0)
148         {
149                 manContourControl = getContourControler(6);
150         }
151         
152         if (typeContour.compare("points")==0)
153         {
154                 manContourControl = getContourControler(7);
155         }
156
157         if (typeContour.compare("rotationTool")==0)
158         {
159                 manContourControl = getContourControler(8);
160         }
161         
162         if (typeContour.compare("polygon")==0)
163         {
164                 manContourControl       =  getContourControler(10);
165         }
166
167         //JPReyes 13/04/2010
168         //Spline 3D
169         if(typeContour.compare("spline3D")==0)
170         {
171                 manContourControl = getContourControler(12);
172         }
173         return manContourControl;
174 }
175
176 manualViewBaseContour* creaContoursFactory::getCountourView (int typeContour)
177 {
178         
179         manualViewBaseContour *manViewerContour = NULL;
180         //spline
181         if (typeContour==1)
182         {
183                 manViewerContour        = new manualViewContour();
184         }
185
186         //rectangle
187         if (typeContour==2)
188         {
189                 manViewerContour        = new manualViewRoi();
190         }
191
192         //circle
193         if (typeContour==3)
194         {
195                 manViewerContour        = new manualViewCircle();
196         }
197
198         //bullEye
199         if (typeContour==4)
200         {
201                 manViewerContour        = new manualViewBullEye();
202         }
203
204         //line
205         if (typeContour==6)
206         {
207                 manViewerContour        = new manualViewLine();
208         }
209         
210         //points
211         if (typeContour==7)
212         {
213                 manViewerContour        = new manualViewPoints();
214         }
215
216         //rotationTool
217         if (typeContour==8)
218         {
219                 manViewerContour        = new manualViewRotationTool();
220         }
221
222         //polygon
223         if (typeContour==10)
224         {
225                 manViewerContour        = new manualViewContour();
226         }
227
228         //JPReyes 13/04/2010
229         //Spline 3D
230         if(typeContour==12)
231         {
232                 manViewerContour        = new manualView3DContour();
233         }
234         return manViewerContour;
235 }
236
237 manualViewBaseContour* creaContoursFactory::getCountourView (std::string typeContour)
238 {
239
240         manualViewBaseContour *manViewerContour = NULL;
241
242         if (typeContour.compare("spline")==0)
243         {
244                 manViewerContour = getCountourView(1);
245         }
246
247         if (typeContour.compare("rectangle")==0)
248         {
249                 manViewerContour = getCountourView(2);
250         }
251
252         if (typeContour.compare("circle")==0)
253         {
254                 manViewerContour = getCountourView(3);
255         }
256
257         if (typeContour.compare("bullEye")==0)
258         {
259                 manViewerContour = getCountourView(4);
260         }
261
262         if (typeContour.compare("line")==0)
263         {
264                 manViewerContour = getCountourView(6);
265         }
266         
267         if (typeContour.compare("points")==0)
268         {
269                 manViewerContour = getCountourView(7);
270         }
271
272         if (typeContour.compare("rotationTool")==0)
273         {
274                 manViewerContour = getCountourView(8);
275         }
276
277         if (typeContour.compare("polygon")==0)
278         {
279                 manViewerContour = getCountourView(10);
280         }
281
282         //JPReyes 13/04/2010
283         //Spline 3D
284         if (typeContour.compare("spline3D")==0)
285         {
286                 manViewerContour = getCountourView(12);
287         }
288
289         return manViewerContour;
290
291 }
292
293 manualBaseModel* creaContoursFactory::getContourModel(int typeContour)
294 {
295         manualBaseModel *manModelContour=NULL;
296
297         // spline
298         if (typeContour==1)
299         {
300                 manModelContour = new manualContourModel();
301         }
302
303         // rectangle
304         if (typeContour==2)
305         {
306                 manModelContour = new manualContourModelRoi();
307         }
308
309         // circle
310         if (typeContour==3)
311         {
312                 manModelContour = new manualContourModelCircle();
313         }
314
315         //bullEye
316         if(typeContour==4)
317         {
318                 //Here we create a bullEye with 3 crowns and 5 sectors.
319                 manualContourModelBullEye *manModelContourBullEye = new manualContourModelBullEye();
320                         
321                 int iCrown,sizeCrowns,iSector,sizeSectors;
322                 double radioA,radioB,ang,angDelta,radioA2,radioB2 ;
323
324                 sizeCrowns = 3;
325                 radioA=33;
326                 radioB=0;
327                 angDelta= 72;
328                 for ( iCrown=0 ; iCrown<sizeCrowns ; iCrown++ )
329                 {
330                         sizeSectors = 5;
331                         radioB  = radioA;
332                         if (iCrown==sizeCrowns-1)
333                         {
334                                 radioA  = 0;
335                         } 
336                         else 
337                         {
338                                 radioA  = radioA+33;
339                         }
340                         radioA2=radioA/100.0;
341                         radioB2=radioB/100.0;
342                         ang=0;
343                         for ( iSector=0 ; iSector<sizeSectors  ; iSector++ )
344                         {               
345                                 ang     = ang+angDelta;
346                                 manModelContourBullEye->AddSector(radioA2,radioB2,ang,angDelta);
347                         } // for iSector
348                 }//for iCrown
349                 manModelContour         = manModelContourBullEye;
350         }
351
352         // line
353         if (typeContour==6)
354         {
355                 manModelContour = new manualContourModelLine();
356         }
357         
358         // points
359         if (typeContour==7)
360         {
361                 manModelContour = new manualBaseModel();
362         }
363
364         //rotationTool
365         if(typeContour==8)
366         {
367                 manModelContour = new manualContourModelRotationTool();
368         }
369
370         //polygon
371         if(typeContour==10)
372         {
373                 manModelContour = new manualContourModelPolygon();
374         }
375
376         
377         //JPReyes 13/04/2010
378         //Spline 3D
379         if(typeContour==12)
380         {
381                 manModelContour = new manualContourModel();
382         }
383
384         return manModelContour;
385 }
386
387
388 manualBaseModel* creaContoursFactory::getContourModel(std::string typeContour)
389 {
390         manualBaseModel *manModelContour=NULL;
391
392         if (typeContour.compare("spline")==0)
393         {
394                 manModelContour = getContourModel(1);
395         }
396
397         if (typeContour.compare("rectangle")==0)
398         {
399                 manModelContour = getContourModel(2);
400         }
401
402         if (typeContour.compare("circle")==0)
403         {
404                 manModelContour = getContourModel(3);
405         }
406
407         if (typeContour.compare("bullEye")==0)
408         {
409                 manModelContour = getContourModel(4);
410         
411         }
412
413         if (typeContour.compare("line")==0)
414         {
415                 manModelContour = getContourModel(6);
416         }
417         
418         if (typeContour.compare("points")==0)
419         {
420                 manModelContour = getContourModel(7);
421         }
422
423         if (typeContour.compare("rotationTool")==0)
424         {
425                 manModelContour = getContourModel(8);
426         }
427         
428         if (typeContour.compare("polygon")==0)
429         {
430                 manModelContour = getContourModel(10);
431         }
432
433         
434         //JPReyes 13/04/2010
435         //Spline 3D
436         if (typeContour.compare("spline3D")==0)
437         {
438                 manModelContour = getContourModel(12);
439         }
440
441         return manModelContour;
442 }