Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Wed, 10 Sep 2014 15:07:54 +0000 (19:07 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 10 Sep 2014 15:07:54 +0000 (19:07 +0400)
18 files changed:
build_Salome740_deb.bat [new file with mode: 0644]
build_Salome740_rel.bat [new file with mode: 0644]
env_Salome.bat [new file with mode: 0644]
salomeRun.bat
src/Model/Model_PluginManager.cpp
src/ModelAPI/ModelAPI_Events.h
src/NewGeom/CMakeLists.txt
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_IPrefMgr.h [new file with mode: 0644]
src/XGUI/XGUI_Preferences.cpp
src/XGUI/XGUI_Preferences.h
src/XGUI/XGUI_SalomeConnector.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

diff --git a/build_Salome740_deb.bat b/build_Salome740_deb.bat
new file mode 100644 (file)
index 0000000..130599b
--- /dev/null
@@ -0,0 +1,19 @@
+@ECHO OFF
+
+REM Find absolute path to ROOT_DIR 
+@SET PARENT_DIR=%~dp0..
+@SET ROOT_DIR=
+pushd %PARENT_DIR%
+@SET ROOT_DIR=%CD%
+popd
+
+@SET SRC_DIR=%ROOT_DIR%\sources
+@SET OCC_LIB_PREFIX=d
+
+call %SRC_DIR%\env_Salome.bat d
+mkdir %ROOT_DIR%\build
+cd %ROOT_DIR%\build
+
+cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
+
+start "" %MSVC_EXE% NewGEOM.sln
diff --git a/build_Salome740_rel.bat b/build_Salome740_rel.bat
new file mode 100644 (file)
index 0000000..26fbe15
--- /dev/null
@@ -0,0 +1,18 @@
+@ECHO OFF
+
+REM Find absolute path to ROOT_DIR 
+@SET PARENT_DIR=%~dp0..
+@SET ROOT_DIR=
+pushd %PARENT_DIR%
+@SET ROOT_DIR=%CD%
+popd
+
+@SET SRC_DIR=%ROOT_DIR%\sources
+
+call %SRC_DIR%\env_Salome.bat
+mkdir %ROOT_DIR%\build
+cd %ROOT_DIR%\build
+
+cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
+
+start "" %MSVC_EXE% NewGEOM.sln
diff --git a/env_Salome.bat b/env_Salome.bat
new file mode 100644 (file)
index 0000000..fafb466
--- /dev/null
@@ -0,0 +1,93 @@
+@echo off
+
+IF NOT EXIST "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" GOTO ERROR1
+
+@REM Load local settings from file localenv.bat that should be located in the root directory
+if "%ROOT_DIR%" == "" (
+  set ROOT_DIR=%~dp0..
+)
+
+if exist "%ROOT_DIR%\localenv.bat" (
+  echo Setting local environment from %ROOT_DIR%\localenv.bat
+  call "%ROOT_DIR%\localenv.bat"
+) else (
+  echo Warning: file %ROOT_DIR%\localenv.bat does not exist; using default environment
+)
+
+if "%SALOME_ROOT_DIR%" == "" (
+  set SALOME_ROOT_DIR=%ROOT_DIR%\SALOME
+)
+
+if "%SOLVESPACE_ROOT_DIR%" == "" (
+  SET SOLVESPACE_ROOT_DIR=%ROOT_DIR%\products\solvespace-2.0
+  SET PATH=%SOLVESPACE_ROOT_DIR%\lib;"%PATH%"
+)
+
+cd %SALOME_ROOT_DIR%\WORK
+call set_env.bat %1
+call "%PDIR%\env_compile.bat"
+cd %ROOT_DIR%
+
+@REM -------------------------
+@REM Python
+@SET PYTHON_LIB_DIR=%PYTHON_ROOT_DIR%\libs
+@SET PYTHON_INC_DIR=%PYTHON_ROOT_DIR%\include
+@REM -------------------------
+
+@REM -------------------------
+@REM CASCADE
+@SET PATH=%CASROOT%;%CASROOT%\win32\bin%OCC_LIB_PREFIX%;%PATH%
+@SET LIB=%CASROOT%\win32\lib%OCC_LIB_PREFIX%;%LIB%
+@set CSF_MDTVFontDirectory=%CASROOT%\src\FontMFT
+@set CSF_LANGUAGE=us
+@set MMGT_CLEAR=1
+@set CSF_EXCEPTION_PROMPT=1
+@set CSF_SHMessage=%CASROOT%\src\SHMessage
+@set CSF_MDTVTexturesDirectory=%CASROOT%\src\Textures
+@set CSF_XSMessage=%CASROOT%\src\XSMessage
+@set CSF_StandardDefaults=%CASROOT%\src\StdResource
+@set CSF_PluginDefaults=%CASROOT%\src\StdResource
+@set CSF_XCAFDefaults=%CASROOT%\src\StdResource
+@set CSF_StandardLiteDefaults=%CASROOT%\src\StdResource
+@set CSF_UnitsLexicon=%CASROOT%\src\UnitsAPI\Lexi_Expr.dat
+@set CSF_UnitsDefinition=%CASROOT%\src\UnitsAPI\Units.dat
+@set CSF_IGESDefaults=%CASROOT%\src\XSTEPResource
+@set CSF_STEPDefaults=%CASROOT%\src\XSTEPResource
+@set CSF_XmlOcafResource=%CASROOT%\src\XmlOcafResource
+@REM -------------------------
+
+@REM -------------------------
+@REM Create launch path
+rem @SET PATH=%LIBXML2_ROOT_DIR%\bin;%PATH%
+rem @SET PATH=%PDIR%\tbb\bin;%PATH%
+rem @SET PATH=%PDIR%\freeimage-3.15.4\bin;%PATH%
+rem @SET PATH=%PDIR%\ftgl-2.1.3\bin;%PATH%
+rem @SET PATH=%PDIR%\freetype-2.4.11\bin;%PATH%
+rem @SET PATH=%PDIR%\gl2ps-1.3.8\bin;%PATH%
+rem @SET PATH=%PDIR%\qwt-5.2.1\lib;%PATH%
+rem @SET PATH=%SOLVESPACE_ROOT_DIR%\lib;%PATH%
+@REM -------------------------
+
+@REM -------------------------
+@SET PYTHONHOME=%PYTHON_ROOT_DIR%
+@SET PYTHON_INCLUDE=%PYTHONHOME%\include
+@REM -------------------------
+
+
+IF "%ARCH%" == "Win64" (
+  call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" x64
+) ELSE (
+  IF "%ARCH%" == "Win32" (
+    call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" x86
+  ) ELSE (
+    echo Wrong architecture is used. Win32 or Win64 architecture is allowed only.
+    echo Refer to the set_env.bat script.
+  )
+)
+
+@SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins
+@SET PATH=%ROOT_DIR%\install\plugins;%ROOT_DIR%\install\bin;%PATH%
+@SET PYTHONPATH=%ROOT_DIR%\install\swig;%PYTHONPATH%
+
+@SET LightAppConfig=%ROOT_DIR%\install\share\salome\resources\newgeom;%GUI_ROOT_DIR%\share\salome\resources\gui
+@SET NewGeomResources=%ROOT_DIR%\install\resources
index a68091b43421c35b46a86d594072ffd3541f490e..a2fa7d3dd0f78fb47a8a02135df7c9568af768db 100644 (file)
@@ -1,30 +1,5 @@
 @ECHO OFF
 
-REM Find absolute path to ROOT_DIR 
-@SET PARENT_DIR=%~dp0..
-@SET ROOT_DIR=
-pushd %PARENT_DIR%
-@SET ROOT_DIR=%CD%
-popd
+call env_Salome.bat
 
-@SET SRC_DIR=%ROOT_DIR%\sources
-@SET OCC_LIB_PREFIX=d
-
-@SET SALOME_ROOT_DIR=%ROOT_DIR%\SALOME-7.3.0-WIN32
-@SET SOLVESPACE_ROOT_DIR=%ROOT_DIR%\products\solvespace-2.0
-@SET NEWGEOM_ROOT_DIR=%ROOT_DIR%\install
-@SET PATH=%SALOME_ROOT_DIR%;%PATH%
-
-
-call %SALOME_ROOT_DIR%\env_launch.bat
-rem Unfortunately in "env_launch.bat" only KERNEL is added as a module, so add GUI manually
-call %SALOME_ROOT_DIR%\set_one_module_env.bat GUI
-
-@SET PATH=%SOLVESPACE_ROOT_DIR%\lib;%PATH%
-@SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins
-@SET PATH=%PATH%;%NEWGEOM_ROOT_DIR%\bin;%NEWGEOM_ROOT_DIR%\plugins
-
-@SET LightAppConfig=%ROOT_DIR%\install\share\salome\resources\newgeom;%SALOME_ROOT_DIR%\MODULES\GUI\share\salome\resources\gui
-
-
-SuitApp.exe LightApp -style salome --modules=NewGeom --uselicense --noexcepthandling
+SuitApp.exe LightApp --modules=NewGeom
index 06893e6fc343c6615bac7b9f097d1cccb56af633..ad5767a5af0d73b470bce966285eb5be7a974ff1 100644 (file)
@@ -159,6 +159,9 @@ void Model_PluginManager::LoadPluginsInfo()
 void Model_PluginManager::registerPlugin(ModelAPI_Plugin* thePlugin)
 {
   myPluginObjs[myCurrentPluginName] = thePlugin;
+  static Events_ID EVENT_LOAD = Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED);
+  ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD);
+  Events_Loop::loop()->flush(EVENT_LOAD);
 }
 
 ModelAPI_ValidatorsFactory* Model_PluginManager::validators()
index 89b1fd5b941773551d7a8e2782771770dc12cf27..c35573168d23c8eeaaa68a642e5be0eb616f2ac7 100644 (file)
@@ -27,6 +27,8 @@ static const char * EVENT_OBJECT_MOVED = "ObjectsMoved";
 static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay";
 /// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage)
 static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched";
+/// Event ID that plugin is loaded (comes with ModelAPI_ObjectUpdatedMessage)
+static const char * EVENT_PLUGIN_LOADED = "PliginLoaded";
 
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
index e0d4ba7305ffb0fc727ce28c012e9279dddf1b0d..9fc3e6b6afe27bc654cf72c14a2c8e45efda5d2f 100644 (file)
@@ -44,6 +44,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI
                                        ${PROJECT_SOURCE_DIR}/src/Events
                                        ${PROJECT_SOURCE_DIR}/src/ModuleBase
                     ${PROJECT_SOURCE_DIR}/src/ModelAPI
+                    ${PROJECT_SOURCE_DIR}/src/Config
                                        ${SALOME_GUI_INCLUDE}
                                        ${SALOME_KERNEL_INCLUDE}
                     ${CAS_INCLUDE_DIRS}
index a4caf653cb0924c3dc0ebfff2e4c2802ca0f393d..a02f119989853835610bf25b378e42f023a03613 100644 (file)
@@ -6,6 +6,7 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_PropertyPanel.h>
 #include <XGUI_ContextMenuMgr.h>
+#include <XGUI_Preferences.h>
 
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 #include <SUIT_Selector.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_ViewManager.h>
+#include <SUIT_ResourceMgr.h>
 
 #include <QtxPopupMgr.h>
 #include <QtxActionMenuMgr.h>
+#include <QtxResourceMgr.h>
+
+#include <Config_PropManager.h>
 
 #include <QDockWidget>
 #include <QAction>
@@ -34,6 +39,28 @@ NewGeom_EXPORT char* getModuleVersion()
 }
 }
 
+class NewGeom_PrefMgr: public XGUI_IPrefMgr
+{
+public:
+  NewGeom_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):myMgr(theMgr), myModName(theModName) {}
+
+  virtual int addPreference(const QString& theLbl, int pId, 
+                            SUIT_PreferenceMgr::PrefItemType theType,
+                            const QString& theSection, const QString& theName )
+  {
+    return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
+  }
+
+  virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
+
+private:
+  LightApp_Preferences* myMgr;
+  QString myModName;
+};
+
+
+
+
 //******************************************************
 NewGeom_Module::NewGeom_Module()
     : LightApp_Module("NewGeom"),
@@ -41,6 +68,9 @@ NewGeom_Module::NewGeom_Module()
 {
   myWorkshop = new XGUI_Workshop(this);
   myProxyViewer = new NewGeom_SalomeViewer(this);
+
+  XGUI_Preferences::setResourceMgr(application()->resourceMgr());
+  XGUI_Preferences::loadCustomProps();
 }
 
 //******************************************************
@@ -145,7 +175,7 @@ QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& the
   myActionsList.append(theId);
   SUIT_Desktop* aDesk = application()->desktop();
   int aKeys = 0;
-  for (int i = 0; i < theKeys.count(); i++)
+  for (unsigned int i = 0; i < theKeys.count(); i++)
     aKeys += theKeys[i];
   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
                                   isCheckable);
@@ -166,7 +196,7 @@ QAction* NewGeom_Module::addEditCommand(const QString& theId, const QString& the
   myActionsList.append(theId);
   SUIT_Desktop* aDesk = application()->desktop();
   int aKeys = 0;
-  for (int i = 0; i < theKeys.count(); i++)
+  for (unsigned int i = 0; i < theKeys.count(); i++)
     aKeys += theKeys[i];
   QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
                                   isCheckable);
@@ -249,3 +279,38 @@ void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu,
   myWorkshop->contextMenuMgr()->addViewerItems(theMenu);
   LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
 }
+
+
+//******************************************************
+void NewGeom_Module::createPreferences()
+{
+  LightApp_Preferences* pref = preferences();
+  if (!pref)
+    return;
+  XGUI_Preferences::updateCustomProps();
+  QString aModName = moduleName();
+
+  QtxPreferenceItem* item = pref->findItem(aModName, true );
+  if ( item && (!item->isEmpty() )) {
+    item->parentItem()->removeItem(item);
+    delete item;
+  }
+
+  int catId = pref->addPreference(aModName, -1 );
+  if ( catId == -1 )
+    return;
+  NewGeom_PrefMgr aMgr(pref, aModName);
+  XGUI_Preferences::createEditContent(&aMgr, catId);
+  pref->retrieve();
+}
+
+//******************************************************
+void NewGeom_Module::preferencesChanged(const QString& theSection, const QString& theParam)
+{
+  SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
+  QString aVal = aResMgr->stringValue(theSection, theParam);
+  if (!aVal.isNull()) {
+    Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(), theParam.toStdString());
+    aProp->setValue(aVal.toStdString());
+  }
+}
index d300655a3c87aca98897a54e11433530ecde9eb7..b4b52e626cfa316c76631b6687e86a5e1b74c6f5 100644 (file)
@@ -72,6 +72,9 @@ Q_OBJECT
 
   virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
 
+  virtual void createPreferences();
+  virtual void preferencesChanged(const QString& theSection, const QString& theParam);
+
  public slots:
   virtual bool activateModule(SUIT_Study* theStudy);
   virtual bool deactivateModule(SUIT_Study* theStudy);
index 5342bf832b68bdecfff05747602d976b0cee614a..fdf230c58769d026c21e81f79b3e94572be3313e 100644 (file)
@@ -133,7 +133,7 @@ void addPlane(double theX, double theY, double theZ,
 {
   boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
   boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
-  double aSize = Config_PropManager::integer("Sketch definition", "Size of planes", PLANE_SIZE);
+  double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
   boost::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal,
                                                                            aSize);
   theShapes.push_back(aFace);
@@ -156,11 +156,11 @@ AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
       aAIS = AISObjectPtr(new GeomAPI_AISObject());
       aAIS->createShape(aCompound);
 
-      std::vector<int> aRGB = Config_PropManager::color("Sketch definition", "planes_color",
+      std::vector<int> aRGB = Config_PropManager::color("Sketch planes", "planes_color",
       SKETCH_PLANE_COLOR);
       aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
 
-      aAIS->setWidth(Config_PropManager::integer("Sketch definition", "planes_thikness",
+      aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thikness",
       SKETCH_WIDTH));
     }
     return aAIS;
index 0e1ad7790eb5f6235af9bc7ef57148a576b6590c..5870e9186c14ecd63bd4d95c8e88831e35eb3386 100644 (file)
@@ -264,11 +264,12 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
     // For the length constraint the start and end points of the line should be added to the entities list instead of line
     if (aConstrType == SLVS_C_PT_PT_DISTANCE
         && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0) {
-      boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-      aConstrEnt[indAttr] = changeEntity(aData->attribute(SketchPlugin_Line::START_ID()));
-      aConstrEnt[indAttr + 1] = changeEntity(aData->attribute(SketchPlugin_Line::END_ID()));
-      // measured object is added into the map of objects to avoid problems with interaction between constraint and group
-      myEntityFeatMap[aFeature] = 0;
+      Slvs_hEntity aLineEnt = changeEntity(aFeature);
+      int aEntPos = Search(aLineEnt, myEntities);
+      aConstrEnt[indAttr++] = myEntities[aEntPos].point[0];
+      aConstrEnt[indAttr++] = myEntities[aEntPos].point[1];
+      while (indAttr < CONSTRAINT_ATTR_SIZE)
+        aConstrEnt[indAttr++] = 0;
       break;  // there should be no other entities
     } else if (aConstrAttr->isObject())
       aConstrEnt[indAttr] = changeEntity(aFeature);
index 8c338271acb04d6e41268d22c310fa90d75ceac0..9f336606eb0df5e543770b831ba71aa74ee5f99e 100644 (file)
@@ -32,6 +32,7 @@ SET(PROJECT_HEADERS
     XGUI_ModuleConnector.h
        XGUI_Selection.h
        XGUI_Preferences.h
+       XGUI_IPrefMgr.h
 )
 
 SET(PROJECT_AUTOMOC 
diff --git a/src/XGUI/XGUI_IPrefMgr.h b/src/XGUI/XGUI_IPrefMgr.h
new file mode 100644 (file)
index 0000000..1a4f848
--- /dev/null
@@ -0,0 +1,22 @@
+// File:        XGUI_IPrefMgr.h
+// Created:     10 Sept 2014
+// Author:      Vitaly SMETANNIKOV
+
+
+#ifndef XGUI_IPrefMgr_H
+#define XGUI_IPrefMgr_H
+
+#include <QString>
+#include <SUIT_PreferenceMgr.h>
+
+class XGUI_IPrefMgr
+{
+public:
+  virtual int addPreference(const QString& theLbl, int pId, 
+                            SUIT_PreferenceMgr::PrefItemType theType,
+                            const QString& theSection, const QString& theName ) = 0;
+
+  virtual SUIT_PreferenceMgr* prefMgr() const = 0;
+};
+
+#endif
\ No newline at end of file
index 81fae93d0a9776fdfc6188f7fc911eee78b329d9..81e0282ee7922bd0ac86aeb672517cf4e1abf85d 100644 (file)
@@ -5,6 +5,8 @@
 #include "XGUI_Preferences.h"
 #include "XGUI_Constants.h"
 
+#include <Config_PropManager.h>
+
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_PreferenceMgr.h>
 
@@ -47,7 +49,7 @@ void XGUI_Preferences::updateCustomProps()
     QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()),
                                               QString(aProp->name().c_str()));
     if (!aVal.isNull())
-      aProp->setValue(qPrintable(aVal));
+      aProp->setValue(aVal.toStdString());
   }
 }
 
@@ -61,13 +63,74 @@ void XGUI_Preferences::loadCustomProps()
     QStringList aParams = myResourceMgr->parameters(aSection);
     foreach (QString aParam, aParams)
     {
-      Config_PropManager::registerProp(qPrintable(aSection), qPrintable(aParam), "",
+      Config_PropManager::registerProp(aSection.toStdString(), aParam.toStdString(), "",
                                        Config_Prop::Disabled,
-                                       qPrintable(myResourceMgr->stringValue(aSection, aParam)));
+                                       myResourceMgr->stringValue(aSection, aParam).toStdString());
+    }
+  }
+}
+
+
+void XGUI_Preferences::createEditContent(XGUI_IPrefMgr* thePref, int thePage)
+{
+  thePref->prefMgr()->setItemIcon(thePage, QIcon(":pictures/module.png"));
+  createCustomPage(thePref, thePage);
+}
+
+
+void XGUI_Preferences::createCustomPage(XGUI_IPrefMgr* thePref, int thePageId)
+{
+  SUIT_ResourceMgr* aResMgr = XGUI_Preferences::resourceMgr();
+  bool isResModified = false;
+
+  // Make a Tab from each section
+  std::list<std::string> aSections = Config_PropManager::getSections();
+  std::list<std::string>::const_iterator it;
+  for (it = aSections.cbegin(); it != aSections.cend(); ++it) {
+    Config_Properties aProps = Config_PropManager::getProperties(*it);
+    int aTab = thePref->prefMgr()->addItem(QString((*it).c_str()), thePageId);
+    thePref->prefMgr()->setItemProperty("columns", 2, aTab);
+
+    Config_Properties::const_iterator aIt;
+    for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
+      Config_Prop* aProp = (*aIt);
+      // check that the property is defined
+      QString aSection(aProp->section().c_str());
+      QString aName(aProp->name().c_str());
+      if (!aResMgr->hasValue(aSection, aName)) {
+        aResMgr->setValue(aSection, aName, QString(aProp->value().c_str()));
+        isResModified = true;
+      }
+      // Add item
+      if (aProp->type() != Config_Prop::Disabled)
+        thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab,
+                               (SUIT_PreferenceMgr::PrefItemType) aProp->type(),
+                               QString(aProp->section().c_str()), QString(aProp->name().c_str()));
     }
   }
 }
 
+//**********************************************************
+//**********************************************************
+//**********************************************************
+class XGUI_PrefMgr: public XGUI_IPrefMgr
+{
+public:
+  XGUI_PrefMgr(XGUI_PreferencesMgr* theMgr):myMgr(theMgr) {}
+
+  virtual int addPreference(const QString& theLbl, int pId, 
+                            SUIT_PreferenceMgr::PrefItemType theType,
+                            const QString& theSection, const QString& theName )
+  {
+    return myMgr->addItem(theLbl, pId, theType, theSection, theName);
+  }
+
+  virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
+
+private:
+  XGUI_PreferencesMgr* myMgr;
+};
+
 //**********************************************************
 //**********************************************************
 //**********************************************************
@@ -112,7 +175,9 @@ void XGUI_PreferencesDlg::createEditors()
 
   aPage = myPreferences->addItem(tr("Module"));
   myPreferences->setItemIcon(aPage, QIcon(":pictures/module.png"));
-  createCustomPage(aPage);
+
+  XGUI_PrefMgr aMgr(myPreferences);
+  XGUI_Preferences::createEditContent(&aMgr, aPage);
 }
 
 void XGUI_PreferencesDlg::createViewerPage(int thePageId)
@@ -159,38 +224,6 @@ void XGUI_PreferencesDlg::createMenuPage(int thePageId)
   myPreferences->setItemProperty("max", 6, aRowsNb);
 }
 
-void XGUI_PreferencesDlg::createCustomPage(int thePageId)
-{
-  SUIT_ResourceMgr* aResMgr = XGUI_Preferences::resourceMgr();
-  bool isResModified = false;
-
-  // Make a Tab from each section
-  std::list<std::string> aSections = Config_PropManager::getSections();
-  std::list<std::string>::const_iterator it;
-  for (it = aSections.cbegin(); it != aSections.cend(); ++it) {
-    Config_Properties aProps = Config_PropManager::getProperties(*it);
-    int aTab = myPreferences->addItem(QString((*it).c_str()), thePageId);
-    myPreferences->setItemProperty("columns", 2, aTab);
-
-    Config_Properties::const_iterator aIt;
-    for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
-      Config_Prop* aProp = (*aIt);
-      // check that the property is defined
-      QString aSection(aProp->section().c_str());
-      QString aName(aProp->name().c_str());
-      if (!aResMgr->hasValue(aSection, aName)) {
-        aResMgr->setValue(aSection, aName, QString(aProp->value().c_str()));
-        isResModified = true;
-      }
-      // Add item
-      if (aProp->type() != Config_Prop::Disabled)
-        myPreferences->addItem(tr(aProp->title().c_str()), aTab,
-                               (SUIT_PreferenceMgr::PrefItemType) aProp->type(),
-                               QString(aProp->section().c_str()), QString(aProp->name().c_str()));
-    }
-  }
-}
-
 void XGUI_PreferencesDlg::accept()
 {
   myPreferences->store();
index 7307de3ef4b034319ae1356f115537163da9a85b..2493414bfe5104ace938431342c2c11225ff34f2 100644 (file)
@@ -6,8 +6,8 @@
 #define XGUI_Preferences_H
 
 #include "XGUI.h"
+#include "XGUI_IPrefMgr.h"
 
-#include <Config_PropManager.h>
 #include <SUIT_PreferenceMgr.h>
 #include <QDialog>
 
@@ -28,13 +28,26 @@ class XGUI_EXPORT XGUI_Preferences
 
   static bool editPreferences(XGUI_Prefs& theModified);
 
+  /// Returns currently installed resource manager
   static SUIT_ResourceMgr* resourceMgr();
 
+  /// Sets a resource manager
+  /// It is used in case of necessity to define external resource manager (not NewGeom)
+  static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
+
+  /// Updates properties defined by module from SUIT_ResourceMgr to Config_PropManager
   static void updateCustomProps();
 
+  /// Loads properties defined by module to Config_PropManager
   static void loadCustomProps();
 
- private:
+  /// 
+  static void createEditContent(XGUI_IPrefMgr* thePref, int thePage);
+
+private:
+  /// Creates content of preferences editing widget
+  static void createCustomPage(XGUI_IPrefMgr* thePref, int thePageId);
+
   static SUIT_ResourceMgr* myResourceMgr;
 };
 
@@ -88,7 +101,7 @@ Q_OBJECT
   void createEditors();
   void createViewerPage(int thePageId);
   void createMenuPage(int thePageId);
-  void createCustomPage(int thePageId);
+  //void createCustomPage(int thePageId);
 
   void updateCustomProps();
 
index 58489c127b61c50d5a96ac17b2fbd37055a8e2ae..0055714b73e4078e6898804484a0bd727e4d6ad9 100644 (file)
@@ -69,6 +69,8 @@ class XGUI_EXPORT XGUI_SalomeConnector
 
   //! Returns interface to Salome viewer
   virtual XGUI_SalomeViewer* viewer() const = 0;
+
+  virtual void createPreferences() = 0;
 };
 
 #endif
index 4df53a8f9e43f9d61e074cf9d89050aa22f045dc..d6d88a0da5b193b485a53421902aba06abbaae04 100644 (file)
@@ -86,7 +86,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
       mySalomeConnector(theConnector),
       myPropertyPanel(0),
       myObjectBrowser(0),
-      myDisplayer(0)
+      myDisplayer(0),
+      myUpdatePrefs(false)
 {
   myMainWindow = mySalomeConnector ? 0 : new XGUI_MainWindow();
 
@@ -139,6 +140,7 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
   aLoop->registerListener(this, Events_Loop::eventByName("LongOperation"));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
 
   registerValidators();
   activateModule();
@@ -243,6 +245,15 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
         dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
     onFeatureCreatedMsg(aUpdMsg);
+    if (myUpdatePrefs) {
+      if (mySalomeConnector)
+        mySalomeConnector->createPreferences();
+      myUpdatePrefs = false;
+    }
+    return;
+  }
+  if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED)) {
+    myUpdatePrefs = true;
     return;
   }
 
@@ -302,6 +313,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
   }
 }
 
+
 //******************************************************
 void XGUI_Workshop::onStartWaiting()
 {
@@ -394,8 +406,11 @@ void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theM
 void XGUI_Workshop::onOperationStarted()
 {
   ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-  aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
-
+  if (this->isSalomeMode()) 
+    aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
+  else 
+    aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
+  
   if (aOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
     connectWithOperation(aOperation);
 
@@ -463,7 +478,7 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
                                                      QString::fromStdString(theMessage->tooltip()),
                                                      QIcon(theMessage->icon().c_str()),
                                                      QKeySequence(), isUsePropPanel);
-    salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" "));
+    salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
     myActionsMgr->addCommand(aAction);
     myModule->featureCreated(aAction);
   } else {
index 95644a07fb1f25913f4141afd7223d137fce8680..dbf160d15105689a1fcf31346a25f7752e00e628 100644 (file)
@@ -208,7 +208,7 @@ signals:
   void displayDocumentResults(DocumentPtr theDoc);
   void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
 
- protected slots:
+ private slots:
   /// SLOT, that is called after the operation is started. Update workshop state according to
   /// the started operation, e.g. visualizes the property panel and connect to it.
   void onOperationStarted();
@@ -253,6 +253,8 @@ signals:
 
   QString myCurrentDir;
   static QMap<QString, QString> myIcons;
+
+  bool myUpdatePrefs;
 };
 
 #endif