00001 #ifndef __OTULINE_MODEL_MANAGER__ 00002 #define __OTULINE_MODEL_MANAGER__ 00003 00004 00005 //------------------------------------------------------------------------------------------------------------ 00006 // Includes 00007 //------------------------------------------------------------------------------------------------------------ 00008 #include <stdio.h> 00009 #include <stdlib.h> 00010 #include <iostream> 00011 #include <sstream> 00012 #include <map> 00013 #include <vector> 00014 #include <string> 00015 00016 00017 #include "ContourThing.h" 00018 #include "AxeThing.h" 00019 #include "ImageSourceThing.h" 00020 #include "ImageSectionThing.h" 00021 #include "InstantMembersNameList.h" 00022 #include "OutlineGroup.h" 00023 #include "ContourWorkspace.h" 00024 #include "CommandsHandler.h" 00025 #include "InstantMembersNameList.h" 00026 #include "PrefixMaxKeyGenerator.h" 00027 00028 //#include "../kernel_Environment/InstantHandler.h" //Is not working 00029 //#include "../kernel_Environment/Instant.h" //Is included in the SomeEnvironment template 00030 //#include "../kernel_Environment/SomeEnvironment.h" 00031 #include "SomeEnvironment.h" 00032 00033 class ContourWorkspace; 00034 00035 class OutlineModelManager{ 00036 00037 //------------------------------------------------------------------------------------------------------------ 00038 // Constructors & Destructors 00039 //------------------------------------------------------------------------------------------------------------ 00040 public: 00041 00042 /* 00043 * Creates the outline manager 00044 */ 00045 OutlineModelManager( SomeEnvironment<ImageSourceThing *>* imSourceEnv, SomeEnvironment<ImageSectionThing *>* imSectionEnv, SomeEnvironment<AxeThing *>* axesEnv, SomeEnvironment<ContourThing *>* contourEnv ); 00046 00047 00048 /* 00049 * Destroys the outline manager 00050 */ 00051 ~OutlineModelManager(); 00052 00053 //------------------------------------------------------------------------------------------------------------ 00054 // Methods 00055 //------------------------------------------------------------------------------------------------------------ 00056 00057 /* 00058 * Creates and sets a workSpace object 00059 * @return Retourns the created workSpace 00060 */ 00061 ContourWorkspace * createWorkSpace(); 00062 00063 /* 00064 * Sets the workSpace object 00065 * @param aWorkSpace The workSpace to set 00066 */ 00067 void setWorkSpace( ContourWorkspace * aWorkSpace ); 00068 00069 /* 00070 * Executes a command over an outline object 00071 * @param imaKName Is the key name of the outline 00072 * @param theCommand Is the command to execute 00073 * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false. 00074 */ 00075 bool executeCommand_OutlineModel(std::string outKName, CommandObject * theCommand, bool fromRegistration); 00076 00077 /* 00078 * Executes a command identifying which actions have to realize before executing it. 00079 * @param theCommand Is the command to execute 00080 * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false. 00081 */ 00082 bool executeCommand(CommandObject * theCommand, bool fromRegistration=false); 00083 00084 /* 00085 * Executes a command queue identifying which actions have to realize before executing it, starting in from the front of it. 00086 * @param executionQueue Is the command queue to execute 00087 * @param fromRegistration Indicates if the execution is directed from the registration, by default comes from the GUI = false. 00088 */ 00089 bool executeCommandsQueue(std::deque<CommandObject *> executionQueue, bool fromRegistration=false); 00090 00091 /* 00092 * Sets the concepts of the environments and includes the concepts managed by the program 00093 * @conceptsScript Is the script for with the concepts descrition 00094 * @return Returns true if successful insert of the given concepts, false otherwise 00095 */ 00096 bool setUserConcepts(std::string conceptsScript); 00097 00098 /* 00099 * Add a concept to all the environments 00100 * @param theConceptName Is the name of the new concept 00101 * @param conceptSize Is the size of the concept, that represent the ammount of concept posible instances 00102 * @return Returns true if successful insert of concept, false otherwise 00103 */ 00104 bool addUserConcept( std::string theConceptName, int conceptSize ); 00105 00112 std::vector<NameWrapper *> getActualInstantOutlines (); 00113 00120 std::vector<ContourThing**> getOutlinesAtInstant(Instant * anInstant, bool ifAnnotate = true); 00121 00126 std::vector<std::string> GetLstNameThings(); 00127 00128 std::vector<std::string> GetLstNameThingsStatic(); 00129 00130 00136 std::vector<ContourThing*> getOutlinesFromGroup(std::string aGroupName); 00137 00144 bool addOutlinesGroup( std::string theOutlineName, OutlineGroup * theGroup ); 00145 00146 /* 00147 * Gets the an outline given the keyName used to be indexed in the outlines's environment 00148 * @param outKName Is the outline keyName to search 00149 * @return The corresponding unique outline with the given key name 00150 */ 00151 ContourThing* getOutlineByKeyName(std::string outKName); 00152 00153 /* 00154 * Gets the an imageSourceThing given the keyName used to be indexed in the ImageSourceThing's environment 00155 * @param outKName Is the imageSourceThing keyName to search 00156 * @return The corresponding unique outline with the given key name 00157 */ 00158 ImageSourceThing* getImageSourceThingByKeyName(std::string iSeourceKName); 00159 00160 /* 00161 * Gets the an imageSectionThing given the keyName used to be indexed in the ImageSectionThing's environment 00162 * @param outISectionName Is the imageSectionThing keyName to search 00163 * @return The corresponding unique outline with the given key name 00164 */ 00165 ImageSectionThing* getImageSectionThingByKeyName(std::string iSectionName); 00166 00167 /* 00168 * Creates an outlineThing with a given name, if no name is given it would have an automatic 00169 * @param aName The name for the outlineThing 00170 * @return Returns the key name of the created outline, or ""if it wasn't created 00171 */ 00172 //bool createOutline(std::string aName, ContourThing * &theOutline); 00173 std::string createOutline(manualBaseModel * model, std::vector<int> theInstantData, std::string aName = "" ); 00174 00175 /* 00176 * Creates an axeThing with a given name 00177 * @param aDescription The description for the axeThing 00178 * @return Returns true if the creation of the axe was successful 00179 */ 00180 //bool createAxe(std::string aDescription,AxeThing * &theAxe); 00181 bool createAxe(std::string aDescription, Instant * theInstantData); 00182 00183 /* 00184 * Creates an imageSourceThing with a given name 00185 * @param aName The name for the imageSourceThing 00186 * @return Returns true if the creation of the imageSource was successful 00187 */ 00188 //bool createImageSource(std::string aName, ImageSourceThing * &imageSource); 00189 bool createImageSource(std::string aSource, Instant * theInstantData); 00190 00191 /* 00192 * Creates an imageSectionThing with a given name 00193 * @param aSecImageData The name for the imageSectionThing 00194 * @return Returns true if the creation of the imageSection was successful 00195 */ 00196 //bool createImageSection(std::string aSecImageData, ImageSectionThing * &imageSection); 00197 bool createImageSection(std::string aSecImageData, Instant * theInstantData); 00198 00199 /* 00200 * Adds an outlineThing 00201 * @param theOutline The outline/contour (thing) 00202 * @param theInstantData Is the instant for the outline to add 00203 * @return Returns the key name of the created outline, or ""if it wasn't created 00204 */ 00205 std::string addOutline(ContourThing * theOutline, Instant * theInstantData); 00206 00207 /* 00208 * Remove an outlineThing 00209 * @param theOutline The outline/contour (thing) 00210 */ 00211 void removeOutline( std::string ss ); 00212 00213 /* 00214 * Adds an axeThing 00215 * @param thaAxe The axe (thing) 00216 * @param theInstantData Is the instant for the axe to add 00217 * @return Returns true if the addition of the axe was successful 00218 */ 00219 bool addAxe( AxeThing * thaAxe, Instant * theInstantData); 00220 00221 /* 00222 * Adds an imageSourceThing 00223 * @param imgageSource The image source (thing) 00224 * @param theInstantData Is the instant for the source to add 00225 * @return Returns true if the addition of the imageSource was successful 00226 */ 00227 bool addImageSource(ImageSourceThing * imageSource, Instant * theInstantData); 00228 00229 /* 00230 * Adds an imageSectionThing with a given name, if no name is given it would have an automatic 00231 * @param aName The imageSection (thing) 00232 * @param theInstantData Is the instant for the imageSection to add 00233 * @return Returns true if the addition of the imageSection was successful 00234 */ 00235 bool addImageSection(ImageSectionThing * imageSection, Instant * theInstantData); 00236 00237 /* 00238 * Annotates an outline keyname at the actual instant 00239 * @param kOutlineName The key name to annotate 00240 * @param theRealName The real name asigned to the outline 00241 */ 00242 void annotateOutlineWrap(std::string kOutlineName, std::string theRealName); 00243 00244 /* 00245 * Annotates a set of outline keynames-real names wrapping at the actual instant 00246 * @param kNamesVector The key names vector to annotate 00247 * @param theOutlinesVector The outlines pointers vector to get the real names from 00248 */ 00249 void annotateOutlinesWrap(std::vector<std::string> keyNames, std::vector<ContourThing **> theOutlinesVector); 00250 00251 /* 00252 * Annotates the actual outline keyName-real name wrapping at the actual instant 00253 * @param actualKeyOutline The key name to annotate 00254 * @param theRealName The real name asigned to the actual outline 00255 */ 00256 void annotateActualOutlineWrap(std::string actualKeyOutline, std::string theRealName); 00257 00258 /* 00259 * Annotate the actual axe keyName-real name wrapping at the actual instant 00260 * @param actualKeyAxe The key name to annotate 00261 * @param theRealName The real name asigned to the actual axe 00262 */ 00263 void annotateActualAxeWrap(std::string actualKeyAxe, std::string theRealName); 00264 00265 /* 00266 * Annotate the annotateActualSection image keyName-real name wrapping at the actual instant 00267 * @param actualKeyImage The key name to annotate 00268 */ 00269 void annotateActualSectionImageWrap(std::string actualKeyImage, std::string theRealName);//---BORRAR... 00270 00271 /* 00272 * Annotate the annotateActualSource image keyName-real name wrapping at the actual instant 00273 * @param actualKeyImage The key name to annotate 00274 */ 00275 void annotateActualSourceImageWrap(std::string actualKeyImage, std::string theRealName);//---BORRAR... 00276 /* 00277 * Sets the actual instant and manage the search of the corresponding elements with the specified instant in all the enviornments 00278 * @param newActualInstantData Is the instant data 00279 */ 00280 void setInstant(Instant * newActualInstantData); 00281 00282 /* 00283 * Gets the an axe with a given keyName 00284 * @axeKName The axe keyName for searching in the axes environment 00285 * @return The corresponding axe 00286 */ 00287 AxeThing * getAxeByKeyName(std::string axeKName); 00288 00289 /* 00290 * Gets the instants of a specific outline 00291 * @param thekName Is the name of the outline 00292 * @return The instants set 00293 */ 00294 std::vector<Instant *> getOutlineInstantsByName(std::string thekName); 00295 00296 /* 00297 * Gets all instants outlines 00298 * @return The instants set 00299 */ 00300 std::vector<Instant *> getOutlineInstants(); 00301 00302 /* 00303 * Includes an instant to the specified axe 00304 * @param outKName Is outline key name 00305 * @param anInstantData Is the instant data 00306 * @return Returns if the insertion was successful or not 00307 */ 00308 bool includeOutlineInstant(std::string outKName,Instant * anInstantData); 00309 00310 /* 00311 * Includes an instant to the specified axe 00312 * @param axeKName Is axe key name 00313 * @param anInstantData Is the instant data 00314 * @return Returns if the insertion was successful or not 00315 */ 00316 bool includeAxeInstant(std::string axeKName,Instant * anInstantData); 00317 00318 /* 00319 * Includes an instant to the specified image section 00320 * @param imaKName Is the image section key name 00321 * @param anInstantData Is the instant data 00322 * @return Returns if the insertion was successful or not 00323 */ 00324 bool includeImageSectionInstant(std::string imaKName,Instant * anInstantData); 00325 00326 /* 00327 * Includes an instant to the specified image source 00328 * @param imaKName Is the image section key name 00329 * @param anInstantData Is the instant data 00330 * @return Returns if the insertion was successful or not 00331 */ 00332 bool includeImageSourceInstant(std::string imaKName,Instant * anInstantData); 00333 00334 /* 00335 * Method that retorns the name of each concept and the size of it. 00336 * @param conceptNameVect, Vector in which is disposed to be setted the name for each of the included concepts 00337 * @param conceptSizeVect, Vector in which is disposed to be setted the size for each of the included concepts 00338 */ 00339 void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect); 00340 00341 /* 00342 * Gets the contourWorspace 00343 * @return Returns the workspace 00344 */ 00345 ContourWorkspace * getContourWorkspace(); 00346 00347 /* 00348 * Gets the number of groups in the model management 00349 * @return Returns the size of 00350 */ 00351 int getGroupsCount(); 00352 00353 /* 00354 * Cleans the outline model manager and its dependencies 00355 */ 00356 void clean(); 00357 00358 void removeAllOutlines(); 00359 std::string createCopyContourOf( std::string anExistingKName, std::vector<int> &instantNoTouchData ); 00360 00361 void SaveThingName( FILE *pFile, FILE *pFileData, std::string nameThing ); 00362 00363 void ChangeContourOfList(std::string keyName, Instant *instant); 00364 int IsPartOfStaticList(std::string ss); 00365 00366 Instant* getInstant(); 00367 00368 private : 00369 00370 /* 00371 * Update the registered objects in the InstantMemebersNameList, is the one that really changes the instant in the model 00372 */ 00373 void updateToActualInstant(); 00374 00375 /* 00376 * Sets the automatic managed concepts including them in the environments. That are at the beginning of the instant vector for the corresponding environments. 00377 * @return Returns true if successful insert of the automatic concepts, false otherwise 00378 */ 00379 bool setAutomaticConcepts(); 00380 00381 00382 00383 00384 00385 //------------------------------------------------------------------------------------------------------------ 00386 // Constants 00387 //------------------------------------------------------------------------------------------------------------ 00388 00389 00390 00391 //------------------------------------------------------------------------------------------------------------ 00392 // Attributes 00393 //------------------------------------------------------------------------------------------------------------ 00394 00395 00396 private: 00397 00398 /* 00399 * Represents the keyName of the actual gruop in the map of gruops 00400 */ 00401 std::string actualGruopID; 00402 00403 /* 00404 * Represents the environment instant iterator of axes 00405 */ 00406 // InstantHandler<AxeThing *> * axesITER; 00407 00408 /* 00409 * Represents the environment of axes 00410 */ 00411 SomeEnvironment<AxeThing *>* axesEnvironment; 00412 00413 /* 00414 * Represents the environment instant iterator of section images 00415 */ 00416 // InstantHandler<ImageSectionThing *> * sectionITER; 00417 00418 /* 00419 * Represents the environment of section images 00420 */ 00421 SomeEnvironment<ImageSectionThing *>* imagesSectionEnvironment; 00422 00423 /* 00424 * Represents the environment instant iterator of source's images (Generally a complete volume data per image) 00425 */ 00426 // InstantHandler<ImageSourceThing *> * imageITER; 00427 00428 /* 00429 * Represents the environment of source images (Generally a complete volume data per image) 00430 */ 00431 SomeEnvironment<ImageSourceThing *>* imageSourceEnvironment; 00432 00433 /* 00434 * Represents the environment instant iterator of outlines (outlines) 00435 */ 00436 // InstantHandler<ContourThing *> * outlinesITER; 00437 00438 /* 00439 * Represents the environment of outlines (outlines) 00440 */ 00441 SomeEnvironment<ContourThing *>* outlinesEnvironment; 00442 00443 /* 00444 * Represents the table of outlines groups 00445 */ 00446 std::map< std::string,OutlineGroup * > outlineGroups; 00447 00448 /* 00449 * Represents the workspace 00450 */ 00451 ContourWorkspace * workSpace; 00452 00453 /* 00454 * Represents the actual instant members list wrrapping (keyName, realName) of objects 00455 */ 00456 InstantMembersNameList * actualInstantWrapping; 00457 00458 /* 00459 * Represents a flag indicating if the actualSourceImage has to be changed when changed instant 00460 */ 00461 bool changeSourceImage; 00462 00463 int counterIdKey; 00464 PrefixMaxKeyGenerator keyGenerator; 00465 00466 00467 /*const*/std::string axeConcept /*= "Axe"*/; 00468 /*const*/std::string axeDepthConcept /*= "Axe Depth"*/; 00469 00470 Instant * actualInstant; 00471 00472 //EED 00473 std::vector<ContourThing **> staticContourLst; 00474 00475 }; 00476 #endif