1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OGL - wxDiagram class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _OGL_OGLDIAG_H_
13 #define _OGL_OGLDIAG_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "ogldiag.h"
21 #include <wx/deprecated/wxexpr.h>
25 class WXDLLIMPEXP_OGL wxDiagram
: public wxObject
27 DECLARE_DYNAMIC_CLASS(wxDiagram
)
34 void SetCanvas(wxShapeCanvas
*can
);
36 inline wxShapeCanvas
*GetCanvas() const { return m_diagramCanvas
; }
38 virtual void Redraw(wxDC
& dc
);
39 virtual void Clear(wxDC
& dc
);
40 virtual void DrawOutline(wxDC
& dc
, double x1
, double y1
, double x2
, double y2
);
42 // Add object to end of object list (if addAfter is NULL)
43 // or just after addAfter.
44 virtual void AddShape(wxShape
*object
, wxShape
*addAfter
= NULL
);
46 // Add object to front of object list
47 virtual void InsertShape(wxShape
*object
);
49 void SetSnapToGrid(bool snap
);
50 void SetGridSpacing(double spacing
);
51 inline double GetGridSpacing() const { return m_gridSpacing
; }
52 inline bool GetSnapToGrid() const { return m_snapToGrid
; }
53 void Snap(double *x
, double *y
);
55 inline void SetQuickEditMode(bool qem
) { m_quickEditMode
= qem
; }
56 inline bool GetQuickEditMode() const { return m_quickEditMode
; }
58 virtual void RemoveShape(wxShape
*object
);
59 virtual void RemoveAllShapes();
60 virtual void DeleteAllShapes();
61 virtual void ShowAll(bool show
);
63 // Find a shape by its id
64 wxShape
* FindShape(long id
) const;
66 inline void SetMouseTolerance(int tol
) { m_mouseTolerance
= tol
; }
67 inline int GetMouseTolerance() const { return m_mouseTolerance
; }
68 inline wxList
*GetShapeList() const { return m_shapeList
; }
69 inline int GetCount() const { return m_shapeList
->GetCount(); }
71 // Make sure all text that should be centred, is centred.
72 void RecentreAll(wxDC
& dc
);
75 virtual bool SaveFile(const wxString
& filename
);
76 virtual bool LoadFile(const wxString
& filename
);
78 virtual void ReadNodes(wxExprDatabase
& database
);
79 virtual void ReadLines(wxExprDatabase
& database
);
80 virtual void ReadContainerGeometry(wxExprDatabase
& database
);
82 // Allow for modifying file
83 virtual bool OnDatabaseLoad(wxExprDatabase
& db
);
84 virtual bool OnDatabaseSave(wxExprDatabase
& db
);
85 virtual bool OnShapeSave(wxExprDatabase
& db
, wxShape
& shape
, wxExpr
& expr
);
86 virtual bool OnShapeLoad(wxExprDatabase
& db
, wxShape
& shape
, wxExpr
& expr
);
87 virtual bool OnHeaderSave(wxExprDatabase
& db
, wxExpr
& expr
);
88 virtual bool OnHeaderLoad(wxExprDatabase
& db
, wxExpr
& expr
);
92 wxShapeCanvas
* m_diagramCanvas
;
100 class WXDLLIMPEXP_OGL wxLineCrossing
: public wxObject
103 wxLineCrossing() { m_lineShape1
= NULL
; m_lineShape2
= NULL
; }
104 wxRealPoint m_pt1
; // First line
106 wxRealPoint m_pt3
; // Second line
108 wxRealPoint m_intersect
;
109 wxLineShape
* m_lineShape1
;
110 wxLineShape
* m_lineShape2
;
113 class WXDLLIMPEXP_OGL wxLineCrossings
: public wxObject
119 void FindCrossings(wxDiagram
& diagram
);
120 void DrawCrossings(wxDiagram
& diagram
, wxDC
& dc
);
121 void ClearCrossings();