1 #ifndef _DXF_DXF_h_
2 #define _DXF_DXF_h_
3 
4 #define DXF_EPSILON 0.0000001
5 
6 #include "Block.h"
7 #include "Header.h"
8 #include "Tables.h"
9 #include "Objects.h"
10 #include "Blocks.h"
11 
12 #include "Entities.h"
13 
14 #include "DXFColorChooser.h"
15 
16 extern "C" byte *dxf_hdr;
17 extern "C" byte *dxf_tbl;
18 extern "C" byte *dxf_blkrec;
19 extern "C" byte *dxf_blk;
20 extern "C" byte *dxf_obj;
21 
22 class DXF : public DXFBlock
23 {
24 	friend class DXFTables;
25 	friend class DXFEntities;
26 	friend class DXFBlock;
27 
28 	public:
29 		enum Colors { ByBlock = 0, Red = 1, Yellow, Green, Cyan, Blue, Magenta, White, ByLayer = 256 };
30 
31 	private:
32 
33 		// next free handle
34 		uint32 nextHandle;
35 
36 		// the header
37 		DXFHeader header;
38 
39 		// gets next free handle
GetNextHandle(void)40 		uint32 GetNextHandle(void) { return nextHandle++; }
41 
42 		// blocks
43 		DXFBlocks blocks;
44 
45 		// objects
46 		DXFObjects objects;
47 
48 		// gets main dxf object
GetDXF(void)49 		virtual DXF &GetDXF(void) { return *this; }
50 
51 		// flag for scaling insertions with transform matrix
52 		bool scaleInsertions;
53 
54 		// view center point and height
55 		// calculated from GetBoundingBox functions
56 		Pointf viewCenter;
57 		double viewHeight;
58 
59 	protected:
60 
61 	public:
62 
63 		// constructor
64 		DXF();
65 
66 		// the tables section
67 		DXFTables tables;
68 
69 		// write drawing to file
70 		bool Write(Stream &s);
71 
72 		// some utility functions
73 
74 		// normalizes an angle to -M_PI .. +M_PI
75 		static double NormalizeAngle(double a);
76 
77 		// Add a block definition
78 		DXFBlock &AddBlock(String const &name);
79 
80 		// checks if a block is present
81 		bool HasBlock(String const &name) const;
82 
83 		// gets a block by name
84 		DXFBlock &GetBlock(String const &name);
85 		DXFBlock const &GetBlock(String const &name) const;
86 
87 		// sets insertion scale option
88 		DXF &SetScaleInsertions(bool i = true) { scaleInsertions = i; return *this; }
SetNoScaleInsertions()89 		DXF &SetNoScaleInsertions() { return SetScaleInsertions(false); }
90 
91 		// gets insertion scale option
GetScaleInsertions()92 		bool GetScaleInsertions() const { return scaleInsertions; }
93 };
94 
95 #endif
96