mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-08 07:59:58 +01:00
Merge branch 'C-Born-Software-dxf' into master
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";
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
|
|
||||||
/* This class exports the project to DXF Format */
|
/* This class exports the project to DXF Format */
|
||||||
class Createdxf
|
class Createdxf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Createdxf();
|
Createdxf();
|
||||||
~Createdxf();
|
~Createdxf();
|
||||||
static void dxfBegin (const QString&);
|
static void dxfBegin (const QString&);
|
||||||
static void dxfEnd(const QString&);
|
static void dxfEnd(const QString&);
|
||||||
// you can add more functions to create more drawings.
|
// you can add more functions to create more drawings.
|
||||||
static void drawCircle(const QString&,
|
static void drawCircle(const QString&,
|
||||||
double,
|
double,
|
||||||
double,
|
double,
|
||||||
@@ -43,7 +43,7 @@ class Createdxf
|
|||||||
double startAngle,
|
double startAngle,
|
||||||
double endAngle,
|
double endAngle,
|
||||||
int color);
|
int color);
|
||||||
static void drawDonut(QString,double,double,double,int);
|
static void drawDonut(QString,double,double,double,int);
|
||||||
|
|
||||||
static void drawArcEllipse (const QString &file_path,
|
static void drawArcEllipse (const QString &file_path,
|
||||||
qreal x,
|
qreal x,
|
||||||
@@ -97,6 +97,7 @@ class Createdxf
|
|||||||
int hAlign,
|
int hAlign,
|
||||||
int vAlign,
|
int vAlign,
|
||||||
double xAlign,
|
double xAlign,
|
||||||
|
double xScale,
|
||||||
int colour,
|
int colour,
|
||||||
bool leftAlign = false,
|
bool leftAlign = false,
|
||||||
float scale = 0);
|
float scale = 0);
|
||||||
@@ -105,12 +106,12 @@ class Createdxf
|
|||||||
static int getcolorCode (const long red,
|
static int getcolorCode (const long red,
|
||||||
const long green,
|
const long green,
|
||||||
const long blue);
|
const long blue);
|
||||||
static long RGBcodeTable[];
|
static long RGBcodeTable[];
|
||||||
|
|
||||||
static const double sheetWidth;
|
static const double sheetWidth;
|
||||||
static const double sheetHeight;
|
static const double sheetHeight;
|
||||||
static double xScale;
|
static double xScale;
|
||||||
static double yScale;
|
static double yScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CREATEDXF_H
|
#endif // CREATEDXF_H
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ void ExportDialog::generateDxf(Diagram *diagram,
|
|||||||
int height,
|
int height,
|
||||||
bool keep_aspect_ratio,
|
bool keep_aspect_ratio,
|
||||||
QString &file_path) {
|
QString &file_path) {
|
||||||
saveReloadDiagramParameters(diagram, true);
|
saveReloadDiagramParameters(diagram, true);
|
||||||
|
|
||||||
width -= 2*Diagram::margin;
|
width -= 2*Diagram::margin;
|
||||||
height -= 2*Diagram::margin;
|
height -= 2*Diagram::margin;
|
||||||
@@ -415,22 +415,12 @@ void ExportDialog::generateDxf(Diagram *diagram,
|
|||||||
Createdxf::dxfBegin(file_path);
|
Createdxf::dxfBegin(file_path);
|
||||||
|
|
||||||
//Add project elements (lines, rectangles, circles, texts) to dxf file
|
//Add project elements (lines, rectangles, circles, texts) to dxf file
|
||||||
if (epw -> exportProperties().draw_border) {
|
if (epw -> exportProperties().draw_border) {
|
||||||
double bx0 = Diagram::margin * Createdxf::xScale;
|
double bx0 = Diagram::margin * Createdxf::xScale;
|
||||||
double by0 = Diagram::margin * Createdxf::yScale;
|
double by0 = Diagram::margin * Createdxf::yScale;
|
||||||
Createdxf::drawRectangle(
|
Createdxf::drawRectangle(file_path, bx0, -by0, double(width)*Createdxf::xScale, double(height)*Createdxf::yScale, 0);
|
||||||
file_path,
|
}
|
||||||
bx0,
|
diagram -> border_and_titleblock.drawDxf(width, height, keep_aspect_ratio, file_path, 0);
|
||||||
-by0,
|
|
||||||
double(width)*Createdxf::xScale,
|
|
||||||
double(height)*Createdxf::yScale,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
diagram -> border_and_titleblock.drawDxf(width,
|
|
||||||
height,
|
|
||||||
keep_aspect_ratio,
|
|
||||||
file_path,
|
|
||||||
0);
|
|
||||||
|
|
||||||
// Build the lists of elements.
|
// Build the lists of elements.
|
||||||
QList<Element *> list_elements;
|
QList<Element *> list_elements;
|
||||||
|
|||||||
@@ -1833,34 +1833,28 @@ 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// x & y offset values below (1 & 3) currently set heuristically based on appearance...
|
||||||
Createdxf::drawTextAligned(file_path,
|
Createdxf::drawTextAligned(file_path,
|
||||||
text,
|
text,
|
||||||
x,
|
x - 1*Createdxf::xScale,
|
||||||
y,
|
y - 3*Createdxf::yScale,
|
||||||
textHeight*Createdxf::yScale,
|
textHeight*Createdxf::yScale,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
hAlign,
|
hAlign,
|
||||||
vAlign,
|
vAlign,
|
||||||
x2,
|
x2,
|
||||||
|
ratio,
|
||||||
color,
|
color,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user