AttributePoint2DPtr aCoord = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
anApex->attribute(SketchPlugin_Point::COORD_ID()));
aCoord->setValue(theCoordinates);
+ anApex->boolean(SketchPlugin_Point::AUXILIARY_ID())->setValue(true);
// additional coincidence constraints
static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
AttributePoint2DPtr aFlyoutAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aLength->attribute(SketchPlugin_ConstraintLength::FLYOUT_VALUE_PNT()));
if (aFlyoutAttr && aFlyoutAttr->isInitialized())
- aNewLength.myFlyoutPoint = aFlyoutAttr->pnt();
+ aNewLength.myFlyoutPoint = SketchPlugin_Tools::flyoutPointCoordinates(aLength);
AttributeIntegerPtr aLocationAttr =
aLength->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID());
if (aLocationAttr && aLocationAttr->isInitialized())
#include "SketchPlugin_Tools.h"
#include "SketchPlugin_ConstraintCoincidence.h"
+#include "SketchPlugin_ConstraintLength.h"
#include "SketchPlugin_ConstraintTangent.h"
+#include "SketchPlugin_Line.h"
#include "SketchPlugin_Point.h"
#include "SketchPlugin_SketchEntity.h"
#include <ModelAPI_AttributeDouble.h>
+#include <GeomAPI_Dir2d.h>
+#include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_XY.h>
+
#include <GeomDataAPI_Point.h>
#include <GeomDataAPI_Point2D.h>
return aConstraint;
}
+GeomPnt2dPtr flyoutPointCoordinates(const ConstraintPtr& theConstraint)
+{
+ // currently process Length constraints only
+ if (theConstraint->getKind() != SketchPlugin_ConstraintLength::ID())
+ return GeomPnt2dPtr();
+
+ AttributeRefAttrPtr aLineAttr = theConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
+ if (!aLineAttr || !aLineAttr->isObject())
+ return GeomPnt2dPtr();
+ FeaturePtr aLine = ModelAPI_Feature::feature(aLineAttr->object());
+ if (!aLine || aLine->getKind() != SketchPlugin_Line::ID())
+ return GeomPnt2dPtr();
+
+ std::shared_ptr<GeomAPI_XY> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aLine->attribute(SketchPlugin_Line::START_ID()))->pnt()->xy();
+ std::shared_ptr<GeomAPI_XY> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aLine->attribute(SketchPlugin_Line::END_ID()))->pnt()->xy();
+
+ std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ theConstraint->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ std::shared_ptr<GeomAPI_Pnt2d> aFltPnt = aFlyoutAttr->pnt();
+
+ std::shared_ptr<GeomAPI_Dir2d> aLineDir(new GeomAPI_Dir2d(aEndPnt->decreased(aStartPnt)));
+
+ double X = aStartPnt->x() + aFltPnt->x() * aLineDir->x() - aFltPnt->y() * aLineDir->y();
+ double Y = aStartPnt->y() + aFltPnt->x() * aLineDir->y() + aFltPnt->y() * aLineDir->x();
+
+ return GeomPnt2dPtr(new GeomAPI_Pnt2d(X, Y));
+}
+
} // namespace SketchPlugin_Tools
#include <ModelAPI_AttributeRefAttr.h>
#include <GeomDataAPI_Point2D.h>
+class SketchPlugin_Constraint;
class SketchPlugin_Feature;
class SketchPlugin_Sketch;
const AttributePtr& theDefaultAttr,
std::shared_ptr<GeomAPI_Shape>& theTangentCurve,
std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
+
+
+/// Calculate global coordinates for flyout point of Length constraint
+GeomPnt2dPtr flyoutPointCoordinates(const std::shared_ptr<SketchPlugin_Constraint>& theConstraint);
}; // namespace SketchPlugin_Tools
#endif // SKETCHPLUGIN_TOOLS_H_
\ No newline at end of file