Salome HOME
Issue #1896: Inspect SALOME modules before loading of XML configurations
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Jan 2017 08:23:55 +0000 (11:23 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Jan 2017 08:29:31 +0000 (11:29 +0300)
src/Config/CMakeLists.txt
src/Config/ConfigAPI.i [new file with mode: 0644]
src/Config/Config_swig.h [new file with mode: 0644]
src/Config/plugins.xml.in
src/Model/Model_Session.cpp
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h

index 5e0123e9c57aca894ffb7004a54f2eb352a6b1e8..831f62020162a31695440230b84bc2034865adbb 100644 (file)
@@ -2,6 +2,8 @@
 
 INCLUDE(Common)
 INCLUDE(XMLProcessing)
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(${SWIG_USE_FILE})
 
 INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
                      ${PYTHON_INCLUDE_DIR})
@@ -46,6 +48,23 @@ SET(PROJECT_SOURCES
   Config_Translator.cpp
 )
 
+SET(CMAKE_SWIG_FLAGS -threads -Wall)
+SET_SOURCE_FILES_PROPERTIES(ConfigAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(ConfigAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+SET(SWIG_SCRIPTS
+  ${CMAKE_CURRENT_BINARY_DIR}/ConfigAPI.py
+)
+SET(SWIG_LINK_LIBRARIES
+  Config
+  ${PYTHON_LIBRARIES}
+)
+SWIG_ADD_MODULE(ConfigAPI python ConfigAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(ConfigAPI ${SWIG_LINK_LIBRARIES})
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_ConfigAPI PROPERTIES DEBUG_OUTPUT_NAME _ConfigAPI_d)
+ENDIF(WIN32)
+
+
 SET(XML_RESOURCES
   ${CMAKE_CURRENT_BINARY_DIR}/plugins.xml
   dataModel.xml
@@ -106,3 +125,6 @@ CONFIGURE_FILE(
 
 INSTALL(TARGETS Config DESTINATION ${SHAPER_INSTALL_BIN})
 INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
+
+INSTALL(TARGETS _ConfigAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})
diff --git a/src/Config/ConfigAPI.i b/src/Config/ConfigAPI.i
new file mode 100644 (file)
index 0000000..26d5fc3
--- /dev/null
@@ -0,0 +1,14 @@
+/* Config.i */
+
+%module ConfigAPI
+%{
+  #include "Config_swig.h"
+%}
+
+// to avoid error on this
+#define CONFIG_EXPORT
+
+%include "typemaps.i"
+%include "std_string.i"
+
+%include "Config_ModuleReader.h"
diff --git a/src/Config/Config_swig.h b/src/Config/Config_swig.h
new file mode 100644 (file)
index 0000000..00c8ae2
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    Config_swig.h
+// Created: Jan 16, 2017
+// Author:  Vitaly SMETANNIKOV
+
+#ifndef SRC_CONFIG_SWIG_H_
+#define SRC_CONFIG_SWIG_H_
+
+  #include "Config_ModuleReader.h"
+
+#endif /* SRC_CONFIG_SWIG_H_ */
index e2b18a79c289e4bc0326ad46c9deb5de04c0c011..2969b9da6eeec9f779173f80e708f4a4e65ab53c 100644 (file)
@@ -13,7 +13,7 @@
   <plugin library="CollectionPlugin" configuration="plugin-Collection.xml"/>
   <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
   <plugin script="addons_Features" configuration="addons_Features.xml"/>
-  <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
+  <plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="GEOM"/>
   <plugin library="ParametersPlugin" configuration="plugin-Parameters.xml"/>
 @DEFAULT_SOLVER@
 <!--
index 7081ebd418b4cdbfb0dee22917dec9040c1f5d4d..cbe0e6a523da9f3ebc457e5f65ebf67ec3088a4f 100644 (file)
@@ -191,6 +191,7 @@ std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
   if (aFirstCall) {
     // to be sure that plugins are loaded,
     // even before the first "createFeature" call (in unit tests)
+
     LoadPluginsInfo();
     // creation of the root document is always outside of the transaction, so, avoid checking it
     setCheckTransactions(false);
@@ -434,7 +435,7 @@ void Model_Session::LoadPluginsInfo()
 {
   if (myPluginsInfoLoaded)  // nothing to do
     return;
-
+  Config_ModuleReader::loadScript("salome.shaper.initConfig");
   // Read plugins information from XML files
   Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT());
   aModuleReader.readAll();
index afaaf6a2cdf612ab5e281d5b3b8665bb10fab27f..5c71120f681b20af62eda2345edf8dd764059c43 100644 (file)
@@ -121,7 +121,6 @@ SHAPERGUI::~SHAPERGUI()
 void SHAPERGUI::initialize(CAM_Application* theApp)
 {
   LightApp_Module::initialize(theApp);
-  inspectSalomeModules();
 
   myWorkshop->startApplication();
   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>(theApp);
@@ -663,15 +662,6 @@ void SHAPERGUI::putInfo(const QString& theInfo, const int theMSecs)
   application()->putInfo(theInfo, theMSecs);
 }
 
-void SHAPERGUI::inspectSalomeModules()
-{
-  QStringList aModuleNames;
-  getApp()->modules(aModuleNames, false);
-  foreach(QString eachModule, aModuleNames) {
-    Config_ModuleReader::addDependencyModule(eachModule.toStdString());
-  }
-}
-
 bool SHAPERGUI::abortAllOperations()
 {
   return workshop()->operationMgr()->abortAllOperations();
index 9b9f28aab21563ce5396c31e64fa683094148665..5e1c23501fbdfe6a7f076c78c795f5d9acfc6557 100644 (file)
@@ -136,9 +136,6 @@ Q_OBJECT
   /// \brief Set flag about opened document state
   void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
 
-  /// Register current modules of SALOME
-  void inspectSalomeModules();
-
  public slots:
   /// \brief The method is redefined to connect to the study viewer before the data
   /// model is filled by opened file. This file open will flush redisplay signals for,