1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifndef __OTULINE_MODEL_MANAGER__
27 #define __OTULINE_MODEL_MANAGER__
30 //------------------------------------------------------------------------------------------------------------
32 //------------------------------------------------------------------------------------------------------------
42 #include "ContourThing.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"
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"
58 class ContourWorkspace;
60 class OutlineModelManager{
62 //------------------------------------------------------------------------------------------------------------
63 // Constructors & Destructors
64 //------------------------------------------------------------------------------------------------------------
68 * Creates the outline manager
70 OutlineModelManager( SomeEnvironment<ImageSourceThing *>* imSourceEnv, SomeEnvironment<ImageSectionThing *>* imSectionEnv, SomeEnvironment<AxeThing *>* axesEnv, SomeEnvironment<ContourThing *>* contourEnv );
74 * Destroys the outline manager
76 ~OutlineModelManager();
78 //------------------------------------------------------------------------------------------------------------
80 //------------------------------------------------------------------------------------------------------------
83 * Creates and sets a workSpace object
84 * @return Retourns the created workSpace
86 ContourWorkspace * createWorkSpace();
89 * Sets the workSpace object
90 * @param aWorkSpace The workSpace to set
92 void setWorkSpace( ContourWorkspace * aWorkSpace );
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.
100 bool executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration);
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.
107 bool executeCommand(CommandObject * theCommand, bool fromRegistration=false);
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.
114 bool executeCommandsQueue(std::deque<CommandObject *> executionQueue, bool fromRegistration=false);
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
121 bool setUserConcepts(std::string conceptsScript);
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
129 bool addUserConcept( std::string theConceptName, int conceptSize );
132 * Gets the outlines at an instant form the wrapping reference
133 * @param anInstant The instant wondered to get outlines at
134 * @param ifAnnotate Indicates if it is needed to annotate the searched outlines
135 * @return The vector to the outlines at the given instance
137 std::vector<NameWrapper *> getActualInstantOutlines ();
140 * Gets the outlines at an instant form the outline's environment
141 * @param anInstant The instant wondered to get outlines at
142 * @param ifAnnotate Indicates if it is needed to annotate the searched outlines
143 * @return The vector to the outlines at the given instance
145 std::vector<ContourThing**> getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate = true);
148 * Gets the name of all outlines
149 * @return The vector of strings of all outlines
151 std::vector<std::string> GetLstNameThings();
153 std::vector<std::string> GetLstNameThingsStatic();
157 * Gets the outlines at a specific form the outline's environment
158 * @param aGroupName The name of the group containing the outlines names to get
159 * @return The vector to the outlineGroups at the given group
161 std::vector<ContourThing*> getOutlinesFromGroup(std::string aGroupName);
164 * Adds to storing at (outlineGroups) an outline group given its name and the group
165 * @param theOutlineName The name of the group containing the outlines names to add
166 * @param theGroup The outlines group to add
167 * @return Returns true
169 bool addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup );
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
176 ContourThing* getOutlineByKeyName(std::string outKName);
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
183 ImageSourceThing* getImageSourceThingByKeyName(std::string iSeourceKName);
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
190 ImageSectionThing* getImageSectionThingByKeyName(std::string iSectionName);
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
197 //bool createOutline(std::string aName, ContourThing * &theOutline);
198 std::string createOutline(manualBaseModel * model, std::vector<int> theInstantData, std::string aName = "" );
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
205 //bool createAxe(std::string aDescription,AxeThing * &theAxe);
206 bool createAxe(std::string aDescription, Instant * theInstantData);
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
213 //bool createImageSource(std::string aName, ImageSourceThing * &imageSource);
214 bool createImageSource(std::string aSource, Instant * theInstantData);
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
221 //bool createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection);
222 bool createImageSection(std::string aSecImageData, Instant * theInstantData);
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
230 std::string addOutline(ContourThing * theOutline, Instant * theInstantData);
233 * Remove an outlineThing
234 * @param theOutline The outline/contour (thing)
236 void removeOutline( std::string ss );
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
244 bool addAxe( AxeThing * thaAxe, Instant * theInstantData);
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
252 bool addImageSource(ImageSourceThing * imageSource, Instant * theInstantData);
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
260 bool addImageSection(ImageSectionThing * imageSection, Instant * theInstantData);
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
267 void annotateOutlineWrap(std::string kOutlineName, std::string theRealName);
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
274 void annotateOutlinesWrap(std::vector<std::string> keyNames, std::vector<ContourThing **> theOutlinesVector);
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
281 void annotateActualOutlineWrap(std::string actualKeyOutline, std::string theRealName);
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
288 void annotateActualAxeWrap(std::string actualKeyAxe, std::string theRealName);
291 * Annotate the annotateActualSection image keyName-real name wrapping at the actual instant
292 * @param actualKeyImage The key name to annotate
294 void annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName);//---BORRAR...
297 * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant
298 * @param actualKeyImage The key name to annotate
300 void annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName);//---BORRAR...
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
305 void setInstant(Instant * newActualInstantData);
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
312 AxeThing * getAxeByKeyName(std::string axeKName);
315 * Gets the instants of a specific outline
316 * @param thekName Is the name of the outline
317 * @return The instants set
319 std::vector<Instant *> getOutlineInstantsByName(std::string thekName);
322 * Gets all instants outlines
323 * @return The instants set
325 std::vector<Instant *> getOutlineInstants();
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
333 bool includeOutlineInstant(std::string outKName,Instant * anInstantData);
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
341 bool includeAxeInstant(std::string axeKName,Instant * anInstantData);
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
349 bool includeImageSectionInstant(std::string imaKName,Instant * anInstantData);
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
357 bool includeImageSourceInstant(std::string imaKName,Instant * anInstantData);
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
364 void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
367 * Gets the contourWorspace
368 * @return Returns the workspace
370 ContourWorkspace * getContourWorkspace();
373 * Gets the number of groups in the model management
374 * @return Returns the size of
376 int getGroupsCount();
379 * Cleans the outline model manager and its dependencies
383 void removeAllOutlines();
384 std::string createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData );
386 void SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing );
388 void ChangeContourOfList(std::string keyName, Instant *instant);
389 int IsPartOfStaticList(std::string ss);
391 Instant* getInstant();
396 * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model
398 void updateToActualInstant();
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
404 bool setAutomaticConcepts();
410 //------------------------------------------------------------------------------------------------------------
412 //------------------------------------------------------------------------------------------------------------
416 //------------------------------------------------------------------------------------------------------------
418 //------------------------------------------------------------------------------------------------------------
424 * Represents the keyName of the actual gruop in the map of gruops
426 std::string actualGruopID;
429 * Represents the environment instant iterator of axes
431 // InstantHandler<AxeThing *> * axesITER;
434 * Represents the environment of axes
436 SomeEnvironment<AxeThing *>* axesEnvironment;
439 * Represents the environment instant iterator of section images
441 // InstantHandler<ImageSectionThing *> * sectionITER;
444 * Represents the environment of section images
446 SomeEnvironment<ImageSectionThing *>* imagesSectionEnvironment;
449 * Represents the environment instant iterator of source's images (Generally a complete volume data per image)
451 // InstantHandler<ImageSourceThing *> * imageITER;
454 * Represents the environment of source images (Generally a complete volume data per image)
456 SomeEnvironment<ImageSourceThing *>* imageSourceEnvironment;
459 * Represents the environment instant iterator of outlines (outlines)
461 // InstantHandler<ContourThing *> * outlinesITER;
464 * Represents the environment of outlines (outlines)
466 SomeEnvironment<ContourThing *>* outlinesEnvironment;
469 * Represents the table of outlines groups
471 std::map< std::string,OutlineGroup * > outlineGroups;
474 * Represents the workspace
476 ContourWorkspace * workSpace;
479 * Represents the actual instant members list wrrapping (keyName, realName) of objects
481 InstantMembersNameList * actualInstantWrapping;
484 * Represents a flag indicating if the actualSourceImage has to be changed when changed instant
486 bool changeSourceImage;
489 PrefixMaxKeyGenerator keyGenerator;
492 /*const*/std::string axeConcept /*= "Axe"*/;
493 /*const*/std::string axeDepthConcept /*= "Axe Depth"*/;
495 Instant * actualInstant;
498 std::vector<ContourThing **> staticContourLst;