DXF: only export visible constraints.

pull/4/head
EvilSpirit 2016-03-24 19:55:36 +06:00 committed by whitequark
parent 73f28b9731
commit e17a24814b
4 changed files with 26 additions and 5 deletions

View File

@ -377,21 +377,27 @@ void Constraint::DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db,
} }
} }
void Constraint::DrawOrGetDistance(Vector *labelPos) { bool Constraint::IsVisible() const {
if(!SS.GW.showConstraints) return; if(!SS.GW.showConstraints) return false;
Group *g = SK.GetGroup(group); Group *g = SK.GetGroup(group);
// If the group is hidden, then the constraints are hidden and not // If the group is hidden, then the constraints are hidden and not
// able to be selected. // 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 // And likewise if the group is not the active group; except for comments
// with an assigned style. // with an assigned style.
if(g->h.v != SS.GW.activeGroup.v && !(type == COMMENT && disp.style.v)) { if(g->h.v != SS.GW.activeGroup.v && !(type == COMMENT && disp.style.v)) {
return; return false;
} }
if(disp.style.v) { if(disp.style.v) {
Style *s = Style::Get(disp.style); 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 // Unit vectors that describe our current view of the scene. One pixel
// long, not one actual unit. // long, not one actual unit.

View File

@ -124,6 +124,7 @@ public:
if(writer->constraint) { if(writer->constraint) {
Constraint *c; Constraint *c;
for(c = writer->constraint->First(); c; c = writer->constraint->NextAfter(c)) { for(c = writer->constraint->First(); c; c = writer->constraint->NextAfter(c)) {
if(!writer->NeedToOutput(c)) continue;
switch(c->type) { switch(c->type) {
case Constraint::PT_PT_DISTANCE: { case Constraint::PT_PT_DISTANCE: {
Vector ap = SK.GetEntity(c->ptA)->PointGetNum(); Vector ap = SK.GetEntity(c->ptA)->PointGetNum();
@ -469,6 +470,18 @@ void DxfFileWriter::FinishAndCloseFile(void) {
constraint = NULL; 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 // Routines for EPS output
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -680,6 +680,7 @@ public:
bool IsStylable(); bool IsStylable();
void LineDrawOrGetDistance(Vector a, Vector b); void LineDrawOrGetDistance(Vector a, Vector b);
bool IsVisible() const;
void DrawOrGetDistance(Vector *labelPos); void DrawOrGetDistance(Vector *labelPos);
double EllipticalInterpolation(double rx, double ry, double theta); double EllipticalInterpolation(double rx, double ry, double theta);
std::string Label(void); std::string Label(void);

View File

@ -553,6 +553,7 @@ public:
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return false; } bool HasCanvasSize(void) { return false; }
bool NeedToOutput(Constraint *c);
}; };
class EpsFileWriter : public VectorFileWriter { class EpsFileWriter : public VectorFileWriter {
public: public: