mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Fix dxf export of autosize text cells in titleblock
This commit is contained in:
@@ -673,7 +673,8 @@ void BorderTitleBlock::drawDxf(
|
||||
1,
|
||||
2,
|
||||
xCoord+recWidth/2,
|
||||
color,
|
||||
1,
|
||||
color,
|
||||
0);
|
||||
}else{
|
||||
Createdxf::drawTextAligned(file_path,
|
||||
@@ -686,7 +687,8 @@ void BorderTitleBlock::drawDxf(
|
||||
1,
|
||||
2,
|
||||
xCoord+recWidth/2,
|
||||
color,
|
||||
1,
|
||||
color,
|
||||
0);
|
||||
}
|
||||
}
|
||||
@@ -721,7 +723,8 @@ void BorderTitleBlock::drawDxf(
|
||||
1,
|
||||
2,
|
||||
xCoord+recWidth/2,
|
||||
color,
|
||||
1,
|
||||
color,
|
||||
0);
|
||||
row_string = incrementLetters(row_string);
|
||||
}
|
||||
|
||||
@@ -744,7 +744,7 @@ void Createdxf::drawText(const QString& fileName, const QString& text,double x,
|
||||
/* draw aligned text in DXF Format */
|
||||
// leftAlign flag added. If the alignment requested is 'fit to width' and the text length is very small,
|
||||
// then the text is either centered or left-aligned, depnding on the value of leftAlign.
|
||||
void Createdxf::drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign,int colour,
|
||||
void Createdxf::drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, double xScale, int colour,
|
||||
bool leftAlign, float scale)
|
||||
{
|
||||
Q_UNUSED(scale);
|
||||
@@ -774,6 +774,8 @@ void Createdxf::drawTextAligned(const QString& fileName, const QString& text,dou
|
||||
To_Dxf << 0.0 << "\r\n"; // Z in UCS (User Coordinate System)coordinates
|
||||
To_Dxf << 40 << "\r\n";
|
||||
To_Dxf << height << "\r\n"; // Text Height
|
||||
To_Dxf << 41 << "\r\n";
|
||||
To_Dxf << xScale << "\r\n"; // X Scale
|
||||
To_Dxf << 1 << "\r\n";
|
||||
To_Dxf << text << "\r\n"; // Text Value
|
||||
To_Dxf << 50 << "\r\n";
|
||||
|
||||
@@ -46,7 +46,7 @@ class Createdxf
|
||||
static void drawLine(const QString &filepath, const QLineF &line,const int &colorcode);
|
||||
|
||||
static void drawText(const QString&,const QString&,double,double,double,double,int);
|
||||
static void drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, int colour, bool leftAlign = false, float scale = 0);
|
||||
static void drawTextAligned(const QString& fileName, const QString& text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, double xScale, int colour, bool leftAlign = false, float scale = 0);
|
||||
|
||||
|
||||
static int getcolorCode (const long red, const long green, const long blue);
|
||||
|
||||
@@ -1833,29 +1833,20 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
||||
x2 = x;
|
||||
} else if ( cell.alignment & Qt::AlignBottom ) {}
|
||||
|
||||
|
||||
//painter.setFont(text_font);
|
||||
|
||||
qreal ratio = 1.0;
|
||||
if (cell.hadjust) {
|
||||
QFontMetricsF font_metrics(text_font);
|
||||
QRectF font_rect = font_metrics.boundingRect(
|
||||
QRect(-10000, -10000, 10000, 10000),
|
||||
cell.alignment,
|
||||
text);
|
||||
|
||||
if (font_rect.width()*Createdxf::xScale > w) {
|
||||
qreal ratio = qreal(w)
|
||||
/ qreal(font_rect.width()
|
||||
*Createdxf::xScale);
|
||||
textHeight *= ratio;
|
||||
// Scale font width to fit string in cell width w
|
||||
QFontMetricsF font_metrics(text_font);
|
||||
qreal textw = font_metrics.width(text)*Createdxf::xScale;
|
||||
if (textw > w) {
|
||||
ratio = (w / textw) * 0.8; // Allow some space around text in cell
|
||||
}
|
||||
}
|
||||
//TODO DAV 16AUG2020 - x & y offset values bellow (5 & 3) set heuristically for now, as are not exactly Diagram::margin = 5
|
||||
// fix when have a chance to work through the preceding scaling logic!
|
||||
// Also add/fix autosizing font to fit in cell
|
||||
// x & y offset values below (1 & 3) currently set heuristically based on appearance...
|
||||
Createdxf::drawTextAligned(file_path,
|
||||
text,
|
||||
x - 5*Createdxf::xScale,
|
||||
x - 1*Createdxf::xScale,
|
||||
y - 3*Createdxf::yScale,
|
||||
textHeight*Createdxf::yScale,
|
||||
0,
|
||||
@@ -1863,6 +1854,7 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
||||
hAlign,
|
||||
vAlign,
|
||||
x2,
|
||||
ratio,
|
||||
color,
|
||||
0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user