]> git.saurik.com Git - wxWidgets.git/blob - samples/opengl/penguin/dxfrenderer.h
Fix wrong in wxListCtrl::SetItemColumnImage() in r74716.
[wxWidgets.git] / samples / opengl / penguin / dxfrenderer.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dxfrenderer.h
3 // Purpose: DXF reader and renderer
4 // Author: Sandro Sigala
5 // Modified by:
6 // Created: 2005-11-10
7 // Copyright: (c) Sandro Sigala
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _DXFRENDERER_H_
12 #define _DXFRENDERER_H_
13
14 struct DXFVector
15 {
16 DXFVector() { x = y = z = 0.0f; }
17 DXFVector(float _x, float _y, float _z) { x = _x; y = _y; z = _z; }
18 float x, y, z;
19 };
20
21 struct DXFEntity
22 {
23 enum Type { Line, Face } type;
24 int colour;
25 };
26
27 struct DXFLine: public DXFEntity
28 {
29 DXFLine() { type = Line; }
30 DXFVector v0;
31 DXFVector v1;
32 };
33
34 struct DXFFace: public DXFEntity
35 {
36 DXFFace() { type = Face; }
37 void CalculateNormal();
38 DXFVector v0;
39 DXFVector v1;
40 DXFVector v2;
41 DXFVector v3;
42 DXFVector n; // normal
43 };
44
45 struct DXFLayer
46 {
47 DXFLayer() { colour = -1; }
48 wxString name;
49 int colour;
50 };
51
52 WX_DECLARE_LIST(DXFEntity, DXFEntityList);
53 WX_DECLARE_LIST(DXFLayer, DXFLayerList);
54
55 class DXFRenderer
56 {
57 public:
58 DXFRenderer();
59 ~DXFRenderer();
60
61 void Clear();
62 bool Load(wxInputStream& stream);
63 bool IsOk() const { return m_loaded; }
64 void Render() const;
65
66 private:
67 bool ParseHeader(wxInputStream& stream);
68 bool ParseTables(wxInputStream& stream);
69 bool ParseEntities(wxInputStream& stream);
70 int GetLayerColour(const wxString& layer) const;
71 void NormalizeEntities();
72
73 bool m_loaded;
74 DXFLayerList m_layers;
75 DXFEntityList m_entities;
76 };
77
78 #endif // !_DXFRENDERER_H_