From: vsv Date: Wed, 10 Sep 2014 08:46:12 +0000 (+0400) Subject: Provide preferences in Salome mode X-Git-Tag: V_0.4.4~72^2~4^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5bd16c177ad50368339aeb289d1980f81a08ad0c;p=modules%2Fshaper.git Provide preferences in Salome mode --- diff --git a/build_Salome740_deb.bat b/build_Salome740_deb.bat new file mode 100644 index 000000000..130599b4f --- /dev/null +++ b/build_Salome740_deb.bat @@ -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 index 000000000..26fbe1521 --- /dev/null +++ b/build_Salome740_rel.bat @@ -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 index 000000000..fafb46630 --- /dev/null +++ b/env_Salome.bat @@ -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 diff --git a/salomeRun.bat b/salomeRun.bat index a68091b43..a2fa7d3dd 100644 --- a/salomeRun.bat +++ b/salomeRun.bat @@ -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 diff --git a/src/NewGeom/CMakeLists.txt b/src/NewGeom/CMakeLists.txt index e0d4ba730..9fc3e6b6a 100644 --- a/src/NewGeom/CMakeLists.txt +++ b/src/NewGeom/CMakeLists.txt @@ -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} diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index a4caf653c..dd97f0fc5 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -15,9 +16,13 @@ #include #include #include +#include #include #include +#include + +#include #include #include @@ -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,28 @@ void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, myWorkshop->contextMenuMgr()->addViewerItems(theMenu); LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle); } + + +//****************************************************** +void NewGeom_Module::createPreferences() +{ + XGUI_Preferences::updateCustomProps(); + LightApp_Preferences* pref = preferences(); + int catId = pref->addPreference( moduleName(), -1 ); + if ( catId == -1 ) + return; + NewGeom_PrefMgr aMgr(pref, moduleName()); + 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()); + } +} diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index d300655a3..b4b52e626 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -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); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 5342bf832..fdf230c58 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -133,7 +133,7 @@ void addPlane(double theX, double theY, double theZ, { boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); boost::shared_ptr 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 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 aRGB = Config_PropManager::color("Sketch definition", "planes_color", + std::vector 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; diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 8c338271a..9f336606e 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -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 index 000000000..1a4f8481c --- /dev/null +++ b/src/XGUI/XGUI_IPrefMgr.h @@ -0,0 +1,22 @@ +// File: XGUI_IPrefMgr.h +// Created: 10 Sept 2014 +// Author: Vitaly SMETANNIKOV + + +#ifndef XGUI_IPrefMgr_H +#define XGUI_IPrefMgr_H + +#include +#include + +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 diff --git a/src/XGUI/XGUI_Preferences.cpp b/src/XGUI/XGUI_Preferences.cpp index 81fae93d0..81e0282ee 100644 --- a/src/XGUI/XGUI_Preferences.cpp +++ b/src/XGUI/XGUI_Preferences.cpp @@ -5,6 +5,8 @@ #include "XGUI_Preferences.h" #include "XGUI_Constants.h" +#include + #include #include @@ -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 aSections = Config_PropManager::getSections(); + std::list::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 aSections = Config_PropManager::getSections(); - std::list::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(); diff --git a/src/XGUI/XGUI_Preferences.h b/src/XGUI/XGUI_Preferences.h index 7307de3ef..2493414bf 100644 --- a/src/XGUI/XGUI_Preferences.h +++ b/src/XGUI/XGUI_Preferences.h @@ -6,8 +6,8 @@ #define XGUI_Preferences_H #include "XGUI.h" +#include "XGUI_IPrefMgr.h" -#include #include #include @@ -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();