Correct line types.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-06-23 22:11:25 +03:00
parent 4c2c4ae7a2
commit d9353df43a
4 changed files with 58 additions and 40 deletions

View File

@ -180,6 +180,10 @@ void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits
// explicitly. // explicitly.
cData.headerC.addDouble("$DIMLFAC", 1.0, 40); cData.headerC.addDouble("$DIMLFAC", 1.0, 40);
cData.headerC.addDouble("$LTSCALE", 0.5, 40);
cData.headerC.addDouble("$PSLTSCALE", 1.0, 70);
cData.headerC.addInt("$PLINEGEN", 1, 70);
QString dateTime = QDateTime::currentDateTime().toString("yyyyMMdd.HHmmsszzz"); QString dateTime = QDateTime::currentDateTime().toString("yyyyMMdd.HHmmsszzz");
dateTime.chop(1);// we need hundredths of a second dateTime.chop(1);// we need hundredths of a second
cData.headerC.addStr("$TDCREATE", dateTime.toStdString(), 40); cData.headerC.addStr("$TDCREATE", dateTime.toStdString(), 40);
@ -187,29 +191,47 @@ void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits
void dx_iface::InitLTypes() void dx_iface::InitLTypes()
{ {
cData.lineTypes.push_back(DRW_LType("ACAD_ISO02W100", "ACAD_ISO02W100")); DRW_LType ltype;
cData.lineTypes.push_back(DRW_LType("ACAD_ISO02W100", "ACAD_ISO02W100")); ltype.name = "DOT";
cData.lineTypes.push_back(DRW_LType("ACAD_ISO03W100", "ACAD_ISO03W100")); ltype.desc = "Dot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .";
cData.lineTypes.push_back(DRW_LType("ACAD_ISO04W100", "ACAD_ISO04W100")); ltype.size = 2;
cData.lineTypes.push_back(DRW_LType("ACAD_ISO05W100", "ACAD_ISO05W100")); ltype.length = 0.125;
cData.lineTypes.push_back(DRW_LType("BORDER", "BORDER")); ltype.path.push_back(0.0);
cData.lineTypes.push_back(DRW_LType("BORDER2", "BORDER2")); ltype.path.push_back(-0.125);
cData.lineTypes.push_back(DRW_LType("BORDERX2", "BORDERX2")); cData.lineTypes.push_back(ltype);
cData.lineTypes.push_back(DRW_LType("CENTER", "CENTER"));
cData.lineTypes.push_back(DRW_LType("CENTER2", "CENTER2")); ltype.path.clear();
cData.lineTypes.push_back(DRW_LType("CENTERX2", "CENTERX2")); ltype.name = "DASHEDTINY";
cData.lineTypes.push_back(DRW_LType("DASHDOT", "DASHDOT")); ltype.desc = "Dashed (.15x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _";
cData.lineTypes.push_back(DRW_LType("DASHDOT2", "DASHDOT2")); ltype.size = 2;
cData.lineTypes.push_back(DRW_LType("DASHDOTX2", "DASHDOTX2")); ltype.length = 2.8575;
cData.lineTypes.push_back(DRW_LType("DASHED", "DASHED")); ltype.path.push_back(1.905);
cData.lineTypes.push_back(DRW_LType("DASHED2", "DASHED2")); ltype.path.push_back(-0.9525);
cData.lineTypes.push_back(DRW_LType("DASHEDX2", "DASHEDX2")); cData.lineTypes.push_back(ltype);
cData.lineTypes.push_back(DRW_LType("DIVIDE", "DIVIDE"));
cData.lineTypes.push_back(DRW_LType("DIVIDE2", "DIVIDE2")); ltype.path.clear();
cData.lineTypes.push_back(DRW_LType("DIVIDEX2", "DIVIDEX2")); ltype.name = "DASHDOT2";
cData.lineTypes.push_back(DRW_LType("DOT", "DOT")); ltype.desc = "Dash dot2 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.";
cData.lineTypes.push_back(DRW_LType("DOT2", "DOT2")); ltype.size = 4;
cData.lineTypes.push_back(DRW_LType("DOTX2", "DOTX2")); ltype.length = 0.5;
ltype.path.push_back(0.25);
ltype.path.push_back(-0.125);
ltype.path.push_back(0.0);
ltype.path.push_back(-0.125);
cData.lineTypes.push_back(ltype);
ltype.path.clear();
ltype.name = "DIVIDE2";
ltype.desc = "Divide2 __..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..";
ltype.size = 6;
ltype.length = 0.625;
ltype.path.push_back(0.25);
ltype.path.push_back(-0.125);
ltype.path.push_back(0.0);
ltype.path.push_back(-0.125);
ltype.path.push_back(0.0);
ltype.path.push_back(-0.125);
cData.lineTypes.push_back(ltype);
} }
void dx_iface::InitLayers() void dx_iface::InitLayers()

View File

@ -244,12 +244,6 @@ class DRW_LType : public DRW_TableEntry {
SETOBJFRIENDS SETOBJFRIENDS
public: public:
DRW_LType() { reset();} DRW_LType() { reset();}
DRW_LType(const UTF8STRING &name, const UTF8STRING &desc)
{
reset();
this->name = name;
this->desc = desc;
}
void reset(){ void reset(){
tType = DRW::LTYPE; tType = DRW::LTYPE;

View File

@ -808,12 +808,14 @@ bool dxfRW::writePolyline(DRW_Polyline *ent) {
writer->writeString(0, "VERTEX"); writer->writeString(0, "VERTEX");
writeEntity(ent); writeEntity(ent);
if (version > DRW::AC1009) if (version > DRW::AC1009)
{
writer->writeString(100, "AcDbVertex"); writer->writeString(100, "AcDbVertex");
if(is3d) { if(is3d) {
writer->writeString(100, "AcDb3dPolylineVertex"); writer->writeString(100, "AcDb3dPolylineVertex");
} else { } else {
writer->writeString(100, "AcDb2dVertex"); writer->writeString(100, "AcDb2dVertex");
} }
}
if ( (v->flags & 128) && !(v->flags & 64) ) { if ( (v->flags & 128) && !(v->flags & 64) ) {
writer->writeDouble(10, 0); writer->writeDouble(10, 0);
writer->writeDouble(20, 0); writer->writeDouble(20, 0);

View File

@ -138,7 +138,10 @@ void VDxfEngine::drawPath(const QPainterPath &path)
poly->color = getPenColor(); poly->color = getPenColor();
poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = getPenStyle(); poly->lineType = getPenStyle();
poly->ltypeScale = 1.0; if (polygon.size() > 1 && polygon.first() == polygon.last())
{
poly->flags = 1; // closed
}
for (int i=0; i < polygon.count(); ++i) for (int i=0; i < polygon.count(); ++i)
{ {
@ -155,7 +158,10 @@ void VDxfEngine::drawPath(const QPainterPath &path)
poly->color = getPenColor(); poly->color = getPenColor();
poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = getPenStyle(); poly->lineType = getPenStyle();
poly->ltypeScale = 1.0; if (polygon.size() > 1 && polygon.first() == polygon.last())
{
poly->flags = 1; // closed
}
for (int i=0; i < polygon.count(); ++i) for (int i=0; i < polygon.count(); ++i)
{ {
@ -185,7 +191,6 @@ void VDxfEngine::drawLines(const QLineF * lines, int lineCount)
line->color = getPenColor(); line->color = getPenColor();
line->lWeight = DRW_LW_Conv::widthByLayer; line->lWeight = DRW_LW_Conv::widthByLayer;
line->lineType = getPenStyle(); line->lineType = getPenStyle();
line->ltypeScale = 1.0;
input->AddEntity(line); input->AddEntity(line);
} }
@ -214,7 +219,6 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
poly->color = getPenColor(); poly->color = getPenColor();
poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = getPenStyle(); poly->lineType = getPenStyle();
poly->ltypeScale = 1.0;
for (int i = 0; i < pointCount; ++i) for (int i = 0; i < pointCount; ++i)
{ {
@ -232,7 +236,6 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
poly->color = getPenColor(); poly->color = getPenColor();
poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = getPenStyle(); poly->lineType = getPenStyle();
poly->ltypeScale = 1.0;
for (int i = 0; i < pointCount; ++i) for (int i = 0; i < pointCount; ++i)
{ {
@ -288,7 +291,6 @@ void VDxfEngine::drawEllipse(const QRectF & rect)
ellipse->color = getPenColor(); ellipse->color = getPenColor();
ellipse->lWeight = DRW_LW_Conv::widthByLayer; ellipse->lWeight = DRW_LW_Conv::widthByLayer;
ellipse->lineType = getPenStyle(); ellipse->lineType = getPenStyle();
ellipse->ltypeScale = 1.0;
input->AddEntity(ellipse); input->AddEntity(ellipse);
} }
@ -324,7 +326,6 @@ void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem)
text->color = getPenColor(); text->color = getPenColor();
text->lWeight = DRW_LW_Conv::widthByLayer; text->lWeight = DRW_LW_Conv::widthByLayer;
text->lineType = getPenStyle(); text->lineType = getPenStyle();
text->ltypeScale = 1.0;
input->AddEntity(text); input->AddEntity(text);
} }
@ -344,7 +345,6 @@ void VDxfEngine::drawTextItem(const QPointF & p, const QTextItem & textItem)
text->color = getPenColor(); text->color = getPenColor();
text->lWeight = DRW_LW_Conv::widthByLayer; text->lWeight = DRW_LW_Conv::widthByLayer;
text->lineType = getPenStyle(); text->lineType = getPenStyle();
text->ltypeScale = 1.0;
input->AddEntity(text); input->AddEntity(text);
} }
@ -423,13 +423,13 @@ std::string VDxfEngine::getPenStyle()
switch (state->pen().style()) switch (state->pen().style())
{ {
case Qt::DashLine: case Qt::DashLine:
return "DASHED"; return "DASHEDTINY";
case Qt::DotLine: case Qt::DotLine:
return "DOT"; return "DOT";
case Qt::DashDotLine: case Qt::DashDotLine:
return "DASHDOT"; return "DASHDOT2";
case Qt::DashDotDotLine: case Qt::DashDotDotLine:
return "DIVIDE"; return "DIVIDE2";
case Qt::SolidLine: case Qt::SolidLine:
default: default:
return "BYLAYER"; return "BYLAYER";