From eba31a1e57f60fe3b8822e6905f92f319003698f Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 3 Nov 2015 13:39:28 +0300 Subject: [PATCH] Lenght, Radius constraints creation after re-entrant operation. The object is clicked, but the 2nd flyout point widget tried to process the mouse release also. --- src/ModuleBase/ModuleBase_IPropertyPanel.cpp | 16 ++++++++++++++ src/ModuleBase/ModuleBase_IPropertyPanel.h | 4 ++++ src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 21 ++++++++----------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.cpp b/src/ModuleBase/ModuleBase_IPropertyPanel.cpp index ee4490aca..a3644773e 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.cpp +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.cpp @@ -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 aWidgets = modelWidgets(); + ModuleBase_ModelWidget* aWgt; + QList::const_iterator aWIt; + for (aWIt = aWidgets.begin(); aWIt != aWidgets.end() && !aFirstWidget; ++aWIt) { + aWgt = (*aWIt); + if (aWgt->canSetValue()) + aFirstWidget = aWgt; + } + return aFirstWidget; +} diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.h b/src/ModuleBase/ModuleBase_IPropertyPanel.h index 6335c5b67..ea5a6edf6 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.h +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.h @@ -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 diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 6e40f33b3..fbb653b4c 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -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 aWidgets = aPanel->modelWidgets(); - ModuleBase_ModelWidget* aFirstWidget = 0; - ModuleBase_ModelWidget* aWgt; - QList::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(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(myWorkshop->module()); } + -- 2.39.2