#include <AIS_PerpendicularRelation.hxx>
#include <AIS_RadiusDimension.hxx>
#include <AIS_Shape.hxx>
+#include <AIS_FixRelation.hxx>
+
+const double tolerance = 1e-7;
const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint
const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance
{
double aFlyout = 0;
if (theFlyoutPoint) {
- boost::shared_ptr<GeomAPI_Lin> aLine = boost::shared_ptr<GeomAPI_Lin>(
- new GeomAPI_Lin(theStartPoint, theEndPoint));
- double aDist = aLine->distance(theFlyoutPoint);
+ double aDist = 0.0;
+ if (theStartPoint->distance(theEndPoint) < tolerance)
+ aDist = theStartPoint->distance(theFlyoutPoint);
+ else {
+ boost::shared_ptr<GeomAPI_Lin> aLine = boost::shared_ptr<GeomAPI_Lin>(
+ new GeomAPI_Lin(theStartPoint, theEndPoint));
+ aDist = aLine->distance(theFlyoutPoint);
+ }
boost::shared_ptr<GeomAPI_XYZ> aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz());
boost::shared_ptr<GeomAPI_XYZ> aFOutDir = theFlyoutPoint->xyz()->decreased(
anAspect->MakeText3d(false);
anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
anAspect->MakeTextShaded(false);
+ anAspect->ArrowAspect()->SetLength(theDistance / 10.);
aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
aDimAIS->SetDimensionAspect(anAspect);
aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE);
anAspect->MakeArrows3d(Standard_False);
anAspect->MakeText3d(false);
anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT);
+ anAspect->ArrowAspect()->SetLength(theRadius / 5.);
anAspect->MakeTextShaded(false);
aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false);
aDimAIS->SetDimensionAspect(anAspect);
}
}
+
+void GeomAPI_AISObject::createFixed(boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Pln> thePlane)
+{
+ Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
+ Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+ if (anAIS.IsNull()) {
+ Handle(AIS_FixRelation) aFixPrs =
+ new AIS_FixRelation(theShape->impl<TopoDS_Shape>(), aPlane);
+
+ setImpl(new Handle(AIS_InteractiveObject)(aFixPrs));
+ } else {
+ Handle(AIS_PerpendicularRelation) aFixPrs =
+ Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
+ if (!aFixPrs.IsNull()) {
+ aFixPrs->SetFirstShape(theShape->impl<TopoDS_Shape>());
+ aFixPrs->SetPlane(aPlane);
+ aFixPrs->Redisplay(Standard_True);
+ }
+ }
+}
+
+
+
void GeomAPI_AISObject::setColor(const int& theColor)
{
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();