-#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);
//An operation passed by message. Start it, process and commit.
const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
- // Clear previous content
myPropertyPanel->cleanContent();
ModuleBase_Operation* anOperation =
(ModuleBase_Operation*)(aPartSetMsg->pointer());
if (myOperationMgr->startOperation(anOperation)) {
myPropertyPanel->updateContentWidget(anOperation->feature());
- if (anOperation->getDescription()->xmlRepresentation().isEmpty()) {
+ if (!anOperation->getDescription()->hasXmlRepresentation()) {
anOperation->commit();
updateCommandStatus();
}
{
ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if(!aOperation->getDescription()->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ if(aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel
connectWithOperation(aOperation);
showPropertyPanel();
-
- ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation, myModuleConnector);
+ QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
+ ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), myModuleConnector);
QWidget* aContent = myPropertyPanel->contentWidget();
qDeleteAll(aContent->children());
aFactory.createWidget(aContent);
- myPropertyPanel->setModelWidgets(aFactory.getModelWidgets());
+
+ QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
+ ModuleBase_ModelWidget* aWidget;
+ for (; anIt != aLast; anIt++) {
+ aWidget = *anIt;
+ //QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue()));
+ QObject::connect(aWidget, SIGNAL(valuesChanged()),
+ this, SLOT(onWidgetValuesChanged()));
+ // Init default values
+ if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
+ aWidget->storeValue(aOperation->feature());
+ }
+ }
+
+ myPropertyPanel->setModelWidgets(aWidgets);
myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
}
updateCommandStatus();
//!< No need for property panel
updateCommandStatus();
hidePropertyPanel();
+ //myPropertyPanel->cleanContent();
}
/*
}
//******************************************************
-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)
{
connect(myPropertyPanel, SIGNAL(keyReleased(const std::string&, QKeyEvent*)),
myOperationMgr, SLOT(onKeyReleased(const std::string&, QKeyEvent*)));
+
+ connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+ myOperationMgr, SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+ connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)),
+ myPropertyPanel, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
}
//******************************************************
showFeatures(aFeatures, false);
}
+//**************************************************************
+void XGUI_Workshop::onWidgetValuesChanged()
+{
+ ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
+ FeaturePtr aFeature = anOperation->feature();
+
+ ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
+ //if (aCustom)
+ // aCustom->storeValue(aFeature);
+
+ const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
+ for (; anIt != aLast; anIt++) {
+ ModuleBase_ModelWidget* aCustom = *anIt;
+ if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/ aCustom == aSenderWidget)) {
+ aCustom->storeValue(aFeature);
+ }
+ }
+}
+
//**************************************************************
void XGUI_Workshop::activatePart(FeaturePtr theFeature)
{