QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 info@ribbonsoft.com 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, // R12
100  AC1015 // R2000
101  };
102 };
103 
104 
105 // Extended color palette:
106 // The first entry is only for direct indexing starting with [1]
107 // Color 1 is red (1,0,0)
108 const double dxfColors[][3] = {
109  {0,0,0}, // unused
110  {1,0,0}, // 1
111  {1,1,0},
112  {0,1,0},
113  {0,1,1},
114  {0,0,1},
115  {1,0,1},
116  {1,1,1}, // black or white
117  {0.5,0.5,0.5},
118  {0.75,0.75,0.75},
119  {1,0,0}, // 10
120  {1,0.5,0.5},
121  {0.65,0,0},
122  {0.65,0.325,0.325},
123  {0.5,0,0},
124  {0.5,0.25,0.25},
125  {0.3,0,0},
126  {0.3,0.15,0.15},
127  {0.15,0,0},
128  {0.15,0.075,0.075},
129  {1,0.25,0}, // 20
130  {1,0.625,0.5},
131  {0.65,0.1625,0},
132  {0.65,0.4063,0.325},
133  {0.5,0.125,0},
134  {0.5,0.3125,0.25},
135  {0.3,0.075,0},
136  {0.3,0.1875,0.15},
137  {0.15,0.0375,0},
138  {0.15,0.0938,0.075},
139  {1,0.5,0}, // 30
140  {1,0.75,0.5},
141  {0.65,0.325,0},
142  {0.65,0.4875,0.325},
143  {0.5,0.25,0},
144  {0.5,0.375,0.25},
145  {0.3,0.15,0},
146  {0.3,0.225,0.15},
147  {0.15,0.075,0},
148  {0.15,0.1125,0.075},
149  {1,0.75,0}, // 40
150  {1,0.875,0.5},
151  {0.65,0.4875,0},
152  {0.65,0.5688,0.325},
153  {0.5,0.375,0},
154  {0.5,0.4375,0.25},
155  {0.3,0.225,0},
156  {0.3,0.2625,0.15},
157  {0.15,0.1125,0},
158  {0.15,0.1313,0.075},
159  {1,1,0}, // 50
160  {1,1,0.5},
161  {0.65,0.65,0},
162  {0.65,0.65,0.325},
163  {0.5,0.5,0},
164  {0.5,0.5,0.25},
165  {0.3,0.3,0},
166  {0.3,0.3,0.15},
167  {0.15,0.15,0},
168  {0.15,0.15,0.075},
169  {0.75,1,0}, // 60
170  {0.875,1,0.5},
171  {0.4875,0.65,0},
172  {0.5688,0.65,0.325},
173  {0.375,0.5,0},
174  {0.4375,0.5,0.25},
175  {0.225,0.3,0},
176  {0.2625,0.3,0.15},
177  {0.1125,0.15,0},
178  {0.1313,0.15,0.075},
179  {0.5,1,0}, // 70
180  {0.75,1,0.5},
181  {0.325,0.65,0},
182  {0.4875,0.65,0.325},
183  {0.25,0.5,0},
184  {0.375,0.5,0.25},
185  {0.15,0.3,0},
186  {0.225,0.3,0.15},
187  {0.075,0.15,0},
188  {0.1125,0.15,0.075},
189  {0.25,1,0}, // 80
190  {0.625,1,0.5},
191  {0.1625,0.65,0},
192  {0.4063,0.65,0.325},
193  {0.125,0.5,0},
194  {0.3125,0.5,0.25},
195  {0.075,0.3,0},
196  {0.1875,0.3,0.15},
197  {0.0375,0.15,0},
198  {0.0938,0.15,0.075},
199  {0,1,0}, // 90
200  {0.5,1,0.5},
201  {0,0.65,0},
202  {0.325,0.65,0.325},
203  {0,0.5,0},
204  {0.25,0.5,0.25},
205  {0,0.3,0},
206  {0.15,0.3,0.15},
207  {0,0.15,0},
208  {0.075,0.15,0.075},
209  {0,1,0.25}, // 100
210  {0.5,1,0.625},
211  {0,0.65,0.1625},
212  {0.325,0.65,0.4063},
213  {0,0.5,0.125},
214  {0.25,0.5,0.3125},
215  {0,0.3,0.075},
216  {0.15,0.3,0.1875},
217  {0,0.15,0.0375},
218  {0.075,0.15,0.0938},
219  {0,1,0.5}, // 110
220  {0.5,1,0.75},
221  {0,0.65,0.325},
222  {0.325,0.65,0.4875},
223  {0,0.5,0.25},
224  {0.25,0.5,0.375},
225  {0,0.3,0.15},
226  {0.15,0.3,0.225},
227  {0,0.15,0.075},
228  {0.075,0.15,0.1125},
229  {0,1,0.75}, // 120
230  {0.5,1,0.875},
231  {0,0.65,0.4875},
232  {0.325,0.65,0.5688},
233  {0,0.5,0.375},
234  {0.25,0.5,0.4375},
235  {0,0.3,0.225},
236  {0.15,0.3,0.2625},
237  {0,0.15,0.1125},
238  {0.075,0.15,0.1313},
239  {0,1,1}, // 130
240  {0.5,1,1},
241  {0,0.65,0.65},
242  {0.325,0.65,0.65},
243  {0,0.5,0.5},
244  {0.25,0.5,0.5},
245  {0,0.3,0.3},
246  {0.15,0.3,0.3},
247  {0,0.15,0.15},
248  {0.075,0.15,0.15},
249  {0,0.75,1}, // 140
250  {0.5,0.875,1},
251  {0,0.4875,0.65},
252  {0.325,0.5688,0.65},
253  {0,0.375,0.5},
254  {0.25,0.4375,0.5},
255  {0,0.225,0.3},
256  {0.15,0.2625,0.3},
257  {0,0.1125,0.15},
258  {0.075,0.1313,0.15},
259  {0,0.5,1}, // 150
260  {0.5,0.75,1},
261  {0,0.325,0.65},
262  {0.325,0.4875,0.65},
263  {0,0.25,0.5},
264  {0.25,0.375,0.5},
265  {0,0.15,0.3},
266  {0.15,0.225,0.3},
267  {0,0.075,0.15},
268  {0.075,0.1125,0.15},
269  {0,0.25,1}, // 160
270  {0.5,0.625,1},
271  {0,0.1625,0.65},
272  {0.325,0.4063,0.65},
273  {0,0.125,0.5},
274  {0.25,0.3125,0.5},
275  {0,0.075,0.3},
276  {0.15,0.1875,0.3},
277  {0,0.0375,0.15},
278  {0.075,0.0938,0.15},
279  {0,0,1}, // 170
280  {0.5,0.5,1},
281  {0,0,0.65},
282  {0.325,0.325,0.65},
283  {0,0,0.5},
284  {0.25,0.25,0.5},
285  {0,0,0.3},
286  {0.15,0.15,0.3},
287  {0,0,0.15},
288  {0.075,0.075,0.15},
289  {0.25,0,1}, // 180
290  {0.625,0.5,1},
291  {0.1625,0,0.65},
292  {0.4063,0.325,0.65},
293  {0.125,0,0.5},
294  {0.3125,0.25,0.5},
295  {0.075,0,0.3},
296  {0.1875,0.15,0.3},
297  {0.0375,0,0.15},
298  {0.0938,0.075,0.15},
299  {0.5,0,1}, // 190
300  {0.75,0.5,1},
301  {0.325,0,0.65},
302  {0.4875,0.325,0.65},
303  {0.25,0,0.5},
304  {0.375,0.25,0.5},
305  {0.15,0,0.3},
306  {0.225,0.15,0.3},
307  {0.075,0,0.15},
308  {0.1125,0.075,0.15},
309  {0.75,0,1}, // 200
310  {0.875,0.5,1},
311  {0.4875,0,0.65},
312  {0.5688,0.325,0.65},
313  {0.375,0,0.5},
314  {0.4375,0.25,0.5},
315  {0.225,0,0.3},
316  {0.2625,0.15,0.3},
317  {0.1125,0,0.15},
318  {0.1313,0.075,0.15},
319  {1,0,1}, // 210
320  {1,0.5,1},
321  {0.65,0,0.65},
322  {0.65,0.325,0.65},
323  {0.5,0,0.5},
324  {0.5,0.25,0.5},
325  {0.3,0,0.3},
326  {0.3,0.15,0.3},
327  {0.15,0,0.15},
328  {0.15,0.075,0.15},
329  {1,0,0.75}, // 220
330  {1,0.5,0.875},
331  {0.65,0,0.4875},
332  {0.65,0.325,0.5688},
333  {0.5,0,0.375},
334  {0.5,0.25,0.4375},
335  {0.3,0,0.225},
336  {0.3,0.15,0.2625},
337  {0.15,0,0.1125},
338  {0.15,0.075,0.1313},
339  {1,0,0.5}, // 230
340  {1,0.5,0.75},
341  {0.65,0,0.325},
342  {0.65,0.325,0.4875},
343  {0.5,0,0.25},
344  {0.5,0.25,0.375},
345  {0.3,0,0.15},
346  {0.3,0.15,0.225},
347  {0.15,0,0.075},
348  {0.15,0.075,0.1125},
349  {1,0,0.25}, // 240
350  {1,0.5,0.625},
351  {0.65,0,0.1625},
352  {0.65,0.325,0.4063},
353  {0.5,0,0.125},
354  {0.5,0.25,0.3125},
355  {0.3,0,0.075},
356  {0.3,0.15,0.1875},
357  {0.15,0,0.0375},
358  {0.15,0.075,0.0938},
359  {0.33,0.33,0.33}, // 250
360  {0.464,0.464,0.464},
361  {0.598,0.598,0.598},
362  {0.732,0.732,0.732},
363  {0.866,0.866,0.866},
364  {1,1,1} // 255
365  }
366  ;
367 
368 
369 // AutoCAD VERSION aliases
370 #define DL_VERSION_R12 DL_Codes::AC1009
371 #define DL_VERSION_LT2 DL_Codes::AC1009
372 #define DL_VERSION_R13 DL_Codes::AC1012 // not supported yet
373 #define DL_VERSION_LT95 DL_Codes::AC1012 // not supported yet
374 #define DL_VERSION_R14 DL_Codes::AC1014 // not supported yet
375 #define DL_VERSION_LT97 DL_Codes::AC1014 // not supported yet
376 #define DL_VERSION_LT98 DL_Codes::AC1014 // not supported yet
377 #define DL_VERSION_2000 DL_Codes::AC1015
378 #define DL_VERSION_2002 DL_Codes::AC1015
379 
380 
381 // DXF Group Codes:
382 
383 // Strings
384 #define DL_STRGRP_START 0
385 #define DL_STRGRP_END 9
386 
387 // Coordinates
388 #define DL_CRDGRP_START 10
389 #define DL_CRDGRP_END 19
390 
391 // Real values
392 #define DL_RLGRP_START 38
393 #define DL_RLGRP_END 59
394 
395 // Short integer values
396 #define DL_SHOGRP_START 60
397 #define DL_SHOGRP_END 79
398 
399 // New in Release 13,
400 #define DL_SUBCLASS 100
401 
402 // More coordinates
403 #define DL_CRD2GRP_START 210
404 #define DL_CRD2GRP_END 239
405 
406 // Extended data strings
407 #define DL_ESTRGRP_START 1000
408 #define DL_ESTRGRP_END 1009
409 
410 // Extended data reals
411 #define DL_ERLGRP_START 1010
412 #define DL_ERLGRP_END 1059
413 
414 
415 #define DL_Y8_COORD_CODE 28
416 #define DL_Z0_COORD_CODE 30
417 #define DL_Z8_COORD_CODE 38
418 
419 #define DL_POINT_COORD_CODE 10
420 #define DL_INSERT_COORD_CODE 10
421 
422 #define DL_CRD2GRP_START 210
423 #define DL_CRD2GRP_END 239
424 
425 #define DL_THICKNESS 39
426 #define DL_FIRST_REAL_CODE THICKNESS
427 #define DL_LAST_REAL_CODE 59
428 #define DL_FIRST_INT_CODE 60
429 #define DL_ATTFLAGS_CODE 70
430 #define DL_PLINE_FLAGS_CODE 70
431 #define DL_LAYER_FLAGS_CODE 70
432 #define DL_FLD_LEN_CODE 73 // Inside ATTRIB resbuf
433 #define DL_LAST_INT_CODE 79
434 #define DL_X_EXTRU_CODE 210
435 #define DL_Y_EXTRU_CODE 220
436 #define DL_Z_EXTRU_CODE 230
437 #define DL_COMMENT_CODE 999
438 
439 // Start and endpoints of a line
440 #define DL_LINE_START_CODE 10 // Followed by x coord
441 #define DL_LINE_END_CODE 11 // Followed by x coord
442 
443 // Some codes used by blocks
444 #define DL_BLOCK_FLAGS_CODE 70 // An int containing flags
445 #define DL_BLOCK_BASE_CODE 10 // Origin of block definition
446 #define DL_XREF_DEPENDENT 16 // If a block contains an XREF
447 #define DL_XREF_RESOLVED 32 // If a XREF resolved ok
448 #define DL_REFERENCED 64 // If a block is ref'd in DWG
449 
450 #define DL_XSCALE_CODE 41
451 #define DL_YSCALE_CODE 42
452 #define DL_ANGLE_CODE 50
453 #define DL_INS_POINT_CODE 10 // Followed by x of ins pnt
454 #define DL_NAME2_CODE 3 // Second appearance of name
455 
456 // Some codes used by circle entities
457 #define DL_CENTER_CODE 10 // Followed by x of center
458 #define DL_RADIUS_CODE 40 // Followd by radius of circle
459 
460 #define DL_COND_OP_CODE -4 // Conditional op,ads_ssget
461 
462 // When using ads_buildlist you MUST use RTDXF0 instead of these
463 #define DL_ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE..
464 #define DL_SES_CODE 0 // Start End String Code
465 #define DL_FILE_SEP_CODE 0 // File separator
466 #define DL_SOT_CODE 0 // Start Of Table
467 #define DL_TEXTVAL_CODE 1
468 #define DL_NAME_CODE 2
469 #define DL_BLOCK_NAME_CODE 2
470 #define DL_SECTION_NAME_CODE 2
471 #define DL_ENT_HAND_CODE 5 // What follows is hexa string
472 #define DL_TXT_STYLE_CODE 7 // Inside attributes
473 #define DL_LAYER_NAME_CODE 8 // What follows is layer name
474 #define DL_FIRST_XCOORD_CODE 10 // Group code x of 1st coord
475 #define DL_FIRST_YCOORD_CODE 20 // Group code y of 1st coord
476 #define DL_FIRST_ZCOORD_CODE 30 // Group code z of 1st coord
477 #define DL_L_START_CODE 10
478 #define DL_L_END_CODE 11
479 #define DL_TXTHI_CODE 40
480 #define DL_SCALE_X_CODE 41
481 #define DL_SCALE_Y_CODE 42
482 #define DL_SCALE_Z_CODE 43
483 #define DL_BULGE_CODE 42 // Used in PLINE verts for arcs
484 #define DL_ROTATION_CODE 50
485 #define DL_COLOUR_CODE 62 // What follows is a color int
486 #define DL_LTYPE_CODE 6 // What follows is a linetype
487 
488 
489 // Attribute flags
490 #define DL_ATTS_FOLLOW_CODE 66
491 #define DL_ATT_TAG_CODE 2
492 #define DL_ATT_VAL_CODE 1
493 #define DL_ATT_FLAGS_CODE 70 // 4 1 bit flags as follows...
494 #define DL_ATT_INVIS_FLAG 1
495 #define DL_ATT_CONST_FLAG 2
496 #define DL_ATT_VERIFY_FLAG 4 // Prompt and verify
497 #define DL_ATT_PRESET_FLAG 8 // No prompt and no verify
498 
499 // PLINE defines
500 // Flags
501 #define DL_OPEN_PLINE 0x00
502 #define DL_CLOSED_PLINE 0x01
503 #define DL_POLYLINE3D 0x80
504 #define DL_PFACE_MESH 0x40
505 #define DL_PGON_MESH 0x10
506 // Vertices follow entity, required in POLYLINES
507 #define DL_VERTS_FOLLOW_CODE 66 // Value should always be 1
508 #define DL_VERTEX_COORD_CODE 10
509 
510 
511 // LAYER flags
512 #define DL_FROZEN 1
513 #define DL_FROZEN_BY_DEF 2
514 #define DL_LOCKED 4
515 #define DL_OBJECT_USED 64 // Object is ref'd in the dwg
516 
517 #define DL_BLOCK_EN_CODE -2 // Block entity definition
518 #define DL_E_NAME -1 // Entity name
519 
520 // Extended data codes
521 #define DL_EXTD_SENTINEL (-3)
522 #define DL_EXTD_STR 1000
523 #define DL_EXTD_APP_NAME 1001
524 #define DL_EXTD_CTL_STR 1002
525 #define DL_EXTD_LYR_STR 1003
526 #define DL_EXTD_CHUNK 1004
527 #define DL_EXTD_HANDLE 1005
528 #define DL_EXTD_POINT 1010
529 #define DL_EXTD_POS 1011
530 #define DL_EXTD_DISP 1012
531 #define DL_EXTD_DIR 1013
532 #define DL_EXTD_FLOAT 1040
533 #define DL_EXTD_DIST 1041
534 #define DL_EXTD_SCALE 1042
535 #define DL_EXTD_INT16 1070
536 #define DL_EXTD_INT32 1071
537 
538 // UCS codes for use in ads_trans
539 #define DL_WCS_TRANS_CODE 0
540 #define DL_UCS_TRANS_CODE 1
541 #define DL_DCS_TRANS_CODE 2
542 #define DL_PCS_TRANS_CODE 3
543 
544 #endif
545