DXF - Add some color

This commit is contained in:
David Varley
2020-09-22 19:41:47 +10:00
parent bcc5846662
commit 2d6bef71ae
3 changed files with 30 additions and 24 deletions

View File

@@ -437,9 +437,11 @@ int Createdxf::getcolorCode (const long red, const long green, const long blue)
}
return minndx;
}
int Createdxf::dxfColor(QColor color) {
return Createdxf::getcolorCode(color.red(), color.green(), color.blue());
}
int Createdxf::dxfColor(QPen pen) {
return Createdxf::dxfColor(pen.color());
}
@@ -984,7 +986,13 @@ void Createdxf::drawPolygon(
const QPolygonF &poly,
const int &colorcode)
{
drawPolyline(filepath,poly,colorcode);
qDebug() << "PolygonIsClosed: " << poly.isClosed();
QPolygonF pg = poly;
if(!poly.isClosed()) {
pg << poly.at(0);
}
qDebug() << "PolygonIsClosed: " << poly.isClosed();
drawPolyline(filepath,pg,colorcode);
}
/**

View File

@@ -660,7 +660,7 @@ void ExportDialog::generateDxf(
qreal offset = fontSize * 1.6;
foreach (QString line, lines) {
if (line.size() > 0 && line != "_" )
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, 0, 0.72 );
Createdxf::drawText(file_path, line, QPointF(x, y), fontSize, 360-angle, Createdxf::dxfColor(dti->color()), 0.72 );
x += offset * xdir;
y -= offset * ydir;
}

View File

@@ -966,29 +966,27 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
{
case Line:
Createdxf::drawLine(filepath,
QLineF(mapToScene(m_P1),
QLineF( mapToScene(m_P1),
mapToScene(m_P2)),
Createdxf::getcolorCode(pen.color().red(),
pen.color().green(),
pen.color().blue()));
Createdxf::dxfColor(pen));
return true;
case Rectangle:
Createdxf::drawRectangle(filepath,
QRectF(mapToScene(m_P1),
mapToScene(m_P2)).normalized(),
Createdxf::getcolorCode(pen.color().red(),
pen.color().green(),
pen.color().blue()));
Createdxf::dxfColor(pen));
return true;
case Ellipse:
Createdxf::drawEllipse (filepath,
Createdxf::drawEllipse(filepath,
QRectF(mapToScene(m_P1),
mapToScene(m_P2)).normalized(),
Createdxf::getcolorCode(pen.color().red(),
pen.color().green(),
pen.color().blue()));
Createdxf::dxfColor(pen));
return true;
default: return false;
case Polygon:
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
return true;
default:
return false;
}
}