X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Tools.cpp;h=8a4c158f3935ca4a311730804b968411d35990c2;hb=7b4a6a2a335d41a647e0f6a6becb7c23df042be1;hp=7644c7268abcaf402450d673e7e36d8a4b8f2a08;hpb=8f09d362a50ccbc085841c24af2e755121e458ba;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 7644c7268..8a4c158f3 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -178,68 +178,6 @@ std::shared_ptr PartSet_Tools::convertTo3D(const double theX, const return aPnt2d->to3D(aC->pnt(), aX->dir(), aY); } -ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, - FeaturePtr theSketch, - const QList& theSelected, - const QList& theHighlighted) -{ - // firstly it finds the feature in the list of highlight - ObjectPtr aDeltaObject = nearestFeature(thePoint, theView, theSketch, theHighlighted); - if (!aDeltaObject) - // secondly it finds the feature in the list of selected objects - aDeltaObject = nearestFeature(thePoint, theView, theSketch, theSelected); - - return aDeltaObject; -} - -ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, - FeaturePtr theSketch, - const QList& thePresentations) -{ - ObjectPtr aDeltaObject; - - CompositeFeaturePtr aSketch = - std::dynamic_pointer_cast(theSketch); - // 1. find it in the selected list by the selected point - if (!aDeltaObject) { - double aX, anY; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(thePoint, theView); - PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY); - - FeaturePtr aFeature; - double aMinDelta = -1; - ModuleBase_ViewerPrs aPrs; - foreach (ModuleBase_ViewerPrs aPrs, thePresentations) { - if (!aPrs.object()) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object()); - std::shared_ptr aSketchFeature = std::dynamic_pointer_cast< - SketchPlugin_Feature>(aFeature); - if (!aSketchFeature || !aSketch->isSub(aSketchFeature)) - continue; - - double aDelta = aSketchFeature->distanceToPoint( - std::shared_ptr(new GeomAPI_Pnt2d(aX, anY))); - if (aMinDelta < 0 || aMinDelta > aDelta) { - aMinDelta = aDelta; - // TODO aDeltaObject = aPrs.result(); - } - } - } - // 2. if the object is not found, returns the first selected sketch feature - if (!aDeltaObject && thePresentations.size() > 0) { - // there can be some highlighted objects, e.g. a result of boolean operation and a sketch point - foreach (ModuleBase_ViewerPrs aPrs, thePresentations) { - if (!aPrs.object()) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object()); - if (aFeature && aSketch->isSub(aFeature)) - aDeltaObject = aPrs.object(); - } - } - return aDeltaObject; -} - std::shared_ptr PartSet_Tools::document() { return ModelAPI_Session::get()->moduleDocument(); @@ -518,14 +456,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap anEdge->setImpl(new TopoDS_Shape(theShape)); anAttr->setValue(aRes, anEdge); - if (!theTemporary) { + //if (!theTemporary) { aMyFeature->execute(); // fix this edge FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> setObject(aMyFeature->lastResult()); - } + //} return aMyFeature->lastResult(); } } @@ -545,14 +483,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap aVert->setImpl(new TopoDS_Shape(theShape)); anAttr->setValue(aRes, aVert); - if (theTemporary) { + //if (theTemporary) { aMyFeature->execute(); // fix this edge FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> setObject(aMyFeature->lastResult()); - } + //} return aMyFeature->lastResult(); } } @@ -714,8 +652,10 @@ std::shared_ptr PartSet_Tools::getPoint(std::shared_ptr anAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(theAttribute)); - if (anAttr) - aFeature = ModelAPI_Feature::feature(anAttr->object()); + if (!anAttr) + return std::shared_ptr(); + + aFeature = ModelAPI_Feature::feature(anAttr->object()); if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) aPointAttr = std::dynamic_pointer_cast( @@ -733,6 +673,7 @@ void PartSet_Tools::findCoincidences(FeaturePtr theStartCoin, QList& std::string theAttr) { AttributeRefAttrPtr aPnt = theStartCoin->refattr(theAttr); + if (!aPnt) return; FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object()); if (!theList.contains(aObj)) { std::shared_ptr aOrig = getPoint(theStartCoin, theAttr);