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
Constructor.
virtual ~CODLinkComponent()
Destructor.
IODLinkShape* m_pILinkShape
Interface to object that implements the link shape.
BOOL Create(CODPointArray* pPointArray, CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)
Creates the link component from an array of points.
BOOL Create(LPPOINT lpPoints, int nCount, CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)
Creates the link component from an array of points.
BOOL Create(CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)
Creates the link component with two vertices.
BOOL CreateOrthogonal(CODPortComponent* pSourcePort = NULL, CODPortComponent* pTargetPort = NULL)
Create the line using an orthogonal line as the shape.
virtual ODComponentId GetID() const
Return the component ID of the link.
virtual CODConnection* ConnectTail(CODPortComponent* pTargetPort)
Create a connection to the tail port.
virtual CODConnection* ConnectHead(CODPortComponent* pTargetPort)
Create a connection to the head port.
virtual void DisconnectTail()
Delete the connection to the tail port.
virtual void DisconnectHead()
Delete the connection to the tail port.
CODPortComponent* GetSourcePort() const
Return connected port on the source component.
CODPortComponent* GetTargetPort() const
Return connected port on the target component.
CODComponent* GetSourceComponent() const
Gets a pointer to the component at the source end of the link.
CODComponent* GetTargetComponent() const
Gets a pointer to the component at the target end of the link.
CODComponent* GetTailComponent() const
Gets a pointer to the component at the source end of the link (obsolete).
CODComponent* GetHeadComponent() const
Gets a pointer to the component at the target end of the link (obsolete).
virtual BOOL AcceptConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)
Gets a pointer to the port at the source end of the link.
virtual BOOL AcceptConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)
Gets a pointer to the port at the target end of the link.
virtual BOOL AcceptConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)
Determines if the two given ports can be connected.
virtual BOOL MovePort(CODPortComponent* pPort, const int nOffsetX, const int nOffsetY)
Moves a port attached to the symbol.
virtual BOOL FollowConnection(CODConnection* pConnection)
Adjust endpoint to follow the given connection.
virtual BOOL AssignShape(IODLinkShape* pILinkShape)
Assign a shape to the link.
IODLinkShape* GetShape() const
Return a pointer to the shape interface for this link.
virtual void UpdatePorts()
Updates the position of the tail and head port to match the link shape.
virtual void AdjustPoints()
Adjusts the link shape to dock with the source and target ports.
virtual CODLabelComponent* CreateLabel(const LPCTSTR lpszText, const OD_CONTROL_POINT ctlPoint, CDC* pDC = NULL)
Creates a new label and adds it to the symbol.
virtual CODLabelComponent* CreateLabel(const LPCTSTR lpszText, CDC* pDC = NULL)
Creates a new label and adds it to the symbol.
virtual CPoint CalcLabelPosition(CODLabelComponent* pLabel)
Calculates the position of a givel label.
virtual void AssignDefaultProperties(CODPropertySet* pDefaults = NULL)
Assign default properties.
CODLineComponent* GetLine()
Get a pointer to the line component.
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.
virtual int GetPointCount() const
Retrieves the number of vertices associated with this component.
virtual int GetPoints(LPPOINT lpPoints) const
Retrieves the vertices associated with the component.
virtual int GetPoints(CODPointArray& ptArray) const
Retrieves the vertices associated with the component.
virtual void SetPoints(LPPOINT lpPoints, const int nCount)
Sets the component's vertex positions.
virtual void SetPoints(const CODPointArray& ptArray)
Sets the component's vertex positions.
virtual CPoint GetVertex(const int nIndex) const
Gets one of the vertices of the component.
virtual CPoint SetVertex(const int nIndex, const CPoint& ptVertex)
Sets the value of a vertex.
virtual void AddVertex(const CPoint& ptVertex)
Adds a vertex to the component.
virtual void InsertVertex(const int nIndex, const CPoint& ptVertex)
Inserts a vertex into the component.
virtual CPoint DeleteVertex(const int nIndex)
Removes a vertex from the component.
virtual OD_MOVEVERTEX_RC MoveVertex(int nIndex, int nOffsetX, int nOffsetY)
Moves one of the component's vertices.
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 TRUE if a vertex can be added to this link.
virtual BOOL CanDeleteVertex()
Returns TRUE if a vertex can be deleted from this link.
virtual int GetNodesAdjacent(IODNode** ppINode1, IODNode** ppINode2)
Get the nodes adjacent to this edge.
virtual IODNode* GetTailNode()
Get the node at the tail of this edge.
virtual IODNode* GetHeadNode()
Get the node at the head of this edge.
virtual long GetWeight() const
Return a weighted value for the edge.
virtual const CODRgn& DoRgnUpdate()
Calculates the region of the symbol.
virtual CODRgn GetEdgeRgn()
Returns a region surrounding the edges of the link.
virtual void GetHandles(CODPointArray* pHandleArray, BOOL bVertexHandles = FALSE)
Gets array of handle positions (transformed vertices).
virtual CODComponentPosition* GetPosition()
Returns the current position and size of the component as an object.
virtual BOOL SetPosition(CODComponentPosition* pCompPos)
Restores the position and size of the component to a previously saved state.
virtual void OnMove()
Called by the framework when the component changes position.
virtual void OnConnect(CODConnection* pConnection)
Called by the framework when a connection is created.
virtual void OnDisconnect(CODConnection* pConnection)
Called by the framework before a connection is destroyed.
virtual BOOL OnConnectionMove(CODConnection* pConnection)
Called by the framework when a connection moves.
virtual BOOL OnRemoveDependent(CODConnection* pConnection)
Called by the framework when the dependent on the given connection is removed.
virtual void OnRemove(CODComponent* pParent)
Called by the framework when the component is removed from its parent.
virtual void Serialize(CArchive& ar)
Serializes the link component.
virtual ULONG STDMETHODCALLTYPE AddRef()
Add a reference to this object.
virtual ULONG STDMETHODCALLTYPE Release()
Release a reference to this object.