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 
234 
235 
244  DL_ArcData(double acx, double acy, double acz,
245  double aRadius,
246  double aAngle1, double aAngle2) {
247 
248  cx = acx;
249  cy = acy;
250  cz = acz;
251  radius = aRadius;
252  angle1 = aAngle1;
253  angle2 = aAngle2;
254  }
255 
257  double cx;
259  double cy;
261  double cz;
262 
264  double radius;
266  double angle1;
268  double angle2;
269 };
270 
271 
272 
281  DL_CircleData(double acx, double acy, double acz,
282  double aRadius) {
283 
284  cx = acx;
285  cy = acy;
286  cz = acz;
287  radius = aRadius;
288  }
289 
291  double cx;
293  double cy;
295  double cz;
296 
298  double radius;
299 };
300 
301 
302 
311  DL_PolylineData(int pNumber, int pMVerteces, int pNVerteces, int pFlags) {
312  number = pNumber;
313  m = pMVerteces;
314  n = pNVerteces;
315  flags = pFlags;
316  }
317 
319  unsigned int number;
320 
322  unsigned int m;
323 
325  unsigned int n;
326 
328  int flags;
329 };
330 
331 
332 
341  DL_VertexData(double px=0.0, double py=0.0, double pz=0.0,
342  double pBulge=0.0) {
343  x = px;
344  y = py;
345  z = pz;
346  bulge = pBulge;
347  }
348 
350  double x;
352  double y;
354  double z;
357  double bulge;
358 };
359 
360 
366  thickness = 0.0;
367  for (int i=0; i<4; i++) {
368  x[i] = 0.0;
369  y[i] = 0.0;
370  z[i] = 0.0;
371  }
372  }
373 
378  DL_TraceData(double sx1, double sy1, double sz1,
379  double sx2, double sy2, double sz2,
380  double sx3, double sy3, double sz3,
381  double sx4, double sy4, double sz4,
382  double sthickness=0.0) {
383 
384  thickness = sthickness;
385 
386  x[0] = sx1;
387  y[0] = sy1;
388  z[0] = sz1;
389 
390  x[1] = sx2;
391  y[1] = sy2;
392  z[1] = sz2;
393 
394  x[2] = sx3;
395  y[2] = sy3;
396  z[2] = sz3;
397 
398  x[3] = sx4;
399  y[3] = sy4;
400  z[3] = sz4;
401  }
402 
404  double thickness;
405 
407  double x[4];
408  double y[4];
409  double z[4];
410 };
411 
412 
413 
414 
415 
420 
421 
426 
427 
436  DL_SplineData(int degree,
437  int nKnots,
438  int nControl,
439  int nFit,
440  int flags) :
441  degree(degree),
442  nKnots(nKnots),
443  nControl(nControl),
444  nFit(nFit),
445  flags(flags) {
446  }
447 
449  unsigned int degree;
450 
452  unsigned int nKnots;
453 
455  unsigned int nControl;
456 
458  unsigned int nFit;
459 
461  int flags;
462 
466  double tangentEndX;
467  double tangentEndY;
468  double tangentEndZ;
469 };
470 
471 
472 
482  DL_KnotData(double pk) {
483  k = pk;
484  }
485 
487  double k;
488 };
489 
490 
491 
500  DL_ControlPointData(double px, double py, double pz, double weight) {
501  x = px;
502  y = py;
503  z = pz;
504  w = weight;
505  }
506 
508  double x;
510  double y;
512  double z;
514  double w;
515 };
516 
517 
518 
527  DL_FitPointData(double x, double y, double z) : x(x), y(y), z(z) {}
528 
530  double x;
532  double y;
534  double z;
535 };
536 
537 
538 
547  DL_EllipseData(double cx, double cy, double cz,
548  double mx, double my, double mz,
549  double ratio,
550  double angle1, double angle2)
551  : cx(cx),
552  cy(cy),
553  cz(cz),
554  mx(mx),
555  my(my),
556  mz(mz),
557  ratio(ratio),
558  angle1(angle1),
559  angle2(angle2) {
560  }
561 
563  double cx;
565  double cy;
567  double cz;
568 
570  double mx;
572  double my;
574  double mz;
575 
577  double ratio;
579  double angle1;
581  double angle2;
582 };
583 
584 
585 
594  DL_InsertData(const std::string& name,
595  double ipx, double ipy, double ipz,
596  double sx, double sy, double sz,
597  double angle,
598  int cols, int rows,
599  double colSp, double rowSp) :
600  name(name),
601  ipx(ipx), ipy(ipy), ipz(ipz),
602  sx(sx), sy(sy), sz(sz),
603  angle(angle),
604  cols(cols), rows(rows),
605  colSp(colSp), rowSp(rowSp) {
606  }
607 
609  std::string name;
611  double ipx;
613  double ipy;
615  double ipz;
617  double sx;
619  double sy;
621  double sz;
623  double angle;
625  int cols;
627  int rows;
629  double colSp;
631  double rowSp;
632 };
633 
634 
635 
644  DL_MTextData(double ipx, double ipy, double ipz,
645  double dirx, double diry, double dirz,
646  double height, double width,
647  int attachmentPoint,
648  int drawingDirection,
649  int lineSpacingStyle,
650  double lineSpacingFactor,
651  const std::string& text,
652  const std::string& style,
653  double angle) :
654  ipx(ipx), ipy(ipy), ipz(ipz),
655  dirx(dirx), diry(diry), dirz(dirz),
656  height(height), width(width),
657  attachmentPoint(attachmentPoint),
658  drawingDirection(drawingDirection),
659  lineSpacingStyle(lineSpacingStyle),
660  lineSpacingFactor(lineSpacingFactor),
661  text(text),
662  style(style),
663  angle(angle) {
664 
665  }
666 
668  double ipx;
670  double ipy;
672  double ipz;
674  double dirx;
676  double diry;
678  double dirz;
680  double height;
682  double width;
708  std::string text;
710  std::string style;
712  double angle;
713 };
714 
715 
716 
725  DL_TextData(double ipx, double ipy, double ipz,
726  double apx, double apy, double apz,
727  double height, double xScaleFactor,
728  int textGenerationFlags,
729  int hJustification,
730  int vJustification,
731  const std::string& text,
732  const std::string& style,
733  double angle)
734  : ipx(ipx), ipy(ipy), ipz(ipz),
735  apx(apx), apy(apy), apz(apz),
736  height(height), xScaleFactor(xScaleFactor),
737  textGenerationFlags(textGenerationFlags),
738  hJustification(hJustification),
739  vJustification(vJustification),
740  text(text),
741  style(style),
742  angle(angle) {
743  }
744 
746  double ipx;
748  double ipy;
750  double ipz;
751 
753  double apx;
755  double apy;
757  double apz;
758 
760  double height;
762  double xScaleFactor;
780  std::string text;
782  std::string style;
784  double angle;
785 };
786 
787 
788 
797  DL_DimensionData(double dpx, double dpy, double dpz,
798  double mpx, double mpy, double mpz,
799  int type,
800  int attachmentPoint,
801  int lineSpacingStyle,
802  double lineSpacingFactor,
803  const std::string& text,
804  const std::string& style,
805  double angle,
806  double linearFactor = 1.0) :
807  dpx(dpx), dpy(dpy), dpz(dpz),
808  mpx(mpx), mpy(mpy), mpz(mpz),
809  type(type),
810  attachmentPoint(attachmentPoint),
811  lineSpacingStyle(lineSpacingStyle),
812  lineSpacingFactor(lineSpacingFactor),
813  text(text),
814  style(style),
815  angle(angle),
816  linearFactor(linearFactor) {
817 
818  }
819 
821  double dpx;
823  double dpy;
825  double dpz;
827  double mpx;
829  double mpy;
831  double mpz;
851  int type;
877  std::string text;
879  std::string style;
884  double angle;
888  double linearFactor;
889 };
890 
891 
892 
901  DL_DimAlignedData(double depx1, double depy1, double depz1,
902  double depx2, double depy2, double depz2) {
903 
904  epx1 = depx1;
905  epy1 = depy1;
906  epz1 = depz1;
907 
908  epx2 = depx2;
909  epy2 = depy2;
910  epz2 = depz2;
911  }
912 
914  double epx1;
916  double epy1;
918  double epz1;
919 
921  double epx2;
923  double epy2;
925  double epz2;
926 };
927 
928 
929 
938  DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1,
939  double ddpx2, double ddpy2, double ddpz2,
940  double dAngle, double dOblique) {
941 
942  dpx1 = ddpx1;
943  dpy1 = ddpy1;
944  dpz1 = ddpz1;
945 
946  dpx2 = ddpx2;
947  dpy2 = ddpy2;
948  dpz2 = ddpz2;
949 
950  angle = dAngle;
951  oblique = dOblique;
952  }
953 
955  double dpx1;
957  double dpy1;
959  double dpz1;
960 
962  double dpx2;
964  double dpy2;
966  double dpz2;
967 
969  double angle;
971  double oblique;
972 };
973 
974 
975 
984  DL_DimRadialData(double ddpx, double ddpy, double ddpz, double dleader) {
985  dpx = ddpx;
986  dpy = ddpy;
987  dpz = ddpz;
988 
989  leader = dleader;
990  }
991 
993  double dpx;
995  double dpy;
997  double dpz;
998 
1000  double leader;
1001 };
1002 
1003 
1004 
1013  DL_DimDiametricData(double ddpx, double ddpy, double ddpz, double dleader) {
1014  dpx = ddpx;
1015  dpy = ddpy;
1016  dpz = ddpz;
1017 
1018  leader = dleader;
1019  }
1020 
1022  double dpx;
1024  double dpy;
1026  double dpz;
1027 
1029  double leader;
1030 };
1031 
1032 
1033 
1042  DL_DimAngularData(double ddpx1, double ddpy1, double ddpz1,
1043  double ddpx2, double ddpy2, double ddpz2,
1044  double ddpx3, double ddpy3, double ddpz3,
1045  double ddpx4, double ddpy4, double ddpz4) {
1046 
1047  dpx1 = ddpx1;
1048  dpy1 = ddpy1;
1049  dpz1 = ddpz1;
1050 
1051  dpx2 = ddpx2;
1052  dpy2 = ddpy2;
1053  dpz2 = ddpz2;
1054 
1055  dpx3 = ddpx3;
1056  dpy3 = ddpy3;
1057  dpz3 = ddpz3;
1058 
1059  dpx4 = ddpx4;
1060  dpy4 = ddpy4;
1061  dpz4 = ddpz4;
1062  }
1063 
1065  double dpx1;
1067  double dpy1;
1069  double dpz1;
1070 
1072  double dpx2;
1074  double dpy2;
1076  double dpz2;
1077 
1079  double dpx3;
1081  double dpy3;
1083  double dpz3;
1084 
1086  double dpx4;
1088  double dpy4;
1090  double dpz4;
1091 };
1092 
1093 
1102  DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1,
1103  double ddpx2, double ddpy2, double ddpz2,
1104  double ddpx3, double ddpy3, double ddpz3) {
1105 
1106  dpx1 = ddpx1;
1107  dpy1 = ddpy1;
1108  dpz1 = ddpz1;
1109 
1110  dpx2 = ddpx2;
1111  dpy2 = ddpy2;
1112  dpz2 = ddpz2;
1113 
1114  dpx3 = ddpx3;
1115  dpy3 = ddpy3;
1116  dpz3 = ddpz3;
1117  }
1118 
1120  double dpx1;
1122  double dpy1;
1124  double dpz1;
1125 
1127  double dpx2;
1129  double dpy2;
1131  double dpz2;
1132 
1134  double dpx3;
1136  double dpy3;
1138  double dpz3;
1139 };
1140 
1141 
1142 
1151  DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1,
1152  double ddpx2, double ddpy2, double ddpz2,
1153  bool dxtype) {
1154 
1155  dpx1 = ddpx1;
1156  dpy1 = ddpy1;
1157  dpz1 = ddpz1;
1158 
1159  dpx2 = ddpx2;
1160  dpy2 = ddpy2;
1161  dpz2 = ddpz2;
1162 
1163  xtype = dxtype;
1164  }
1165 
1167  double dpx1;
1169  double dpy1;
1171  double dpz1;
1172 
1174  double dpx2;
1176  double dpy2;
1178  double dpz2;
1179 
1181  bool xtype;
1182 };
1183 
1184 
1185 
1194  DL_LeaderData(int lArrowHeadFlag,
1195  int lLeaderPathType,
1196  int lLeaderCreationFlag,
1197  int lHooklineDirectionFlag,
1198  int lHooklineFlag,
1199  double lTextAnnotationHeight,
1200  double lTextAnnotationWidth,
1201  int lNumber) {
1202 
1203  arrowHeadFlag = lArrowHeadFlag;
1204  leaderPathType = lLeaderPathType;
1205  leaderCreationFlag = lLeaderCreationFlag;
1206  hooklineDirectionFlag = lHooklineDirectionFlag;
1207  hooklineFlag = lHooklineFlag;
1208  textAnnotationHeight = lTextAnnotationHeight;
1209  textAnnotationWidth = lTextAnnotationWidth;
1210  number = lNumber;
1211  }
1212 
1228  int number;
1229 };
1230 
1231 
1232 
1241  DL_LeaderVertexData(double px=0.0, double py=0.0, double pz=0.0) {
1242  x = px;
1243  y = py;
1244  z = pz;
1245  }
1246 
1248  double x;
1250  double y;
1252  double z;
1253 };
1254 
1255 
1256 
1265 
1270  DL_HatchData(int numLoops,
1271  bool solid,
1272  double scale,
1273  double angle,
1274  const std::string& pattern,
1275  double originX = 0.0,
1276  double originY = 0.0) :
1277  numLoops(numLoops),
1278  solid(solid),
1279  scale(scale),
1280  angle(angle),
1281  pattern(pattern),
1282  originX(originX),
1283  originY(originY) {
1284 
1285  }
1286 
1290  bool solid;
1292  double scale;
1294  double angle;
1296  std::string pattern;
1298  double originX;
1299  double originY;
1300 };
1301 
1302 
1303 
1316  DL_HatchLoopData(int hNumEdges) {
1317  numEdges = hNumEdges;
1318  }
1319 
1322 };
1323 
1324 
1325 
1333  DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0) {
1334  }
1335 
1340  DL_HatchEdgeData(double x1, double y1,
1341  double x2, double y2) :
1342  defined(true),
1343  type(1),
1344  x1(x1),
1345  y1(y1),
1346  x2(x2),
1347  y2(y2) {
1348  }
1349 
1354  DL_HatchEdgeData(double cx, double cy,
1355  double radius,
1356  double angle1, double angle2,
1357  bool ccw) :
1358  defined(true),
1359  type(2),
1360  cx(cx),
1361  cy(cy),
1362  radius(radius),
1363  angle1(angle1),
1364  angle2(angle2),
1365  ccw(ccw) {
1366  }
1367 
1372  DL_HatchEdgeData(double cx, double cy,
1373  double mx, double my,
1374  double ratio,
1375  double angle1, double angle2,
1376  bool ccw) :
1377  defined(true),
1378  type(3),
1379  cx(cx),
1380  cy(cy),
1381  angle1(angle1),
1382  angle2(angle2),
1383  ccw(ccw),
1384  mx(mx),
1385  my(my),
1386  ratio(ratio) {
1387  }
1388 
1393  DL_HatchEdgeData(unsigned int degree,
1394  bool rational,
1395  bool periodic,
1396  unsigned int nKnots,
1397  unsigned int nControl,
1398  unsigned int nFit,
1399  const std::vector<double>& knots,
1400  const std::vector<std::vector<double> >& controlPoints,
1401  const std::vector<std::vector<double> >& fitPoints,
1402  const std::vector<double>& weights,
1403  double startTangentX,
1404  double startTangentY,
1405  double endTangentX,
1406  double endTangentY) :
1407  defined(true),
1408  type(4),
1409  degree(degree),
1410  rational(rational),
1411  periodic(periodic),
1412  nKnots(nKnots),
1413  nControl(nControl),
1414  nFit(nFit),
1415  controlPoints(controlPoints),
1416  knots(knots),
1417  weights(weights),
1418  fitPoints(fitPoints),
1419  startTangentX(startTangentX),
1420  startTangentY(startTangentY),
1421  endTangentX(endTangentX),
1422  endTangentY(endTangentY) {
1423  }
1424 
1428  bool defined;
1429 
1433  int type;
1434 
1435  // line edges:
1436 
1438  double x1;
1440  double y1;
1442  double x2;
1444  double y2;
1445 
1447  double cx;
1449  double cy;
1451  double radius;
1453  double angle1;
1455  double angle2;
1457  bool ccw;
1458 
1460  double mx;
1462  double my;
1464  double ratio;
1465 
1466 
1468  unsigned int degree;
1469  bool rational;
1470  bool periodic;
1472  unsigned int nKnots;
1474  unsigned int nControl;
1476  unsigned int nFit;
1477 
1478  std::vector<std::vector<double> > controlPoints;
1479  std::vector<double> knots;
1480  std::vector<double> weights;
1481  std::vector<std::vector<double> > fitPoints;
1482 
1485 
1486  double endTangentX;
1487  double endTangentY;
1488 
1490  std::vector<std::vector<double> > vertices;
1491  //bool closed;
1492 };
1493 
1494 
1495 
1504  DL_ImageData(const std::string& iref,
1505  double iipx, double iipy, double iipz,
1506  double iux, double iuy, double iuz,
1507  double ivx, double ivy, double ivz,
1508  int iwidth, int iheight,
1509  int ibrightness, int icontrast, int ifade) {
1510  ref = iref;
1511  ipx = iipx;
1512  ipy = iipy;
1513  ipz = iipz;
1514  ux = iux;
1515  uy = iuy;
1516  uz = iuz;
1517  vx = ivx;
1518  vy = ivy;
1519  vz = ivz;
1520  width = iwidth;
1521  height = iheight;
1522  brightness = ibrightness;
1523  contrast = icontrast;
1524  fade = ifade;
1525  }
1526 
1529  std::string ref;
1531  double ipx;
1533  double ipy;
1535  double ipz;
1537  double ux;
1539  double uy;
1541  double uz;
1543  double vx;
1545  double vy;
1547  double vz;
1549  int width;
1551  int height;
1557  int fade;
1558 };
1559 
1560 
1561 
1570  DL_ImageDefData(const std::string& iref,
1571  const std::string& ifile) {
1572  ref = iref;
1573  file = ifile;
1574  }
1575 
1578  std::string ref;
1579 
1581  std::string file;
1582 };
1583 
1584 
1585 
1590  DL_DictionaryData(const std::string& handle) : handle(handle) {}
1591  std::string handle;
1592 };
1593 
1594 
1595 
1600  DL_DictionaryEntryData(const std::string& name, const std::string& handle) :
1601  name(name), handle(handle) {}
1602 
1603  std::string name;
1604  std::string handle;
1605 };
1606 
1607 #endif
1608 
1609 // EOF