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