From: mpa Date: Thu, 2 Feb 2017 07:45:05 +0000 (+0300) Subject: code improvement X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=858facdbc728c15ce2d4b8f700f0418d3f4918d1;p=modules%2Fgui.git code improvement --- diff --git a/doc/salome/gui/input/howtos_and_best_practives.doc b/doc/salome/gui/input/howtos_and_best_practives.doc index 8d3f9de49..bb32f91cb 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 = GUI::getStudy(); // study + SALOMEDS::Study_var study = GUI::getStudyServant(); // 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/GUI_PY/helper.py b/src/GUI_PY/helper.py index ce652e4e8..d1f0ca992 100644 --- a/src/GUI_PY/helper.py +++ b/src/GUI_PY/helper.py @@ -67,7 +67,7 @@ def getSObjectSelected(): ''' sobj = None entry = None - study = services.getStudy() + study = salome.myStudy if SalomeGUI.SelectedCount() == 1: # We only considere the first element of the list. If you need # something else, create another function in your own context. @@ -95,7 +95,7 @@ def deleteSObjectSelected(): ''' sobj, entry = getSObjectSelected() if ( sobj ): - study = services.getStudy() + study = salome.myStudy builder = study.NewBuilder() builder.RemoveObject( sobj ) SalomeGUI.updateObjBrowser() diff --git a/src/GuiHelpers/SALOME_AppStudyEditor.cxx b/src/GuiHelpers/SALOME_AppStudyEditor.cxx index df96b6d3b..d024287ff 100644 --- a/src/GuiHelpers/SALOME_AppStudyEditor.cxx +++ b/src/GuiHelpers/SALOME_AppStudyEditor.cxx @@ -35,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 = GUI::getStudy()->FindObjectID(iobject->getEntry()); + SALOMEDS::SObject_var sobject = GUI::getStudyServant()->FindObjectID(iobject->getEntry()); return sobject._retn(); } } diff --git a/src/GuiHelpers/SALOME_GuiServices.cxx b/src/GuiHelpers/SALOME_GuiServices.cxx index 208ae10cf..c834860cb 100644 --- a/src/GuiHelpers/SALOME_GuiServices.cxx +++ b/src/GuiHelpers/SALOME_GuiServices.cxx @@ -72,11 +72,10 @@ namespace GUI { * This returns the current active study if an active study is * defined in the SALOME session, returns null otherwise. */ - SALOMEDS::Study_ptr getStudy() { - return KERNEL::getStudy(); + SALOMEDS::Study_ptr getStudyServant() { + return KERNEL::getStudyServant(); } - // __GBO__ Question: what is the difference between a // SALOMEDS::Study and a SalomeApp_Study? SalomeApp_Study* getSalomeAppActiveStudy() { @@ -104,8 +103,7 @@ namespace GUI { // retrieve the SALOMEDS::Study servant first and the to // request this servant to get the SObject given its entry. // - SALOMEDS::Study_var study = KERNEL::getStudy(); - SALOMEDS::SObject_ptr sobject = study->FindObjectID(iobject->getEntry()); + SALOMEDS::SObject_ptr sobject = KERNEL::getStudyServant()->FindObjectID(iobject->getEntry()); return sobject; } } diff --git a/src/GuiHelpers/SALOME_GuiServices.hxx b/src/GuiHelpers/SALOME_GuiServices.hxx index ae48d6459..a7565ff9d 100644 --- a/src/GuiHelpers/SALOME_GuiServices.hxx +++ b/src/GuiHelpers/SALOME_GuiServices.hxx @@ -58,7 +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 getStudy(); + SALOMEGUIHELPERS_EXPORT SALOMEDS::Study_ptr getStudyServant(); // Another way to get the active study (to be converted in // SALOMEDS::Study): diff --git a/src/GuiHelpers/StandardApp_Module.cxx b/src/GuiHelpers/StandardApp_Module.cxx index f1636d52c..051958daa 100644 --- a/src/GuiHelpers/StandardApp_Module.cxx +++ b/src/GuiHelpers/StandardApp_Module.cxx @@ -20,6 +20,8 @@ #include "StandardApp_Module.hxx" +#include "SALOME_GuiServices.hxx" + #include #include #include @@ -279,7 +281,7 @@ bool StandardApp_Module::activateModule( SUIT_Study* theStudy ) setToolShown( true ); if ( this->createStudyComponentAtActivation() ) { - this->createStudyComponent(theStudy); + this->createStudyComponent(); } return bOk; @@ -301,11 +303,9 @@ bool StandardApp_Module::createStudyComponentAtActivation() { * the module. This component is associated to the engine (return by * getEngine()) if the engine is a SALOMEDS::Driver. */ -void StandardApp_Module::createStudyComponent(SUIT_Study* theStudy) { +void StandardApp_Module::createStudyComponent() { - SALOME_NamingService *aNamingService = SalomeApp_Application::namingService(); - CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study"); - SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aStudyObject); + SALOMEDS::Study_var aDSStudy = GUI::getStudyServant(); SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent(QCHARSTAR(moduleName())); if (aFather->_is_nil()) diff --git a/src/GuiHelpers/StandardApp_Module.hxx b/src/GuiHelpers/StandardApp_Module.hxx index 62dad7d0e..acf1a4c19 100644 --- a/src/GuiHelpers/StandardApp_Module.hxx +++ b/src/GuiHelpers/StandardApp_Module.hxx @@ -103,7 +103,7 @@ protected: virtual void createModuleActions(); /* Use this to create a root entry in the study for this module */ - void createStudyComponent(SUIT_Study*); + void createStudyComponent(); /* Implement this to say if study component entry should be created at activation step */ virtual bool createStudyComponentAtActivation(); diff --git a/src/TOOLSGUI/ToolsGUI.cxx b/src/TOOLSGUI/ToolsGUI.cxx index 6dd203ad9..253389ad7 100755 --- a/src/TOOLSGUI/ToolsGUI.cxx +++ b/src/TOOLSGUI/ToolsGUI.cxx @@ -35,7 +35,6 @@ /*! \brief Get visibility value of the "AttributeGraphic" attribute. - \param theStudy study \param theObj object \param theId sub-object identifier \return \c true if an object (sub-object) is visible @@ -55,7 +54,6 @@ bool ToolsGUI::GetVisibility( _PTR(SObject) theObj, /*! \brief Set visibility value of the "AttributeGraphic" attribute. - \param theStudy study \param theObj object \return theValue new visibility value \param theId sub-object identifier @@ -64,7 +62,7 @@ bool ToolsGUI::SetVisibility( const char* theEntry, const bool theValue, void* theId ) { - _PTR(Study) aStudy = ClientFactory::Study(KERNEL::getStudy()); + _PTR(Study) aStudy = ClientFactory::Study(KERNEL::getStudyServant()); _PTR(SObject) anObj ( aStudy->FindObjectID( theEntry ) ); if ( anObj )