]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourModelBullEye.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 "manualContourModelBullEye.h"
27
28
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
32
33 manualContourModelBullEye::manualContourModelBullEye()
34 : manualContourModel()
35 {
36         _numberPointsSlineBySector=101;   // impaire
37 }
38
39 manualContourModelBullEye::~manualContourModelBullEye()
40 {
41 }
42
43
44 // ----------------------------------------------------------------------------
45 manualContourModelBullEye * manualContourModelBullEye :: Clone()  // virtual
46 {
47         manualContourModelBullEye * clone = new manualContourModelBullEye();
48         CopyAttributesTo(clone);
49         return clone;
50 }
51
52 // ---------------------------------------------------------------------------
53
54 void manualContourModelBullEye::CopyAttributesTo( manualContourModelBullEye * cloneObject)
55 {
56         // Fathers object
57         manualContourModel::CopyAttributesTo(cloneObject);
58 }
59
60 //----------------------------------------------------------------
61 int manualContourModelBullEye::GetTypeModel() //virtual
62 {
63         return 4;
64 }
65
66 //----------------------------------------------------------------
67 int     manualContourModelBullEye::GetNumberOfPointsSplineSectorBulleEje()
68 {
69         return _numberPointsSlineBySector;
70 }
71
72 //----------------------------------------------------------------
73 void manualContourModelBullEye::SetNumberOfPointsSplineSectorBulleEje(int numpoints)
74 {
75         this->_numberPointsSlineBySector = numpoints;
76 }
77
78 //----------------------------------------------------------------
79 void manualContourModelBullEye::AddSector(      double radioA,
80                                                 double radioB,
81                                                 double ang,
82                                                 double angDelta)
83 {
84         manualContourModelBullEyeSector *modelSector = new manualContourModelBullEyeSector();
85         modelSector->SetSector(radioA,radioB,ang,angDelta);
86         modelSector->SetNumberOfPointsSpline( this->GetNumberOfPointsSplineSectorBulleEje() );
87         _lstModelBullEyeSector.push_back(modelSector);
88 }
89
90 //----------------------------------------------------------------
91 manualContourModelBullEyeSector * manualContourModelBullEye::GetModelSector(int id)
92 {
93         return _lstModelBullEyeSector[id];
94 }
95
96 //----------------------------------------------------------------
97 void manualContourModelBullEye::GetSector(int id,
98                                                 double *radioA,
99                                                 double *radioB,
100                                                 double *ang,
101                                                 double *angDelta)
102 {
103         _lstModelBullEyeSector[id]->GetSector(radioA,radioB,ang,angDelta);
104 }
105
106 void manualContourModelBullEye::UpdateSpline() // virtual
107 {
108         manualContourModel::UpdateSpline();
109
110         if (this->GetSizeLstPoints()>2){
111                 double cx,cy;
112                 double ww,hh;
113                 manualPoint *mpA = GetManualPoint(0);
114                 manualPoint *mpB = GetManualPoint(2);
115                 cx = (mpA->GetX() + mpB->GetX()) / 2.0;
116                 cy = (mpA->GetY() + mpB->GetY()) / 2.0;
117                 ww = fabs( mpA->GetX() - mpB->GetX() )/2.0;
118                 hh = fabs( mpA->GetY() - mpB->GetY() )/2.0;
119                 int i,size = _lstModelBullEyeSector.size();
120                 for (i=0;i<size;i++)
121                 {
122                         _lstModelBullEyeSector[i]->SetCenter(cx,cy);
123                         _lstModelBullEyeSector[i]->SetSize(ww,hh);
124                 } // for
125         }
126 }
127
128
129 //----------------------------------------------------------------
130 void manualContourModelBullEye::ResetSectors()
131 {
132         int i,size=_lstModelBullEyeSector.size();
133         for (i=0;i<size;i++)
134         {
135                 delete _lstModelBullEyeSector[i];
136         }
137         _lstModelBullEyeSector.clear();
138 }
139
140 //----------------------------------------------------------------
141 int manualContourModelBullEye::GetSizeOfSectorLst()
142 {
143         return _lstModelBullEyeSector.size();
144 }
145
146 //----------------------------------------------------------------
147 void manualContourModelBullEye::Save(FILE *ff) // virtual
148 {
149         manualContourModel::Save(ff);
150         int i,size = GetSizeOfSectorLst();
151         fprintf(ff,"numberOfSections %d \n",size);
152         for ( i=0 ; i<size ; i++ )
153         {
154                 _lstModelBullEyeSector[i]->Save(ff);
155         }
156 }
157
158 //----------------------------------------------------------------
159 void manualContourModelBullEye::Open(FILE *ff) // virtual
160 {
161         manualContourModel::Open(ff);
162
163         ResetSectors();
164
165         char tmp[255];
166         int i;
167         int numberOfSections;
168 //      double radioA,radioB,ang,deltaAng;
169
170         fscanf(ff,"%s",tmp); // NumberOfSections
171         fscanf(ff,"%s",tmp); // ##
172         numberOfSections = atoi(tmp);
173         for (i=0;i<numberOfSections;i++)
174         {
175                 AddSector(0,1,90,0);
176                 _lstModelBullEyeSector[i]->Open(ff);
177         }
178
179 }
180
181 // ----------------------------------------------------------------------------
182 std::vector<manualBaseModel*> manualContourModelBullEye::ExploseModel(  )
183 {
184 //EED004
185         std::vector<manualBaseModel*> lstTmp;
186         int i,iSize=_lstModelBullEyeSector.size();
187         for (i=0;i<iSize;i++)
188         {
189                 lstTmp.push_back( _lstModelBullEyeSector[i] );
190         }
191         return lstTmp;
192 }
193