QCAD
Open Source 2D CAD
dl_codes.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved.
3 ** Copyright (C) 2001 Robert J. Campbell Jr.
4 **
5 ** This file is part of the dxflib project.
6 **
7 ** This file is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
11 **
12 ** Licensees holding valid dxflib Professional Edition licenses may use
13 ** this file in accordance with the dxflib Commercial License
14 ** Agreement provided with the Software.
15 **
16 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 **
19 ** See http://www.ribbonsoft.com for further details.
20 **
21 ** Contact [email protected] if any conditions of this licensing are
22 ** not clear to you.
23 **
24 **********************************************************************/
25 
30 #ifndef DXF_CODES_H
31 #define DXF_CODES_H
32 
33 #include "dl_global.h"
34 
35 #if _MSC_VER > 1000
36 #pragma once
37 #endif // _MSC_VER > 1000
38 
39 #if defined(__OS2__)||defined(__EMX__)
40 #define strcasecmp(s,t) stricmp(s,t)
41 #endif
42 
43 #if defined(_WIN32)
44 #define strcasecmp(s,t) _stricmp(s,t)
45 #endif
46 
47 
48 #ifdef _WIN32
49 #undef M_PI
50 #define M_PI 3.14159265358979323846
51 #pragma warning(disable : 4800)
52 #endif
53 
54 #ifndef M_PI
55 #define M_PI 3.1415926535897932384626433832795
56 #endif
57 
58 #define DL_DXF_MAXLINE 1024
59 #define DL_DXF_MAXGROUPCODE 1100
60 
61 // used to mark invalid vectors:
62 //#define DL_DXF_MAXDOUBLE 1.0E+10
63 
68 public:
72  enum color {
73  black = 250,
74  green = 3,
75  red = 1,
76  brown = 15,
77  yellow = 2,
78  cyan = 4,
79  magenta = 6,
80  gray = 8,
81  blue = 5,
82  l_blue = 163,
83  l_green = 121,
84  l_cyan = 131,
85  l_red = 23,
86  l_magenta = 221,
87  l_gray = 252,
88  white = 7,
89  bylayer = 256,
90  byblock = 0
91  };
92 
96  enum version {
97  AC1009_MIN, // R12, minimalistic
98  AC1009, // R12
101  AC1015 // R2000
102  };
103 };
104 
105 
106 // Extended color palette:
107 // The first entry is only for direct indexing starting with [1]
108 // Color 1 is red (1,0,0)
109 const double dxfColors[][3] = {
110  {0,0,0}, // unused
111  {1,0,0}, // 1
112  {1,1,0},
113  {0,1,0},
114  {0,1,1},
115  {0,0,1},
116  {1,0,1},
117  {1,1,1}, // black or white
118  {0.5,0.5,0.5},
119  {0.75,0.75,0.75},
120  {1,0,0}, // 10
121  {1,0.5,0.5},
122  {0.65,0,0},
123  {0.65,0.325,0.325},
124  {0.5,0,0},
125  {0.5,0.25,0.25},
126  {0.3,0,0},
127  {0.3,0.15,0.15},
128  {0.15,0,0},
129  {0.15,0.075,0.075},
130  {1,0.25,0}, // 20
131  {1,0.625,0.5},
132  {0.65,0.1625,0},
133  {0.65,0.4063,0.325},
134  {0.5,0.125,0},
135  {0.5,0.3125,0.25},
136  {0.3,0.075,0},
137  {0.3,0.1875,0.15},
138  {0.15,0.0375,0},
139  {0.15,0.0938,0.075},
140  {1,0.5,0}, // 30
141  {1,0.75,0.5},
142  {0.65,0.325,0},
143  {0.65,0.4875,0.325},
144  {0.5,0.25,0},
145  {0.5,0.375,0.25},
146  {0.3,0.15,0},
147  {0.3,0.225,0.15},
148  {0.15,0.075,0},
149  {0.15,0.1125,0.075},
150  {1,0.75,0}, // 40
151  {1,0.875,0.5},
152  {0.65,0.4875,0},
153  {0.65,0.5688,0.325},
154  {0.5,0.375,0},
155  {0.5,0.4375,0.25},
156  {0.3,0.225,0},
157  {0.3,0.2625,0.15},
158  {0.15,0.1125,0},
159  {0.15,0.1313,0.075},
160  {1,1,0}, // 50
161  {1,1,0.5},
162  {0.65,0.65,0},
163  {0.65,0.65,0.325},
164  {0.5,0.5,0},
165  {0.5,0.5,0.25},
166  {0.3,0.3,0},
167  {0.3,0.3,0.15},
168  {0.15,0.15,0},
169  {0.15,0.15,0.075},
170  {0.75,1,0}, // 60
171  {0.875,1,0.5},
172  {0.4875,0.65,0},
173  {0.5688,0.65,0.325},
174  {0.375,0.5,0},
175  {0.4375,0.5,0.25},
176  {0.225,0.3,0},
177  {0.2625,0.3,0.15},
178  {0.1125,0.15,0},
179  {0.1313,0.15,0.075},
180  {0.5,1,0}, // 70
181  {0.75,1,0.5},
182  {0.325,0.65,0},
183  {0.4875,0.65,0.325},
184  {0.25,0.5,0},
185  {0.375,0.5,0.25},
186  {0.15,0.3,0},
187  {0.225,0.3,0.15},
188  {0.075,0.15,0},
189  {0.1125,0.15,0.075},
190  {0.25,1,0}, // 80
191  {0.625,1,0.5},
192  {0.1625,0.65,0},
193  {0.4063,0.65,0.325},
194  {0.125,0.5,0},
195  {0.3125,0.5,0.25},
196  {0.075,0.3,0},
197  {0.1875,0.3,0.15},
198  {0.0375,0.15,0},
199  {0.0938,0.15,0.075},
200  {0,1,0}, // 90
201  {0.5,1,0.5},
202  {0,0.65,0},
203  {0.325,0.65,0.325},
204  {0,0.5,0},
205  {0.25,0.5,0.25},
206  {0,0.3,0},
207  {0.15,0.3,0.15},
208  {0,0.15,0},
209  {0.075,0.15,0.075},
210  {0,1,0.25}, // 100
211  {0.5,1,0.625},
212  {0,0.65,0.1625},
213  {0.325,0.65,0.4063},
214  {0,0.5,0.125},
215  {0.25,0.5,0.3125},
216  {0,0.3,0.075},
217  {0.15,0.3,0.1875},
218  {0,0.15,0.0375},
219  {0.075,0.15,0.0938},
220  {0,1,0.5}, // 110
221  {0.5,1,0.75},
222  {0,0.65,0.325},
223  {0.325,0.65,0.4875},
224  {0,0.5,0.25},
225  {0.25,0.5,0.375},
226  {0,0.3,0.15},
227  {0.15,0.3,0.225},
228  {0,0.15,0.075},
229  {0.075,0.15,0.1125},
230  {0,1,0.75}, // 120
231  {0.5,1,0.875},
232  {0,0.65,0.4875},
233  {0.325,0.65,0.5688},
234  {0,0.5,0.375},
235  {0.25,0.5,0.4375},
236  {0,0.3,0.225},
237  {0.15,0.3,0.2625},
238  {0,0.15,0.1125},
239  {0.075,0.15,0.1313},
240  {0,1,1}, // 130
241  {0.5,1,1},
242  {0,0.65,0.65},
243  {0.325,0.65,0.65},
244  {0,0.5,0.5},
245  {0.25,0.5,0.5},
246  {0,0.3,0.3},
247  {0.15,0.3,0.3},
248  {0,0.15,0.15},
249  {0.075,0.15,0.15},
250  {0,0.75,1}, // 140
251  {0.5,0.875,1},
252  {0,0.4875,0.65},
253  {0.325,0.5688,0.65},
254  {0,0.375,0.5},
255  {0.25,0.4375,0.5},
256  {0,0.225,0.3},
257  {0.15,0.2625,0.3},
258  {0,0.1125,0.15},
259  {0.075,0.1313,0.15},
260  {0,0.5,1}, // 150
261  {0.5,0.75,1},
262  {0,0.325,0.65},
263  {0.325,0.4875,0.65},
264  {0,0.25,0.5},
265  {0.25,0.375,0.5},
266  {0,0.15,0.3},
267  {0.15,0.225,0.3},
268  {0,0.075,0.15},
269  {0.075,0.1125,0.15},
270  {0,0.25,1}, // 160
271  {0.5,0.625,1},
272  {0,0.1625,0.65},
273  {0.325,0.4063,0.65},
274  {0,0.125,0.5},
275  {0.25,0.3125,0.5},
276  {0,0.075,0.3},
277  {0.15,0.1875,0.3},
278  {0,0.0375,0.15},
279  {0.075,0.0938,0.15},
280  {0,0,1}, // 170
281  {0.5,0.5,1},
282  {0,0,0.65},
283  {0.325,0.325,0.65},
284  {0,0,0.5},
285  {0.25,0.25,0.5},
286  {0,0,0.3},
287  {0.15,0.15,0.3},
288  {0,0,0.15},
289  {0.075,0.075,0.15},
290  {0.25,0,1}, // 180
291  {0.625,0.5,1},
292  {0.1625,0,0.65},
293  {0.4063,0.325,0.65},
294  {0.125,0,0.5},
295  {0.3125,0.25,0.5},
296  {0.075,0,0.3},
297  {0.1875,0.15,0.3},
298  {0.0375,0,0.15},
299  {0.0938,0.075,0.15},
300  {0.5,0,1}, // 190
301  {0.75,0.5,1},
302  {0.325,0,0.65},
303  {0.4875,0.325,0.65},
304  {0.25,0,0.5},
305  {0.375,0.25,0.5},
306  {0.15,0,0.3},
307  {0.225,0.15,0.3},
308  {0.075,0,0.15},
309  {0.1125,0.075,0.15},
310  {0.75,0,1}, // 200
311  {0.875,0.5,1},
312  {0.4875,0,0.65},
313  {0.5688,0.325,0.65},
314  {0.375,0,0.5},
315  {0.4375,0.25,0.5},
316  {0.225,0,0.3},
317  {0.2625,0.15,0.3},
318  {0.1125,0,0.15},
319  {0.1313,0.075,0.15},
320  {1,0,1}, // 210
321  {1,0.5,1},
322  {0.65,0,0.65},
323  {0.65,0.325,0.65},
324  {0.5,0,0.5},
325  {0.5,0.25,0.5},
326  {0.3,0,0.3},
327  {0.3,0.15,0.3},
328  {0.15,0,0.15},
329  {0.15,0.075,0.15},
330  {1,0,0.75}, // 220
331  {1,0.5,0.875},
332  {0.65,0,0.4875},
333  {0.65,0.325,0.5688},
334  {0.5,0,0.375},
335  {0.5,0.25,0.4375},
336  {0.3,0,0.225},
337  {0.3,0.15,0.2625},
338  {0.15,0,0.1125},
339  {0.15,0.075,0.1313},
340  {1,0,0.5}, // 230
341  {1,0.5,0.75},
342  {0.65,0,0.325},
343  {0.65,0.325,0.4875},
344  {0.5,0,0.25},
345  {0.5,0.25,0.375},
346  {0.3,0,0.15},
347  {0.3,0.15,0.225},
348  {0.15,0,0.075},
349  {0.15,0.075,0.1125},
350  {1,0,0.25}, // 240
351  {1,0.5,0.625},
352  {0.65,0,0.1625},
353  {0.65,0.325,0.4063},
354  {0.5,0,0.125},
355  {0.5,0.25,0.3125},
356  {0.3,0,0.075},
357  {0.3,0.15,0.1875},
358  {0.15,0,0.0375},
359  {0.15,0.075,0.0938},
360  {0.33,0.33,0.33}, // 250
361  {0.464,0.464,0.464},
362  {0.598,0.598,0.598},
363  {0.732,0.732,0.732},
364  {0.866,0.866,0.866},
365  {1,1,1} // 255
366  }
367  ;
368 
369 
370 // AutoCAD VERSION aliases
371 #define DL_VERSION_R12 DL_Codes::AC1009
372 #define DL_VERSION_LT2 DL_Codes::AC1009
373 #define DL_VERSION_R13 DL_Codes::AC1012 // not supported yet
374 #define DL_VERSION_LT95 DL_Codes::AC1012 // not supported yet
375 #define DL_VERSION_R14 DL_Codes::AC1014 // not supported yet
376 #define DL_VERSION_LT97 DL_Codes::AC1014 // not supported yet
377 #define DL_VERSION_LT98 DL_Codes::AC1014 // not supported yet
378 #define DL_VERSION_2000 DL_Codes::AC1015
379 #define DL_VERSION_2002 DL_Codes::AC1015
380 
381 
382 // DXF Group Codes:
383 
384 // Strings
385 #define DL_STRGRP_START 0
386 #define DL_STRGRP_END 9
387 
388 // Coordinates
389 #define DL_CRDGRP_START 10
390 #define DL_CRDGRP_END 19
391 
392 // Real values
393 #define DL_RLGRP_START 38
394 #define DL_RLGRP_END 59
395 
396 // Short integer values
397 #define DL_SHOGRP_START 60
398 #define DL_SHOGRP_END 79
399 
400 // New in Release 13,
401 #define DL_SUBCLASS 100
402 
403 // More coordinates
404 #define DL_CRD2GRP_START 210
405 #define DL_CRD2GRP_END 239
406 
407 // Extended data strings
408 #define DL_ESTRGRP_START 1000
409 #define DL_ESTRGRP_END 1009
410 
411 // Extended data reals
412 #define DL_ERLGRP_START 1010
413 #define DL_ERLGRP_END 1059
414 
415 
416 #define DL_Y8_COORD_CODE 28
417 #define DL_Z0_COORD_CODE 30
418 #define DL_Z8_COORD_CODE 38
419 
420 #define DL_POINT_COORD_CODE 10
421 #define DL_INSERT_COORD_CODE 10
422 
423 #define DL_CRD2GRP_START 210
424 #define DL_CRD2GRP_END 239
425 
426 #define DL_THICKNESS 39
427 #define DL_FIRST_REAL_CODE THICKNESS
428 #define DL_LAST_REAL_CODE 59
429 #define DL_FIRST_INT_CODE 60
430 #define DL_ATTFLAGS_CODE 70
431 #define DL_PLINE_FLAGS_CODE 70
432 #define DL_LAYER_FLAGS_CODE 70
433 #define DL_FLD_LEN_CODE 73 // Inside ATTRIB resbuf
434 #define DL_LAST_INT_CODE 79
435 #define DL_X_EXTRU_CODE 210
436 #define DL_Y_EXTRU_CODE 220
437 #define DL_Z_EXTRU_CODE 230
438 #define DL_COMMENT_CODE 999
439 
440 // Start and endpoints of a line
441 #define DL_LINE_START_CODE 10 // Followed by x coord
442 #define DL_LINE_END_CODE 11 // Followed by x coord
443 
444 // Some codes used by blocks
445 #define DL_BLOCK_FLAGS_CODE 70 // An int containing flags
446 #define DL_BLOCK_BASE_CODE 10 // Origin of block definition
447 #define DL_XREF_DEPENDENT 16 // If a block contains an XREF
448 #define DL_XREF_RESOLVED 32 // If a XREF resolved ok
449 #define DL_REFERENCED 64 // If a block is ref'd in DWG
450 
451 #define DL_XSCALE_CODE 41
452 #define DL_YSCALE_CODE 42
453 #define DL_ANGLE_CODE 50
454 #define DL_INS_POINT_CODE 10 // Followed by x of ins pnt
455 #define DL_NAME2_CODE 3 // Second appearance of name
456 
457 // Some codes used by circle entities
458 #define DL_CENTER_CODE 10 // Followed by x of center
459 #define DL_RADIUS_CODE 40 // Followd by radius of circle
460 
461 #define DL_COND_OP_CODE -4 // Conditional op,ads_ssget
462 
463 // When using ads_buildlist you MUST use RTDXF0 instead of these
464 #define DL_ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE..
465 #define DL_SES_CODE 0 // Start End String Code
466 #define DL_FILE_SEP_CODE 0 // File separator
467 #define DL_SOT_CODE 0 // Start Of Table
468 #define DL_TEXTVAL_CODE 1
469 #define DL_NAME_CODE 2
470 #define DL_BLOCK_NAME_CODE 2
471 #define DL_SECTION_NAME_CODE 2
472 #define DL_ENT_HAND_CODE 5 // What follows is hexa string
473 #define DL_TXT_STYLE_CODE 7 // Inside attributes
474 #define DL_LAYER_NAME_CODE 8 // What follows is layer name
475 #define DL_FIRST_XCOORD_CODE 10 // Group code x of 1st coord
476 #define DL_FIRST_YCOORD_CODE 20 // Group code y of 1st coord
477 #define DL_FIRST_ZCOORD_CODE 30 // Group code z of 1st coord
478 #define DL_L_START_CODE 10
479 #define DL_L_END_CODE 11
480 #define DL_TXTHI_CODE 40
481 #define DL_SCALE_X_CODE 41
482 #define DL_SCALE_Y_CODE 42
483 #define DL_SCALE_Z_CODE 43
484 #define DL_BULGE_CODE 42 // Used in PLINE verts for arcs
485 #define DL_ROTATION_CODE 50
486 #define DL_COLOUR_CODE 62 // What follows is a color int
487 #define DL_LTYPE_CODE 6 // What follows is a linetype
488 
489 
490 // Attribute flags
491 #define DL_ATTS_FOLLOW_CODE 66
492 #define DL_ATT_TAG_CODE 2
493 #define DL_ATT_VAL_CODE 1
494 #define DL_ATT_FLAGS_CODE 70 // 4 1 bit flags as follows...
495 #define DL_ATT_INVIS_FLAG 1
496 #define DL_ATT_CONST_FLAG 2
497 #define DL_ATT_VERIFY_FLAG 4 // Prompt and verify
498 #define DL_ATT_PRESET_FLAG 8 // No prompt and no verify
499 
500 // PLINE defines
501 // Flags
502 #define DL_OPEN_PLINE 0x00
503 #define DL_CLOSED_PLINE 0x01
504 #define DL_POLYLINE3D 0x08
505 #define DL_PFACE_MESH 0x40
506 #define DL_PGON_MESH 0x10
507 // Vertices follow entity, required in POLYLINES
508 #define DL_VERTS_FOLLOW_CODE 66 // Value should always be 1
509 #define DL_VERTEX_COORD_CODE 10
510 
511 
512 // LAYER flags
513 #define DL_FROZEN 1
514 #define DL_FROZEN_BY_DEF 2
515 #define DL_LOCKED 4
516 #define DL_OBJECT_USED 64 // Object is ref'd in the dwg
517 
518 #define DL_BLOCK_EN_CODE -2 // Block entity definition
519 #define DL_E_NAME -1 // Entity name
520 
521 // Extended data codes
522 #define DL_EXTD_SENTINEL (-3)
523 #define DL_EXTD_STR 1000
524 #define DL_EXTD_APP_NAME 1001
525 #define DL_EXTD_CTL_STR 1002
526 #define DL_EXTD_LYR_STR 1003
527 #define DL_EXTD_CHUNK 1004
528 #define DL_EXTD_HANDLE 1005
529 #define DL_EXTD_POINT 1010
530 #define DL_EXTD_POS 1011
531 #define DL_EXTD_DISP 1012
532 #define DL_EXTD_DIR 1013
533 #define DL_EXTD_FLOAT 1040
534 #define DL_EXTD_DIST 1041
535 #define DL_EXTD_SCALE 1042
536 #define DL_EXTD_INT16 1070
537 #define DL_EXTD_INT32 1071
538 
539 // UCS codes for use in ads_trans
540 #define DL_WCS_TRANS_CODE 0
541 #define DL_UCS_TRANS_CODE 1
542 #define DL_DCS_TRANS_CODE 2
543 #define DL_PCS_TRANS_CODE 3
544 
545 #endif
546 
DL_Codes::version
version
Version numbers for the DXF Format.
Definition: dl_codes.h:96
dl_global.h
dxfColors
const double dxfColors[][3]
Definition: dl_codes.h:109
DL_Codes
Codes for colors and DXF versions.
Definition: dl_codes.h:67
DL_Codes::AC1012
@ AC1012
Definition: dl_codes.h:99
DL_Codes::AC1009
@ AC1009
Definition: dl_codes.h:98
DL_Codes::color
color
Standard DXF colors.
Definition: dl_codes.h:72
DL_Codes::AC1009_MIN
@ AC1009_MIN
Definition: dl_codes.h:97
DXFLIB_EXPORT
#define DXFLIB_EXPORT
Definition: dl_global.h:12
DL_Codes::AC1014
@ AC1014
Definition: dl_codes.h:100