X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_SketcherMgr.cpp;h=84a0ab0c06c314294fbe07fa4665ac999756d878;hb=384c819a1edf4b726e3a523c1ffd2b5e6b16a4c0;hp=68045ed3e414645c7963c5372bf6e57212ffd980;hpb=bbef0297c85f81513744d7fa64a953cc223c8f4b;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 68045ed3e..84a0ab0c0 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -197,6 +197,7 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) PartSet_SketcherMgr::~PartSet_SketcherMgr() { + delete mySketchPlane; } void PartSet_SketcherMgr::onEnterViewPort() @@ -648,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(); @@ -735,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); } } } @@ -942,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()); @@ -956,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)) @@ -997,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)); @@ -1067,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; @@ -1161,12 +1179,12 @@ void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation) } } -bool PartSet_SketcherMgr::sketchSelectionFilter(const PartSet_SelectionFilterType theFilterType) +bool PartSet_SketcherMgr::sketchSelectionFilter(const XGUI_SelectionFilterType theFilterType) { return mySelectionFilterTypes.find(theFilterType) != mySelectionFilterTypes.end(); } -void PartSet_SketcherMgr::registerSelectionFilter(const PartSet_SelectionFilterType theFilterType, +void PartSet_SketcherMgr::registerSelectionFilter(const XGUI_SelectionFilterType theFilterType, const Handle(SelectMgr_Filter)& theFilter) { mySelectionFilterTypes.insert(theFilterType); @@ -1465,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; } @@ -1886,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);