diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index 432b816..6551ee5 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -377,22 +377,28 @@ void Constraint::DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db, } } -void Constraint::DrawOrGetDistance(Vector *labelPos) { - if(!SS.GW.showConstraints) return; +bool Constraint::IsVisible() const { + if(!SS.GW.showConstraints) return false; Group *g = SK.GetGroup(group); // If the group is hidden, then the constraints are hidden and not // able to be selected. - if(!(g->visible)) return; + if(!(g->visible)) return false; // And likewise if the group is not the active group; except for comments // with an assigned style. if(g->h.v != SS.GW.activeGroup.v && !(type == COMMENT && disp.style.v)) { - return; + return false; } if(disp.style.v) { Style *s = Style::Get(disp.style); - if(!s->visible) return; + if(!s->visible) return false; } + return true; +} +void Constraint::DrawOrGetDistance(Vector *labelPos) { + + if(!IsVisible()) return; + // Unit vectors that describe our current view of the scene. One pixel // long, not one actual unit. Vector gr = SS.GW.projRight.ScaledBy(1/SS.GW.scale); diff --git a/src/exportvector.cpp b/src/exportvector.cpp index 5401e37..d7e7a19 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -124,6 +124,7 @@ public: if(writer->constraint) { Constraint *c; for(c = writer->constraint->First(); c; c = writer->constraint->NextAfter(c)) { + if(!writer->NeedToOutput(c)) continue; switch(c->type) { case Constraint::PT_PT_DISTANCE: { Vector ap = SK.GetEntity(c->ptA)->PointGetNum(); @@ -469,6 +470,18 @@ void DxfFileWriter::FinishAndCloseFile(void) { constraint = NULL; } +bool DxfFileWriter::NeedToOutput(Constraint *c) { + switch(c->type) { + case Constraint::PT_PT_DISTANCE: + case Constraint::PT_LINE_DISTANCE: + case Constraint::DIAMETER: + case Constraint::ANGLE: + case Constraint::COMMENT: + return c->IsVisible(); + } + return false; +} + //----------------------------------------------------------------------------- // Routines for EPS output //----------------------------------------------------------------------------- diff --git a/src/sketch.h b/src/sketch.h index 144d7db..4a1ffcc 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -680,6 +680,7 @@ public: bool IsStylable(); void LineDrawOrGetDistance(Vector a, Vector b); + bool IsVisible() const; void DrawOrGetDistance(Vector *labelPos); double EllipticalInterpolation(double rx, double ry, double theta); std::string Label(void); diff --git a/src/solvespace.h b/src/solvespace.h index b1b034c..fbcc9b8 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -553,6 +553,7 @@ public: void StartFile(void); void FinishAndCloseFile(void); bool HasCanvasSize(void) { return false; } + bool NeedToOutput(Constraint *c); }; class EpsFileWriter : public VectorFileWriter { public: