Fix polygon linetype.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-06-26 13:00:59 +03:00
parent 05d2873de7
commit ff0e5919a7
2 changed files with 27 additions and 17 deletions

View File

@ -174,15 +174,6 @@ void dx_iface::InitHeader(VarMeasurement varMeasurement, VarInsunits varInsunits
// Sets drawing units: 0 = English; 1 = Metric // Sets drawing units: 0 = English; 1 = Metric
cData.headerC.addInt("$MEASUREMENT", static_cast<int>(varMeasurement), 70); cData.headerC.addInt("$MEASUREMENT", static_cast<int>(varMeasurement), 70);
cData.headerC.addInt("$INSUNITS", static_cast<int>(varInsunits), 70); cData.headerC.addInt("$INSUNITS", static_cast<int>(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"); 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
@ -201,12 +192,12 @@ void dx_iface::InitLTypes()
cData.lineTypes.push_back(ltype); cData.lineTypes.push_back(ltype);
ltype.path.clear(); ltype.path.clear();
ltype.name = "DASHEDTINY"; ltype.name = "DASHED";
ltype.desc = "Dashed (.15x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _"; ltype.desc = "Dashed _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _";
ltype.size = 2; ltype.size = 2;
ltype.length = 2.8575; ltype.length = 0.375;
ltype.path.push_back(1.905); ltype.path.push_back(0.25);
ltype.path.push_back(-0.9525); ltype.path.push_back(-0.125);
cData.lineTypes.push_back(ltype); cData.lineTypes.push_back(ltype);
ltype.path.clear(); ltype.path.clear();

View File

@ -138,11 +138,14 @@ 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();
if (polygon.size() > 1 && polygon.first() == polygon.last()) 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) for (int i=0; i < polygon.count(); ++i)
{ {
poly->addVertex(DRW_Vertex2D(FromPixel(polygon.at(i).x(), varInsunits), poly->addVertex(DRW_Vertex2D(FromPixel(polygon.at(i).x(), varInsunits),
@ -160,9 +163,11 @@ void VDxfEngine::drawPath(const QPainterPath &path)
poly->lineType = getPenStyle(); poly->lineType = getPenStyle();
if (polygon.size() > 1 && polygon.first() == polygon.last()) 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) for (int i=0; i < polygon.count(); ++i)
{ {
poly->addVertex(DRW_Vertex(FromPixel(polygon.at(i).x(), varInsunits), 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->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = getPenStyle(); 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) for (int i = 0; i < pointCount; ++i)
{ {
const QPointF p = matrix.map(points[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->lWeight = DRW_LW_Conv::widthByLayer;
poly->lineType = getPenStyle(); 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) for (int i = 0; i < pointCount; ++i)
{ {
const QPointF p = matrix.map(points[i]); const QPointF p = matrix.map(points[i]);
@ -423,7 +442,7 @@ std::string VDxfEngine::getPenStyle()
switch (state->pen().style()) switch (state->pen().style())
{ {
case Qt::DashLine: case Qt::DashLine:
return "DASHEDTINY"; return "DASHED";
case Qt::DotLine: case Qt::DotLine:
return "DOT"; return "DOT";
case Qt::DashDotLine: case Qt::DashDotLine: