-
- std::shared_ptr<GeomAPI_Pnt> anAnchor = SketcherPrs_Tools::getAnchorPoint(myConstraint, myPlane);
- //std::shared_ptr<GeomAPI_Pnt> anAnchor = aCircle.project(aFlyoutPnt);
- //std::shared_ptr<GeomAPI_XYZ> anAnchorXYZ = anAnchor->xyz();
- //anAnchorXYZ = anAnchorXYZ->decreased(aCenter->xyz());
- //std::shared_ptr<GeomAPI_Dir> aDeltaDir(new GeomAPI_Dir(anAnchorXYZ));
- //const double aDelta = 1e-3;
- //anAnchor->setX(anAnchor->x() + aDelta * aDeltaDir->x());
- //anAnchor->setY(anAnchor->y() + aDelta * aDeltaDir->y());
- //anAnchor->setZ(anAnchor->z() + aDelta * aDeltaDir->z());
-
- SetMeasuredGeometry(aCircle.impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
- SetCustomValue(aRadius);
-
- AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);
+ std::shared_ptr<GeomAPI_Pnt> anAnchor =
+ SketcherPrs_Tools::getAnchorPoint(theConstraint, thePlane);
+
+ theCircle = aCircle.impl<gp_Circ>();
+ theAnchorPoint = anAnchor->impl<gp_Pnt>();
+
+ aReadyToDisplay = theAnchorPoint.Distance(theCircle.Location()) > 1e-7;
+
+ return aReadyToDisplay;
+}
+
+void SketcherPrs_Radius::Compute(
+ const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ if (!plane().get())
+ return;
+ gp_Circ aCircle;
+ gp_Pnt anAnchorPoint;
+ bool aReadyToDisplay = readyToDisplay(myConstraint, plane(), aCircle, anAnchorPoint);
+ if (aReadyToDisplay) {
+ myCircle = aCircle;
+ myAnchorPoint = anAnchorPoint;
+
+ DataPtr aData = myConstraint->data();
+ AttributeDoublePtr anAttributeValue = aData->real(SketchPlugin_Constraint::VALUE());
+ myValue.init(anAttributeValue);
+ }
+
+ SetMeasuredGeometry(myCircle, myAnchorPoint);
+ myStyleListener->updateDimensions(this, myValue);
+
+ // Update variable aspect parameters (depending on viewer scale)
+ double aTextSize = 0.0;
+ GetValueString(aTextSize);
+
+ AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+ (myConstraint->data()->attribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
+ SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ?
+ (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC;
+ updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType);
+
+ PrsDim_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);
+
+ if (!aReadyToDisplay)
+ SketcherPrs_Tools::sendEmptyPresentationError(myConstraint,
+ "An empty AIS presentation: SketcherPrs_Radius");