]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/GuiHelpers/StandardApp_Module.cxx
Salome HOME
Copyright update 2021
[modules/gui.git] / src / GuiHelpers / StandardApp_Module.cxx
index ad91a22ec04c13331ac25c859c27794333888e0c..380beaad9ec228ccccec6a2798e82eea7d7e2a30 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2011-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -20,6 +20,8 @@
 
 #include "StandardApp_Module.hxx"
 
+#include "SALOME_GuiServices.hxx"
+
 #include <SUIT_Desktop.h>
 #include <SUIT_Study.h>
 #include <SalomeApp_Application.h>
@@ -76,7 +78,7 @@ void StandardApp_Module::initialize( CAM_Application* app )
   // share/salome/resources/xsalome/SalomeApp.xml in the install
   // directory.
   _defaultMenuId = this->createMenu( QCHARSTAR(moduleName()), -1, -1, 30 );
-  _defaultToolbarId = this->createTool ( QCHARSTAR(moduleName()) );
+  _defaultToolbarId = this->createTool ( QCHARSTAR(moduleName()), moduleName() );
   _actionId_internalCount = StandardApp_Module::ACTIONID_DEFAULT_INIT_VALUE;
 
   //
@@ -136,9 +138,9 @@ int StandardApp_Module::createStandardAction(const QString& label,
   }
 
   // Creating the action
-  QAction * action= this->createAction( effIdentifier, label, actionIcon,
-                                        label, effToolTip, 0, getApp()->desktop(),
-                                        false, slotobject, slotmember);
+  this->createAction( effIdentifier, label, actionIcon,
+                      label, effToolTip, 0, getApp()->desktop(),
+                      false, slotobject, slotmember);
 
   return effIdentifier;
 }
@@ -169,14 +171,17 @@ void StandardApp_Module::addActionInMenubar(int actionId, int menuId) {
  * Add the specified action as an item in the popup menu, with the
  * specified visible rule. The default is "visible for object browser".
  */
-void StandardApp_Module::addActionInPopupMenu(int actionId,const QString& rule) {
+void StandardApp_Module::addActionInPopupMenu(int actionId,const QString& menus,const QString& rule) {
   // _GBO_ for a fine customization of the rule (for example with a
   // test on the type of the selected object), see the LIGTH module:
   // implement "LightApp_Selection*    createSelection() const;"
   int parentId = -1;
   QtxPopupMgr* mgr = this->popupMgr();
   this->action( actionId )->setIconVisibleInMenu(true);
-  mgr->insert ( this->action( actionId ), parentId, 0 );
+  if (! menus.isEmpty())
+    mgr->insert ( this->action( actionId ), menus, parentId, 0 );
+  else
+    mgr->insert ( this->action( actionId ), parentId, 0 );
   mgr->setRule( this->action( actionId ), rule, QtxPopupMgr::VisibleRule );
 }
 
@@ -208,7 +213,9 @@ void StandardApp_Module::windows( QMap<int, int>& theMap ) const
 {
   theMap.clear();
   theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+#ifndef DISABLE_PYCONSOLE
   theMap.insert( SalomeApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
+#endif
 }
 
 // Module's engine IOR
@@ -274,7 +281,7 @@ bool StandardApp_Module::activateModule( SUIT_Study* theStudy )
   setToolShown( true );
 
   if ( this->createStudyComponentAtActivation() ) {
-    this->createStudyComponent(theStudy);
+    this->createStudyComponent();
   }
 
   return bOk;
@@ -296,12 +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 aSMObject = aNamingService->Resolve("/myStudyManager");
-  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
-  SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id());
+  SALOMEDS::Study_var aDSStudy = GUI::getStudyServant();
 
   SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent(QCHARSTAR(moduleName()));
   if (aFather->_is_nil())