- SALOMEDS::Study_var aStudy = study->getStudyDocument();
- bool aLocked = aStudy->GetProperties()->IsLocked();
- // asv : 23.11.04 : if the study is locked -- then we can't put anything in it.
- // fix for PAL6852.
- if ( aLocked )
- return false;
-
- SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- SALOMEDS::AttributeIOR_var anIORAttr;
- SALOMEDS::AttributePixMap_var aPixmap;
- QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
-
- // searching dataflow
- SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
- if (aSO->_is_nil()) { // create new dataflow SObject
- SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
- if (aComponent->_is_nil()) { // is supervision component not found, then create it
- QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
- anOperation->start();
- //if (aLocked) aStudy->GetProperties()->SetLocked(false);
+ // stop selection
+ choosing = false;
+ setCursor(aSupMod->getCursor());
+ objectBrowser->setCursor(aSupMod->getCursor());
+ aSupMod->putInfo("");
+ }
+ }
+ }
+}
+
+_PTR(SObject) SearchOrCreateSOWithName( _PTR(Study) const theStudy,
+ _PTR(StudyBuilder) const theBuilder,
+ _PTR(SObject) const theSO,
+ const char* theName,
+ bool* theDoneSomething ) {
+ _PTR(SObject) aResult;
+ _PTR(AttributeName) aName;
+ _PTR(GenericAttribute) anAttr;
+ _PTR(ChildIterator) anIterator ( theStudy->NewChildIterator(theSO) );
+ for (; anIterator->More(); anIterator->Next()) {
+ if (anIterator->Value()->FindAttribute(anAttr, "AttributeName")) {
+ aName = anAttr;
+ if (strcmp(aName->Value().c_str(), theName) == 0) {
+ aResult = anIterator->Value();
+ break;
+ }
+ }
+ }
+
+ // if aResule was found then theDoneSomething=false and we return
+ *theDoneSomething = !aResult ? 1 : 0;//->_is_nil();
+ if ( !*theDoneSomething )
+ return aResult;
+
+ // add new SObject
+ aResult = theBuilder->NewObject( theSO );
+ anAttr = theBuilder->FindOrCreateAttribute(aResult, "AttributeName");
+ aName = anAttr;
+ aName->SetValue(theName);
+ return aResult;
+}
+
+/**
+ * Return true if dataflow is already in the study
+ */
+bool SUPERVGUI_Main::isDataflowInStudy() const {
+ _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
+ _PTR(SObject) aSO ( aStudy->FindObjectIOR( dataflow->getIOR() ) );
+ return ( aSO ? true : false );
+}
+
+/**
+ * Create a "Supervision" object in the Study and a "dataflow" object under it
+ * aDoneSomething will be true if "Supervision" or "dataflow" object were created (not found).
+ */
+_PTR(SObject) createDataflowSObj( SUIT_Study* study,
+ SUPERV::Graph_var dataflow,
+ _PTR(StudyBuilder) aBuilder,
+ bool& aDoneSomething ) {
+ _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeName) aName;
+
+ // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
+ _PTR(SObject) aSO = aStudy->FindObjectIOR( dataflow->getIOR() );
+ if ( !aSO ) { // dataflow SObject not found in the study
+ aDoneSomething = true;
+ _PTR(SComponent) aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
+ if ( !aComponent ) { // is supervision component not found, then create it