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