X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/42cfaf8cd4464466398ed888cb2caa5ee360c7ef..35c9d9582be4ebea40251378e95fdbbfe6b8ce73:/utils/ogl/src/basic.h?ds=sidebyside diff --git a/utils/ogl/src/basic.h b/utils/ogl/src/basic.h index bc3bb5f356..8374b2c345 100644 --- a/utils/ogl/src/basic.h +++ b/utils/ogl/src/basic.h @@ -94,6 +94,15 @@ #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; @@ -127,11 +136,13 @@ class wxShapeEvtHandler: public wxObject 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); @@ -211,6 +222,7 @@ class wxShape: public wxShapeEvtHandler 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); @@ -269,11 +281,13 @@ class wxShape: public wxShapeEvtHandler 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 wxList& GetLines() { return m_lines; } + 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(bool flag) { m_attachmentMode = flag; } - inline bool GetAttachmentMode() const { return m_attachmentMode; } + 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; } @@ -364,10 +378,9 @@ class wxShape: public wxShapeEvtHandler void RemoveLine(wxLineShape *line); #ifdef PROLOGIO - // Prolog database stuff - virtual char *GetFunctor(); - virtual void WritePrologAttributes(wxExpr *clause); - virtual void ReadPrologAttributes(wxExpr *clause); + // 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)) { }; @@ -378,23 +391,29 @@ class wxShape: public wxShapeEvtHandler // Attachment code virtual bool GetAttachmentPosition(int attachment, double *x, double *y, int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); - virtual int GetNumberOfAttachments(); - virtual bool AttachmentIsValid(int attachment); + 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. - wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2, + 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. - bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2); + 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 void MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move, + virtual bool MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move, double x, double y); // Reorders the lines coming into the node image at this attachment @@ -407,6 +426,59 @@ class wxShape: public wxShapeEvtHandler // 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.) @@ -425,11 +497,8 @@ class wxShape: public wxShapeEvtHandler // handler data if any. Calls the virtual Copy function. void CopyWithHandler(wxShape& copy); - // Rotate about the given axis by the given amount in radians - // (does nothing for most objects) - // But even non-rotating objects should record their notional - // rotation in case it's important (e.g. in dog-leg code). - virtual inline void Rotate(double WXUNUSED(x), double WXUNUSED(y), double theta) { m_rotation = theta; } + // 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(); @@ -446,7 +515,7 @@ class wxShape: public wxShapeEvtHandler protected: wxShapeEvtHandler* m_eventHandler; bool m_formatted; - double m_xpos, m_ypos; + double m_xpos, m_ypos; wxPen* m_pen; wxBrush* m_brush; wxFont* m_font; @@ -464,10 +533,11 @@ class wxShape: public wxShapeEvtHandler bool m_selected; bool m_highlighted; // Different from selected: user-defined highlighting, // e.g. thick border. - double m_rotation; + double m_rotation; int m_sensitivity; bool m_draggable; - bool m_attachmentMode; // TRUE if using attachments, FALSE otherwise + 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; @@ -483,6 +553,11 @@ class wxShape: public wxShapeEvtHandler 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 @@ -533,12 +608,11 @@ class wxPolygonShape: public wxShape virtual void CalculatePolygonCentre(); #ifdef PROLOGIO - // Prolog database stuff - void WritePrologAttributes(wxExpr *clause); - void ReadPrologAttributes(wxExpr *clause); + void WriteAttributes(wxExpr *clause); + void ReadAttributes(wxExpr *clause); #endif - int GetNumberOfAttachments(); + 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); @@ -547,13 +621,16 @@ class wxPolygonShape: public wxShape 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; + double m_boundWidth; + double m_boundHeight; + double m_originalWidth; + double m_originalHeight; }; class wxRectangleShape: public wxShape @@ -570,12 +647,11 @@ class wxRectangleShape: public wxShape void SetCornerRadius(double rad); // If > 0, rounded corners #ifdef PROLOGIO - // Prolog database stuff - void WritePrologAttributes(wxExpr *clause); - void ReadPrologAttributes(wxExpr *clause); + void WriteAttributes(wxExpr *clause); + void ReadAttributes(wxExpr *clause); #endif - int GetNumberOfAttachments(); + 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 @@ -601,7 +677,7 @@ class wxTextShape: public wxRectangleShape void OnDraw(wxDC& dc); #ifdef PROLOGIO - void WritePrologAttributes(wxExpr *clause); + void WriteAttributes(wxExpr *clause); #endif // Does the copying for this object @@ -623,12 +699,11 @@ class wxEllipseShape: public wxShape void SetSize(double x, double y, bool recursive = TRUE); #ifdef PROLOGIO - // Prolog database stuff - void WritePrologAttributes(wxExpr *clause); - void ReadPrologAttributes(wxExpr *clause); + void WriteAttributes(wxExpr *clause); + void ReadAttributes(wxExpr *clause); #endif - int GetNumberOfAttachments(); + int GetNumberOfAttachments() const; bool GetAttachmentPosition(int attachment, double *x, double *y, int nth = 0, int no_arcs = 1, wxLineShape *line = NULL); @@ -638,6 +713,9 @@ class wxEllipseShape: public wxShape 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;