OutlineModelManager.cxx

Go to the documentation of this file.
00001 
00002 //----------------------------------------------------------------------------------------------------------------
00003 // Class definition include
00004 //----------------------------------------------------------------------------------------------------------------
00005 #include "OutlineModelManager.h"
00006 
00007 //----------------------------------------------------------------------------------------------------------------
00008 // Class implementation
00009 //----------------------------------------------------------------------------------------------------------------
00012 //------------------------------------------------------------------------------------------------------------
00013 // Constructors & Destructors
00014 //------------------------------------------------------------------------------------------------------------
00015 /*
00016         * Creates the outline manager
00017         */
00018         OutlineModelManager :: OutlineModelManager( SomeEnvironment<ImageSourceThing *> *imSourceEnv, SomeEnvironment<ImageSectionThing *> *imSectionEnv, SomeEnvironment<AxeThing *> *axesEnv, SomeEnvironment<ContourThing *> *contourEnv )
00019         {
00020                 actualInstant                           = NULL;
00021                 imageSourceEnvironment          = imSourceEnv;
00022                 imagesSectionEnvironment        = imSectionEnv;
00023                 axesEnvironment                         = axesEnv;
00024                 outlinesEnvironment                     = contourEnv;
00025 
00026                 workSpace                                       = new ContourWorkspace(this);//implies a shared workSpace
00027                 keyGenerator                            = * new PrefixMaxKeyGenerator();
00028                 counterIdKey                            = 0;
00029 
00030                 actualInstantWrapping           = new InstantMembersNameList();
00031                 changeSourceImage                       = true;
00032 
00033                 bool allOK      = keyGenerator.addKeyThing("Axes", "Axe");
00034                 allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
00035                 allOK &= keyGenerator.addKeyThing("Image Sections", "Image section");
00036                 allOK &= keyGenerator.addKeyThing("Outlines", "Outline");
00037                 //setAutomaticConcepts();
00038         }
00039 
00040         /*
00041         * Destroys the outline manager
00042         */
00043         OutlineModelManager :: ~OutlineModelManager()
00044         {
00045                 clean();
00046                 delete actualInstant;
00047                 delete workSpace;
00048                 delete actualInstantWrapping;
00049         }
00050 
00051 //------------------------------------------------------------------------------------------------------------
00052 // Methods
00053 //------------------------------------------------------------------------------------------------------------
00054 
00055 
00056         /*
00057         * Creates and sets a workSpace object
00058         * @return Retourns the created workSpace
00059         */
00060         ContourWorkspace * OutlineModelManager :: createWorkSpace()
00061         {
00062                 workSpace = new ContourWorkspace(this);
00063                 return workSpace;
00064         }
00065 
00066         /*
00067         * Sets the workSpace object
00068         * @param  aWorkSpace The workSpace to set
00069         */
00070         void OutlineModelManager :: setWorkSpace( ContourWorkspace * aWorkSpace )
00071         {
00072                 workSpace = aWorkSpace;
00073         }
00074 
00075         /*
00076         * Executes a command over an outline object
00077         * @param imaKName Is the key name of the outline
00078         * @param theCommand Is the command to execute
00079         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
00080         */
00081 
00082         bool OutlineModelManager :: executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration)
00083         {
00084                 ContourThing * theOutline = *outlinesEnvironment->getThingByName( outKName );
00085                 if(!fromRegistration)
00086                 {
00087                         CommandObject * undoCommand = theOutline->getUndoCommandOf( theCommand );
00088                         workSpace->callRegisterCommand(theCommand, undoCommand);
00089                 }
00090                 return theOutline->executeCommand( theCommand );
00091         }
00092 
00093         /*
00094         * Executes a command identifying which actions have to realize before executing it.
00095         * @param theCommand Is the command to execute
00096         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
00097         */
00098         bool OutlineModelManager :: executeCommand(CommandObject * theCommand, bool fromRegistration)
00099         {
00100                 bool executedCom = true;
00101                 //TODO**********************************************************************************************************************************************
00102                 //Interpreting who is the one that executes the command
00103 
00104                 //Modifiying the command in necessary for detaching interpreted information
00105 
00106                 //If is an outline, sending the command to execute the specific command
00107 
00108                 return executedCom;
00109         }
00110 
00111         /*
00112         * Executes a command queue identifying which actions have to realize before executing it, using FIFO for each.
00113         * @param executionQueue Is the command queue to execute
00114         * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false.
00115         */
00116         bool OutlineModelManager ::  executeCommandsQueue(std::deque<CommandObject *> executionQueue, bool fromRegistration)
00117         {
00118                 bool executedComs = executionQueue.size()>0 ? true : false;
00119                 while( executionQueue.size()>0 )
00120                 {
00121                         CommandObject * aCmmand = executionQueue.front();
00122                         executedComs &= executeCommand(aCmmand, fromRegistration);
00123                         executionQueue.pop_front();
00124                 }
00125                 return executedComs;
00126         }
00127 
00128 
00129         /*
00130         * Sets the concepts of the environments and includes the concepts managed by the program
00131         * @conceptsScript Is the script for with the concepts descrition
00132         * @return Returns true if successful insert of the given concepts, false otherwise
00133         */
00134         bool OutlineModelManager :: setUserConcepts(std::string conceptsScript)
00135         {
00136                 bool allOK = true;
00137                 int endSub;
00138                 std::string::size_type equalIndex = conceptsScript.find("=", 0);
00139                 std::string::size_type nextIndex = 0;
00140                 while( equalIndex != std::string::npos && allOK)
00141                 {
00142             endSub = equalIndex;
00143                         std::string concept = conceptsScript.substr( 0, endSub );
00144                         conceptsScript.erase( 0, endSub+1 );
00145                         std::cout << "C: " << concept <<std::endl;
00146                         nextIndex = conceptsScript.find(";", 0);
00147                         std::string cSize;
00148                         if(nextIndex != std::string::npos)
00149                         {
00150                                 endSub = nextIndex;
00151                                 cSize = conceptsScript.substr( 0, endSub );
00152                                 conceptsScript.erase( 0, endSub+1 );
00153                         }
00154                         else
00155                         {
00156                                 endSub = conceptsScript.size();
00157                                 cSize = conceptsScript.substr( 0, endSub );
00158                                 conceptsScript.erase( 0, endSub );
00159                         }
00160                         int intReturn = atoi(cSize.c_str());
00161                         std::cout << "SZ: "<<intReturn <<std::endl;
00162                         equalIndex = conceptsScript.find("=", 0);
00163                         if( intReturn>0 )
00164                                 allOK &= addUserConcept(concept, intReturn);
00165                         else
00166                                 allOK = false;
00167                 }
00168                 return allOK;
00169         }
00170 
00171         /*
00172         * Add a concept to all the environments
00173         * @param theConceptName Is the name of the new concept
00174         * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances
00175         * @return Returns true if successful insert of concept, false otherwise
00176         */
00177         bool OutlineModelManager :: addUserConcept(std::string theConceptName, int conceptSize)
00178         {
00179                 bool allOK = axesEnvironment->addConcept(theConceptName, conceptSize);
00180                 allOK &= imagesSectionEnvironment->addConcept(theConceptName, conceptSize);
00181                 allOK &= imageSourceEnvironment->addConcept(theConceptName, conceptSize);
00182                 allOK &= outlinesEnvironment->addConcept(theConceptName, conceptSize);
00183                 return allOK;
00184         }
00185 
00192         std::vector<NameWrapper *> OutlineModelManager :: getActualInstantOutlines ()
00193         {
00194                 return actualInstantWrapping->getOutlinesNamesVector();
00195         }
00196 
00197 //EED01
00198         void OutlineModelManager :: ChangeContourOfList(std::string keyName, Instant *instant)
00199         {
00200                 int ispartofstaticlist = IsPartOfStaticList(keyName);
00201                 if (ispartofstaticlist==-1)
00202                 {
00203                         staticContourLst.push_back(  this->outlinesEnvironment->getThingByName(keyName)  );
00204                         this->outlinesEnvironment->removeThingFromInstant(keyName, instant);
00205                 } else {
00206                         ContourThing **contourthing  = staticContourLst[ispartofstaticlist];
00207                         this->outlinesEnvironment->addInstantToThing    ( keyName , instant );
00208                         staticContourLst.erase( staticContourLst.begin()+ispartofstaticlist );
00209                 }
00210         }
00211 
00212 
00219         std::vector<ContourThing**>  OutlineModelManager :: getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate)
00220         {
00221                 std::vector<std::string> kNamesVector;
00222                 std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
00223                 outlinesEnvironment->getThings( kNamesVector, outlinesVector, anInstant);
00224 
00225 //EED01
00226                 int i,sizeStaticContourLst =  staticContourLst.size();
00227                 for ( i=0 ; i<sizeStaticContourLst ; i++ )
00228                 {
00229                         ContourThing **contourthing  = staticContourLst[i];
00230                         outlinesVector.push_back( contourthing );
00231                         kNamesVector.push_back( (*contourthing)->getName() );
00232                 }// for i
00233 
00234                 if (ifAnnotate)
00235                 {
00236                         annotateOutlinesWrap(kNamesVector, outlinesVector);
00237                 }
00238                 return outlinesVector;
00239         }
00240 
00241 //EED01
00242         std::vector<std::string> OutlineModelManager :: GetLstNameThingsStatic()
00243         {
00244                 std::vector<std::string> result;
00245                 int i,sizeStaticContourLst =  staticContourLst.size();
00246                 for ( i=0 ; i<sizeStaticContourLst ; i++ )
00247                 {
00248                         ContourThing **contourthing  = staticContourLst[i];
00249                         result.push_back( (*contourthing)->getName() );
00250                 }// for i
00251                 return result;
00252         }
00253 
00254         std::vector<std::string> OutlineModelManager :: GetLstNameThings()
00255         {
00256                 std::vector<std::string> kNamesVector;
00257                 std::vector<ContourThing **> outlinesVector; //= new std::vector<ContourThing **>();
00258                 std::vector<Instant *> lstInstants = getOutlineInstants();
00259                 int i,sizeLstInstants = lstInstants.size();
00260                 Instant *instant;
00261                 for ( i=0 ; i<sizeLstInstants ; i++ )
00262                 {
00263                         instant = lstInstants[i];
00264                         outlinesEnvironment->getThings( kNamesVector, outlinesVector, instant);
00265                 } // for i
00266                 return kNamesVector;
00267         }
00268 
00269 
00275         std::vector<ContourThing*> OutlineModelManager :: getOutlinesFromGroup(std::string aGroupName)
00276         {
00277                 std::vector<ContourThing *> outlinesVector;
00278                 std::map< std::string,OutlineGroup * >::iterator iterP = outlineGroups.find(aGroupName);
00279                 if ( iterP != outlineGroups.end() )
00280                 {
00281                         std::vector<std::string> kNamesVector = iterP->second->getGroupOutlinesNames();
00282                         for(int i=0; i<kNamesVector.size();i++)
00283                         {
00284                                 ContourThing * outlineI = getOutlineByKeyName(kNamesVector[i]);
00285                                 outlinesVector.push_back(outlineI);
00286                         }
00287                 }
00288                 return outlinesVector;
00289         }
00290 
00296         bool OutlineModelManager :: addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup )
00297         {
00298         outlineGroups.insert(std::pair <std::string, OutlineGroup *> ( theOutlineName, theGroup ));
00299 //              std::map<std::string, OutlineGroup *> :: iterator iter = NULL;
00300                 std::map<std::string, OutlineGroup *> :: iterator iter;
00301                 iter = outlineGroups.find( theOutlineName );
00302                 bool ifAdded = iter->first.compare( theOutlineName ) == 0;
00303                 return ifAdded;
00304         }
00305         /*
00306         * Gets the an outline given the keyName used to be indexed in the outlines's environment
00307         * @param outKName Is the outline keyName to search
00308         * @return  The corresponding unique outline with the given key name
00309         */
00310         ContourThing* OutlineModelManager :: getOutlineByKeyName(std::string outKName)
00311         {
00312                 return *(outlinesEnvironment->getThingByName(outKName));
00313         }
00314 
00315         /*
00316         * Gets the an imageSourceThing given the keyName used to be indexed in the ImageSourceThing's environment
00317         * @param outKName Is the imageSourceThing keyName to search
00318         * @return  The corresponding unique outline with the given key name
00319         */
00320         ImageSourceThing* OutlineModelManager ::getImageSourceThingByKeyName(std::string iSeourceKName)
00321         {
00322                 return *(imageSourceEnvironment->getThingByName(iSeourceKName));
00323         }
00324 
00325         /*
00326         * Gets the an imageSectionThing given the keyName used to be indexed in the ImageSectionThing's environment
00327         * @param outISectionName Is the imageSectionThing keyName to search
00328         * @return  The corresponding unique outline with the given key name
00329         */
00330         ImageSectionThing* OutlineModelManager ::getImageSectionThingByKeyName(std::string iSectionName)
00331         {
00332                 return *(imagesSectionEnvironment->getThingByName(iSectionName));
00333         }
00334 
00335         /*
00336         * Creates an outlineThing with a given name, if no name is given it would have an automatic
00337         * @param aName The name for the outlineThing
00338                 * @return Returns the key name of the created outline, or ""if it wasn't created
00339         */
00340 //      bool OutlineModelManager :: createOutline(std::string aName, ContourThing * &theOutline)
00341         std::string  OutlineModelManager :: createOutline(manualBaseModel * model, std::vector<int> theInstantData, std::string aName)
00342         {
00343                 ContourThing * theOutline = new ContourThing ( model );
00344                 theOutline->setName(aName);
00345                 return addOutline( theOutline, new Instant( &theInstantData ) );
00346         }
00347 
00348         /*
00349         * Creates an axeThing with a given name
00350         * @param aDescription The description for the axeThing
00351         * @return Returns true if the creation of the axe was successful
00352         */
00353         //bool OutlineModelManager :: createAxe(std::string aDescription, AxeThing * &theAxe)
00354         bool  OutlineModelManager :: createAxe(std::string aDescription, Instant * theInstantData)
00355         {
00356                 AxeThing * theAxe = new AxeThing ();
00357                 theAxe->setDescription(aDescription);
00358                 return addAxe(theAxe, theInstantData);
00359         }
00360 
00361         /*
00362         * Creates an imageSourceThing with a given name
00363         * @param aSource The name for the imageSourceThing
00364         * @return Returns true if the creation of the imageSource was successful
00365         */
00366         //bool OutlineModelManager :: createImageSource(std::string aSource, ImageSourceThing * &imageSource)
00367         bool OutlineModelManager :: createImageSource(std::string aSource, Instant * theInstantData)
00368         {
00369 //              imageSource = new ImageSourceThing(aSource);
00370                 //return addImageSource(new ImageSourceThing(aSource), theInstantData);
00371                 return NULL;//***********************************************************************************************
00372         }
00373 
00374         /*
00375         * Creates an imageSectionThing with a given name
00376         * @param aSecImageData The name for the imageSectionThing
00377         * @return Returns true if the creation of the imageSection was successful
00378         */
00379         //bool OutlineModelManager :: createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection)
00380         bool OutlineModelManager :: createImageSection(std::string aSecImageData, Instant * theInstantData)
00381         {
00382                 //imageSection = new ImageSectionThing(aSecImageData);
00383 //              return addImageSection(new ImageSectionThing(aSecImageData), theInstantData);
00384                 return NULL;
00385         }
00386 
00387         /*
00388         * Adds an outlineThing
00389         * @param theOutline The outline/contour (thing)
00390         * @param theInstantData Is the instant for the outline to add
00391         * @return Returns true if the addition of the outline was successful
00392         */
00393         std::string OutlineModelManager :: addOutline( ContourThing * theOutline, Instant * theInstantData)
00394         {
00395                 std::string kName;
00396 
00397 // EED
00398 //              bool added  = keyGenerator.generateKeyOf("Outlines", outlinesEnvironment->getNumberOfThings(),kName);
00399 
00400                 counterIdKey++;
00401                 bool added = keyGenerator.generateKeyOf( "Outlines", counterIdKey , kName );
00402 
00403                 if( theOutline->getName().compare("")==0 )
00404                 {
00405                         theOutline->setName(kName);
00406                 }
00407                 added &= outlinesEnvironment->addThingWithInstant(kName,theOutline, theInstantData);
00408                 if( added )
00409                         return kName;
00410                 else
00411                         return "";
00412         }
00413 
00414 
00415         int OutlineModelManager::IsPartOfStaticList(std::string ss)
00416         {
00417                 int iBack=-1;
00418                 int i, size = staticContourLst.size();
00419                 for( i=0 ; i<size ; i++ )
00420                 {
00421                         ContourThing **contourthing  = staticContourLst[i];
00422                         if ((*contourthing)->getName() == ss)
00423                         {
00424                                 iBack=i;
00425                         } // getName() == ss
00426                 }
00427                 return iBack;
00428         }
00429 
00430 
00431         /*
00432         * Remove an outlineThing
00433         * @param theOutline The outline/contour (thing)
00434         */
00435         void OutlineModelManager :: removeOutline( std::string ss )
00436         {
00437                         outlinesEnvironment->removeThing( ss );
00438         }
00439 
00440 //EED01
00441         void OutlineModelManager :: removeAllOutlines()
00442         {
00443                 //
00444                 staticContourLst.clear();
00445 
00446                 //
00447                 std::vector< ContourThing **>  thingsVector;
00448                 outlinesEnvironment->getThingsOfEnvironment( &thingsVector );
00449                 int i,sizeThingVector = thingsVector.size();
00450                 for(i=0;i<sizeThingVector;i++)
00451                 {
00452                         ContourThing ** contourthing =  thingsVector[i];
00453                     removeOutline(  (*contourthing)->getName()   );
00454                 }
00455         }
00456 
00457 
00458         /*
00459         * Adds an axeThing
00460         * @param thaAxe The axe (thing)
00461         * @param theInstantData Is the instant for the axe to add
00462         * @return Returns true if the addition of the axe was successful
00463         */
00464         bool OutlineModelManager :: addAxe( AxeThing * theAxe , Instant * theInstantData)
00465         {
00466                 std::string kName;
00467                 bool added  = keyGenerator.generateKeyOf("Axes", axesEnvironment->getNumberOfThings(),kName);
00468                 added &= axesEnvironment->addThingWithInstant(kName,theAxe, theInstantData);
00469                 return added;
00470         }
00471 
00472         /*
00473         * Adds an imageSourceThing
00474         * @param imgageSource The image source (thing)
00475         * @param theInstantData Is the instant for the source to add
00476         * @return Returns true if the addition of the imageSource was successful
00477         */
00478         bool OutlineModelManager :: addImageSource(ImageSourceThing * imageSource, Instant * theInstantData)
00479         {
00480                 std::string kName;
00481                 bool added  = keyGenerator.generateKeyOf("Image Sources", imageSourceEnvironment->getNumberOfThings(),kName);
00482                 added &= imageSourceEnvironment->addThingWithInstant(kName,imageSource, theInstantData );
00483                 return added;
00484         }
00485 
00486         /*
00487         * Adds an imageSectionThing with a given name, if no name is given it would have an automatic
00488         * @param aName The imageSection (thing)
00489         * @param theInstantData Is the instant for the imageSection to add
00490         * @return Returns true if the addition of the imageSection was successful
00491         */
00492         bool OutlineModelManager :: addImageSection(ImageSectionThing * imageSection, Instant * theInstantData)
00493         {
00494                 std::string kName;
00495                 bool added  = keyGenerator.generateKeyOf("Image Sections", imagesSectionEnvironment->getNumberOfThings(),kName);
00496                 added &= imagesSectionEnvironment->addThingWithInstant(kName, imageSection, theInstantData);
00497                 return added;
00498         }
00499 
00500         /*
00501         * Annotates an outline keyname at the actual instant
00502         * @param kOutlineName The key name to annotate
00503         * @param theRealName The real name asigned to the outline
00504         */
00505         void OutlineModelManager :: annotateOutlineWrap(std::string kOutlineName, std::string theRealName)
00506         {
00507                 actualInstantWrapping -> addOutlineName(kOutlineName, theRealName);
00508         }
00509 
00510         /*
00511         * Annotates a set of outline keynames-real names wrapping at the actual instant
00512         * @param kNamesVector The key names vector to annotate
00513         * @param theOutlinesVector The outlines pointers vector to get the real names from
00514         */
00515         void OutlineModelManager :: annotateOutlinesWrap(std::vector<std::string> kNamesVector, std::vector<ContourThing **> theOutlinesVector)
00516         {
00517                 actualInstantWrapping ->clean();
00518                 for(int i=0; i<kNamesVector.size(); i++)
00519                 {
00520                         ContourThing * anOutline = *theOutlinesVector[i];
00521                         actualInstantWrapping -> addOutlineName( kNamesVector[i], anOutline->getName() );
00522                 }
00523         }
00524 
00525         /*
00526         * Annotates the actual outline keyName-real name wrapping at the actual instant
00527         * @param actualKeyOutline The key name to annotate
00528         * @param theRealName The real name asigned to the actual outline
00529         */
00530         void OutlineModelManager :: annotateActualOutlineWrap(std::string actualKeyOutline, std::string theRealName)
00531         {
00532                 actualInstantWrapping -> setActualOutline(actualKeyOutline, theRealName);
00533         }
00534 
00535         /*
00536         * Annotate the actual axe keyName-real name wrapping at the actual instant
00537         * @param actualKeyAxe The key name to annotate
00538         * @param theRealName The real name asigned to the actual axe
00539         */
00540         void OutlineModelManager :: annotateActualAxeWrap(std::string actualKeyAxe, std::string theRealName)
00541         {
00542                 actualInstantWrapping -> setActualAxeWrap(actualKeyAxe, theRealName);
00543         }
00544 
00545         /*
00546         * Annotate the annotateActualSection image keyName-real name wrapping at the actual instant
00547         * @param actualKeyImage The key name to annotate
00548         * @param theRealName The real name asigned to the annotateActualSection
00549         */
00550         void OutlineModelManager :: annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
00551         {
00552                 actualInstantWrapping -> setActualSectionImageNamesWrapp(actualKeyImage, theRealName);
00553         }
00554 
00555         /*
00556         * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant
00557         * @param actualKeyImage The key name to annotate
00558         * @param theRealName The real name asigned to the annotateActualSource
00559         */
00560         void OutlineModelManager :: annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName)//---BORRAR...
00561         {
00562                 actualInstantWrapping -> setActualSourceImageNamesWrapp(actualKeyImage, theRealName);
00563         }
00564 
00565 
00566         /*
00567         * Sets the actual instant and manage the search of the corresponding elements with the specified instant in all the enviornments
00568         * @param newActualInstantData Is the instant data
00569         */
00570         void OutlineModelManager :: setInstant(Instant * newActualInstantData)
00571         {
00572                 actualInstant = newActualInstantData;
00573                 updateToActualInstant();
00574         }
00575 
00576         Instant* OutlineModelManager :: getInstant()
00577         {
00578                 return actualInstant;
00579         }
00580 
00581         /*
00582         * Gets the an axe with a given keyName
00583         * @axeKName The axe keyName for searching in the axes environment
00584         * @return The corresponding axe
00585         */
00586         AxeThing * OutlineModelManager :: getAxeByKeyName(std::string axeKName)
00587         {
00588                 return *axesEnvironment->getThingByName(axeKName);
00589         }
00590 
00591         /*
00592         * Gets the instants of a specific outline
00593         * @param thekName Is the name of the outline
00594         * @return The instants set
00595         */
00596         std::vector<Instant *> OutlineModelManager :: getOutlineInstantsByName(std::string thekName)
00597         {
00598                 return *outlinesEnvironment->getInstantsOfThing(thekName);
00599         }
00600 
00601         /*
00602         * Gets all instants outlines
00603         * @return The instants set
00604         */
00605         std::vector<Instant *> OutlineModelManager :: getOutlineInstants()
00606         {
00607                 return *outlinesEnvironment->getExistingInstants();
00608         }
00609 
00610 
00611 
00612         /*
00613         * Includes an instant to the specified axe
00614         * @param outKName Is outline key name
00615         * @param anInstantData Is the instant data
00616         * @return Returns if the insertion was successful or not
00617         */
00618         bool OutlineModelManager :: includeOutlineInstant(std::string outKName,Instant * anInstantData)
00619         {
00620                 return outlinesEnvironment->addInstantToThing(outKName,anInstantData);
00621         }
00622 
00623         /*
00624         * Includes an instant to the specified axe
00625         * @param axeKName Is axe key name
00626         * @param anInstantData Is the instant data
00627         * @return Returns if the insertion was successful or not
00628         */
00629         bool OutlineModelManager :: includeAxeInstant(std::string axeKName,Instant * anInstantData)
00630         {
00631                 return axesEnvironment->addInstantToThing( axeKName,anInstantData );
00632         }
00633 
00634         /*
00635         * Includes an instant to the specified image section
00636         * @param imaKName Is the image section key name
00637         * @param anInstantData Is the instant data
00638         * @return Returns if the insertion was successful or not
00639         */
00640         bool OutlineModelManager :: includeImageSectionInstant(std::string imaKName,Instant * anInstantData)
00641         {
00642                 return imagesSectionEnvironment->addInstantToThing( imaKName,anInstantData );
00643         }
00644 
00645         /*
00646         * Includes an instant to the specified image source
00647         * @param imaKName Is the image section key name
00648         * @param anInstantData Is the instant data
00649         * @return Returns if the insertion was successful or not
00650         */
00651         bool OutlineModelManager :: includeImageSourceInstant(std::string imaKName,Instant * anInstantData)
00652         {
00653                 return imageSourceEnvironment->addInstantToThing( imaKName,anInstantData );
00654         }
00655 
00656         /*
00657         *       Method that retorns the name of each concept and the size of it.
00658         *       @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts
00659         *       @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts
00660         */
00661         void OutlineModelManager :: getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect)
00662         {
00663                 if( outlinesEnvironment != NULL )
00664                 {
00665                         //if (outlinesEnvironment->getNumberOfThings()>0)
00666                                 outlinesEnvironment->getConceptsInformation(conceptNameVect, conceptSizeVect);
00667                 }
00668         }
00669 
00670 
00671         /*
00672         * Gets the contourWorspace
00673         * @return Returns the workspace
00674         */
00675         ContourWorkspace * OutlineModelManager :: getContourWorkspace()
00676         {
00677                 return workSpace;
00678         }
00679 
00680 
00681         /*
00682         * Cleans the outline model manager and its dependencies
00683         */
00684         void OutlineModelManager :: clean()
00685         {
00686                 /*axesEnvironment->clean();
00687                 imagesSectionEnvironment->clean();
00688                 imageSourceEnvironment->clean();
00689                 outlinesEnvironment->clean();*/
00690                 outlineGroups.clear();
00691                 actualInstantWrapping->clean();
00692                 keyGenerator.clear();
00693                 //workSpace->clear();
00694         }
00695 
00696         /*
00697         * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model
00698         */
00699         void OutlineModelManager :: updateToActualInstant()
00700         {
00701                 Instant * longInstant = actualInstant;
00702                 /*Instant * mediumInstant = new Instant();
00703                 Instant * shortInstant = new Instant();
00704                 std::vector<int>* theInstant = longInstant->getInstant();
00705                 for(int i=1; i<theInstant->size(); i++)
00706                 {
00707                         if (i>=2)
00708                                 shortInstant->addConcept( (*theInstant)[i] );
00709                         mediumInstant->addConcept( (*theInstant)[i] );
00710                 }
00711 
00712                 //getting the sourceAtInstant
00713                 std::vector<std::string> kSourceVector;
00714                 std::vector<ImageSourceThing **> imSourceVector;
00715                 imageSourceEnvironment->getThings(kSourceVector, imSourceVector, shortInstant);
00716                 annotateActualSourceImageWrap(kSourceVector[0], (**imSourceVector[0]).getSourceImage());
00717 
00718         //getting the aAxeAtInstant
00719                 std::vector<std::string> kAxeVector;
00720                 std::vector<AxeThing **> axesVector;
00721                 axesEnvironment->getThings(kAxeVector, axesVector, mediumInstant);
00722                 if ( !kAxeVector.empty() )
00723                         annotateActualAxeWrap(kAxeVector[0], (**axesVector[0]).getDescription());
00724 
00725                 //getting the sectionAtInstant
00726                 std::vector<std::string> kSectionVector;
00727                 std::vector<ImageSectionThing **> imSectionVector;
00728                 imagesSectionEnvironment->getThings(kSectionVector, imSectionVector, longInstant); if ( !kSectionVector.empty() )
00729             //annotateActualSectionImageWrap(kSectionVector[0], (**imSectionVector[0]).getImageData());
00730                 */
00731 
00732                 //getting the outlines
00733 
00734                 std::vector<ContourThing ** > vect = getOutlinesAtInstant( longInstant );
00735 
00736         }
00737 
00738         /*
00739         * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments.
00740         * @return Returns true if successful insert of the automatic concepts, false otherwise
00741         */
00742         bool OutlineModelManager :: setAutomaticConcepts()
00743         {
00744                 axeConcept = "Axe";
00745                 axeDepthConcept = "Axe Depth";
00746                 int axeC_size = 10;
00747                 int axeDepthC_size = INT_MAX;
00748 
00749                 bool allOK = axesEnvironment->addConcept(axeConcept, axeC_size);
00750                 allOK &= imagesSectionEnvironment->addConcept(axeConcept, axeC_size);
00751                 allOK &= outlinesEnvironment->addConcept(axeConcept, axeC_size);
00752 
00753                 allOK &= imagesSectionEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
00754                 allOK &= outlinesEnvironment->addConcept(axeDepthConcept, axeDepthC_size);
00755 /*
00756                 allOK &= keyGenerator.addKeyThing("Axes", "Axe");
00757                 allOK &= keyGenerator.addKeyThing("Image Sources", "Image source");
00758                 allOK &= keyGenerator.addKeyThing("Image Sections", "Image section");
00759                 allOK &= keyGenerator.addKeyThing("Outlines", "Outline");*/
00760 
00761                 return allOK;
00762         }
00763 
00764 
00765         std::string OutlineModelManager :: createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData )
00766         {
00767                 manualBaseModel * manModelContour  = getOutlineByKeyName( anExistingKName )->getModel()->Clone();
00768                 return createOutline( manModelContour, instantNoTouchData );
00769         }
00770 
00771         void OutlineModelManager::SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing )
00772         {
00773                 std::vector< Instant * > *lstInstants;
00774                 lstInstants = outlinesEnvironment->getInstantsOfThing( nameThing );
00775                 Instant *instant = (*lstInstants)[0];
00776                 std::vector<int> *vecInst =instant->getInstant();
00777                 int i,sizeVecInst = vecInst->size();
00778                 fprintf(pFile,"Instant ");
00779                 for ( i=0 ; i<sizeVecInst ; i++ )
00780                 {
00781                         fprintf(pFile,"%d ",(*vecInst)[i]);
00782                 }
00783                 fprintf(pFile,"\n");
00784                 ContourThing *contourthing = *outlinesEnvironment->getThingByName(nameThing);
00785                 contourthing->getModel()->Save(pFile);
00786                 contourthing->getModel()->SaveData(pFileData);
00787         }
00788 

Generated on Wed Jun 27 23:28:33 2012 for creaContours_lib by  doxygen 1.5.7.1