]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/ogl/ogldiag.h
Added LoadFile and SaveFile methods
[wxWidgets.git] / contrib / include / wx / ogl / ogldiag.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ogldiag.h
3 // Purpose: OGL - wxDiagram class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 12/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _OGL_OGLDIAG_H_
13 #define _OGL_OGLDIAG_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "ogldiag.h"
17 #endif
18
19 #include <wx/deprecated/setup.h>
20
21 #if wxUSE_PROLOGIO
22 #include <wx/deprecated/wxexpr.h>
23 #endif
24
25 #include <wx/ogl/basic.h>
26
27 class wxDiagram: public wxObject
28 {
29 DECLARE_DYNAMIC_CLASS(wxDiagram)
30
31 public:
32
33 wxDiagram();
34 virtual ~wxDiagram();
35
36 void SetCanvas(wxShapeCanvas *can);
37
38 inline wxShapeCanvas *GetCanvas() const { return m_diagramCanvas; }
39
40 virtual void Redraw(wxDC& dc);
41 virtual void Clear(wxDC& dc);
42 virtual void DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2);
43
44 // Add object to end of object list (if addAfter is NULL)
45 // or just after addAfter.
46 virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
47
48 // Add object to front of object list
49 virtual void InsertShape(wxShape *object);
50
51 void SetSnapToGrid(bool snap);
52 void SetGridSpacing(double spacing);
53 inline double GetGridSpacing() const { return m_gridSpacing; }
54 inline bool GetSnapToGrid() const { return m_snapToGrid; }
55 void Snap(double *x, double *y);
56
57 inline void SetQuickEditMode(bool qem) { m_quickEditMode = qem; }
58 inline bool GetQuickEditMode() const { return m_quickEditMode; }
59
60 virtual void RemoveShape(wxShape *object);
61 virtual void RemoveAllShapes();
62 virtual void DeleteAllShapes();
63 virtual void ShowAll(bool show);
64
65 // Find a shape by its id
66 wxShape* FindShape(long id) const;
67
68 inline void SetMouseTolerance(int tol) { m_mouseTolerance = tol; }
69 inline int GetMouseTolerance() const { return m_mouseTolerance; }
70 inline wxList *GetShapeList() const { return m_shapeList; }
71 inline int GetCount() const { return m_shapeList->GetCount(); }
72
73 // Make sure all text that should be centred, is centred.
74 void RecentreAll(wxDC& dc);
75
76 #if wxUSE_PROLOGIO
77 virtual bool SaveFile(const wxString& filename);
78 virtual bool LoadFile(const wxString& filename);
79
80 virtual void ReadNodes(wxExprDatabase& database);
81 virtual void ReadLines(wxExprDatabase& database);
82 virtual void ReadContainerGeometry(wxExprDatabase& database);
83
84 // Allow for modifying file
85 virtual bool OnDatabaseLoad(wxExprDatabase& db);
86 virtual bool OnDatabaseSave(wxExprDatabase& db);
87 virtual bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
88 virtual bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
89 virtual bool OnHeaderSave(wxExprDatabase& db, wxExpr& expr);
90 virtual bool OnHeaderLoad(wxExprDatabase& db, wxExpr& expr);
91 #endif
92
93 protected:
94 wxShapeCanvas* m_diagramCanvas;
95 bool m_quickEditMode;
96 bool m_snapToGrid;
97 double m_gridSpacing;
98 int m_mouseTolerance;
99 wxList* m_shapeList;
100 };
101
102 class wxLineCrossing: public wxObject
103 {
104 public:
105 wxLineCrossing() { m_lineShape1 = NULL; m_lineShape2 = NULL; }
106 wxRealPoint m_pt1; // First line
107 wxRealPoint m_pt2;
108 wxRealPoint m_pt3; // Second line
109 wxRealPoint m_pt4;
110 wxRealPoint m_intersect;
111 wxLineShape* m_lineShape1;
112 wxLineShape* m_lineShape2;
113 };
114
115 class wxLineCrossings: public wxObject
116 {
117 public:
118 wxLineCrossings();
119 ~wxLineCrossings();
120
121 void FindCrossings(wxDiagram& diagram);
122 void DrawCrossings(wxDiagram& diagram, wxDC& dc);
123 void ClearCrossings();
124
125 public:
126 wxList m_crossings;
127 };
128
129 #endif
130 // _OGL_OGLDIAG_H_