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 #include "wx/ogl/basic.h"
18 #include <wx/deprecated/wxexpr.h>
22 class WXDLLIMPEXP_OGL wxDiagram
: public wxObject
24 DECLARE_DYNAMIC_CLASS(wxDiagram
)
31 void SetCanvas(wxShapeCanvas
*can
);
33 inline wxShapeCanvas
*GetCanvas() const { return m_diagramCanvas
; }
35 virtual void Redraw(wxDC
& dc
);
36 virtual void Clear(wxDC
& dc
);
37 virtual void DrawOutline(wxDC
& dc
, double x1
, double y1
, double x2
, double y2
);
39 // Add object to end of object list (if addAfter is NULL)
40 // or just after addAfter.
41 virtual void AddShape(wxShape
*object
, wxShape
*addAfter
= NULL
);
43 // Add object to front of object list
44 virtual void InsertShape(wxShape
*object
);
46 void SetSnapToGrid(bool snap
);
47 void SetGridSpacing(double spacing
);
48 inline double GetGridSpacing() const { return m_gridSpacing
; }
49 inline bool GetSnapToGrid() const { return m_snapToGrid
; }
50 void Snap(double *x
, double *y
);
52 inline void SetQuickEditMode(bool qem
) { m_quickEditMode
= qem
; }
53 inline bool GetQuickEditMode() const { return m_quickEditMode
; }
55 virtual void RemoveShape(wxShape
*object
);
56 virtual void RemoveAllShapes();
57 virtual void DeleteAllShapes();
58 virtual void ShowAll(bool show
);
60 // Find a shape by its id
61 wxShape
* FindShape(long id
) const;
63 inline void SetMouseTolerance(int tol
) { m_mouseTolerance
= tol
; }
64 inline int GetMouseTolerance() const { return m_mouseTolerance
; }
65 inline wxList
*GetShapeList() const { return m_shapeList
; }
66 inline int GetCount() const { return m_shapeList
->GetCount(); }
68 // Make sure all text that should be centred, is centred.
69 void RecentreAll(wxDC
& dc
);
72 virtual bool SaveFile(const wxString
& filename
);
73 virtual bool LoadFile(const wxString
& filename
);
75 virtual void ReadNodes(wxExprDatabase
& database
);
76 virtual void ReadLines(wxExprDatabase
& database
);
77 virtual void ReadContainerGeometry(wxExprDatabase
& database
);
79 // Allow for modifying file
80 virtual bool OnDatabaseLoad(wxExprDatabase
& db
);
81 virtual bool OnDatabaseSave(wxExprDatabase
& db
);
82 virtual bool OnShapeSave(wxExprDatabase
& db
, wxShape
& shape
, wxExpr
& expr
);
83 virtual bool OnShapeLoad(wxExprDatabase
& db
, wxShape
& shape
, wxExpr
& expr
);
84 virtual bool OnHeaderSave(wxExprDatabase
& db
, wxExpr
& expr
);
85 virtual bool OnHeaderLoad(wxExprDatabase
& db
, wxExpr
& expr
);
89 wxShapeCanvas
* m_diagramCanvas
;
97 class WXDLLIMPEXP_OGL wxLineCrossing
: public wxObject
100 wxLineCrossing() { m_lineShape1
= NULL
; m_lineShape2
= NULL
; }
101 wxRealPoint m_pt1
; // First line
103 wxRealPoint m_pt3
; // Second line
105 wxRealPoint m_intersect
;
106 wxLineShape
* m_lineShape1
;
107 wxLineShape
* m_lineShape2
;
110 class WXDLLIMPEXP_OGL wxLineCrossings
: public wxObject
116 void FindCrossings(wxDiagram
& diagram
);
117 void DrawCrossings(wxDiagram
& diagram
, wxDC
& dc
);
118 void ClearCrossings();