]> Creatis software - creaContours.git/blob - lib/kernel_ManagerContour_NDimensions/OutlineGroup.cxx
ed66019d236220dfc4de6b69a50cfbf5963b23a0
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / OutlineGroup.cxx
1
2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "OutlineGroup.h"
6
7 //----------------------------------------------------------------------------------------------------------------
8 // Class implementation
9 //----------------------------------------------------------------------------------------------------------------
10 /** @file OutlineGroup.cxx */
11
12 //------------------------------------------------------------------------------------------------------------
13 // Constructors & Destructors
14 //------------------------------------------------------------------------------------------------------------
15
16         /*
17         * Constructs an outline group with the given name
18         * @param theName Is the name for the group
19         * @param theGroupType Is the type for the group corresponding to one of the constants of this class
20         */ 
21         OutlineGroup :: OutlineGroup(std::string theName, int theGroupType)
22         {
23                 name = theName;         
24                 groupType = theGroupType;
25                 totalCount = 0;
26                 
27                 if ( groupType == PROPAGATION || groupType == PLANE_SECTION  )
28                 {
29                         visibleGroup = true;                    
30                         selectedGroup = false;
31                         editingGroup = false;
32                         staticGroup = false;
33                         acceptsRepetedOutlines = false;
34                 }
35                 else if ( groupType ==  STRIP )
36                 {       
37                         visibleGroup = true;                    
38                         selectedGroup = false;
39                         editingGroup = false;
40                         staticGroup = false;
41                         acceptsRepetedOutlines = true;
42                 }
43                 else if ( groupType == OVERLAPED )
44                 {                               
45                         visibleGroup = true;                    
46                         selectedGroup = false;
47                         editingGroup = false;
48                         staticGroup = true;
49                         acceptsRepetedOutlines = false;
50                 }
51                 else if ( groupType ==  MANUAL_GROUP )
52                 {                               
53                         visibleGroup = true;
54                         selectedGroup = true;
55                         editingGroup = true;
56                         staticGroup = false;
57                         acceptsRepetedOutlines = true;
58                 }                               
59         }
60         
61         /*
62         * Destroyes the outline and its dependencies
63         */
64         OutlineGroup :: ~ OutlineGroup()
65         {
66                 outlines_keyNames.clear();
67         }
68
69 //------------------------------------------------------------------------------------------------------------
70 // Methods
71 //------------------------------------------------------------------------------------------------------------
72
73
74         /*
75         * Indicates if a given name of an outline is member of the group or not
76         * @param aKeyName Is the name of an outline to search for
77         */
78         bool OutlineGroup :: isMemberOfGroup(std::string aKeyName)
79         {
80                 for (int a=0; a < outlines_keyNames.size(); a++)
81                 {
82                         if ( outlines_keyNames[a].compare(aKeyName) == 0 )
83                                 return true;
84                 }               
85                 return false;
86         }
87
88         /*
89         * Removes an outline with the given name from the group 
90         * @param theNameToRemove Is the name to remove from member name list
91         */
92         void OutlineGroup :: removeOutline(std::string theNameToRemove, bool allOcurrencies)
93         {
94                 std::vector <std::string>::iterator iter;               
95                 
96                 bool ifContinue = true;
97                 bool deleted = false;
98                 for ( iter = outlines_keyNames.begin( ); iter != outlines_keyNames.end( ) && ifContinue; iter++ )
99                 {
100                         if ( (*iter).compare(theNameToRemove)==0 )
101                         {
102                                 outlines_keyNames.erase(iter);
103                                 deleted = true;
104                         }
105                         ifContinue = allOcurrencies ? acceptsRepetedOutlines : deleted; 
106                 }
107                 //delete iter; Se incluye esta linea o no ????????????????????
108         }
109         
110         /*
111         * Adds an outline with the given name to the group members list
112         * @param theNameNw Is the name to add to the group
113         */
114         void OutlineGroup :: addOutline(std::string theNameNw)
115         {
116                 bool ifInclude = acceptsRepetedOutlines ? true : !isMemberOfGroup(theNameNw);
117                 if ( ifInclude )
118                         outlines_keyNames.push_back(theNameNw);
119         /*
120                 if( groupType == PROPAGATION )
121                         addOutline_PropagationType( theNameNw );
122                 else if ( groupType == PLANE_SECTION )
123                         addOutline_PlaneSectionType( theNameNw );
124                 else if ( groupType == OVERLAPED )
125                         addOutline_OverlapedType( theNameNw );
126                 else if ( groupType == STRIP )
127                         addOutline_StripType( theNameNw );
128                 else if ( groupType == MANUAL_GROUP )
129                         addOutline_ManualType( theNameNw );
130         */
131         }       
132
133         /*
134         * Gets the name of the group
135         * @return name Is the name of the group
136         */ 
137         std::string OutlineGroup :: getName()
138         { 
139                 return name;
140         }
141
142         /*
143         * Sets the name of the group as the given one 
144         * @param name Is the new name of the group
145         */ 
146         void OutlineGroup :: setName(std::string theNwName)
147         { 
148                 name = theNwName;
149         }
150
151         /*
152         * Gets the state of visiblility (true:visible) or not of the group
153         * @return visibleGroup Is the corresponding state
154         */ 
155         bool OutlineGroup ::  getIfVisibleGroup()
156         { 
157                 return visibleGroup;
158         }
159
160         /*
161         * Sets state of visible (true) or not of the with the given one 
162         * @param theNwVisiblity Is the corresponding state
163         */ 
164         void OutlineGroup :: setIfVisibleGroup(bool theNwVisiblity)
165         { 
166                 visibleGroup = theNwVisiblity;
167         }
168
169         /*
170         * Gets the state of static (true:static) or not of the group
171         * @return staticGroup Is the corresponding state
172         */ 
173         bool OutlineGroup ::  getIfStaticGroup()
174         { 
175                 return staticGroup;
176         }
177
178         /*
179         * Sets state of static (true) or not of the with the given one 
180         * @param theNwStatic Is the corresponding state
181         */ 
182         void OutlineGroup :: setIfStaticGroup(bool theNwStatic)
183         { 
184                 staticGroup = theNwStatic;
185         }
186
187         /*
188         * Gets the state of selection (true:selected) or not of the group
189         * @return selecetedGroup Is the corresponding state
190         */ 
191         bool OutlineGroup ::  getIfSelectedGroup()
192         { 
193                 return selectedGroup;
194         }
195
196         /*
197         * Sets state of visible (true) or not of the with the given one 
198         * @param theNwSelected Is the corresponding state
199         */ 
200         void OutlineGroup :: setIfSelectedGroup(bool theNwSelected)
201         { 
202                 selectedGroup = theNwSelected;
203         }
204
205         /*
206         * Gets the state of edition (true:editing) or not of the group
207         * @return editingGroup Is the corresponding state
208         */ 
209         bool OutlineGroup ::  getIfEditingGroup()
210         { 
211                 return editingGroup;
212         }
213
214         /*
215         * Sets state of editing (true) or not of the with the given one 
216         * @param theNwEditing Is the corresponding state
217         */ 
218         void OutlineGroup :: setIfEditingGroup(bool theNwEditing)
219         { 
220                 editingGroup = theNwEditing;
221         }
222
223         /*
224         * Gets the total count of outlines in the group
225         * @return totalCount Is the corresponding number of elements
226         */ 
227         int  OutlineGroup :: getGroupType()
228         {
229                 return groupType;
230         }
231
232         /*
233         * Sets the group type 
234         * @param theType Is the corresponding new type to assign 
235         */ 
236         void OutlineGroup :: setGroupType(int  theType)
237         {
238                 groupType = theType;
239         }
240
241         /*
242         * Sets the total count of outlines in the group
243         * @param theNwVisiblity Is the corresponding state
244         */ 
245         void OutlineGroup :: setIfEditingGroup(int  theTotal)
246         {
247                 totalCount = theTotal;
248         }
249
250         /*
251         * Gets the group type 
252         * @return type Is the corresponding number of elements
253         */ 
254         int  OutlineGroup :: getOutlinesCount()
255         {
256                 return totalCount;
257         }
258
259         /*
260         * Adds an outline to the group as propagation type
261         * @param theOutlineKeyName Is the name used as identifier of the outline        
262         */
263         void OutlineGroup :: addOutline_PropagationType(std::string theOutlineKeyName)
264         {
265                 outlines_keyNames.push_back(theOutlineKeyName);
266         }
267
268         /*
269         * Adds an outline to the group as plane section type
270         * @param theOutlineKeyName Is the name used as identifier of the outline        
271         */
272         void OutlineGroup :: addOutline_PlaneSectionType(std::string theOutlineKeyName)
273         {
274                 outlines_keyNames.push_back(theOutlineKeyName);
275         }
276
277
278         /*
279         * Adds an outline to the group as overlaped type
280         * @param theOutlineKeyName Is the name used as identifier of the outline        
281         */
282         void OutlineGroup :: addOutline_OverlapedType(std::string theOutlineKeyName)
283         {
284                 bool ifInclude = isMemberOfGroup(theOutlineKeyName);
285                 if ( ifInclude )
286                         outlines_keyNames.push_back(theOutlineKeyName);
287         }
288
289         /*
290         * Adds an outline to the group as strip type
291         * @param theOutlineKeyName Is the name used as identifier of the outline        
292         */
293         void OutlineGroup :: addOutline_StripType(std::string theOutlineKeyName)
294         {
295                 outlines_keyNames.push_back(theOutlineKeyName);
296         }
297
298         /*
299         * Adds an outline to the group as manual type
300         * @param theOutlineKeyName Is the name used as identifier of the outline        
301         */
302         void OutlineGroup :: addOutline_ManualType(std::string theOutlineKeyName)
303         {
304                 outlines_keyNames.push_back(theOutlineKeyName);
305         }
306
307         /*
308         * Gets the outlines of the group
309         * @return Returns the names of the outlines that belong to the group
310         */
311          std::vector< std::string > OutlineGroup :: getGroupOutlinesNames ( )
312          {
313                  return outlines_keyNames;
314          }
315