Salome HOME
Lenght, Radius constraints creation after re-entrant operation. The object is clicked...
authornds <nds@opencascade.com>
Tue, 3 Nov 2015 10:39:28 +0000 (13:39 +0300)
committernds <nds@opencascade.com>
Tue, 3 Nov 2015 10:39:28 +0000 (13:39 +0300)
src/ModuleBase/ModuleBase_IPropertyPanel.cpp
src/ModuleBase/ModuleBase_IPropertyPanel.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp

index ee4490aca9aa2450dc8a40a498962c1db91a69b0..a3644773e17efe249c1a61ff1f9e9d8898ae0f3b 100644 (file)
@@ -8,8 +8,24 @@
  */
 
 #include "ModuleBase_IPropertyPanel.h"
+#include "ModuleBase_ModelWidget.h"
 
 ModuleBase_IPropertyPanel::ModuleBase_IPropertyPanel(QWidget* theParent) : QDockWidget(theParent), myIsEditing(false)
 {
 
 }
+
+ModuleBase_ModelWidget* ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget()
+{
+  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) {
+    aWgt = (*aWIt);
+    if (aWgt->canSetValue())
+      aFirstWidget = aWgt;
+  }
+  return aFirstWidget;
+}
index 6335c5b67437337d1b12a8be2a048a0d9cdf7a1c..ea5a6edf6f51234235d888ac4fa2be5eed6aa83e 100644 (file)
@@ -64,6 +64,10 @@ public:
   /// Sets widget processed by preselection
   virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget) = 0;
 
+  /// Returns the first widget, where canSetValue returns true 
+  /// \return a widget or null
+  ModuleBase_ModelWidget* findFirstAcceptingValueWidget();
+
 signals:
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theEvent key release event
index 6e40f33b31696da601345807f4a59b281f752e87..fbb653b4c2d48e0cb17e7c7138f017ebd1027e42 100755 (executable)
@@ -45,15 +45,7 @@ ModuleBase_ModelWidget* PartSet_SketcherReetntrantMgr::internalActiveWidget() co
     ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
     if (myIsInternalEditOperation && (!anActiveWidget || !anActiveWidget->isViewerSelector())) {
       // finds the first widget which can accept a value
-      QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
-      ModuleBase_ModelWidget* aFirstWidget = 0;
-      ModuleBase_ModelWidget* aWgt;
-      QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
-      for (aWIt = aWidgets.begin(); aWIt != aWidgets.end() && !aFirstWidget; ++aWIt) {
-        aWgt = (*aWIt);
-        if (aWgt->canSetValue())
-          aFirstWidget = aWgt;
-      }
+      ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
       if (aFirstWidget)
         aWidget = aFirstWidget;
     }
@@ -135,15 +127,19 @@ bool PartSet_SketcherReetntrantMgr::processMouseReleased(ModuleBase_IViewWindow*
 
   if (myIsInternalEditOperation) {
     ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+    ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
 
-    ModuleBase_ModelWidget* anActiveWidget = anOperation->propertyPanel()->activeWidget();
+    ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
     if (!anActiveWidget || !anActiveWidget->isViewerSelector()) {
       restartOperation();
       aProcessed = true;
 
-      // fill the widget by the mouse event point
+      // fill the first widget by the mouse event point
+      // if the active widget is not the first, it means that the restarted operation is filled by
+      // the current preselection.
       PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
-      if (aPoint2DWdg) {
+      ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
+      if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
         aPoint2DWdg->onMouseRelease(theWnd, theEvent);
       }
     }
@@ -339,3 +335,4 @@ PartSet_Module* PartSet_SketcherReetntrantMgr::module() const
 {
   return dynamic_cast<PartSet_Module*>(myWorkshop->module());
 }
+