mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Fix some DXF issues
This commit is contained in:
parent
ec464282f3
commit
71d7f8bbe6
@ -651,6 +651,7 @@ void BorderTitleBlock::drawDxf(
|
||||
// dessine la numerotation des colonnes
|
||||
if (display_border_ &&
|
||||
display_columns_) {
|
||||
int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
|
||||
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
||||
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
||||
(rows_header_width_ + ((i - 1) *
|
||||
@ -662,11 +663,11 @@ void BorderTitleBlock::drawDxf(
|
||||
double recHeight = columns_header_height_;
|
||||
Createdxf::drawRectangle(file_path, xCoord, yCoord,
|
||||
recWidth, recHeight, color);
|
||||
if (settings.value("border-columns_0", true).toBool()){
|
||||
|
||||
Createdxf::drawTextAligned(file_path,
|
||||
QString::number(i - 1),
|
||||
QString::number(i - offset),
|
||||
xCoord+recWidth/4,
|
||||
yCoord + recHeight*0.2,
|
||||
yCoord + recHeight*0.5,
|
||||
recHeight*0.7,
|
||||
0,
|
||||
0,
|
||||
@ -676,22 +677,7 @@ void BorderTitleBlock::drawDxf(
|
||||
1,
|
||||
color,
|
||||
0);
|
||||
}else{
|
||||
Createdxf::drawTextAligned(file_path,
|
||||
QString::number(i),
|
||||
xCoord+recWidth/4,
|
||||
yCoord + recHeight*0.2,
|
||||
recHeight*0.7,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
xCoord+recWidth/2,
|
||||
1,
|
||||
color,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw line numbering
|
||||
|
@ -826,18 +826,23 @@ void Createdxf::drawTextAligned(const QString& fileName,
|
||||
To_Dxf << text << "\r\n"; // Text Value
|
||||
To_Dxf << 50 << "\r\n";
|
||||
To_Dxf << rotation << "\r\n"; // Text Rotation
|
||||
// If "Fit to width", then check if width of text < width specified then change it "center align or left align"
|
||||
#if 0
|
||||
// If "Fit to width", then check if width of text < width specified then change it "center align or left align"
|
||||
if (hAlign == 5) {
|
||||
int xDiff = xAlign - x;
|
||||
int len = text.length();
|
||||
int t = xDiff/height;
|
||||
if (text.length() < xDiff/height && !leftAlign) {
|
||||
hAlign = 1;
|
||||
xAlign = (x+xAlign) / 2;
|
||||
xAlign = x+ (xAlign / 2);
|
||||
} else if (text.length() < xDiff/height && leftAlign) {
|
||||
file.close();
|
||||
return;
|
||||
hAlign = 0;
|
||||
xAlign = x;
|
||||
// file.close();
|
||||
// return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
To_Dxf << 51 << "\r\n";
|
||||
To_Dxf << oblique << "\r\n"; // Text Obliqueness
|
||||
To_Dxf << 72 << "\r\n";
|
||||
|
@ -1804,50 +1804,53 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
||||
textHeight = text_font.pixelSize();
|
||||
|
||||
qreal x2 = x + w;
|
||||
qreal y1 = y;
|
||||
|
||||
int vAlign = 0;
|
||||
int hAlign = 0;
|
||||
bool hALigned = false;
|
||||
|
||||
x2 = x; // default
|
||||
|
||||
if ( cell.alignment & Qt::AlignTop ) {
|
||||
vAlign = 3;
|
||||
y1 = y + h - (textHeight*Createdxf::yScale / 8);
|
||||
} else if ( cell.alignment & Qt::AlignVCenter ) {
|
||||
vAlign = 2;
|
||||
y1 = y + h/2;
|
||||
} else if ( cell.alignment & Qt::AlignBottom ) {
|
||||
y1 = y + (textHeight*Createdxf::yScale / 8);
|
||||
}
|
||||
|
||||
if ( cell.alignment & Qt::AlignRight ) {
|
||||
hAlign = 2;
|
||||
hALigned = true;
|
||||
x2 = x + w;
|
||||
} else if ( cell.alignment & Qt::AlignHCenter ) {
|
||||
hAlign = 1;
|
||||
hALigned = true;
|
||||
x2 = x + w/2;
|
||||
} else if ( cell.alignment & Qt::AlignJustify ) {
|
||||
} else if (cell.alignment & Qt::AlignJustify ) {
|
||||
hAlign = 5;
|
||||
hALigned = true;
|
||||
vAlign = 0;
|
||||
x2 = x + w;
|
||||
y1 = y + textHeight*Createdxf::yScale / 8;
|
||||
}
|
||||
|
||||
if ( cell.alignment & Qt::AlignTop ) {
|
||||
vAlign = 3;
|
||||
y += h - textHeight*Createdxf::yScale;
|
||||
if (!hALigned)
|
||||
x2 = x;
|
||||
} else if ( cell.alignment & Qt::AlignVCenter ) {
|
||||
vAlign = 2;
|
||||
y += h/2;
|
||||
if (!hALigned)
|
||||
x2 = x;
|
||||
} else if ( cell.alignment & Qt::AlignBottom ) {}
|
||||
|
||||
//painter.setFont(text_font);
|
||||
qreal ratio = 1.0;
|
||||
if (cell.hadjust) {
|
||||
|
||||
if (cell.hadjust) {
|
||||
// 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
|
||||
}
|
||||
// As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD
|
||||
int len = text.length() * textHeight * Createdxf::xScale * 1.2;
|
||||
|
||||
if(len > w)
|
||||
ratio = (w/len);
|
||||
}
|
||||
// x & y offset values below (1 & 3) currently set heuristically based on appearance...
|
||||
|
||||
// x offset value below currently set heuristically based on appearance...
|
||||
Createdxf::drawTextAligned(file_path,
|
||||
text,
|
||||
x - 1*Createdxf::xScale,
|
||||
y - 3*Createdxf::yScale,
|
||||
x - 2*Createdxf::xScale,
|
||||
y1,
|
||||
textHeight*Createdxf::yScale,
|
||||
0,
|
||||
0,
|
||||
@ -1855,12 +1858,11 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
|
||||
vAlign,
|
||||
x2,
|
||||
ratio,
|
||||
color,
|
||||
color,
|
||||
cell.alignment & Qt::AlignLeft,
|
||||
0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@brief TitleBlockTemplate::forgetSpanning
|
||||
Set the spanner_cell attribute of every cell to 0.
|
||||
|
Loading…
x
Reference in New Issue
Block a user