]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 1 Jul 2014 07:10:37 +0000 (11:10 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 1 Jul 2014 07:10:37 +0000 (11:10 +0400)
22 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Definitions.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_IModule.h [new file with mode: 0644]
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Constants.h
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_DocumentDataModel.h
src/XGUI/XGUI_MainMenu.cpp
src/XGUI/XGUI_MainMenu.h
src/XGUI/XGUI_Module.h [deleted file]
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_Viewer.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index ae5cf2fd9b043fc0147a0cc1e92de3e8564326dc..6b3847b293b466d43282a28cd566ba386c616a31 100644 (file)
@@ -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 (file)
index 0000000..f32657a
--- /dev/null
@@ -0,0 +1,14 @@
+
+#ifndef ModuleBase_Definitions_H
+#define ModuleBase_Definitions_H
+
+#include <QList>
+#include <ModelAPI_Feature.h>
+
+typedef QList<int> QIntList;       //!< list of int values
+typedef QList<short> QShortList;     //!< list of short int values
+typedef QList<double> QDoubleList;    //!< list of double values
+typedef QList<FeaturePtr> 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 (file)
index 0000000..6a4401f
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef ModuleBase_IModule_H
+#define ModuleBase_IModule_H
+
+#include <QString>
+#include <QObject>
+
+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
index 1f3505ee771821645ce24f312f47364718f4e481..fb4c4fad3c884f8f8ec523077cddea4c67807241 100644 (file)
@@ -7,6 +7,7 @@
 #include <PartSet_Module.h>
 
 #include <XGUI_Displayer.h>
+#include <XGUI_Workshop.h>
 
 #include <Events_Loop.h>
 #include <Model_Events.h>
index 75d9692019797317976d556efe95a77c1ab7fe94..2d43a2f1327692c451c5d2596500174cb4f1ddb7 100644 (file)
@@ -51,7 +51,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);
 }
@@ -521,3 +521,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;
+}
index 561c97fe0224741d042221903ba80f27d388a000..261427642304dff1cf6afc7cae2e37ab20790962 100644 (file)
@@ -3,8 +3,10 @@
 
 #include "PartSet.h"
 
-#include <XGUI_Module.h>
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_Definitions.h>
 #include <XGUI_Command.h>
+#include <ModelAPI_Feature.h>
 
 #include <QMap>
 #include <QObject>
@@ -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
index 6c320ee7195fbb7af6862a906400168469512672..16862fa241f116e9b7e1f7559f8a0bc63aacf882 100644 (file)
@@ -14,7 +14,7 @@
       </feature>
       <feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon=":icons/circle.png">
         <point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
-        <point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius"/>
+        <point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="1" icon=":icons/radius.png" tooltip="Set Radius"/>
       </feature>
       <feature id="SketchArc" title="Arc" tooltip="Create a new arc of a circle" icon=":icons/arc.png">
         <point_selector id="ArcCenter" title="Center" tooltip="Center of the arc"/>
index 8c9244e52392af267ea209b8dbd0fb887c13ce12..450954322a3bb50d4a0cc8dd99a85a1745dd210d 100644 (file)
@@ -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
index 02f0001c1482f2e6c5509f4f2c4689ff92856018..6058ba3b44cc76a8e9be4f3c1afde0eeb7a38934 100644 (file)
@@ -1,17 +1,6 @@
 #ifndef XGUI_Constants_H
 #define XGUI_Constants_H
 
-#include <QList>
-#include <ModelAPI_Feature.h>
-
-//! This file contains various constants used in the application
-
-
-typedef QList<int> QIntList;       //!< list of int values
-typedef QList<short> QShortList;     //!< list of short int values
-typedef QList<double> QDoubleList;    //!< list of double values
-typedef QList<FeaturePtr> QFeatureList; //!< List of features
-
 namespace XGUI
 {
 
index 7652165fad52950fd1f4853032979cef7cce58c6..2ce31b14d440ff367f09b444ffa16d647e05acc4 100644 (file)
@@ -6,7 +6,7 @@
 #define XGUI_Displayer_H
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
 
 #include <QString>
 #include <boost/shared_ptr.hpp>
index 09d530bab70ea5be675096b2f80c335231eb7c63..b4cc62c0c9f4d5f8bc6a6fba6cd41dffd6301903 100644 (file)
@@ -553,4 +553,5 @@ QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) co
         QModelIndex();
     }
   }
+  return QModelIndex();
 }
\ No newline at end of file
index a5257a981c7d1041f9a991d97447bcbf08f54269..c6b924bb438889be075bd0dee34ba7ea40a445fc 100644 (file)
@@ -3,7 +3,7 @@
 #define XGUI_DocumentDataModel_H
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
 
 #include <QAbstractItemModel>
 #include <Events_Listener.h>
index 88d68492e584bae12021f350f33043c2412b31f7..9f79a1db88b6fd44796cbd4e33577fbed8f552ee 100644 (file)
@@ -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<XGUI_Workbench*>(theObjName);
 }
@@ -94,3 +94,14 @@ QList<XGUI_Command*> XGUI_MainMenu::features() const
   return aList;
 }
 
+QList<XGUI_Workbench*> XGUI_MainMenu::workbenches() const
+{
+  QList<XGUI_Workbench*> aList;
+  aList.append(myGeneralPage);
+  foreach(QDockWidget* aDoc, myMenuTabs) {
+    XGUI_Workbench* aWb = dynamic_cast<XGUI_Workbench*>(aDoc->widget());
+    if (aWb)
+      aList.append(aWb);
+  }
+  return aList;
+}
\ No newline at end of file
index 48d97459135f78be9f26e3f2b6a6d7450e10f833..945ddcb8d9f890b6d90811986f280805c69dfb01 100644 (file)
@@ -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<XGUI_Command*> features() const;
 
+  QList<XGUI_Workbench*> 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 (file)
index 4df05ea..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef XGUI_Module_H\r
-#define XGUI_Module_H\r
-\r
-#include <XGUI_Workshop.h>\r
-#include <QString>\r
-\r
-class QAction;\r
-\r
-class XGUI_Module\r
-{\r
-public:\r
-  virtual void createFeatures() = 0;\r
-  virtual void featureCreated(QAction*) = 0;\r
-  virtual void launchOperation(const QString& theCmdId) = 0;\r
-\r
-  virtual ~XGUI_Module() {};\r
-};\r
-\r
-//! This function must return a new module instance.\r
-extern "C"\r
-{\r
-typedef XGUI_Module* (*CREATE_FUNC)(XGUI_Workshop*);\r
-}\r
-\r
-#define CREATE_MODULE "createModule"\r
-\r
-#endif //XGUI_Module\r
index fbab125db1a03b85e44c9fd4950c40e28f21ad57..8efd97e210f0697814417da53b11a91115a48986 100644 (file)
@@ -7,8 +7,7 @@
 
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
-
+#include <ModuleBase_Definitions.h>
 #include <ModuleBase_IWorkshop.h>
 
 class Handle_AIS_InteractiveContext;
index 70c13d11cc8648fed3d496090fe423ffd1003802..a1e5c5ef1dd4b5bfbc04684db0424fb5cb07cbef 100644 (file)
@@ -3,7 +3,7 @@
 #define XGUI_ObjectsBrowser_H
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
 
 #include <QWidget>
 #include <QTreeView>
index 767e0dfcc8b1682dab0140468572ede859ee1cea..e9383b4d71bfef5cce48587573e689dba4419087 100644 (file)
@@ -5,8 +5,8 @@
  *      Author: sbh
  */
 
-#include <XGUI_Constants.h>
 #include <XGUI_PropertyPanel.h>
+#include <XGUI_Constants.h>
 #include <ModuleBase_WidgetPoint2D.h>
 
 #include <QWidget>
@@ -22,7 +22,8 @@
 #include <iostream>
 #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<ModuleBase_ModelWidget*>& 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<ModuleBase_WidgetPoint2D*>(*anIt);
       if (aPointWidget)
index b75989abbfb6640bc90ec681c263cc800eb8c4c2..e98b52841fb76fb321e910d51a52e1ebdbfb7b76 100644 (file)
@@ -2,7 +2,7 @@
 #define XGUI_SelectionMgr_H
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
 #include <QObject>
 #include <QModelIndexList>
 
index 664e58b2b772126e0d892c6ff6a1f11e733c905c..8c2f13c9c4f470fc30c55074cd12972bdfa094e2 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "XGUI.h"
 #include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
 
 #include <QObject>
 #include <QMap>
index 408497da87ff710de4b59c0241d7663edc58c9be..ee311ff8f6bc943b96cf651331f1a684b8968511 100644 (file)
@@ -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<QAction*> 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)
 {
index e52f48db8323d1b5b30fbb00d9c8b27ac2baccd1..cb4d64e1d2d0b458ba81a35117d585303c307874 100644 (file)
@@ -4,15 +4,16 @@
 #include "XGUI.h"
 #include "XGUI_Constants.h"
 #include <Events_Listener.h>
+#include <ModuleBase_Definitions.h>
 
 #include <QObject>
 #include <QMap>
 #include <QIcon>
 #include <QKeySequence>
 
+
 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;