]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Creation of GUI widgets for the re-entrant internal feature. They are hidden and...
authornds <nds@opencascade.com>
Thu, 5 Nov 2015 05:46:50 +0000 (08:46 +0300)
committernds <nds@opencascade.com>
Thu, 5 Nov 2015 05:46:50 +0000 (08:46 +0300)
src/ModuleBase/ModuleBase_IPropertyPanel.cpp
src/ModuleBase/ModuleBase_IPropertyPanel.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h

index a3644773e17efe249c1a61ff1f9e9d8898ae0f3b..0a87a74c838943d7ac01623d9f3a38c3e125d149 100644 (file)
@@ -16,13 +16,18 @@ ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent) : QDock
 }
 
 ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget()
+{
+  return ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(modelWidgets());
+}
+
+ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget(
+                                                              const QList<ModuleBase_ModelWidget*>& theWidgets)
 {
   ModuleBase_ModelWidget* aFirstWidget = 0;
 
-  QList<ModuleBase_ModelWidget*> aWidgets = modelWidgets();
   ModuleBase_ModelWidget* aWgt;
   QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
-  for (aWIt = aWidgets.begin(); aWIt != aWidgets.end() && !aFirstWidget; ++aWIt) {
+  for (aWIt = theWidgets.begin(); aWIt != theWidgets.end() && !aFirstWidget; ++aWIt) {
     aWgt = (*aWIt);
     if (aWgt->canSetValue())
       aFirstWidget = aWgt;
index ea5a6edf6f51234235d888ac4fa2be5eed6aa83e..afafce7a756ce91ae5cf7506d52d0b16f3b3691b 100644 (file)
@@ -68,6 +68,11 @@ public:
   /// \return a widget or null
   ModuleBase_ModelWidget* findFirstAcceptingValueWidget();
 
+  /// Returns the first widget, where canSetValue returns true 
+  /// \return a widget or null
+  static ModuleBase_ModelWidget* findFirstAcceptingValueWidget(
+                          const QList<ModuleBase_ModelWidget*>& theWidgets);
+
 signals:
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theEvent key release event
index a7418714813f12a3975cf8019a36e8d01e786e29..3834a98d8f0fb717fd6e33371ff0eeab3a641d2e 100755 (executable)
 #include <ModuleBase_ModelWidget.h>
 #include <ModuleBase_ViewerPrs.h>
 #include <ModuleBase_WidgetSelector.h>
+#include <ModuleBase_PageWidget.h>
+#include <ModuleBase_PageBase.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_OperationDescription.h>
 
 #include <SketchPlugin_Feature.h>
 #include <SketchPlugin_Line.h>
@@ -19,6 +23,7 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_OperationMgr.h>
+#include <XGUI_PropertyPanel.h>
 
 PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop)
 : QObject(theWorkshop),
@@ -43,12 +48,8 @@ ModuleBase_ModelWidget* PartSet_SketcherReetntrantMgr::internalActiveWidget() co
   if (aOperation) {
     ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
     ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
-    if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector())) {
-      // finds the first widget which can accept a value
-      ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
-      if (aFirstWidget)
-        aWidget = aFirstWidget;
-    }
+    if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector()))
+      aWidget = myInternalActiveWidget;
   }
   return aWidget;
 }
@@ -276,6 +277,27 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
 
     CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
     myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
+    XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
+                                                 (aFOperation->propertyPanel());
+
+    myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
+    myInternalWidget->setVisible(false);
+
+    ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
+
+    QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+    ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
+
+    aFactory.createWidget(anInternalPage);
+    QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+
+    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+      aWidget->setFeature(myInternalFeature, true);
+    }
+    ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
+                                                                                        (aWidgets);
+    if (aFirstWidget)
+      myInternalActiveWidget = aFirstWidget;
 
     myIsInternalEditOperation = true;
     isDone = true;
@@ -314,18 +336,19 @@ void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
     disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
   }
 
+  if (myInternalActiveWidget) {
+    ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
+    if (aWSelector)
+      aWSelector->activateSelectionAndFilters(false);
+    myInternalActiveWidget = 0;
+  }
+  delete myInternalWidget;
+  myInternalWidget = 0;
+
   QObjectPtrList anObjects;
   anObjects.append(myInternalFeature);
   workshop()->deleteFeatures(anObjects);
 
-  PartSet_Module* aModule = module();
-  ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget();
-  ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel();
-  if (aFirstWidget != aPanel->activeWidget()) {
-    ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(aFirstWidget);
-    if (aWSelector)
-      aWSelector->activateSelectionAndFilters(false);
-  }
 }
 
 void PartSet_SketcherReetntrantMgr::restartOperation()
index 1f8d2e5fd24e9840e1e3839c73d7454de0401007..8853e10dcacf7feb85363a7d21324e34b760100c 100755 (executable)
@@ -147,6 +147,8 @@ private:
   bool myIsInternalEditOperation; /// true when the 'internal' edit is started
 
   FeaturePtr myInternalFeature;
+  QWidget* myInternalWidget;
+  ModuleBase_ModelWidget* myInternalActiveWidget;
 };
 
 #endif