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

VIEWS_API CODLineComponent()

Constructor.

VIEWS_API CODLineComponent(const CODLineComponent& src)

Copy constructor.

VIEWS_API virtual ~CODLineComponent()

Destructor.

VIEWS_API BOOL Create(CODPointArray* pPointArray)

Creates the line component from an array of points.

VIEWS_API BOOL Create(LPPOINT lpPoints, int nCount)

Creates the line component from an array of points.

VIEWS_API CODLineComponent& operator=(const CODLineComponent& src)

Assignment operator.

VIEWS_API 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.

VIEWS_API CODEndpoint* GetSourceEndpoint()

Gets the representation of the source endpoint.

VIEWS_API void SetSourceEndpoint(CODEndpoint* pEndpoint)

Sets the representation of the source endpoint.

VIEWS_API CODEndpoint* GetTargetEndpoint()

Gets the representation of the target endpoint.

VIEWS_API void SetTargetEndpoint(CODEndpoint* pEndpoint)

Sets the representation of the target endpoint.

VIEWS_API int GetLineLength()

Gets the total length of the line.

VIEWS_API CPoint FindPercentageAlong(int nPercent)

Finds the point at a certain percentage along the line.

VIEWS_API CPoint FindPercentageAlong(int nPercent, int& nVertex1, int& nVertex2)

Finds the point at a certain percentage along the line.

VIEWS_API BOOL IsOrthogonal() const

Returns boolean that indicates if 90 degree angles are enforced.

VIEWS_API void SetOrthogonal(const BOOL bFlag)

Sets boolean that indicates if 90 degree angles should be enforced.

VIEWS_API virtual BOOL TestOrthogonality() const

Determines if the line is currently orthogonal.

VIEWS_API void MakeOrthogonal()

Updates the points in the line so that it is orthogonal.

VIEWS_API void MakeOrthogonal(const CSize& szDirEndPt1, const CSize& szDirEndPt2)

Updates the points in the line so that it is orthogonal.

VIEWS_API virtual void CalcEndpointDirections(CSize& szDirPt1, CSize& szDirPt2)

Calculates a direction vector for each endpoint.

VIEWS_API virtual CPoint GetOrthogonalPoint(const int nRow, const int nCol, const CRect& rcPadding)

Returns a point orthogonal to the two endpoints of the line.

VIEWS_API 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.

VIEWS_API virtual OD_MOVEVERTEX_RC CalculateMovedVertices(int nIndex, int nOffsetX, int nOffsetY)

Calculates the new position of a vertex given an offset.

VIEWS_API virtual BOOL CanInsertVertex()

Returns non-zero if a vertex can be inserted (lines always can have additional vertices so this override always returns TRUE.

VIEWS_API virtual BOOL CanDeleteVertex()

Returns non-zero if a vertex can be deleted (lines can have no fewer than 2 vertices).

VIEWS_API virtual void OnDraw(CDC* pDC)

Draws the line.

VIEWS_API virtual void DrawSourceEndpoint(CDC* pDC)

Draws the source endpoint.

VIEWS_API virtual void DrawTargetEndpoint(CDC* pDC)

Draws the target endpoint.

VIEWS_API 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.

VIEWS_API virtual void CalculateRgn(CODRgn* pRgn)

Calculates the region of the window taken up by the line component.

VIEWS_API virtual void Serialize(CArchive& ar)

Serializes the line component.