From 01adaaf3350fbb57fb83ea4f9b4ad078ac60c643 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 1 Dec 2015 15:21:09 +0300 Subject: [PATCH] #1108 Point coordinates is changed after click in the viewer The problem was in myClickedPoint, it was not cleared and after click, the new line used the old clicked coordinates. The point and coincide last point of the previous line are moved to a start point of a new line. There is a problem with this flag during Alt+TAB when creation of a line is active. So, the decision is to remove this flag. The case to be checked: contour creation. The preview of created lines should not dragged to an origin. How it is corrected: point 2D widget do not initialize attribute by activating. --- src/PartSet/PartSet_SketcherMgr.cpp | 37 +++++++++++++-------------- src/PartSet/PartSet_SketcherMgr.h | 4 +-- src/PartSet/PartSet_WidgetPoint2d.cpp | 4 +++ src/PartSet/PartSet_WidgetPoint2d.h | 7 +++++ 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index eddf4b07e..a90f4a0f8 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -323,7 +323,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent)) return; - get2dPoint(theWnd, theEvent, myClickedPoint); + //get2dPoint(theWnd, theEvent, myClickedPoint); if (!(theEvent->buttons() & Qt::LeftButton)) return; @@ -435,7 +435,7 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse ModuleBase_Operation* aOp = getCurrentOperation(); if (aOp) { if (isNestedSketchOperation(aOp)) { - get2dPoint(theWnd, theEvent, myClickedPoint); + //get2dPoint(theWnd, theEvent, myClickedPoint); // Only for sketcher operations if (myIsDragging) { @@ -491,7 +491,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve } } - myClickedPoint.clear(); + //myClickedPoint.clear(); if (myIsDragging) { // 1. the current selection is saved in the mouse press method in order to restore it after moving @@ -619,8 +619,8 @@ void PartSet_SketcherMgr::onApplicationStarted() XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel(); if (aPropertyPanel) { - connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)), - this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*))); + //connect(aPropertyPanel, SIGNAL(beforeWidgetActivated(ModuleBase_ModelWidget*)), + // this, SLOT(onBeforeWidgetActivated(ModuleBase_ModelWidget*))); connect(aPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)), aReentranceMgr, SLOT(onNoMoreWidgets(const std::string&))); @@ -637,23 +637,23 @@ void PartSet_SketcherMgr::onApplicationStarted() connect(aContextMenuMgr, SIGNAL(afterContextMenu()), this, SLOT(onAfterContextMenu())); } -void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget) -{ - if (!myClickedPoint.myIsInitialized) - return; +//void PartSet_SketcherMgr::onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget) +//{ + //if (!myClickedPoint.myIsInitialized) + // return; - ModuleBase_Operation* aOperation = getCurrentOperation(); + //ModuleBase_Operation* aOperation = getCurrentOperation(); // the distance constraint feature should not use the clickedd point // this is workaround in order to don't throw down the flyout point value, // set by execute() method of these type of features - if (isDistanceOperation(aOperation)) - return; + //if (isDistanceOperation(aOperation)) + // return; - PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast(theWidget); - if (aPnt2dWgt) { - aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY); - } -} + //PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast(theWidget); + //if (aPnt2dWgt) { + // aPnt2dWgt->setPoint(myClickedPoint.myCurX, myClickedPoint.myCurY); + //} +//} void PartSet_SketcherMgr::onBeforeContextMenu() { @@ -714,8 +714,7 @@ QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) void PartSet_SketcherMgr::clearClickedFlags() { - return; - myClickedPoint.clear(); + //myClickedPoint.clear(); myCurrentPoint.clear(); } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 284d2b316..5d31e7d4a 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -237,7 +237,7 @@ private slots: void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*); void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*); void onApplicationStarted(); - void onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget); + //void onBeforeWidgetActivated(ModuleBase_ModelWidget* theWidget); void onBeforeContextMenu(); void onAfterContextMenu(); @@ -317,7 +317,7 @@ private: bool myIsMouseOverViewProcessed; /// the state whether the over view state is processed by mouseMove method bool myIsPopupMenuActive; /// the state of the popup menu is shown Point myCurrentPoint; - Point myClickedPoint; + //Point myClickedPoint; CompositeFeaturePtr myCurrentSketch; diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 6e78ed9d7..b10dd41cf 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -496,6 +496,10 @@ bool PartSet_WidgetPoint2D::isFeatureContainsPoint(const FeaturePtr& theFeature, return aPointIsFound; } +void PartSet_WidgetPoint2D::initializeValueByActivate() +{ +} + /*void PartSet_WidgetPoint2D::onValuesChanged() { emit valuesChanged(); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index c1b0d0576..e32cf72c1 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -134,6 +134,13 @@ protected: /// Process value changed event //void onValuesChanged(); + /// Compute the feature default value and fill the controls with it + /// or store the control value to the feature + /// The widget is not initialize the attribute value in order to avoid the + /// incorrect visualization in Sketch. E.g. by a line creation, the line should not + /// be visualized immediatelly when the end point widget is activated. + virtual void initializeValueByActivate(); + private: /// Returns point 2d from selected vertex /// \param theView a view window -- 2.39.2