DXF: export freehand and zigzag lines as continuous, with a message.
Previously, this resulted in a crash even with no such lines present.pull/19/head
parent
131acc5e56
commit
da1fc3fd70
|
@ -138,9 +138,12 @@ public:
|
||||||
// Routines for DXF export
|
// Routines for DXF export
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
class DxfWriteInterface : public DRW_Interface {
|
class DxfWriteInterface : public DRW_Interface {
|
||||||
|
public:
|
||||||
DxfFileWriter *writer;
|
DxfFileWriter *writer;
|
||||||
dxfRW *dxf;
|
dxfRW *dxf;
|
||||||
|
|
||||||
|
std::set<std::string> messages;
|
||||||
|
|
||||||
static DRW_Coord toCoord(const Vector &v) {
|
static DRW_Coord toCoord(const Vector &v) {
|
||||||
return DRW_Coord(v.x, v.y, v.z);
|
return DRW_Coord(v.x, v.y, v.z);
|
||||||
}
|
}
|
||||||
|
@ -149,10 +152,6 @@ class DxfWriteInterface : public DRW_Interface {
|
||||||
return writer->Transform(v);
|
return writer->Transform(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
DxfWriteInterface(DxfFileWriter *w, dxfRW *dxfrw) :
|
|
||||||
writer(w), dxf(dxfrw) {}
|
|
||||||
|
|
||||||
void writeTextstyles() override {
|
void writeTextstyles() override {
|
||||||
DRW_Textstyle ts;
|
DRW_Textstyle ts;
|
||||||
ts.name = "unicode";
|
ts.name = "unicode";
|
||||||
|
@ -238,7 +237,8 @@ public:
|
||||||
|
|
||||||
case StipplePattern::FREEHAND:
|
case StipplePattern::FREEHAND:
|
||||||
case StipplePattern::ZIGZAG:
|
case StipplePattern::ZIGZAG:
|
||||||
ssassert(false, "Freehand and zigzag export not implemented");
|
// Not implemented; exported as continuous.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
dxf->writeLineType(&type);
|
dxf->writeLineType(&type);
|
||||||
}
|
}
|
||||||
|
@ -462,6 +462,12 @@ public:
|
||||||
entity->lineType = DxfFileWriter::lineTypeName(s->stippleType);
|
entity->lineType = DxfFileWriter::lineTypeName(s->stippleType);
|
||||||
entity->ltypeScale = Style::StippleScaleMm(s->h);
|
entity->ltypeScale = Style::StippleScaleMm(s->h);
|
||||||
entity->setWidthMm(Style::WidthMm(hs.v));
|
entity->setWidthMm(Style::WidthMm(hs.v));
|
||||||
|
|
||||||
|
if(s->stippleType == StipplePattern::FREEHAND) {
|
||||||
|
messages.insert("freehand lines were replaced with continuous lines");
|
||||||
|
} else if(s->stippleType == StipplePattern::ZIGZAG) {
|
||||||
|
messages.insert("zigzag lines were replaced with continuous lines");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assignDimensionDefaults(DRW_Dimension *dimension, hStyle hs) {
|
void assignDimensionDefaults(DRW_Dimension *dimension, hStyle hs) {
|
||||||
|
@ -696,10 +702,21 @@ void DxfFileWriter::Bezier(SBezier *sb) {
|
||||||
|
|
||||||
void DxfFileWriter::FinishAndCloseFile() {
|
void DxfFileWriter::FinishAndCloseFile() {
|
||||||
dxfRW dxf(filename.c_str());
|
dxfRW dxf(filename.c_str());
|
||||||
DxfWriteInterface interface(this, &dxf);
|
DxfWriteInterface interface = {};
|
||||||
|
interface.writer = this;
|
||||||
|
interface.dxf = &dxf;
|
||||||
dxf.write(&interface, DRW::AC1021, /*bin=*/false);
|
dxf.write(&interface, DRW::AC1021, /*bin=*/false);
|
||||||
paths.clear();
|
paths.clear();
|
||||||
constraint = NULL;
|
constraint = NULL;
|
||||||
|
|
||||||
|
if(!interface.messages.empty()) {
|
||||||
|
std::string text = "Some aspects of the drawing have no DXF equivalent and "
|
||||||
|
"were not exported:\n";
|
||||||
|
for(const std::string &message : interface.messages) {
|
||||||
|
text += " * " + message + "\n";
|
||||||
|
}
|
||||||
|
Message(text.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DxfFileWriter::NeedToOutput(Constraint *c) {
|
bool DxfFileWriter::NeedToOutput(Constraint *c) {
|
||||||
|
@ -726,11 +743,12 @@ const char *DxfFileWriter::lineTypeName(StipplePattern stippleType) {
|
||||||
case StipplePattern::DASH_DOT: return "DASHDOT";
|
case StipplePattern::DASH_DOT: return "DASHDOT";
|
||||||
case StipplePattern::DASH_DOT_DOT: return "DIVIDE";
|
case StipplePattern::DASH_DOT_DOT: return "DIVIDE";
|
||||||
case StipplePattern::DOT: return "DOT";
|
case StipplePattern::DOT: return "DOT";
|
||||||
case StipplePattern::FREEHAND: return "CONTINUOUS";
|
|
||||||
case StipplePattern::ZIGZAG: return "CONTINUOUS";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
case StipplePattern::FREEHAND:
|
||||||
|
case StipplePattern::ZIGZAG:
|
||||||
|
/* no corresponding DXF line type */
|
||||||
return "CONTINUOUS";
|
return "CONTINUOUS";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue