From ff0e5919a706ad9a61d5f4a5c3a4ca41fe7b9312 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 26 Jun 2017 13:00:59 +0300 Subject: [PATCH] Fix polygon linetype. --HG-- branch : feature --- src/libs/vdxf/dxiface.cpp | 19 +++++-------------- src/libs/vdxf/vdxfengine.cpp | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/libs/vdxf/dxiface.cpp b/src/libs/vdxf/dxiface.cpp index c5bc9cc6f..f55e774e5 100644 --- a/src/libs/vdxf/dxiface.cpp +++ b/src/libs/vdxf/dxiface.cpp @@ -174,15 +174,6 @@ void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits // Sets drawing units: 0 = English; 1 = Metric cData.headerC.addInt("$MEASUREMENT", static_cast(varMeasurement), 70); cData.headerC.addInt("$INSUNITS", static_cast(varInsunits), 70); - cData.headerC.addDouble("$DIMSCALE", 1.0, 40); - - // Official documentation says that initial value is 1.0, however LibreCAD has trouble if not set this value - // explicitly. - 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"); dateTime.chop(1);// we need hundredths of a second @@ -201,12 +192,12 @@ void dx_iface::InitLTypes() cData.lineTypes.push_back(ltype); ltype.path.clear(); - ltype.name = "DASHEDTINY"; - ltype.desc = "Dashed (.15x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _"; + ltype.name = "DASHED"; + ltype.desc = "Dashed _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _"; ltype.size = 2; - ltype.length = 2.8575; - ltype.path.push_back(1.905); - ltype.path.push_back(-0.9525); + ltype.length = 0.375; + ltype.path.push_back(0.25); + ltype.path.push_back(-0.125); cData.lineTypes.push_back(ltype); ltype.path.clear(); diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 499faa7d5..ea8e1db38 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -138,11 +138,14 @@ void VDxfEngine::drawPath(const QPainterPath &path) poly->color = getPenColor(); poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lineType = getPenStyle(); + if (polygon.size() > 1 && polygon.first() == polygon.last()) { - poly->flags = 1; // closed + poly->flags |= 0x1; // closed } + poly->flags |= 0x80; // plinegen + for (int i=0; i < polygon.count(); ++i) { poly->addVertex(DRW_Vertex2D(FromPixel(polygon.at(i).x(), varInsunits), @@ -160,9 +163,11 @@ void VDxfEngine::drawPath(const QPainterPath &path) poly->lineType = getPenStyle(); if (polygon.size() > 1 && polygon.first() == polygon.last()) { - poly->flags = 1; // closed + poly->flags |= 0x1; // closed } + poly->flags |= 0x80; // plinegen + for (int i=0; i < polygon.count(); ++i) { poly->addVertex(DRW_Vertex(FromPixel(polygon.at(i).x(), varInsunits), @@ -220,6 +225,13 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lineType = getPenStyle(); + if (pointCount > 1 && points[0] == points[pointCount]) + { + poly->flags |= 0x1; // closed + } + + poly->flags |= 0x80; // plinegen + for (int i = 0; i < pointCount; ++i) { const QPointF p = matrix.map(points[i]); @@ -237,6 +249,13 @@ void VDxfEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM poly->lWeight = DRW_LW_Conv::widthByLayer; poly->lineType = getPenStyle(); + if (pointCount > 1 && points[0] == points[pointCount]) + { + poly->flags |= 0x1; // closed + } + + poly->flags |= 0x80; // plinegen + for (int i = 0; i < pointCount; ++i) { const QPointF p = matrix.map(points[i]); @@ -423,7 +442,7 @@ std::string VDxfEngine::getPenStyle() switch (state->pen().style()) { case Qt::DashLine: - return "DASHEDTINY"; + return "DASHED"; case Qt::DotLine: return "DOT"; case Qt::DashDotLine: