Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ hConstraint Constraint::ConstrainCoincident(hEntity ptA, hEntity ptB) {
Entity::NO_ENTITY, Entity::NO_ENTITY, /*other=*/false, /*other2=*/false);
}

void Constraint::ConstrainArcLineTangent(Constraint *c, Entity *line, Entity *arc) {
bool Constraint::ConstrainArcLineTangent(Constraint *c, Entity *line, Entity *arc) {
Vector l0 = SK.GetEntity(line->point[0])->PointGetNum(),
l1 = SK.GetEntity(line->point[1])->PointGetNum();
Vector a1 = SK.GetEntity(arc->point[1])->PointGetNum(),
Expand All @@ -140,11 +140,12 @@ void Constraint::ConstrainArcLineTangent(Constraint *c, Entity *line, Entity *ar
Error(_("The tangent arc and line segment must share an "
"endpoint. Constrain them with Constrain -> "
"On Point before constraining tangent."));
return;
return false;
}
return true;
}

void Constraint::ConstrainCubicLineTangent(Constraint *c, Entity *line, Entity *cubic) {
bool Constraint::ConstrainCubicLineTangent(Constraint *c, Entity *line, Entity *cubic) {
Vector l0 = SK.GetEntity(line->point[0])->PointGetNum(),
l1 = SK.GetEntity(line->point[1])->PointGetNum();
Vector as = cubic->CubicGetStartNum(),
Expand All @@ -158,11 +159,12 @@ void Constraint::ConstrainCubicLineTangent(Constraint *c, Entity *line, Entity *
Error(_("The tangent cubic and line segment must share an "
"endpoint. Constrain them with Constrain -> "
"On Point before constraining tangent."));
return;
return false;
}
return true;
}

void Constraint::ConstrainCurveCurveTangent(Constraint *c, Entity *eA, Entity *eB) {
bool Constraint::ConstrainCurveCurveTangent(Constraint *c, Entity *eA, Entity *eB) {
Vector as = eA->EndpointStart(),
af = eA->EndpointFinish(),
bs = eB->EndpointStart(),
Expand All @@ -183,8 +185,9 @@ void Constraint::ConstrainCurveCurveTangent(Constraint *c, Entity *eA, Entity *e
Error(_("The curves must share an endpoint. Constrain them "
"with Constrain -> On Point before constraining "
"tangent."));
return;
return false;
}
return true;
}

void Constraint::MenuConstrain(Command id) {
Expand Down Expand Up @@ -690,7 +693,9 @@ void Constraint::MenuConstrain(Command id) {
if(line->type == Entity::Type::ARC_OF_CIRCLE) {
swap(line, arc);
}
ConstrainArcLineTangent(&c, line, arc);
if(!ConstrainArcLineTangent(&c, line, arc)) {
return;
}
c.type = Type::ARC_LINE_TANGENT;
c.entityA = arc->h;
c.entityB = line->h;
Expand All @@ -700,7 +705,9 @@ void Constraint::MenuConstrain(Command id) {
if(line->type == Entity::Type::CUBIC) {
swap(line, cubic);
}
ConstrainCubicLineTangent(&c, line, cubic);
if(!ConstrainCubicLineTangent(&c, line, cubic)) {
return;
}
c.type = Type::CUBIC_LINE_TANGENT;
c.entityA = cubic->h;
c.entityB = line->h;
Expand All @@ -711,7 +718,9 @@ void Constraint::MenuConstrain(Command id) {
}
Entity *eA = SK.GetEntity(gs.entity[0]),
*eB = SK.GetEntity(gs.entity[1]);
ConstrainCurveCurveTangent(&c, eA, eB);
if(!ConstrainCurveCurveTangent(&c, eA, eB)) {
return;
}
c.type = Type::CURVE_CURVE_TANGENT;
c.entityA = eA->h;
c.entityB = eB->h;
Expand Down
6 changes: 3 additions & 3 deletions src/sketch.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,9 @@ class Constraint : public ConstraintBase {
static hConstraint TryConstrain(Constraint::Type type, hEntity ptA, hEntity ptB,
hEntity entityA, hEntity entityB = Entity::NO_ENTITY,
bool other = false, bool other2 = false);
static void ConstrainArcLineTangent(Constraint *c, Entity *line, Entity *arc);
static void ConstrainCubicLineTangent(Constraint *c, Entity *line, Entity *cubic);
static void ConstrainCurveCurveTangent(Constraint *c, Entity *eA, Entity *eB);
static bool ConstrainArcLineTangent(Constraint *c, Entity *line, Entity *arc);
static bool ConstrainCubicLineTangent(Constraint *c, Entity *line, Entity *cubic);
static bool ConstrainCurveCurveTangent(Constraint *c, Entity *eA, Entity *eB);
};

class hEquation {
Expand Down