X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_SketcherReentrantMgr.cpp;h=839da3fa082c2d3a161d055e2527272ab2e100ee;hb=ca925f26180f15699a77e76461679f11abd499ba;hp=c5a4e3cb1b5919da873604ff8f623e1ca257c5a9;hpb=87b6a30a3afb8fb32e7e43ade8d9c947d9eb1684;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_SketcherReentrantMgr.cpp b/src/PartSet/PartSet_SketcherReentrantMgr.cpp index c5a4e3cb1..839da3fa0 100644 --- a/src/PartSet/PartSet_SketcherReentrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReentrantMgr.cpp @@ -19,6 +19,7 @@ // #include "PartSet_SketcherReentrantMgr.h" +#include "PartSet_ExternalObjectsMgr.h" #include "PartSet_Module.h" #include "PartSet_SketcherMgr.h" #include "PartSet_WidgetPoint2d.h" @@ -32,6 +33,7 @@ #include "GeomDataAPI_Point2D.h" #include +#include #include #include #include @@ -42,6 +44,7 @@ #include #include "ModuleBase_ToolBox.h" #include "ModuleBase_ISelection.h" +#include "ModuleBase_ISelectionActivate.h" #include #include @@ -252,6 +255,7 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow* myClickedSketchPoint = PartSet_Tools::getPnt2d(theEvent, theWindow, module()->sketchMgr()->activeSketch()); + FeaturePtr anExternalCreatedFeature; if (!aPreSelected.empty()) { ModuleBase_ViewerPrsPtr aValue = aPreSelected.first(); module()->getGeomSelection(aValue, mySelectedObject, mySelectedAttribute); @@ -260,10 +264,23 @@ bool PartSet_SketcherReentrantMgr::processMouseReleased(ModuleBase_IViewWindow* if (aPointWidget) { GeomShapePtr aShape; aPointWidget->getGeomSelection_(aValue, mySelectedObject, aShape); + ObjectPtr anExternalObject = + aPointWidget->getExternalObjectMgr()->getExternalObjectValidated(); + // if external object is during reentrant operation and is used as a parameter of feature + // it should be removed after the operation is restarted. (Circle feature, Projection) + if (anExternalObject.get()) + anExternalCreatedFeature = ModelAPI_Feature::feature(anExternalObject); } } restartOperation(); + // remove created external feature + if (anExternalCreatedFeature.get()) { + QObjectPtrList anObjects; + anObjects.append(anExternalCreatedFeature); + workshop()->deleteFeatures(anObjects); + } + myClickedSketchPoint = std::shared_ptr(); mySelectedObject = ObjectPtr(); mySelectedAttribute = AttributePtr(); @@ -320,22 +337,24 @@ void PartSet_SketcherReentrantMgr::setReentrantPreSelection( aReentrantMessage->setClickedPoint(myClickedSketchPoint); } -void PartSet_SketcherReentrantMgr::onWidgetActivated() -{ - if (!isActiveMgr()) - return; - if (!myIsInternalEditOperation) - return; - - PartSet_Module* aModule = module(); - ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget(); - ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel(); - if (aFirstWidget != aPanel->activeWidget()) { - ModuleBase_WidgetSelector* aWSelector = dynamic_cast(aFirstWidget); - if (aWSelector) - aWSelector->activateSelectionAndFilters(true); - } -} +//void PartSet_SketcherReentrantMgr::onWidgetActivated() +//{ +// if (!isActiveMgr()) +// return; +// if (!myIsInternalEditOperation) +// return; +// +// PartSet_Module* aModule = module(); +// ModuleBase_ModelWidget* aFirstWidget = aModule->activeWidget(); +// ModuleBase_IPropertyPanel* aPanel = aModule->currentOperation()->propertyPanel(); +// if (aFirstWidget != aPanel->activeWidget()) { +// ModuleBase_WidgetSelector* aWSelector = dynamic_cast +// (aFirstWidget); +// if (aWSelector) { +// myWorkshop->selectionActivate()->updateSelectionModesAndFilters(aWSelector); +// } +// } +//} void PartSet_SketcherReentrantMgr::onNoMoreWidgets(const std::string& thePreviousAttributeID) { @@ -361,15 +380,20 @@ void PartSet_SketcherReentrantMgr::onNoMoreWidgets(const std::string& thePreviou return; if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) { - bool isStarted = false; - if (!module()->sketchMgr()->sketchSolverError()) { - if (myRestartingMode != RM_Forbided) { - myRestartingMode = RM_LastFeatureUsed; - isStarted = startInternalEdit(thePreviousAttributeID); + if (aFOperation->isNeedToBeAborted()) { + aFOperation->abort(); + } + else { + bool isStarted = false; + if (!module()->sketchMgr()->sketchSolverError()) { + if (myRestartingMode != RM_Forbided) { + myRestartingMode = RM_LastFeatureUsed; + isStarted = startInternalEdit(thePreviousAttributeID); + } } + if (!isStarted) + aFOperation->commit(); } - if (!isStarted) - aFOperation->commit(); } } @@ -486,6 +510,10 @@ bool PartSet_SketcherReentrantMgr::startInternalEdit(const std::string& thePrevi (myWorkshop->currentOperation()); if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) { + /// improvement to deselect automatically all eventual selected objects, when + // returning to the neutral point of the Sketcher or start internal edit + workshop()->selector()->clearSelection(); + aFOperation->setEditOperation(true/*, false*/); createInternalFeature(); @@ -497,7 +525,7 @@ bool PartSet_SketcherReentrantMgr::startInternalEdit(const std::string& thePrevi connect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped())); // activate selection filters of the first widget in the viewer - onWidgetActivated(); + //onWidgetActivated(); // activate the last active widget in the Property Panel if (!thePreviousAttributeID.empty()) { @@ -652,13 +680,8 @@ void PartSet_SketcherReentrantMgr::deleteInternalFeature() std::cout << "PartSet_SketcherReentrantMgr::deleteInternalFeature: " << myInternalFeature->data()->name() << std::endl; #endif - if (myInternalActiveWidget) { - ModuleBase_WidgetSelector* aWSelector = - dynamic_cast(myInternalActiveWidget); - if (aWSelector) - aWSelector->activateSelectionAndFilters(false); + if (myInternalActiveWidget) myInternalActiveWidget = 0; - } delete myInternalWidget; myInternalWidget = 0;