]> Shamusworld >> Repos - architektonas/blob - dxflib/src/dl_codes.h
Fixed problem with MDI activation.
[architektonas] / dxflib / src / dl_codes.h
1 /****************************************************************************
2 ** $Id: dl_codes.h 273 2005-02-28 18:14:39Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 ** Copyright (C) 2001 Robert J. Campbell Jr.
6 **
7 ** This file is part of the dxflib project.
8 **
9 ** This file may be distributed and/or modified under the terms of the
10 ** GNU General Public License version 2 as published by the Free Software
11 ** Foundation and appearing in the file LICENSE.GPL included in the
12 ** packaging of this file.
13 **
14 ** Licensees holding valid dxflib Professional Edition licenses may use 
15 ** this file in accordance with the dxflib Commercial License
16 ** Agreement provided with the Software.
17 **
18 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 **
21 ** See http://www.ribbonsoft.com for further details.
22 **
23 ** Contact info@ribbonsoft.com if any conditions of this licensing are
24 ** not clear to you.
25 **
26 **********************************************************************/
27
28 /**
29  * Defines common DXF codes and constants.
30  */
31
32 #ifndef DXF_CODES_H
33 #define DXF_CODES_H
34
35 #if _MSC_VER > 1000
36 #pragma once
37 #endif // _MSC_VER > 1000
38
39 #if defined(__OS2__)||defined(__EMX__)||defined(_WIN32)
40 #define strcasecmp(s,t) stricmp(s,t)
41 #endif
42
43 #ifdef _WIN32
44 #undef M_PI
45 #define M_PI   3.14159265358979323846
46 #pragma warning(disable : 4800)
47 #endif
48
49 #ifndef M_PI
50 #define M_PI 3.1415926535897932384626433832795
51 #endif
52
53 #define DL_DXF_MAXLINE 1024
54 #define DL_DXF_MAXGROUPCODE 1100
55
56 // used to mark invalid vectors:
57 //#define DL_DXF_MAXDOUBLE 1.0E+10
58
59 /**
60  * Codes for colors and DXF versions.
61  */
62 class DL_Codes {
63 public:
64     /**
65      * Standard DXF colors.
66      */
67     enum color {
68         black = 250,
69         green = 3,
70         red = 1,
71         brown = 15,
72         yellow = 2,
73         cyan = 4,
74         magenta = 6,
75         gray = 8,
76         blue = 5,
77         l_blue = 163,
78         l_green = 121,
79         l_cyan = 131,
80         l_red = 23,
81         l_magenta = 221,
82         l_gray = 252,
83         white = 7,
84         bylayer = 256,
85         byblock = 0
86     };
87
88     /**
89      * Version numbers for the DXF Format.
90      */
91     enum version {
92         AC1009, AC1012, AC1014, AC1015
93     };
94 };
95
96
97 // Extended color palette:
98 // The first entry is only for direct indexing starting with [1]
99 // Color 1 is red (1,0,0)
100 const double dxfColors[][3] = {
101                                   {0,0,0},                // unused
102                                   {1,0,0},                // 1
103                                   {1,1,0},
104                                   {0,1,0},
105                                   {0,1,1},
106                                   {0,0,1},
107                                   {1,0,1},
108                                   {1,1,1},                // black or white
109                                   {0.5,0.5,0.5},
110                                   {0.75,0.75,0.75},
111                                   {1,0,0},                // 10
112                                   {1,0.5,0.5},
113                                   {0.65,0,0},
114                                   {0.65,0.325,0.325},
115                                   {0.5,0,0},
116                                   {0.5,0.25,0.25},
117                                   {0.3,0,0},
118                                   {0.3,0.15,0.15},
119                                   {0.15,0,0},
120                                   {0.15,0.075,0.075},
121                                   {1,0.25,0},             // 20
122                                   {1,0.625,0.5},
123                                   {0.65,0.1625,0},
124                                   {0.65,0.4063,0.325},
125                                   {0.5,0.125,0},
126                                   {0.5,0.3125,0.25},
127                                   {0.3,0.075,0},
128                                   {0.3,0.1875,0.15},
129                                   {0.15,0.0375,0},
130                                   {0.15,0.0938,0.075},
131                                   {1,0.5,0},              // 30
132                                   {1,0.75,0.5},
133                                   {0.65,0.325,0},
134                                   {0.65,0.4875,0.325},
135                                   {0.5,0.25,0},
136                                   {0.5,0.375,0.25},
137                                   {0.3,0.15,0},
138                                   {0.3,0.225,0.15},
139                                   {0.15,0.075,0},
140                                   {0.15,0.1125,0.075},
141                                   {1,0.75,0},             // 40
142                                   {1,0.875,0.5},
143                                   {0.65,0.4875,0},
144                                   {0.65,0.5688,0.325},
145                                   {0.5,0.375,0},
146                                   {0.5,0.4375,0.25},
147                                   {0.3,0.225,0},
148                                   {0.3,0.2625,0.15},
149                                   {0.15,0.1125,0},
150                                   {0.15,0.1313,0.075},
151                                   {1,1,0},                // 50
152                                   {1,1,0.5},
153                                   {0.65,0.65,0},
154                                   {0.65,0.65,0.325},
155                                   {0.5,0.5,0},
156                                   {0.5,0.5,0.25},
157                                   {0.3,0.3,0},
158                                   {0.3,0.3,0.15},
159                                   {0.15,0.15,0},
160                                   {0.15,0.15,0.075},
161                                   {0.75,1,0},             // 60
162                                   {0.875,1,0.5},
163                                   {0.4875,0.65,0},
164                                   {0.5688,0.65,0.325},
165                                   {0.375,0.5,0},
166                                   {0.4375,0.5,0.25},
167                                   {0.225,0.3,0},
168                                   {0.2625,0.3,0.15},
169                                   {0.1125,0.15,0},
170                                   {0.1313,0.15,0.075},
171                                   {0.5,1,0},              // 70
172                                   {0.75,1,0.5},
173                                   {0.325,0.65,0},
174                                   {0.4875,0.65,0.325},
175                                   {0.25,0.5,0},
176                                   {0.375,0.5,0.25},
177                                   {0.15,0.3,0},
178                                   {0.225,0.3,0.15},
179                                   {0.075,0.15,0},
180                                   {0.1125,0.15,0.075},
181                                   {0.25,1,0},             // 80
182                                   {0.625,1,0.5},
183                                   {0.1625,0.65,0},
184                                   {0.4063,0.65,0.325},
185                                   {0.125,0.5,0},
186                                   {0.3125,0.5,0.25},
187                                   {0.075,0.3,0},
188                                   {0.1875,0.3,0.15},
189                                   {0.0375,0.15,0},
190                                   {0.0938,0.15,0.075},
191                                   {0,1,0},                // 90
192                                   {0.5,1,0.5},
193                                   {0,0.65,0},
194                                   {0.325,0.65,0.325},
195                                   {0,0.5,0},
196                                   {0.25,0.5,0.25},
197                                   {0,0.3,0},
198                                   {0.15,0.3,0.15},
199                                   {0,0.15,0},
200                                   {0.075,0.15,0.075},
201                                   {0,1,0.25},             // 100
202                                   {0.5,1,0.625},
203                                   {0,0.65,0.1625},
204                                   {0.325,0.65,0.4063},
205                                   {0,0.5,0.125},
206                                   {0.25,0.5,0.3125},
207                                   {0,0.3,0.075},
208                                   {0.15,0.3,0.1875},
209                                   {0,0.15,0.0375},
210                                   {0.075,0.15,0.0938},
211                                   {0,1,0.5},              // 110
212                                   {0.5,1,0.75},
213                                   {0,0.65,0.325},
214                                   {0.325,0.65,0.4875},
215                                   {0,0.5,0.25},
216                                   {0.25,0.5,0.375},
217                                   {0,0.3,0.15},
218                                   {0.15,0.3,0.225},
219                                   {0,0.15,0.075},
220                                   {0.075,0.15,0.1125},
221                                   {0,1,0.75},             // 120
222                                   {0.5,1,0.875},
223                                   {0,0.65,0.4875},
224                                   {0.325,0.65,0.5688},
225                                   {0,0.5,0.375},
226                                   {0.25,0.5,0.4375},
227                                   {0,0.3,0.225},
228                                   {0.15,0.3,0.2625},
229                                   {0,0.15,0.1125},
230                                   {0.075,0.15,0.1313},
231                                   {0,1,1},                // 130
232                                   {0.5,1,1},
233                                   {0,0.65,0.65},
234                                   {0.325,0.65,0.65},
235                                   {0,0.5,0.5},
236                                   {0.25,0.5,0.5},
237                                   {0,0.3,0.3},
238                                   {0.15,0.3,0.3},
239                                   {0,0.15,0.15},
240                                   {0.075,0.15,0.15},
241                                   {0,0.75,1},             // 140
242                                   {0.5,0.875,1},
243                                   {0,0.4875,0.65},
244                                   {0.325,0.5688,0.65},
245                                   {0,0.375,0.5},
246                                   {0.25,0.4375,0.5},
247                                   {0,0.225,0.3},
248                                   {0.15,0.2625,0.3},
249                                   {0,0.1125,0.15},
250                                   {0.075,0.1313,0.15},
251                                   {0,0.5,1},              // 150
252                                   {0.5,0.75,1},
253                                   {0,0.325,0.65},
254                                   {0.325,0.4875,0.65},
255                                   {0,0.25,0.5},
256                                   {0.25,0.375,0.5},
257                                   {0,0.15,0.3},
258                                   {0.15,0.225,0.3},
259                                   {0,0.075,0.15},
260                                   {0.075,0.1125,0.15},
261                                   {0,0.25,1},             // 160
262                                   {0.5,0.625,1},
263                                   {0,0.1625,0.65},
264                                   {0.325,0.4063,0.65},
265                                   {0,0.125,0.5},
266                                   {0.25,0.3125,0.5},
267                                   {0,0.075,0.3},
268                                   {0.15,0.1875,0.3},
269                                   {0,0.0375,0.15},
270                                   {0.075,0.0938,0.15},
271                                   {0,0,1},                // 170
272                                   {0.5,0.5,1},
273                                   {0,0,0.65},
274                                   {0.325,0.325,0.65},
275                                   {0,0,0.5},
276                                   {0.25,0.25,0.5},
277                                   {0,0,0.3},
278                                   {0.15,0.15,0.3},
279                                   {0,0,0.15},
280                                   {0.075,0.075,0.15},
281                                   {0.25,0,1},             // 180
282                                   {0.625,0.5,1},
283                                   {0.1625,0,0.65},
284                                   {0.4063,0.325,0.65},
285                                   {0.125,0,0.5},
286                                   {0.3125,0.25,0.5},
287                                   {0.075,0,0.3},
288                                   {0.1875,0.15,0.3},
289                                   {0.0375,0,0.15},
290                                   {0.0938,0.075,0.15},
291                                   {0.5,0,1},              // 190
292                                   {0.75,0.5,1},
293                                   {0.325,0,0.65},
294                                   {0.4875,0.325,0.65},
295                                   {0.25,0,0.5},
296                                   {0.375,0.25,0.5},
297                                   {0.15,0,0.3},
298                                   {0.225,0.15,0.3},
299                                   {0.075,0,0.15},
300                                   {0.1125,0.075,0.15},
301                                   {0.75,0,1},             // 200
302                                   {0.875,0.5,1},
303                                   {0.4875,0,0.65},
304                                   {0.5688,0.325,0.65},
305                                   {0.375,0,0.5},
306                                   {0.4375,0.25,0.5},
307                                   {0.225,0,0.3},
308                                   {0.2625,0.15,0.3},
309                                   {0.1125,0,0.15},
310                                   {0.1313,0.075,0.15},
311                                   {1,0,1},                // 210
312                                   {1,0.5,1},
313                                   {0.65,0,0.65},
314                                   {0.65,0.325,0.65},
315                                   {0.5,0,0.5},
316                                   {0.5,0.25,0.5},
317                                   {0.3,0,0.3},
318                                   {0.3,0.15,0.3},
319                                   {0.15,0,0.15},
320                                   {0.15,0.075,0.15},
321                                   {1,0,0.75},             // 220
322                                   {1,0.5,0.875},
323                                   {0.65,0,0.4875},
324                                   {0.65,0.325,0.5688},
325                                   {0.5,0,0.375},
326                                   {0.5,0.25,0.4375},
327                                   {0.3,0,0.225},
328                                   {0.3,0.15,0.2625},
329                                   {0.15,0,0.1125},
330                                   {0.15,0.075,0.1313},
331                                   {1,0,0.5},              // 230
332                                   {1,0.5,0.75},
333                                   {0.65,0,0.325},
334                                   {0.65,0.325,0.4875},
335                                   {0.5,0,0.25},
336                                   {0.5,0.25,0.375},
337                                   {0.3,0,0.15},
338                                   {0.3,0.15,0.225},
339                                   {0.15,0,0.075},
340                                   {0.15,0.075,0.1125},
341                                   {1,0,0.25},             // 240
342                                   {1,0.5,0.625},
343                                   {0.65,0,0.1625},
344                                   {0.65,0.325,0.4063},
345                                   {0.5,0,0.125},
346                                   {0.5,0.25,0.3125},
347                                   {0.3,0,0.075},
348                                   {0.3,0.15,0.1875},
349                                   {0.15,0,0.0375},
350                                   {0.15,0.075,0.0938},
351                                   {0.33,0.33,0.33},       // 250
352                                   {0.464,0.464,0.464},
353                                   {0.598,0.598,0.598},
354                                   {0.732,0.732,0.732},
355                                   {0.866,0.866,0.866},
356                                   {1,1,1}                 // 255
357                               }
358                               ;
359
360
361 // AutoCAD VERSION aliases
362 #define VER_R12    DL_Codes::AC1009
363 #define VER_LT2    DL_Codes::AC1009
364 #define VER_R13    DL_Codes::AC1012   // not supported yet
365 #define VER_LT95   DL_Codes::AC1012   // not supported yet
366 #define VER_R14    DL_Codes::AC1014   // not supported yet
367 #define VER_LT97   DL_Codes::AC1014   // not supported yet
368 #define VER_LT98   DL_Codes::AC1014   // not supported yet
369 #define VER_2000   DL_Codes::AC1015
370 #define VER_2002   DL_Codes::AC1015
371
372
373 // DXF Group Codes:
374
375 // Strings
376 #define STRGRP_START      0
377 #define STRGRP_END        9
378
379 // Coordinates
380 #define CRDGRP_START     10
381 #define CRDGRP_END       19
382
383 // Real values
384 #define RLGRP_START      38
385 #define RLGRP_END        59
386
387 // Short integer values
388 #define SHOGRP_START     60
389 #define SHOGRP_END       79
390
391 // New in Release 13,
392 #define SUBCLASS        100
393
394 // More coordinates
395 #define CRD2GRP_START   210
396 #define CRD2GRP_END     239
397
398 // Extended data strings
399 #define ESTRGRP_START  1000
400 #define ESTRGRP_END    1009
401
402 // Extended data reals
403 #define ERLGRP_START   1010
404 #define ERLGRP_END     1059
405
406
407 #define Y8_COORD_CODE       28
408 #define Z0_COORD_CODE       30
409 #define Z8_COORD_CODE       38
410
411 #define POINT_COORD_CODE    10
412 #define INSERT_COORD_CODE   10
413
414 #define CRD2GRP_START      210
415 #define CRD2GRP_END        239
416
417 #define THICKNESS            39
418 #define FIRST_REAL_CODE      THICKNESS
419 #define LAST_REAL_CODE       59
420 #define FIRST_INT_CODE       60
421 #define ATTFLAGS_CODE        70
422 #define PLINE_FLAGS_CODE     70
423 #define LAYER_FLAGS_CODE     70
424 #define FLD_LEN_CODE         73 // Inside ATTRIB resbuf
425 #define LAST_INT_CODE        79
426 #define X_EXTRU_CODE        210
427 #define Y_EXTRU_CODE        220
428 #define Z_EXTRU_CODE        230
429 #define COMMENT_CODE        999
430
431 // Start and endpoints of a line
432 #define LINE_START_CODE      10  // Followed by x coord
433 #define LINE_END_CODE        11  // Followed by x coord
434
435 // Some codes used by blocks
436 #define BLOCK_FLAGS_CODE     70  // An int containing flags
437 #define BLOCK_BASE_CODE      10  // Origin of block definition
438 #define XREF_DEPENDENT       16  // If a block contains an XREF
439 #define XREF_RESOLVED        32  // If a XREF resolved ok
440 #define REFERENCED           64  // If a block is ref'd in DWG
441
442 #define XSCALE_CODE          41
443 #define YSCALE_CODE          42
444 #define ANGLE_CODE           50
445 #define INS_POINT_CODE       10  // Followed by x of ins pnt
446 #define NAME2_CODE            3  // Second appearance of name
447
448 // Some codes used by circle entities
449 #define CENTER_CODE          10  // Followed by x of center
450 #define RADIUS_CODE          40  // Followd by radius of circle
451
452 #define COND_OP_CODE         -4  // Conditional op,ads_ssget
453
454 // When using ads_buildlist you MUST use RTDXF0 instead of these
455 #define ENTITY_TYPE_CODE      0  // Then there is LINE, 3DFACE..
456 #define SES_CODE              0  // Start End String Code
457 #define FILE_SEP_CODE         0  // File separator
458 #define SOT_CODE              0  // Start Of Table
459 #define TEXTVAL_CODE          1
460 #define NAME_CODE             2
461 #define BLOCK_NAME_CODE       2
462 #define SECTION_NAME_CODE     2
463 #define ENT_HAND_CODE         5  // What follows is hexa string
464 #define TXT_STYLE_CODE        7  // Inside attributes
465 #define LAYER_NAME_CODE       8  // What follows is layer name
466 #define FIRST_XCOORD_CODE    10  // Group code x of 1st coord
467 #define FIRST_YCOORD_CODE    20  // Group code y of 1st coord
468 #define FIRST_ZCOORD_CODE    30  // Group code z of 1st coord
469 #define L_START_CODE         10
470 #define L_END_CODE           11
471 #define TXTHI_CODE           40
472 #define SCALE_X_CODE         41
473 #define SCALE_Y_CODE         42
474 #define SCALE_Z_CODE         43
475 #define BULGE_CODE           42  // Used in PLINE verts for arcs
476 #define ROTATION_CODE        50
477 #define COLOUR_CODE          62  // What follows is a color int
478 #define LTYPE_CODE            6  // What follows is a linetype
479
480
481 // Attribute flags
482 #define ATTS_FOLLOW_CODE     66
483 #define ATT_TAG_CODE          2
484 #define ATT_VAL_CODE          1
485 #define ATT_FLAGS_CODE       70  // 4 1 bit flags as follows...
486 #define ATT_INVIS_FLAG        1
487 #define ATT_CONST_FLAG        2
488 #define ATT_VERIFY_FLAG       4 // Prompt and verify
489 #define ATT_PRESET_FLAG       8 // No prompt and no verify
490
491 // PLINE defines
492 // Flags
493 #define OPEN_PLINE       0x00
494 #define CLOSED_PLINE     0x01
495 #define POLYLINE3D       0x80
496 #define PFACE_MESH       0x40
497 #define PGON_MESH        0x10
498 // Vertices follow entity, required in POLYLINES
499 #define VERTS_FOLLOW_CODE   66 // Value should always be 1
500 #define VERTEX_COORD_CODE   10
501
502
503 // LAYER flags
504 #define FROZEN           1
505 #define FROZEN_BY_DEF    2
506 #define LOCKED           4
507 #define OBJECT_USED     64   // Object is ref'd in the dwg
508
509 #define BLOCK_EN_CODE   -2   // Block entity definition
510 #define E_NAME          -1   // Entity name
511
512 // Extended data codes
513 #define EXTD_SENTINEL    (-3)
514 #define EXTD_STR         1000
515 #define EXTD_APP_NAME    1001
516 #define EXTD_CTL_STR     1002
517 #define EXTD_LYR_STR     1003
518 #define EXTD_CHUNK       1004
519 #define EXTD_HANDLE      1005
520 #define EXTD_POINT       1010
521 #define EXTD_POS         1011
522 #define EXTD_DISP        1012
523 #define EXTD_DIR         1013
524 #define EXTD_FLOAT       1040
525 #define EXTD_DIST        1041
526 #define EXTD_SCALE       1042
527 #define EXTD_INT16       1070
528 #define EXTD_INT32       1071
529
530 // UCS codes for use in ads_trans
531 #define WCS_TRANS_CODE      0
532 #define UCS_TRANS_CODE      1
533 #define DCS_TRANS_CODE      2
534 #define PCS_TRANS_CODE      3
535
536 #endif
537