From: mpa Date: Tue, 31 Jan 2017 09:15:05 +0000 (+0300) Subject: Deleted Study as an input parameter and class field. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cb32cc7b4e90149689350b560849156bc497935e;p=modules%2Fgui.git Deleted Study as an input parameter and class field. --- diff --git a/doc/salome/gui/input/howtos_and_best_practives.doc b/doc/salome/gui/input/howtos_and_best_practives.doc index b601e80e3..8d3f9de49 100644 --- a/doc/salome/gui/input/howtos_and_best_practives.doc +++ b/doc/salome/gui/input/howtos_and_best_practives.doc @@ -416,7 +416,7 @@ void MyModule::copyOrMove( const MYMODULE_ORB::object_list& what, { if ( CORBA::is_nil( where ) ) return; // bad parent - SALOMEDS::Study_var study = where->GetStudy(); // study + SALOMEDS::Study_var study = GUI::getStudy(); // study SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); // study builder SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); // use case builder SALOMEDS::SComponent_var father = where->GetFatherComponent(); // father component diff --git a/src/GuiHelpers/SALOME_AppStudyEditor.cxx b/src/GuiHelpers/SALOME_AppStudyEditor.cxx index 4f9b88242..df96b6d3b 100644 --- a/src/GuiHelpers/SALOME_AppStudyEditor.cxx +++ b/src/GuiHelpers/SALOME_AppStudyEditor.cxx @@ -20,6 +20,7 @@ // Author: Guillaume Boulant (EDF/R&D) #include "SALOME_AppStudyEditor.hxx" +#include "SALOME_GuiServices.hxx" #include #include @@ -34,7 +35,7 @@ SALOME_AppStudyEditor::SALOME_AppStudyEditor(SalomeApp_Application * salomeApp) SALOMEDS::SObject_ptr SALOME_AppStudyEditor::IObjectToSObject(const Handle(SALOME_InteractiveObject)& iobject) { if (!iobject.IsNull()) { if (iobject->hasEntry()) { - SALOMEDS::SObject_var sobject = _study->FindObjectID(iobject->getEntry()); + SALOMEDS::SObject_var sobject = GUI::getStudy()->FindObjectID(iobject->getEntry()); return sobject._retn(); } } diff --git a/src/GuiHelpers/SALOME_GuiServices.cxx b/src/GuiHelpers/SALOME_GuiServices.cxx index c5ce1b135..208ae10cf 100644 --- a/src/GuiHelpers/SALOME_GuiServices.cxx +++ b/src/GuiHelpers/SALOME_GuiServices.cxx @@ -68,28 +68,11 @@ namespace GUI { // SALOME application using the resourceMgr() method: // - /** - * This returns the current active study id if an active study is - * defined in the SALOME session, returns -1 otherwise. Note that - * the active study doesn't make sense outside of the GUI SALOME - * process, i.e. the SALOME_SessionServer embedding the - * SalomeApp_Application. - */ - bool isActiveStudy() { - SALOME::Session_var aSession = KERNEL::getSalomeSession(); - if ( CORBA::is_nil(aSession) ) { - INFOS("ERR: can't request for active study because the session is NULL"); - return false; - } - return true; - } - /** * This returns the current active study if an active study is * defined in the SALOME session, returns null otherwise. */ - SALOMEDS::Study_ptr getActiveStudy() { - if ( isActiveStudy() ) + SALOMEDS::Study_ptr getStudy() { return KERNEL::getStudy(); } diff --git a/src/GuiHelpers/SALOME_GuiServices.hxx b/src/GuiHelpers/SALOME_GuiServices.hxx index 92fdd6005..ae48d6459 100644 --- a/src/GuiHelpers/SALOME_GuiServices.hxx +++ b/src/GuiHelpers/SALOME_GuiServices.hxx @@ -58,8 +58,7 @@ namespace GUI { // depends of the SALOME module technical choices). In general, on // of the attribute of a SObject is a CORBA servant that handles the // data to work with - SALOMEGUIHELPERS_EXPORT SALOMEDS::Study_ptr getActiveStudy(); - SALOMEGUIHELPERS_EXPORT bool isActiveStudy(); + SALOMEGUIHELPERS_EXPORT SALOMEDS::Study_ptr getStudy(); // Another way to get the active study (to be converted in // SALOMEDS::Study): diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index dbec2f4b2..3981d50cb 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -286,12 +286,6 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) if ( !anOCCPrs || anOCCPrs->IsNull() ) return; - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - // get context Handle (AIS_InteractiveContext) ic = getAISContext(); @@ -367,8 +361,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); //if ( !anObj.IsNull() && anObj->hasEntry() ) //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // ToolsGUI::SetVisibility( anObj->getEntry(), true, this ); //} // Deactivate object if necessary @@ -392,12 +385,6 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) if ( !anOCCPrs || anOCCPrs->IsNull() ) return; - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -421,8 +408,7 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); // if ( !anObj.IsNull() && anObj->hasEntry() ) // { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // ToolsGUI::SetVisibility( anObj->getEntry(), true, this ); // } //} } @@ -437,12 +423,6 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) */ void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) { - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -470,8 +450,7 @@ void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) // Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); // if ( !anObj.IsNull() && anObj->hasEntry() ) { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // ToolsGUI::SetVisibility( anObj->getEntry(), true, this ); // } //} } diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 1063979c5..eb5c339a8 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -665,11 +665,6 @@ void SVTK_Viewer::Display( const SALOME_VTKPrs* prs ) if(aPrs->IsNull()) return; if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) aStudy(getStudyDS()); anActorCollection->InitTraversal(); while(vtkActor* anActor = anActorCollection->GetNextActor()){ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ @@ -680,8 +675,8 @@ void SVTK_Viewer::Display( const SALOME_VTKPrs* prs ) // TODO: better mechanism of storing display/erse status in a study // should be provided... //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); + //if(!anObj.IsNull() && anObj->hasEntry()){ + // ToolsGUI::SetVisibility(anObj->getEntry(),true,this); //} // just display the object QVector aViews = myViewManager->getViews(); @@ -714,11 +709,6 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) if(aPrs->IsNull()) return; if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erase status in a study - // should be provided... - //_PTR(Study) aStudy(getStudyDS()); anActorCollection->InitTraversal(); while(vtkActor* anActor = anActorCollection->GetNextActor()) if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ @@ -727,8 +717,8 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) // TODO: better mechanism of storing display/erase status in a study // should be provided... //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + //if(!anObj.IsNull() && anObj->hasEntry()){ + // ToolsGUI::SetVisibility(anObj->getEntry(),false,this); //} // just display the object QVector aViews = myViewManager->getViews(); @@ -753,10 +743,6 @@ void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) */ void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) { - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //_PTR(Study) aStudy(getStudyDS()); QVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))) @@ -772,8 +758,8 @@ void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) // TODO: better mechanism of storing display/erse status in a study // should be provided... //Handle(SALOME_InteractiveObject) anObj = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy) - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + //if(!anObj.IsNull() && anObj->hasEntry()) + // ToolsGUI::SetVisibility(anObj->getEntry(),false,this); if(forced){ if(SVTK_Renderer* aRnd = aView->GetRenderer()) aRnd->RemoveActor(anAct); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index b1fb863f9..68fe5ee66 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -249,8 +249,7 @@ void SalomeApp_Application::start() SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); PyConsole_Console* pyConsole = pythonConsole(); if ( appStudy && pyConsole ) { - _PTR(Study) aStudy = appStudy->studyDS(); - if ( !aStudy->GetProperties()->IsLocked() ) { + if ( !getStudy()->GetProperties()->IsLocked() ) { // pyfiles[j] is a dictionary: {"/absolute/path/to/script.py": [script_args]} // Path is absolute, script has .py extension for (uint j = 0; j < pyfiles.count(); j++ ) { @@ -593,7 +592,7 @@ void SalomeApp_Application::onCopy() SalomeApp_Study* study = dynamic_cast(activeStudy()); if(study == NULL) return; - _PTR(Study) stdDS = study->studyDS(); + _PTR(Study) stdDS = getStudy(); if(!stdDS) return; SALOME_ListIteratorOfListIO it( list ); @@ -619,7 +618,7 @@ void SalomeApp_Application::onPaste() SalomeApp_Study* study = dynamic_cast(activeStudy()); if(study == NULL) return; - _PTR(Study) stdDS = study->studyDS(); + _PTR(Study) stdDS = getStudy(); if(!stdDS) return; if ( stdDS->GetProperties()->IsLocked() ) { @@ -654,18 +653,13 @@ bool SalomeApp_Application::isPossibleToClose( bool& closePermanently ) /*! Check if the study is locked */ void SalomeApp_Application::onCloseDoc( bool ask ) { - SalomeApp_Study* study = dynamic_cast(activeStudy()); - - if (study != NULL) { - _PTR(Study) stdDS = study->studyDS(); - if(stdDS && stdDS->IsStudyLocked()) { - if ( SUIT_MessageBox::question( desktop(), - QObject::tr( "WRN_WARNING" ), - QObject::tr( "CLOSE_LOCKED_STUDY" ), - SUIT_MessageBox::Yes | SUIT_MessageBox::No, - SUIT_MessageBox::No) == SUIT_MessageBox::No ) return; + if(getStudy()->IsStudyLocked()) { + if ( SUIT_MessageBox::question( desktop(), + QObject::tr( "WRN_WARNING" ), + QObject::tr( "CLOSE_LOCKED_STUDY" ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No, + SUIT_MessageBox::No) == SUIT_MessageBox::No ) return; - } } LightApp_Application::onCloseDoc( ask ); } @@ -687,21 +681,14 @@ void SalomeApp_Application::onSelectionChanged() canPaste = m->canPaste(); } - SalomeApp_Study* study = dynamic_cast(activeStudy()); - if (study) { - _PTR(Study) stdDS = study->studyDS(); + SALOME_ListIteratorOfListIO it ( list ); - if (stdDS) { - SALOME_ListIteratorOfListIO it ( list ); + if (it.More() && list.Extent() == 1) { + _PTR(SObject) so = getStudy()->FindObjectID(it.Value()->getEntry()); - if (it.More() && list.Extent() == 1) { - _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); - - if ( so ) { - canCopy = canCopy || stdDS->CanCopy(so); - canPaste = canPaste || stdDS->CanPaste(so); - } - } + if ( so ) { + canCopy = canCopy || getStudy()->CanCopy(so); + canPaste = canPaste || getStudy()->CanPaste(so); } } @@ -719,8 +706,7 @@ void SalomeApp_Application::onDeleteInvalidReferences() if( aList.IsEmpty() ) return; - SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); - _PTR(Study) aStudyDS = aStudy->studyDS(); + _PTR(Study) aStudyDS = getStudy(); _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder(); _PTR(SObject) anObj; @@ -865,7 +851,6 @@ void SalomeApp_Application::onDumpStudy( ) { SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); if ( !appStudy ) return; - _PTR(Study) aStudy = appStudy->studyDS(); QStringList aFilters; aFilters.append( tr( "PYTHON_FILES_FILTER" ) ); @@ -917,15 +902,11 @@ void SalomeApp_Application::onDumpStudy( ) /*!Private SLOT. On load script.*/ void SalomeApp_Application::onLoadScript( ) { - SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); - if ( appStudy ) { - _PTR(Study) aStudy = appStudy->studyDS(); - if ( aStudy->GetProperties()->IsLocked() ) { - SUIT_MessageBox::warning( desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED") ); - return; - } + if ( getStudy()->GetProperties()->IsLocked() ) { + SUIT_MessageBox::warning( desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED") ); + return; } QStringList filtersList; @@ -1074,14 +1055,11 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) } else if ( flag == WT_NoteBook ) { - SalomeApp_Study* appStudy = dynamic_cast( activeStudy() ); - if ( appStudy ) { - _PTR(Study) aStudy = appStudy->studyDS(); - setNoteBook( new SalomeApp_NoteBook( desktop(), aStudy ) ); - //to receive signal in NoteBook that it's variable was modified - connect( this, SIGNAL( notebookVarUpdated( QString ) ), - getNoteBook(), SLOT( onVarUpdate( QString ) ) ); - } + setNoteBook( new SalomeApp_NoteBook( desktop() ) ); + //to receive signal in NoteBook that it's variable was modified + connect( this, SIGNAL( notebookVarUpdated( QString ) ), + getNoteBook(), SLOT( onVarUpdate( QString ) ) ); + wid = getNoteBook(); wid->setObjectName( "noteBook" ); } @@ -1130,16 +1108,10 @@ void SalomeApp_Application::updateDesktopTitle() { { QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false ); if ( !sName.isEmpty() ) { - SalomeApp_Study* study = dynamic_cast(activeStudy()); - if ( study ) { - _PTR(Study) stdDS = study->studyDS(); - if(stdDS) { - if ( stdDS->GetProperties()->IsLocked() ) { - aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) ); - } else { - aTitle += QString( " - [%1]" ).arg( sName ); - } - } + if ( getStudy()->GetProperties()->IsLocked() ) { + aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) ); + } else { + aTitle += QString( " - [%1]" ).arg( sName ); } } } @@ -1392,72 +1364,62 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop // isInvalidRefs will be true, if at least one of selected objects is invalid reference bool isInvalidRefs = false; - SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); - if ( aStudy ) { - _PTR(Study) aStudyDS = aStudy->studyDS(); - _PTR(SObject) anObj; - for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() ) + _PTR(SObject) anObj; + for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() ) + { + if( it.Value()->hasEntry() ) { - if( it.Value()->hasEntry() ) - { - _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject; - while( aRefObj && aRefObj->ReferencedObject( anObj ) ) - aRefObj = anObj; + _PTR(SObject) aSObject = getStudy()->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject; + while( aRefObj && aRefObj->ReferencedObject( anObj ) ) + aRefObj = anObj; - if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() ) - isInvalidRefs = true; - } + if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() ) + isInvalidRefs = true; } + } - // Add "Delete reference" item to popup - if ( isInvalidRefs ) - { - thePopup->addSeparator(); - thePopup->addAction( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); - return; - } + // Add "Delete reference" item to popup + if ( isInvalidRefs ) + { + thePopup->addSeparator(); + thePopup->addAction( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); + return; + } - // "Activate module" item should appear only if it's necessary - if ( aList.Extent() == 1 ) { - aList.Clear(); - mgr->selectedObjects( aList ); - - Handle(SALOME_InteractiveObject) aIObj = aList.First(); - - // add extra popup menu (defined in XML) - if ( myExtActions.size() > 0 ) { - // Use only first selected object - SalomeApp_Study* study = dynamic_cast( activeStudy() ); - if ( study ) { - _PTR(Study) stdDS = study->studyDS(); - if ( stdDS ) { - _PTR(SObject) aSO = stdDS->FindObjectID( aIObj->getEntry() ); - if ( aSO ) { - _PTR( GenericAttribute ) anAttr; - std::string auid = "AttributeUserID"; - auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID); - if ( aSO->FindAttribute( anAttr, auid ) ) { - _PTR(AttributeUserID) aAttrID = anAttr; - QString aId = aAttrID->Value().c_str(); - if ( myExtActions.contains( aId ) ) { - thePopup->addAction(myExtActions[aId]); - } - } - } + // "Activate module" item should appear only if it's necessary + if ( aList.Extent() == 1 ) { + aList.Clear(); + mgr->selectedObjects( aList ); + + Handle(SALOME_InteractiveObject) aIObj = aList.First(); + + // add extra popup menu (defined in XML) + if ( myExtActions.size() > 0 ) { + // Use only first selected object + _PTR(SObject) aSO = getStudy()->FindObjectID( aIObj->getEntry() ); + if ( aSO ) { + _PTR( GenericAttribute ) anAttr; + std::string auid = "AttributeUserID"; + auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID); + if ( aSO->FindAttribute( anAttr, auid ) ) { + _PTR(AttributeUserID) aAttrID = anAttr; + QString aId = aAttrID->Value().c_str(); + if ( myExtActions.contains( aId ) ) { + thePopup->addAction(myExtActions[aId]); } } } + } - // check if item is a "GUI state" item (also a first level object) - QString entry( aIObj->getEntry() ); - if ( !entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) { - QString aModuleName( aIObj->getComponentDataType() ); - QString aModuleTitle = moduleTitle( aModuleName ); - CAM_Module* currentModule = activeModule(); - if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() ) - thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) ); - } + // check if item is a "GUI state" item (also a first level object) + QString entry( aIObj->getEntry() ); + if ( !entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) { + QString aModuleName( aIObj->getComponentDataType() ); + QString aModuleTitle = moduleTitle( aModuleName ); + CAM_Module* currentModule = activeModule(); + if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() ) + thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) ); } } @@ -1474,25 +1436,21 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) SalomeApp_Study* study = dynamic_cast(activeStudy()); if ( study ) { - _PTR(Study) stdDS = study->studyDS(); - if( stdDS ) + for ( _PTR(SComponentIterator) it ( getStudy()->NewComponentIterator() ); it->More(); it->Next() ) { - for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() ) - { - _PTR(SComponent) aComponent ( it->Value() ); + _PTR(SComponent) aComponent ( it->Value() ); #ifndef WITH_SALOMEDS_OBSERVER - // with GUI observers this check is not needed anymore - if ( aComponent->ComponentDataType() == study->getVisualComponentName().toLatin1().constData() ) - continue; // skip the magic "Interface Applicative" component + // with GUI observers this check is not needed anymore + if ( aComponent->ComponentDataType() == study->getVisualComponentName().toLatin1().constData() ) + continue; // skip the magic "Interface Applicative" component #endif - if ( !objectBrowser() ) - getWindow( WT_ObjectBrowser ); - const bool isAutoUpdate = objectBrowser()->autoUpdate(); - objectBrowser()->setAutoUpdate( false ); - SalomeApp_DataModel::synchronize( aComponent, study ); - objectBrowser()->setAutoUpdate( isAutoUpdate ); - } + if ( !objectBrowser() ) + getWindow( WT_ObjectBrowser ); + const bool isAutoUpdate = objectBrowser()->autoUpdate(); + objectBrowser()->setAutoUpdate( false ); + SalomeApp_DataModel::synchronize( aComponent, study ); + objectBrowser()->setAutoUpdate( isAutoUpdate ); } } @@ -1920,8 +1878,6 @@ bool SalomeApp_Application::updateStudy() myNoteBook->setIsDumpedStudySaved( study->isSaved() ); myNoteBook->setDumpedStudyName( study->studyName() ); - _PTR(Study) studyDS = study->studyDS(); - // get unique temporary directory name QString aTmpDir = QString::fromStdString( SALOMEDS_Tool::GetTmpDir() ); if( aTmpDir.isEmpty() ) @@ -1939,12 +1895,12 @@ bool SalomeApp_Application::updateStudy() int savePoint; _PTR(AttributeParameter) ap; _PTR(IParameters) ip = ClientFactory::getIParameters(ap); - if(ip->isDumpPython(studyDS)) ip->setDumpPython(studyDS); //Unset DumpPython flag. + if(ip->isDumpPython()) ip->setDumpPython(); //Unset DumpPython flag. if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method - ip->setDumpPython(studyDS); + ip->setDumpPython(); savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point } - bool ok = studyDS->DumpStudy( aTmpDir.toStdString(), aScriptName.toStdString(), toPublish, isMultiFile ); + bool ok = getStudy()->DumpStudy( aTmpDir.toStdString(), aScriptName.toStdString(), toPublish, isMultiFile ); if ( toSaveGUI ) study->removeSavePoint(savePoint); //SRN: remove the created temporary save point. @@ -2031,9 +1987,8 @@ bool SalomeApp_Application::onRestoreStudy( const QString& theDumpScript, if( SalomeApp_Study* newStudy = dynamic_cast( app->activeStudy() ) ) { #ifndef DISABLE_PYCONSOLE - _PTR(Study) aStudyDS = newStudy->studyDS(); if ( app->getNoteBook() ) - app->getNoteBook()->Init( aStudyDS ); + app->getNoteBook()->Init(); newStudy->updateFromNotebook(theStudyName, theIsStudySaved); newStudy->Modified(); updateDesktopTitle(); diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index bebd38e64..77a1ea824 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -286,8 +286,7 @@ bool SalomeApp_DataModel::open( const QString& name, CAM_Study* study, QStringLi if ( anId.isEmpty() ) return true; // Probably nothing to load - _PTR(Study) aStudy ( aDoc->studyDS() ); // shared_ptr cannot be used here - _PTR(SComponent) aSComp ( aStudy->FindComponentID( std::string( anId.toLatin1() ) ) ); + _PTR(SComponent) aSComp ( SalomeApp_Application::getStudy()->FindComponentID( std::string( anId.toLatin1() ) ) ); if ( aSComp ) updateTree( aSComp, aDoc ); @@ -321,8 +320,7 @@ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) studyRoot = dynamic_cast( aSStudy->root() ); QString anId = getRootEntry( aSStudy ); if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing - _PTR(Study) aStudy ( aSStudy->studyDS() ); - sobj = aStudy->FindComponentID( std::string( anId.toLatin1() ) ); + sobj = SalomeApp_Application::getStudy()->FindComponentID( std::string( anId.toLatin1() ) ); } } } @@ -331,9 +329,8 @@ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) if ( studyRoot ) { aSStudy = dynamic_cast( studyRoot->study() ); // value should not change here theoretically, but just to make sure if ( aSStudy ) { - _PTR(Study) aStudy ( aSStudy->studyDS() ); // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon - sobj = aStudy->FindComponentID( std::string( modelRoot->entry().toLatin1() ) ); + sobj = SalomeApp_Application::getStudy()->FindComponentID( std::string( modelRoot->entry().toLatin1() ) ); } } } diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 2cabd00fd..ba1afa068 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -405,13 +405,13 @@ bool SalomeApp_DataObject::hasChildren() const bool ok = false; // tmp?? - _PTR(UseCaseBuilder) aUseCaseBuilder = myObject->GetStudy()->GetUseCaseBuilder(); + _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder(); if (aUseCaseBuilder->IsUseCaseNode(myObject)) { ok = aUseCaseBuilder->HasChildren(myObject); // TODO: check name as below? } else { - _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) ); + _PTR(ChildIterator) it ( SalomeApp_Application::getStudy()->NewChildIterator( myObject ) ); for ( ; it->More() && !ok; it->Next() ) { _PTR(SObject) obj = it->Value(); if ( obj ) { @@ -548,36 +548,28 @@ QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const QString aStrings = fromUtf8( str ); //Special case to show NoteBook variables in the "Value" column of the OB - if ( LightApp_RootObject* aRoot = dynamic_cast( root() ) ) + bool ok = false; + QStringList aSectionList = aStrings.split( "|" ); + if ( !aSectionList.isEmpty() ) { - if ( SalomeApp_Study* aStudy = dynamic_cast( aRoot->study() ) ) + QString aLastSection = aSectionList.last(); + QStringList aStringList = aLastSection.split( ":" ); + if ( !aStringList.isEmpty() ) { - _PTR(Study) studyDS( aStudy->studyDS() ); - - bool ok = false; - QStringList aSectionList = aStrings.split( "|" ); - if ( !aSectionList.isEmpty() ) + ok = true; + for ( int i = 0, n = aStringList.size(); i < n; i++ ) { - QString aLastSection = aSectionList.last(); - QStringList aStringList = aLastSection.split( ":" ); - if ( !aStringList.isEmpty() ) - { - ok = true; - for ( int i = 0, n = aStringList.size(); i < n; i++ ) - { - QString aStr = aStringList[i]; - if ( studyDS->IsVariable( aStr.toStdString() ) ) - val.append( aStr + ", " ); - } - - if ( !val.isEmpty() ) - val.remove( val.length() - 2, 2 ); - } + QString aStr = aStringList[i]; + if ( SalomeApp_Application::getStudy()->IsVariable( aStr.toStdString() ) ) + val.append( aStr + ", " ); } - if( !ok ) - val = aStrings; + + if ( !val.isEmpty() ) + val.remove( val.length() - 2, 2 ); } } + if( !ok ) + val = aStrings; } else if ( obj->FindAttribute( attr, "AttributeInteger" ) ) { diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx index 9bdda7525..216b107cd 100644 --- a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx @@ -425,38 +425,35 @@ SalomeApp_DoubleSpinBox::SearchState SalomeApp_DoubleSpinBox::findVariable( cons value = 0; if( SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) { - if( SalomeApp_Study* study = dynamic_cast( app->activeStudy() ) ) - { - _PTR(Study) studyDS = study->studyDS(); + _PTR(Study) studyDS = SalomeApp_Application::getStudy(); - std::string aName = name.toStdString(); - if( studyDS->IsVariable( aName ) ) + std::string aName = name.toStdString(); + if( studyDS->IsVariable( aName ) ) + { + if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) || studyDS->IsString( aName ) ) { - if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) || studyDS->IsString( aName ) ) + if( studyDS->IsString( aName ) ) { - if( studyDS->IsString( aName ) ) - { #ifndef DISABLE_PYCONSOLE - PyConsole_Interp* pyInterp = app->getPyInterp(); - PyLockWrapper aLock; // Acquire GIL - std::string command; - command = "import salome_notebook ; "; - command += "salome_notebook.notebook.setAsReal(\""; - command += aName; - command += "\")"; - bool aResult; - aResult = pyInterp->run(command.c_str()); - if(aResult) - { - return IncorrectType; - } + PyConsole_Interp* pyInterp = app->getPyInterp(); + PyLockWrapper aLock; // Acquire GIL + std::string command; + command = "import salome_notebook ; "; + command += "salome_notebook.notebook.setAsReal(\""; + command += aName; + command += "\")"; + bool aResult; + aResult = pyInterp->run(command.c_str()); + if(aResult) + { + return IncorrectType; + } #endif - } - value = studyDS->GetReal( aName ); - return Found; } - return IncorrectType; + value = studyDS->GetReal( aName ); + return Found; } + return IncorrectType; } } return NotFound; diff --git a/src/SalomeApp/SalomeApp_Engine_i.cxx b/src/SalomeApp/SalomeApp_Engine_i.cxx index 57d4340f3..108cee699 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.cxx +++ b/src/SalomeApp/SalomeApp_Engine_i.cxx @@ -65,7 +65,7 @@ SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theCompone { SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; - if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy())) + if (CORBA::is_nil(theComponent)) return aStreamFile._retn(); // Get a temporary directory to store a file @@ -107,7 +107,7 @@ CORBA::Boolean SalomeApp_Engine_i::Load (SALOMEDS::SComponent_ptr theComponent, bool isMultiFile) { std::cout << "SalomeApp_Engine_i::Load() isMultiFile = " << isMultiFile << std::endl; - if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy())) + if (CORBA::is_nil(theComponent)) return false; // Error somewhere outside - Load() called with diff --git a/src/SalomeApp/SalomeApp_IntSpinBox.cxx b/src/SalomeApp/SalomeApp_IntSpinBox.cxx index 64bf5a306..bb4e01b88 100644 --- a/src/SalomeApp/SalomeApp_IntSpinBox.cxx +++ b/src/SalomeApp/SalomeApp_IntSpinBox.cxx @@ -373,38 +373,35 @@ SalomeApp_IntSpinBox::SearchState SalomeApp_IntSpinBox::findVariable( const QStr value = 0; if( SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ) ) { - if( SalomeApp_Study* study = dynamic_cast( app->activeStudy() ) ) - { - _PTR(Study) studyDS = study->studyDS(); + _PTR(Study) studyDS = SalomeApp_Application::getStudy(); - std::string aName = name.toStdString(); - if( studyDS->IsVariable( aName ) ) + std::string aName = name.toStdString(); + if( studyDS->IsVariable( aName ) ) + { + if( studyDS->IsInteger( aName ) || studyDS->IsString( aName ) ) { - if( studyDS->IsInteger( aName ) || studyDS->IsString( aName ) ) + if( studyDS->IsString( aName ) ) { - if( studyDS->IsString( aName ) ) - { #ifndef DISABLE_PYCONSOLE - PyConsole_Interp* pyInterp = app->getPyInterp(); - PyLockWrapper aLock; // Acquire GIL - std::string command; - command = "import salome_notebook ; "; - command += "salome_notebook.notebook.setAsInteger(\""; - command += aName; - command += "\")"; - bool aResult; - aResult = pyInterp->run(command.c_str()); - if(aResult) - { - return IncorrectType; - } + PyConsole_Interp* pyInterp = app->getPyInterp(); + PyLockWrapper aLock; // Acquire GIL + std::string command; + command = "import salome_notebook ; "; + command += "salome_notebook.notebook.setAsInteger(\""; + command += aName; + command += "\")"; + bool aResult; + aResult = pyInterp->run(command.c_str()); + if(aResult) + { + return IncorrectType; + } #endif - } - value = studyDS->GetInteger( aName ); - return Found; } - return IncorrectType; + value = studyDS->GetInteger( aName ); + return Found; } + return IncorrectType; } } return NotFound; diff --git a/src/SalomeApp/SalomeApp_NoteBook.cxx b/src/SalomeApp/SalomeApp_NoteBook.cxx index 749ce3798..64d75941f 100644 --- a/src/SalomeApp/SalomeApp_NoteBook.cxx +++ b/src/SalomeApp/SalomeApp_NoteBook.cxx @@ -378,7 +378,7 @@ int NoteBook_Table::getUniqueIndex() const * Purpose : Add variables in the table from theStudy */ //============================================================================ -void NoteBook_Table::Init(_PTR(Study) theStudy) +void NoteBook_Table::Init() { isProcessItemChangedSignal = false; @@ -403,10 +403,10 @@ void NoteBook_Table::Init(_PTR(Study) theStudy) myVariableMap.clear(); //Add all variables into the table - std::vector aVariables = theStudy->GetVariableNames(); + std::vector aVariables = SalomeApp_Application::getStudy()->GetVariableNames(); for(int iVar = 0; iVar < aVariables.size(); iVar++ ) { AddRow(QString(aVariables[iVar].c_str()), - Variable2String(aVariables[iVar],theStudy)); + Variable2String(aVariables[iVar])); } //Add empty row @@ -414,8 +414,6 @@ void NoteBook_Table::Init(_PTR(Study) theStudy) isProcessItemChangedSignal = true; ResetMaps(); - - myStudy = theStudy; } //============================================================================ @@ -423,18 +421,18 @@ void NoteBook_Table::Init(_PTR(Study) theStudy) * Purpose : Convert variable values to QString */ //============================================================================ -QString NoteBook_Table::Variable2String(const std::string& theVarName, - _PTR(Study) theStudy) +QString NoteBook_Table::Variable2String(const std::string& theVarName) { + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); QString aResult; - if( theStudy->IsReal(theVarName) ) - aResult = QString::number(theStudy->GetReal(theVarName)); - else if( theStudy->IsInteger(theVarName) ) - aResult = QString::number(theStudy->GetInteger(theVarName)); - else if( theStudy->IsBoolean(theVarName) ) - aResult = theStudy->GetBoolean(theVarName) ? QString("True") : QString("False"); - else if( theStudy->IsString(theVarName) ) - aResult = theStudy->GetString(theVarName).c_str(); + if( aStudy->IsReal(theVarName) ) + aResult = QString::number(aStudy->GetReal(theVarName)); + else if( aStudy->IsInteger(theVarName) ) + aResult = QString::number(aStudy->GetInteger(theVarName)); + else if( aStudy->IsBoolean(theVarName) ) + aResult = aStudy->GetBoolean(theVarName) ? QString("True") : QString("False"); + else if( aStudy->IsString(theVarName) ) + aResult = aStudy->GetString(theVarName).c_str(); return aResult; } @@ -566,7 +564,7 @@ void NoteBook_Table::onItemChanged(QTableWidgetItem* theItem) if( myVariableMap.contains( anIndex ) ) { const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ]; - if( !aVariable.Name.isEmpty() && myStudy->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) ) + if( !aVariable.Name.isEmpty() && SalomeApp_Application::getStudy()->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) ) { if( QMessageBox::warning( parentWidget(), tr( "WARNING" ), tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ), @@ -661,6 +659,7 @@ bool NoteBook_Table::IsUniqueName(const NoteBook_TableRow* theRow) const //============================================================================ void NoteBook_Table::RemoveSelected() { + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); isProcessItemChangedSignal = false; QList aSelectedItems = selectedItems(); if( !(aSelectedItems.size() > 0)) { @@ -678,7 +677,7 @@ void NoteBook_Table::RemoveSelected() else { int nRow = row(aSelectedItems[i]); - if( myStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) ) + if( aStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) ) { if( QMessageBox::warning( parentWidget(), tr( "WARNING" ), tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ), @@ -696,7 +695,7 @@ void NoteBook_Table::RemoveSelected() myVariableMap.remove( index ); removeRow(nRow); myRows.removeAt(nRow); - if(myStudy->IsVariable(aVarName.toLatin1().constData())) + if(aStudy->IsVariable(aVarName.toLatin1().constData())) removedFromStudy = true; } } @@ -757,9 +756,8 @@ void NoteBook_Table::ResetMaps() * Purpose : Constructor */ //============================================================================ -SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent, _PTR(Study) theStudy): - QWidget(parent), - myStudy(theStudy) +SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent): + QWidget(parent) { setObjectName("SalomeApp_NoteBook"); setWindowTitle(tr("NOTEBOOK_TITLE")); @@ -789,7 +787,7 @@ SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent, _PTR(Study) theStudy): connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) ); connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove())); - myTable->Init(myStudy); + myTable->Init(); myDumpedStudyScript = ""; myIsDumpedStudySaved = false; @@ -808,10 +806,8 @@ SalomeApp_NoteBook::~SalomeApp_NoteBook(){} * Purpose : init variable table */ //============================================================================ -void SalomeApp_NoteBook::Init(_PTR(Study) theStudy){ - if(myStudy!= theStudy) - myStudy = theStudy; - myTable->Init(myStudy); +void SalomeApp_NoteBook::Init(){ + myTable->Init(); } @@ -822,7 +818,7 @@ void SalomeApp_NoteBook::Init(_PTR(Study) theStudy){ //============================================================================ void SalomeApp_NoteBook::onVarUpdate(QString theVarName) { - myTable->Init(myStudy); + myTable->Init(); } //============================================================================ @@ -837,6 +833,7 @@ void SalomeApp_NoteBook::onApply() SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) ); return; } + _PTR(Study) aStudy = SalomeApp_Application::getStudy(); double aDVal; int anIVal; @@ -852,7 +849,7 @@ void SalomeApp_NoteBook::onApply() if( aVariableMapRef.contains( anIndex ) ) { QString aRemovedVariable = aVariableMapRef[ anIndex ].Name; - myStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) ); + aStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) ); } } @@ -874,22 +871,22 @@ void SalomeApp_NoteBook::onApply() if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName ) { - myStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ), - std::string( aName.toLatin1().constData() ) ); + aStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ), + std::string( aName.toLatin1().constData() ) ); } } if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) ) - myStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal); + aStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal); else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) ) - myStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal); + aStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal); else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) ) - myStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal); + aStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal); else - myStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString()); + aStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString()); } } myTable->ResetMaps(); @@ -898,7 +895,7 @@ void SalomeApp_NoteBook::onApply() if(app) app->updateActions(); - myStudy->Modified(); + aStudy->Modified(); } //============================================================================ diff --git a/src/SalomeApp/SalomeApp_NoteBook.h b/src/SalomeApp/SalomeApp_NoteBook.h index ba4e96b25..4722ee7aa 100644 --- a/src/SalomeApp/SalomeApp_NoteBook.h +++ b/src/SalomeApp/SalomeApp_NoteBook.h @@ -95,9 +95,8 @@ class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget NoteBook_Table(QWidget * parent = 0); virtual ~NoteBook_Table(); - void Init(_PTR(Study) theStudy); - static QString Variable2String(const std::string& theVarName, - _PTR(Study) theStudy); + void Init(); + static QString Variable2String(const std::string& theVarName); bool IsValid() const; @@ -137,18 +136,16 @@ class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget QList myRemovedRows; VariableMap myVariableMapRef; VariableMap myVariableMap; - - _PTR(Study) myStudy; }; class SALOMEAPP_EXPORT SalomeApp_NoteBook : public QWidget { Q_OBJECT public: - SalomeApp_NoteBook(QWidget * parent , _PTR(Study) theStudy); + SalomeApp_NoteBook(QWidget * parent); virtual ~SalomeApp_NoteBook(); - void Init(_PTR(Study) theStudy); + void Init(); QString getDumpedStudyName() { return myDumpedStudyName; } void setDumpedStudyName(QString theName) { myDumpedStudyName = theName; } @@ -170,7 +167,6 @@ class SALOMEAPP_EXPORT SalomeApp_NoteBook : public QWidget QPushButton* myRemoveButton; QPushButton* myUpdateStudyBtn; - _PTR(Study) myStudy; QString myDumpedStudyScript; // path to script of dumped study QString myDumpedStudyName; bool myIsDumpedStudySaved; diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index beabade90..96445c864 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -82,9 +82,8 @@ class SalomeApp_Study::Observer_i : public virtual POA_SALOMEDS::Observer, QObje public: - Observer_i(_PTR(Study) aStudyDS, SalomeApp_Study* aStudy):QObject(aStudy) + Observer_i( SalomeApp_Study* aStudy):QObject(aStudy) { - myStudyDS=aStudyDS; myStudy=aStudy; fillEntryMap(); } @@ -122,7 +121,7 @@ public: switch(event) { case 1: { //Add sobject - _PTR(SObject) aSObj = myStudyDS->FindObjectID(theID); + _PTR(SObject) aSObj = SalomeApp_Application::getStudy()->FindObjectID(theID); _PTR(SComponent) aSComp = aSObj->GetFatherComponent(); if (!aSComp || aSComp->IsNull()) { @@ -131,7 +130,7 @@ public: } // Mantis issue 0020136: Drag&Drop in OB - _PTR(UseCaseBuilder) aUseCaseBuilder = myStudyDS->GetUseCaseBuilder(); + _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder(); if (aUseCaseBuilder->IsUseCaseNode(aSComp)) { // BEGIN: work with tree nodes structure if (!aUseCaseBuilder->IsUseCaseNode(aSObj)) { // tree node is not yet set, it is a normal situation @@ -386,7 +385,6 @@ private: } private: - _PTR(Study) myStudyDS; SalomeApp_Study* myStudy; EntryMap entry2SuitObject; }; @@ -398,6 +396,7 @@ private: SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) : LightApp_Study( app ), myObserver( 0 ) { + myStudyDS = SalomeApp_Application::getStudy(); } /*! @@ -452,35 +451,7 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) { MESSAGE( "createDocument" ); - // initialize myStudyDS, read HDF file - QString aName = studyName(); - - _PTR(Study) study; - bool showError = !application()->property("open_study_from_command_line").isValid() || - !application()->property("open_study_from_command_line").toBool(); - try { - study = SalomeApp_Application::getStudy(); - } - catch(const SALOME_Exception& ex) { - application()->putInfo(tr(ex.what())); - if ( showError ) - SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), - tr("ERR_ERROR"), tr(ex.what())); - return false; - } - catch(...) { - application()->putInfo(tr("CREATE_DOCUMENT_PROBLEM")); - if ( showError ) - SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), - tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM")); - return false; - } - - if ( !study ) - return false; - - setStudyDS( study ); - setStudyName( QString::fromUtf8(study->URL().c_str()) ); + setStudyName( QString::fromUtf8(myStudyDS->URL().c_str()) ); // create myRoot SalomeApp_RootObject* aRoot=new SalomeApp_RootObject( this ); @@ -492,9 +463,9 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) bool aRet = CAM_Study::createDocument( theStr ); #ifdef WITH_SALOMEDS_OBSERVER - myObserver = new Observer_i(study,this); + myObserver = new Observer_i(this); //attach an observer to the study with notification of modifications - study->attach(myObserver->_this(),true); + myStudyDS->attach(myObserver->_this(),true); #endif emit created( this ); @@ -510,14 +481,12 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) { MESSAGE( "openDocument" ); - // initialize myStudyDS, read HDF file - _PTR(Study) study; + // read HDF file bool res = false; bool showError = !application()->property("open_study_from_command_line").isValid() || !application()->property("open_study_from_command_line").toBool(); try { - study = SalomeApp_Application::getStudy(); - res = study->Open( theFileName.toUtf8().data() ); + res = myStudyDS->Open( theFileName.toUtf8().data() ); } catch(const SALOME_Exception& ex) { application()->putInfo(tr(ex.what())); @@ -537,8 +506,6 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) if ( !res) return false; - setStudyDS( study ); - setRoot( new SalomeApp_RootObject( this ) ); // create myRoot // update loaded data models: call open() and update() on them. @@ -555,7 +522,7 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) #ifdef WITH_SALOMEDS_OBSERVER dynamic_cast( root() )->setToSynchronize(false); - myObserver = new Observer_i(myStudyDS,this); + myObserver = new Observer_i(this); //attach an observer to the study with notification of modifications myStudyDS->attach(myObserver->_this(),true); #endif @@ -563,7 +530,7 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) res = CAM_Study::openDocument( theFileName ); emit opened( this ); - study->IsSaved(true); + myStudyDS->IsSaved(true); bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true ); if ( restore ) { @@ -584,13 +551,6 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) { MESSAGE( "loadDocument" ); - // obtain myStudyDS - _PTR(Study) study = SalomeApp_Application::getStudy(); - if ( !study ) - return false; - - setStudyDS( study ); - setRoot( new SalomeApp_RootObject( this ) ); // create myRoot //SRN: BugID IPAL9021, put there the same code as in a method openDocument @@ -610,7 +570,7 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) #ifdef WITH_SALOMEDS_OBSERVER dynamic_cast( root() )->setToSynchronize(false); - myObserver = new Observer_i(myStudyDS,this); + myObserver = new Observer_i(this); //attach an observer to the study with notification of modifications myStudyDS->attach(myObserver->_this(),true); #endif @@ -726,26 +686,18 @@ void SalomeApp_Study::closeDocument(bool permanently) LightApp_Study::closeDocument(permanently); // close SALOMEDS document - _PTR(Study) studyPtr = studyDS(); - if ( studyPtr ) - { - if ( myObserver ) - myStudyDS->detach( myObserver->_this() ); - if ( permanently ) { - SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop(); - bool isBlocked = desk->signalsBlocked(); - desk->blockSignals( true ); - studyPtr->Clear(); - desk->blockSignals( isBlocked ); + if ( myObserver ) + myStudyDS->detach( myObserver->_this() ); + if ( permanently ) { + SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop(); + bool isBlocked = desk->signalsBlocked(); + desk->blockSignals( true ); + myStudyDS->Clear(); + desk->blockSignals( isBlocked ); #ifndef DISABLE_PYCONSOLE - SalomeApp_Application* app = dynamic_cast( application() ); - app->getPyInterp()->destroy(); + SalomeApp_Application* app = dynamic_cast( application() ); + app->getPyInterp()->destroy(); #endif - } - else { - SALOMEDSClient_Study* aStudy = 0; - setStudyDS( _PTR(Study)(aStudy) ); - } } } @@ -772,13 +724,12 @@ bool SalomeApp_Study::dump( const QString& theFileName, int savePoint; _PTR(AttributeParameter) ap; _PTR(IParameters) ip = ClientFactory::getIParameters(ap); - _PTR(Study) aStudy = studyDS(); - if( ip->isDumpPython( aStudy ) ) - ip->setDumpPython( aStudy ); //Unset DumpPython flag. + if( ip->isDumpPython() ) + ip->setDumpPython(); //Unset DumpPython flag. if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method - ip->setDumpPython( aStudy ); + ip->setDumpPython(); //SRN: create a temporary save point savePoint = SalomeApp_VisualState( dynamic_cast( application() ) ).storeState(); @@ -808,10 +759,10 @@ bool SalomeApp_Study::dump( const QString& theFileName, // Now dump SALOMEDS part that also involves SalomeApp_Engine in case if // any light module is present in the current configuration QFileInfo aFileInfo( theFileName ); - bool res = aStudy->DumpStudy( aFileInfo.absolutePath().toUtf8().data(), - aFileInfo.baseName().toUtf8().data(), - toPublish, - isMultiFile); + bool res = myStudyDS->DumpStudy( aFileInfo.absolutePath().toUtf8().data(), + aFileInfo.baseName().toUtf8().data(), + toPublish, + isMultiFile); if ( toSaveGUI ) removeSavePoint( savePoint ); //SRN: remove the created temporary save point. @@ -840,8 +791,7 @@ bool SalomeApp_Study::isModified() const */ void SalomeApp_Study::Modified() { - if(_PTR(Study) aStudy = studyDS()) - aStudy->Modified(); + myStudyDS->Modified(); LightApp_Study::Modified(); } @@ -927,14 +877,6 @@ bool SalomeApp_Study::openStudyData( const QString& theFileName ) return true; } -/*! - Set studyDS. -*/ -void SalomeApp_Study::setStudyDS( const _PTR(Study)& s ) -{ - myStudyDS = s; -} - /*! Virtual method re-implemented from LightApp_Study in order to create the module object connected to SALOMEDS - SalomeApp_ModuleObject. @@ -968,11 +910,7 @@ CAM_ModuleObject* SalomeApp_Study::createModuleObject( LightApp_DataModel* theDa } if ( !res ){ - _PTR(Study) aStudy = studyDS(); - if ( !aStudy ) - return res; - - _PTR(SComponent) aComp = aStudy->FindComponent( + _PTR(SComponent) aComp = myStudyDS->FindComponent( theDataModel->module()->name().toStdString() ); if ( !aComp ) return res; @@ -1004,16 +942,13 @@ void SalomeApp_Study::addComponent(const CAM_DataModel* dm) // 1. aModule == 0 means that this is a light module (no CORBA enigine) if (!aModule) { // Check SComponent existance - _PTR(Study) aStudy = studyDS(); - if (!aStudy) - return; std::string aCompDataType = dm->module()->name().toStdString(); - _PTR(SComponent) aComp = aStudy->FindComponent(aCompDataType); + _PTR(SComponent) aComp = myStudyDS->FindComponent(aCompDataType); if (!aComp) { // Create SComponent - _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(StudyBuilder) aBuilder = myStudyDS->NewBuilder(); aComp = aBuilder->NewComponent(aCompDataType); aBuilder->SetName(aComp, dm->module()->moduleName().toStdString()); QString anIconName = dm->module()->iconName(); @@ -1032,7 +967,7 @@ void SalomeApp_Study::addComponent(const CAM_DataModel* dm) SalomeApp_DataModel::synchronize( aComp, this ); } else { - _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + _PTR(StudyBuilder) aBuilder = myStudyDS->NewBuilder(); aBuilder->SetName(aComp, dm->module()->moduleName().toStdString()); QString anIconName = dm->module()->iconName(); if (!anIconName.isEmpty()) { @@ -1055,7 +990,6 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm // SalomeApp_DataModel* aDM = (SalomeApp_DataModel*)(dm); SalomeApp_Module* aModule = dynamic_cast( dm->module() ); - _PTR(Study) aStudy = studyDS(); // shared_ptr cannot be used here _PTR(SComponent) aSComp; QString anEngine; // 1. aModule == 0 means that this is a light module (no CORBA enigine) @@ -1063,7 +997,7 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm // Issue 21377 - using separate engine for each type of light module std::string aCompDataType = dm->module()->name().toStdString(); anEngine = SalomeApp_Engine_i::EngineIORForComponent( aCompDataType.c_str(), true ).c_str(); - aSComp = aStudy->FindComponent( aCompDataType ); + aSComp = myStudyDS->FindComponent( aCompDataType ); } else { SalomeApp_DataModel* aDM = dynamic_cast( dm ); @@ -1074,11 +1008,11 @@ bool SalomeApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm anEngine = aDM->getModule()->engineIOR(); if ( anEngine.isEmpty() ) return false; - aSComp = aStudy->FindComponentID( std::string( anId.toLatin1() ) ); + aSComp = myStudyDS->FindComponentID( std::string( anId.toLatin1() ) ); } } if ( aSComp ) { - _PTR(StudyBuilder) aBuilder( aStudy->NewBuilder() ); + _PTR(StudyBuilder) aBuilder( myStudyDS->NewBuilder() ); if ( aBuilder ) { try { aBuilder->LoadWith( aSComp, std::string( anEngine.toLatin1() ) ); diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index 2f9f48ef2..2284df8db 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -102,7 +102,7 @@ protected: protected: virtual void dataModelInserted( const CAM_DataModel* ); virtual bool openDataModel( const QString&, CAM_DataModel* ); - void setStudyDS(const _PTR(Study)& s ); + virtual CAM_ModuleObject* createModuleObject( LightApp_DataModel* theDataModel, SUIT_DataObject* theParent ) const; protected slots: diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx index 043a2e30c..55a4765c7 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx @@ -25,6 +25,7 @@ // Author : Roman NIKOLAEV #include "SalomeApp_StudyPropertiesDlg.h" +#include "SalomeApp_Application.h" #include "SalomeApp_Study.h" #include "SUIT_Session.h" @@ -69,12 +70,6 @@ SalomeApp_StudyPropertiesDlg::SalomeApp_StudyPropertiesDlg(QWidget* parent) setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint ); - // Display study properties - SalomeApp_Study* study = - dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); - if (study) - myStudyDoc = study->studyDS(); - //Author QLabel* authorLbl = new QLabel(tr("PRP_AUTHOR"),this); myAuthor = new QLineEdit(this); @@ -173,10 +168,10 @@ SalomeApp_StudyPropertiesDlg::~SalomeApp_StudyPropertiesDlg() */ void SalomeApp_StudyPropertiesDlg::initData() { - bool hasData = (myStudyDoc != NULL); + bool hasData = (SalomeApp_Application::getStudy() != NULL); _PTR(AttributeStudyProperties) propAttr; if (hasData) - propAttr = myStudyDoc->GetProperties(); + propAttr = SalomeApp_Application::getStudy()->GetProperties(); hasData = hasData && propAttr; if (hasData) { @@ -268,7 +263,7 @@ void SalomeApp_StudyPropertiesDlg::initData() */ void SalomeApp_StudyPropertiesDlg::clickOnOk() { - _PTR(AttributeStudyProperties) propAttr = myStudyDoc->GetProperties(); + _PTR(AttributeStudyProperties) propAttr = SalomeApp_Application::getStudy()->GetProperties(); //Firstly, store locked flag if(propAttr) { bool bLocked = myLocked->isChecked(); diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h index 7289eb800..a88d54edb 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h @@ -60,7 +60,6 @@ private: void initData(); private: - _PTR(Study) myStudyDoc; bool myIsChanged; QLineEdit* myAuthor; QLabel* myDate; diff --git a/src/SalomeApp/SalomeApp_TypeFilter.cxx b/src/SalomeApp/SalomeApp_TypeFilter.cxx index 8d296e815..d2652792b 100644 --- a/src/SalomeApp/SalomeApp_TypeFilter.cxx +++ b/src/SalomeApp/SalomeApp_TypeFilter.cxx @@ -24,6 +24,7 @@ #include "LightApp_DataOwner.h" #include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" /*! Constructor. @@ -48,20 +49,18 @@ bool SalomeApp_TypeFilter::isOk( const SUIT_DataOwner* sOwner ) const { const LightApp_DataOwner* owner = dynamic_cast ( sOwner ); - SalomeApp_Study* aDoc = getStudy(); - if (owner && aDoc && aDoc->studyDS()) + if (owner) + { + QString entry = owner->entry(); + + _PTR(SObject) aSObj( SalomeApp_Application::getStudy()->FindObjectID( entry.toStdString() ) ); + if (aSObj) { - _PTR(Study) aStudy = aDoc->studyDS(); - QString entry = owner->entry(); - - _PTR(SObject) aSObj( aStudy->FindObjectID( entry.toStdString() ) ); - if (aSObj) - { - _PTR(SComponent) aComponent(aSObj->GetFatherComponent()); - if ( aComponent && (aComponent->ComponentDataType() == myKind.toStdString()) ) - return true; - } + _PTR(SComponent) aComponent(aSObj->GetFatherComponent()); + if ( aComponent && (aComponent->ComponentDataType() == myKind.toStdString()) ) + return true; } + } return false; } diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index b767eee7a..d75e202a2 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -210,7 +210,7 @@ Launch a new session or close the study. QUE_DOC_ALREADYEXIST - The document %1 already exists in study manager. + The document %1 already exists. Do you want to reload it ? diff --git a/src/SalomeApp/resources/SalomeApp_msg_fr.ts b/src/SalomeApp/resources/SalomeApp_msg_fr.ts index b3c87d068..c50fe9355 100755 --- a/src/SalomeApp/resources/SalomeApp_msg_fr.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_fr.ts @@ -210,7 +210,7 @@ Lancez une nouvelle session ou fermez l'étude en cours. QUE_DOC_ALREADYEXIST - Le document %1 existe déjà dans le gestionnaire d'études. + Le document %1 existe déjà. Voulez-vous le recharger ? diff --git a/src/SalomeApp/resources/SalomeApp_msg_ja.ts b/src/SalomeApp/resources/SalomeApp_msg_ja.ts index ff59df505..7dab9b3a4 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_ja.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_ja.ts @@ -210,7 +210,7 @@ QUE_DOC_ALREADYEXIST - ドキュメント %1 は研究のマネージャーに既に存在します。それを再読み込みしますか。 + ドキュメント %1 はの存在。それを再読み込みしますか。 MEN_RENAME_VS diff --git a/src/TOOLSGUI/CMakeLists.txt b/src/TOOLSGUI/CMakeLists.txt index d391fc676..91bef71a8 100755 --- a/src/TOOLSGUI/CMakeLists.txt +++ b/src/TOOLSGUI/CMakeLists.txt @@ -44,8 +44,10 @@ SET(_link_LIBRARIES ${CAS_KERNEL} ${KERNEL_SalomeIDLKernel} ${KERNEL_SALOMELocalTrace} + ${KERNEL_SalomeDSClient} ${KERNEL_SalomeNS} ${KERNEL_OpUtil} + ${KERNEL_SalomeKernelHelpers} ${OMNIORB_LIBRARIES} qtx suit ) diff --git a/src/TOOLSGUI/ToolsGUI.cxx b/src/TOOLSGUI/ToolsGUI.cxx index aba358027..6dd203ad9 100755 --- a/src/TOOLSGUI/ToolsGUI.cxx +++ b/src/TOOLSGUI/ToolsGUI.cxx @@ -25,6 +25,8 @@ // Author : Nicolas REJNERI // #include "ToolsGUI.h" +#include +#include /*! \class ToolsGUI @@ -38,8 +40,7 @@ \param theId sub-object identifier \return \c true if an object (sub-object) is visible */ -bool ToolsGUI::GetVisibility( _PTR(Study) theStudy, - _PTR(SObject) theObj, +bool ToolsGUI::GetVisibility( _PTR(SObject) theObj, void* theId ) { _PTR(GenericAttribute) anAttr; @@ -59,12 +60,12 @@ bool ToolsGUI::GetVisibility( _PTR(Study) theStudy, \return theValue new visibility value \param theId sub-object identifier */ -bool ToolsGUI::SetVisibility( _PTR(Study) theStudy, - const char* theEntry, +bool ToolsGUI::SetVisibility( const char* theEntry, const bool theValue, void* theId ) { - _PTR(SObject) anObj ( theStudy->FindObjectID( theEntry ) ); + _PTR(Study) aStudy = ClientFactory::Study(KERNEL::getStudy()); + _PTR(SObject) anObj ( aStudy->FindObjectID( theEntry ) ); if ( anObj ) { @@ -76,7 +77,7 @@ bool ToolsGUI::SetVisibility( _PTR(Study) theStudy, } else if ( theValue ) { - _PTR(StudyBuilder) aBuilder (theStudy->NewBuilder()); + _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder()); _PTR(AttributeGraphic) anAttr (aBuilder->FindOrCreateAttribute(anObj, "AttributeGraphic")); anAttr->SetVisibility( (unsigned long)theId, theValue ); } diff --git a/src/TOOLSGUI/ToolsGUI.h b/src/TOOLSGUI/ToolsGUI.h index 5a2190d7a..05ab64815 100755 --- a/src/TOOLSGUI/ToolsGUI.h +++ b/src/TOOLSGUI/ToolsGUI.h @@ -43,11 +43,9 @@ class TOOLSGUI_EXPORT ToolsGUI { public : - static bool GetVisibility( _PTR(Study) theStudy, - _PTR(SObject) theObj, + static bool GetVisibility( _PTR(SObject) theObj, void* theId ); - static bool SetVisibility( _PTR(Study) theStudy, - const char* theEntry, + static bool SetVisibility( const char* theEntry, const bool theValue, void* theId ); };