From 8a91c120999d09d63eb4fd76cff399dd107e151a Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 30 Mar 2017 13:21:07 +0300 Subject: [PATCH] Issue #2027 Sketcher Trim Feature: preselection in reentrant operation --- .../PartSet_OverconstraintListener.cpp | 15 +++-------- src/PartSet/PartSet_SketcherReentrantMgr.cpp | 25 +++++++++++++++++-- src/PartSet/PartSet_SketcherReentrantMgr.h | 5 ++++ .../PartSet_WidgetFeaturePointSelector.cpp | 3 +++ src/SketchPlugin/SketchPlugin_Plugin.cpp | 2 +- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index 18125ad34..41ee6b2a2 100755 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -46,11 +46,7 @@ void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject, std::vector& theColor) { if (myConflictingObjects.find(theObject) != myConflictingObjects.end()) { - Quantity_Color aColor = ModuleBase_Tools::color("Visualization", - "sketch_overconstraint_color"); - theColor.push_back(aColor.Red()*255.); - theColor.push_back(aColor.Green()*255.); - theColor.push_back(aColor.Blue()*255.); + theColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color"); } if (myIsFullyConstrained) { FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); @@ -59,13 +55,8 @@ void PartSet_OverconstraintListener::getCustomColor(const ObjectPtr& theObject, PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); CompositeFeaturePtr aCompositeFeature = aModule->sketchMgr()->activeSketch(); // the given object is sub feature of the current sketch(created or edited) - if (ModelAPI_Tools::compositeOwner(aFeature) == aCompositeFeature) { - Quantity_Color aColor = ModuleBase_Tools::color("Visualization", - "sketch_fully_constrained_color"); - theColor.push_back(aColor.Red()*0.); - theColor.push_back(aColor.Green()*255.); - theColor.push_back(aColor.Blue()*0.); - } + if (ModelAPI_Tools::compositeOwner(aFeature) == aCompositeFeature) + theColor = Config_PropManager::color("Visualization", "sketch_fully_constrained_color"); } } } diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.cpp b/src/PartSet/PartSet_SketcherReentrantMgr.cpp index 488f5660a..00b8f3f25 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReentrantMgr.cpp @@ -246,6 +246,12 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow* std::shared_ptr aSelectedPrs; if (!aPreSelected.empty()) aSelectedPrs = aPreSelected.front(); + if (!aSelectedPrs.get() && aSelectedPrs->object().get() + && !aSelectedPrs->object()->data()->isValid()) { + // the selected object was removed diring restart, e.g. presentable macro feature + // there are created objects to replace the object depending on created feature kind + aSelectedPrs = generatePreSelection(); + } aMouseProcessor->setPreSelection(aSelectedPrs, theWnd, theEvent); //aPoint2DWdg->mouseReleased(theWnd, theEvent); //if (!aPreSelected.empty()) @@ -255,7 +261,6 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow* ModuleBase_Tools::blockUpdateViewer(false); } } - return aProcessed; } @@ -394,10 +399,19 @@ void PartSet_SketcherReentrantMgr::appendCreatedObjects(const std::set + (myWorkshop->currentOperation()); + if (aFOperation) + aCurrentFeature = aFOperation->feature(); + + for (std::set::const_iterator anIt = theObjects.begin(); anIt != theObjects.end(); ++anIt) { FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); - if (myCreatedFeatures.find(aFeature) != myCreatedFeatures.end()) + if (aFeature == aCurrentFeature) + continue; + if (myCreatedFeatures.find(aFeature) == myCreatedFeatures.end()) myCreatedFeatures.insert(aFeature); } } @@ -714,6 +728,13 @@ bool PartSet_SketcherReentrantMgr::isTangentArc(ModuleBase_Operation* theOperati return aTangentArc; } +std::shared_ptr PartSet_SketcherReentrantMgr::generatePreSelection() +{ + std::shared_ptr aPrs; + + return aPrs; +} + void PartSet_SketcherReentrantMgr::updateAcceptAllAction() { CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch(); diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.h b/src/PartSet/PartSet_SketcherReentrantMgr.h index 17006c1e4..96ff87753 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.h +++ b/src/PartSet/PartSet_SketcherReentrantMgr.h @@ -22,6 +22,7 @@ class QMouseEvent; class XGUI_Workshop; class PartSet_Module; +class ModuleBase_ViewerPrs; /// \ingroup PartSet_SketcherReentrantMgr /// It provides reentrant create operations in sketch, that is when all inputs are valid, @@ -174,6 +175,10 @@ private: bool isTangentArc(ModuleBase_Operation* theOperation, const std::shared_ptr& /*theSketch*/) const; + /// Creates selection instance by the current feature and created by restart objects + /// \returns viewer selection presentation + std::shared_ptr generatePreSelection(); + /// Accept All action is enabled if an internal edit is started. /// It updates the state of the button void updateAcceptAllAction(); diff --git a/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp b/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp index f2808b3ad..e8c4abf8c 100644 --- a/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp +++ b/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp @@ -167,6 +167,9 @@ bool PartSet_WidgetFeaturePointSelector::fillFeature( if (theSelectedPrs.get() && theSelectedPrs->object().get()) anObject = theSelectedPrs->object(); + if (!anObject.get()) + return aFilled; + gp_Pnt aPnt = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView()); double aX, anY; Handle(V3d_View) aView = theWindow->v3dView(); diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 774a961b9..3b12526d6 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -53,7 +53,7 @@ #define SKETCH_EXTERNAL_COLOR "170,0,225" #define SKETCH_AUXILIARY_COLOR "0,85,0" #define SKETCH_OVERCONSTRAINT_COLOR "0,0,0" -#define SKETCH_FULLY_CONSTRAINED_COLOR "150,150,150" +#define SKETCH_FULLY_CONSTRAINED_COLOR "0,150,0" //#define SET_PLANES_COLOR_IN_PREFERENCES -- 2.39.2