From 44db5b97e8d5e94a05dd5c844898af23f8e987e9 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 5 Dec 2016 07:27:37 +0300 Subject: [PATCH] Issue #1750 Remove sub-shapes edition: can't select sub-shapes in the 3D view, Issue #1820 Selection of two points in sketch --- src/PartSet/PartSet_SketcherMgr.cpp | 21 ++++++++++++++++++--- src/PartSet/PartSet_SketcherMgr.h | 1 + src/XGUI/XGUI_WorkshopListener.cpp | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 54619b476..f76d3318c 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -133,8 +133,8 @@ void getAttributesOrResults(const Handle(SelectMgr_EntityOwner)& theOwner, } PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) - : QObject(theModule), myModule(theModule), myIsDragging(false), myDragDone(false), - myIsMouseOverWindow(false), + : QObject(theModule), myModule(theModule), myIsEditLaunching(false), myIsDragging(false), + myDragDone(false), myIsMouseOverWindow(false), myIsMouseOverViewProcessed(true), myPreviousUpdateViewerEnabled(true), myIsPopupMenuActive(false) { @@ -394,6 +394,8 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE } } else if (isSketchOpe && isEditing) { // If selected another object commit current result + bool aPrevLaunchingState = myIsEditLaunching; + myIsEditLaunching = true; aFOperation->commit(); myIsDragging = true; @@ -404,6 +406,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE // selected entities, e.g. selection of point(attribute on a line) should edit the point restoreSelection(); launchEditing(); + myIsEditLaunching = aPrevLaunchingState; if (aFeature.get() != NULL) { std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aFeature); @@ -1034,7 +1037,19 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation) //} /// improvement to deselect automatically all eventual selected objects, when // returning to the neutral point of the Sketcher - workshop()->selector()->clearSelection(); + bool isClearSelectionPossible = true; + if (myIsEditLaunching) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (theOperation); + if (aFOperation) { + FeaturePtr aFeature = aFOperation->feature(); + if (aFeature.get() && PartSet_SketcherMgr::isEntity(aFeature->getKind())) { + isClearSelectionPossible = false; + } + } + } + if (isClearSelectionPossible) + workshop()->selector()->clearSelection(); } void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation) diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index b6cf959d3..2029cc4a4 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -369,6 +369,7 @@ private: PartSet_Module* myModule; bool myPreviousDrawModeEnabled; // the previous selection enabled state in the viewer + bool myIsEditLaunching; bool myIsDragging; bool myDragDone; bool myIsMouseOverWindow; /// the state that the mouse over the view diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 55bfec3d8..72cf26593 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -413,6 +413,28 @@ void XGUI_WorkshopListener:: aDisplayed = displayObject(anObject); if (aDisplayed) aDoFitAll = aDoFitAll || neededFitAll(anObject, aNbOfShownObjects); + + // workaround for #1750: sub results should be sent here to be displayed + FeaturePtr anObjectFeature = ModelAPI_Feature::feature(anObject); + if (anObjectFeature.get() && anObjectFeature->getKind() == "Partition") { + XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); + if (anOperationMgr->hasOperation()) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (anOperationMgr->currentOperation()); + if (aFOperation && aFOperation->isEditOperation() && aFOperation->id() == "Remove_SubShapes") { + ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(anObject); + if (aCompsolidResult.get() != NULL) { // display all sub results + for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) { + ObjectPtr aSubObject = aCompsolidResult->subResult(i); + aSubObject->setDisplayed(true); + aDisplayed = displayObject(aSubObject); + if (aDisplayed) + aDoFitAll = aDoFitAll || neededFitAll(aSubObject, aNbOfShownObjects); + } + } + } + } + } } else anObject->setDisplayed(false); } -- 2.39.2