QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dl_entities.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
3 **
4 ** This file is part of the dxflib project.
5 **
6 ** This file is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 ** Licensees holding valid dxflib Professional Edition licenses may use
12 ** this file in accordance with the dxflib Commercial License
13 ** Agreement provided with the Software.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** See http://www.ribbonsoft.com for further details.
19 **
20 ** Contact info@ribbonsoft.com if any conditions of this licensing are
21 ** not clear to you.
22 **
23 **********************************************************************/
24 
25 #ifndef DL_ENTITIES_H
26 #define DL_ENTITIES_H
27 
28 #include "dl_global.h"
29 
30 #include <string>
31 #include <vector>
32 
41  DL_LayerData(const std::string& lName,
42  int lFlags) {
43  name = lName;
44  flags = lFlags;
45  }
46 
48  std::string name;
50  int flags;
51 };
52 
53 
54 
63  DL_BlockData(const std::string& bName,
64  int bFlags,
65  double bbpx, double bbpy, double bbpz) {
66  name = bName;
67  flags = bFlags;
68  bpx = bbpx;
69  bpy = bbpy;
70  bpz = bbpz;
71  }
72 
74  std::string name;
76  int flags;
78  double bpx;
80  double bpy;
82  double bpz;
83 };
84 
85 
86 
95  DL_LineTypeData(const std::string& lName,
96  int lFlags) {
97  name = lName;
98  flags = lFlags;
99  }
100 
102  std::string name;
104  int flags;
105 };
106 
107 
108 
118  const std::string& name,
119  int flags,
120  double fixedTextHeight,
121  double widthFactor,
122  double obliqueAngle,
123  int textGenerationFlags,
124  double lastHeightUsed,
125  const std::string& primaryFontFile,
126  const std::string& bigFontFile
127  )
128  : name(name),
129  flags(flags),
130  fixedTextHeight(fixedTextHeight),
131  widthFactor(widthFactor),
132  obliqueAngle(obliqueAngle),
133  textGenerationFlags(textGenerationFlags),
134  lastHeightUsed(lastHeightUsed),
135  primaryFontFile(primaryFontFile),
136  bigFontFile(bigFontFile),
137  bold(false),
138  italic(false) {
139  }
140 
141  bool operator==(const DL_StyleData& other) {
142  // ignore lastHeightUsed:
143  return (name==other.name &&
144  flags==other.flags &&
145  fixedTextHeight==other.fixedTextHeight &&
146  widthFactor==other.widthFactor &&
147  obliqueAngle==other.obliqueAngle &&
148  textGenerationFlags==other.textGenerationFlags &&
149  primaryFontFile==other.primaryFontFile &&
150  bigFontFile==other.bigFontFile);
151  }
152 
154  std::string name;
156  int flags;
160  double widthFactor;
162  double obliqueAngle;
168  std::string primaryFontFile;
170  std::string bigFontFile;
171 
172  bool bold;
173  bool italic;
174 };
175 
184  DL_PointData(double px=0.0, double py=0.0, double pz=0.0) {
185  x = px;
186  y = py;
187  z = pz;
188  }
189 
191  double x;
193  double y;
195  double z;
196 };
197 
198 
199 
208  DL_LineData(double lx1, double ly1, double lz1,
209  double lx2, double ly2, double lz2) {
210  x1 = lx1;
211  y1 = ly1;
212  z1 = lz1;
213 
214  x2 = lx2;
215  y2 = ly2;
216  z2 = lz2;
217  }
218 
220  double x1;
222  double y1;
224  double z1;
225 
227  double x2;
229  double y2;
231  double z2;
232 };
233 
242  DL_XLineData(double bx, double by, double bz,
243  double dx, double dy, double dz) :
244  bx(bx), by(by), bz(bz),
245  dx(dx), dy(dy), dz(dz) {
246  }
247 
249  double bx;
251  double by;
253  double bz;
254 
256  double dx;
258  double dy;
260  double dz;
261 };
262 
271  DL_RayData(double bx, double by, double bz,
272  double dx, double dy, double dz) :
273  bx(bx), by(by), bz(bz),
274  dx(dx), dy(dy), dz(dz) {
275  }
276 
278  double bx;
280  double by;
282  double bz;
283 
285  double dx;
287  double dy;
289  double dz;
290 };
291 
292 
293 
302  DL_ArcData(double acx, double acy, double acz,
303  double aRadius,
304  double aAngle1, double aAngle2) {
305 
306  cx = acx;
307  cy = acy;
308  cz = acz;
309  radius = aRadius;
310  angle1 = aAngle1;
311  angle2 = aAngle2;
312  }
313 
315  double cx;
317  double cy;
319  double cz;
320 
322  double radius;
324  double angle1;
326  double angle2;
327 };
328 
329 
330 
339  DL_CircleData(double acx, double acy, double acz,
340  double aRadius) {
341 
342  cx = acx;
343  cy = acy;
344  cz = acz;
345  radius = aRadius;
346  }
347 
349  double cx;
351  double cy;
353  double cz;
354 
356  double radius;
357 };
358 
359 
360 
369  DL_PolylineData(int pNumber, int pMVerteces, int pNVerteces, int pFlags) {
370  number = pNumber;
371  m = pMVerteces;
372  n = pNVerteces;
373  flags = pFlags;
374  }
375 
377  unsigned int number;
378 
380  unsigned int m;
381 
383  unsigned int n;
384 
386  int flags;
387 };
388 
389 
390 
399  DL_VertexData(double px=0.0, double py=0.0, double pz=0.0,
400  double pBulge=0.0) {
401  x = px;
402  y = py;
403  z = pz;
404  bulge = pBulge;
405  }
406 
408  double x;
410  double y;
412  double z;
415  double bulge;
416 };
417 
418 
424  thickness = 0.0;
425  for (int i=0; i<4; i++) {
426  x[i] = 0.0;
427  y[i] = 0.0;
428  z[i] = 0.0;
429  }
430  }
431 
436  DL_TraceData(double sx1, double sy1, double sz1,
437  double sx2, double sy2, double sz2,
438  double sx3, double sy3, double sz3,
439  double sx4, double sy4, double sz4,
440  double sthickness=0.0) {
441 
442  thickness = sthickness;
443 
444  x[0] = sx1;
445  y[0] = sy1;
446  z[0] = sz1;
447 
448  x[1] = sx2;
449  y[1] = sy2;
450  z[1] = sz2;
451 
452  x[2] = sx3;
453  y[2] = sy3;
454  z[2] = sz3;
455 
456  x[3] = sx4;
457  y[3] = sy4;
458  z[3] = sz4;
459  }
460 
462  double thickness;
463 
465  double x[4];
466  double y[4];
467  double z[4];
468 };
469 
470 
471 
472 
473 
478 
479 
484 
485 
494  DL_SplineData(int degree,
495  int nKnots,
496  int nControl,
497  int nFit,
498  int flags) :
499  degree(degree),
500  nKnots(nKnots),
501  nControl(nControl),
502  nFit(nFit),
503  flags(flags) {
504  }
505 
507  unsigned int degree;
508 
510  unsigned int nKnots;
511 
513  unsigned int nControl;
514 
516  unsigned int nFit;
517 
519  int flags;
520 
524  double tangentEndX;
525  double tangentEndY;
526  double tangentEndZ;
527 };
528 
529 
530 
540  DL_KnotData(double pk) {
541  k = pk;
542  }
543 
545  double k;
546 };
547 
548 
549 
558  DL_ControlPointData(double px, double py, double pz, double weight) {
559  x = px;
560  y = py;
561  z = pz;
562  w = weight;
563  }
564 
566  double x;
568  double y;
570  double z;
572  double w;
573 };
574 
575 
576 
585  DL_FitPointData(double x, double y, double z) : x(x), y(y), z(z) {}
586 
588  double x;
590  double y;
592  double z;
593 };
594 
595 
596 
605  DL_EllipseData(double cx, double cy, double cz,
606  double mx, double my, double mz,
607  double ratio,
608  double angle1, double angle2)
609  : cx(cx),
610  cy(cy),
611  cz(cz),
612  mx(mx),
613  my(my),
614  mz(mz),
615  ratio(ratio),
616  angle1(angle1),
617  angle2(angle2) {
618  }
619 
621  double cx;
623  double cy;
625  double cz;
626 
628  double mx;
630  double my;
632  double mz;
633 
635  double ratio;
637  double angle1;
639  double angle2;
640 };
641 
642 
643 
652  DL_InsertData(const std::string& name,
653  double ipx, double ipy, double ipz,
654  double sx, double sy, double sz,
655  double angle,
656  int cols, int rows,
657  double colSp, double rowSp) :
658  name(name),
659  ipx(ipx), ipy(ipy), ipz(ipz),
660  sx(sx), sy(sy), sz(sz),
661  angle(angle),
662  cols(cols), rows(rows),
663  colSp(colSp), rowSp(rowSp) {
664  }
665 
667  std::string name;
669  double ipx;
671  double ipy;
673  double ipz;
675  double sx;
677  double sy;
679  double sz;
681  double angle;
683  int cols;
685  int rows;
687  double colSp;
689  double rowSp;
690 };
691 
692 
693 
702  DL_MTextData(double ipx, double ipy, double ipz,
703  double dirx, double diry, double dirz,
704  double height, double width,
705  int attachmentPoint,
706  int drawingDirection,
707  int lineSpacingStyle,
708  double lineSpacingFactor,
709  const std::string& text,
710  const std::string& style,
711  double angle) :
712  ipx(ipx), ipy(ipy), ipz(ipz),
713  dirx(dirx), diry(diry), dirz(dirz),
714  height(height), width(width),
715  attachmentPoint(attachmentPoint),
716  drawingDirection(drawingDirection),
717  lineSpacingStyle(lineSpacingStyle),
718  lineSpacingFactor(lineSpacingFactor),
719  text(text),
720  style(style),
721  angle(angle) {
722 
723  }
724 
726  double ipx;
728  double ipy;
730  double ipz;
732  double dirx;
734  double diry;
736  double dirz;
738  double height;
740  double width;
766  std::string text;
768  std::string style;
770  double angle;
771 };
772 
773 
774 
783  DL_TextData(double ipx, double ipy, double ipz,
784  double apx, double apy, double apz,
785  double height, double xScaleFactor,
786  int textGenerationFlags,
787  int hJustification,
788  int vJustification,
789  const std::string& text,
790  const std::string& style,
791  double angle)
792  : ipx(ipx), ipy(ipy), ipz(ipz),
793  apx(apx), apy(apy), apz(apz),
794  height(height), xScaleFactor(xScaleFactor),
795  textGenerationFlags(textGenerationFlags),
796  hJustification(hJustification),
797  vJustification(vJustification),
798  text(text),
799  style(style),
800  angle(angle) {
801  }
802 
804  double ipx;
806  double ipy;
808  double ipz;
809 
811  double apx;
813  double apy;
815  double apz;
816 
818  double height;
820  double xScaleFactor;
838  std::string text;
840  std::string style;
842  double angle;
843 };
844 
845 
846 
855  DL_DimensionData(double dpx, double dpy, double dpz,
856  double mpx, double mpy, double mpz,
857  int type,
858  int attachmentPoint,
859  int lineSpacingStyle,
860  double lineSpacingFactor,
861  const std::string& text,
862  const std::string& style,
863  double angle,
864  double linearFactor = 1.0) :
865  dpx(dpx), dpy(dpy), dpz(dpz),
866  mpx(mpx), mpy(mpy), mpz(mpz),
867  type(type),
868  attachmentPoint(attachmentPoint),
869  lineSpacingStyle(lineSpacingStyle),
870  lineSpacingFactor(lineSpacingFactor),
871  text(text),
872  style(style),
873  angle(angle),
874  linearFactor(linearFactor) {
875 
876  }
877 
879  double dpx;
881  double dpy;
883  double dpz;
885  double mpx;
887  double mpy;
889  double mpz;
909  int type;
935  std::string text;
937  std::string style;
942  double angle;
946  double linearFactor;
947 };
948 
949 
950 
959  DL_DimAlignedData(double depx1, double depy1, double depz1,
960  double depx2, double depy2, double depz2) {
961 
962  epx1 = depx1;
963  epy1 = depy1;
964  epz1 = depz1;
965 
966  epx2 = depx2;
967  epy2 = depy2;
968  epz2 = depz2;
969  }
970 
972  double epx1;
974  double epy1;
976  double epz1;
977 
979  double epx2;
981  double epy2;
983  double epz2;
984 };
985 
986 
987 
996  DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1,
997  double ddpx2, double ddpy2, double ddpz2,
998  double dAngle, double dOblique) {
999 
1000  dpx1 = ddpx1;
1001  dpy1 = ddpy1;
1002  dpz1 = ddpz1;
1003 
1004  dpx2 = ddpx2;
1005  dpy2 = ddpy2;
1006  dpz2 = ddpz2;
1007 
1008  angle = dAngle;
1009  oblique = dOblique;
1010  }
1011 
1013  double dpx1;
1015  double dpy1;
1017  double dpz1;
1018 
1020  double dpx2;
1022  double dpy2;
1024  double dpz2;
1025 
1027  double angle;
1029  double oblique;
1030 };
1031 
1032 
1033 
1042  DL_DimRadialData(double ddpx, double ddpy, double ddpz, double dleader) {
1043  dpx = ddpx;
1044  dpy = ddpy;
1045  dpz = ddpz;
1046 
1047  leader = dleader;
1048  }
1049 
1051  double dpx;
1053  double dpy;
1055  double dpz;
1056 
1058  double leader;
1059 };
1060 
1061 
1062 
1071  DL_DimDiametricData(double ddpx, double ddpy, double ddpz, double dleader) {
1072  dpx = ddpx;
1073  dpy = ddpy;
1074  dpz = ddpz;
1075 
1076  leader = dleader;
1077  }
1078 
1080  double dpx;
1082  double dpy;
1084  double dpz;
1085 
1087  double leader;
1088 };
1089 
1090 
1091 
1100  DL_DimAngularData(double ddpx1, double ddpy1, double ddpz1,
1101  double ddpx2, double ddpy2, double ddpz2,
1102  double ddpx3, double ddpy3, double ddpz3,
1103  double ddpx4, double ddpy4, double ddpz4) {
1104 
1105  dpx1 = ddpx1;
1106  dpy1 = ddpy1;
1107  dpz1 = ddpz1;
1108 
1109  dpx2 = ddpx2;
1110  dpy2 = ddpy2;
1111  dpz2 = ddpz2;
1112 
1113  dpx3 = ddpx3;
1114  dpy3 = ddpy3;
1115  dpz3 = ddpz3;
1116 
1117  dpx4 = ddpx4;
1118  dpy4 = ddpy4;
1119  dpz4 = ddpz4;
1120  }
1121 
1123  double dpx1;
1125  double dpy1;
1127  double dpz1;
1128 
1130  double dpx2;
1132  double dpy2;
1134  double dpz2;
1135 
1137  double dpx3;
1139  double dpy3;
1141  double dpz3;
1142 
1144  double dpx4;
1146  double dpy4;
1148  double dpz4;
1149 };
1150 
1151 
1160  DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1,
1161  double ddpx2, double ddpy2, double ddpz2,
1162  double ddpx3, double ddpy3, double ddpz3) {
1163 
1164  dpx1 = ddpx1;
1165  dpy1 = ddpy1;
1166  dpz1 = ddpz1;
1167 
1168  dpx2 = ddpx2;
1169  dpy2 = ddpy2;
1170  dpz2 = ddpz2;
1171 
1172  dpx3 = ddpx3;
1173  dpy3 = ddpy3;
1174  dpz3 = ddpz3;
1175  }
1176 
1178  double dpx1;
1180  double dpy1;
1182  double dpz1;
1183 
1185  double dpx2;
1187  double dpy2;
1189  double dpz2;
1190 
1192  double dpx3;
1194  double dpy3;
1196  double dpz3;
1197 };
1198 
1199 
1200 
1209  DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1,
1210  double ddpx2, double ddpy2, double ddpz2,
1211  bool dxtype) {
1212 
1213  dpx1 = ddpx1;
1214  dpy1 = ddpy1;
1215  dpz1 = ddpz1;
1216 
1217  dpx2 = ddpx2;
1218  dpy2 = ddpy2;
1219  dpz2 = ddpz2;
1220 
1221  xtype = dxtype;
1222  }
1223 
1225  double dpx1;
1227  double dpy1;
1229  double dpz1;
1230 
1232  double dpx2;
1234  double dpy2;
1236  double dpz2;
1237 
1239  bool xtype;
1240 };
1241 
1242 
1243 
1252  DL_LeaderData(int lArrowHeadFlag,
1253  int lLeaderPathType,
1254  int lLeaderCreationFlag,
1255  int lHooklineDirectionFlag,
1256  int lHooklineFlag,
1257  double lTextAnnotationHeight,
1258  double lTextAnnotationWidth,
1259  int lNumber) {
1260 
1261  arrowHeadFlag = lArrowHeadFlag;
1262  leaderPathType = lLeaderPathType;
1263  leaderCreationFlag = lLeaderCreationFlag;
1264  hooklineDirectionFlag = lHooklineDirectionFlag;
1265  hooklineFlag = lHooklineFlag;
1266  textAnnotationHeight = lTextAnnotationHeight;
1267  textAnnotationWidth = lTextAnnotationWidth;
1268  number = lNumber;
1269  }
1270 
1286  int number;
1287 };
1288 
1289 
1290 
1299  DL_LeaderVertexData(double px=0.0, double py=0.0, double pz=0.0) {
1300  x = px;
1301  y = py;
1302  z = pz;
1303  }
1304 
1306  double x;
1308  double y;
1310  double z;
1311 };
1312 
1313 
1314 
1323 
1328  DL_HatchData(int numLoops,
1329  bool solid,
1330  double scale,
1331  double angle,
1332  const std::string& pattern,
1333  double originX = 0.0,
1334  double originY = 0.0) :
1335  numLoops(numLoops),
1336  solid(solid),
1337  scale(scale),
1338  angle(angle),
1339  pattern(pattern),
1340  originX(originX),
1341  originY(originY) {
1342 
1343  }
1344 
1348  bool solid;
1350  double scale;
1352  double angle;
1354  std::string pattern;
1356  double originX;
1357  double originY;
1358 };
1359 
1360 
1361 
1374  DL_HatchLoopData(int hNumEdges) {
1375  numEdges = hNumEdges;
1376  }
1377 
1380 };
1381 
1382 
1383 
1391  DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0) {
1392  }
1393 
1398  DL_HatchEdgeData(double x1, double y1,
1399  double x2, double y2) :
1400  defined(true),
1401  type(1),
1402  x1(x1),
1403  y1(y1),
1404  x2(x2),
1405  y2(y2) {
1406  }
1407 
1412  DL_HatchEdgeData(double cx, double cy,
1413  double radius,
1414  double angle1, double angle2,
1415  bool ccw) :
1416  defined(true),
1417  type(2),
1418  cx(cx),
1419  cy(cy),
1420  radius(radius),
1421  angle1(angle1),
1422  angle2(angle2),
1423  ccw(ccw) {
1424  }
1425 
1430  DL_HatchEdgeData(double cx, double cy,
1431  double mx, double my,
1432  double ratio,
1433  double angle1, double angle2,
1434  bool ccw) :
1435  defined(true),
1436  type(3),
1437  cx(cx),
1438  cy(cy),
1439  angle1(angle1),
1440  angle2(angle2),
1441  ccw(ccw),
1442  mx(mx),
1443  my(my),
1444  ratio(ratio) {
1445  }
1446 
1451  DL_HatchEdgeData(unsigned int degree,
1452  bool rational,
1453  bool periodic,
1454  unsigned int nKnots,
1455  unsigned int nControl,
1456  unsigned int nFit,
1457  const std::vector<double>& knots,
1458  const std::vector<std::vector<double> >& controlPoints,
1459  const std::vector<std::vector<double> >& fitPoints,
1460  const std::vector<double>& weights,
1461  double startTangentX,
1462  double startTangentY,
1463  double endTangentX,
1464  double endTangentY) :
1465  defined(true),
1466  type(4),
1467  degree(degree),
1468  rational(rational),
1469  periodic(periodic),
1470  nKnots(nKnots),
1471  nControl(nControl),
1472  nFit(nFit),
1473  controlPoints(controlPoints),
1474  knots(knots),
1475  weights(weights),
1476  fitPoints(fitPoints),
1477  startTangentX(startTangentX),
1478  startTangentY(startTangentY),
1479  endTangentX(endTangentX),
1480  endTangentY(endTangentY) {
1481  }
1482 
1486  bool defined;
1487 
1491  int type;
1492 
1493  // line edges:
1494 
1496  double x1;
1498  double y1;
1500  double x2;
1502  double y2;
1503 
1505  double cx;
1507  double cy;
1509  double radius;
1511  double angle1;
1513  double angle2;
1515  bool ccw;
1516 
1518  double mx;
1520  double my;
1522  double ratio;
1523 
1524 
1526  unsigned int degree;
1527  bool rational;
1528  bool periodic;
1530  unsigned int nKnots;
1532  unsigned int nControl;
1534  unsigned int nFit;
1535 
1536  std::vector<std::vector<double> > controlPoints;
1537  std::vector<double> knots;
1538  std::vector<double> weights;
1539  std::vector<std::vector<double> > fitPoints;
1540 
1543 
1544  double endTangentX;
1545  double endTangentY;
1546 
1548  std::vector<std::vector<double> > vertices;
1549  //bool closed;
1550 };
1551 
1552 
1553 
1562  DL_ImageData(const std::string& iref,
1563  double iipx, double iipy, double iipz,
1564  double iux, double iuy, double iuz,
1565  double ivx, double ivy, double ivz,
1566  int iwidth, int iheight,
1567  int ibrightness, int icontrast, int ifade) {
1568  ref = iref;
1569  ipx = iipx;
1570  ipy = iipy;
1571  ipz = iipz;
1572  ux = iux;
1573  uy = iuy;
1574  uz = iuz;
1575  vx = ivx;
1576  vy = ivy;
1577  vz = ivz;
1578  width = iwidth;
1579  height = iheight;
1580  brightness = ibrightness;
1581  contrast = icontrast;
1582  fade = ifade;
1583  }
1584 
1587  std::string ref;
1589  double ipx;
1591  double ipy;
1593  double ipz;
1595  double ux;
1597  double uy;
1599  double uz;
1601  double vx;
1603  double vy;
1605  double vz;
1607  int width;
1609  int height;
1615  int fade;
1616 };
1617 
1618 
1619 
1628  DL_ImageDefData(const std::string& iref,
1629  const std::string& ifile) {
1630  ref = iref;
1631  file = ifile;
1632  }
1633 
1636  std::string ref;
1637 
1639  std::string file;
1640 };
1641 
1642 
1643 
1648  DL_DictionaryData(const std::string& handle) : handle(handle) {}
1649  std::string handle;
1650 };
1651 
1652 
1653 
1658  DL_DictionaryEntryData(const std::string& name, const std::string& handle) :
1659  name(name), handle(handle) {}
1660 
1661  std::string name;
1662  std::string handle;
1663 };
1664 
1665 #endif
1666 
1667 // EOF