SET(PROJECT_HEADERS
ModuleBase.h
ModuleBase_IOperation.h
+ ModuleBase_IModule.h
ModuleBase_Operation.h
ModuleBase_OperationDescription.h
ModuleBase_ModelWidget.h
ModuleBase_WidgetPoint2dDistance.h
ModuleBase_WidgetValue.h
ModuleBase_WidgetValueFeature.h
+ ModuleBase_Definitions.h
)
SET(PROJECT_SOURCES
--- /dev/null
+
+#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
--- /dev/null
+#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
#include <PartSet_Module.h>
#include <XGUI_Displayer.h>
+#include <XGUI_Workshop.h>
#include <Events_Loop.h>
#include <Model_Events.h>
#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);
}
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;
+}
#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>
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
/// \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&);
/// \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
</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"/>
XGUI_MainMenu.h
XGUI_MainWindow.h
XGUI_MenuGroupPanel.h
- XGUI_Module.h
XGUI_Tools.h
XGUI_Workbench.h
XGUI_Workshop.h
#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
{
#define XGUI_Displayer_H
#include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
#include <QString>
#include <boost/shared_ptr.hpp>
QModelIndex();
}
}
+ return QModelIndex();
}
\ No newline at end of file
#define XGUI_DocumentDataModel_H
#include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
#include <QAbstractItemModel>
#include <Events_Listener.h>
/*
* 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);
}
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
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; }
//! Returns list of created commands
QList<XGUI_Command*> features() const;
+ QList<XGUI_Workbench*> workbenches() const;
+
virtual bool eventFilter(QObject *theWatched, QEvent *theEvent);
private:
+++ /dev/null
-#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
#include "XGUI.h"
-#include "XGUI_Constants.h"
-
+#include <ModuleBase_Definitions.h>
#include <ModuleBase_IWorkshop.h>
class Handle_AIS_InteractiveContext;
#define XGUI_ObjectsBrowser_H
#include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
#include <QWidget>
#include <QTreeView>
* Author: sbh
*/
-#include <XGUI_Constants.h>
#include <XGUI_PropertyPanel.h>
+#include <XGUI_Constants.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <QWidget>
#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();
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)
#define XGUI_SelectionMgr_H
#include "XGUI.h"
-#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
#include <QObject>
#include <QModelIndexList>
#include "XGUI.h"
#include "XGUI_Constants.h"
+#include <ModuleBase_Definitions.h>
#include <QObject>
#include <QMap>
-#include "XGUI_Module.h"
+#include "ModuleBase_IModule.h"
#include "XGUI_Constants.h"
#include "XGUI_Command.h"
#include "XGUI_MainMenu.h"
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);
}
//******************************************************
-XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
+ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
{
QString libName =
QString::fromStdString(library(theModule.toStdString()));
}
#endif
- XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
+ ModuleBase_IModule* aModule = crtInst ? crtInst(this) : 0;
if (!err.isEmpty()) {
if (mainWindow()) {
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)
{
#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;
class XGUI_ModuleConnector;
class ModuleBase_Operation;
+class ModuleBase_IModule;
class Config_FeatureMessage;
class Config_PointerMessage;
public slots:
void updateCommandStatus();
+ void updateModuleCommands();
void onNew();
void onOpen();
private:
void initMenu();
- XGUI_Module* loadModule(const QString& theModule);
+ ModuleBase_IModule* loadModule(const QString& theModule);
bool activateModule();
QDockWidget* createObjectBrowser(QWidget* theParent);
void createDockWidgets();
XGUI_MainWindow* myMainWindow;
- XGUI_Module* myPartSetModule;
+ ModuleBase_IModule* myPartSetModule;
XGUI_ObjectsBrowser* myObjectBrowser;
XGUI_PropertyPanel* myPropertyPanel;
XGUI_SelectionMgr* mySelector;