1 /*******************************************************************************
2  *  Project: libopencad
3  *  Purpose: OpenSource CAD formats support library
4  *  Author: Alexandr Borzykh, mush3d at gmail.com
5  *  Author: Dmitry Baryshnikov, bishop.dev@gmail.com
6  *  Language: C++
7  *******************************************************************************
8  *  The MIT License (MIT)
9  *
10  *  Copyright (c) 2016 Alexandr Borzykh
11  *  Copyright (c) 2016 NextGIS, <info@nextgis.com>
12  *
13  *  Permission is hereby granted, free of charge, to any person obtaining a copy
14  *  of this software and associated documentation files (the "Software"), to deal
15  *  in the Software without restriction, including without limitation the rights
16  *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  *  copies of the Software, and to permit persons to whom the Software is
18  *  furnished to do so, subject to the following conditions:
19  *
20  *  The above copyright notice and this permission notice shall be included in all
21  *  copies or substantial portions of the Software.
22  *
23  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26  *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29  *  SOFTWARE.
30  *******************************************************************************/
31 #ifndef CADHEADER_H
32 #define CADHEADER_H
33 
34 #include "opencad.h"
35 #include <map>
36 #include <string>
37 #include <vector>
38 #include <ctime>
39 
40 class OCAD_EXTERN CADHandle final
41 {
42 public:
43     CADHandle( unsigned char codeIn = 0 );
44     CADHandle( const CADHandle& other );
45     CADHandle& operator=( const CADHandle& other );
46 
47     void addOffset( unsigned char val );
48     bool isNull() const;
49     long getAsLong() const;
50     long getAsLong( const CADHandle& ref_handle ) const;
51 protected:
52     unsigned char              code;
53     std::vector<unsigned char> handleOrOffset;
54 };
55 
56 class OCAD_EXTERN CADVariant final
57 {
58 public:
59     enum class DataType
60     {
61         INVALID = 0, DECIMAL, REAL, STRING, DATETIME, COORDINATES, HANDLE
62     };
63 
64 public:
65     CADVariant();
66     CADVariant( const char * val );
67     CADVariant( int val );
68     CADVariant( long val );
69     CADVariant( short val );
70     CADVariant( double val );
71     CADVariant( double x, double y, double z = 0 );
72     CADVariant( const CADHandle& val );
73     CADVariant( const std::string& val );
74     CADVariant( time_t val, bool bIsTime );
75 public:
76     CADVariant( const CADVariant& orig );
77     CADVariant& operator=( const CADVariant& orig );
78 public:
79     long   getDecimal() const;
80     double getReal() const;
81     const std::string& getString() const;
82     DataType getType() const;
83     double   getX() const;
84     double   getY() const;
85     double   getZ() const;
86     const CADHandle& getHandle() const;
87 protected:
88     DataType    type;
89     long        decimalVal;
90     double      xVal;
91     double      yVal;
92     double      zVal;
93     std::string stringVal;
94     CADHandle   handleVal;
95     time_t      dateTimeVal;
96 };
97 
98 /**
99  * @brief The common CAD header class
100  */
101 class OCAD_EXTERN CADHeader
102 {
103 public:
104     /**
105      * @brief The CAD нeader сonstants enum get from dxf reference:
106      *        http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-A85E8E67-27CD-4C59-BE61-4DC9FADBE74A
107      */
108     enum CADHeaderConstants
109     {
110         OPENCADVER          = 1, /**< enum CADVersions value*/
111         ACADMAINTVER, /**< Maintenance version number (should be ignored) */
112         ACADVER, /**< The AutoCAD drawing database version number:
113                               AC1006 = R10
114                               AC1009 = R11 and R12
115                               AC1012 = R13
116                               AC1014 = R14
117                               AC1015 = AutoCAD 2000
118                               AC1018 = AutoCAD 2004
119                               AC1021 = AutoCAD 2007
120                               AC1024 = AutoCAD 2010
121                               AC1027 = AutoCAD 2013 */
122         ANGBASE, /**< Angle 0 direction */
123         ANGDIR, /**< 1 (Clockwise angles) or 0 (Counterclockwise angles) */
124         ATTMODE, /**< Attribute visibility: 0,1,2 */
125         ATTREQ, /**< todo: */
126         ATTDIA, /**< todo: */
127         AUNITS, /**< Units format for angles */
128         AUPREC, /**< Units precision for angles */
129         CECOLOR, /**< 0 = BYBLOCK; 256 = BYLAYER */
130         CELTSCALE, /**< Current entity linetype scale */
131         CELTYPE, /**< Entity linetype name, or BYBLOCK or BYLAYER */
132         CELWEIGHT, /**< Lineweight of new objects */
133         CEPSNID, /**< Plotstyle handle of new objects;
134                               if CEPSNTYPE is 3, then this value indicates the
135                               handle */
136         CEPSNTYPE, /**< Plot style type of new objects:
137                               0 = Plot style by layer,
138                               1 = Plot style by block,
139                               2 = Plot style by dictionary default,
140                               3 = Plot style by object ID/handle */
141         CHAMFERA, /**< First chamfer distance */
142         CHAMFERB, /**< Second chamfer distance */
143         CHAMFERC, /**< Chamfer length */
144         CHAMFERD, /**< Chamfer angle */
145         CLAYER, /**< Current layer name */
146         CMLJUST, /**< Current multiline justification:
147                               0 = Top;
148                               1 = Middle;
149                               2 = Bottom */
150         CMLSCALE, /**< Current multiline scale */
151         CMLSTYLE, /**< Current multiline style name */
152         CSHADOW, /**< Shadow mode for a 3D object:
153                               0 = Casts and receives shadows
154                               1 = Casts shadows
155                               2 = Receives shadows
156                               3 = Ignores shadows */
157         DIMADEC, /**< Number of precision places displayed in angular
158                               dimensions */
159         DIMALT, /**< Alternate unit dimensioning performed if nonzero */
160         DIMALTD, /**< Alternate unit decimal places */
161         DIMALTF, /**< Alternate unit scale factor */
162         DIMALTRND, /**< Determines rounding of alternate units */
163         DIMALTTD, /**< Number of decimal places for tolerance values of
164                               an alternate units dimension */
165         DIMALTTZ, /**< Controls suppression of zeros for alternate
166                               tolerance values:
167                               0 = Suppresses zero feet and precisely zero inches
168                               1 = Includes zero feet and precisely zero inches
169                               2 = Includes zero feet and suppresses zero inches
170                               3 = Includes zero inches and suppresses zero feet */
171         DIMALTU, /**< Units format for alternate units of all dimension
172                               style family members except angular:
173                               1 = Scientific
174                               2 = Decimal
175                               3 = Engineering
176                               4 = Architectural (stacked)
177                               5 = Fractional (stacked)
178                               6 = Architectural
179                               7 = Fractional */
180         DIMALTZ, /**< Controls suppression of zeros for alternate unit
181                               dimension, values:
182                               0 = Suppresses zero feet and precisely zero inches
183                               1 = Includes zero feet and precisely zero inches
184                               2 = Includes zero feet and suppresses zero inches
185                               3 = Includes zero inches and suppresses zero feet */
186         DIMAPOST, /**< Alternate dimensioning suffix */
187         DIMASO, /**< 1 = Create associative dimensioning,
188                               0 = Draw individual entities */
189         DIMASSOC, /**< Controls the associativity of dimension objects:
190                               0 = Creates exploded dimensions; there is no
191                                   association between elements of the dimension,
192                                   and the lines, arcs, arrowheads, and text of a
193                                   dimension are drawn as separate objects
194                               1 = Creates non-associative dimension objects;
195                                   the elements of the dimension are formed into
196                                   a single object, and if the definition point
197                                   on the object moves, then the dimension value
198                                   is updated
199                               2 = Creates associative dimension objects; the
200                                   elements of the dimension are formed into a
201                                   single object and one or more definition
202                                   points of the dimension are coupled with
203                                   association points on geometric objects */
204         DIMASZ, /**< Dimensioning arrow size */
205         DIMATFIT, /**< Controls dimension text and arrow placement when
206                               space is not sufficient to place both within the
207                               extension lines:
208                               0 = Places both text and arrows outside extension
209                                   lines
210                               1 = Moves arrows first, then text
211                               2 = Moves text first, then arrows
212                               3 = Moves either text or arrows, whichever fits
213                                   best AutoCAD adds a leader to moved dimension
214                                   text when DIMTMOVE is set to 1 */
215         DIMAUNIT, /**< Angle format for angular dimensions:
216                               0 = Decimal degrees
217                               1 = Degrees/minutes/seconds
218                               2 = Gradians
219                               3 = Radians
220                               4 = Surveyor's units */
221         DIMAZIN, /**< Controls suppression of zeros for angular
222                               dimensions:
223                               0 = Displays all leading and trailing zeros
224                               1 = Suppresses leading zeros in decimal dimensions
225                               2 = Suppresses trailing zeros in decimal dimensions
226                               3 = Suppresses leading and trailing zeros */
227         DIMBLK, /**< Arrow block name */
228         DIMBLK1, /**< First arrow block name */
229         DIMBLK2, /**< Second arrow block name */
230         DIMCEN, /**< Size of center mark/lines */
231         DIMCLRD, /**< Dimension line color:
232                               range is 0 = BYBLOCK; 256 = BYLAYER */
233         DIMCLRE, /**< Dimension extension line color:
234                               range is 0 = BYBLOCK; 256 = BYLAYER */
235         DIMCLRT, /**< Dimension text color:
236                               range is 0 = BYBLOCK; 256 = BYLAYER */
237         DIMDEC, /**< Number of decimal places for the tolerance values
238                               of a primary units dimension */
239         DIMDLE, /**< Dimension line extension */
240         DIMDLI, /**< Dimension line increment */
241         DIMDSEP, /**< Single-character decimal separator used when
242                               creating dimensions whose unit format is decimal */
243         DIMEXE, /**< Extension line extension */
244         DIMEXO, /**< Extension line offset */
245         DIMFAC, /**< Scale factor used to calculate the height of text
246                               for dimension fractions and tolerances. AutoCAD
247                               multiplies DIMTXT by DIMTFAC to set the fractional
248                               or tolerance text height */
249         DIMGAP, /**< Dimension line gap */
250         DIMJUST, /**< Horizontal dimension text position:
251                               0 = Above dimension line and center-justified
252                                   between extension lines
253                               1 = Above dimension line and next to first
254                                   extension line
255                               2 = Above dimension line and next to second
256                                   extension line
257                               3 = Above and center-justified to first extension
258                                   line
259                               4 = Above and center-justified to second
260                                   extension line */
261         DIMLDRBLK, /**< Arrow block name for leaders */
262         DIMLFAC, /**< Linear measurements scale factor */
263         DIMLIM, /**< Dimension limits generated if nonzero */
264         DIMLUNIT, /**< Sets units for all dimension types except Angular:
265                               1 = Scientific
266                               2 = Decimal
267                               3 = Engineering
268                               4 = Architectural
269                               5 = Fractional
270                               6 = Windows desktop */
271         DIMLWD, /**< Dimension line lineweight:
272                               -3 = Standard
273                               -2 = ByLayer
274                               -1 = ByBlock
275                               0-211 = an integer representing 100th of mm */
276         DIMLWE, /**< Extension line lineweight:
277                               -3 = Standard
278                               -2 = ByLayer
279                               -1 = ByBlock
280                               0-211 = an integer representing 100th of mm */
281         DIMPOST, /**< General dimensioning suffix */
282         DIMRND, /**< Rounding value for dimension distances */
283         DIMSAH, /**< Use separate arrow blocks if nonzero */
284         DIMSCALE, /**< Overall dimensioning scale factor */
285         DIMSD1, /**< Suppression of first extension line:
286                               0 = Not suppressed
287                               1 = Suppressed */
288         DIMSD2, /**< Suppression of second extension line:
289                               0 = Not suppressed
290                               1 = Suppressed */
291         DIMSE1, /**< First extension line suppressed if nonzero */
292         DIMSE2, /**< Second extension line suppressed if nonzero */
293         DIMSHO, /**< 1 = Recompute dimensions while dragging
294                               0 = Drag original image */
295         DIMSOXD, /**< Suppress outside-extensions dimension lines if
296                               nonzero */
297         DIMSTYLE, /**< Dimension style name */
298         DIMTAD, /**< Text above dimension line if nonzero */
299         DIMTDEC, /**< Number of decimal places to display the tolerance
300                               values */
301         DIMTFAC, /**< Dimension tolerance display scale factor */
302         DIMTIH, /**< Text inside horizontal if nonzero */
303         DIMTIX, /**< Force text inside extensions if nonzero */
304         DIMTM, /**< Minus tolerance */
305         DIMTMOVE, /**< Dimension text movement rules:
306                               0 = Moves the dimension line with dimension text
307                               1 = Adds a leader when dimension text is moved
308                               2 = Allows text to be moved freely without a leader */
309         DIMTOFL, /**< If text is outside extensions, force line
310                               extensions between extensions if nonzero */
311         DIMTOH, /**< Text outside horizontal if nonzero */
312         DIMTOL, /**< Dimension tolerances generated if nonzero */
313         DIMTOLJ, /**< Vertical justification for tolerance values:
314                               0 = Top
315                               1 = Middle
316                               2 = Bottom */
317         DIMTP, /**< Plus tolerance */
318         DIMTSZ, /**< Dimensioning tick size:
319                               0 = No ticks */
320         DIMTVP, /**< Text vertical position */
321         DIMTXSTY, /**< Dimension text style */
322         DIMTXT, /**< Dimensioning text height */
323         DIMTZIN, /**< Controls suppression of zeros for tolerance values:
324                               0 = Suppresses zero feet and precisely zero inches
325                               1 = Includes zero feet and precisely zero inches
326                               2 = Includes zero feet and suppresses zero inches
327                               3 = Includes zero inches and suppresses zero feet */
328         DIMUPT, /**< Cursor functionality for user-positioned text:
329                               0 = Controls only the dimension line location
330                               1 = Controls the text position as well as the
331                                   dimension line location */
332         DIMZIN, /**< Controls suppression of zeros for primary unit
333                               values:
334                               0 = Suppresses zero feet and precisely zero inches
335                               1 = Includes zero feet and precisely zero inches
336                               2 = Includes zero feet and suppresses zero inches
337                               3 = Includes zero inches and suppresses zero feet */
338         DISPSILH, /**< Controls the display of silhouette curves of body
339                               objects in Wireframe mode:
340                               0 = Off
341                               1 = On */
342         DRAGVS, /**< Hard-pointer ID to visual style while creating 3D
343                               solid primitives. The defualt value is NULL */
344         DWGCODEPAGE, /**< Drawing code page; set to the system code page
345                               when a new drawing is created, but not otherwise
346                               maintained by AutoCAD */
347         ELEVATION, /**< Current elevation set by ELEV command */
348         ENDCAPS, /**< Lineweight endcaps setting for new objects:
349                               0 = none
350                               1 = round
351                               2 = angle
352                               3 = square */
353         EXTMAX, /**< X, Y, and Z drawing extents upper-right corner
354                               (in WCS) */
355         EXTMIN, /**< X, Y, and Z drawing extents lower-left corner
356                               (in WCS) */
357         EXTNAMES, /**< Controls symbol table naming:
358                               0 = Release 14 compatibility. Limits names to 31
359                                   characters in length. Names can include the
360                                   letters A to Z, the numerals 0 to 9, and the
361                                   special characters dollar sign ($), underscore
362                                   (_), and hyphen (-).
363                               1 = AutoCAD 2000. Names can be up to 255 characters
364                                   in length, and can include the letters A to Z,
365                                   the numerals 0 to 9, spaces, and any special
366                                   characters not used for other purposes by
367                                   Microsoft Windows and AutoCAD */
368         FILLETRAD, /**< Fillet radius */
369         FILLMODE, /**< Fill mode on if nonzero */
370         FINGERPRINTGUID, /**< Set at creation time, uniquely identifies a
371                               particular drawing */
372         HALOGAP, /**< Specifies a gap to be displayed where an object is
373                               hidden by another object; the value is specified
374                               as a percent of one unit and is independent of the
375                               zoom level. A haloed line is shortened at the
376                               point where it is hidden when HIDE or the Hidden
377                               option of SHADEMODE is used */
378         HANDSEED, /**< Next available handle */
379         HIDETEXT, /**< Specifies HIDETEXT system variable:
380                               0 = HIDE ignores text objects when producing the
381                                   hidden view
382                               1 = HIDE does not ignore text objects */
383         HYPERLINKBASE, /**< Path for all relative hyperlinks in the drawing.
384                               If null, the drawing path is used */
385         INDEXCTL, /**< Controls whether layer and spatial indexes are
386                               created and saved in drawing files:
387                               0 = No indexes are created
388                               1 = Layer index is created
389                               2 = Spatial index is created
390                               3 = Layer and spatial indexes are created */
391         INSBASE, /**< Insertion base set by BASE command (in WCS) */
392         INSUNITS, /**< Default drawing units for AutoCAD DesignCenter
393                               blocks:
394                               0 = Unitless
395                               1 = Inches
396                               2 = Feet
397                               3 = Miles
398                               4 = Millimeters
399                               5 = Centimeters
400                               6 = Meters
401                               7 = Kilometers
402                               8 = Microinches
403                               9 = Mils
404                              10 = Yards
405                              11 = Angstroms
406                              12 = Nanometers
407                              13 = Microns
408                              14 = Decimeters
409                              15 = Decameters
410                              16 = Hectometers
411                              17 = Gigameters
412                              18 = Astronomical units
413                              19 = Light years
414                              20 = Parsecs */
415         INTERFERECOLOR, /**< Represents the ACI color index of the
416                               "interference objects" created during the
417                               interfere command. Default value is 1 */
418         INTERFEREOBJVS, /**< Hard-pointer ID to the visual style for
419                               interference objects. Default visual style is
420                               Conceptual */
421         INTERFEREVPVS, /**< Hard-pointer ID to the visual style for the
422                               viewport during interference checking. Default
423                               visual style is 3d Wireframe. */
424         INTERSECTIONCOLOR, /**< Specifies the entity color of intersection
425                                  polylines:
426                                  Values 1-255 designate an AutoCAD color index (ACI)
427                                  0 = Color BYBLOCK
428                                256 = Color BYLAYER
429                                257 = Color BYENTITY */
430         INTERSECTIONDISPLAY, /**< Specifies the display of intersection polylines:
431                                  0 = Turns off the display of intersection
432                                      polylines
433                                  1 = Turns on the display of intersection
434                                      polylines */
435         JOINSTYLE, /**< Lineweight joint setting for new objects:
436                               0 = none
437                               1 = round
438                               2 = angle
439                               3 = flat */
440         LIMCHECK, /**< Nonzero if limits checking is on */
441         LIMMAX, /**< XY drawing limits upper-right corner (in WCS) */
442         LIMMIN, /**< XY drawing limits lower-left corner (in WCS) */
443         LTSCALE, /**< Global linetype scale */
444         LUNITS, /**< Units format for coordinates and distances */
445         LUPREC, /**< Units precision for coordinates and distances */
446         LWDISPLAY, /**< Controls the display of lineweights on the Model
447                               or Layout tab:
448                               0 = Lineweight is not displayed
449                               1 = Lineweight is displayed */
450         MAXACTVP, /**< Sets maximum number of viewports to be regenerated */
451         MEASUREMENT, /**< Sets drawing units:
452                               0 = English
453                               1 = Metric */
454         MENU, /**< Name of menu file */
455         MIRRTEXT, /**< Mirror text if nonzero */
456         OBSCOLOR, /**< Specifies the color of obscured lines. An obscured
457                               line is a hidden line made visible by changing its
458                               color and linetype and is visible only when the
459                               HIDE or SHADEMODE command is used. The OBSCUREDCOLOR
460                               setting is visible only if the OBSCUREDLTYPE is
461                               turned ON by setting it to a value other than 0.
462                               0 and 256 = Entity color
463                               1-255 = An AutoCAD color index (ACI) */
464         OBSLTYPE, /**< Specifies the linetype of obscured lines. Obscured
465                               linetypes are independent of zoom level, unlike
466                               regular AutoCAD linetypes. Value 0 turns off
467                               display of obscured lines and is the default.
468                               Linetype values are defined as follows:
469                               0 = Off
470                               1 = Solid
471                               2 = Dashed
472                               3 = Dotted
473                               4 = Short Dash
474                               5 = Medium Dash
475                               6 = Long Dash
476                               7 = Double Short Dash
477                               8 = Double Medium Dash
478                               9 = Double Long Dash
479                              10 = Medium Long Dash
480                              11 = Sparse Dot */
481         ORTHOMODE, /**< Ortho mode on if nonzero */
482         PDMODE, /**< Point display mode */
483         PDSIZE, /**< Point display size */
484         PELEVATION, /**< Current paper space elevation */
485         PEXTMAX, /**< Maximum X, Y, and Z extents for paper space */
486         PEXTMIN, /**< Minimum X, Y, and Z extents for paper space */
487         PINSBASE, /**< Paper space insertion base point */
488         PLIMCHECK, /**< Limits checking in paper space when nonzero */
489         PLIMMAX, /**< Maximum X and Y limits in paper space */
490         PLIMMIN, /**< Minimum X and Y limits in paper space */
491         PLINEGEN, /**< Governs the generation of linetype patterns around
492                               the vertices of a 2D polyline:
493                               1 = Linetype is generated in a continuous pattern
494                                   around vertices of the polyline
495                               0 = Each segment of the polyline starts and ends
496                                   with a dash */
497         PLINEWID, /**< Default polyline width */
498         PROJECTNAME, /**< Assigns a project name to the current drawing.
499                               Used when an external reference or image is not
500                               found on its original path. The project name
501                               points to a section in the registry that can
502                               contain one or more search paths for each project
503                               name defined. Project names and their search
504                               directories are created from the Files tab of the
505                               Options dialog box */
506         PROXYGRAPHICS, /**< Controls the saving of proxy object images */
507         PSLTSCALE, /**< Controls paper space linetype scaling:
508                               1 = No special linetype scaling
509                               0 = Viewport scaling governs linetype scaling */
510         PSTYLEMODE, /**< Indicates whether the current drawing is in a
511                               Color-Dependent or Named Plot Style mode:
512                               0 = Uses named plot style tables in the current
513                                   drawing
514                               1 = Uses color-dependent plot style tables in the
515                                   current drawing */
516         PSVPSCALE, /**< View scale factor for new viewports:
517                               0 = Scaled to fit
518                              >0 = Scale factor (a positive real value) */
519         PUCSBASE, /**< Name of the UCS that defines the origin and
520                               orientation of orthographic UCS settings (paper
521                               space only) */
522         PUCSNAME, /**< Current paper space UCS name */
523         PUCSORG, /**< Current paper space UCS origin */
524         PUCSORGBACK, /**< Point which becomes the new UCS origin after
525                               changing paper space UCS to BACK when PUCSBASE is
526                               set to WORLD */
527         PUCSORGBOTTOM, /**< Point which becomes the new UCS origin after
528                               changing paper space UCS to BOTTOM when PUCSBASE
529                               is set to WORLD */
530         PUCSORGFRONT, /**< Point which becomes the new UCS origin after
531                               changing paper space UCS to FRONT when PUCSBASE is
532                               set to WORLD */
533         PUCSORGLEFT, /**< Point which becomes the new UCS origin after
534                               changing paper space UCS to LEFT when PUCSBASE is
535                               set to WORLD */
536         PUCSORGRIGHT, /**< Point which becomes the new UCS origin after
537                               changing paper space UCS to RIGHT when PUCSBASE is
538                               set to WORLD */
539         PUCSORGTOP, /**< Point which becomes the new UCS origin after
540                               changing paper space UCS to TOP when PUCSBASE is
541                               set to WORLD */
542         PUCSORTHOREF, /**< If paper space UCS is orthographic (PUCSORTHOVIEW
543                               not equal to 0), this is the name of the UCS that
544                               the orthographic UCS is relative to. If blank, UCS
545                               is relative to WORLD */
546         PUCSORTHOVIEW, /**< Orthographic view type of paper space UCS:
547                               0 = UCS is not orthographic
548                               1 = Top
549                               2 = Bottom
550                               3 = Front
551                               4 = Back
552                               5 = Left
553                               6 = Right */
554         PUCSXDIR, /**< Current paper space UCS X axis */
555         PUCSYDIR, /**< Current paper space UCS Y axis */
556         QTEXTMODE, /**< Quick Text mode on if nonzero */
557         REGENMODE, /**< REGENAUTO mode on if nonzero */
558         SHADEDGE, /**< 0 = Faces shaded, edges not highlighted
559                               1 = Faces shaded, edges highlighted in black
560                               2 = Faces not filled, edges in entity color
561                               3 = Faces in entity color, edges in black */
562         SHADEDIF, /**< Percent ambient/diffuse light range 1-100
563                               default 70 */
564         SHADOWPLANELOCATION, /**< Location of the ground shadow plane. This is a
565                                   Z axis ordinate. */
566         SKETCHINC, /**< Sketch record increment */
567         SKPOLY, /**< 0 = Sketch lines
568                               1 = Sketch polylines */
569         SORTENTS, /**< Controls the object sorting methods; accessible
570                               from the Options dialog box User Preferences tab.
571                               SORTENTS uses the following bitcodes:
572                               0 = Disables SORTENTS
573                               1 = Sorts for object selection
574                               2 = Sorts for object snap
575                               4 = Sorts for redraws
576                               8 = Sorts for MSLIDE command slide creation
577                              16 = Sorts for REGEN commands
578                              32 = Sorts for plotting
579                              64 = Sorts for PostScript output */
580         SPLINESEGS, /**< Number of line segments per spline patch */
581         SPLINETYPE, /**< Spline curve type for PEDIT Spline */
582         SURFTAB1, /**< Number of mesh tabulations in first direction */
583         SURFTAB2, /**< Number of mesh tabulations in second direction */
584         SURFTYPE, /**< Surface type for PEDIT Smooth */
585         SURFU, /**< Surface density (for PEDIT Smooth) in M direction */
586         SURFV, /**< Surface density (for PEDIT Smooth) in N direction */
587         TDCREATE, /**< Local date/time of drawing creation (see “Special
588                               Handling of Date/Time Variables”) */
589         TDINDWG, /**< Cumulative editing time for this drawing */
590         TDUCREATE, /**< Universal date/time the drawing was created */
591         TDUPDATE, /**< Local date/time of last drawing update */
592         TDUSRTIMER, /**< User-elapsed timer */
593         TDUUPDATE, /**< Universal date/time of the last update/save */
594         TEXTSIZE, /**< Default text height */
595         TEXTSTYLE, /**< Current text style name */
596         THICKNESS, /**< Current thickness set by ELEV command */
597         TILEMODE, /**< 1 for previous release compatibility mode
598                               0 otherwise */
599         TRACEWID, /**< Default trace width */
600         TREEDEPTH, /**< Specifies the maximum depth of the spatial index */
601         UCSBASE, /**< Name of the UCS that defines the origin and
602                               orientation of orthographic UCS settings */
603         UCSNAME, /**< Name of current UCS */
604         UCSORG, /**< Origin of current UCS (in WCS) */
605         UCSORGBACK, /**< Point which becomes the new UCS origin after
606                               changing model space UCS to BACK when UCSBASE is
607                               set to WORLD */
608         UCSORGBOTTOM, /**< Point which becomes the new UCS origin after
609                               changing model space UCS to BOTTOM when UCSBASE is
610                               set to WORLD */
611         UCSORGFRONT, /**< Point which becomes the new UCS origin after
612                               changing model space UCS to FRONT when UCSBASE is
613                               set to WORLD */
614         UCSORGLEFT, /**< Point which becomes the new UCS origin after
615                               changing model space UCS to LEFT when UCSBASE is
616                               set to WORLD */
617         UCSORGRIGHT, /**< Point which becomes the new UCS origin after
618                               changing model space UCS to RIGHT when UCSBASE is
619                               set to WORLD */
620         UCSORGTOP, /**< Point which becomes the new UCS origin after
621                               changing model space UCS to TOP when UCSBASE is
622                               set to WORLD */
623         UCSORTHOREF, /**< If model space UCS is orthographic (UCSORTHOVIEW
624                               not equal to 0), this is the name of the UCS that
625                               the orthographic UCS is relative to. If blank, UCS
626                               is relative to WORLD */
627         UCSORTHOVIEW, /**< Orthographic view type of model space UCS:
628                               0 = UCS is not orthographic
629                               1 = Top
630                               2 = Bottom
631                               3 = Front
632                               4 = Back
633                               5 = Left
634                               6 = Right */
635         UCSXDIR, /**< Direction of the current UCS X axis (in WCS) */
636         UCSYDIR, /**< Direction of the current UCS Y axis (in WCS) */
637         UNITMODE, /**< Low bit set = Display fractions, feet-and-inches,
638                               and surveyor's angles in input format */
639         USERI1, /**< Five integer variables intended for use by
640                               third-party developers */
641         USERI2, USERI3, USERI4, USERI5, USERR1, /**< Five real variables intended for use by
642                               third-party developers */
643         USERR2, USERR3, USERR4, USERR5, USRTIMER, /**< 0 = Timer off
644                               1 = Timer on */
645         VERSIONGUID, /**< Uniquely identifies a particular version of a
646                               drawing. Updated when the drawing is modified */
647         VISRETAIN, /**< 0 = Don't retain xref-dependent visibility settings
648                               1 = Retain xref-dependent visibility settings */
649         WORLDVIEW, /**< 1 = Set UCS to WCS during DVIEW/VPOINT
650                               0 = Don't change UCS */
651         XCLIPFRAME, /**< Controls the visibility of xref clipping
652                               boundaries:
653                               0 = Clipping boundary is not visible
654                               1 = Clipping boundary is visible */
655         XEDIT, /**< Controls whether the current drawing can be edited
656                               in-place when being referenced by another drawing.
657                               0 = Can't use in-place reference editing
658                               1 = Can use in-place reference editing */
659         SPLFRAME, /** ? */
660         WORDLVIEW, /** ? */
661         PELLIPSE, /** ? */
662         ISOLINES, /** ? */
663         TEXTQLTY, /** ? */
664         FACETRES, /** ? */
665         DIMFRAC, /** ? */
666         OLESTARTUP, /** ? */
667         STYLESHEET, /** ? */
668         TSTACKALIGN, /**< default = 1 (not present in DXF) */
669         TSTACKSIZE, /**< default = 70 (not present in DXF) */
670         MAX_HEADER_CONSTANT = 1000 /**< max + num for user constants */
671 
672     };
673 public:
674                      CADHeader();
675     /**
676      * @brief Add new value to the CAD file header
677      * @param code The code from constants enum
678      * @param val Value to add
679      * @return SUCCESS or some value from CADErrorCodes
680      */
681     int              addValue( short code, const CADVariant& val );
682     int              addValue( short code, const char * val );
683     int              addValue( short code, long val );
684     int              addValue( short code, int val );
685     int              addValue( short code, short val );
686     int              addValue( short code, double val );
687     int              addValue( short code, const std::string& val );
688     int              addValue( short code, bool val );
689     int              addValue( short code, double x, double y, double z = 0 );
690     int              addValue( short code, long julianday, long milliseconds );
691     int              getGroupCode( short code ) const;
692     const CADVariant getValue( short code, const CADVariant& val = CADVariant() ) const;
693     const char * getValueName( short code ) const;
694     void   print() const;
695     size_t getSize() const;
696     short  getCode( int index ) const;
697 protected:
698     std::map<short, CADVariant> valuesMap;
699 };
700 
701 #endif // CADHEADER_H
702