File: OrthoShape.h

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (127 lines) | stat: -rwxr-xr-x 5,039 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/***************************************************************
 * Name:      OrthoShape.h
 * Purpose:   Defines orthogonal line shape class
 * Author:    Michal Bližňák (michal.bliznak@gmail.com)
 * Created:   2009-04-26
 * Copyright: Michal Bližňák
 * License:   wxWidgets license (www.wxwidgets.org)
 * Notes:
 **************************************************************/

#ifndef _WXSFORTHOSHAPE_H
#define _WXSFORTHOSHAPE_H

#include <wx/wxsf/LineShape.h>

/*!
 * \brief Orthogonal line shape. The class extends wxSFLineShape class and allows
 * user to create connection line orthgonal to base axis.
 */
class WXDLLIMPEXP_SF wxSFOrthoLineShape : public wxSFLineShape
{
public:
    XS_DECLARE_CLONABLE_CLASS(wxSFOrthoLineShape);
	
	/*! \brief Connection points used by the line segment */
	typedef struct _SEGMENTCPS {
		const wxSFConnectionPoint *cpSrc;
		const wxSFConnectionPoint *cpTrg;
	} SEGMENTCPS;

    /*! \brief Default constructor. */
    wxSFOrthoLineShape();
    /*!
     * \brief User constructor.
     * \param src ID of the source shape
     * \param trg ID of the target shape
     * \param path Array of line's control points
     * \param manager Parent parent diagram manager
     */
	wxSFOrthoLineShape(long src, long trg, const wxXS::RealPointList& path, wxSFDiagramManager* manager);
	/*!
     * \brief Copy constructor.
	 * \param obj Reference to the source object
	 */
	wxSFOrthoLineShape(const wxSFOrthoLineShape& obj);
	/*! \brief Destructor. */
    virtual ~wxSFOrthoLineShape();

protected:

    // protected virtual functions
    /*!
     * \brief Internal function used for drawing of completed line shape.
     * \param dc Refernce of the device context where the shape will be darwn to
     */
	virtual void DrawCompleteLine(wxDC& dc);
	/*!
     * \brief Get index of the line segment intersecting the given point.
	 * \param pos Examined point
	 * \return Zero-based index of line segment located under the given point
	 */
	virtual int GetHitLinesegment(const wxPoint& pos);
	/**
	 * \brief Draw one orthogonal line segment.
	 * \param dc Device context
	 * \param src Starting point of the ortho line segment
	 * \param trg Ending point of the ortho line segment
	 * \param cps Connection points used by the line segment
	 */
	virtual void DrawLineSegment(wxDC& dc, const wxRealPoint& src, const wxRealPoint& trg, const SEGMENTCPS& cps );

	// protected functions
	/**
	 * \brief Get first part of orthogonal line segment.
	 * \param src Staring point of the ortho line segment
	 * \param trg Ending point of the ortho line segment
	 * \param subsrc Starting point of the first part of ortho line segment
	 * \param subtrg Ending point of the first part of ortho line segment
	 * \param cps Connection points used by the line segment
	 */
	void GetFirstSubsegment( const wxRealPoint& src, const wxRealPoint& trg, wxRealPoint& subsrc, wxRealPoint& subtrg, const SEGMENTCPS& cps );
	/**
	 * \brief Get middle part of orthogonal line segment.
	 * \param src Staring point of the ortho line segment
	 * \param trg Ending point of the ortho line segment
	 * \param subsrc Starting point of the second part of ortho line segment
	 * \param subtrg Ending point of the second part of ortho line segment
	 * \param cps Connection points used by the line segment
	 */
	void GetMiddleSubsegment( const wxRealPoint& src, const wxRealPoint& trg, wxRealPoint& subsrc, wxRealPoint& subtrg, const SEGMENTCPS& cps );
	/**
	 * \brief Get last part of orthogonal line segment.
	 * \param src Staring point of the ortho line segment
	 * \param trg Ending point of the ortho line segment
	 * \param subsrc Starting point of the third part of ortho line segment
	 * \param subtrg Ending point of the third part of ortho line segment
	 * \param cps Connection points used by the line segment
	 */
	void GetLastSubsegment( const wxRealPoint& src, const wxRealPoint& trg, wxRealPoint& subsrc, wxRealPoint& subtrg, const SEGMENTCPS& cps );
	
	/*!
	 * \brief Get direction of the line segment.
	 * \param src Staring point of the ortho line segment
	 * \param trg Ending point of the ortho line segment
	 * \param cps Connection points used by the line segment
	 * \return Direction number
	 */
	double GetSegmentDirection(const wxRealPoint& src, const wxRealPoint& trg, const SEGMENTCPS& cps );
	
	/*!
	 * \brief Determine which available connection points are used by given line segment.
	 * \param src Potential source connection point (can be NULL)
	 * \param trg Potential target connection point (can be NULL)
	 * \param i Index of the line segment
	 * \return Structure containing used connection points
	 */
	SEGMENTCPS GetUsedConnectionPoints( const wxSFConnectionPoint *src, const wxSFConnectionPoint *trg, size_t i) const;
	
	/*!
	 * \brief Determine whether a line using give connection point should be drawn as two-segmented.
	 * \param cps Used connection points
	 * \return TRUE if the line should be just two-segmented
	 */
	bool IsTwoSegment( const SEGMENTCPS& cps);
};

#endif //_WXSFORTHOSHAPE_H