-// returns false, if can't add dataflow into the study
-bool SUPERVGUI_Main::addStudy() {
- Trace("SUPERVGUI_Main::addStudy");
- if (myIsFromStudy) return false;
- if ((SUPERV_isNull(dataflow))) return false;
-
- 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);
- aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
- anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- //aName->SetValue(STUDY_SUPERVISION);
- aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
- anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
- aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
- aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
- aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
- //if (aLocked) aStudy->GetProperties()->SetLocked(true);
- anOperation->finish();
- }
- op->start();
- aSO = aBuilder->NewObject(aComponent);
- anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue(dataflow->Name());
- anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
- anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
- anIORAttr->SetValue(dataflow->getIOR());
- op->finish();
- //if (aLocked) return false;
- }
-
- sync();
- Supervision.unregisterGraph(this);
- Supervision.registerGraph(dataflow->getIOR(), this);
- myIsFromStudy = true;
- return true;
-}
-
-