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,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);

View File

@ -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
//-----------------------------------------------------------------------------

View File

@ -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);

View File

@ -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: