X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_SketcherMgr.cpp;h=84a0ab0c06c314294fbe07fa4665ac999756d878;hb=384c819a1edf4b726e3a523c1ffd2b5e6b16a4c0;hp=27b0b64f67ef5d7f56d56c4337305593c639a452;hpb=25749947f69ef498b2cd03c4f7c0a33b12c46e09;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 27b0b64f6..84a0ab0c0 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -19,6 +19,8 @@ // #include "PartSet_SketcherMgr.h" + +#include "PartSet_Filters.h" #include "PartSet_SketcherReentrantMgr.h" #include "PartSet_Module.h" #include "PartSet_MouseProcessor.h" @@ -34,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +58,7 @@ #include #include #include +#include #include @@ -187,14 +191,13 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) mySketchPlane = new PartSet_PreviewSketchPlane(); - myCirclePointFilter = new PartSet_CirclePointFilter(anIWorkshop); - myPlaneFilter = new ModuleBase_ShapeInPlaneFilter(); + registerSelectionFilter(SF_SketchCirclePointFilter, new PartSet_CirclePointFilter(anIWorkshop)); + registerSelectionFilter(SF_SketchPlaneFilter, new ModuleBase_ShapeInPlaneFilter()); } PartSet_SketcherMgr::~PartSet_SketcherMgr() { - myPlaneFilter.Nullify(); - myCirclePointFilter.Nullify(); + delete mySketchPlane; } void PartSet_SketcherMgr::onEnterViewPort() @@ -646,8 +649,10 @@ void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMo QList aWidgets = aPanel->modelWidgets(); // Find corresponded widget to activate value editing foreach (ModuleBase_ModelWidget* aWgt, aWidgets) { - if (aWgt->attributeID() == SketchPlugin_Constraint::VALUE() || - aWgt->attributeID() == SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()) { + std::string anId = aWgt->attributeID(); + if (anId == SketchPlugin_Constraint::VALUE() || + anId == SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID() || + anId == SketchPlugin_ConstraintDistanceAlongDir::DISTANCE_VALUE_ID()) { PartSet_WidgetEditor* anEditor = dynamic_cast(aWgt); if (anEditor) anEditor->showPopupEditor(); @@ -672,8 +677,8 @@ void PartSet_SketcherMgr::onApplicationStarted() connect(aPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)), aReentranceMgr, SLOT(onNoMoreWidgets(const std::string&))); - connect(aPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), - aReentranceMgr, SLOT(onWidgetActivated())); + //connect(aPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), + // aReentranceMgr, SLOT(onWidgetActivated())); } XGUI_ViewerProxy* aViewerProxy = aWorkshop->viewer(); @@ -733,10 +738,15 @@ void PartSet_SketcherMgr::launchEditing() if (!aSPFeature->isExternal()) myModule->editFeature(aSPFeature); else { - FeaturePtr aProjectionFeature = PartSet_Tools::findRefsToMeFeature(aFeature, + // need to edit a feature (Projection/IntersectionPoint), + // which produces current External feature + FeaturePtr aProducerFeature = PartSet_Tools::findRefsToMeFeature(aFeature, SketchPlugin_Projection::ID()); - if (aProjectionFeature.get()) - myModule->editFeature(aProjectionFeature); + if (!aProducerFeature.get()) + aProducerFeature = PartSet_Tools::findRefsToMeFeature(aFeature, + SketchPlugin_IntersectionPoint::ID()); + if (aProducerFeature.get()) + myModule->editFeature(aProducerFeature); } } } @@ -812,9 +822,11 @@ const QStringList& PartSet_SketcherMgr::constraintsIdList() return aConstraintIds; } -void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes) +void PartSet_SketcherMgr::sketchSelectionModes(const CompositeFeaturePtr& theSketch, + QIntList& theModes) { - theModes.clear(); + if (!theSketch.get() || !PartSet_Tools::sketchPlane(theSketch).get()) + return; theModes.append(SketcherPrs_Tools::Sel_Dimension_Text); theModes.append(SketcherPrs_Tools::Sel_Dimension_Line); @@ -938,6 +950,13 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) // Display all sketcher sub-Objects myCurrentSketch = std::dynamic_pointer_cast(aFOperation->feature()); + double aSizeOfView = 0; + std::shared_ptr aCentralPoint; + if (aFOperation->isEditOperation() && + mySketchPlane->getDefaultSizeOfView(myCurrentSketch, aSizeOfView, aCentralPoint)) { + mySketchPlane->setSizeOfView(aSizeOfView, true, aCentralPoint); + } + mySketchPlane->createSketchPlane(myCurrentSketch, myModule->workshop()); XGUI_ModuleConnector* aConnector = dynamic_cast(myModule->workshop()); @@ -952,7 +971,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) // Remove invalid sketch entities std::set anInvalidFeatures; ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + int aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); if (aFeature.get()) { if (!aFactory->validate(aFeature)) @@ -993,7 +1013,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) QStringList anInfo; Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); #ifdef DEBUG_SKETCHER_ENTITIES anInfo.append(ModuleBase_Tools::objectInfo(aFeature)); @@ -1020,15 +1041,14 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) bool aHasPlane = false; std::shared_ptr aPln; aPln = PartSet_Tools::sketchPlane(myCurrentSketch); - myPlaneFilter->setPlane(aPln); + Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter); + if (!aFilter.IsNull()) + Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln); - activateSelectionFilters(); + workshop()->selectionActivate()->updateSelectionFilters(); + workshop()->selectionActivate()->updateSelectionModes(); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - // all displayed objects should be activated in current selection modes according to switched - // plane filter - if (aPln.get()) - aConnector->activateModuleSelectionModes(); myExternalPointsMgr = new PartSet_ExternalPointsMgr(myModule->workshop(), myCurrentSketch); } @@ -1064,7 +1084,8 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) } else { // Hide all sketcher sub-Objects - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + int aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); std::list aResults = aFeature->results(); std::list::const_iterator aIt; @@ -1097,10 +1118,8 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) Events_Loop::loop()->flush(aDispEvent); } - deactivateSelectionFilters(); - - // restore the module selection modes, which were changed on startSketch - aConnector->activateModuleSelectionModes(); + workshop()->selectionActivate()->updateSelectionFilters(); + workshop()->selectionActivate()->updateSelectionModes(); } void PartSet_SketcherMgr::startNestedSketch(ModuleBase_Operation* theOperation) @@ -1160,24 +1179,16 @@ void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation) } } -void PartSet_SketcherMgr::activateSelectionFilters() +bool PartSet_SketcherMgr::sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType) { - myModule->workshop()->viewer()->addSelectionFilter(myCirclePointFilter); - myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter); + return mySelectionFilterTypes.find(theFilterType) != mySelectionFilterTypes.end(); } -void PartSet_SketcherMgr::deactivateSelectionFilters() +void PartSet_SketcherMgr::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, + const Handle(SelectMgr_Filter)& theFilter) { - myModule->workshop()->viewer()->removeSelectionFilter(myCirclePointFilter); - myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter); -} - -void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate) -{ - if (toActivate) - myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter); - else - myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter); + mySelectionFilterTypes.insert(theFilterType); + myModule->registerSelectionFilter(theFilterType, theFilter); } bool PartSet_SketcherMgr::operationActivatedByPreselection() @@ -1472,7 +1483,7 @@ bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject); if (anObjectFeature.get()) { int aSize = myCurrentSketch->numberOfSubs(); - for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) { + for (int i = 0; i < aSize && !isFoundObject; i++) { FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i); isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature; } @@ -1480,9 +1491,13 @@ bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const return isFoundObject; } -void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& thePln) +void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& thePlane) { - myPlaneFilter->setPlane(thePln); + Handle(SelectMgr_Filter) aFilter = myModule->selectionFilter(SF_SketchPlaneFilter); + if (!aFilter.IsNull()) + Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(thePlane); + + workshop()->selectionActivate()->updateSelectionModes(); } bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation, @@ -1889,7 +1904,8 @@ void PartSet_SketcherMgr::updateBySketchParameters( if (aPrevState != theState) { ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + int aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aSubFeature = myCurrentSketch->subFeature(i); bool aProcessed = false; bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, theType, aProcessed);