Added OGL to contrib

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-03-03 11:25:10 +00:00
parent b14391d1c8
commit 1fc25a89ac
221 changed files with 30863 additions and 0 deletions

View File

@@ -0,0 +1,744 @@
/////////////////////////////////////////////////////////////////////////////
// Name: basic.h
// Purpose: Basic OGL classes and definitions
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_BASIC_H_
#define _OGL_BASIC_H_
#ifdef __GNUG__
#pragma interface "basic.h"
#endif
#define OGL_VERSION 2.0
#ifndef DEFAULT_MOUSE_TOLERANCE
#define DEFAULT_MOUSE_TOLERANCE 3
#endif
// Edit these lines if you positively don't want PROLOGIO support
#ifndef PROLOGIO
#define PROLOGIO
#endif
// Key identifiers
#define KEY_SHIFT 1
#define KEY_CTRL 2
// Arrow styles
#define ARROW_NONE 0
#define ARROW_END 1
#define ARROW_BOTH 2
#define ARROW_MIDDLE 3
#define ARROW_START 4
// Control point types
// Rectangle and most other shapes
#define CONTROL_POINT_VERTICAL 1
#define CONTROL_POINT_HORIZONTAL 2
#define CONTROL_POINT_DIAGONAL 3
// Line
#define CONTROL_POINT_ENDPOINT_TO 4
#define CONTROL_POINT_ENDPOINT_FROM 5
#define CONTROL_POINT_LINE 6
// Types of formatting: can be combined in a bit list
#define FORMAT_NONE 0
// Left justification
#define FORMAT_CENTRE_HORIZ 1
// Centre horizontally
#define FORMAT_CENTRE_VERT 2
// Centre vertically
#define FORMAT_SIZE_TO_CONTENTS 4
// Resize shape to contents
// Shadow mode
#define SHADOW_NONE 0
#define SHADOW_LEFT 1
#define SHADOW_RIGHT 2
/*
* Declare types
*
*/
#define SHAPE_BASIC wxTYPE_USER + 1
#define SHAPE_RECTANGLE wxTYPE_USER + 2
#define SHAPE_ELLIPSE wxTYPE_USER + 3
#define SHAPE_POLYGON wxTYPE_USER + 4
#define SHAPE_CIRCLE wxTYPE_USER + 5
#define SHAPE_LINE wxTYPE_USER + 6
#define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
#define SHAPE_COMPOSITE wxTYPE_USER + 9
#define SHAPE_CONTROL_POINT wxTYPE_USER + 10
#define SHAPE_DRAWN wxTYPE_USER + 11
#define SHAPE_DIVISION wxTYPE_USER + 12
#define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
#define SHAPE_BITMAP wxTYPE_USER + 14
#define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
#define OBJECT_REGION wxTYPE_USER + 20
#define OP_CLICK_LEFT 1
#define OP_CLICK_RIGHT 2
#define OP_DRAG_LEFT 4
#define OP_DRAG_RIGHT 8
#define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
// Attachment modes
#define ATTACHMENT_MODE_NONE 0
#define ATTACHMENT_MODE_EDGE 1
#define ATTACHMENT_MODE_BRANCHING 2
// Sub-modes for branching attachment mode
#define BRANCHING_ATTACHMENT_NORMAL 1
#define BRANCHING_ATTACHMENT_BLOB 2
class wxShapeTextLine;
class wxShapeCanvas;
class wxLineShape;
class wxControlPoint;
class wxShapeRegion;
class wxShape;
#ifdef PROLOGIO
class WXDLLEXPORT wxExpr;
class WXDLLEXPORT wxExprDatabase;
#endif
// Round up
#define WXROUND(x) ( (long) (x + 0.5) )
// logical function to use when drawing rubberband boxes, etc.
#define OGLRBLF wxINVERT
class wxShapeEvtHandler: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler)
public:
wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL);
virtual ~wxShapeEvtHandler();
inline void SetShape(wxShape *sh) { m_handlerShape = sh; }
inline wxShape *GetShape() const { return m_handlerShape; }
inline void SetPreviousHandler(wxShapeEvtHandler* handler) { m_previousHandler = handler; }
inline wxShapeEvtHandler* GetPreviousHandler() const { return m_previousHandler; }
// This is called when the _shape_ is deleted.
virtual void OnDelete();
virtual void OnDraw(wxDC& dc);
virtual void OnDrawContents(wxDC& dc);
virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
virtual void OnMoveLinks(wxDC& dc);
virtual void OnErase(wxDC& dc);
virtual void OnEraseContents(wxDC& dc);
virtual void OnHighlight(wxDC& dc);
virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
virtual void OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
virtual void OnSize(double x, double y);
virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
virtual void OnDrawControlPoints(wxDC& dc);
virtual void OnEraseControlPoints(wxDC& dc);
virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
// Can override this to prevent or intercept line reordering.
virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
// Creates a copy of this event handler.
wxShapeEvtHandler *CreateNewCopy();
// Does the copy - override for new event handlers which might store
// app-specific data.
virtual void CopyData(wxShapeEvtHandler& copy) {};
private:
wxShapeEvtHandler* m_previousHandler;
wxShape* m_handlerShape;
};
class wxShape: public wxShapeEvtHandler
{
DECLARE_ABSTRACT_CLASS(wxShape)
public:
wxShape(wxShapeCanvas *can = NULL);
virtual ~wxShape();
virtual void GetBoundingBoxMax(double *width, double *height);
virtual void GetBoundingBoxMin(double *width, double *height) = 0;
virtual bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3);
inline wxShapeCanvas *GetCanvas() { return m_canvas; }
void SetCanvas(wxShapeCanvas *the_canvas);
virtual void AddToCanvas(wxShapeCanvas *the_canvas, wxShape *addAfter = NULL);
virtual void InsertInCanvas(wxShapeCanvas *the_canvas);
virtual void RemoveFromCanvas(wxShapeCanvas *the_canvas);
inline double GetX() const { return m_xpos; }
inline double GetY() const { return m_ypos; }
inline void SetX(double x) { m_xpos = x; }
inline void SetY(double y) { m_ypos = y; }
inline wxShape *GetParent() const { return m_parent; }
inline void SetParent(wxShape *p) { m_parent = p; }
wxShape *GetTopAncestor();
inline wxList& GetChildren() { return m_children; }
virtual void OnDraw(wxDC& dc);
virtual void OnDrawContents(wxDC& dc);
virtual void OnMoveLinks(wxDC& dc);
virtual void Unlink() { };
void SetDrawHandles(bool drawH);
inline bool GetDrawHandles() { return m_drawHandles; }
virtual void OnErase(wxDC& dc);
virtual void OnEraseContents(wxDC& dc);
virtual void OnHighlight(wxDC& dc);
virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
virtual void OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0) {}
virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
virtual void OnSize(double x, double y);
virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
virtual void OnDrawControlPoints(wxDC& dc);
virtual void OnEraseControlPoints(wxDC& dc);
virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void MakeControlPoints();
virtual void DeleteControlPoints(wxDC *dc = NULL);
virtual void ResetControlPoints();
inline wxShapeEvtHandler *GetEventHandler() { return m_eventHandler; }
inline void SetEventHandler(wxShapeEvtHandler *handler) { m_eventHandler = handler; }
// Mandatory control points, e.g. the divided line moving handles
// should appear even if a child of the 'selected' image
virtual void MakeMandatoryControlPoints();
virtual void ResetMandatoryControlPoints();
inline virtual bool Recompute() { return TRUE; };
// Calculate size recursively, if size changes. Size might depend on children.
inline virtual void CalculateSize() { };
virtual void Select(bool select = TRUE, wxDC* dc = NULL);
virtual void SetHighlight(bool hi = TRUE, bool recurse = FALSE);
inline virtual bool IsHighlighted() const { return m_highlighted; };
virtual bool Selected() const;
virtual bool AncestorSelected() const;
void SetSensitivityFilter(int sens = OP_ALL, bool recursive = FALSE);
int GetSensitivityFilter() const { return m_sensitivity; }
void SetDraggable(bool drag, bool recursive = FALSE);
inline void SetFixedSize(bool x, bool y) { m_fixedWidth = x; m_fixedHeight = y; };
inline void GetFixedSize(bool *x, bool *y) const { *x = m_fixedWidth; *y = m_fixedHeight; };
inline bool GetFixedWidth() const { return m_fixedWidth; }
inline bool GetFixedHeight() const { return m_fixedHeight; }
inline void SetSpaceAttachments(bool sp) { m_spaceAttachments = sp; };
inline bool GetSpaceAttachments() const { return m_spaceAttachments; };
void SetShadowMode(int mode, bool redraw = FALSE);
inline int GetShadowMode() const { return m_shadowMode; }
virtual bool HitTest(double x, double y, int *attachment, double *distance);
inline void SetCentreResize(bool cr) { m_centreResize = cr; }
inline bool GetCentreResize() const { return m_centreResize; }
inline void SetMaintainAspectRatio(bool ar) { m_maintainAspectRatio = ar; }
inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio; }
inline wxList& GetLines() const { return (wxList&) m_lines; }
inline void SetDisableLabel(bool flag) { m_disableLabel = flag; }
inline bool GetDisableLabel() const { return m_disableLabel; }
inline void SetAttachmentMode(int mode) { m_attachmentMode = mode; }
inline int GetAttachmentMode() const { return m_attachmentMode; }
inline void SetId(long i) { m_id = i; }
inline long GetId() const { return m_id; }
void SetPen(wxPen *pen);
void SetBrush(wxBrush *brush);
inline void SetClientData(wxObject *client_data) { m_clientData = client_data; };
inline wxObject *GetClientData() const { return m_clientData; };
virtual void Show(bool show);
virtual bool IsShown() const { return m_visible; }
virtual void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
virtual void Erase(wxDC& dc);
virtual void EraseContents(wxDC& dc);
virtual void Draw(wxDC& dc);
virtual void Flash();
virtual void MoveLinks(wxDC& dc);
virtual void DrawContents(wxDC& dc); // E.g. for drawing text label
virtual void SetSize(double x, double y, bool recursive = TRUE);
virtual void SetAttachmentSize(double x, double y);
void Attach(wxShapeCanvas *can);
void Detach();
inline virtual bool Constrain() { return FALSE; } ;
void AddLine(wxLineShape *line, wxShape *other,
int attachFrom = 0, int attachTo = 0,
// The line ordering
int positionFrom = -1, int positionTo = -1);
// Return the zero-based position in m_lines of line.
int GetLinePosition(wxLineShape* line);
void AddText(const wxString& string);
inline wxPen *GetPen() const { return m_pen; }
inline wxBrush *GetBrush() const { return m_brush; }
/*
* Region-specific functions (defaults to the default region
* for simple objects
*/
// Set the default, single region size to be consistent
// with the object size
void SetDefaultRegionSize();
virtual void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
virtual void SetFormatMode(int mode, int regionId = 0);
virtual int GetFormatMode(int regionId = 0) const;
virtual void SetFont(wxFont *font, int regionId = 0);
virtual wxFont *GetFont(int regionId = 0) const;
virtual void SetTextColour(const wxString& colour, int regionId = 0);
virtual wxString GetTextColour(int regionId = 0) const;
virtual inline int GetNumberOfTextRegions() const { return m_regions.Number(); }
virtual void SetRegionName(const wxString& name, int regionId = 0);
// Get the name representing the region for this image alone.
// I.e. this image's region ids go from 0 to N-1.
// But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
// So the last digit represents the region Id, the others represent positions
// in composites.
virtual wxString GetRegionName(int regionId);
// Gets the region corresponding to the name, or -1 if not found.
virtual int GetRegionId(const wxString& name);
// Construct names for regions, unique even for children of a composite.
virtual void NameRegions(const wxString& parentName = "");
// Get list of regions
inline wxList& GetRegions() const { return (wxList&) m_regions; }
virtual void AddRegion(wxShapeRegion *region);
virtual void ClearRegions();
// Assign new ids to this image and children (if composite)
void AssignNewIds();
// Returns actual image (same as 'this' if non-composite) and region id
// for given region name.
virtual wxShape *FindRegion(const wxString& regionName, int *regionId);
// Finds all region names for this image (composite or simple).
// Supply empty string list.
virtual void FindRegionNames(wxStringList& list);
virtual void ClearText(int regionId = 0);
void RemoveLine(wxLineShape *line);
#ifdef PROLOGIO
// I/O
virtual void WriteAttributes(wxExpr *clause);
virtual void ReadAttributes(wxExpr *clause);
// In case the object has constraints it needs to read in in a different pass
inline virtual void ReadConstraints(wxExpr *WXUNUSED(clause), wxExprDatabase *WXUNUSED(database)) { };
virtual void WriteRegions(wxExpr *clause);
virtual void ReadRegions(wxExpr *clause);
#endif
// Attachment code
virtual bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
virtual int GetNumberOfAttachments() const;
virtual bool AttachmentIsValid(int attachment) const;
// Only get the attachment position at the _edge_ of the shape, ignoring
// branching mode. This is used e.g. to indicate the edge of interest, not the point
// on the attachment branch.
virtual bool GetAttachmentPositionEdge(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Assuming the attachment lies along a vertical or horizontal line,
// calculate the position on that point.
virtual wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
int nth, int noArcs, wxLineShape* line);
// Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
// edge of the shape.
// attachmentPoint is the attachment point (= side) in question.
virtual bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
virtual void EraseLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
virtual void DrawLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
virtual bool MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move,
double x, double y);
// Reorders the lines coming into the node image at this attachment
// position, in the order in which they appear in linesToSort.
virtual void SortLines(int attachment, wxList& linesToSort);
// Apply an attachment ordering change
void ApplyAttachmentOrdering(wxList& ordering);
// Can override this to prevent or intercept line reordering.
virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
//// New banching attachment code, 24/9/98
//
// |________|
// | <- root
// | <- neck
// shoulder1 ->---------<- shoulder2
// | | | | |<- stem
// <- branching attachment point N-1
// This function gets the root point at the given attachment.
virtual wxRealPoint GetBranchingAttachmentRoot(int attachment);
// This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
virtual bool GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRealPoint& neck,
wxRealPoint& shoulder1, wxRealPoint& shoulder2);
// n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
// at this attachment point.
// attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
// shoulder.
virtual bool GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& attachmentPoint,
wxRealPoint& stemPoint);
// Get the number of lines at this attachment position.
virtual int GetAttachmentLineCount(int attachment) const;
// Draw the branches (not the actual arcs though)
virtual void OnDrawBranches(wxDC& dc, int attachment, bool erase = FALSE);
virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
// Branching attachment settings
inline void SetBranchNeckLength(int len) { m_branchNeckLength = len; }
inline int GetBranchNeckLength() const { return m_branchNeckLength; }
inline void SetBranchStemLength(int len) { m_branchStemLength = len; }
inline int GetBranchStemLength() const { return m_branchStemLength; }
inline void SetBranchSpacing(int len) { m_branchSpacing = len; }
inline int GetBranchSpacing() const { return m_branchSpacing; }
// Further detail on branching style, e.g. blobs on interconnections
inline void SetBranchStyle(long style) { m_branchStyle = style; }
inline long GetBranchStyle() const { return m_branchStyle; }
// Rotate the standard attachment point from physical (0 is always North)
// to logical (0 -> 1 if rotated by 90 degrees)
virtual int PhysicalToLogicalAttachment(int physicalAttachment) const;
// Rotate the standard attachment point from logical
// to physical (0 is always North)
virtual int LogicalToPhysicalAttachment(int logicalAttachment) const;
// This is really to distinguish between lines and other images.
// For lines, want to pass drag to canvas, since lines tend to prevent
// dragging on a canvas (they get in the way.)
virtual bool Draggable() const { return TRUE; }
// Returns TRUE if image is a descendant of this image
bool HasDescendant(wxShape *image);
// Creates a copy of this shape.
wxShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
// Does the copying for this object
virtual void Copy(wxShape& copy);
// Does the copying for this object, including copying event
// handler data if any. Calls the virtual Copy function.
void CopyWithHandler(wxShape& copy);
// Rotate about the given axis by the given amount in radians.
virtual void Rotate(double x, double y, double theta);
virtual inline double GetRotation() const { return m_rotation; }
void ClearAttachments();
// Recentres all the text regions for this object
void Recentre(wxDC& dc);
// Clears points from a list of wxRealPoints
void ClearPointList(wxList& list);
private:
wxObject* m_clientData;
protected:
wxShapeEvtHandler* m_eventHandler;
bool m_formatted;
double m_xpos, m_ypos;
wxPen* m_pen;
wxBrush* m_brush;
wxFont* m_font;
wxColour* m_textColour;
wxString m_textColourName;
wxShapeCanvas* m_canvas;
wxList m_lines;
wxList m_text;
wxList m_controlPoints;
wxList m_regions;
wxList m_attachmentPoints;
bool m_visible;
bool m_disableLabel;
long m_id;
bool m_selected;
bool m_highlighted; // Different from selected: user-defined highlighting,
// e.g. thick border.
double m_rotation;
int m_sensitivity;
bool m_draggable;
int m_attachmentMode; // 0 for no attachments, 1 if using normal attachments,
// 2 for branching attachments
bool m_spaceAttachments; // TRUE if lines at one side should be spaced
bool m_fixedWidth;
bool m_fixedHeight;
bool m_centreResize; // Default is to resize keeping the centre constant (TRUE)
bool m_drawHandles; // Don't draw handles if FALSE, usually TRUE
wxList m_children; // In case it's composite
wxShape* m_parent; // In case it's a child
int m_formatMode;
int m_shadowMode;
wxBrush* m_shadowBrush;
int m_shadowOffsetX;
int m_shadowOffsetY;
int m_textMarginX; // Gap between text and border
int m_textMarginY;
wxString m_regionName;
bool m_maintainAspectRatio;
int m_branchNeckLength;
int m_branchStemLength;
int m_branchSpacing;
long m_branchStyle;
};
class wxPolygonShape: public wxShape
{
DECLARE_DYNAMIC_CLASS(wxPolygonShape)
public:
wxPolygonShape();
~wxPolygonShape();
// Takes a list of wxRealPoints; each point is an OFFSET from the centre.
// Deletes user's points in destructor.
virtual void Create(wxList *points);
virtual void ClearPoints();
void GetBoundingBoxMin(double *w, double *h);
void CalculateBoundingBox();
bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3);
bool HitTest(double x, double y, int *attachment, double *distance);
void SetSize(double x, double y, bool recursive = TRUE);
void OnDraw(wxDC& dc);
void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
// A polygon should have a control point at each vertex,
// with the option of moving the control points individually
// to change the shape.
void MakeControlPoints();
void ResetControlPoints();
// If we've changed the shape, must make the original
// points match the working points
void UpdateOriginalPoints();
// Add a control point after the given point
virtual void AddPolygonPoint(int pos = 0);
// Delete a control point
virtual void DeletePolygonPoint(int pos = 0);
// Recalculates the centre of the polygon
virtual void CalculatePolygonCentre();
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
int GetNumberOfAttachments() const;
bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
bool AttachmentIsValid(int attachment);
// Does the copying for this object
void Copy(wxShape& copy);
inline wxList *GetPoints() { return m_points; }
// Rotate about the given axis by the given amount in radians
virtual void Rotate(double x, double y, double theta);
private:
wxList* m_points;
wxList* m_originalPoints;
double m_boundWidth;
double m_boundHeight;
double m_originalWidth;
double m_originalHeight;
};
class wxRectangleShape: public wxShape
{
DECLARE_DYNAMIC_CLASS(wxRectangleShape)
public:
wxRectangleShape(double w = 0.0, double h = 0.0);
void GetBoundingBoxMin(double *w, double *h);
bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3);
void OnDraw(wxDC& dc);
void SetSize(double x, double y, bool recursive = TRUE);
void SetCornerRadius(double rad); // If > 0, rounded corners
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
int GetNumberOfAttachments() const;
bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object
void Copy(wxShape& copy);
inline double GetWidth() const { return m_width; }
inline double GetHeight() const { return m_height; }
inline void SetWidth(double w) { m_width = w; }
inline void SetHeight(double h) { m_height = h; }
protected:
double m_width;
double m_height;
double m_cornerRadius;
};
class wxTextShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxTextShape)
public:
wxTextShape(double width = 0.0, double height = 0.0);
void OnDraw(wxDC& dc);
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
#endif
// Does the copying for this object
void Copy(wxShape& copy);
};
class wxEllipseShape: public wxShape
{
DECLARE_DYNAMIC_CLASS(wxEllipseShape)
public:
wxEllipseShape(double w = 0.0, double h = 0.0);
void GetBoundingBoxMin(double *w, double *h);
bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3);
void OnDraw(wxDC& dc);
void SetSize(double x, double y, bool recursive = TRUE);
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
int GetNumberOfAttachments() const;
bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
// Does the copying for this object
void Copy(wxShape& copy);
inline double GetWidth() const { return m_width; }
inline double GetHeight() const { return m_height; }
inline void SetWidth(double w) { m_width = w; }
inline void SetHeight(double h) { m_height = h; }
protected:
double m_width;
double m_height;
};
class wxCircleShape: public wxEllipseShape
{
DECLARE_DYNAMIC_CLASS(wxCircleShape)
public:
wxCircleShape(double w = 0.0);
bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3);
// Does the copying for this object
void Copy(wxShape& copy);
};
#endif
// _OGL_BASIC_H_

View File

@@ -0,0 +1,223 @@
/////////////////////////////////////////////////////////////////////////////
// Name: basicp.h
// Purpose: Private OGL classes and definitions
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_BASICP_H_
#define _OGL_BASICP_H_
#ifdef __GNUG__
#pragma interface "basicp.h"
#endif
#define CONTROL_POINT_SIZE 6
class wxShapeTextLine: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxShapeTextLine)
public:
wxShapeTextLine(double the_x = 0.0, double the_y = 0.0, const wxString& the_line = "");
~wxShapeTextLine();
inline double GetX() const { return m_x; }
inline double GetY() const { return m_y; }
inline void SetX(double x) { m_x = x; }
inline void SetY(double y) { m_y = y; }
inline void SetText(const wxString& text) { m_line = text; }
inline wxString GetText() const { return m_line; }
protected:
wxString m_line;
double m_x;
double m_y;
};
class wxShape;
class wxControlPoint: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxControlPoint)
friend class wxShapeEvtHandler;
friend class wxShape;
public:
wxControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, double the_xoffset = 0.0,
double the_yoffset = 0.0, int the_type = 0);
~wxControlPoint();
void OnDraw(wxDC& dc);
void OnErase(wxDC& dc);
void OnDrawContents(wxDC& dc);
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
int GetNumberOfAttachments() const;
inline void SetEraseObject(bool er) { m_eraseObject = er; }
public:
int m_type;
double m_xoffset;
double m_yoffset;
wxShape* m_shape;
wxCursor* m_oldCursor;
bool m_eraseObject; // If TRUE, erases object before dragging handle.
/*
* Store original top-left, bottom-right coordinates
* in case we're doing non-vertical resizing.
*/
static double sm_controlPointDragStartX;
static double sm_controlPointDragStartY;
static double sm_controlPointDragStartWidth;
static double sm_controlPointDragStartHeight;
static double sm_controlPointDragEndWidth;
static double sm_controlPointDragEndHeight;
static double sm_controlPointDragPosX;
static double sm_controlPointDragPosY;
};
class wxPolygonShape;
class wxPolygonControlPoint: public wxControlPoint
{
DECLARE_DYNAMIC_CLASS(wxPolygonControlPoint)
friend class wxPolygonShape;
public:
wxPolygonControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0, wxRealPoint *vertex = NULL,
double the_xoffset = 0.0, double the_yoffset = 0.0);
~wxPolygonControlPoint();
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
// Calculate what new size would be, at end of resize
virtual void CalculateNewSize(double x, double y);
// Get new size
inline wxRealPoint GetNewSize() const { return m_newSize; };
public:
wxRealPoint* m_polygonVertex;
wxRealPoint m_originalSize;
double m_originalDistance;
wxRealPoint m_newSize;
};
/*
* Object regions.
* Every shape has one or more text regions with various
* properties. Not all of a region's properties will be used
* by a shape.
*
*/
class wxShapeRegion: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxShapeRegion)
public:
// Constructor
wxShapeRegion();
// Copy constructor
wxShapeRegion(wxShapeRegion& region);
// Destructor
~wxShapeRegion();
// Accessors
inline void SetText(const wxString& s) { m_regionText = s; }
void SetFont(wxFont *f);
void SetMinSize(double w, double h);
void SetSize(double w, double h);
void SetPosition(double x, double y);
void SetProportions(double x, double y);
void SetFormatMode(int mode);
inline void SetName(const wxString& s) { m_regionName = s; };
void SetColour(const wxString& col); // Text colour
inline wxString GetText() const { return m_regionText; }
inline wxFont *GetFont() const { return m_font; }
inline void GetMinSize(double *x, double *y) const { *x = m_minWidth; *y = m_minHeight; }
inline void GetProportion(double *x, double *y) const { *x = m_regionProportionX; *y = m_regionProportionY; }
inline void GetSize(double *x, double *y) const { *x = m_width; *y = m_height; }
inline void GetPosition(double *xp, double *yp) const { *xp = m_x; *yp = m_y; }
inline int GetFormatMode() const { return m_formatMode; }
inline wxString GetName() const { return m_regionName; }
inline wxString GetColour() const { return m_textColour; }
wxColour *GetActualColourObject();
inline wxList& GetFormattedText() { return m_formattedText; }
inline wxString GetPenColour() const { return m_penColour; }
inline int GetPenStyle() const { return m_penStyle; }
inline void SetPenStyle(int style) { m_penStyle = style; m_actualPenObject = NULL; }
void SetPenColour(const wxString& col);
wxPen *GetActualPen();
inline double GetWidth() const { return m_width; }
inline double GetHeight() const { return m_height; }
void ClearText();
public:
wxString m_regionText;
wxList m_formattedText; // List of wxShapeTextLines
wxFont* m_font;
double m_minHeight; // If zero, hide region.
double m_minWidth; // If zero, hide region.
double m_width;
double m_height;
double m_x;
double m_y;
double m_regionProportionX; // Proportion of total object size;
// -1.0 indicates equal proportion
double m_regionProportionY; // Proportion of total object size;
// -1.0 indicates equal proportion
int m_formatMode; // FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT | FORMAT_NONE
wxString m_regionName;
wxString m_textColour;
wxColour* m_actualColourObject; // For speed purposes
// New members for specifying divided rectangle division colour/style 30/6/94
wxString m_penColour;
int m_penStyle;
wxPen* m_actualPenObject;
};
/*
* User-defined attachment point
*/
class wxAttachmentPoint: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxAttachmentPoint)
public:
inline wxAttachmentPoint()
{
m_id = 0; m_x = 0.0; m_y = 0.0;
}
inline wxAttachmentPoint(int id, double x, double y)
{
m_id = id; m_x = x; m_y = y;
}
public:
int m_id; // Identifier
double m_x; // x offset from centre of object
double m_y; // y offset from centre of object
};
#endif
// _OGL_BASICP_H_

View File

@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpshape.h
// Purpose: wxBitmapShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_BITMAP_H_
#define _OGL_BITMAP_H_
#ifdef __GNUG__
#pragma interface "bmpshape.h"
#endif
#include <wx/ogl/basic.h>
class wxBitmapShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxBitmapShape)
public:
wxBitmapShape();
~wxBitmapShape();
void OnDraw(wxDC& dc);
#ifdef PROLOGIO
// I/O
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
// Does the copying for this object
void Copy(wxShape& copy);
void SetSize(double w, double h, bool recursive = TRUE);
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
void SetBitmap(const wxBitmap& bm);
inline void SetFilename(const wxString& f) { m_filename = f; };
inline wxString GetFilename() const { return m_filename; }
private:
wxBitmap m_bitmap;
wxString m_filename;
};
#endif
// _OGL_BITMAP_H_

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: canvas.h
// Purpose: wxShapeCanvas
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_CANVAS_H_
#define _OGL_CANVAS_H_
#ifdef __GNUG__
#pragma interface "canvas.h"
#endif
// Drag states
#define NoDragging 0
#define StartDraggingLeft 1
#define ContinueDraggingLeft 2
#define StartDraggingRight 3
#define ContinueDraggingRight 4
// When drag_count reaches 0, process drag message
class wxDiagram;
class wxShapeCanvas: public wxScrolledWindow
{
DECLARE_DYNAMIC_CLASS(wxShapeCanvas)
public:
wxShapeCanvas(wxWindow *parent = NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxBORDER | wxRETAINED);
~wxShapeCanvas();
inline void SetDiagram(wxDiagram *diag) { m_shapeDiagram = diag; }
inline wxDiagram *GetDiagram() const { return m_shapeDiagram; }
virtual void OnLeftClick(double x, double y, int keys = 0);
virtual void OnRightClick(double x, double y, int keys = 0);
virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
virtual void OnBeginDragLeft(double x, double y, int keys=0);
virtual void OnEndDragLeft(double x, double y, int keys=0);
virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
virtual void OnBeginDragRight(double x, double y, int keys=0);
virtual void OnEndDragRight(double x, double y, int keys=0);
// Find object for mouse click, of given wxClassInfo (NULL for any type).
// If notImage is non-NULL, don't find an object that is equal to or a descendant of notImage
virtual wxShape *FindShape(double x, double y, int *attachment, wxClassInfo *info = NULL, wxShape *notImage = NULL);
wxShape *FindFirstSensitiveShape(double x, double y, int *new_attachment, int op);
wxShape *FindFirstSensitiveShape1(wxShape *image, int op);
// Redirect to wxDiagram object
virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
virtual void InsertShape(wxShape *object);
virtual void RemoveShape(wxShape *object);
virtual bool GetQuickEditMode();
virtual void Redraw(wxDC& dc);
void Snap(double *x, double *y);
// Events
void OnPaint(wxPaintEvent& event);
void OnMouseEvent(wxMouseEvent& event);
protected:
wxDiagram* m_shapeDiagram;
int m_dragState;
double m_oldDragX, m_oldDragY; // Previous drag coordinates
double m_firstDragX, m_firstDragY; // INITIAL drag coordinates
bool m_checkTolerance; // Whether to check drag tolerance
wxShape* m_draggedShape;
int m_draggedAttachment;
DECLARE_EVENT_TABLE()
};
#endif
// _OGL_CANVAS_H_

View File

@@ -0,0 +1,238 @@
/////////////////////////////////////////////////////////////////////////////
// Name: composit.h
// Purpose: wxCompositeShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_COMPOSIT_H_
#define _OGL_COMPOSIT_H_
#ifdef __GNUG__
#pragma interface "composit.h"
#endif
class wxDivisionShape;
class wxOGLConstraint;
/*
* A composite object is an invisible rectangle surrounding all children
*
*/
class wxCompositeShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxCompositeShape)
public:
wxCompositeShape();
~wxCompositeShape();
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
void OnErase(wxDC& dc);
bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = TRUE);
void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
void OnRightClick(double x, double y, int keys, int attachment = 0);
void SetSize(double w, double h, bool recursive = TRUE);
// Returns TRUE if it settled down
bool Recompute();
// New members
void AddChild(wxShape *child, wxShape *addAfter = NULL);
void RemoveChild(wxShape *child);
wxOGLConstraint *AddConstraint(wxOGLConstraint *constraint);
wxOGLConstraint *AddConstraint(int type, wxShape *constraining, wxList& constrained);
wxOGLConstraint *AddConstraint(int type, wxShape *constraining, wxShape *constrained);
void DeleteConstraint(wxOGLConstraint *constraint);
// Delete constraints that involve this child.
void DeleteConstraintsInvolvingChild(wxShape *child);
// Remove the image from any constraints involving it, but DON'T
// remove any constraints.
void RemoveChildFromConstraints(wxShape *child);
// Find constraint, also returning actual composite the constraint was in,
// in case it had to find it recursively.
wxOGLConstraint *FindConstraint(long id, wxCompositeShape **actualComposite = NULL);
// Returns TRUE if something changed
bool Constrain();
// Make this composite into a container by creating one wxDivisionShape
void MakeContainer();
// Calculates size and position of composite object based on children
void CalculateSize();
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
// In case the object has constraints it needs to read in in a different pass
void ReadConstraints(wxExpr *clause, wxExprDatabase *database);
#endif
// Does the copying for this object
void Copy(wxShape& copy);
virtual wxDivisionShape *OnCreateDivision();
// Finds the image used to visualize a container. This is any child
// of the composite that is not in the divisions list.
wxShape *FindContainerImage();
// Returns TRUE if division is a descendant of this container
bool ContainsDivision(wxDivisionShape *division);
inline wxList& GetDivisions() const { return (wxList&) m_divisions; }
inline wxList& GetConstraints() const { return (wxList&) m_constraints; }
protected:
double m_oldX;
double m_oldY;
wxList m_constraints;
wxList m_divisions; // In case it's a container
};
/*
* A division object is a composite with special properties,
* to be used for containment. It's a subdivision of a container.
* A containing node image consists of a composite with a main child shape
* such as rounded rectangle, plus a list of division objects.
* It needs to be a composite because a division contains pieces
* of diagram.
* NOTE a container has at least one wxDivisionShape for consistency.
* This can be subdivided, so it turns into two objects, then each of
* these can be subdivided, etc.
*/
#define DIVISION_SIDE_NONE 0
#define DIVISION_SIDE_LEFT 1
#define DIVISION_SIDE_TOP 2
#define DIVISION_SIDE_RIGHT 3
#define DIVISION_SIDE_BOTTOM 4
class wxDivisionShape: public wxCompositeShape
{
DECLARE_DYNAMIC_CLASS(wxDivisionShape)
public:
wxDivisionShape();
~wxDivisionShape();
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
bool OnMovePre(wxDC& dc, double x, double y, double oldX, double oldY, bool display = TRUE);
void OnDragLeft(bool draw, double x, double y, int keys, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys, int attachment = 0);
void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
// Don't want this kind of composite to resize its subdiagrams, so
// override composite's SetSize.
void SetSize(double w, double h, bool recursive = TRUE);
// Similarly for calculating size: it's fixed at whatever SetSize
// set it to, not in terms of children.
void CalculateSize();
void MakeControlPoints();
void ResetControlPoints();
void MakeMandatoryControlPoints();
void ResetMandatoryControlPoints();
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
// Does the copying for this object
void Copy(wxShape& copy);
// Divide horizontally (wxHORIZONTAL) or vertically (wxVERTICAL)
bool Divide(int direction);
// Resize adjoining divisions at the given side. If test is TRUE,
// just see whether it's possible for each adjoining region,
// returning FALSE if it's not.
bool ResizeAdjoining(int side, double newPos, bool test);
// Adjust a side, returning FALSE if it's not physically possible.
bool AdjustLeft(double left, bool test);
bool AdjustTop(double top, bool test);
bool AdjustRight(double right, bool test);
bool AdjustBottom(double bottom, bool test);
// Edit style of left or top side
void EditEdge(int side);
// Popup menu
void PopupMenu(double x, double y);
inline void SetLeftSide(wxDivisionShape *shape) { m_leftSide = shape; }
inline void SetTopSide(wxDivisionShape *shape) { m_topSide = shape; }
inline void SetRightSide(wxDivisionShape *shape) { m_rightSide = shape; }
inline void SetBottomSide(wxDivisionShape *shape) { m_bottomSide = shape; }
inline wxDivisionShape *GetLeftSide() const { return m_leftSide; }
inline wxDivisionShape *GetTopSide() const { return m_topSide; }
inline wxDivisionShape *GetRightSide() const { return m_rightSide; }
inline wxDivisionShape *GetBottomSide() const { return m_bottomSide; }
inline void SetHandleSide(int side) { m_handleSide = side; }
inline int GetHandleSide() const { return m_handleSide; }
inline void SetLeftSidePen(wxPen *pen) { m_leftSidePen = pen; }
inline wxPen *GetLeftSidePen() const { return m_leftSidePen; }
inline void SetTopSidePen(wxPen *pen) { m_topSidePen = pen; }
inline wxPen *GetTopSidePen() const { return m_topSidePen; }
void SetLeftSideColour(const wxString& colour);
void SetTopSideColour(const wxString& colour);
void SetLeftSideStyle(const wxString& style);
void SetTopSideStyle(const wxString& style);
inline wxString GetLeftSideColour() const { return m_leftSideColour; }
inline wxString GetTopSideColour() const { return m_topSideColour; }
inline wxString GetLeftSideStyle() const { return m_leftSideStyle; }
inline wxString GetTopSideStyle() const { return m_topSideStyle; }
protected:
// Adjoining divisions. NULL indicates edge
// of container, and that side shouldn't be
// drawn.
wxDivisionShape* m_leftSide;
wxDivisionShape* m_rightSide;
wxDivisionShape* m_topSide;
wxDivisionShape* m_bottomSide;
int m_handleSide; // Side at which handle is legal
wxPen* m_leftSidePen;
wxPen* m_topSidePen;
wxString m_leftSideColour;
wxString m_topSideColour;
wxString m_leftSideStyle;
wxString m_topSideStyle;
};
#define DIVISION_MENU_SPLIT_HORIZONTALLY 1
#define DIVISION_MENU_SPLIT_VERTICALLY 2
#define DIVISION_MENU_EDIT_LEFT_EDGE 3
#define DIVISION_MENU_EDIT_TOP_EDGE 4
#define DIVISION_MENU_EDIT_RIGHT_EDGE 5
#define DIVISION_MENU_EDIT_BOTTOM_EDGE 6
#define DIVISION_MENU_DELETE_ALL 7
#endif
// _OGL_COMPOSIT_H_

View File

@@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////
// Name: constrnt.h
// Purpose: OGL constraint definitions
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_CONSTRNT_H_
#define _OGL_CONSTRNT_H_
#ifdef __GNUG__
#pragma interface "constrnt.h"
#endif
/*
* OGL Constraints
*
*/
class wxOGLConstraintType: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxOGLConstraintType)
public:
wxOGLConstraintType(int type = 0, const wxString& name = "", const wxString& phrase = "");
~wxOGLConstraintType();
public:
int m_type; // E.g. gyCONSTRAINT_CENTRED_VERTICALLY
wxString m_name; // E.g. "Centre vertically"
wxString m_phrase; // E.g. "centred vertically with respect to", "left of"
};
extern wxList* wxOGLConstraintTypes;
#define gyCONSTRAINT_CENTRED_VERTICALLY 1
#define gyCONSTRAINT_CENTRED_HORIZONTALLY 2
#define gyCONSTRAINT_CENTRED_BOTH 3
#define gyCONSTRAINT_LEFT_OF 4
#define gyCONSTRAINT_RIGHT_OF 5
#define gyCONSTRAINT_ABOVE 6
#define gyCONSTRAINT_BELOW 7
#define gyCONSTRAINT_ALIGNED_TOP 8
#define gyCONSTRAINT_ALIGNED_BOTTOM 9
#define gyCONSTRAINT_ALIGNED_LEFT 10
#define gyCONSTRAINT_ALIGNED_RIGHT 11
// Like aligned, but with the objects centred on the respective edge
// of the reference object.
#define gyCONSTRAINT_MIDALIGNED_TOP 12
#define gyCONSTRAINT_MIDALIGNED_BOTTOM 13
#define gyCONSTRAINT_MIDALIGNED_LEFT 14
#define gyCONSTRAINT_MIDALIGNED_RIGHT 15
class wxOGLConstraint: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxOGLConstraint)
public:
wxOGLConstraint() { m_xSpacing = 0.0; m_ySpacing = 0.0; m_constraintType = 0; m_constraintName = ""; m_constraintId = 0;
m_constrainingObject = NULL; }
wxOGLConstraint(int type, wxShape *constraining, wxList& constrained);
~wxOGLConstraint();
// Returns TRUE if anything changed
bool Evaluate();
inline void SetSpacing(double x, double y) { m_xSpacing = x; m_ySpacing = y; };
bool Equals(double a, double b);
double m_xSpacing;
double m_ySpacing;
int m_constraintType;
wxString m_constraintName;
long m_constraintId;
wxShape* m_constrainingObject;
wxList m_constrainedObjects;
};
void OGLInitializeConstraintTypes();
void OGLCleanUpConstraintTypes();
#endif
// _OGL_CONSTRNT_H_

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////
// Name: divided.h
// Purpose: wxDividedShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_DIVIDED_H_
#define _OGL_DIVIDED_H_
#ifdef __GNUG__
#pragma interface "basic.h"
#endif
/*
* Definition of a region
*
*/
/*
* Box divided into horizontal regions
*
*/
extern wxFont *g_oglNormalFont;
class wxDividedShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxDividedShape)
public:
wxDividedShape(double w = 0.0, double h = 0.0);
~wxDividedShape();
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
void SetSize(double w, double h, bool recursive = TRUE);
void MakeControlPoints();
void ResetControlPoints();
void MakeMandatoryControlPoints();
void ResetMandatoryControlPoints();
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
void Copy(wxShape &copy);
// Set all region sizes according to proportions and
// this object total size
void SetRegionSizes();
// Edit region colours/styles
void EditRegions();
// Attachment points correspond to regions in the divided box
bool GetAttachmentPosition(int attachment, double *x, double *y,
int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
bool AttachmentIsValid(int attachment);
int GetNumberOfAttachments() const;
// Invoke editor on CTRL-right click
void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
};
#endif
// _OGL_DIVIDED_H_

View File

@@ -0,0 +1,227 @@
/////////////////////////////////////////////////////////////////////////////
// Name: drawn.h
// Purpose: wxDrawnShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_DRAWN_H_
#define _OGL_DRAWN_H_
#ifdef __GNUG__
#pragma interface "drawn.h"
#endif
#include <wx/ogl/basic.h>
#define oglMETAFLAGS_OUTLINE 1
#define oglMETAFLAGS_ATTACHMENTS 2
class wxDrawnShape;
class wxPseudoMetaFile: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxPseudoMetaFile)
public:
wxPseudoMetaFile();
wxPseudoMetaFile(wxPseudoMetaFile& mf);
~wxPseudoMetaFile();
void Draw(wxDC& dc, double xoffset, double yoffset);
#ifdef PROLOGIO
void WriteAttributes(wxExpr *clause, int whichAngle);
void ReadAttributes(wxExpr *clause, int whichAngle);
#endif
void Clear();
void Copy(wxPseudoMetaFile& copy);
void Scale(double sx, double sy);
void ScaleTo(double w, double h); // Scale to fit size
void Translate(double x, double y);
// Rotate about the given axis by theta radians from the x axis.
void Rotate(double x, double y, double theta);
bool LoadFromMetaFile(char *filename, double *width, double *height);
void GetBounds(double *minX, double *minY, double *maxX, double *maxY);
// Calculate size from current operations
void CalculateSize(wxDrawnShape* shape);
inline wxList& GetOutlineColours() const { return (wxList&) m_outlineColours; }
inline wxList& GetFillColours() const { return (wxList&) m_fillColours; }
inline void SetRotateable(bool rot) { m_rotateable = rot; }
inline bool GetRotateable() const { return m_rotateable; }
inline void SetSize(double w, double h) { m_width = w; m_height = h; }
inline void SetFillBrush(wxBrush* brush) { m_fillBrush = brush; }
inline wxBrush* GetFillBrush() const { return m_fillBrush; }
inline void SetOutlinePen(wxPen* pen) { m_outlinePen = pen; }
inline wxPen* GetOutlinePen() const { return m_outlinePen; }
inline void SetOutlineOp(int op) { m_outlineOp = op; }
inline int GetOutlineOp() const { return m_outlineOp; }
inline wxList& GetOps() const { return (wxList&) m_ops; }
// Is this a valid (non-empty) metafile?
inline bool IsValid() const { return (m_ops.Number() > 0); }
public:
/// Set of functions for drawing into a pseudo metafile.
/// They use integers, but doubles are used internally for accuracy
/// when scaling.
virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
virtual void DrawRectangle(const wxRect& rect);
virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
virtual void DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt);
virtual void DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle);
virtual void DrawEllipse(const wxRect& rect);
virtual void DrawPoint(const wxPoint& pt);
virtual void DrawText(const wxString& text, const wxPoint& pt);
virtual void DrawLines(int n, wxPoint pts[]);
// flags:
// oglMETAFLAGS_OUTLINE: will be used for drawing the outline and
// also drawing lines/arrows at the circumference.
// oglMETAFLAGS_ATTACHMENTS: will be used for initialising attachment points at
// the vertices (perhaps a rare case...)
virtual void DrawPolygon(int n, wxPoint pts[], int flags = 0);
virtual void DrawSpline(int n, wxPoint pts[]);
virtual void SetClippingRect(const wxRect& rect);
virtual void DestroyClippingRect();
virtual void SetPen(wxPen* pen, bool isOutline = FALSE); // TODO: eventually, just store GDI object attributes, not actual
virtual void SetBrush(wxBrush* brush, bool isFill = FALSE); // pens/brushes etc.
virtual void SetFont(wxFont* font);
virtual void SetTextColour(const wxColour& colour);
virtual void SetBackgroundColour(const wxColour& colour);
virtual void SetBackgroundMode(int mode);
public:
bool m_rotateable;
double m_width;
double m_height;
wxList m_ops; // List of drawing operations (see drawnp.h)
wxList m_gdiObjects; // List of pens, brushes and fonts for this object.
int m_outlineOp; // The op representing the outline, if any
// Pen/brush specifying outline/fill colours
// to override operations.
wxPen* m_outlinePen;
wxBrush* m_fillBrush;
wxList m_outlineColours; // List of the GDI operations that comprise the outline
wxList m_fillColours; // List of the GDI operations that fill the shape
double m_currentRotation;
};
#define oglDRAWN_ANGLE_0 0
#define oglDRAWN_ANGLE_90 1
#define oglDRAWN_ANGLE_180 2
#define oglDRAWN_ANGLE_270 3
class wxDrawnShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxDrawnShape)
public:
wxDrawnShape();
~wxDrawnShape();
void OnDraw(wxDC& dc);
#ifdef PROLOGIO
// I/O
void WriteAttributes(wxExpr *clause);
void ReadAttributes(wxExpr *clause);
#endif
// Does the copying for this object
void Copy(wxShape& copy);
void Scale(double sx, double sy);
void Translate(double x, double y);
// Rotate about the given axis by theta radians from the x axis.
void Rotate(double x, double y, double theta);
// Get current rotation
inline double GetRotation() const { return m_rotation; }
void SetSize(double w, double h, bool recursive = TRUE);
bool LoadFromMetaFile(char *filename);
inline void SetSaveToFile(bool save) { m_saveToFile = save; }
inline wxPseudoMetaFile& GetMetaFile(int which = 0) const { return (wxPseudoMetaFile&) m_metafiles[which]; }
void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
// Get the perimeter point using the special outline op, if there is one,
// otherwise use default wxRectangleShape scheme
bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3);
/// Set of functions for drawing into a pseudo metafile.
/// They use integers, but doubles are used internally for accuracy
/// when scaling.
virtual void DrawLine(const wxPoint& pt1, const wxPoint& pt2);
virtual void DrawRectangle(const wxRect& rect);
virtual void DrawRoundedRectangle(const wxRect& rect, double radius);
virtual void DrawArc(const wxPoint& centrePt, const wxPoint& startPt, const wxPoint& endPt);
virtual void DrawEllipticArc(const wxRect& rect, double startAngle, double endAngle);
virtual void DrawEllipse(const wxRect& rect);
virtual void DrawPoint(const wxPoint& pt);
virtual void DrawText(const wxString& text, const wxPoint& pt);
virtual void DrawLines(int n, wxPoint pts[]);
virtual void DrawPolygon(int n, wxPoint pts[], int flags = 0);
virtual void DrawSpline(int n, wxPoint pts[]);
virtual void SetClippingRect(const wxRect& rect);
virtual void DestroyClippingRect();
virtual void SetDrawnPen(wxPen* pen, bool isOutline = FALSE); // TODO: eventually, just store GDI object attributes, not actual
virtual void SetDrawnBrush(wxBrush* brush, bool isFill = FALSE); // pens/brushes etc.
virtual void SetDrawnFont(wxFont* font);
virtual void SetDrawnTextColour(const wxColour& colour);
virtual void SetDrawnBackgroundColour(const wxColour& colour);
virtual void SetDrawnBackgroundMode(int mode);
// Set the width/height according to the shapes in the metafile.
// Call this after drawing into the shape.
inline void CalculateSize() { m_metafiles[m_currentAngle].CalculateSize(this); }
inline void DrawAtAngle(int angle) { m_currentAngle = angle; };
inline int GetAngle() const { return m_currentAngle; }
// Implementation
protected:
// Which metafile do we use now? Based on current rotation and validity
// of metafiles.
int DetermineMetaFile(double rotation);
private:
// One metafile for each 90 degree rotation (or just a single one).
wxPseudoMetaFile m_metafiles[4];
// Don't save all wxDrawnShape metafiles to file: sometimes
// we take the metafile data from a symbol library.
bool m_saveToFile;
// Which angle are we using/drawing into?
int m_currentAngle;
};
#endif
// _DRAWN_H_

View File

@@ -0,0 +1,205 @@
/////////////////////////////////////////////////////////////////////////////
// Name: drawnp.h
// Purpose: Private header for wxDrawnShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_DRAWNP_H_
#define _OGL_DRAWNP_H_
#ifdef __GNUG__
#pragma interface "drawnp.h"
#endif
#include <wx/ogl/drawn.h>
/*
* Drawing operations
*
*/
#define DRAWOP_SET_PEN 1
#define DRAWOP_SET_BRUSH 2
#define DRAWOP_SET_FONT 3
#define DRAWOP_SET_TEXT_COLOUR 4
#define DRAWOP_SET_BK_COLOUR 5
#define DRAWOP_SET_BK_MODE 6
#define DRAWOP_SET_CLIPPING_RECT 7
#define DRAWOP_DESTROY_CLIPPING_RECT 8
/*
#define DRAWOP_CREATE_PEN 10
#define DRAWOP_CREATE_BRUSH 11
#define DRAWOP_CREATE_FONT 12
*/
#define DRAWOP_DRAW_LINE 20
#define DRAWOP_DRAW_POLYLINE 21
#define DRAWOP_DRAW_POLYGON 22
#define DRAWOP_DRAW_RECT 23
#define DRAWOP_DRAW_ROUNDED_RECT 24
#define DRAWOP_DRAW_ELLIPSE 25
#define DRAWOP_DRAW_POINT 26
#define DRAWOP_DRAW_ARC 27
#define DRAWOP_DRAW_TEXT 28
#define DRAWOP_DRAW_SPLINE 29
#define DRAWOP_DRAW_ELLIPTIC_ARC 30
/*
* Base, virtual class
*
*/
class wxDrawOp: public wxObject
{
public:
inline wxDrawOp(int theOp) { m_op = theOp; }
inline ~wxDrawOp() {}
inline virtual void Scale(double xScale, double yScale) {};
inline virtual void Translate(double x, double y) {};
inline virtual void Rotate(double x, double y, double theta, double sinTheta, double cosTheta) {};
virtual void Do(wxDC& dc, double xoffset, double yoffset) = 0;
virtual wxDrawOp *Copy(wxPseudoMetaFile *newImage) = 0;
virtual wxExpr *WriteExpr(wxPseudoMetaFile *image) = 0;
virtual void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr) = 0;
inline int GetOp() const { return m_op; }
// Draw an outline using the current operation. By default, return FALSE (not drawn)
virtual bool OnDrawOutline(wxDC& dc, double x, double y, double w, double h,
double oldW, double oldH) { return FALSE; }
// Get the perimeter point using this data
virtual bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3,
double xOffset, double yOffset,
int attachmentMode)
{ return FALSE; }
protected:
int m_op;
};
/*
* Set font, brush, text colour
*
*/
class wxOpSetGDI: public wxDrawOp
{
public:
wxOpSetGDI(int theOp, wxPseudoMetaFile *theImage, int theGdiIndex, int theMode = 0);
void Do(wxDC& dc, double xoffset, double yoffset);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
public:
int m_mode;
int m_gdiIndex;
wxPseudoMetaFile* m_image;
unsigned char m_r;
unsigned char m_g;
unsigned char m_b;
};
/*
* Set/destroy clipping
*
*/
class wxOpSetClipping: public wxDrawOp
{
public:
wxOpSetClipping(int theOp, double theX1, double theY1, double theX2, double theY2);
void Do(wxDC& dc, double xoffset, double yoffset);
void Scale(double xScale, double yScale);
void Translate(double x, double y);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
public:
double m_x1;
double m_y1;
double m_x2;
double m_y2;
};
/*
* Draw line, rectangle, rounded rectangle, ellipse, point, arc, text
*
*/
class wxOpDraw: public wxDrawOp
{
public:
wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2,
double radius = 0.0, char *s = NULL);
~wxOpDraw();
void Do(wxDC& dc, double xoffset, double yoffset);
void Scale(double scaleX, double scaleY);
void Translate(double x, double y);
void Rotate(double x, double y, double theta, double sinTheta, double cosTheta);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
public:
double m_x1;
double m_y1;
double m_x2;
double m_y2;
double m_x3;
double m_y3;
double m_radius;
char* m_textString;
};
/*
* Draw polyline, spline, polygon
*
*/
class wxOpPolyDraw: public wxDrawOp
{
public:
wxOpPolyDraw(int theOp, int n, wxRealPoint *thePoints);
~wxOpPolyDraw();
void Do(wxDC& dc, double xoffset, double yoffset);
void Scale(double scaleX, double scaleY);
void Translate(double x, double y);
void Rotate(double x, double y, double theta, double sinTheta, double cosTheta);
wxDrawOp *Copy(wxPseudoMetaFile *newImage);
wxExpr *WriteExpr(wxPseudoMetaFile *image);
void ReadExpr(wxPseudoMetaFile *image, wxExpr *expr);
// Draw an outline using the current operation.
virtual bool OnDrawOutline(wxDC& dc, double x, double y, double w, double h,
double oldW, double oldH);
// Get the perimeter point using this data
bool GetPerimeterPoint(double x1, double y1,
double x2, double y2,
double *x3, double *y3,
double xOffset, double yOffset,
int attachmentMode);
public:
wxRealPoint* m_points;
int m_noPoints;
};
#endif
// _OGL_DRAWNP_H_

View File

@@ -0,0 +1,296 @@
/////////////////////////////////////////////////////////////////////////////
// Name: lines.h
// Purpose: wxLineShape
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_LINES_H_
#define _OGL_LINES_H_
#ifdef __GNUG__
#pragma interface "lines.h"
#endif
class wxLabelShape;
class wxPseudoMetaFile;
class wxLineControlPoint;
/*
* Arcs with multiple arrowheads
*
*/
// Types of arrowhead
// (i) Built-in
#define ARROW_HOLLOW_CIRCLE 1
#define ARROW_FILLED_CIRCLE 2
#define ARROW_ARROW 3
#define ARROW_SINGLE_OBLIQUE 4
#define ARROW_DOUBLE_OBLIQUE 5
// (ii) Custom
#define ARROW_METAFILE 20
// Position of arrow on line
#define ARROW_POSITION_START 0
#define ARROW_POSITION_END 1
#define ARROW_POSITION_MIDDLE 2
// Line alignment flags
// Vertical by default
#define LINE_ALIGNMENT_HORIZ 1
#define LINE_ALIGNMENT_VERT 0
#define LINE_ALIGNMENT_TO_NEXT_HANDLE 2
#define LINE_ALIGNMENT_NONE 0
class wxArrowHead: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxArrowHead)
public:
wxArrowHead(WXTYPE type = 0, int end = 0, double size = 0.0, double dist = 0.0, const wxString& name = "", wxPseudoMetaFile *mf = NULL,
long arrowId = -1);
~wxArrowHead();
wxArrowHead(wxArrowHead& toCopy);
inline WXTYPE _GetType() const { return m_arrowType; }
inline int GetPosition() const { return m_arrowEnd; }
inline void SetPosition(int pos) { m_arrowEnd = pos; }
inline double GetXOffset() const { return m_xOffset; }
inline double GetYOffset() const { return m_yOffset; }
inline double GetSpacing() const { return m_spacing; }
inline double GetSize() const { return m_arrowSize; }
inline wxString GetName() const { return m_arrowName; }
inline void SetXOffset(double x) { m_xOffset = x; }
inline void SetYOffset(double y) { m_yOffset = y; }
inline wxPseudoMetaFile *GetMetaFile() const { return m_metaFile; }
inline long GetId() const { return m_id; }
inline int GetArrowEnd() const { return m_arrowEnd; }
inline double GetArrowSize() const { return m_arrowSize; }
void SetSize(double size);
inline void SetSpacing(double sp) { m_spacing = sp; }
protected:
WXTYPE m_arrowType;
int m_arrowEnd; // Position on line
double m_xOffset; // Distance from arc start or end, w.r.t. point on arrowhead
// nearest start or end. If zero, use default spacing.
double m_yOffset; // vertical offset (w.r.t. a horizontal line). Normally zero.
double m_spacing; // Spacing from the last arrowhead
double m_arrowSize; // Length of arrowhead
wxString m_arrowName; // Name of arrow
bool m_saveToFile; // TRUE if we want to save custom arrowheads to file.
wxPseudoMetaFile* m_metaFile; // Pseudo metafile if this is a custom arrowhead
long m_id; // identifier
};
// Line object
class wxLabelShape;
class wxLineShape: public wxShape
{
DECLARE_DYNAMIC_CLASS(wxLineShape)
public:
wxLineShape();
~wxLineShape();
// Called when a connected object has moved, to move the link to
// correct position
// moveControlPoints must be disabled when a control point is being
// dragged.
void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
void OnDrawControlPoints(wxDC& dc);
void OnEraseControlPoints(wxDC& dc);
void OnErase(wxDC& dc);
virtual bool OnMoveControlPoint(int WXUNUSED(which), double WXUNUSED(x), double WXUNUSED(y)) { return FALSE; }
virtual bool OnMoveMiddleControlPoint(wxDC& dc, wxLineControlPoint* lpt, const wxRealPoint& pt);
virtual bool OnLabelMovePre(wxDC& dc, wxLabelShape* labelShape, double x, double y, double old_x, double old_y, bool display);
void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
void GetBoundingBoxMin(double *w, double *h);
void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
virtual void SetEnds(double x1, double y1, double x2, double y2);
virtual void GetEnds(double *x1, double *y1, double *x2, double *y2);
inline virtual wxShape *GetFrom() { return m_from; }
inline virtual wxShape *GetTo() { return m_to; }
inline virtual int GetAttachmentFrom() { return m_attachmentFrom; }
inline virtual int GetAttachmentTo() { return m_attachmentTo; }
virtual void SetFrom(wxShape *object);
virtual void SetTo(wxShape *object);
virtual void DrawArrows(wxDC& dc);
// Finds the x, y points at the two ends of the line.
// This function can be used by e.g. line-routing routines to
// get the actual points on the two node images where the lines will be drawn
// to/from.
void FindLineEndPoints(double *fromX, double *fromY, double *toX, double *toY);
// Format one region at this position
void DrawRegion(wxDC& dc, wxShapeRegion *region, double x, double y);
// Erase one region at this position
void EraseRegion(wxDC& dc, wxShapeRegion *region, double x, double y);
// Get the reference point for a label. Region x and y
// are offsets from this.
// position is 0 (middle), 1 (start), 2 (end)
void GetLabelPosition(int position, double *x, double *y);
// Can override this to create a different class of label shape
virtual wxLabelShape* OnCreateLabelShape(wxLineShape *parent = NULL, wxShapeRegion *region = NULL, double w = 0.0, double h = 0.0);
// Straighten verticals and horizontals
virtual void Straighten(wxDC* dc = NULL);
// Not implemented
inline void SetMaintainStraightLines(bool flag) { m_maintainStraightLines = flag; }
inline bool GetMaintainStraightLines() const { return m_maintainStraightLines; }
// Make handle control points
void MakeControlPoints();
void ResetControlPoints();
// Make a given number of control points
virtual void MakeLineControlPoints(int n);
virtual wxNode *InsertLineControlPoint(wxDC* dc);
virtual bool DeleteLineControlPoint();
virtual void Initialise();
inline wxList *GetLineControlPoints() { return m_lineControlPoints; }
// Override dragging behaviour - don't want to be able to drag lines!
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
// Control points ('handles') redirect control to the actual shape, to make it easier
// to override sizing behaviour.
virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
// Override select, to create/delete temporary label-moving objects
void Select(bool select = TRUE, wxDC* dc = NULL);
// Set to spline (TRUE) or line (FALSE)
inline void SetSpline(bool spl) { m_isSpline = spl; }
inline bool IsSpline() const { return m_isSpline; }
void Unlink();
void SetAttachments(int from_attach, int to_attach);
inline void SetAttachmentFrom(int attach) { m_attachmentFrom = attach; }
inline void SetAttachmentTo(int attach) { m_attachmentTo = attach; }
bool HitTest(double x, double y, int *attachment, double *distance);
#ifdef PROLOGIO
// I/O
virtual void WriteAttributes(wxExpr *clause);
virtual void ReadAttributes(wxExpr *clause);
#endif
virtual void FindNth(wxShape *image, int *nth, int *no_arcs, bool incoming);
// Find which position we're talking about at this (x, y).
// Returns ARROW_POSITION_START, ARROW_POSITION_MIDDLE, ARROW_POSITION_END
int FindLinePosition(double x, double y);
// This is really to distinguish between lines and other images.
// For lines, want to pass drag to canvas, since lines tend to prevent
// dragging on a canvas (they get in the way.)
virtual bool Draggable() const { return FALSE; }
// Does the copying for this object
void Copy(wxShape& copy);
// Add an arrowhead.
wxArrowHead *AddArrow(WXTYPE type, int end = ARROW_POSITION_END,
double arrowSize = 10.0, double xOffset = 0.0, const wxString& name = "",
wxPseudoMetaFile *mf = NULL, long arrowId = -1);
// Add an arrowhead in the position indicated by the reference
// list of arrowheads, which contains all legal arrowheads for this
// line, in the correct order.
// E.g. reference list: a b c d e
// Current line list: a d
// Add c, then line list is: a c d
// If no legal arrowhead position, return FALSE.
// Assume reference list is for one end only, since it potentially defines
// the ordering for any one of the 3 positions. So we don't check
// the reference list for arrowhead position.
bool AddArrowOrdered(wxArrowHead *arrow, wxList& referenceList, int end);
// Delete arrowhead(s)
void ClearArrowsAtPosition(int end = -1);
bool ClearArrow(const wxString& name);
wxArrowHead *FindArrowHead(int position, const wxString& name);
wxArrowHead *FindArrowHead(long arrowId);
bool DeleteArrowHead(int position, const wxString& name);
bool DeleteArrowHead(long arrowId);
void DrawArrow(wxDC& dc, wxArrowHead *arrow, double xOffset, bool proportionalOffset);
inline void SetIgnoreOffsets(bool ignore) { m_ignoreArrowOffsets = ignore; }
inline wxList& GetArrows() const { return (wxList&) m_arcArrows; }
// Find horizontal width for drawing a line with
// arrows in minimum space. Assume arrows at
// END only
double FindMinimumWidth();
// Set alignment flags. ALIGNMENT NOT IMPLEMENTED.
void SetAlignmentOrientation(bool isEnd, bool isHoriz);
void SetAlignmentType(bool isEnd, int alignType);
bool GetAlignmentOrientation(bool isEnd);
int GetAlignmentType(bool isEnd);
// Find next control point in line after the start/end point
// (depending on whether the node object is at start or end)
wxRealPoint *GetNextControlPoint(wxShape *nodeObject);
inline bool IsEnd(wxShape *nodeObject) const { return (m_to == nodeObject); }
private:
bool m_erasing; // flag to say whether we're erasing or drawing
// this line (really so metafiles can draw a
// blank rectangle)
bool m_ignoreArrowOffsets; // Don't always want to draw arrowhead offsets
// because they may not work on tool palettes (for example)
bool m_isSpline;
bool m_maintainStraightLines;
protected:
// Temporary list of line segment orientations
// so we know what direction the line is supposed to be dog-legging
// in. The values are integer: 0 for vertical, 1 for horizontal.
wxList m_lineOrientations;
// Temporary pointers for start, middle and end label editing objects
// (active only when the line is selected)
wxLabelShape* m_labelObjects[3];
// These define the segmented line - not to be confused with temporary control
// points which appear when object is selected (although in this case they'll
// probably be the same)
wxList* m_lineControlPoints;
double m_arrowSpacing; // Separation between adjacent arrows
wxShape* m_to;
wxShape* m_from;
int m_attachmentTo; // Attachment point at one end
int m_attachmentFrom; // Attachment point at other end
// Alignment flags
int m_alignmentStart;
int m_alignmentEnd;
wxList m_arcArrows;
};
#endif
// _OGL_LINES_H_

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////
// Name: linesp.h
// Purpose: Lines private header file
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_LINESP_H_
#define _OGL_LINESP_H_
#ifdef __GNUG__
#pragma interface "linesp.h"
#endif
class wxLineShape;
class wxLineControlPoint: public wxControlPoint
{
DECLARE_DYNAMIC_CLASS(wxLineControlPoint)
friend class wxLineShape;
public:
wxLineControlPoint(wxShapeCanvas *the_canvas = NULL, wxShape *object = NULL, double size = 0.0,
double x = 0.0, double y = 0.0, int the_type = 0);
~wxLineControlPoint();
void OnDraw(wxDC& dc);
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
// Obsolete (left-dragging now moves attachment point to new relative position OR new
// attachment id)
#if 0
void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0);
void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
#endif
public:
int m_type;
wxRealPoint* m_point; // Line point
wxRealPoint m_originalPos;
};
/*
* Temporary arc label object
*/
class wxLabelShape: public wxRectangleShape
{
DECLARE_DYNAMIC_CLASS(wxLabelShape)
public:
wxLabelShape(wxLineShape *parent = NULL, wxShapeRegion *region = NULL, double w = 0.0, double h = 0.0);
~wxLabelShape();
void OnDraw(wxDC& dc);
void OnDrawContents(wxDC& dc);
void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0);
void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
public:
wxLineShape* m_lineShape;
wxShapeRegion* m_shapeRegion;
};
/*
* Get the point on the given line (x1, y1) (x2, y2)
* distance 'length' along from the end,
* returned values in x and y
*/
void GetPointOnLine(double x1, double y1, double x2, double y2,
double length, double *x, double *y);
#endif
// _OGL_LINESP_H_

View File

@@ -0,0 +1,211 @@
/////////////////////////////////////////////////////////////////////////////
// Name: mfutils.h
// Purpose: Metafile utilities: reading a placeable metafile independently
// of Windows.
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _MFUTILS_H_
#define _MFUTILS_H_
#ifdef __GNUG__
#pragma interface "mfutils.h"
#endif
#include <wx/metafile.h>
#ifndef GetRValue
#define GetRValue(rgb) ((unsigned char)(rgb))
#define GetGValue(rgb) ((unsigned char)(((int)(rgb)) >> 8))
#define GetBValue(rgb) ((unsigned char)((rgb)>>16))
#endif
/* Metafile Functions */
/* Win32s/Borland need these macros, although META_SETBKCOLOR is defined */
#if 1 // !defined(META_SETBKCOLOR) // || defined(WIN32)
#define META_SETBKCOLOR 0x0201
#define META_SETBKMODE 0x0102
#define META_SETMAPMODE 0x0103
#define META_SETROP2 0x0104
#define META_SETRELABS 0x0105
#define META_SETPOLYFILLMODE 0x0106
#define META_SETSTRETCHBLTMODE 0x0107
#define META_SETTEXTCHAREXTRA 0x0108
#define META_SETTEXTCOLOR 0x0209
#define META_SETTEXTJUSTIFICATION 0x020A
#define META_SETWINDOWORG 0x020B
#define META_SETWINDOWEXT 0x020C
#define META_SETVIEWPORTORG 0x020D
#define META_SETVIEWPORTEXT 0x020E
#define META_OFFSETWINDOWORG 0x020F
#define META_SCALEWINDOWEXT 0x0410
#define META_OFFSETVIEWPORTORG 0x0211
#define META_SCALEVIEWPORTEXT 0x0412
#define META_LINETO 0x0213
#define META_MOVETO 0x0214
#define META_EXCLUDECLIPRECT 0x0415
#define META_INTERSECTCLIPRECT 0x0416
#define META_ARC 0x0817
#define META_ELLIPSE 0x0418
#define META_FLOODFILL 0x0419
#define META_PIE 0x081A
#define META_RECTANGLE 0x041B
#define META_ROUNDRECT 0x061C
#define META_PATBLT 0x061D
#define META_SAVEDC 0x001E
#define META_SETPIXEL 0x041F
#define META_OFFSETCLIPRGN 0x0220
#define META_TEXTOUT 0x0521
#define META_BITBLT 0x0922
#define META_STRETCHBLT 0x0B23
#define META_POLYGON 0x0324
#define META_POLYLINE 0x0325
#define META_ESCAPE 0x0626
#define META_RESTOREDC 0x0127
#define META_FILLREGION 0x0228
#define META_FRAMEREGION 0x0429
#define META_INVERTREGION 0x012A
#define META_PAINTREGION 0x012B
#define META_SELECTCLIPREGION 0x012C
#define META_SELECTOBJECT 0x012D
#define META_SETTEXTALIGN 0x012E
#define META_DRAWTEXT 0x062F
#define META_CHORD 0x0830
#define META_SETMAPPERFLAGS 0x0231
#define META_EXTTEXTOUT 0x0a32
#define META_SETDIBTODEV 0x0d33
#define META_SELECTPALETTE 0x0234
#define META_REALIZEPALETTE 0x0035
#define META_ANIMATEPALETTE 0x0436
#define META_SETPALENTRIES 0x0037
#define META_POLYPOLYGON 0x0538
#define META_RESIZEPALETTE 0x0139
#define META_DIBBITBLT 0x0940
#define META_DIBSTRETCHBLT 0x0b41
#define META_DIBCREATEPATTERNBRUSH 0x0142
#define META_STRETCHDIB 0x0f43
#define META_EXTFLOODFILL 0x0548
#define META_RESETDC 0x014C
#define META_STARTDOC 0x014D
#define META_STARTPAGE 0x004F
#define META_ENDPAGE 0x0050
#define META_ABORTDOC 0x0052
#define META_ENDDOC 0x005E
#define META_DELETEOBJECT 0x01f0
#define META_CREATEPALETTE 0x00f7
#define META_CREATEBRUSH 0x00F8
#define META_CREATEPATTERNBRUSH 0x01F9
#define META_CREATEPENINDIRECT 0x02FA
#define META_CREATEFONTINDIRECT 0x02FB
#define META_CREATEBRUSHINDIRECT 0x02FC
#define META_CREATEBITMAPINDIRECT 0x02FD
#define META_CREATEBITMAP 0x06FE
#define META_CREATEREGION 0x06FF
/* Background Modes */
#define TRANSPARENT 1
#define OPAQUE 2
/* Pen Styles */
#define PS_SOLID 0
#define PS_DASH 1
#define PS_DOT 2
#define PS_DASHDOT 3
#define PS_DASHDOTDOT 4
#define PS_NULL 5
#define PS_INSIDEFRAME 6
/* PitchAndFamily family values (high 4 bits) */
/* Win32s/Borland don't need this */
#ifndef FF_DONTCARE // !defined(__BORLANDC__) && !defined(WIN32)
#define FF_DONTCARE 0x00
#define FF_ROMAN 0x10
#define FF_SWISS 0x20
#define FF_MODERN 0x30
#define FF_SCRIPT 0x40
#define FF_DECORATIVE 0x50
#endif
/* Brush Styles */
#define BS_SOLID 0
#define BS_NULL 1
#define BS_HOLLOW BS_NULL
#define BS_HATCHED 2
#define BS_PATTERN 3
#define BS_INDEXED 4
#define BS_DIBPATTERN 5
/* Hatch Styles */
#define HS_HORIZONTAL 0
#define HS_VERTICAL 1
#define HS_FDIAGONAL 2
#define HS_BDIAGONAL 3
#define HS_CROSS 4
#define HS_DIAGCROSS 5
#endif // metafile functions
class wxMetaRecord: public wxObject
{
public:
int metaFunction;
long param1;
long param2;
long param3;
long param4;
long param5;
long param6;
long param7;
long param8;
char *stringParam;
wxRealPoint *points;
wxMetaRecord(int fun)
{
metaFunction = fun; points = NULL; stringParam = NULL;
param1 = 0;
}
~wxMetaRecord(void);
};
class wxXMetaFile: public wxObject
{
public:
double lastX;
double lastY;
bool ok;
double left;
double top;
double right;
double bottom;
wxList metaRecords;
wxList gdiObjects; // List of wxMetaRecord objects created with Create...,
// referenced by position in list by SelectObject
wxXMetaFile(char *file = NULL);
~wxXMetaFile(void);
// After this is called, the metafile cannot be used for anything
// since it is now owned by the clipboard.
bool SetClipboard(int width = 0, int height = 0);
bool Play(wxDC *dc);
inline bool Ok(void) const { return ok; }
bool ReadFile(char *file);
};
#endif
// _MFUTILS_H_

View File

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////
// Name: misc.h
// Purpose: Miscellaneous utilities for OGL
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_MISC_H_
#define _OGL_MISC_H_
#ifdef __GNUG__
#pragma interface "misc.h"
#endif
// List to use when copying objects; may need to associate elements of new objects
// with elements of old objects, e.g. when copying constraint.s
extern wxList oglObjectCopyMapping;
/*
* TEXT FORMATTING FUNCTIONS
*
*/
// Centres the given list of wxShapeTextLine strings in the given box
// (changing the positions in situ). Doesn't actually draw into the DC.
void oglCentreText(wxDC& dc, wxList *text, double m_xpos, double m_ypos,
double width, double height,
int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT);
// Given a string, returns a list of strings that fit within the given
// width of box. Height is ignored.
wxStringList *oglFormatText(wxDC& dc, const wxString& text, double width, double height, int formatMode = 0);
// Centres the list of wxShapeTextLine strings, doesn't clip.
// Doesn't actually draw into the DC.
void oglCentreTextNoClipping(wxDC& dc, wxList *text_list,
double m_xpos, double m_ypos, double width, double height);
// Gets the maximum width and height of the given list of wxShapeTextLines.
void oglGetCentredTextExtent(wxDC& dc, wxList *text_list,
double m_xpos, double m_ypos, double width, double height,
double *actual_width, double *actual_height);
// Actually draw the preformatted list of wxShapeTextLines.
void oglDrawFormattedText(wxDC& context, wxList *text_list,
double m_xpos, double m_ypos, double width, double height,
int formatMode = FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT);
// Give it a list of points, finds the centre.
void oglFindPolylineCentroid(wxList *points, double *x, double *y);
void oglCheckLineIntersection(double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4,
double *ratio1, double *ratio2);
void oglFindEndForPolyline(double n, double xvec[], double yvec[],
double x1, double y1, double x2, double y2, double *x3, double *y3);
void oglFindEndForBox(double width, double height,
double x1, double y1, // Centre of box (possibly)
double x2, double y2, // other end of line
double *x3, double *y3); // End on box edge
void oglFindEndForCircle(double radius,
double x1, double y1, // Centre of circle
double x2, double y2, // Other end of line
double *x3, double *y3);
void oglGetArrowPoints(double x1, double y1, double x2, double y2,
double length, double width,
double *tip_x, double *tip_y,
double *side1_x, double *side1_y,
double *side2_x, double *side2_y);
/*
* Given an ellipse and endpoints of a line, returns the point at which
* the line touches the ellipse in values x4, y4.
* This function assumes that the centre of the ellipse is at x1, y1, and the
* ellipse has a width of a1 and a height of b1. It also assumes you are
* wanting to draw an arc FROM point x2, y2 TOWARDS point x3, y3.
* This function calculates the x,y coordinates of the intersection point of
* the arc with the ellipse.
* Author: Ian Harrison
*/
void oglDrawArcToEllipse(double x1, double y1, double a1, double b1, double x2, double y2, double x3, double y3,
double *x4, double *y4);
bool oglRoughlyEqual(double val1, double val2, double tol = 0.00001);
extern wxFont* g_oglNormalFont;
extern wxPen* g_oglBlackPen;
extern wxPen* g_oglWhiteBackgroundPen;
extern wxPen* g_oglTransparentPen;
extern wxBrush* g_oglWhiteBackgroundBrush;
extern wxPen* g_oglBlackForegroundPen;
extern wxCursor* g_oglBullseyeCursor;
extern wxFont* oglMatchFont(int point_size);
extern wxString oglColourToHex(const wxColour& colour);
extern wxColour oglHexToColour(const wxString& hex);
extern void oglDecToHex(unsigned int dec, char *buf);
extern unsigned int oglHexToDec(char* buf);
#endif
// _OGL_MISC_H_

View File

@@ -0,0 +1,27 @@
/////////////////////////////////////////////////////////////////////////////
// Name: ogl.h
// Purpose: OGL main include
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_OGL_H_
#define _OGL_OGL_H_
#include <wx/ogl/basic.h> // Basic shapes
#include <wx/ogl/lines.h> // Lines and splines
#include <wx/ogl/divided.h> // Vertically-divided rectangle
#include <wx/ogl/composit.h> // Composite images
#include <wx/ogl/canvas.h> // wxShapeCanvas for displaying objects
#include <wx/ogl/ogldiag.h> // wxDiagram
// TODO: replace with wxModule implementation
extern void wxOGLInitialize();
extern void wxOGLCleanUp();
#endif
// _OGL_OGL_H_

View File

@@ -0,0 +1,124 @@
/////////////////////////////////////////////////////////////////////////////
// Name: ogldiag.h
// Purpose: OGL - wxDiagram class
// Author: Julian Smart
// Modified by:
// Created: 12/07/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _OGL_OGLDIAG_H_
#define _OGL_OGLDIAG_H_
#ifdef __GNUG__
#pragma interface "ogldiag.h"
#endif
#include <wx/ogl/basic.h>
class wxDiagram: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxDiagram)
public:
wxDiagram();
virtual ~wxDiagram();
void SetCanvas(wxShapeCanvas *can);
inline wxShapeCanvas *GetCanvas() const { return m_diagramCanvas; }
virtual void Redraw(wxDC& dc);
virtual void Clear(wxDC& dc);
virtual void DrawOutline(wxDC& dc, double x1, double y1, double x2, double y2);
// Add object to end of object list (if addAfter is NULL)
// or just after addAfter.
virtual void AddShape(wxShape *object, wxShape *addAfter = NULL);
// Add object to front of object list
virtual void InsertShape(wxShape *object);
void SetSnapToGrid(bool snap);
void SetGridSpacing(double spacing);
inline double GetGridSpacing() const { return m_gridSpacing; }
inline bool GetSnapToGrid() const { return m_snapToGrid; }
void Snap(double *x, double *y);
inline void SetQuickEditMode(bool qem) { m_quickEditMode = qem; }
inline bool GetQuickEditMode() const { return m_quickEditMode; }
virtual void RemoveShape(wxShape *object);
virtual void RemoveAllShapes();
virtual void DeleteAllShapes();
virtual void ShowAll(bool show);
// Find a shape by its id
wxShape* FindShape(long id) const;
inline void SetMouseTolerance(int tol) { m_mouseTolerance = tol; }
inline int GetMouseTolerance() const { return m_mouseTolerance; }
inline wxList *GetShapeList() const { return m_shapeList; }
inline int GetCount() const { return m_shapeList->Number(); }
// Make sure all text that should be centred, is centred.
void RecentreAll(wxDC& dc);
#ifdef PROLOGIO
virtual bool SaveFile(const wxString& filename);
virtual bool LoadFile(const wxString& filename);
virtual void ReadNodes(wxExprDatabase& database);
virtual void ReadLines(wxExprDatabase& database);
virtual void ReadContainerGeometry(wxExprDatabase& database);
// Allow for modifying file
virtual bool OnDatabaseLoad(wxExprDatabase& db);
virtual bool OnDatabaseSave(wxExprDatabase& db);
virtual bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
virtual bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr);
virtual bool OnHeaderSave(wxExprDatabase& db, wxExpr& expr);
virtual bool OnHeaderLoad(wxExprDatabase& db, wxExpr& expr);
#endif
protected:
wxShapeCanvas* m_diagramCanvas;
bool m_quickEditMode;
bool m_snapToGrid;
double m_gridSpacing;
int m_mouseTolerance;
wxList* m_shapeList;
};
class wxLineCrossing: public wxObject
{
public:
wxLineCrossing() { m_lineShape1 = NULL; m_lineShape2 = NULL; }
wxRealPoint m_pt1; // First line
wxRealPoint m_pt2;
wxRealPoint m_pt3; // Second line
wxRealPoint m_pt4;
wxRealPoint m_intersect;
wxLineShape* m_lineShape1;
wxLineShape* m_lineShape2;
};
class wxLineCrossings: public wxObject
{
public:
wxLineCrossings();
~wxLineCrossings();
void FindCrossings(wxDiagram& diagram);
void DrawCrossings(wxDiagram& diagram, wxDC& dc);
void ClearCrossings();
public:
wxList m_crossings;
};
#endif
// _OGL_OGLDIAG_H_