X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_Radius.cpp;h=0846607545204f88e73403d9734f3b077025f423;hb=a5746a7f8fd8bcd555fb16f98e312c86ca1210da;hp=a99bdc9af57f216d671dce5f1b115dd99cd3a9b9;hpb=a8ed41e2ed5a9528335f0a5d1a2203f35048620e;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_Radius.cpp b/src/SketcherPrs/SketcherPrs_Radius.cpp index a99bdc9af..084660754 100644 --- a/src/SketcherPrs/SketcherPrs_Radius.cpp +++ b/src/SketcherPrs/SketcherPrs_Radius.cpp @@ -18,6 +18,8 @@ #include #include +#include + static const gp_Circ MyDefCirc(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), 1); IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Radius, AIS_RadiusDimension); @@ -27,6 +29,7 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane) : AIS_RadiusDimension(MyDefCirc), myConstraint(theConstraint), myPlane(thePlane) { + // Set default values of the presentation myAspect = new Prs3d_DimensionAspect(); myAspect->MakeArrows3d(false); myAspect->MakeText3d(false); @@ -39,7 +42,6 @@ SketcherPrs_Radius::SketcherPrs_Radius(ModelAPI_Feature* theConstraint, SetSelToleranceForText2d(SketcherPrs_Tools::getDefaultTextHeight()); } - void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) @@ -62,6 +64,10 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the std::shared_ptr aCyrcFeature = ModelAPI_Feature::feature(anAttr->object()); double aRadius = 1; std::shared_ptr aCenterAttr; + // it is possible that circle result becomes zero, in this case the presentation should disappear + // for example, it happens when circle radius is set to zero + if (!aCyrcFeature) + return; if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle aCenterAttr = std::dynamic_pointer_cast( aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); @@ -78,21 +84,33 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt()); } std::shared_ptr aCenter = myPlane->to3D(aCenterAttr->x(), aCenterAttr->y()); - std::shared_ptr aNormal = myPlane->norm(); + std::shared_ptr aNormal = myPlane->normal(); GeomAPI_Circ aCircle(aCenter, aNormal, aRadius); std::shared_ptr anAnchor = SketcherPrs_Tools::getAnchorPoint(myConstraint, myPlane); - SetMeasuredGeometry(aCircle.impl(), anAnchor->impl()); + gp_Circ aCirc = aCircle.impl(); + gp_Pnt anAncorPnt = anAnchor->impl(); + // anchor point should not coincide to the location point of the circle + // OCCT does not process this case. + if (anAncorPnt.Distance(aCirc.Location()) < 1e-7) + return; + SetMeasuredGeometry(aCirc, anAncorPnt); SetCustomValue(aRadius); + myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length()); + myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length()); + // The value of vertical aligment is sometimes changed + myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER); + AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode); } void SketcherPrs_Radius::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer theMode) { + // Map the application selection modes to standard ones Standard_Integer aMode; switch (theMode) { case 0: // we should use selection of all objects