libopencad
cadheader.h
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 
39 class OCAD_EXTERN CADHandle final
40 {
41 public:
42  CADHandle(unsigned char codeIn = 0);
43  CADHandle(const CADHandle& other);
44  CADHandle& operator = (const CADHandle& other);
45  void addOffset(unsigned char val);
46  bool isNull() const;
47  long getAsLong() const;
48  long getAsLong(const CADHandle &ref_handle ) const;
49 protected:
50  unsigned char code;
51  std::vector<unsigned char> handleOrOffset;
52 };
53 
54 class OCAD_EXTERN CADVariant final
55 {
56 public:
57  enum class DataType
58  {
59  INVALID = 0,
60  DECIMAL,
61  REAL,
62  STRING,
63  DATETIME,
64  COORDINATES,
65  HANDLE
66  };
67 
68 public:
69  CADVariant();
70  CADVariant(const char* val);
71  CADVariant(int val);
72  CADVariant(short val);
73  CADVariant(double val);
74  CADVariant(double x, double y, double z = 0);
75  CADVariant(const CADHandle& val);
76  CADVariant(const std::string &val);
77  CADVariant(time_t val);
78 public:
79  CADVariant(const CADVariant& orig);
80  CADVariant& operator = (const CADVariant& orig);
81 public:
82  long getDecimal() const;
83  double getReal() const;
84  const std::string &getString() const;
85  enum DataType getType() const;
86  double getX() const;
87  double getY() const;
88  double getZ() const;
89  const CADHandle &getHandle() const;
90 protected:
91  enum DataType type;
92  long decimalVal;
93  double xVal;
94  double yVal;
95  double zVal;
96  std::string stringVal;
97  CADHandle handleVal;
98  time_t dateTimeVal;
99 };
100 
101 
105 class OCAD_EXTERN CADHeader
106 {
107 public:
113  {
114  OPENCADVER = 1,
116  ACADVER,
137  CEPSNID,
140  CEPSNTYPE,
150  CMLJUST,
156  CSHADOW,
161  DIMADEC,
167  DIMALTTD,
169  DIMALTTZ,
175  DIMALTU,
184  DIMALTZ,
191  DIMASO,
193  DIMASSOC,
209  DIMATFIT,
219  DIMAUNIT,
225  DIMAZIN,
235  DIMCLRD,
237  DIMCLRE,
239  DIMCLRT,
241  DIMDEC,
245  DIMDSEP,
249  DIMFAC,
254  DIMJUST,
268  DIMLUNIT,
275  DIMLWD,
280  DIMLWE,
289  DIMSD1,
292  DIMSD2,
297  DIMSHO,
299  DIMSOXD,
303  DIMTDEC,
309  DIMTMOVE,
313  DIMTOFL,
317  DIMTOLJ,
322  DIMTSZ,
327  DIMTZIN,
332  DIMUPT,
336  DIMZIN,
342  DISPSILH,
346  DRAGVS,
348  DWGCODEPAGE,
352  ENDCAPS,
357  EXTMAX,
359  EXTMIN,
361  EXTNAMES,
374  FINGERPRINTGUID,
376  HALOGAP,
383  HIDETEXT,
387  HYPERLINKBASE,
389  INDEXCTL,
396  INSUNITS,
419  INTERFERECOLOR,
422  INTERFEREOBJVS,
425  INTERFEREVPVS,
428  INTERSECTIONCOLOR,
434  INTERSECTIONDISPLAY,
439  JOINSTYLE,
450  LWDISPLAY,
455  MEASUREMENT,
460  OBSCOLOR,
468  OBSLTYPE,
495  PLINEGEN,
502  PROJECTNAME,
511  PSLTSCALE,
514  PSTYLEMODE,
520  PSVPSCALE,
523  PUCSBASE,
528  PUCSORGBACK,
531  PUCSORGBOTTOM,
534  PUCSORGFRONT,
537  PUCSORGLEFT,
540  PUCSORGRIGHT,
543  PUCSORGTOP,
546  PUCSORTHOREF,
550  PUCSORTHOVIEW,
562  SHADEDGE,
566  SHADEDIF,
568  SHADOWPLANELOCATION,
571  SKPOLY,
573  SORTENTS,
591  TDCREATE,
601  TILEMODE,
605  UCSBASE,
609  UCSORGBACK,
612  UCSORGBOTTOM,
615  UCSORGFRONT,
618  UCSORGLEFT,
621  UCSORGRIGHT,
624  UCSORGTOP,
627  UCSORTHOREF,
631  UCSORTHOVIEW,
641  UNITMODE,
643  USERI1,
645  USERI2,
646  USERI3,
647  USERI4,
648  USERI5,
649  USERR1,
651  USERR2,
652  USERR3,
653  USERR4,
654  USERR5,
655  USRTIMER,
657  VERSIONGUID,
659  VISRETAIN,
661  WORLDVIEW,
663  XCLIPFRAME,
667  XEDIT,
671  SPLFRAME,
682  MAX_HEADER_CONSTANT = 1000
684  };
685 public:
686  CADHeader();
693  int addValue(short code, const CADVariant& val);
694  int addValue(short code, const char* val);
695  int addValue(short code, long val);
696  int addValue(short code, int val);
697  int addValue(short code, short val);
698  int addValue(short code, double val);
699  int addValue(short code, const std::string& val);
700  int addValue(short code, bool val);
701  int addValue(short code, double x, double y, double z = 0);
702  int addValue(short code, long julianday, long milliseconds);
703  int getGroupCode(short code) const;
704  const CADVariant& getValue(short code,
705  const CADVariant& val = CADVariant()) const;
706  const char* getValueName(short code) const;
707  void print() const;
708 protected:
709  std::map<short, CADVariant> valuesMap;
710 };
711 
712 #endif // CADHEADER_H
Definition: cadheader.h:681
Definition: cadheader.h:39
Definition: cadheader.h:459
Definition: cadheader.h:584
Definition: cadheader.h:128
Definition: cadheader.h:607
Definition: cadheader.h:604
Definition: cadheader.h:285
CADHeaderConstants
The CAD нeader сonstants enum get from dxf reference: http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-A85E8E67-27CD-4C59-BE61-4DC9FADBE74A.
Definition: cadheader.h:112
Definition: cadheader.h:674
Definition: cadheader.h:132
Definition: cadheader.h:148
Definition: cadheader.h:598
Definition: cadheader.h:448
Definition: cadheader.h:675
Definition: cadheader.h:129
Definition: cadheader.h:306
Definition: cadheader.h:680
Definition: cadheader.h:600
Definition: cadheader.h:208
Definition: cadheader.h:234
Definition: cadheader.h:155
Definition: cadheader.h:587
Definition: cadheader.h:678
Definition: cadheader.h:308
Definition: cadheader.h:597
Definition: cadheader.h:640
Definition: cadheader.h:134
Definition: cadheader.h:570
Definition: cadheader.h:126
Definition: cadheader.h:373
Definition: cadheader.h:673
Definition: cadheader.h:679
Definition: cadheader.h:395
Definition: cadheader.h:672
Definition: cadheader.h:446
Definition: cadheader.h:267
Definition: cadheader.h:494
Definition: cadheader.h:487
Definition: cadheader.h:492
Definition: cadheader.h:486
Definition: cadheader.h:588
Definition: cadheader.h:559
Definition: cadheader.h:594
Definition: cadheader.h:164
Definition: cadheader.h:560
Definition: cadheader.h:595
Definition: cadheader.h:639
Definition: cadheader.h:133
Definition: cadheader.h:253
Definition: cadheader.h:485
Definition: cadheader.h:149
The common CAD header class.
Definition: cadheader.h:105
Definition: cadheader.h:154
Definition: cadheader.h:296
Definition: cadheader.h:146
Definition: cadheader.h:488
Definition: cadheader.h:324
Definition: cadheader.h:233
Definition: cadheader.h:287
Definition: cadheader.h:596
Definition: cadheader.h:490
Definition: cadheader.h:248
Definition: cadheader.h:593
Definition: cadheader.h:501
Definition: cadheader.h:608
Definition: cadheader.h:147
Definition: cadheader.h:135
Definition: cadheader.h:326
Definition: cadheader.h:585
Definition: cadheader.h:382
Definition: cadheader.h:491
Definition: cadheader.h:586
Definition: cadheader.h:307
Definition: cadheader.h:54
Definition: cadheader.h:316
Definition: cadheader.h:489
Definition: cadheader.h:265
Definition: cadheader.h:305
Definition: cadheader.h:301
Definition: cadheader.h:136
Definition: cadheader.h:166
Definition: cadheader.h:321
Definition: cadheader.h:510
Definition: cadheader.h:145
Definition: cadheader.h:165
Definition: cadheader.h:590
Definition: cadheader.h:231
Definition: cadheader.h:295
Definition: cadheader.h:444
Definition: cadheader.h:302
Definition: cadheader.h:130
Definition: cadheader.h:449
Definition: cadheader.h:458
Definition: cadheader.h:603
Definition: cadheader.h:351
Definition: cadheader.h:286
Definition: cadheader.h:190
Definition: cadheader.h:232
Definition: cadheader.h:288
Definition: cadheader.h:447
Definition: cadheader.h:115
Definition: cadheader.h:266
Definition: cadheader.h:599
Definition: cadheader.h:561
Definition: cadheader.h:244
Definition: cadheader.h:127
Definition: cadheader.h:315
Definition: cadheader.h:131
Definition: cadheader.h:247
Definition: cadheader.h:558
Definition: cadheader.h:163
Definition: cadheader.h:526
Definition: cadheader.h:493
Definition: cadheader.h:243
Definition: cadheader.h:676
Definition: cadheader.h:454
Definition: cadheader.h:677
Definition: cadheader.h:372
Definition: cadheader.h:325
Definition: cadheader.h:589
Definition: cadheader.h:527
Definition: cadheader.h:445