20 #include <QTextStream> 21 #include <QMessageBox> 47 if (!fileName.isEmpty()) {
49 if (!file.open(QFile::WriteOnly)) {
51 QMessageBox errorFileOpen;
52 errorFileOpen.setIcon(QMessageBox::Warning);
53 errorFileOpen.setText(
"Error: "+fileName+
" Could Not be Opened.");
54 errorFileOpen.setInformativeText(
"Close all Files and Try Again.");
58 QTextStream To_Dxf(&file);
59 To_Dxf << 999 <<
"\r\n";
60 To_Dxf <<
"QET" <<
"\r\n";
61 To_Dxf << 0 <<
"\r\n";
62 To_Dxf <<
"SECTION" <<
"\r\n";
63 To_Dxf << 2 <<
"\r\n";
64 To_Dxf <<
"HEADER" <<
"\r\n";
65 To_Dxf << 9 <<
"\r\n";
66 To_Dxf <<
"$ACADVER" <<
"\r\n";
67 To_Dxf << 1 <<
"\r\n";
68 To_Dxf <<
"AC1006" <<
"\r\n";
69 To_Dxf << 9 <<
"\r\n";
70 To_Dxf <<
"$INSBASE" <<
"\r\n";
71 To_Dxf << 10 <<
"\r\n";
72 To_Dxf <<
"0.0" <<
"\r\n";
73 To_Dxf << 20 <<
"\r\n";
74 To_Dxf <<
"0.0" <<
"\r\n";
75 To_Dxf << 30 <<
"\r\n";
76 To_Dxf <<
"0.0" <<
"\r\n";
77 To_Dxf << 9 <<
"\r\n";
79 To_Dxf <<
"$EXTMIN" <<
"\r\n";
80 To_Dxf << 10 <<
"\r\n";
81 To_Dxf <<
"0.0" <<
"\r\n";
82 To_Dxf << 20 <<
"\r\n";
83 To_Dxf <<
"0.0" <<
"\r\n";
84 To_Dxf << 9 <<
"\r\n";
85 To_Dxf <<
"$EXTMAX" <<
"\r\n";
86 To_Dxf << 10 <<
"\r\n";
87 To_Dxf <<
"4000.0" <<
"\r\n";
88 To_Dxf << 20 <<
"\r\n";
89 To_Dxf <<
"4000.0" <<
"\r\n";
91 To_Dxf << 9 <<
"\r\n";
92 To_Dxf <<
"$LIMMIN" <<
"\r\n";
93 To_Dxf << 10 <<
"\r\n";
94 To_Dxf <<
"0.0" <<
"\r\n";
95 To_Dxf << 20 <<
"\r\n";
96 To_Dxf <<
"0.0" <<
"\r\n";
97 To_Dxf << 9 <<
"\r\n";
98 To_Dxf <<
"$LIMMAX" <<
"\r\n";
99 To_Dxf << 10 <<
"\r\n";
100 To_Dxf <<
"4000.0" <<
"\r\n";
101 To_Dxf << 20 <<
"\r\n";
102 To_Dxf <<
"4000.0" <<
"\r\n";
103 To_Dxf << 0 <<
"\r\n";
104 To_Dxf <<
"ENDSEC" <<
"\r\n";
105 To_Dxf << 0 <<
"\r\n";
106 To_Dxf <<
"SECTION" <<
"\r\n";
107 To_Dxf << 2 <<
"\r\n";
108 To_Dxf <<
"TABLES" <<
"\r\n";
109 To_Dxf << 0 <<
"\r\n";
110 To_Dxf <<
"TABLE" <<
"\r\n";
111 To_Dxf << 2 <<
"\r\n";
113 To_Dxf <<
"VPORT" <<
"\r\n";
114 To_Dxf << 70 <<
"\r\n";
115 To_Dxf << 1 <<
"\r\n";
116 To_Dxf << 0 <<
"\r\n";
117 To_Dxf <<
"VPORT" <<
"\r\n";
118 To_Dxf << 2 <<
"\r\n";
119 To_Dxf <<
"*ACTIVE" <<
"\r\n";
120 To_Dxf << 70 <<
"\r\n";
121 To_Dxf << 0 <<
"\r\n";
122 To_Dxf << 10 <<
"\r\n";
123 To_Dxf << 0.0 <<
"\r\n";
124 To_Dxf << 20 <<
"\r\n";
125 To_Dxf << 0.0 <<
"\r\n";
126 To_Dxf << 11 <<
"\r\n";
127 To_Dxf << 1.0 <<
"\r\n";
128 To_Dxf << 21 <<
"\r\n";
129 To_Dxf << 1.0 <<
"\r\n";
130 To_Dxf << 12 <<
"\r\n";
131 To_Dxf << 2000 <<
"\r\n";
132 To_Dxf << 22 <<
"\r\n";
133 To_Dxf << 1350 <<
"\r\n";
134 To_Dxf << 13 <<
"\r\n";
135 To_Dxf << 0.0 <<
"\r\n";
136 To_Dxf << 23 <<
"\r\n";
137 To_Dxf << 0.0 <<
"\r\n";
138 To_Dxf << 14 <<
"\r\n";
139 To_Dxf << 1.0 <<
"\r\n";
140 To_Dxf << 24 <<
"\r\n";
141 To_Dxf << 1.0 <<
"\r\n";
142 To_Dxf << 15 <<
"\r\n";
143 To_Dxf << 0.0 <<
"\r\n";
144 To_Dxf << 25 <<
"\r\n";
145 To_Dxf << 0.0 <<
"\r\n";
146 To_Dxf << 16 <<
"\r\n";
147 To_Dxf << 0.0 <<
"\r\n";
148 To_Dxf << 26 <<
"\r\n";
149 To_Dxf << 0.0 <<
"\r\n";
150 To_Dxf << 36 <<
"\r\n";
151 To_Dxf << 1.0 <<
"\r\n";
152 To_Dxf << 17 <<
"\r\n";
153 To_Dxf << 0.0 <<
"\r\n";
154 To_Dxf << 27 <<
"\r\n";
155 To_Dxf << 0.0 <<
"\r\n";
156 To_Dxf << 37 <<
"\r\n";
157 To_Dxf << 0.0 <<
"\r\n";
158 To_Dxf << 40 <<
"\r\n";
159 To_Dxf << 2732.5 <<
"\r\n";
160 To_Dxf << 41 <<
"\r\n";
161 To_Dxf << 2.558 <<
"\r\n";
162 To_Dxf << 42 <<
"\r\n";
163 To_Dxf << 50.0 <<
"\r\n";
164 To_Dxf << 43 <<
"\r\n";
165 To_Dxf << 0.0 <<
"\r\n";
166 To_Dxf << 44 <<
"\r\n";
167 To_Dxf << 0.0 <<
"\r\n";
168 To_Dxf << 50 <<
"\r\n";
169 To_Dxf << 0.0 <<
"\r\n";
170 To_Dxf << 51 <<
"\r\n";
171 To_Dxf << 0.0 <<
"\r\n";
172 To_Dxf << 71 <<
"\r\n";
173 To_Dxf << 0 <<
"\r\n";
174 To_Dxf << 72 <<
"\r\n";
175 To_Dxf << 100 <<
"\r\n";
176 To_Dxf << 73 <<
"\r\n";
177 To_Dxf << 1 <<
"\r\n";
178 To_Dxf << 74 <<
"\r\n";
179 To_Dxf << 1 <<
"\r\n";
180 To_Dxf << 75 <<
"\r\n";
181 To_Dxf << 0 <<
"\r\n";
182 To_Dxf << 76 <<
"\r\n";
183 To_Dxf << 0 <<
"\r\n";
184 To_Dxf << 77 <<
"\r\n";
185 To_Dxf << 0 <<
"\r\n";
186 To_Dxf << 78 <<
"\r\n";
187 To_Dxf << 0 <<
"\r\n";
188 To_Dxf << 0 <<
"\r\n";
189 To_Dxf <<
"ENDTAB" <<
"\r\n";
190 To_Dxf << 0 <<
"\r\n";
191 To_Dxf <<
"TABLE" <<
"\r\n";
192 To_Dxf << 2 <<
"\r\n";
194 To_Dxf <<
"LTYPE" <<
"\r\n";
195 To_Dxf << 70 <<
"\r\n";
196 To_Dxf << 1 <<
"\r\n";
197 To_Dxf << 0 <<
"\r\n";
198 To_Dxf <<
"LTYPE" <<
"\r\n";
199 To_Dxf << 2 <<
"\r\n";
200 To_Dxf <<
"CONTINUOUS" <<
"\r\n";
201 To_Dxf << 70 <<
"\r\n";
202 To_Dxf << 64 <<
"\r\n";
203 To_Dxf << 3 <<
"\r\n";
204 To_Dxf <<
"Solid Line" <<
"\r\n";
205 To_Dxf << 72 <<
"\r\n";
206 To_Dxf << 65 <<
"\r\n";
207 To_Dxf << 73 <<
"\r\n";
208 To_Dxf << 0 <<
"\r\n";
209 To_Dxf << 40 <<
"\r\n";
210 To_Dxf << 0.00 <<
"\r\n";
211 To_Dxf << 0 <<
"\r\n";
213 To_Dxf <<
"ENDTAB" <<
"\r\n";
214 To_Dxf << 0 <<
"\r\n";
215 To_Dxf <<
"ENDSEC" <<
"\r\n";
216 To_Dxf << 0 <<
"\r\n";
217 To_Dxf <<
"SECTION" <<
"\r\n";
218 To_Dxf << 2 <<
"\r\n";
219 To_Dxf <<
"BLOCKS" <<
"\r\n";
220 To_Dxf << 0 <<
"\r\n";
221 To_Dxf <<
"ENDSEC" <<
"\r\n";
222 To_Dxf << 0 <<
"\r\n";
223 To_Dxf <<
"SECTION" <<
"\r\n";
224 To_Dxf << 2 <<
"\r\n";
225 To_Dxf <<
"ENTITIES" <<
"\r\n";
235 if (!fileName.isEmpty()) {
236 QFile file(fileName);
237 if (!file.open(QFile::Append)) {
239 QMessageBox errorFileOpen;
240 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
241 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
242 errorFileOpen.exec();
244 QTextStream To_Dxf(&file);
245 To_Dxf << 0 <<
"\r\n";
246 To_Dxf <<
"ENDSEC" <<
"\r\n";
247 To_Dxf << 0 <<
"\r\n";
258 if (!fileName.isEmpty()) {
259 QFile file(fileName);
260 if (!file.open(QFile::Append)) {
262 QMessageBox errorFileOpen;
263 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
264 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
265 errorFileOpen.exec();
267 QTextStream To_Dxf(&file);
269 To_Dxf << 0 <<
"\r\n";
270 To_Dxf <<
"CIRCLE" <<
"\r\n";
271 To_Dxf << 8 <<
"\r\n";
272 To_Dxf << 0 <<
"\r\n";
273 To_Dxf << 62 <<
"\r\n";
274 To_Dxf << colour <<
"\r\n";
275 To_Dxf << 10 <<
"\r\n";
276 To_Dxf << x <<
"\r\n";
277 To_Dxf << 20 <<
"\r\n";
278 To_Dxf << y <<
"\r\n";
279 To_Dxf << 30 <<
"\r\n";
280 To_Dxf << 0.0 <<
"\r\n";
281 To_Dxf << 40 <<
"\r\n";
282 To_Dxf << radius <<
"\r\n";
290 void Createdxf::drawLine (
const QString &fileName,
double x1,
double y1,
double x2,
double y2,
const int &colour)
292 if (!fileName.isEmpty()) {
293 QFile file(fileName);
294 if (!file.open(QFile::Append)) {
296 QMessageBox errorFileOpen;
297 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
298 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
299 errorFileOpen.exec();
301 QTextStream To_Dxf(&file);
303 To_Dxf << 0 <<
"\r\n";
304 To_Dxf <<
"LINE" <<
"\r\n";
305 To_Dxf << 8 <<
"\r\n";
306 To_Dxf << 0 <<
"\r\n";
307 To_Dxf << 62 <<
"\r\n";
308 To_Dxf << colour <<
"\r\n";
309 To_Dxf << 10 <<
"\r\n";
310 To_Dxf << x1 <<
"\r\n";
311 To_Dxf << 20 <<
"\r\n";
312 To_Dxf << y1 <<
"\r\n";
313 To_Dxf << 30 <<
"\r\n";
314 To_Dxf << 0.0 <<
"\r\n";
315 To_Dxf << 11 <<
"\r\n";
316 To_Dxf << x2 <<
"\r\n";
317 To_Dxf << 21 <<
"\r\n";
318 To_Dxf << y2 <<
"\r\n";
319 To_Dxf << 31 <<
"\r\n";
320 To_Dxf << 0.0 <<
"\r\n";
327 0x000000, 0xff0000, 0xffff00, 0x00ff00, 0x00ffff,
328 0x0000ff, 0xff00ff, 0xffffff, 0x414141, 0x808080,
329 0xff0000, 0xffaaaa, 0xbd0000, 0xbd7e7e, 0x810000,
330 0x815656, 0x680000, 0x684545, 0x4f0000, 0x4f3535,
331 0xff3f00, 0xffbfaa, 0xbd2e00, 0xbd8d7e, 0x811f00,
332 0x816056, 0x681900, 0x684e45, 0x4f1300, 0x4f3b35,
333 0xff7f00, 0xffd4aa, 0xbd5e00, 0xbd9d7e, 0x814000,
334 0x816b56, 0x683400, 0x685645, 0x4f2700, 0x4f4235,
335 0xffbf00, 0xffeaaa, 0xbd8d00, 0xbdad7e, 0x816000,
336 0x817656, 0x684e00, 0x685f45, 0x4f3b00, 0x4f4935,
337 0xffff00, 0xffffaa, 0xbdbd00, 0xbdbd7e, 0x818100,
338 0x818156, 0x686800, 0x686845, 0x4f4f00, 0x4f4f35,
339 0xbfff00, 0xeaffaa, 0x8dbd00, 0xadbd7e, 0x608100,
340 0x768156, 0x4e6800, 0x5f6845, 0x3b4f00, 0x494f35,
341 0x7fff00, 0xd4ffaa, 0x5ebd00, 0x9dbd7e, 0x408100,
342 0x6b8156, 0x346800, 0x566845, 0x274f00, 0x424f35,
343 0x3fff00, 0xbfffaa, 0x2ebd00, 0x8dbd7e, 0x1f8100,
344 0x608156, 0x196800, 0x4e6845, 0x134f00, 0x3b4f35,
345 0x00ff00, 0xaaffaa, 0x00bd00, 0x7ebd7e, 0x008100,
346 0x568156, 0x006800, 0x456845, 0x004f00, 0x354f35,
347 0x00ff3f, 0xaaffbf, 0x00bd2e, 0x7ebd8d, 0x00811f,
348 0x568160, 0x006819, 0x45684e, 0x004f13, 0x354f3b,
349 0x00ff7f, 0xaaffd4, 0x00bd5e, 0x7ebd9d, 0x008140,
350 0x56816b, 0x006834, 0x456856, 0x004f27, 0x354f42,
351 0x00ffbf, 0xaaffea, 0x00bd8d, 0x7ebdad, 0x008160,
352 0x568176, 0x00684e, 0x45685f, 0x004f3b, 0x354f49,
353 0x00ffff, 0xaaffff, 0x00bdbd, 0x7ebdbd, 0x008181,
354 0x568181, 0x006868, 0x456868, 0x004f4f, 0x354f4f,
355 0x00bfff, 0xaaeaff, 0x008dbd, 0x7eadbd, 0x006081,
356 0x567681, 0x004e68, 0x455f68, 0x003b4f, 0x35494f,
357 0x007fff, 0xaad4ff, 0x005ebd, 0x7e9dbd, 0x004081,
358 0x566b81, 0x003468, 0x455668, 0x00274f, 0x35424f,
359 0x003fff, 0xaabfff, 0x002ebd, 0x7e8dbd, 0x001f81,
360 0x566081, 0x001968, 0x454e68, 0x00134f, 0x353b4f,
361 0x0000ff, 0xaaaaff, 0x0000bd, 0x7e7ebd, 0x000081,
362 0x565681, 0x000068, 0x454568, 0x00004f, 0x35354f,
363 0x3f00ff, 0xbfaaff, 0x2e00bd, 0x8d7ebd, 0x1f0081,
364 0x605681, 0x190068, 0x4e4568, 0x13004f, 0x3b354f,
365 0x7f00ff, 0xd4aaff, 0x5e00bd, 0x9d7ebd, 0x400081,
366 0x6b5681, 0x340068, 0x564568, 0x27004f, 0x42354f,
367 0xbf00ff, 0xeeaaff, 0x8d00bd, 0xad7ebd, 0x600081,
368 0x765681, 0x4e0068, 0x5f4568, 0x3b004f, 0x49354f,
369 0xff00ff, 0xffaaff, 0xbd00bd, 0xbd7ebd, 0x810081,
370 0x815681, 0x680068, 0x684568, 0x4f004f, 0x4f354f,
371 0xff00bf, 0xffaaea, 0xbd008d, 0xbd7ead, 0x810060,
372 0x815676, 0x68004e, 0x68455f, 0x4f003b, 0x4f3549,
373 0xff007f, 0xffaad4, 0xbd005e, 0xbd7e9d, 0x810040,
374 0x81566b, 0x680034, 0x684556, 0x4f0027, 0x4f3542,
375 0xff003f, 0xffaabf, 0xbd002e, 0xbd7e8d, 0x81001f,
376 0x815660, 0x680019, 0x68454e, 0x4f0013, 0x4f353b,
377 0x333333, 0x505050, 0x696969, 0x828282, 0xbebebe
392 long mindst = 2147483647L;
395 for (
int i = 0; i < 254; i++ )
398 b = ( acirgb & 0xffL );
399 g = ( acirgb & 0xff00L ) >> 8;
401 dst = abs ( r-red) + abs ( g -green) + abs (b-blue);
426 void Createdxf::drawArcEllipse(
const QString &file_path, qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal spanAngle, qreal hotspot_x, qreal hotspot_y, qreal rotation_angle,
const int &colorcode) {
428 QVector< QPair<qreal,qreal> > arc_parts_vector;
431 qreal start = startAngle;
434 for ( i = startAngle; i < startAngle+spanAngle; i++ ) {
435 int absolute_theta = (i > 0) ? i : -i;
436 if (absolute_theta == 0 || absolute_theta == 90 ||
437 absolute_theta == 180 || absolute_theta == 270 ||
438 absolute_theta == 360) {
440 QPair<qreal, qreal> newPart(start,span);
441 arc_parts_vector.push_back(newPart);
447 QPair<qreal, qreal> newPart(start,span);
448 arc_parts_vector.push_back(newPart);
451 qreal start = startAngle;
454 for ( i = startAngle; i > startAngle+spanAngle; i-- ) {
455 int absolute_theta = (i > 0) ? i : -i;
456 if (absolute_theta == 0 || absolute_theta == 90 ||
457 absolute_theta == 180 || absolute_theta == 270 ||
458 absolute_theta == 360) {
460 QPair<qreal, qreal> newPart(start,span);
461 arc_parts_vector.push_back(newPart);
467 QPair<qreal, qreal> newPart(start,span);
468 arc_parts_vector.push_back(newPart);
472 for (
int i = 0; i < arc_parts_vector.size(); i++) {
474 QPair<qreal,qreal> arc = arc_parts_vector[i];
477 qreal arc_startAngle = arc.first * 3.142/180;
478 qreal arc_spanAngle = arc.second * 3.142/180;
483 qreal x1 = x + w/2 + a*cos(arc_startAngle);
484 qreal y1 = y - h/2 + b*sin(arc_startAngle);
485 qreal x2 = x + w/2 + a*cos(arc_startAngle + arc_spanAngle);
486 qreal y2 = y - h/2 + b*sin(arc_startAngle + arc_spanAngle);
489 qreal mid_ellipse_x = x + w/2 + a*cos(arc_startAngle + arc_spanAngle/2);
490 qreal mid_ellipse_y = y - h/2 + b*sin(arc_startAngle + arc_spanAngle/2);
491 qreal mid_line_x = (x1+x2)/2;
492 qreal mid_line_y = (y1+y2)/2;
494 qreal x3 = (mid_ellipse_x + mid_line_x)/2;
495 qreal y3 = (mid_ellipse_y + mid_line_y)/2;
498 qreal a1 = 2*x2 - 2*x1;
499 qreal b1 = 2*y2 - 2*y1;
500 qreal c1 = x1*x1 + y1*y1 - x2*x2 - y2*y2;
502 qreal a2 = 2*x3 - 2*x1;
503 qreal b2 = 2*y3 - 2*y1;
504 qreal c2 = x1*x1 + y1*y1 - x3*x3 - y3*y3;
506 qreal center_x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
507 qreal center_y = (a1*c2 - a2*c1) / (b1*a2 - b2*a1);
509 qreal radius = sqrt( (x1-center_x)*(x1-center_x) + (y1-center_y)*(y1-center_y) );
511 if ( x1 > center_x && y1 > center_y )
512 arc_startAngle = asin( (y1 - center_y) / radius );
513 else if ( x1 > center_x && y1 < center_y )
514 arc_startAngle = 3.142*2 - asin( (center_y - y1) / radius );
515 else if ( x1 < center_x && y1 < center_y )
516 arc_startAngle = 3.142 + asin( (center_y - y1) / radius );
518 arc_startAngle = 3.142 - asin( (y1 - center_y) / radius );
522 if ( x2 > center_x && y2 > center_y )
523 arc_endAngle = asin( (y2 - center_y) / radius );
524 else if ( x2 > center_x && y2 < center_y )
525 arc_endAngle = 3.142*2 - asin( (center_y - y2) / radius );
526 else if ( x2 < center_x && y2 < center_y )
527 arc_endAngle = 3.142 + asin( (center_y - y2) / radius );
529 arc_endAngle = 3.142 - asin( (y2 - center_y) / radius );
531 if (arc_endAngle < arc_startAngle) {
532 qreal temp = arc_startAngle;
533 arc_startAngle = arc_endAngle;
538 center_x = transformed_point.x();
539 center_y = transformed_point.y();
540 arc_endAngle *= 180/3.142;
541 arc_startAngle *= 180/3.142;
542 arc_endAngle -= rotation_angle;
543 arc_startAngle -= rotation_angle;
545 drawArc(file_path, center_x, center_y, radius, arc_startAngle, arc_endAngle, colorcode);
561 0, 360, 0, 0, 0, colorcode);
567 if (!fileName.isEmpty()) {
568 QFile file(fileName);
569 if (!file.open(QFile::Append)) {
571 QMessageBox errorFileOpen;
572 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
573 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
574 errorFileOpen.exec();
576 QTextStream To_Dxf(&file);
578 To_Dxf << 0 <<
"\r\n";
579 To_Dxf <<
"LINE" <<
"\r\n";
580 To_Dxf << 8 <<
"\r\n";
581 To_Dxf << 0 <<
"\r\n";
582 To_Dxf << 62 <<
"\r\n";
583 To_Dxf << colour <<
"\r\n";
584 To_Dxf << 10 <<
"\r\n";
585 To_Dxf << x1 <<
"\r\n";
586 To_Dxf << 20 <<
"\r\n";
587 To_Dxf << y1 <<
"\r\n";
588 To_Dxf << 30 <<
"\r\n";
589 To_Dxf << 0.0 <<
"\r\n";
590 To_Dxf << 11 <<
"\r\n";
591 To_Dxf << x1+width <<
"\r\n";
592 To_Dxf << 21 <<
"\r\n";
593 To_Dxf << y1 <<
"\r\n";
594 To_Dxf << 31 <<
"\r\n";
595 To_Dxf << 0.0 <<
"\r\n";
596 To_Dxf << 0 <<
"\r\n";
597 To_Dxf <<
"LINE" <<
"\r\n";
598 To_Dxf << 8 <<
"\r\n";
599 To_Dxf << 0 <<
"\r\n";
600 To_Dxf << 62 <<
"\r\n";
601 To_Dxf << colour <<
"\r\n";
602 To_Dxf << 10 <<
"\r\n";
603 To_Dxf << x1 <<
"\r\n";
604 To_Dxf << 20 <<
"\r\n";
605 To_Dxf << y1 <<
"\r\n";
606 To_Dxf << 30 <<
"\r\n";
607 To_Dxf << 0.0 <<
"\r\n";
608 To_Dxf << 11 <<
"\r\n";
609 To_Dxf << x1 <<
"\r\n";
610 To_Dxf << 21 <<
"\r\n";
611 To_Dxf << y1+height <<
"\r\n";
612 To_Dxf << 31 <<
"\r\n";
613 To_Dxf << 0.0 <<
"\r\n";
614 To_Dxf << 0 <<
"\r\n";
615 To_Dxf <<
"LINE" <<
"\r\n";
616 To_Dxf << 8 <<
"\r\n";
617 To_Dxf << 0 <<
"\r\n";
618 To_Dxf << 62 <<
"\r\n";
619 To_Dxf << colour <<
"\r\n";
620 To_Dxf << 10 <<
"\r\n";
621 To_Dxf << x1+width <<
"\r\n";
622 To_Dxf << 20 <<
"\r\n";
623 To_Dxf << y1 <<
"\r\n";
624 To_Dxf << 30 <<
"\r\n";
625 To_Dxf << 0.0 <<
"\r\n";
626 To_Dxf << 11 <<
"\r\n";
627 To_Dxf << x1+width <<
"\r\n";
628 To_Dxf << 21 <<
"\r\n";
629 To_Dxf << y1+height <<
"\r\n";
630 To_Dxf << 31 <<
"\r\n";
631 To_Dxf << 0.0 <<
"\r\n";
632 To_Dxf << 0 <<
"\r\n";
633 To_Dxf <<
"LINE" <<
"\r\n";
634 To_Dxf << 8 <<
"\r\n";
635 To_Dxf << 0 <<
"\r\n";
636 To_Dxf << 62 <<
"\r\n";
637 To_Dxf << colour <<
"\r\n";
638 To_Dxf << 10 <<
"\r\n";
639 To_Dxf << x1 <<
"\r\n";
640 To_Dxf << 20 <<
"\r\n";
641 To_Dxf << y1+height <<
"\r\n";
642 To_Dxf << 30 <<
"\r\n";
643 To_Dxf << 0.0 <<
"\r\n";
644 To_Dxf << 11 <<
"\r\n";
645 To_Dxf << x1+width <<
"\r\n";
646 To_Dxf << 21 <<
"\r\n";
647 To_Dxf << y1+height <<
"\r\n";
648 To_Dxf << 31 <<
"\r\n";
649 To_Dxf << 0.0 <<
"\r\n";
671 void Createdxf::drawArc(
const QString& fileName,
double x,
double y,
double rad,
double startAngle,
double endAngle,
int color)
673 if (!fileName.isEmpty()) {
674 QFile file(fileName);
675 if (!file.open(QFile::Append)) {
677 QMessageBox errorFileOpen;
678 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
679 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
680 errorFileOpen.exec();
682 QTextStream To_Dxf(&file);
684 To_Dxf << 0 <<
"\r\n";
685 To_Dxf <<
"ARC" <<
"\r\n";
686 To_Dxf << 8 <<
"\r\n";
687 To_Dxf << 0 <<
"\r\n";
688 To_Dxf << 62 <<
"\r\n";
689 To_Dxf << color <<
"\r\n";
690 To_Dxf << 10 <<
"\r\n";
691 To_Dxf << x <<
"\r\n";
692 To_Dxf << 20 <<
"\r\n";
693 To_Dxf << y <<
"\r\n";
694 To_Dxf << 30 <<
"\r\n";
695 To_Dxf << 0.0 <<
"\r\n";
696 To_Dxf << 40 <<
"\r\n";
697 To_Dxf << rad <<
"\r\n";
698 To_Dxf << 50 <<
"\r\n";
699 To_Dxf << startAngle<<
"\r\n";
700 To_Dxf << 51 <<
"\r\n";
701 To_Dxf << endAngle <<
"\r\n";
708 void Createdxf::drawText(
const QString& fileName,
const QString& text,
double x,
double y,
double height,
double rotation,
int colour)
710 if (!fileName.isEmpty()) {
711 QFile file(fileName);
712 if (!file.open(QFile::Append)) {
714 QMessageBox errorFileOpen;
715 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
716 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
717 errorFileOpen.exec();
719 QTextStream To_Dxf(&file);
721 To_Dxf << 0 <<
"\r\n";
722 To_Dxf <<
"TEXT" <<
"\r\n";
723 To_Dxf << 8 <<
"\r\n";
724 To_Dxf << 0 <<
"\r\n";
725 To_Dxf << 62 <<
"\r\n";
726 To_Dxf << colour <<
"\r\n";
727 To_Dxf << 10 <<
"\r\n";
728 To_Dxf << x <<
"\r\n";
729 To_Dxf << 20 <<
"\r\n";
730 To_Dxf << y <<
"\r\n";
731 To_Dxf << 30 <<
"\r\n";
732 To_Dxf << 0.0 <<
"\r\n";
733 To_Dxf << 40 <<
"\r\n";
734 To_Dxf << height <<
"\r\n";
735 To_Dxf << 1 <<
"\r\n";
736 To_Dxf << text <<
"\r\n";
737 To_Dxf << 50 <<
"\r\n";
738 To_Dxf << rotation <<
"\r\n";
747 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,
748 bool leftAlign,
float scale)
752 if (!fileName.isEmpty()) {
753 QFile file(fileName);
754 if (!file.open(QFile::Append)) {
756 QMessageBox errorFileOpen;
757 errorFileOpen.setText(
"Error: File "+fileName+
" was not written correctly.");
758 errorFileOpen.setInformativeText(
"Close all Files and Re-Run");
759 errorFileOpen.exec();
761 QTextStream To_Dxf(&file);
763 To_Dxf << 0 <<
"\r\n";
764 To_Dxf <<
"TEXT" <<
"\r\n";
765 To_Dxf << 8 <<
"\r\n";
766 To_Dxf << 0 <<
"\r\n";
767 To_Dxf << 62 <<
"\r\n";
768 To_Dxf << colour <<
"\r\n";
769 To_Dxf << 10 <<
"\r\n";
770 To_Dxf << x <<
"\r\n";
771 To_Dxf << 20 <<
"\r\n";
772 To_Dxf << y <<
"\r\n";
773 To_Dxf << 30 <<
"\r\n";
774 To_Dxf << 0.0 <<
"\r\n";
775 To_Dxf << 40 <<
"\r\n";
776 To_Dxf << height <<
"\r\n";
777 To_Dxf << 1 <<
"\r\n";
778 To_Dxf << text <<
"\r\n";
779 To_Dxf << 50 <<
"\r\n";
780 To_Dxf << rotation <<
"\r\n";
783 int xDiff = xAlign - x;
784 if (text.length() < xDiff/height && !leftAlign) {
786 xAlign = (x+xAlign) / 2;
787 }
else if (text.length() < xDiff/height && leftAlign) {
793 To_Dxf << 51 <<
"\r\n";
794 To_Dxf << oblique <<
"\r\n";
795 To_Dxf << 72 <<
"\r\n";
796 To_Dxf << hAlign <<
"\r\n";
797 To_Dxf << 73 <<
"\r\n";
798 To_Dxf << vAlign <<
"\r\n";
800 if ((hAlign) || (vAlign)) {
801 To_Dxf << 11 <<
"\r\n";
802 To_Dxf << xAlign <<
"\r\n";
803 To_Dxf << 21 <<
"\r\n";
804 To_Dxf << y <<
"\r\n";
805 To_Dxf << 31 <<
"\r\n";
806 To_Dxf << 0.0 <<
"\r\n";
static long RGBcodeTable[]
static int getcolorCode(const long red, const long green, const long blue)
Createdxf::getcolorCode This function returns the ACI color which is the "nearest" color to the color...
static void dxfEnd(const QString &)
static void drawArc(const QString &, double x, double y, double rad, double startAngle, double endAngle, int color)
static void drawRectangle(const QString &filepath, double, double, double, double, const int &colorcode)
static void drawText(const QString &, const QString &, double, double, double, double, int)
static const double sheetHeight
static void drawArcEllipse(const QString &file_path, qreal x, qreal y, qreal w, qreal h, qreal startAngle, qreal spanAngle, qreal hotspot_x, qreal hotspot_y, qreal rotation_angle, const int &colorcode)
static const double sheetWidth
static QPointF rotation_transformed(qreal, qreal, qreal, qreal, qreal)
static void drawCircle(const QString &, double, double, double, int)
static void drawEllipse(const QString &filepath, const QRectF &rect, const int &colorcode)
Createdxf::drawEllipse Conveniance function for draw ellipse.
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 drawLine(const QString &filapath, double, double, double, double, const int &clorcode)
static void dxfBegin(const QString &)