creaContours_lib
OutlineModelManager.h
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 #ifndef __OTULINE_MODEL_MANAGER__
27 #define __OTULINE_MODEL_MANAGER__
28 
29 
30 //------------------------------------------------------------------------------------------------------------
31 // Includes
32 //------------------------------------------------------------------------------------------------------------
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <iostream>
36 #include <sstream>
37 #include <map>
38 #include <vector>
39 #include <string>
40 
41 
42 #include "ContourThing.h"
43 #include "AxeThing.h"
44 #include "ImageSourceThing.h"
45 #include "ImageSectionThing.h"
46 #include "InstantMembersNameList.h"
47 #include "OutlineGroup.h"
48 #include "ContourWorkspace.h"
49 #include "CommandsHandler.h"
50 #include "InstantMembersNameList.h"
51 #include "PrefixMaxKeyGenerator.h"
52 
53 //#include "../kernel_Environment/InstantHandler.h" //Is not working
54 //#include "../kernel_Environment/Instant.h" //Is included in the SomeEnvironment template
55 //#include "../kernel_Environment/SomeEnvironment.h"
56 #include "SomeEnvironment.h"
57 
58 class ContourWorkspace;
59 
61 
62 //------------------------------------------------------------------------------------------------------------
63 // Constructors & Destructors
64 //------------------------------------------------------------------------------------------------------------
65 public:
66 
67  /*
68  * Creates the outline manager
69  */
70  OutlineModelManager( SomeEnvironment<ImageSourceThing *>* imSourceEnv, SomeEnvironment<ImageSectionThing *>* imSectionEnv, SomeEnvironment<AxeThing *>* axesEnv, SomeEnvironment<ContourThing *>* contourEnv );
71 
72 
73  /*
74  * Destroys the outline manager
75  */
77 
78 //------------------------------------------------------------------------------------------------------------
79 // Methods
80 //------------------------------------------------------------------------------------------------------------
81 
82  /*
83  * Creates and sets a workSpace object
84  * @return Retourns the created workSpace
85  */
87 
88  /*
89  * Sets the workSpace object
90  * @param aWorkSpace The workSpace to set
91  */
92  void setWorkSpace( ContourWorkspace * aWorkSpace );
93 
94  /*
95  * Executes a command over an outline object
96  * @param imaKName Is the key name of the outline
97  * @param theCommand Is the command to execute
98  * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
99  */
100  bool executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration);
101 
102  /*
103  * Executes a command identifying which actions have to realize before executing it.
104  * @param theCommand Is the command to execute
105  * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
106  */
107  bool executeCommand(CommandObject * theCommand, bool fromRegistration=false);
108 
109  /*
110  * Executes a command queue identifying which actions have to realize before executing it, starting in from the front of it.
111  * @param executionQueue Is the command queue to execute
112  * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
113  */
114  bool executeCommandsQueue(std::deque<CommandObject *> executionQueue, bool fromRegistration=false);
115 
116  /*
117  * Sets the concepts of the environments and includes the concepts managed by the program
118  * @conceptsScript Is the script for with the concepts descrition
119  * @return Returns true if successful insert of the given concepts, false otherwise
120  */
121  bool setUserConcepts(std::string conceptsScript);
122 
123  /*
124  * Add a concept to all the environments
125  * @param theConceptName Is the name of the new concept
126  * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances
127  * @return Returns true if successful insert of concept, false otherwise
128  */
129  bool addUserConcept( std::string theConceptName, int conceptSize );
130 
137  std::vector<NameWrapper *> getActualInstantOutlines ();
138 
145  std::vector<ContourThing**> getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate = true);
146 
151  std::vector<std::string> GetLstNameThings();
152 
153  std::vector<std::string> GetLstNameThingsStatic();
154 
155 
161  std::vector<ContourThing*> getOutlinesFromGroup(std::string aGroupName);
162 
169  bool addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup );
170 
171  /*
172  * Gets the an outline given the keyName used to be indexed in the outlines's environment
173  * @param outKName Is the outline keyName to search
174  * @return The corresponding unique outline with the given key name
175  */
176  ContourThing* getOutlineByKeyName(std::string outKName);
177 
178  /*
179  * Gets the an imageSourceThing given the keyName used to be indexed in the ImageSourceThing's environment
180  * @param outKName Is the imageSourceThing keyName to search
181  * @return The corresponding unique outline with the given key name
182  */
183  ImageSourceThing* getImageSourceThingByKeyName(std::string iSeourceKName);
184 
185  /*
186  * Gets the an imageSectionThing given the keyName used to be indexed in the ImageSectionThing's environment
187  * @param outISectionName Is the imageSectionThing keyName to search
188  * @return The corresponding unique outline with the given key name
189  */
190  ImageSectionThing* getImageSectionThingByKeyName(std::string iSectionName);
191 
192  /*
193  * Creates an outlineThing with a given name, if no name is given it would have an automatic
194  * @param aName The name for the outlineThing
195  * @return Returns the key name of the created outline, or ""if it wasn't created
196  */
197  //bool createOutline(std::string aName, ContourThing * &theOutline);
198  std::string createOutline(manualBaseModel * model, std::vector<int> theInstantData, std::string aName = "" );
199 
200  /*
201  * Creates an axeThing with a given name
202  * @param aDescription The description for the axeThing
203  * @return Returns true if the creation of the axe was successful
204  */
205  //bool createAxe(std::string aDescription,AxeThing * &theAxe);
206  bool createAxe(std::string aDescription, Instant * theInstantData);
207 
208  /*
209  * Creates an imageSourceThing with a given name
210  * @param aName The name for the imageSourceThing
211  * @return Returns true if the creation of the imageSource was successful
212  */
213  //bool createImageSource(std::string aName, ImageSourceThing * &imageSource);
214  bool createImageSource(std::string aSource, Instant * theInstantData);
215 
216  /*
217  * Creates an imageSectionThing with a given name
218  * @param aSecImageData The name for the imageSectionThing
219  * @return Returns true if the creation of the imageSection was successful
220  */
221  //bool createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection);
222  bool createImageSection(std::string aSecImageData, Instant * theInstantData);
223 
224  /*
225  * Adds an outlineThing
226  * @param theOutline The outline/contour (thing)
227  * @param theInstantData Is the instant for the outline to add
228  * @return Returns the key name of the created outline, or ""if it wasn't created
229  */
230  std::string addOutline(ContourThing * theOutline, Instant * theInstantData);
231 
232  /*
233  * Remove an outlineThing
234  * @param theOutline The outline/contour (thing)
235  */
236  void removeOutline( std::string ss );
237 
238  /*
239  * Adds an axeThing
240  * @param thaAxe The axe (thing)
241  * @param theInstantData Is the instant for the axe to add
242  * @return Returns true if the addition of the axe was successful
243  */
244  bool addAxe( AxeThing * thaAxe, Instant * theInstantData);
245 
246  /*
247  * Adds an imageSourceThing
248  * @param imgageSource The image source (thing)
249  * @param theInstantData Is the instant for the source to add
250  * @return Returns true if the addition of the imageSource was successful
251  */
252  bool addImageSource(ImageSourceThing * imageSource, Instant * theInstantData);
253 
254  /*
255  * Adds an imageSectionThing with a given name, if no name is given it would have an automatic
256  * @param aName The imageSection (thing)
257  * @param theInstantData Is the instant for the imageSection to add
258  * @return Returns true if the addition of the imageSection was successful
259  */
260  bool addImageSection(ImageSectionThing * imageSection, Instant * theInstantData);
261 
262  /*
263  * Annotates an outline keyname at the actual instant
264  * @param kOutlineName The key name to annotate
265  * @param theRealName The real name asigned to the outline
266  */
267  void annotateOutlineWrap(std::string kOutlineName, std::string theRealName);
268 
269  /*
270  * Annotates a set of outline keynames-real names wrapping at the actual instant
271  * @param kNamesVector The key names vector to annotate
272  * @param theOutlinesVector The outlines pointers vector to get the real names from
273  */
274  void annotateOutlinesWrap(std::vector<std::string> keyNames, std::vector<ContourThing **> theOutlinesVector);
275 
276  /*
277  * Annotates the actual outline keyName-real name wrapping at the actual instant
278  * @param actualKeyOutline The key name to annotate
279  * @param theRealName The real name asigned to the actual outline
280  */
281  void annotateActualOutlineWrap(std::string actualKeyOutline, std::string theRealName);
282 
283  /*
284  * Annotate the actual axe keyName-real name wrapping at the actual instant
285  * @param actualKeyAxe The key name to annotate
286  * @param theRealName The real name asigned to the actual axe
287  */
288  void annotateActualAxeWrap(std::string actualKeyAxe, std::string theRealName);
289 
290  /*
291  * Annotate the annotateActualSection image keyName-real name wrapping at the actual instant
292  * @param actualKeyImage The key name to annotate
293  */
294  void annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName);//---BORRAR...
295 
296  /*
297  * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant
298  * @param actualKeyImage The key name to annotate
299  */
300  void annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName);//---BORRAR...
301  /*
302  * Sets the actual instant and manage the search of the corresponding elements with the specified instant in all the enviornments
303  * @param newActualInstantData Is the instant data
304  */
305  void setInstant(Instant * newActualInstantData);
306 
307  /*
308  * Gets the an axe with a given keyName
309  * @axeKName The axe keyName for searching in the axes environment
310  * @return The corresponding axe
311  */
312  AxeThing * getAxeByKeyName(std::string axeKName);
313 
314  /*
315  * Gets the instants of a specific outline
316  * @param thekName Is the name of the outline
317  * @return The instants set
318  */
319  std::vector<Instant *> getOutlineInstantsByName(std::string thekName);
320 
321  /*
322  * Gets all instants outlines
323  * @return The instants set
324  */
325  std::vector<Instant *> getOutlineInstants();
326 
327  /*
328  * Includes an instant to the specified axe
329  * @param outKName Is outline key name
330  * @param anInstantData Is the instant data
331  * @return Returns if the insertion was successful or not
332  */
333  bool includeOutlineInstant(std::string outKName,Instant * anInstantData);
334 
335  /*
336  * Includes an instant to the specified axe
337  * @param axeKName Is axe key name
338  * @param anInstantData Is the instant data
339  * @return Returns if the insertion was successful or not
340  */
341  bool includeAxeInstant(std::string axeKName,Instant * anInstantData);
342 
343  /*
344  * Includes an instant to the specified image section
345  * @param imaKName Is the image section key name
346  * @param anInstantData Is the instant data
347  * @return Returns if the insertion was successful or not
348  */
349  bool includeImageSectionInstant(std::string imaKName,Instant * anInstantData);
350 
351  /*
352  * Includes an instant to the specified image source
353  * @param imaKName Is the image section key name
354  * @param anInstantData Is the instant data
355  * @return Returns if the insertion was successful or not
356  */
357  bool includeImageSourceInstant(std::string imaKName,Instant * anInstantData);
358 
359  /*
360  * Method that retorns the name of each concept and the size of it.
361  * @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
362  * @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts
363  */
364  void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
365 
366  /*
367  * Gets the contourWorspace
368  * @return Returns the workspace
369  */
371 
372  /*
373  * Gets the number of groups in the model management
374  * @return Returns the size of
375  */
376  int getGroupsCount();
377 
378  /*
379  * Cleans the outline model manager and its dependencies
380  */
381  void clean();
382 
383  void removeAllOutlines();
384  std::string createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData );
385 
386  void SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing );
387 
388  void ChangeContourOfList(std::string keyName, Instant *instant);
389  int IsPartOfStaticList(std::string ss);
390 
391  Instant* getInstant();
392 
393 private :
394 
395  /*
396  * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model
397  */
398  void updateToActualInstant();
399 
400  /*
401  * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments.
402  * @return Returns true if successful insert of the automatic concepts, false otherwise
403  */
404  bool setAutomaticConcepts();
405 
406 
407 
408 
409 
410 //------------------------------------------------------------------------------------------------------------
411 // Constants
412 //------------------------------------------------------------------------------------------------------------
413 
414 
415 
416 //------------------------------------------------------------------------------------------------------------
417 // Attributes
418 //------------------------------------------------------------------------------------------------------------
419 
420 
421 private:
422 
423  /*
424  * Represents the keyName of the actual gruop in the map of gruops
425  */
426  std::string actualGruopID;
427 
428  /*
429  * Represents the environment instant iterator of axes
430  */
431 // InstantHandler<AxeThing *> * axesITER;
432 
433  /*
434  * Represents the environment of axes
435  */
436  SomeEnvironment<AxeThing *>* axesEnvironment;
437 
438  /*
439  * Represents the environment instant iterator of section images
440  */
441 // InstantHandler<ImageSectionThing *> * sectionITER;
442 
443  /*
444  * Represents the environment of section images
445  */
446  SomeEnvironment<ImageSectionThing *>* imagesSectionEnvironment;
447 
448  /*
449  * Represents the environment instant iterator of source's images (Generally a complete volume data per image)
450  */
451 // InstantHandler<ImageSourceThing *> * imageITER;
452 
453  /*
454  * Represents the environment of source images (Generally a complete volume data per image)
455  */
456  SomeEnvironment<ImageSourceThing *>* imageSourceEnvironment;
457 
458  /*
459  * Represents the environment instant iterator of outlines (outlines)
460  */
461 // InstantHandler<ContourThing *> * outlinesITER;
462 
463  /*
464  * Represents the environment of outlines (outlines)
465  */
466  SomeEnvironment<ContourThing *>* outlinesEnvironment;
467 
468  /*
469  * Represents the table of outlines groups
470  */
471  std::map< std::string,OutlineGroup * > outlineGroups;
472 
473  /*
474  * Represents the workspace
475  */
477 
478  /*
479  * Represents the actual instant members list wrrapping (keyName, realName) of objects
480  */
482 
483  /*
484  * Represents a flag indicating if the actualSourceImage has to be changed when changed instant
485  */
487 
490 
491 
492  /*const*/std::string axeConcept /*= "Axe"*/;
493  /*const*/std::string axeDepthConcept /*= "Axe Depth"*/;
494 
495  Instant * actualInstant;
496 
497  //EED
498  std::vector<ContourThing **> staticContourLst;
499 
500 };
501 #endif