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