Salome HOME
Update SketchBuilder to work on faces with holes (issue #1320)
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 9d9b893001d59dae2021650deb8c3b37e7e8ad98..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>
@@ -567,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();
@@ -619,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()));
       }
     }
   }
@@ -896,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()));