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