From: vsv Date: Tue, 1 Jul 2014 07:10:22 +0000 (+0400) Subject: Some slight improvements and bugs fixing. X-Git-Tag: V_0.4.4~216 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0e5b22dfff609f8ee88bc654c275f3ad23b88eaf;p=modules%2Fshaper.git Some slight improvements and bugs fixing. --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index ae5cf2fd9..6b3847b29 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -4,6 +4,7 @@ SET(CMAKE_AUTOMOC ON) SET(PROJECT_HEADERS ModuleBase.h ModuleBase_IOperation.h + ModuleBase_IModule.h ModuleBase_Operation.h ModuleBase_OperationDescription.h ModuleBase_ModelWidget.h @@ -20,6 +21,7 @@ SET(PROJECT_HEADERS ModuleBase_WidgetPoint2dDistance.h ModuleBase_WidgetValue.h ModuleBase_WidgetValueFeature.h + ModuleBase_Definitions.h ) SET(PROJECT_SOURCES diff --git a/src/ModuleBase/ModuleBase_Definitions.h b/src/ModuleBase/ModuleBase_Definitions.h new file mode 100644 index 000000000..f32657a9e --- /dev/null +++ b/src/ModuleBase/ModuleBase_Definitions.h @@ -0,0 +1,14 @@ + +#ifndef ModuleBase_Definitions_H +#define ModuleBase_Definitions_H + +#include +#include + +typedef QList QIntList; //!< list of int values +typedef QList QShortList; //!< list of short int values +typedef QList QDoubleList; //!< list of double values +typedef QList QFeatureList; //!< List of features + + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h new file mode 100644 index 000000000..6a4401f76 --- /dev/null +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -0,0 +1,40 @@ +#ifndef ModuleBase_IModule_H +#define ModuleBase_IModule_H + +#include +#include + +class QAction; +class XGUI_Workshop; + +/** +* Interface to a module +*/ +class ModuleBase_IModule: public QObject +{ +public: + /// Reads description of features from XML file + virtual void createFeatures() = 0; + + /// Called on creation of menu item in desktop + virtual void featureCreated(QAction*) = 0; + + /// Creates an operation and send it to loop + /// \param theCmdId the operation name + virtual void launchOperation(const QString& theCmdId) = 0; + + /// Called when it is necessary to update a command state (enable or disable it) + virtual bool isFeatureEnabled(const QString& theCmdId) const = 0; + + virtual ~ModuleBase_IModule() {}; +}; + +//! This function must return a new module instance. +extern "C" +{ +typedef ModuleBase_IModule* (*CREATE_FUNC)(XGUI_Workshop*); +} + +#define CREATE_MODULE "createModule" + +#endif //ModuleBase_IModule diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index 1f3505ee7..fb4c4fad3 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 65172c482..f05965159 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -53,7 +53,7 @@ #endif /*!Create and return new instance of XGUI_Module*/ -extern "C" PARTSET_EXPORT XGUI_Module* createModule(XGUI_Workshop* theWshop) +extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop) { return new PartSet_Module(theWshop); } @@ -522,3 +522,9 @@ void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& th PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute, aPoint->x(), aPoint->y()); } + +bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const +{ + qDebug("### isFeatureEnabled %s", qPrintable(theCmdId)); + return true; +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 561c97fe0..261427642 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -3,8 +3,10 @@ #include "PartSet.h" -#include +#include +#include #include +#include #include #include @@ -18,8 +20,9 @@ class QKeyEvent; class PartSet_Listener; class ModelAPI_Feature; class XGUI_ViewerPrs; +class ModuleBase_Operation; -class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module +class PARTSET_EXPORT PartSet_Module: public ModuleBase_IModule { Q_OBJECT @@ -31,8 +34,13 @@ public: /// \returns a workshop instance XGUI_Workshop* workshop() const; + /// Reads description of features from XML file virtual void createFeatures(); + + /// Called on creation of menu item in desktop virtual void featureCreated(QAction* theFeature); + + /// Returnc list of nested commands for the given feature virtual QStringList nestedFeatures(QString theFeature); std::string featureFile(const std::string&); @@ -40,6 +48,9 @@ public: /// \param theCmdId the operation name virtual void launchOperation(const QString& theCmdId); + /// Called when it is necessary to update a command state (enable or disable it) + virtual bool isFeatureEnabled(const QString& theCmdId) const; + /// Displays or erase the current operation preview, if it has it. /// \param theFeature the feature instance to be displayed /// \param isDisplay the state whether the presentation should be displayed or erased diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 6c320ee71..16862fa24 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -14,7 +14,7 @@ - + diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 8c9244e52..450954322 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -8,7 +8,6 @@ SET(PROJECT_HEADERS XGUI_MainMenu.h XGUI_MainWindow.h XGUI_MenuGroupPanel.h - XGUI_Module.h XGUI_Tools.h XGUI_Workbench.h XGUI_Workshop.h diff --git a/src/XGUI/XGUI_Constants.h b/src/XGUI/XGUI_Constants.h index 02f0001c1..6058ba3b4 100644 --- a/src/XGUI/XGUI_Constants.h +++ b/src/XGUI/XGUI_Constants.h @@ -1,17 +1,6 @@ #ifndef XGUI_Constants_H #define XGUI_Constants_H -#include -#include - -//! This file contains various constants used in the application - - -typedef QList QIntList; //!< list of int values -typedef QList QShortList; //!< list of short int values -typedef QList QDoubleList; //!< list of double values -typedef QList QFeatureList; //!< List of features - namespace XGUI { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index f5402c351..47941965f 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -6,7 +6,7 @@ #define XGUI_Displayer_H #include "XGUI.h" -#include "XGUI_Constants.h" +#include #include #include diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 09d530bab..b4cc62c0c 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -553,4 +553,5 @@ QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) co QModelIndex(); } } + return QModelIndex(); } \ No newline at end of file diff --git a/src/XGUI/XGUI_DocumentDataModel.h b/src/XGUI/XGUI_DocumentDataModel.h index a5257a981..c6b924bb4 100644 --- a/src/XGUI/XGUI_DocumentDataModel.h +++ b/src/XGUI/XGUI_DocumentDataModel.h @@ -3,7 +3,7 @@ #define XGUI_DocumentDataModel_H #include "XGUI.h" -#include "XGUI_Constants.h" +#include #include #include diff --git a/src/XGUI/XGUI_MainMenu.cpp b/src/XGUI/XGUI_MainMenu.cpp index 88d68492e..9f79a1db8 100644 --- a/src/XGUI/XGUI_MainMenu.cpp +++ b/src/XGUI/XGUI_MainMenu.cpp @@ -54,7 +54,7 @@ XGUI_Workbench* XGUI_MainMenu::addWorkbench(const QString& theId, const QString& /* * Searches for already created workbench with given name. */ -XGUI_Workbench* XGUI_MainMenu::findWorkbench(const QString& theObjName) +XGUI_Workbench* XGUI_MainMenu::findWorkbench(const QString& theObjName) const { return myDesktop->findChild(theObjName); } @@ -94,3 +94,14 @@ QList XGUI_MainMenu::features() const return aList; } +QList XGUI_MainMenu::workbenches() const +{ + QList aList; + aList.append(myGeneralPage); + foreach(QDockWidget* aDoc, myMenuTabs) { + XGUI_Workbench* aWb = dynamic_cast(aDoc->widget()); + if (aWb) + aList.append(aWb); + } + return aList; +} \ No newline at end of file diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h index 48d974591..945ddcb8d 100644 --- a/src/XGUI/XGUI_MainMenu.h +++ b/src/XGUI/XGUI_MainMenu.h @@ -33,7 +33,7 @@ public: XGUI_Workbench* addWorkbench(const QString& theId, const QString& theText = ""); //! Returns workbench (menu group) by the given name. - XGUI_Workbench* findWorkbench(const QString& theId); + XGUI_Workbench* findWorkbench(const QString& theId) const; //! Returns General page (predefined workbench) XGUI_Workbench* generalPage() const { return myGeneralPage; } @@ -47,6 +47,8 @@ public: //! Returns list of created commands QList features() const; + QList workbenches() const; + virtual bool eventFilter(QObject *theWatched, QEvent *theEvent); private: diff --git a/src/XGUI/XGUI_Module.h b/src/XGUI/XGUI_Module.h deleted file mode 100644 index 4df05ea2f..000000000 --- a/src/XGUI/XGUI_Module.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef XGUI_Module_H -#define XGUI_Module_H - -#include -#include - -class QAction; - -class XGUI_Module -{ -public: - virtual void createFeatures() = 0; - virtual void featureCreated(QAction*) = 0; - virtual void launchOperation(const QString& theCmdId) = 0; - - virtual ~XGUI_Module() {}; -}; - -//! This function must return a new module instance. -extern "C" -{ -typedef XGUI_Module* (*CREATE_FUNC)(XGUI_Workshop*); -} - -#define CREATE_MODULE "createModule" - -#endif //XGUI_Module diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index fbab125db..8efd97e21 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -7,8 +7,7 @@ #include "XGUI.h" -#include "XGUI_Constants.h" - +#include #include class Handle_AIS_InteractiveContext; diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 70c13d11c..a1e5c5ef1 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -3,7 +3,7 @@ #define XGUI_ObjectsBrowser_H #include "XGUI.h" -#include "XGUI_Constants.h" +#include #include #include diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 767e0dfcc..e9383b4d7 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -5,8 +5,8 @@ * Author: sbh */ -#include #include +#include #include #include @@ -22,7 +22,8 @@ #include #endif -XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) +XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) : +QDockWidget(theParent) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -97,8 +98,8 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); - connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)), - this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*))); + //connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)), + // this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*))); ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast(*anIt); if (aPointWidget) diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index b75989abb..e98b52841 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -2,7 +2,7 @@ #define XGUI_SelectionMgr_H #include "XGUI.h" -#include "XGUI_Constants.h" +#include #include #include diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 664e58b2b..8c2f13c9c 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -3,6 +3,7 @@ #include "XGUI.h" #include "XGUI_Constants.h" +#include #include #include diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 408497da8..ee311ff8f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1,4 +1,4 @@ -#include "XGUI_Module.h" +#include "ModuleBase_IModule.h" #include "XGUI_Constants.h" #include "XGUI_Command.h" #include "XGUI_MainMenu.h" @@ -85,6 +85,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myDisplayer = new XGUI_Displayer(this); mySelector = new XGUI_SelectionMgr(this); + connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands())); myOperationMgr = new XGUI_OperationMgr(this); myActionsMgr = new XGUI_ActionsMgr(this); @@ -575,7 +576,7 @@ void XGUI_Workshop::onRedo() } //****************************************************** -XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule) +ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) { QString libName = QString::fromStdString(library(theModule.toStdString())); @@ -623,7 +624,7 @@ XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule) } #endif - XGUI_Module* aModule = crtInst ? crtInst(this) : 0; + ModuleBase_IModule* aModule = crtInst ? crtInst(this) : 0; if (!err.isEmpty()) { if (mainWindow()) { @@ -689,6 +690,26 @@ void XGUI_Workshop::updateCommandStatus() myActionsMgr->update(); } +//****************************************************** +void XGUI_Workshop::updateModuleCommands() +{ + QList aCommands; + if (isSalomeMode()) { // update commands in SALOME mode + aCommands = salomeConnector()->commandList(); + } else { + XGUI_MainMenu* aMenuBar = myMainWindow->menuObject(); + foreach (XGUI_Workbench* aWb, aMenuBar->workbenches()) { + if (aWb != aMenuBar->generalPage()) { + foreach(XGUI_Command* aCmd, aWb->features()) + aCommands.append(aCmd); + } + } + } + foreach(QAction* aCmd, aCommands) { + aCmd->setEnabled(myPartSetModule->isFeatureEnabled(aCmd->data().toString())); + } +} + //****************************************************** QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index e52f48db8..cb4d64e1d 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -4,15 +4,16 @@ #include "XGUI.h" #include "XGUI_Constants.h" #include +#include #include #include #include #include + class XGUI_MainWindow; class XGUI_Command; -class XGUI_Module; class XGUI_Workbench; class XGUI_SelectionMgr; class XGUI_Displayer; @@ -28,6 +29,7 @@ class XGUI_ContextMenuMgr; class XGUI_ModuleConnector; class ModuleBase_Operation; +class ModuleBase_IModule; class Config_FeatureMessage; class Config_PointerMessage; @@ -119,6 +121,7 @@ signals: public slots: void updateCommandStatus(); + void updateModuleCommands(); void onNew(); void onOpen(); @@ -160,7 +163,7 @@ protected slots: private: void initMenu(); - XGUI_Module* loadModule(const QString& theModule); + ModuleBase_IModule* loadModule(const QString& theModule); bool activateModule(); QDockWidget* createObjectBrowser(QWidget* theParent); @@ -170,7 +173,7 @@ private: void createDockWidgets(); XGUI_MainWindow* myMainWindow; - XGUI_Module* myPartSetModule; + ModuleBase_IModule* myPartSetModule; XGUI_ObjectsBrowser* myObjectBrowser; XGUI_PropertyPanel* myPropertyPanel; XGUI_SelectionMgr* mySelector;