CODLineComponent Class
class CODLineComponent: public CODPointComponent
A line component is one or more line segments consisting of two or more vertices. The Create method allows the caller to supply the set of vertices for the line. Endpoint objects can be attached to a line by calling the functions SetSourceEndpoint and SetTargetEndpoint. An endpoint is an object that is derived from the CODEndpoint class and that draws an adornment, such as an arrow or circle, for either endpoint of a line.The boolean property OD_PROP_ORTHOGONAL can be set for a line component to force the line to maintain 90 degree angles at each vertex. The SetOrthogonal method sets the OD_PROP_ORTHOGONAL property and the IsOrthogonal method returns the value of the OD_PROP_ORTHOGONAL property. The TestOrthogonality method tests the angle at each vertex to verify that all angles are 90 degrees. The MakeOrthogonal adjusts the vertices of the line so that all angles are 90 degrees. The MakeOrthogonal method uses the integer properties to determine the minimum amount of spacing between vertices when line segments must be added to make the line orthogonal: OD_PROP_LINEPAD_LEFT, OD_PROP_LINEPAD_TOP, OD_PROP_LINEPAD_RIGHT, OD_PROP_LINEPAD_BOTTOM.
The following properties are added to the component by this class:
OD_PROP_LINE, OD_PROP_ORTHOGONAL, OD_PROP_LINEPAD_LEFT, OD_PROP_LINEPAD_TOP, OD_PROP_LINEPAD_RIGHT, OD_PROP_LINEPAD_BOTTOM.
Defined in: OdLineComp.h
See Also
Component Property Identifiers
Class Members
Constructor.
CODLineComponent(const CODLineComponent& src)
Copy constructor.
virtual ~CODLineComponent()
Destructor.
BOOL Create(CODPointArray* pPointArray)
Creates the line component from an array of points.
BOOL Create(LPPOINT lpPoints, int nCount)
Creates the line component from an array of points.
CODLineComponent& operator=(const CODLineComponent& src)
Assignment operator.
virtual CODComponent* Dup() const
Create a duplicate copy of this object.
CODEndpoint* m_pSourceEndpoint
Representation of the source endpoint.
CODEndpoint* m_pTargetEndpoint
Representation of the target endpoint.
CODEndpoint* GetSourceEndpoint()
Gets the representation of the source endpoint.
void SetSourceEndpoint(CODEndpoint* pEndpoint)
Sets the representation of the source endpoint.
CODEndpoint* GetTargetEndpoint()
Gets the representation of the target endpoint.
void SetTargetEndpoint(CODEndpoint* pEndpoint)
Sets the representation of the target endpoint.
int GetLineLength()
Gets the total length of the line.
CPoint FindPercentageAlong(int nPercent)
Finds the point at a certain percentage along the line.
CPoint FindPercentageAlong(int nPercent, int& nVertex1, int& nVertex2)
Finds the point at a certain percentage along the line.
BOOL IsOrthogonal() const
Returns boolean that indicates if 90 degree angles are enforced.
void SetOrthogonal(const BOOL bFlag)
Sets boolean that indicates if 90 degree angles should be enforced.
virtual BOOL TestOrthogonality() const
Determines if the line is currently orthogonal.
void MakeOrthogonal()
Updates the points in the line so that it is orthogonal.
void MakeOrthogonal(const CSize& szDirEndPt1, const CSize& szDirEndPt2)
Updates the points in the line so that it is orthogonal.
virtual void CalcEndpointDirections(CSize& szDirPt1, CSize& szDirPt2)
Calculates a direction vector for each endpoint.
virtual CPoint GetOrthogonalPoint(const int nRow, const int nCol, const CRect& rcPadding)
Returns a point orthogonal to the two endpoints of the line.
virtual void CalcOrthogonalPoints(CODPointArray& ptsOut, const CSize& szDirEndPt1, const CSize& szDirEndPt2)
Returns the set of points needed to connect the endpoints of the line using line segments that form 90 degree angles.
virtual OD_MOVEVERTEX_RC CalculateMovedVertices(int nIndex, int nOffsetX, int nOffsetY)
Calculates the new position of a vertex given an offset.
virtual BOOL CanInsertVertex()
Returns non-zero if a vertex can be inserted (lines always can have additional vertices so this override always returns TRUE.
virtual BOOL CanDeleteVertex()
Returns non-zero if a vertex can be deleted (lines can have no fewer than 2 vertices).
virtual void OnDraw(CDC* pDC)
Draws the line.
virtual void DrawSourceEndpoint(CDC* pDC)
Draws the source endpoint.
virtual void DrawTargetEndpoint(CDC* pDC)
Draws the target endpoint.
virtual CODRgn GetEdgeRgn()
Returns a region surrounding the edges of the component. In the case of a line component, it is the same as the normal region.
virtual void CalculateRgn(CODRgn* pRgn)
Calculates the region of the window taken up by the line component.
virtual void Serialize(CArchive& ar)
Serializes the line component.