]> Creatis software - creaContours.git/blob - lib/kernel_ManagerContour_NDimensions/OutlineModelManager.cxx
44d91fa5f592521c68c2fb1dc8d76f5aed628ece
[creaContours.git] / lib / kernel_ManagerContour_NDimensions / OutlineModelManager.cxx
1
2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "OutlineModelManager.h"
6
7 //----------------------------------------------------------------------------------------------------------------
8 // Class implementation
9 //----------------------------------------------------------------------------------------------------------------
10 /** @file OutlineModelManager.cxx */
11
12 //------------------------------------------------------------------------------------------------------------
13 // Constructors & Destructors
14 //------------------------------------------------------------------------------------------------------------
15 /*
16         * Creates the outline manager
17         */
18         OutlineModelManager :: OutlineModelManager( SomeEnvironment<ImageSourceThing *> *imSourceEnv, SomeEnvironment<ImageSectionThing *> *imSectionEnv, SomeEnvironment<AxeThing *> *axesEnv, SomeEnvironment<ContourThing *> *contourEnv )
19         {
20                 actualInstant                           = NULL;
21                 imageSourceEnvironment          = imSourceEnv;
22                 imagesSectionEnvironment        = imSectionEnv;
23                 axesEnvironment                         = axesEnv;
24                 outlinesEnvironment                     = contourEnv;
25
26                 workSpace                                       = new ContourWorkspace(this);//implies a shared workSpace
27                 keyGenerator                            = * new PrefixMaxKeyGenerator();        
28                 counterIdKey                            = 0;
29
30                 actualInstantWrapping           = new InstantMembersNameList();
31                 changeSourceImage                       = true; 
32
33                 bool allOK      = keyGenerator.addKeyThing("Axes", "Axe");
34                 allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
35                 allOK &= keyGenerator.addKeyThing("Image Sections", "Image section");
36                 allOK &= keyGenerator.addKeyThing("Outlines", "Outline");
37                 //setAutomaticConcepts();
38         }
39
40         /*
41         * Destroys the outline manager
42         */
43         OutlineModelManager :: ~OutlineModelManager()
44         {
45                 clean();
46                 delete actualInstant;
47                 delete workSpace;
48                 delete actualInstantWrapping;           
49         }
50
51 //------------------------------------------------------------------------------------------------------------
52 // Methods 
53 //------------------------------------------------------------------------------------------------------------
54
55
56         /*
57         * Creates and sets a workSpace object
58         * @return Retourns the created workSpace
59         */
60         ContourWorkspace * OutlineModelManager :: createWorkSpace()
61         {
62                 workSpace = new ContourWorkspace(this);
63                 return workSpace;
64         }
65
66         /*
67         * Sets the workSpace object
68         * @param  aWorkSpace The workSpace to set 
69         */
70         void OutlineModelManager :: setWorkSpace( ContourWorkspace * aWorkSpace )
71         {
72                 workSpace = aWorkSpace;
73         }
74
75         /*
76         * Executes a command over an outline object
77         * @param imaKName Is the key name of the outline
78         * @param theCommand Is the command to execute
79         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
80         */
81         bool OutlineModelManager :: executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration)
82         {
83                 ContourThing * theOutline = *outlinesEnvironment->getThingByName( outKName );
84                 if(!fromRegistration)
85                 {
86                         CommandObject * undoCommand = theOutline->getUndoCommandOf( theCommand );
87                         workSpace->callRegisterCommand(theCommand, undoCommand);
88                 }
89                 return theOutline->executeCommand( theCommand );
90         }
91
92         /*
93         * Executes a command identifying which actions have to realize before executing it.
94         * @param theCommand Is the command to execute
95         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
96         */
97         bool OutlineModelManager :: executeCommand(CommandObject * theCommand, bool fromRegistration)
98         {
99                 bool executedCom = true;
100                 //TODO**********************************************************************************************************************************************
101                 //Interpreting who is the one that executes the command
102
103                 //Modifiying the command in necessary for detaching interpreted information
104
105                 //If is an outline, sending the command to execute the specific command
106
107                 return executedCom;
108         }
109
110         /*
111         * Executes a command queue identifying which actions have to realize before executing it, using FIFO for each.
112         * @param executionQueue Is the command queue to execute
113         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
114         */
115         bool OutlineModelManager ::  executeCommandsQueue(std::deque<CommandObject *> executionQueue, bool fromRegistration)
116         {
117                 bool executedComs = executionQueue.size()>0 ? true : false;
118                 while( executionQueue.size()>0 )
119                 {                       
120                         CommandObject * aCmmand = executionQueue.front();
121                         executedComs &= executeCommand(aCmmand, fromRegistration);
122                         executionQueue.pop_front();
123                 }
124                 return executedComs;
125         }
126
127         
128         /*
129         * Sets the concepts of the environments and includes the concepts managed by the program 
130         * @conceptsScript Is the script for with the concepts descrition
131         * @return Returns true if successful insert of the given concepts, false otherwise
132         */
133         bool OutlineModelManager :: setUserConcepts(std::string conceptsScript)
134         {
135                 bool allOK = true;
136                 int endSub;
137                 std::string::size_type equalIndex = conceptsScript.find("=", 0);
138                 std::string::size_type nextIndex = 0;
139                 while( equalIndex != std::string::npos && allOK) 
140                 {       
141             endSub = equalIndex;
142                         std::string concept = conceptsScript.substr( 0, endSub ); 
143                         conceptsScript.erase( 0, endSub+1 ); 
144                         std::cout << "C: " << concept <<std::endl;                      
145                         nextIndex = conceptsScript.find(";", 0);
146                         std::string cSize;
147                         if(nextIndex != std::string::npos)
148                         {
149                                 endSub = nextIndex;
150                                 cSize = conceptsScript.substr( 0, endSub ); 
151                                 conceptsScript.erase( 0, endSub+1 ); 
152                         }
153                         else
154                         {
155                                 endSub = conceptsScript.size();         
156                                 cSize = conceptsScript.substr( 0, endSub ); 
157                                 conceptsScript.erase( 0, endSub ); 
158                         }                       
159                         int intReturn = atoi(cSize.c_str());                    
160                         std::cout << "SZ: "<<intReturn <<std::endl;     
161                         equalIndex = conceptsScript.find("=", 0);       
162                         if( intReturn>0 )
163                                 allOK &= addUserConcept(concept, intReturn);
164                         else
165                                 allOK = false;
166                 }               
167                 return allOK;
168         }
169
170         /*
171         * Add a concept to all the environments 
172         * @param theConceptName Is the name of the new concept
173         * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances 
174         * @return Returns true if successful insert of concept, false otherwise
175         */              
176         bool OutlineModelManager :: addUserConcept(std::string theConceptName, int conceptSize)
177         {       
178                 bool allOK = axesEnvironment->addConcept(theConceptName, conceptSize);
179                 allOK &= imagesSectionEnvironment->addConcept(theConceptName, conceptSize);
180                 allOK &= imageSourceEnvironment->addConcept(theConceptName, conceptSize);
181                 allOK &= outlinesEnvironment->addConcept(theConceptName, conceptSize);
182                 return allOK;
183         }
184
185         /**
186         * Gets the outlines at an instant form the outline's environment
187         * @param anInstant The instant wondered to get outlines at
188         * @param ifAnnotate Indicates if it is needed to annotate the searched outlines
189         * @return The vector to the outlines at the given instance
190         */
191         std::vector<NameWrapper *> OutlineModelManager :: getActualInstantOutlines ()
192         {
193                 return actualInstantWrapping->getOutlinesNamesVector();
194         }
195
196 //EED01
197         void OutlineModelManager :: ChangeContourOfList(std::string keyName, Instant *instant)
198         {
199                 int ispartofstaticlist = IsPartOfStaticList(keyName);
200                 if (ispartofstaticlist==-1)
201                 {
202                         staticContourLst.push_back(  this->outlinesEnvironment->getThingByName(keyName)  );
203                         this->outlinesEnvironment->removeThingFromInstant(keyName, instant);
204                 } else {
205                         ContourThing **contourthing  = staticContourLst[ispartofstaticlist];
206                         this->outlinesEnvironment->addInstantToThing    ( keyName , instant );                  
207                         staticContourLst.erase( staticContourLst.begin()+ispartofstaticlist );
208                 }
209         }
210
211
212         /**
213         * Gets the outlines at an instant form the outline's environment
214         * @param anInstant The instant wondered to get outlines at
215         * @param ifAnnotate Indicates if it is needed to annotate the searched outlines
216         * @return The vector to the outlines at the given instance
217         */
218         std::vector<ContourThing**>  OutlineModelManager :: getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate)
219         {
220                 std::vector<std::string> kNamesVector;
221                 std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
222                 outlinesEnvironment->getThings( kNamesVector, outlinesVector, anInstant);
223
224 //EED01
225                 int i,sizeStaticContourLst =  staticContourLst.size();
226                 for ( i=0 ; i<sizeStaticContourLst ; i++ )
227                 {
228                         ContourThing **contourthing  = staticContourLst[i];
229                         outlinesVector.push_back( contourthing );
230                         kNamesVector.push_back( (*contourthing)->getName() );
231                 }// for i
232
233                 if (ifAnnotate)
234                 {
235                         annotateOutlinesWrap(kNamesVector, outlinesVector);
236                 }
237                 return outlinesVector;
238         }
239
240 //EED01
241         std::vector<std::string> OutlineModelManager :: GetLstNameThingsStatic()
242         {
243                 std::vector<std::string> result;
244                 int i,sizeStaticContourLst =  staticContourLst.size();
245                 for ( i=0 ; i<sizeStaticContourLst ; i++ )
246                 {
247                         ContourThing **contourthing  = staticContourLst[i];
248                         result.push_back( (*contourthing)->getName() );
249                 }// for i
250                 return result;
251         }
252
253         std::vector<std::string> OutlineModelManager :: GetLstNameThings()
254         {
255                 std::vector<std::string> kNamesVector;
256                 std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
257                 std::vector<Instant *> lstInstants = getOutlineInstants();
258                 int i,sizeLstInstants = lstInstants.size(); 
259                 Instant *instant;
260                 for ( i=0 ; i<sizeLstInstants ; i++ )
261                 {
262                         instant = lstInstants[i];
263                         outlinesEnvironment->getThings( kNamesVector, outlinesVector, instant);
264                 } // for i
265                 return kNamesVector;
266         }
267
268
269         /**
270         * Gets the outlines at a specific form the outline's environment
271         * @param aGroupName The name of the group containing the outlines names to get
272         * @return The vector to the outlines at the given group
273         */ 
274         std::vector<ContourThing*> OutlineModelManager :: getOutlinesFromGroup(std::string aGroupName)
275         {
276                 std::vector<ContourThing *> outlinesVector;
277                 std::map< std::string,OutlineGroup * >::iterator iterP = outlineGroups.find(aGroupName);
278                 if ( iterP != outlineGroups.end() )
279                 {       
280                         std::vector<std::string> kNamesVector = iterP->second->getGroupOutlinesNames(); 
281                         for(int i=0; i<kNamesVector.size();i++)
282                         {
283                                 ContourThing * outlineI = getOutlineByKeyName(kNamesVector[i]);
284                                 outlinesVector.push_back(outlineI);
285                         }                       
286                 }
287                 return outlinesVector;
288         }
289
290         /**
291         * Gets the outlines at a specific form the outline's environment
292         * @param aGroupName The name of the group containing the outlines names to get
293         * @return The vector to the outlineGroups at the given group
294         */ 
295         bool OutlineModelManager :: addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup )
296         {
297         outlineGroups.insert(std::pair <std::string, OutlineGroup *> ( theOutlineName, theGroup ));                             
298 //              std::map<std::string, OutlineGroup *> :: iterator iter = NULL;
299                 std::map<std::string, OutlineGroup *> :: iterator iter;
300                 iter = outlineGroups.find( theOutlineName );
301                 bool ifAdded = iter->first.compare( theOutlineName ) == 0;
302                 return ifAdded;
303         }
304         /*
305         * Gets the an outline given the keyName used to be indexed in the outlines's environment
306         * @param outKName Is the outline keyName to search
307         * @return  The corresponding unique outline with the given key name
308         */
309         ContourThing* OutlineModelManager :: getOutlineByKeyName(std::string outKName)
310         {
311                 return *(outlinesEnvironment->getThingByName(outKName));
312         }
313
314         /*
315         * Gets the an imageSourceThing given the keyName used to be indexed in the ImageSourceThing's environment
316         * @param outKName Is the imageSourceThing keyName to search
317         * @return  The corresponding unique outline with the given key name
318         */
319         ImageSourceThing* OutlineModelManager ::getImageSourceThingByKeyName(std::string iSeourceKName)
320         {
321                 return *(imageSourceEnvironment->getThingByName(iSeourceKName));
322         }
323
324         /*
325         * Gets the an imageSectionThing given the keyName used to be indexed in the ImageSectionThing's environment
326         * @param outISectionName Is the imageSectionThing keyName to search
327         * @return  The corresponding unique outline with the given key name
328         */
329         ImageSectionThing* OutlineModelManager ::getImageSectionThingByKeyName(std::string iSectionName)
330         {
331                 return *(imagesSectionEnvironment->getThingByName(iSectionName));
332         }
333
334         /*
335         * Creates an outlineThing with a given name, if no name is given it would have an automatic
336         * @param aName The name for the outlineThing
337                 * @return Returns the key name of the created outline, or ""if it wasn't created
338         */
339 //      bool OutlineModelManager :: createOutline(std::string aName, ContourThing * &theOutline)
340         std::string  OutlineModelManager :: createOutline(manualContourModel * model, std::vector<int> theInstantData, std::string aName)
341         {
342                 ContourThing * theOutline = new ContourThing ( model );
343                 theOutline->setName(aName);             
344                 return addOutline( theOutline, new Instant( &theInstantData ) );                                
345         }
346
347         /*
348         * Creates an axeThing with a given name
349         * @param aDescription The description for the axeThing
350         * @return Returns true if the creation of the axe was successful
351         */
352         //bool OutlineModelManager :: createAxe(std::string aDescription, AxeThing * &theAxe)
353         bool  OutlineModelManager :: createAxe(std::string aDescription, Instant * theInstantData)
354         {
355                 AxeThing * theAxe = new AxeThing ();
356                 theAxe->setDescription(aDescription);                 
357                 return addAxe(theAxe, theInstantData);          
358         }
359
360         /*
361         * Creates an imageSourceThing with a given name
362         * @param aSource The name for the imageSourceThing
363         * @return Returns true if the creation of the imageSource was successful
364         */
365         //bool OutlineModelManager :: createImageSource(std::string aSource, ImageSourceThing * &imageSource)
366         bool OutlineModelManager :: createImageSource(std::string aSource, Instant * theInstantData)
367         {
368 //              imageSource = new ImageSourceThing(aSource);                
369                 //return addImageSource(new ImageSourceThing(aSource), theInstantData);         
370                 return NULL;//***********************************************************************************************
371         }
372
373         /*
374         * Creates an imageSectionThing with a given name
375         * @param aSecImageData The name for the imageSectionThing
376         * @return Returns true if the creation of the imageSection was successful
377         */
378         //bool OutlineModelManager :: createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection)
379         bool OutlineModelManager :: createImageSection(std::string aSecImageData, Instant * theInstantData)
380         {
381                 //imageSection = new ImageSectionThing(aSecImageData);               
382 //              return addImageSection(new ImageSectionThing(aSecImageData), theInstantData);   
383                 return NULL;
384         }
385
386         /*
387         * Adds an outlineThing 
388         * @param theOutline The outline/contour (thing)
389         * @param theInstantData Is the instant for the outline to add
390         * @return Returns true if the addition of the outline was successful
391         */
392         std::string OutlineModelManager :: addOutline( ContourThing * theOutline, Instant * theInstantData)
393         {               
394                 std::string kName;
395
396 // EED 
397 //              bool added  = keyGenerator.generateKeyOf("Outlines", outlinesEnvironment->getNumberOfThings(),kName);
398
399                 counterIdKey++;
400                 bool added = keyGenerator.generateKeyOf( "Outlines", counterIdKey , kName );
401
402                 if( theOutline->getName().compare("")==0 )
403                 {
404                         theOutline->setName(kName);
405                 }
406                 added &= outlinesEnvironment->addThingWithInstant(kName,theOutline, theInstantData);
407                 if( added )
408                         return kName;
409                 else
410                         return "";              
411         }
412
413
414         int OutlineModelManager::IsPartOfStaticList(std::string ss)
415         {
416                 int iBack=-1;
417                 int i, size = staticContourLst.size();
418                 for( i=0 ; i<size ; i++ )
419                 {
420                         ContourThing **contourthing  = staticContourLst[i];
421                         if ((*contourthing)->getName() == ss)
422                         {
423                                 iBack=i;
424                         } // getName() == ss
425                 }
426                 return iBack;
427         }
428
429
430         /*
431         * Remove an outlineThing 
432         * @param theOutline The outline/contour (thing)
433         */
434         void OutlineModelManager :: removeOutline( std::string ss )
435         {               
436                         outlinesEnvironment->removeThing( ss );
437         }
438
439 //EED01
440         void OutlineModelManager :: removeAllOutlines()
441         {
442                 //
443                 staticContourLst.clear();
444
445                 //
446                 std::vector< ContourThing **>  thingsVector;
447                 outlinesEnvironment->getThingsOfEnvironment( &thingsVector );
448                 int i,sizeThingVector = thingsVector.size();
449                 for(i=0;i<sizeThingVector;i++) 
450                 {
451                         ContourThing ** contourthing =  thingsVector[i];
452                     removeOutline(  (*contourthing)->getName()   );
453                 }
454         }
455
456
457         /*
458         * Adds an axeThing 
459         * @param thaAxe The axe (thing)
460         * @param theInstantData Is the instant for the axe to add
461         * @return Returns true if the addition of the axe was successful
462         */
463         bool OutlineModelManager :: addAxe( AxeThing * theAxe , Instant * theInstantData)
464         {
465                 std::string kName;
466                 bool added  = keyGenerator.generateKeyOf("Axes", axesEnvironment->getNumberOfThings(),kName);           
467                 added &= axesEnvironment->addThingWithInstant(kName,theAxe, theInstantData);
468                 return added;
469         }
470
471         /*
472         * Adds an imageSourceThing 
473         * @param imgageSource The image source (thing)
474         * @param theInstantData Is the instant for the source to add
475         * @return Returns true if the addition of the imageSource was successful
476         */
477         bool OutlineModelManager :: addImageSource(ImageSourceThing * imageSource, Instant * theInstantData)
478         {
479                 std::string kName;
480                 bool added  = keyGenerator.generateKeyOf("Image Sources", imageSourceEnvironment->getNumberOfThings(),kName);
481                 added &= imageSourceEnvironment->addThingWithInstant(kName,imageSource, theInstantData );
482                 return added;
483         }
484
485         /*
486         * Adds an imageSectionThing with a given name, if no name is given it would have an automatic
487         * @param aName The imageSection (thing)
488         * @param theInstantData Is the instant for the imageSection to add
489         * @return Returns true if the addition of the imageSection was successful
490         */
491         bool OutlineModelManager :: addImageSection(ImageSectionThing * imageSection, Instant * theInstantData)
492         {               
493                 std::string kName;
494                 bool added  = keyGenerator.generateKeyOf("Image Sections", imagesSectionEnvironment->getNumberOfThings(),kName);
495                 added &= imagesSectionEnvironment->addThingWithInstant(kName, imageSection, theInstantData);
496                 return added;
497         }
498
499         /*
500         * Annotates an outline keyname at the actual instant
501         * @param kOutlineName The key name to annotate
502         * @param theRealName The real name asigned to the outline
503         */
504         void OutlineModelManager :: annotateOutlineWrap(std::string kOutlineName, std::string theRealName)
505         {
506                 actualInstantWrapping -> addOutlineName(kOutlineName, theRealName);
507         }
508
509         /*
510         * Annotates a set of outline keynames-real names wrapping at the actual instant
511         * @param kNamesVector The key names vector to annotate
512         * @param theOutlinesVector The outlines pointers vector to get the real names from
513         */
514         void OutlineModelManager :: annotateOutlinesWrap(std::vector<std::string> kNamesVector, std::vector<ContourThing **> theOutlinesVector)
515         {
516                 actualInstantWrapping ->clean();
517                 for(int i=0; i<kNamesVector.size(); i++)
518                 {
519                         ContourThing * anOutline = *theOutlinesVector[i];
520                         actualInstantWrapping -> addOutlineName( kNamesVector[i], anOutline->getName() );
521                 }
522         }
523         
524         /*
525         * Annotates the actual outline keyName-real name wrapping at the actual instant
526         * @param actualKeyOutline The key name to annotate
527         * @param theRealName The real name asigned to the actual outline
528         */
529         void OutlineModelManager :: annotateActualOutlineWrap(std::string actualKeyOutline, std::string theRealName)
530         {
531                 actualInstantWrapping -> setActualOutline(actualKeyOutline, theRealName);
532         }
533
534         /*
535         * Annotate the actual axe keyName-real name wrapping at the actual instant
536         * @param actualKeyAxe The key name to annotate
537         * @param theRealName The real name asigned to the actual axe
538         */
539         void OutlineModelManager :: annotateActualAxeWrap(std::string actualKeyAxe, std::string theRealName)
540         {
541                 actualInstantWrapping -> setActualAxeWrap(actualKeyAxe, theRealName);
542         }
543
544         /*
545         * Annotate the annotateActualSection image keyName-real name wrapping at the actual instant
546         * @param actualKeyImage The key name to annotate
547         * @param theRealName The real name asigned to the annotateActualSection
548         */
549         void OutlineModelManager :: annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
550         {
551                 actualInstantWrapping -> setActualSectionImageNamesWrapp(actualKeyImage, theRealName);
552         } 
553
554         /*
555         * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant
556         * @param actualKeyImage The key name to annotate
557         * @param theRealName The real name asigned to the annotateActualSource 
558         */
559         void OutlineModelManager :: annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
560         {
561                 actualInstantWrapping -> setActualSourceImageNamesWrapp(actualKeyImage, theRealName);
562         } 
563
564
565         /*
566         * Sets the actual instant and manage the search of the corresponding elements with the specified instant in all the enviornments
567         * @param newActualInstantData Is the instant data
568         */
569         void OutlineModelManager :: setInstant(Instant * newActualInstantData)
570         {
571                 actualInstant = newActualInstantData;
572                 updateToActualInstant();
573         }
574
575         Instant* OutlineModelManager :: getInstant()
576         {
577                 return actualInstant;
578         }
579
580         /*
581         * Gets the an axe with a given keyName
582         * @axeKName The axe keyName for searching in the axes environment
583         * @return The corresponding axe
584         */
585         AxeThing * OutlineModelManager :: getAxeByKeyName(std::string axeKName)
586         {
587                 return *axesEnvironment->getThingByName(axeKName);
588         }
589
590         /*
591         * Gets the instants of a specific outline
592         * @param thekName Is the name of the outline
593         * @return The instants set 
594         */
595         std::vector<Instant *> OutlineModelManager :: getOutlineInstantsByName(std::string thekName)
596         {               
597                 return *outlinesEnvironment->getInstantsOfThing(thekName);              
598         }
599
600         /*
601         * Gets all instants outlines
602         * @return The instants set 
603         */
604         std::vector<Instant *> OutlineModelManager :: getOutlineInstants()
605         {               
606                 return *outlinesEnvironment->getExistingInstants();             
607         }
608
609
610
611         /*
612         * Includes an instant to the specified axe
613         * @param outKName Is outline key name
614         * @param anInstantData Is the instant data
615         * @return Returns if the insertion was successful or not
616         */
617         bool OutlineModelManager :: includeOutlineInstant(std::string outKName,Instant * anInstantData)
618         {
619                 return outlinesEnvironment->addInstantToThing(outKName,anInstantData);
620         }
621
622         /*
623         * Includes an instant to the specified axe
624         * @param axeKName Is axe key name
625         * @param anInstantData Is the instant data
626         * @return Returns if the insertion was successful or not
627         */
628         bool OutlineModelManager :: includeAxeInstant(std::string axeKName,Instant * anInstantData)
629         {
630                 return axesEnvironment->addInstantToThing( axeKName,anInstantData );
631         }
632
633         /*
634         * Includes an instant to the specified image section
635         * @param imaKName Is the image section key name
636         * @param anInstantData Is the instant data
637         * @return Returns if the insertion was successful or not
638         */
639         bool OutlineModelManager :: includeImageSectionInstant(std::string imaKName,Instant * anInstantData)
640         {
641                 return imagesSectionEnvironment->addInstantToThing( imaKName,anInstantData );
642         }
643
644         /*
645         * Includes an instant to the specified image source
646         * @param imaKName Is the image section key name
647         * @param anInstantData Is the instant data
648         * @return Returns if the insertion was successful or not
649         */
650         bool OutlineModelManager :: includeImageSourceInstant(std::string imaKName,Instant * anInstantData)
651         {
652                 return imageSourceEnvironment->addInstantToThing( imaKName,anInstantData );
653         }
654         
655         /*
656         *       Method that retorns the name of each concept and the size of it.
657         *       @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
658         *       @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts
659         */
660         void OutlineModelManager :: getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect)
661         {
662                 if( outlinesEnvironment != NULL )
663                 {
664                         //if (outlinesEnvironment->getNumberOfThings()>0)
665                                 outlinesEnvironment->getConceptsInformation(conceptNameVect, conceptSizeVect);
666                 }       
667         }
668
669
670         /*
671         * Gets the contourWorspace 
672         * @return Returns the workspace
673         */
674         ContourWorkspace * OutlineModelManager :: getContourWorkspace()
675         {
676                 return workSpace;
677         }
678
679
680         /*
681         * Cleans the outline model manager and its dependencies
682         */
683         void OutlineModelManager :: clean()
684         {
685                 /*axesEnvironment->clean();
686                 imagesSectionEnvironment->clean();
687                 imageSourceEnvironment->clean();
688                 outlinesEnvironment->clean();*/
689                 outlineGroups.clear();
690                 actualInstantWrapping->clean();
691                 keyGenerator.clear();
692                 //workSpace->clear();
693         }
694
695         /*
696         * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model
697         */
698         void OutlineModelManager :: updateToActualInstant()
699         {               
700                 Instant * longInstant = actualInstant;
701                 /*Instant * mediumInstant = new Instant();
702                 Instant * shortInstant = new Instant();         
703                 std::vector<int>* theInstant = longInstant->getInstant();
704                 for(int i=1; i<theInstant->size(); i++)
705                 {
706                         if (i>=2)
707                                 shortInstant->addConcept( (*theInstant)[i] );
708                         mediumInstant->addConcept( (*theInstant)[i] );
709                 }
710                 
711                 //getting the sourceAtInstant
712                 std::vector<std::string> kSourceVector;
713                 std::vector<ImageSourceThing **> imSourceVector;
714                 imageSourceEnvironment->getThings(kSourceVector, imSourceVector, shortInstant);
715                 annotateActualSourceImageWrap(kSourceVector[0], (**imSourceVector[0]).getSourceImage());
716
717         //getting the aAxeAtInstant 
718                 std::vector<std::string> kAxeVector;
719                 std::vector<AxeThing **> axesVector;
720                 axesEnvironment->getThings(kAxeVector, axesVector, mediumInstant);
721                 if ( !kAxeVector.empty() )
722                         annotateActualAxeWrap(kAxeVector[0], (**axesVector[0]).getDescription());
723
724                 //getting the sectionAtInstant
725                 std::vector<std::string> kSectionVector;
726                 std::vector<ImageSectionThing **> imSectionVector;
727                 imagesSectionEnvironment->getThings(kSectionVector, imSectionVector, longInstant); if ( !kSectionVector.empty() )
728             //annotateActualSectionImageWrap(kSectionVector[0], (**imSectionVector[0]).getImageData());
729                 */
730                 
731                 //getting the outlines          
732
733                 std::vector<ContourThing ** > vect = getOutlinesAtInstant( longInstant );
734
735         }
736         
737         /*
738         * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments.   
739         * @return Returns true if successful insert of the automatic concepts, false otherwise
740         */
741         bool OutlineModelManager :: setAutomaticConcepts()
742         {
743                 axeConcept = "Axe";
744                 axeDepthConcept = "Axe Depth";
745                 int axeC_size = 10;
746                 int axeDepthC_size = INT_MAX;
747
748                 bool allOK = axesEnvironment->addConcept(axeConcept, axeC_size);
749                 allOK &= imagesSectionEnvironment->addConcept(axeConcept, axeC_size);
750                 allOK &= outlinesEnvironment->addConcept(axeConcept, axeC_size);
751                 
752                 allOK &= imagesSectionEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
753                 allOK &= outlinesEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
754 /*
755                 allOK &= keyGenerator.addKeyThing("Axes", "Axe");
756                 allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
757                 allOK &= keyGenerator.addKeyThing("Image Sections", "Image section");
758                 allOK &= keyGenerator.addKeyThing("Outlines", "Outline");*/
759
760                 return allOK;
761         }
762
763
764         std::string OutlineModelManager :: createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData )
765         {
766                 manualContourModel * manModelContour  = getOutlineByKeyName( anExistingKName )->getModel()->Clone();
767                 return createOutline( manModelContour, instantNoTouchData );
768         }
769
770         void OutlineModelManager::SaveThingName( FILE *pFile, std::string nameThing )
771         {
772                 std::vector< Instant * > *lstInstants;
773                 lstInstants = outlinesEnvironment->getInstantsOfThing( nameThing );
774                 Instant *instant = (*lstInstants)[0];
775                 std::vector<int> *vecInst =instant->getInstant();
776                 int i,sizeVecInst = vecInst->size();
777                 fprintf(pFile,"Instant ");
778                 for ( i=0 ; i<sizeVecInst ; i++ )
779                 {
780                         fprintf(pFile,"%d ",(*vecInst)[i]);
781                 }
782                 fprintf(pFile,"\n");
783                 ContourThing *contourthing = *outlinesEnvironment->getThingByName(nameThing);
784                 contourthing->getModel()->Save(pFile);
785         }
786