#include <SketchSolver_Manager.h>
#include <PlaneGCSSolver_EdgeWrapper.h>
+#include <PlaneGCSSolver_PointArrayWrapper.h>
#include <PlaneGCSSolver_PointWrapper.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Ellipse.h>
+#include <SketchPlugin_EllipticArc.h>
#include <SketchPlugin_Line.h>
#include <SketchPlugin_Point.h>
{
}
-SketchSolver_ConstraintMovement::SketchSolver_ConstraintMovement(AttributePtr thePoint)
+SketchSolver_ConstraintMovement::SketchSolver_ConstraintMovement(AttributePtr theAttribute,
+ const int thePointIndex)
: SketchSolver_ConstraintFixed(ConstraintPtr()),
- myDraggedPoint(thePoint),
+ myDraggedAttribute(theAttribute),
+ myDraggedPointIndex(thePointIndex),
mySimpleMove(true)
{
- myMovedFeature = ModelAPI_Feature::feature(thePoint->owner());
+ myMovedFeature = ModelAPI_Feature::feature(theAttribute->owner());
}
void SketchSolver_ConstraintMovement::blockEvents(bool isBlocked)
if (theMovedFeature->getKind() == SketchPlugin_Circle::ID() ||
theMovedFeature->getKind() == SketchPlugin_Ellipse::ID())
isSimple = (theDraggedPoint.get() != 0);
- else if (theMovedFeature->getKind() == SketchPlugin_Arc::ID()) {
+ else if (theMovedFeature->getKind() == SketchPlugin_Arc::ID() ||
+ theMovedFeature->getKind() == SketchPlugin_EllipticArc::ID()) {
isSimple = (theDraggedPoint.get() != 0 &&
- theDraggedPoint->id() == SketchPlugin_Arc::CENTER_ID());
+ (theDraggedPoint->id() == SketchPlugin_Arc::CENTER_ID() ||
+ theDraggedPoint->id() == SketchPlugin_EllipticArc::CENTER_ID()));
}
#endif
return isSimple;
return aConstraint;
}
- EntityWrapperPtr anEntity =
- myDraggedPoint ? myStorage->entity(myDraggedPoint) : myStorage->entity(myMovedFeature);
+ EntityWrapperPtr anEntity = myDraggedAttribute ? myStorage->entity(myDraggedAttribute)
+ : myStorage->entity(myMovedFeature);
if (!anEntity) {
myStorage->update(myMovedFeature, true);
- anEntity =
- myDraggedPoint ? myStorage->entity(myDraggedPoint) : myStorage->entity(myMovedFeature);
+ anEntity = myDraggedAttribute ? myStorage->entity(myDraggedAttribute)
+ : myStorage->entity(myMovedFeature);
if (!anEntity)
return aConstraint;
}
- mySimpleMove = isSimpleMove(myMovedFeature, myDraggedPoint);
+ mySimpleMove = isSimpleMove(myMovedFeature, myDraggedAttribute);
- if (mySimpleMove)
+ if (mySimpleMove) {
+ if (anEntity->type() == ENTITY_POINT_ARRAY) {
+ anEntity = std::dynamic_pointer_cast<PlaneGCSSolver_PointArrayWrapper>(anEntity)
+ ->value(myDraggedPointIndex);
+ }
aConstraint = fixFeature(anEntity);
+ }
else {
- if (myDraggedPoint) // start or end point of arc has been moved
+ if (myDraggedAttribute) // start or end point of arc has been moved
aConstraint = fixArcExtremity(anEntity);
else if (anEntity->type() == ENTITY_CIRCLE || anEntity->type() == ENTITY_ARC) {
// arc or circle has been moved
aConstraint = fixPointOnCircle(anEntity);
}
- else if (anEntity->type() == ENTITY_ELLIPSE || anEntity->type() == ENTITY_ELLIPTICAL_ARC) {
- // ellipse or elliptical arc has been moved
+ else if (anEntity->type() == ENTITY_ELLIPSE || anEntity->type() == ENTITY_ELLIPTIC_ARC) {
+ // ellipse or elliptic arc has been moved
aConstraint = fixPointOnEllipse(anEntity);
}
}
myStorage->entity(myMovedFeature));
std::shared_ptr<GCS::Arc> anArc =
std::dynamic_pointer_cast<GCS::Arc>(aCircularEntity->entity());
+ std::shared_ptr<GCS::ArcOfEllipse> anEllArc =
+ std::dynamic_pointer_cast<GCS::ArcOfEllipse>(aCircularEntity->entity());
PointWrapperPtr aPoint =
std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theArcExtremity);
- double* aParams[nbParams] = { aPoint->point()->x, aPoint->point()->y,
- anArc->center.x, anArc->center.y };
+ double* aParams[nbParams] = { aPoint->point()->x, aPoint->point()->y, 0, 0 };
+ if (anArc) {
+ aParams[2] = anArc->center.x;
+ aParams[3] = anArc->center.y;
+ }
+ else if (anEllArc) {
+ aParams[2] = anEllArc->center.x;
+ aParams[3] = anEllArc->center.y;
+ }
std::list<GCSConstraintPtr> aConstraints;
for (int i = 0; i < nbParams; ++i) {
#ifdef CHANGE_RADIUS_WHILE_MOVE
int aMaxSize = mySimpleMove ? (int)myFixedValues.size() : 2;
#else
- int aMaxSize = myMovedFeature->getKind() == SketchPlugin_Line::ID() && !myDraggedPoint ? 4 : 2;
+ int aMaxSize =
+ myMovedFeature->getKind() == SketchPlugin_Line::ID() && !myDraggedAttribute ? 4 : 2;
#endif
for (int i = 0; i < aMaxSize; ++i)
myFixedValues[i] += aDelta[i % 2];