1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOMEDSImpl_Study.cxx
23 // Author : Sergey RUIN
26 #include "SALOMEDSImpl_Study.hxx"
31 #include "DF_Application.hxx"
32 #include "DF_ChildIterator.hxx"
34 #include "SALOMEDSImpl_ChildNodeIterator.hxx"
35 #include "SALOMEDSImpl_Attributes.hxx"
36 #include "SALOMEDSImpl_UseCaseIterator.hxx"
37 #include "SALOMEDSImpl_AttributeReference.hxx"
38 #include "SALOMEDSImpl_StudyHandle.hxx"
39 #include "SALOMEDSImpl_Tool.hxx"
40 #include "SALOMEDSImpl_IParameters.hxx"
41 #include "SALOMEDSImpl_ScalarVariable.hxx"
45 #define DIRECTORYID 16661
46 #define FILELOCALID 26662
47 #define FILEID "FILE: "
48 #define VARIABLE_SEPARATOR ':'
49 #define OPERATION_SEPARATOR '|'
52 //============================================================================
53 /*! Function : SALOMEDSImpl_Study
54 * Purpose : SALOMEDSImpl_Study constructor
56 //============================================================================
57 SALOMEDSImpl_Study::SALOMEDSImpl_Study(const DF_Document* doc,
58 const string& study_name)
61 _doc = (DF_Document*)doc;
67 _useCaseBuilder = new SALOMEDSImpl_UseCaseBuilder(_doc);
68 _builder = new SALOMEDSImpl_StudyBuilder(this);
69 _cb = new SALOMEDSImpl_Callback(_useCaseBuilder);
70 //Put on the root label a StudyHandle attribute to store the address of this object
71 //It will be used to retrieve the study object by DF_Label that belongs to the study
72 SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this);
76 //============================================================================
77 /*! Function : ~SALOMEDSImpl_Study
78 * Purpose : SALOMEDSImpl_Study destructor
80 //============================================================================
81 SALOMEDSImpl_Study::~SALOMEDSImpl_Study()
85 delete _useCaseBuilder;
88 //============================================================================
89 /*! Function : GetPersistentReference
90 * Purpose : Get persistent reference of study (idem URL())
92 //============================================================================
93 string SALOMEDSImpl_Study::GetPersistentReference()
98 //============================================================================
99 /*! Function : GetTransientReference
100 * Purpose : Get IOR of the Study (registred in Document in doc->Root)
102 //============================================================================
103 string SALOMEDSImpl_Study::GetTransientReference()
108 SALOMEDSImpl_AttributeIOR* Att;
109 DF_Label _lab = _doc->Root();
110 if ((Att=(SALOMEDSImpl_AttributeIOR*)_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
114 _errorCode = "IOR is empty";
120 void SALOMEDSImpl_Study::SetTransientReference(const string& theIOR)
124 SALOMEDSImpl_AttributeStudyProperties* aProp = GetProperties();
125 int aLocked = aProp->IsLocked();
126 if (aLocked) aProp->SetLocked(false);
128 // Assign the value of the IOR in the study->root
129 SALOMEDSImpl_AttributeIOR::Set(_doc->Main().Root(), theIOR);
131 if (aLocked) aProp->SetLocked(true);
134 //============================================================================
135 /*! Function : IsEmpty
136 * Purpose : Detect if study is empty
138 //============================================================================
139 bool SALOMEDSImpl_Study::IsEmpty()
142 if (!_doc) return true;
143 return _doc->IsEmpty();
146 //============================================================================
147 /*! Function : FindComponent
148 * Purpose : Find a Component with ComponentDataType = aComponentName
150 //============================================================================
151 SALOMEDSImpl_SComponent SALOMEDSImpl_Study::FindComponent (const string& aComponentName)
156 SALOMEDSImpl_SComponentIterator itcomp = NewComponentIterator();
157 SALOMEDSImpl_SComponent compo;
159 for (; itcomp.More(); itcomp.Next()) {
160 SALOMEDSImpl_SComponent SC = itcomp.Value();
161 name = SC.ComponentDataType();
162 if(aComponentName == name) {
170 _errorCode = "No component was found";
176 //============================================================================
177 /*! Function : FindComponentID
178 * Purpose : Find a Component from it's ID
180 //============================================================================
181 SALOMEDSImpl_SComponent SALOMEDSImpl_Study::FindComponentID(const string& aComponentID)
185 // Iterate on each components defined in the study
186 // Get the component ID and compare with aComponentID
189 SALOMEDSImpl_SComponent compo;
191 SALOMEDSImpl_SComponentIterator itcomp = NewComponentIterator();
192 for (; itcomp.More(); itcomp.Next()) {
193 SALOMEDSImpl_SComponent SC = itcomp.Value();
195 if(aComponentID == ID)
204 _errorCode = "No component was found";
211 //============================================================================
212 /*! Function : FindObject
213 * Purpose : Find an Object with SALOMEDSImpl_Name = anObjectName
215 //============================================================================
216 SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObject(const string& anObjectName)
220 // Iterate to all components defined in the study
221 // After testing the component name, iterate in all objects defined under
222 // components (function _FindObject)
224 SALOMEDSImpl_SObject RefSO;
226 SALOMEDSImpl_SComponentIterator it = NewComponentIterator();
227 for (; it.More();it.Next()){
230 SALOMEDSImpl_SComponent SC = it.Value();
231 if (SC.GetName() == anObjectName)
237 if (!_find) RefSO = _FindObject(SC, anObjectName, _find);
240 if(!RefSO) _errorCode = "No object was found";
244 //============================================================================
245 /*! Function : FindObjectID
246 * Purpose : Find an Object with ID = anObjectID
248 //============================================================================
249 SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectID(const string& anObjectID)
252 SALOMEDSImpl_SObject so;
254 // Convert aSO->GetID in DF_Label.
255 DF_Label Lab = DF_Label::Label(_doc->Main(), anObjectID, false);
258 _errorCode = "No label was found by ID";
261 return GetSObject(Lab);
265 //============================================================================
266 /*! Function : CreateObjectID
267 * Purpose : Creates an Object with ID = anObjectID
269 //============================================================================
270 SALOMEDSImpl_SObject SALOMEDSImpl_Study::CreateObjectID(const string& anObjectID)
273 SALOMEDSImpl_SObject so;
275 // Convert aSO->GetID in DF_Label.
276 DF_Label Lab = DF_Label::Label(_doc->Main(), anObjectID, true);
279 _errorCode = "Can not create a label";
282 return GetSObject(Lab);
286 //============================================================================
287 /*! Function : FindObjectByName
288 * Purpose : Find Objects with SALOMEDSImpl_Name = anObjectName in a Component
289 * : with ComponentDataType = aComponentName
291 //============================================================================
292 vector<SALOMEDSImpl_SObject> SALOMEDSImpl_Study::FindObjectByName(const string& anObjectName,
293 const string& aComponentName)
297 vector<SALOMEDSImpl_SObject> listSO;
299 SALOMEDSImpl_SComponent compo = FindComponent(aComponentName) ;
301 _errorCode = "Can not find the component";
305 // Iterate on each object and subobject of the component
306 // If objectName is found add it to the list of SObjects
309 string compoId = compo.GetID();
310 SALOMEDSImpl_ChildIterator it = NewChildIterator(compo);
311 for ( ; it.More(); it.Next() ) {
313 SALOMEDSImpl_SObject CSO = it.Value();
314 if ( CSO.GetName() == anObjectName ) {
316 listSO.push_back(CSO) ;
319 /* looks also for eventual children */
321 CSO = _FindObject( CSO, anObjectName, found ) ;
323 listSO.push_back(CSO) ;
332 //============================================================================
333 /*! Function : FindObjectIOR
334 * Purpose : Find an Object with IOR = anObjectIOR
336 //============================================================================
337 SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectIOR(const string& anObjectIOR)
341 SALOMEDSImpl_SObject aResult ;
343 // searching in the datamap for optimization
344 if (myIORLabels.find(anObjectIOR) != myIORLabels.end()) {
345 aResult = GetSObject(myIORLabels[anObjectIOR]);
346 // 11 oct 2002: forbidden attributes must be checked here
347 if (!aResult.GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID())) {
348 myIORLabels.erase(anObjectIOR);
349 aResult = SALOMEDSImpl_SObject();
353 if(!aResult) _errorCode = "No object was found";
357 //============================================================================
358 /*! Function : FindObjectByPath
359 * Purpose : Find an Object by its path = thePath
361 //============================================================================
362 SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectByPath(const string& thePath)
366 string aPath(thePath), aToken;
367 SALOMEDSImpl_SObject aSO;
368 int aLength = aPath.size();
369 bool isRelative = false;
371 if(aLength == 0) { //Empty path - return the current context
372 return GetSObject(_current);
375 if(aPath[0] != '/') //Relative path
378 DF_ChildIterator anIterator;
380 SALOMEDSImpl_AttributeName* anAttr;
383 if(_current.IsNull()) return aSO;
384 anIterator.Init(_current, false);
387 if(aPath.size() == 1 && aPath[0] == '/') { //Root
388 return GetSObject(_doc->Main());
390 anIterator.Init(_doc->Main(), false);
393 vector<string> vs = SALOMEDSImpl_Tool::splitString(aPath, '/');
394 for(int i = 0, len = vs.size(); i<len; i++) {
397 if(aToken.size() == 0) break;
399 for ( ; anIterator.More(); anIterator.Next() ) {
400 aLabel = anIterator.Value();
401 if((anAttr=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
402 if(anAttr->Value() == aToken) {
403 if(i == (len-1)) { //The searched label is found (no part of the path is left)
404 return GetSObject(aLabel);
407 anIterator.Init(aLabel, false);
415 if(!aSO) _errorCode = "No object was found";
419 //============================================================================
420 /*! Function : GetObjectPath
423 //============================================================================
424 string SALOMEDSImpl_Study::GetObjectPath(const SALOMEDSImpl_SObject& theObject)
430 _errorCode = "Null object";
434 string aName = theObject.GetName();
435 if(!aName.empty() && aName != "" ) {
440 SALOMEDSImpl_SObject aFather = theObject.GetFather();
442 aName = aFather.GetName();
443 if(!aName.empty() && aName != "") {
444 aValue = GetObjectPath(aFather);
445 aPath = aValue + aPath;
454 //============================================================================
455 /*! Function : GetObjectPathByIOR
458 //============================================================================
459 string SALOMEDSImpl_Study::GetObjectPathByIOR(const string& theIOR)
464 SALOMEDSImpl_SObject so = FindObjectIOR(theIOR);
466 _errorCode = "No SObject was found by IOR";
470 return GetObjectPath(so);
474 //============================================================================
475 /*! Function : SetContext
476 * Purpose : Sets the current context
478 //============================================================================
479 bool SALOMEDSImpl_Study::SetContext(const string& thePath)
482 if(thePath.empty()) {
483 _errorCode = "InvalidPath";
487 string aPath(thePath), aContext("");
488 bool isInvalid = false;
489 SALOMEDSImpl_SObject aSO;
491 if(aPath[0] != '/') { //Relative path
492 aContext = GetContext();
500 aSO = FindObjectByPath(aContext);
506 if(isInvalid || !aSO) {
507 _errorCode = "InvalidContext";
511 DF_Label aLabel = aSO.GetLabel();
512 if(aLabel.IsNull()) {
513 _errorCode = "InvalidContext";
517 _current = aLabel; //Set the current context
522 //============================================================================
523 /*! Function : GetContext
524 * Purpose : Gets the current context
526 //============================================================================
527 string SALOMEDSImpl_Study::GetContext()
531 if(_current.IsNull()) {
532 _errorCode = "InvaidContext";
535 SALOMEDSImpl_SObject so = GetSObject(_current);
536 return GetObjectPath(so);
539 //============================================================================
540 /*! Function : GetObjectNames
541 * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
543 //============================================================================
544 vector<string> SALOMEDSImpl_Study::GetObjectNames(const string& theContext)
548 vector<string> aResultSeq;
550 if (theContext.empty()) {
553 DF_Label aTmp = _current;
554 SetContext(theContext);
558 if (aLabel.IsNull()) {
559 _errorCode = "InvalidContext";
563 DF_ChildIterator anIter (aLabel, true); // iterate all subchildren at all sublevels
564 for (; anIter.More(); anIter.Next()) {
565 DF_Label aLabel = anIter.Value();
566 SALOMEDSImpl_AttributeName* aName;
567 if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
568 aResultSeq.push_back(aName->Value());
574 //============================================================================
575 /*! Function : GetDirectoryNames
576 * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
578 //============================================================================
579 vector<string> SALOMEDSImpl_Study::GetDirectoryNames(const string& theContext)
583 vector<string> aResultSeq;
585 if (theContext.empty()) {
588 DF_Label aTmp = _current;
589 SetContext(theContext);
593 if (aLabel.IsNull()) {
594 _errorCode = "InvalidContext";
598 DF_ChildIterator anIter (aLabel, true); // iterate first-level children at all sublevels
599 for (; anIter.More(); anIter.Next()) {
600 DF_Label aLabel = anIter.Value();
601 SALOMEDSImpl_AttributeLocalID* anID;
602 if ((anID=(SALOMEDSImpl_AttributeLocalID*)aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID()))) {
603 if (anID->Value() == DIRECTORYID) {
604 SALOMEDSImpl_AttributeName* aName;
605 if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
606 aResultSeq.push_back(aName->Value());
615 //============================================================================
616 /*! Function : GetFileNames
617 * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
619 //============================================================================
620 vector<string> SALOMEDSImpl_Study::GetFileNames(const string& theContext)
624 vector<string> aResultSeq;
626 if (theContext.empty()) {
629 DF_Label aTmp = _current;
630 SetContext(theContext);
634 if (aLabel.IsNull()) {
635 _errorCode = "InvalidContext";
639 DF_ChildIterator anIter (aLabel, true); // iterate all subchildren at all sublevels
640 for (; anIter.More(); anIter.Next()) {
641 DF_Label aLabel = anIter.Value();
642 SALOMEDSImpl_AttributeLocalID* anID;
643 if ((anID=(SALOMEDSImpl_AttributeLocalID*)aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID()))) {
644 if (anID->Value() == FILELOCALID) {
645 SALOMEDSImpl_AttributePersistentRef* aName;
646 if ((aName=(SALOMEDSImpl_AttributePersistentRef*)aLabel.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID()))) {
647 std::string aFileName = aName->Value();
648 if (aFileName.size() > 0)
649 aResultSeq.push_back(aFileName.substr(strlen(FILEID), aFileName.size()));
658 //============================================================================
659 /*! Function : GetComponentNames
660 * Purpose : method to get all components names
662 //============================================================================
663 vector<string> SALOMEDSImpl_Study::GetComponentNames(const string& theContext)
667 vector<string> aResultSeq;
668 DF_ChildIterator anIter(_doc->Main(), false); // iterate all subchildren at first level
669 for(; anIter.More(); anIter.Next()) {
670 DF_Label aLabel = anIter.Value();
671 SALOMEDSImpl_AttributeName* aName;
672 if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
673 aResultSeq.push_back(aName->Value());
679 //============================================================================
680 /*! Function : NewChildIterator
681 * Purpose : Create a ChildIterator from an SObject
683 //============================================================================
684 SALOMEDSImpl_ChildIterator SALOMEDSImpl_Study::NewChildIterator(const SALOMEDSImpl_SObject& aSO)
687 return SALOMEDSImpl_ChildIterator(aSO);
691 //============================================================================
692 /*! Function : NewComponentIterator
693 * Purpose : Create a SComponentIterator
695 //============================================================================
696 SALOMEDSImpl_SComponentIterator SALOMEDSImpl_Study::NewComponentIterator()
699 return SALOMEDSImpl_SComponentIterator(_doc);
703 //============================================================================
704 /*! Function : NewBuilder
705 * Purpose : Create a StudyBuilder
707 //============================================================================
708 SALOMEDSImpl_StudyBuilder* SALOMEDSImpl_Study::NewBuilder()
712 _builder->SetOnAddSObject(_cb);
713 _builder->SetOnRemoveSObject(_cb);
719 //============================================================================
721 * Purpose : get study name
723 //============================================================================
724 string SALOMEDSImpl_Study::Name()
730 //============================================================================
732 * Purpose : set study name
734 //============================================================================
735 void SALOMEDSImpl_Study::Name(const string& name)
741 //============================================================================
742 /*! Function : IsSaved
743 * Purpose : get if study has been saved
745 //============================================================================
746 bool SALOMEDSImpl_Study::IsSaved()
752 //============================================================================
753 /*! Function : IsSaved
754 * Purpose : set if study has been saved
756 //============================================================================
757 void SALOMEDSImpl_Study::IsSaved(bool save)
761 if(save) _doc->SetModified(false);
764 //============================================================================
765 /*! Function : IsModified
766 * Purpose : Detect if a Study has been modified since it has been saved
768 //============================================================================
769 bool SALOMEDSImpl_Study::IsModified()
773 // True if is modified
774 if (_doc && _doc->IsModified()) return true;
779 //============================================================================
781 * Purpose : get URL of the study (persistent reference of the study)
783 //============================================================================
784 string SALOMEDSImpl_Study::URL()
790 //============================================================================
792 * Purpose : set URL of the study (persistent reference of the study)
794 //============================================================================
795 void SALOMEDSImpl_Study::URL(const string& url)
800 /*jfa: Now name of SALOMEDS study will correspond to name of SalomeApp study
803 char *aName = (char*)tmp.ToCString();
804 char *adr = strtok(aName, "/");
808 adr = strtok(NULL, "/");
815 //============================================================================
816 /*! Function : _FindObject
817 * Purpose : Find an Object with SALOMEDSImpl_Name = anObjectName
819 //============================================================================
820 SALOMEDSImpl_SObject SALOMEDSImpl_Study::_FindObject(const SALOMEDSImpl_SObject& SO,
821 const string& theObjectName,
824 SALOMEDSImpl_SObject RefSO;
825 if(!SO) return RefSO;
827 // Iterate on each objects and subobjects of the component
828 // If objectName find, stop the loop and get the object reference
829 SALOMEDSImpl_AttributeName* anAttr;
831 string soid = SO.GetID();
832 DF_ChildIterator it(SO.GetLabel());
833 for (; it.More(); it.Next()){
836 if ((anAttr=(SALOMEDSImpl_AttributeName*)it.Value().FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
838 string Val(anAttr->Value());
839 if (Val == theObjectName)
841 RefSO = GetSObject(it.Value());
845 if (!_find) RefSO = _FindObject(GetSObject(it.Value()), theObjectName, _find);
851 //============================================================================
852 /*! Function : _FindObjectIOR
853 * Purpose : Find an Object with SALOMEDSImpl_IOR = anObjectIOR
855 //============================================================================
857 SALOMEDSImpl_Study::_FindObjectIOR(const SALOMEDSImpl_SObject& SO,
858 const string& theObjectIOR,
861 SALOMEDSImpl_SObject RefSO, aSO;
862 if(!SO) return RefSO;
864 // Iterate on each objects and subobjects of the component
865 // If objectName find, stop the loop and get the object reference
866 SALOMEDSImpl_AttributeIOR* anAttr;
868 DF_ChildIterator it(SO.GetLabel());
869 for (; it.More();it.Next()){
872 if ((anAttr=(SALOMEDSImpl_AttributeIOR*)it.Value().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID())))
874 string Val(anAttr->Value());
875 if (Val == theObjectIOR)
877 RefSO = GetSObject(it.Value());
881 aSO = GetSObject(it.Value());
882 if (!_find) RefSO = _FindObjectIOR(aSO, theObjectIOR, _find);
888 //============================================================================
889 /*! Function : _GetNoteBookAccessor
890 * Purpose : Find an Object with SALOMEDSImpl_IOR = anObjectIOR
892 //============================================================================
893 string SALOMEDSImpl_Study::_GetNoteBookAccessor(){
894 return string("notebook");
897 //============================================================================
898 /*! Function : _GetStudyVariablesScript
901 //============================================================================
902 string SALOMEDSImpl_Study::_GetStudyVariablesScript()
906 if(myNoteBookVars.empty())
909 dump += "####################################################\n";
910 dump += "## Begin of NoteBook variables section ##\n";
911 dump += "####################################################\n";
913 string set_method = _GetNoteBookAccessor()+".set(";
916 for(int i = 0 ; i < myNoteBookVars.size();i++ ) {
917 varName = myNoteBookVars[i]->Name();
918 varValue = myNoteBookVars[i]->SaveToScript();
919 dump+=set_method+"\""+varName+"\", "+varValue+")\n";
922 dump += "####################################################\n";
923 dump += "## End of NoteBook variables section ##\n";
924 dump += "####################################################\n";
929 //============================================================================
930 /*! Function : _GetNoteBookAccess
933 //============================================================================
934 string SALOMEDSImpl_Study::_GetNoteBookAccess()
936 string accessor = _GetNoteBookAccessor();
937 string notebook = "import salome_notebook\n";
938 notebook += accessor+" = salome_notebook."+accessor + "\n";
942 bool SALOMEDSImpl_Study::IsLocked()
945 return GetProperties()->IsLocked();
948 int SALOMEDSImpl_Study::StudyId()
954 void SALOMEDSImpl_Study::StudyId(int id)
960 void SALOMEDSImpl_Study::UpdateIORLabelMap(const string& anIOR,const string& anEntry)
963 DF_Label aLabel = DF_Label::Label(_doc->Main(), anEntry, true);
964 if (myIORLabels.find(anIOR) != myIORLabels.end()) myIORLabels.erase(anIOR);
965 myIORLabels[anIOR] = aLabel;
968 SALOMEDSImpl_Study* SALOMEDSImpl_Study::GetStudy(const DF_Label& theLabel)
970 SALOMEDSImpl_StudyHandle* Att;
971 if ((Att=(SALOMEDSImpl_StudyHandle*)theLabel.Root().FindAttribute(SALOMEDSImpl_StudyHandle::GetID()))) {
977 SALOMEDSImpl_SObject SALOMEDSImpl_Study::SObject(const DF_Label& theLabel)
979 return GetStudy(theLabel)->GetSObject(theLabel);
982 SALOMEDSImpl_SComponent SALOMEDSImpl_Study::SComponent(const DF_Label& theLabel)
984 return GetStudy(theLabel)->GetSComponent(theLabel);
988 void SALOMEDSImpl_Study::IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute)
990 string aString = theAttribute->Label().Entry();
991 GetStudy(theAttribute->Label())->UpdateIORLabelMap(theAttribute->Value(), aString);
994 vector<SALOMEDSImpl_SObject> SALOMEDSImpl_Study::FindDependances(const SALOMEDSImpl_SObject& anObject)
997 vector<SALOMEDSImpl_SObject> aSeq;
999 SALOMEDSImpl_AttributeTarget* aTarget;
1000 if ((aTarget=(SALOMEDSImpl_AttributeTarget*)anObject.GetLabel().FindAttribute(SALOMEDSImpl_AttributeTarget::GetID()))) {
1001 return aTarget->Get();
1008 SALOMEDSImpl_AttributeStudyProperties* SALOMEDSImpl_Study::GetProperties()
1011 return SALOMEDSImpl_AttributeStudyProperties::Set(_doc->Main());
1014 string SALOMEDSImpl_Study::GetLastModificationDate()
1017 SALOMEDSImpl_AttributeStudyProperties* aProp = GetProperties();
1019 vector<string> aNames;
1020 vector<int> aMinutes, aHours, aDays, aMonths, aYears;
1021 aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
1023 int aLastIndex = aNames.size()-1;
1025 sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d",
1026 (int)(aDays[aLastIndex]),(int)(aMonths[aLastIndex]), (int)(aYears[aLastIndex]),
1027 (int)(aHours[aLastIndex]), (int)(aMinutes[aLastIndex]));
1028 string aResStr (aResult);
1032 vector<string> SALOMEDSImpl_Study::GetModificationsDate()
1035 SALOMEDSImpl_AttributeStudyProperties* aProp = GetProperties();
1037 vector<string> aNames;
1038 vector<int> aMinutes, aHours, aDays, aMonths, aYears;
1039 aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
1041 int anIndex, aLength = aNames.size();
1042 vector<string> aDates;
1044 for (anIndex = 1; anIndex < aLength; anIndex++) {
1046 sprintf(aDate, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d",
1047 (int)(aDays[anIndex]), (int)(aMonths[anIndex]), (int)(aYears[anIndex]),
1048 (int)(aHours[anIndex]), (int)(aMinutes[anIndex]));
1049 aDates.push_back(aDate);
1056 //============================================================================
1057 /*! Function : GetUseCaseBuilder
1058 * Purpose : Returns a UseCase builder
1060 //============================================================================
1061 SALOMEDSImpl_UseCaseBuilder* SALOMEDSImpl_Study::GetUseCaseBuilder()
1064 return _useCaseBuilder;
1068 //============================================================================
1069 /*! Function : Close
1072 //============================================================================
1073 void SALOMEDSImpl_Study::Close()
1076 _doc->GetApplication()->Close(_doc);
1083 //============================================================================
1084 /*! Function : GetSComponent
1087 //============================================================================
1088 SALOMEDSImpl_SComponent SALOMEDSImpl_Study::GetSComponent(const string& theEntry)
1090 SALOMEDSImpl_SComponent aSCO;
1091 if(_mapOfSCO.find(theEntry) != _mapOfSCO.end())
1092 aSCO = _mapOfSCO[theEntry];
1094 DF_Label aLabel = DF_Label::Label(_doc->Main(), theEntry);
1095 aSCO = SALOMEDSImpl_SComponent(aLabel);
1096 _mapOfSCO[theEntry] = aSCO;
1102 //============================================================================
1103 /*! Function : GetSComponent
1106 //============================================================================
1107 SALOMEDSImpl_SComponent SALOMEDSImpl_Study::GetSComponent(const DF_Label& theLabel)
1109 return SALOMEDSImpl_SComponent(theLabel);
1112 //============================================================================
1113 /*! Function : GetSObject
1116 //============================================================================
1117 SALOMEDSImpl_SObject SALOMEDSImpl_Study::GetSObject(const string& theEntry)
1119 SALOMEDSImpl_SObject aSO;
1120 if(_mapOfSO.find(theEntry) != _mapOfSO.end())
1121 aSO = _mapOfSO[theEntry];
1123 DF_Label aLabel = DF_Label::Label(_doc->Main(), theEntry);
1124 aSO = SALOMEDSImpl_SObject(aLabel);
1125 _mapOfSO[theEntry] = aSO;
1131 //============================================================================
1132 /*! Function : GetSObject
1135 //============================================================================
1136 SALOMEDSImpl_SObject SALOMEDSImpl_Study::GetSObject(const DF_Label& theLabel)
1138 return SALOMEDSImpl_SObject(theLabel);
1141 //============================================================================
1142 /*! Function : GetAttribute
1145 //============================================================================
1146 DF_Attribute* SALOMEDSImpl_Study::GetAttribute(const string& theEntry,
1147 const string& theType)
1149 SALOMEDSImpl_SObject aSO = GetSObject(theEntry);
1150 DF_Attribute* anAttr;
1151 aSO.FindAttribute(anAttr, theType);
1155 //============================================================================
1156 /*! Function : DumpStudy
1159 //============================================================================
1160 bool SALOMEDSImpl_Study::DumpStudy(const string& thePath,
1161 const string& theBaseName,
1163 SALOMEDSImpl_DriverFactory* theFactory)
1167 if(theFactory == NULL) {
1168 _errorCode = "Null factory for creation of Engines";
1172 vector<string> aSeq;
1173 string aCompType, aFactoryType;
1175 //Build a list of all components in the Study
1176 SALOMEDSImpl_SComponentIterator itcomponent = NewComponentIterator();
1178 for (; itcomponent.More(); itcomponent.Next()) {
1179 SALOMEDSImpl_SComponent sco = itcomponent.Value();
1180 aCompType = sco.ComponentDataType();
1181 //GEOM and MED are independent components
1182 if (aCompType == "GEOM" || aCompType == "MED")
1183 aSeq.insert(aSeq.begin(), aCompType);
1185 aSeq.push_back(aCompType);
1190 thePath + string("\\") + theBaseName + string(".py");
1193 thePath + string("/") + theBaseName + string(".py");
1196 //Create a file that will contain a main Study script
1198 fp.open(aFileName.c_str(), ios::out);
1201 bool isOpened = fp.is_open();
1203 bool isOpened = fp.rdbuf()->is_open();
1207 _errorCode = string("Can't create a file ")+aFileName;
1211 string aBatchModeScript = "salome";
1213 //Output to the main Study script required Python modules import,
1214 //set sys.path and add a creation of the study.
1215 fp << GetDumpStudyComment() << endl << endl;
1216 fp << "import sys" << endl;
1217 fp << "import " << aBatchModeScript << endl << endl;
1219 fp << aBatchModeScript << ".salome_init()" << endl << endl;
1221 fp << _GetNoteBookAccess();
1223 fp << "sys.path.insert( 0, r\'" << thePath << "\')" << endl << endl;
1225 //Dump NoteBook Variables
1226 fp << _GetStudyVariablesScript();
1228 //Check if it's necessary to dump visual parameters
1229 bool isDumpVisuals = SALOMEDSImpl_IParameters::isDumpPython(this);
1230 int lastSavePoint = -1;
1232 lastSavePoint = SALOMEDSImpl_IParameters::getLastSavePoint(this);
1233 if(lastSavePoint > 0) {
1234 fp << SALOMEDSImpl_IParameters::getStudyScript(this, lastSavePoint) << endl << endl;
1239 vector<string> aSeqOfFileNames;
1241 //Iterate all components and create the componponents specific scripts.
1243 int aLength = aSeq.size();
1244 for(int i = 1; i <= aLength; i++) {
1246 aCompType = aSeq[i-1];
1247 SALOMEDSImpl_SComponent sco = FindComponent(aCompType);
1248 SALOMEDSImpl_Driver* aDriver = NULL;
1249 // if there is an associated Engine call its method for saving
1252 if (!sco.ComponentIOR(IOREngine)) {
1253 if (!aCompType.empty()) {
1255 aDriver = theFactory->GetDriverByType(aCompType);
1257 if (aDriver != NULL) {
1258 SALOMEDSImpl_StudyBuilder* SB = NewBuilder();
1259 if(!SB->LoadWith(sco, aDriver)) {
1260 _errorCode = SB->GetErrorCode();
1268 aDriver = theFactory->GetDriverByIOR(IOREngine);
1271 _errorCode = "Can not restore information to dump it";
1275 if(aDriver == NULL) continue;
1278 long aStreamLength = 0;
1279 SALOMEDSImpl_TMPFile* aStream = aDriver->DumpPython(this, isPublished, isValidScript, aStreamLength);
1280 if ( !isValidScript )
1283 //Create a file that will contain the component specific script
1286 aFileName=thePath+string("\\");
1288 aFileName=thePath+string("/");
1291 aScriptName += theBaseName;
1293 aScriptName += aCompType;
1295 aFileName += aScriptName+ string(".py");
1296 aSeqOfFileNames.push_back(aFileName);
1298 fp2.open(aFileName.c_str(), ios::out);
1301 isOpened = fp2.is_open();
1303 isOpened = fp2.rdbuf()->is_open();
1307 _errorCode = string("Can't create a file ")+aFileName;
1308 SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false);
1312 //Output the Python script generated by the component in the newly created file.
1313 fp2 << aStream->Data();
1316 if(aStream) delete aStream;
1318 //Add to the main script a call to RebuildData of the generated by the component the Python script
1319 fp << "import " << aScriptName << endl;
1320 fp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << endl;
1324 fp << "if salome.sg.hasDesktop():" << endl;
1325 fp << "\tsalome.sg.updateObjBrowser(1)" << endl;
1327 if(isDumpVisuals) { //Output the call to Session's method restoreVisualState
1328 fp << "\tiparameters.getSession().restoreVisualState(1)" << endl;
1336 //=======================================================================
1337 //function : GetDumpStudyComment
1338 //purpose : return a header comment for a DumpStudy script
1339 //=======================================================================
1341 string SALOMEDSImpl_Study::GetDumpStudyComment(const char* theComponentName)
1344 ("### This file is generated by SALOME automatically by dump python functionality");
1345 if ( theComponentName )
1346 txt += string(" of ") + (char*) theComponentName + " component";
1350 void dumpSO(const SALOMEDSImpl_SObject& theSO,
1353 SALOMEDSImpl_Study* theStudy);
1355 //============================================================================
1359 //============================================================================
1360 void SALOMEDSImpl_Study::dump(const string& theFileName)
1362 //Create a file that will contain a main Study script
1364 fp.open(theFileName.c_str(), ios::out);
1367 bool isOpened = fp.is_open();
1369 bool isOpened = fp.rdbuf()->is_open();
1373 _errorCode = string("Can't create a file ")+theFileName;
1374 cout << "### SALOMEDSImpl_Study::dump Error: " << _errorCode << endl;
1378 SALOMEDSImpl_SObject aSO = FindObjectID("0:1");
1379 fp << "0:1" << endl;
1380 SALOMEDSImpl_ChildIterator Itr = NewChildIterator(aSO);
1382 for(; Itr.More(); Itr.Next()) {
1383 dumpSO(Itr.Value(), fp, aTab, this);
1390 void dumpSO(const SALOMEDSImpl_SObject& theSO,
1393 SALOMEDSImpl_Study* theStudy)
1395 string aTab(Tab), anID(theSO.GetID());
1396 fp << aTab << anID << endl;
1397 vector<DF_Attribute*> attribs = theSO.GetLabel().GetAttributes();
1398 for(int i = 0; i<attribs.size(); i++) {
1399 SALOMEDSImpl_GenericAttribute* anAttr = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(attribs[i]);
1405 string aType = anAttr->GetClassType();
1406 fp << Tab << " -- " << aType;
1408 if(aType == string("AttributeReal")) {
1409 fp << " : " << dynamic_cast<SALOMEDSImpl_AttributeReal*>(anAttr)->Value();
1411 else if(aType == string("AttributeInteger")) {
1412 fp << " : " << dynamic_cast<SALOMEDSImpl_AttributeInteger*>(anAttr)->Value();
1414 else if(aType == string("AttributeName")) {
1415 fp << " : " << dynamic_cast<SALOMEDSImpl_AttributeName*>(anAttr)->Value();
1417 else if(aType == string("AttributeComment")) {
1418 fp << " : " << dynamic_cast<SALOMEDSImpl_AttributeComment*>(anAttr)->Value();
1420 else if(aType == string("AttributeReference")) {
1421 fp << " : " << dynamic_cast<SALOMEDSImpl_AttributeReference*>(anAttr)->Save();
1426 SALOMEDSImpl_ChildIterator Itr = theStudy->NewChildIterator(theSO);
1427 string aNewTab(" ");
1429 for(; Itr.More(); Itr.Next()) {
1430 dumpSO(Itr.Value(), fp, aNewTab, theStudy);
1436 void SALOMEDSImpl_Study::Modify()
1439 _doc->SetModified(true);
1442 //============================================================================
1446 //============================================================================
1447 SALOMEDSImpl_AttributeParameter* SALOMEDSImpl_Study::GetCommonParameters(const char* theID, int theSavePoint)
1449 if (theSavePoint < 0) return NULL;
1450 SALOMEDSImpl_StudyBuilder* builder = NewBuilder();
1451 SALOMEDSImpl_SObject so = FindComponent((char*)theID);
1452 if (!so) so = builder->NewComponent((char*)theID);
1453 SALOMEDSImpl_AttributeParameter* attParam = NULL;
1455 if (theSavePoint > 0) { // Try to find SObject that contains attribute parameter ...
1456 DF_Label savePointLabel = so.GetLabel().FindChild( theSavePoint, /*create=*/0 );
1457 if ( !savePointLabel.IsNull() )
1458 so = GetSObject( savePointLabel );
1459 else // ... if it does not exist - create a new one
1460 so = builder->NewObjectToTag( so, theSavePoint );
1465 builder->FindAttribute(so, A, "AttributeParameter");
1466 if ( !A ) { // first call of GetCommonParameters on "Interface Applicative" component
1467 A = builder->FindOrCreateAttribute(so, "AttributeParameter");
1469 attParam = dynamic_cast<SALOMEDSImpl_AttributeParameter*>( A );
1474 //============================================================================
1478 //============================================================================
1479 SALOMEDSImpl_AttributeParameter* SALOMEDSImpl_Study::GetModuleParameters(const char* theID,
1480 const char* theModuleName,
1483 if(theSavePoint <= 0) return NULL;
1484 SALOMEDSImpl_AttributeParameter* main_ap = GetCommonParameters(theID, theSavePoint);
1485 SALOMEDSImpl_SObject main_so = main_ap->GetSObject();
1486 SALOMEDSImpl_AttributeParameter* par = NULL;
1488 SALOMEDSImpl_ChildIterator it = NewChildIterator(main_so);
1489 string moduleName(theModuleName);
1490 for(; it.More(); it.Next()) {
1491 SALOMEDSImpl_SObject so(it.Value());
1492 if((par=(SALOMEDSImpl_AttributeParameter*)so.GetLabel().FindAttribute(SALOMEDSImpl_AttributeParameter::GetID()))) {
1493 if(!par->IsSet("AP_MODULE_NAME", (Parameter_Types)3)) continue; //3 -> PT_STRING
1494 if(par->GetString("AP_MODULE_NAME") == moduleName) return par;
1498 SALOMEDSImpl_StudyBuilder* builder = NewBuilder();
1499 SALOMEDSImpl_SObject so = builder->NewObject(main_so);
1500 par = dynamic_cast<SALOMEDSImpl_AttributeParameter*>(builder->FindOrCreateAttribute(so, "AttributeParameter"));
1501 par->SetString("AP_MODULE_NAME", moduleName);
1505 //============================================================================
1506 /*! Function : SetStudyLock
1509 //============================================================================
1510 void SALOMEDSImpl_Study::SetStudyLock(const char* theLockerID)
1512 _lockers.push_back(theLockerID);
1515 //============================================================================
1516 /*! Function : IsStudyLocked
1519 //============================================================================
1520 bool SALOMEDSImpl_Study::IsStudyLocked()
1522 return (_lockers.size() > 0);
1525 //============================================================================
1526 /*! Function : UnLockStudy
1529 //============================================================================
1530 void SALOMEDSImpl_Study::UnLockStudy(const char* theLockerID)
1532 vector<string>::iterator vsI = _lockers.begin();
1533 int length = _lockers.size();
1534 bool isFound = false;
1535 string id(theLockerID);
1536 for(int i = 0; i<length; i++, vsI++) {
1537 if(id == _lockers[i]) {
1542 if(isFound) _lockers.erase(vsI);
1545 //============================================================================
1546 /*! Function : GetLockerID
1549 //============================================================================
1550 vector<string> SALOMEDSImpl_Study::GetLockerID()
1555 //============================================================================
1556 /*! Function : SetVariable
1559 //============================================================================
1560 void SALOMEDSImpl_Study::SetVariable(const string& theVarName,
1561 const double theValue,
1562 const SALOMEDSImpl_GenericVariable::VariableTypes theType)
1564 bool modified = false;
1565 SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
1567 if( aGVar == NULL ) {
1569 SALOMEDSImpl_ScalarVariable* aSVar = new SALOMEDSImpl_ScalarVariable(theType, theVarName);
1571 aSVar->setValue(theValue);
1572 myNoteBookVars.push_back(aSVar);
1576 if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast<SALOMEDSImpl_ScalarVariable*>(aGVar)) {
1577 modified = aSVar->setValue(theValue) || modified;
1578 modified = aSVar->setType(theType) || modified;
1585 //============================================================================
1586 /*! Function : GetReal
1589 //============================================================================
1590 double SALOMEDSImpl_Study::GetVariableValue(const string& theVarName)
1592 SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
1595 if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast<SALOMEDSImpl_ScalarVariable*>(aGVar))
1596 return aSVar->getValue();
1601 //============================================================================
1602 /*! Function : IsTypeOf
1605 //============================================================================
1606 bool SALOMEDSImpl_Study::IsTypeOf(const string& theVarName,
1607 SALOMEDSImpl_GenericVariable::
1608 VariableTypes theType) const
1610 SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
1613 return aGVar->Type() == theType;
1618 //============================================================================
1619 /*! Function : IsVariable
1622 //============================================================================
1623 bool SALOMEDSImpl_Study::IsVariable(const string& theVarName) const
1625 SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
1626 return (aGVar != NULL);
1629 //============================================================================
1630 /*! Function : GetVariableNames
1633 //============================================================================
1634 vector<string> SALOMEDSImpl_Study::GetVariableNames() const
1636 vector<string> aResult;
1638 for(int i = 0; i < myNoteBookVars.size(); i++)
1639 aResult.push_back(myNoteBookVars[i]->Name());
1644 //============================================================================
1645 /*! Function : AddVariable
1648 //============================================================================
1649 void SALOMEDSImpl_Study::AddVariable(SALOMEDSImpl_GenericVariable* theVariable)
1651 myNoteBookVars.push_back(theVariable);
1654 //============================================================================
1655 /*! Function : AddVariable
1658 //============================================================================
1659 SALOMEDSImpl_GenericVariable* SALOMEDSImpl_Study::GetVariable(const std::string& theName) const
1661 SALOMEDSImpl_GenericVariable* aResult = NULL;
1662 for(int i = 0; i < myNoteBookVars.size();i++) {
1663 if(theName.compare(myNoteBookVars[i]->Name()) == 0) {
1664 aResult = myNoteBookVars[i];
1671 //============================================================================
1672 /*! Function : RemoveVariable
1675 //============================================================================
1676 bool SALOMEDSImpl_Study::RemoveVariable(const string& theVarName)
1678 SALOMEDSImpl_GenericVariable* aVariable = GetVariable( theVarName );
1682 string aValue = aVariable->SaveToScript();
1683 ReplaceVariableAttribute( theVarName, aValue );
1685 std::vector<SALOMEDSImpl_GenericVariable*>::iterator it = myNoteBookVars.begin(), itEnd = myNoteBookVars.end();
1686 for( ; it != itEnd; it++ )
1688 SALOMEDSImpl_GenericVariable* aVariableRef = *it;
1689 if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 )
1691 myNoteBookVars.erase( it );
1700 //============================================================================
1701 /*! Function : RenameVariable
1704 //============================================================================
1705 bool SALOMEDSImpl_Study::RenameVariable(const string& theVarName, const string& theNewVarName)
1707 SALOMEDSImpl_GenericVariable* aVariable = GetVariable( theVarName );
1711 ReplaceVariableAttribute( theVarName, theNewVarName );
1713 std::vector<SALOMEDSImpl_GenericVariable*>::iterator it = myNoteBookVars.begin(), itEnd = myNoteBookVars.end();
1714 for( ; it != itEnd; it++ )
1716 SALOMEDSImpl_GenericVariable* aVariableRef = *it;
1717 if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 )
1719 aVariableRef->setName( theNewVarName );
1728 //============================================================================
1729 /*! Function : IsVariableUsed
1732 //============================================================================
1733 bool SALOMEDSImpl_Study::IsVariableUsed(const string& theVarName)
1735 return FindVariableAttribute( theVarName );
1738 //============================================================================
1739 /*! Function : FindVariableAttribute
1742 //============================================================================
1743 bool SALOMEDSImpl_Study::FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
1744 SALOMEDSImpl_SObject theSObject,
1745 const std::string& theName)
1747 SALOMEDSImpl_ChildIterator anIter = NewChildIterator( theSObject );
1748 for( ; anIter.More(); anIter.Next() )
1749 if( FindVariableAttribute( theStudyBuilder, anIter.Value(), theName ) )
1752 DF_Attribute* anAttr;
1753 if( theStudyBuilder->FindAttribute( theSObject, anAttr, "AttributeString" ) )
1755 if( SALOMEDSImpl_AttributeString* aStringAttr = ( SALOMEDSImpl_AttributeString* )anAttr )
1757 string aString = aStringAttr->Value();
1759 vector< vector<string> > aSections = ParseVariables( aString );
1760 for( int i = 0, n = aSections.size(); i < n; i++ )
1762 vector<string> aVector = aSections[i];
1763 for( int j = 0, m = aVector.size(); j < m; j++ )
1765 string aStr = aVector[j];
1766 if( aStr.compare( theName ) == 0 )
1775 //============================================================================
1776 /*! Function : FindVariableAttribute
1779 //============================================================================
1780 bool SALOMEDSImpl_Study::FindVariableAttribute(const std::string& theName)
1782 SALOMEDSImpl_StudyBuilder* aStudyBuilder = NewBuilder();
1783 SALOMEDSImpl_SComponentIterator aCompIter = NewComponentIterator();
1784 for( ; aCompIter.More(); aCompIter.Next() )
1786 SALOMEDSImpl_SObject aComp = aCompIter.Value();
1787 if( FindVariableAttribute( aStudyBuilder, aComp, theName ) )
1793 //============================================================================
1794 /*! Function : ReplaceVariableAttribute
1797 //============================================================================
1798 void SALOMEDSImpl_Study::ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
1799 SALOMEDSImpl_SObject theSObject,
1800 const std::string& theSource,
1801 const std::string& theDest)
1803 SALOMEDSImpl_ChildIterator anIter = NewChildIterator( theSObject );
1804 for( ; anIter.More(); anIter.Next() )
1805 ReplaceVariableAttribute( theStudyBuilder, anIter.Value(), theSource, theDest );
1807 DF_Attribute* anAttr;
1808 if( theStudyBuilder->FindAttribute( theSObject, anAttr, "AttributeString" ) )
1810 if( SALOMEDSImpl_AttributeString* aStringAttr = ( SALOMEDSImpl_AttributeString* )anAttr )
1812 bool isChanged = false;
1813 string aNewString, aCurrentString = aStringAttr->Value();
1815 vector< vector<string> > aSections = ParseVariables( aCurrentString );
1816 for( int i = 0, n = aSections.size(); i < n; i++ )
1818 vector<string> aVector = aSections[i];
1819 for( int j = 0, m = aVector.size(); j < m; j++ )
1821 string aStr = aVector[j];
1822 if( aStr.compare( theSource ) == 0 )
1828 aNewString.append( aStr );
1830 aNewString.append( ":" );
1833 aNewString.append( "|" );
1837 aStringAttr->SetValue( aNewString );
1842 //============================================================================
1843 /*! Function : ReplaceVariableAttribute
1846 //============================================================================
1847 void SALOMEDSImpl_Study::ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest)
1849 SALOMEDSImpl_StudyBuilder* aStudyBuilder = NewBuilder();
1850 SALOMEDSImpl_SComponentIterator aCompIter = NewComponentIterator();
1851 for( ; aCompIter.More(); aCompIter.Next() )
1853 SALOMEDSImpl_SObject aComp = aCompIter.Value();
1854 ReplaceVariableAttribute( aStudyBuilder, aComp, theSource, theDest );
1858 //============================================================================
1859 /*! Function : ParseVariables
1862 //============================================================================
1863 vector< vector< string > > SALOMEDSImpl_Study::ParseVariables(const string& theVariables) const
1865 return SALOMEDSImpl_Tool::splitStringWithEmpty( theVariables, OPERATION_SEPARATOR, VARIABLE_SEPARATOR );
1868 //============================================================================
1869 /*! Function : EnableUseCaseAutoFilling
1872 //============================================================================
1873 void SALOMEDSImpl_Study::EnableUseCaseAutoFilling(bool isEnabled)
1875 _errorCode = ""; _autoFill = isEnabled;
1877 _builder->SetOnAddSObject(_cb);
1878 _builder->SetOnRemoveSObject(_cb);
1881 _builder->SetOnAddSObject(NULL);
1882 _builder->SetOnRemoveSObject(NULL);
1886 //============================================================================
1887 /*! Function : GetIORs
1890 //============================================================================
1891 vector<string> SALOMEDSImpl_Study::GetIORs()
1893 vector<string> anIORs;
1894 map<string, DF_Label>::const_iterator MI;
1895 for(MI = myIORLabels.begin(); MI!=myIORLabels.end(); MI++)
1896 anIORs.push_back(MI->first);