CODLinkComponent Class

class CODLinkComponent: public CODSymbolComponent, public IODVertices, public IODEdge

Link components are symbols that have at least two ports, where one port is designated as the tail and another port is designated as the head. The head and tail ports can be connected to ports on other symbols, and the link adjusts itself so that it "docks" with the ports it is connected to. The ports on other symbols that are connected to the tail and head port of the link are referred to as the source and and target ports, respectively. The dependent component connected to the tail port is the source component and the dependent component connected to the head port is the target component.

The link uses the IODLinkShape interface to dock itself to the source and target. The IODLinkShape interface allows the link to synchronize the head and tail ports with some arbitrary shape. By default, the link shape is a line. The IODLinkShape interface is implemented by classes derived from CODComponent, so any type of component can represent the link shape as long as it supports this interface. The link shape determines how the head and tail ports map to actual points.

The function AdjustPoints adjusts the link shape so that it docks with the source and target ports. It calls the IODLinkShape::Dock method and allows the shape to determine how to adjust itself to dock with the source and target ports. The AdjustPoints method is called from OnConnectionMove if the OD_PROP_FOLLOW_CONNECTION property is set to TRUE. This boolean property forces the link to follow or re-dock itself when the source or target ports move.

Links implement the IODEdge interface, which provides methods to traverse symbols and links as a directed or undirected graph. An edge is a graph element that connects two components that support the IODNode interface.

The following properties are added to the component by this class:

OD_PROP_LINK_SPACING

Defined in: OdLinkComp.h

See Also

CODSymbolComponent, IODVertices, IODEdge, IODLinkShape

Class Members

VIEWS_API CODLinkComponent()

Constructor.

VIEWS_API virtual ~CODLinkComponent()

Destructor.

IODLinkShape* m_pILinkShape

Interface to object that implements the link shape.

VIEWS_API BOOL Create(CODPointArray* pPointArray, CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)

Creates the link component from an array of points.

VIEWS_API BOOL Create(LPPOINT lpPoints, int nCount, CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)

Creates the link component from an array of points.

VIEWS_API BOOL Create(CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)

Creates the link component with two vertices.

VIEWS_API BOOL CreateOrthogonal(CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)

Create the line using an orthogonal line as the shape.

VIEWS_API virtual ODComponentId GetID() const

Return the component ID of the link.

VIEWS_API virtual CODConnection* ConnectTail(CODPortComponent* pTargetPort)

Create a connection to the tail port.

VIEWS_API virtual CODConnection* ConnectHead(CODPortComponent* pTargetPort)

Create a connection to the head port.

VIEWS_API virtual void DisconnectTail()

Delete the connection to the tail port.

VIEWS_API virtual void DisconnectHead()

Delete the connection to the tail port.

VIEWS_API CODPortComponent* GetSourcePort() const

Return connected port on the source component.

VIEWS_API CODPortComponent* GetTargetPort() const

Return connected port on the target component.

VIEWS_API CODComponent* GetSourceComponent() const

Gets a pointer to the component at the source end of the link.

VIEWS_API CODComponent* GetTargetComponent() const

Gets a pointer to the component at the target end of the link.

VIEWS_API CODComponent* GetTailComponent() const

Gets a pointer to the component at the source end of the link (obsolete).

VIEWS_API CODComponent* GetHeadComponent() const

Gets a pointer to the component at the target end of the link (obsolete).

VIEWS_API virtual BOOL AcceptConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)

Gets a pointer to the port at the source end of the link.

VIEWS_API virtual BOOL AcceptConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)

Gets a pointer to the port at the target end of the link.

VIEWS_API virtual BOOL AcceptConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)

Determines if the two given ports can be connected.

VIEWS_API virtual BOOL MovePort(CODPortComponent* pPort, const int nOffsetX, const int nOffsetY)

Moves a port attached to the symbol.

VIEWS_API virtual BOOL FollowConnection(CODConnection* pConnection)

Adjust endpoint to follow the given connection.

VIEWS_API virtual BOOL AssignShape(IODLinkShape* pILinkShape)

Assign a shape to the link.

VIEWS_API IODLinkShape* GetShape() const

Return a pointer to the shape interface for this link.

VIEWS_API virtual void UpdatePorts()

Updates the position of the tail and head port to match the link shape.

VIEWS_API virtual void AdjustPoints()

Adjusts the link shape to dock with the source and target ports.

VIEWS_API virtual CODLabelComponent* CreateLabel(const LPCTSTR lpszText, const OD_CONTROL_POINT ctlPoint, CDC* pDC = NULL)

Creates a new label and adds it to the symbol.

VIEWS_API virtual CODLabelComponent* CreateLabel(const LPCTSTR lpszText, CDC* pDC = NULL)

Creates a new label and adds it to the symbol.

VIEWS_API virtual CPoint CalcLabelPosition(CODLabelComponent* pLabel)

Calculates the position of a givel label.

VIEWS_API virtual void AssignDefaultProperties(CODPropertySet* pDefaults = NULL)

Assign default properties.

VIEWS_API CODLineComponent* GetLine()

Get a pointer to the line component.

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 virtual int GetPointCount() const

Retrieves the number of vertices associated with this component.

VIEWS_API virtual int GetPoints(LPPOINT lpPoints) const

Retrieves the vertices associated with the component.

VIEWS_API virtual int GetPoints(CODPointArray& ptArray) const

Retrieves the vertices associated with the component.

VIEWS_API virtual void SetPoints(LPPOINT lpPoints, const int nCount)

Sets the component's vertex positions.

VIEWS_API virtual void SetPoints(const CODPointArray& ptArray)

Sets the component's vertex positions.

VIEWS_API virtual CPoint GetVertex(const int nIndex) const

Gets one of the vertices of the component.

VIEWS_API virtual CPoint SetVertex(const int nIndex, const CPoint& ptVertex)

Sets the value of a vertex.

VIEWS_API virtual void AddVertex(const CPoint& ptVertex)

Adds a vertex to the component.

VIEWS_API virtual void InsertVertex(const int nIndex, const CPoint& ptVertex)

Inserts a vertex into the component.

VIEWS_API virtual CPoint DeleteVertex(const int nIndex)

Removes a vertex from the component.

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

Moves one of the component's vertices.

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 TRUE if a vertex can be added to this link.

VIEWS_API virtual BOOL CanDeleteVertex()

Returns TRUE if a vertex can be deleted from this link.

VIEWS_API virtual int GetNodesAdjacent(IODNode** ppINode1, IODNode** ppINode2)

Get the nodes adjacent to this edge.

VIEWS_API virtual IODNode* GetTailNode()

Get the node at the tail of this edge.

VIEWS_API virtual IODNode* GetHeadNode()

Get the node at the head of this edge.

VIEWS_API virtual long GetWeight() const

Return a weighted value for the edge.

VIEWS_API virtual const CODRgn& DoRgnUpdate()

Calculates the region of the symbol.

VIEWS_API virtual CODRgn GetEdgeRgn()

Returns a region surrounding the edges of the link.

VIEWS_API virtual void GetHandles(CODPointArray* pHandleArray, BOOL bVertexHandles = FALSE)

Gets array of handle positions (transformed vertices).

VIEWS_API virtual CODComponentPosition* GetPosition()

Returns the current position and size of the component as an object.

VIEWS_API virtual BOOL SetPosition(CODComponentPosition* pCompPos)

Restores the position and size of the component to a previously saved state.

VIEWS_API virtual void OnMove()

Called by the framework when the component changes position.

VIEWS_API virtual void OnConnect(CODConnection* pConnection)

Called by the framework when a connection is created.

VIEWS_API virtual void OnDisconnect(CODConnection* pConnection)

Called by the framework before a connection is destroyed.

VIEWS_API virtual BOOL OnConnectionMove(CODConnection* pConnection)

Called by the framework when a connection moves.

VIEWS_API virtual BOOL OnRemoveDependent(CODConnection* pConnection)

Called by the framework when the dependent on the given connection is removed.

VIEWS_API virtual void OnRemove(CODComponent* pParent)

Called by the framework when the component is removed from its parent.

VIEWS_API virtual void Serialize(CArchive& ar)

Serializes the link component.

VIEWS_API virtual ULONG STDMETHODCALLTYPE AddRef()

Add a reference to this object.

VIEWS_API virtual ULONG STDMETHODCALLTYPE Release()

Release a reference to this object.