Salome HOME
Update SketchBuilder to work on faces with holes (issue #1320)
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index d2782f2ffb9c643394afc9c1a0d173bf5b1f36c1..feb5405db4d9996f8307efbd05b7f6c55c656db5 100755 (executable)
@@ -66,6 +66,8 @@
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_OperationFeature.h>
 #include <ModuleBase_OperationAction.h>
+#include <ModuleBase_PagedContainer.h>
+#include <ModuleBase_WidgetValidated.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
@@ -242,6 +244,7 @@ void XGUI_Workshop::activateModule()
   QIntList aModes;
   module()->activeSelectionModes(aModes);
   aDisplayer->activateObjects(aModes, aDisplayed);
+  myOperationMgr->activate();
 }
 
 void XGUI_Workshop::deactivateModule()
@@ -259,6 +262,8 @@ void XGUI_Workshop::deactivateModule()
   XGUI_Displayer* aDisplayer = displayer();
   QObjectPtrList aDisplayed = aDisplayer->displayedObjects();
   aDisplayer->deactivateObjects(aDisplayed, true);
+
+  myOperationMgr->deactivate();
 }
 
 //******************************************************
@@ -564,13 +569,15 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
     return;
 
   showPropertyPanel();
-  QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
-  ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
-
   myPropertyPanel->cleanContent();
-  aFactory.createWidget(myPropertyPanel->contentWidget());
 
-  QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+  QList<ModuleBase_ModelWidget*> aWidgets;
+  if (!module()->createWidgets(theOperation, aWidgets)) {
+    QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+    ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
+    aFactory.createWidget(myPropertyPanel->contentWidget());
+    aWidgets = aFactory.getModelWidgets();
+  }
 
   // check compatibility of feature and widgets
   FeaturePtr aFeature = aFOperation->feature();
@@ -616,11 +623,13 @@ void XGUI_Workshop::connectToPropertyPanel(const bool isToConnect)
     const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
     foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
        myModule->connectToPropertyPanel(aWidget, isToConnect);
-      if (isToConnect) {
+       if (isToConnect) {
         connect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
+        connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged()));
       }
       else {
         disconnect(aWidget, SIGNAL(valueStateChanged(int)), this, SLOT(onWidgetStateChanged(int)));
+        disconnect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onValuesChanged()));
       }
     }
   }
@@ -893,6 +902,27 @@ void XGUI_Workshop::onWidgetStateChanged(int thePreviousState)
   myModule->widgetStateChanged(thePreviousState);
 }
 
+//******************************************************
+void XGUI_Workshop::onValuesChanged()
+{
+  ModuleBase_ModelWidget* aSenderWidget = (ModuleBase_ModelWidget*)(sender());
+  if (!aSenderWidget || aSenderWidget->canSetValue())
+    return;
+
+  ModuleBase_ModelWidget* anActiveWidget = 0;
+  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
+  if (anOperation) {
+    ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+    if (aPanel)
+      anActiveWidget = aPanel->activeWidget();
+  }
+  if (anActiveWidget) {
+    ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
+                                                                           (anActiveWidget);
+    aWidgetValidated->clearValidatedCash();
+  }
+}
+
 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
 {
   QString libName = QString::fromStdString(library(theModule.toStdString()));
@@ -1063,8 +1093,8 @@ void XGUI_Workshop::createDockWidgets()
   connect(myPropertyPanel, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
           myOperationMgr,  SLOT(onKeyReleased(QObject*, QKeyEvent*)));
 
-  connect(myPropertyPanel, SIGNAL(enterClicked()),
-          myOperationMgr,  SLOT(onProcessEnter()));
+  connect(myPropertyPanel, SIGNAL(enterClicked(QObject*)),
+          myOperationMgr,  SLOT(onProcessEnter(QObject*)));
 }
 
 //******************************************************