From 8bb21a37986d5eec276260eca3c71cadd8a6b47c Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 16 Feb 2015 08:15:00 +0300 Subject: [PATCH] Issue #394 Undo-ing a Sketch element A correction to display the nested feature by the operation commit, but if it was not displayed in the view. --- src/PartSet/PartSet_Module.cpp | 3 --- src/PartSet/PartSet_SketcherMgr.cpp | 26 ++++++++++++++------------ src/PartSet/PartSet_SketcherMgr.h | 9 +++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 2e61cf223..60d6768cf 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -390,9 +390,6 @@ void PartSet_Module::onOperationActivatedByPreselection() // Set final definitions if they are necessary //propertyPanelDefined(aOperation); - // the sketch manager should return the true state in canBeDisplayed, so it is correct - // to switch the property panel value changed flag for this - mySketchMgr->onValuesChangedInPropertyPanel(); /// Commit sketcher operations automatically aOperation->commit(); } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 6398ce252..44bac35b6 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -179,7 +179,7 @@ void PartSet_SketcherMgr::onLeaveViewPort() // hides the presentation of the current operation feature myIsPropertyPanelValueChanged = false; - updateVisibilityOfCreatedFeature(); + visualizeFeature(aOperation, false); } void PartSet_SketcherMgr::onValuesChangedInPropertyPanel() @@ -189,7 +189,8 @@ void PartSet_SketcherMgr::onValuesChangedInPropertyPanel() // visualize the current operation feature myIsPropertyPanelValueChanged = true; - updateVisibilityOfCreatedFeature(); + ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation(); + visualizeFeature(aOperation, true); } void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) @@ -333,7 +334,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve if (aDistanceWdg) { aDistanceWdg->onMouseMove(theWnd, theEvent); } - updateVisibilityOfCreatedFeature(); + visualizeFeature(aOperation, true); } myClickedPoint.clear(); @@ -651,11 +652,12 @@ void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* ) connectToPropertyPanel(true); } -void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* ) +void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation) { connectToPropertyPanel(false); myIsPropertyPanelValueChanged = false; myIsMouseOverViewProcessed = true; + visualizeFeature(theOperation, true); } bool PartSet_SketcherMgr::canUndo() const @@ -829,21 +831,21 @@ bool PartSet_SketcherMgr::isNestedCreateOperation() const return aOperation && !aOperation->isEditOperation() && isNestedSketchOperation(aOperation); } -void PartSet_SketcherMgr::updateVisibilityOfCreatedFeature() +void PartSet_SketcherMgr::visualizeFeature(ModuleBase_Operation* theOperation, + const bool isToDisplay) { - ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); - ModuleBase_Operation* aOperation = aWorkshop->currentOperation(); - if (!aOperation || aOperation->isEditOperation()) + if (!theOperation || theOperation->isEditOperation()) return; + + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); - bool aToDisplay = canDisplayObject(); // 1. change visibility of the object itself, here the presentable object is processed, // e.g. constraints features - FeaturePtr aFeature = aOperation->feature(); + FeaturePtr aFeature = theOperation->feature(); std::list aResults = aFeature->results(); - if (aToDisplay) + if (isToDisplay) aDisplayer->display(aFeature, false); else aDisplayer->erase(aFeature, false); @@ -851,7 +853,7 @@ void PartSet_SketcherMgr::updateVisibilityOfCreatedFeature() // change visibility of the object results, e.g. non-constraint features std::list::const_iterator aIt; for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { - if (aToDisplay) { + if (isToDisplay) { aDisplayer->display(*aIt, false); } else { diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index a4a0246d7..81a30242d 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -128,9 +128,6 @@ public slots: /// Process sketch plane selected event void onPlaneSelected(const std::shared_ptr& thePln); - /// Listens the value changed signal and display the current operation feature - void onValuesChangedInPropertyPanel(); - private slots: /// Process the enter mouse to the view port. If the current operation is a create of /// a nested sketch feature, it updates internal flags to display the feature on mouse move @@ -138,6 +135,8 @@ private slots: /// Process the leave mouse of the view port. If the current operation is a create of /// a nested sketch feature, it hides the feature in the viewer void onLeaveViewPort(); + /// Listens the value changed signal and display the current operation feature + void onValuesChangedInPropertyPanel(); void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*); void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*); @@ -216,7 +215,9 @@ private: /// Erase or display the feature of the current operation. If the mouse over the active view or /// a current value is changed by property panel, the feature is displayed otherwise it is hidden - void updateVisibilityOfCreatedFeature(); + /// \param theOperation an operation which feature is to be displayed, it is nested create operation + /// \param isToDisplay a flag about the display or erase the feature + void visualizeFeature(ModuleBase_Operation* theOperation, const bool isToDisplay); private: PartSet_Module* myModule; -- 2.39.2