CODSymbolComponent Class
class CODSymbolComponent: public CODComponent, public IODNode, public IODConnectionEventListener
Symbol components are composite components that can have labels and connections to other symbols.Symbols are typically composed of more primitive components. They can be loaded from files or as application resources.
A symbol can have one or more ports. Each port can have one or more connection. The symbol maintains a list of ports and a list of connections. Each connection object binds two ports together. Both symbols involved in the connection have a pointer to the connection object. Ports and symbols on the opposite end of a connection from a given symbol are referred to as dependents.
A symbol can have one or more labels. Symbols and labels are sibling components and have an owner-slave relationship, rather than a parent-child relationship. This is so that the symbols and labels can be transformed somewhat independently of each other. Labels are always included in their owner's translate set, which means that the same translations applied to the symbol are also applied to the labels. The bounding region of a symbol includes its labels. When the region of a label is changed, its parent is notified through the OnLabelRgnUpdate method.
Symbols implement the IODNode interface, which provides methods to traverse symbols and links as a directed or undirected graph. Edges are defined by dependent (i.e. connected) symbols that support the IODEdge interface.
Defined in: OdSymbolComp.h
See Also
CODComponent, IODNode, CODPortComponent, CODLabelComponent, CODConnection, IODConnectionEventListener, Component Property Identifiers
Class Members
Constructor.
CODSymbolComponent(const CODSymbolComponent& src)
Copy constructor.
virtual ~CODSymbolComponent()
Destructor.
BOOL Create()
Creates the symbol component.
BOOL Create(LPCTSTR lpszPath)
Creates the symbol component from a file.
BOOL Create(UINT nID)
Creates the symbol component from a resource.
BOOL Create(UINT nID, HINSTANCE hInst)
Creates the symbol component from a resource.
BOOL Create(CODComponentSet* pCompSet)
Creates the symbol component from a list of existing components.
CODSymbolComponent& operator=(const CODSymbolComponent& src)
Assignment operator.
virtual CODComponent* Dup() const
Create a duplicate copy of this object.
CODPortSet m_setPorts
The ports that this component contains.
CODCirclePort * m_pCenterPort
All components have a port at their center.
CODConnectionSet m_setConnections
The connections that this component contains.
CODLabelSet m_setLabels
The list of labels of the symbol.
CODRgn m_rgnWithoutLabels
Region occupied by symbol excluding its labels.
BOOL AddPort(CODPortComponent* pPort)
Return the component ID of the symbol.
BOOL AddPort(CODPortComponent* pPort)
Adds a port to the symbol.
int GetNumPorts() const
Returns the number of ports in the symbol.
CODPortComponent* GetPort(const int nPortIdx) const
Returns a pointer to the port at the given index.
BOOL RemovePort(const int nPortIdx)
Removes a port from the symbol.
virtual BOOL MovePort(CODPortComponent* pPort, const int nOffsetX, const int nOffsetY)
Moves a port attached to the symbol.
void RemoveAllPorts()
Removes all ports from the symbol.
virtual CODPortComponent* GetPortAt(const CPoint& ptAt, const int nSlop = 0) const
Returns a pointer to the port at the given point.
virtual CODPortComponent* CreateCenterPort()
Create the center port for the symbol.
void EnableCenterPort(const BOOL bEnable)
Returns a pointer to the built-in port located at the center of the bounding rectangle of the symbol.
void EnableCenterPort(const BOOL bEnable)
Enables or disables the center port.
void GetAllPorts(CODPortSet& setPorts)
Returns a list of all ports in the symbol.
void DrawPorts(CDC *pDC)
Draw all ports in the symbol to the given DC.
void SetPortsVisible(const BOOL bVisibleFlag)
Set visibility for all ports belonging to the symbol.
CODConnection* GetConnection(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort) const
Locates the connection associated with the given ports.
void GetAllConnections(CODConnectionSet& setConnections) const
Returns a list of all connections for the symbol.
void GetConnectionsOnPort(const int nPortIdx, CODConnectionSet& setConnections) const
Returns a list of all connections on a given port.
void GetConnectionsOnPort(CODPortComponent* pPort, CODConnectionSet& setConnections) const
Returns a list of all connections on a given port.
CODPortComponent* GetPortOnConnection(CODConnection* pConnection) const
Returns the port which the symbol owns on a given connection.
CODPortComponent* GetDependentPortOnConnection(CODConnection* pConnection) const
Returns the port at the other end of a given connection.
void GetConnectionsToComponent(CODComponent* pTargetComponent, CODConnectionSet& setConnections) const
Returns a list of connections from this symbol to another symbol.
BOOL IsConnectionSource(CODConnection* pConnection) const
Determines if this symbol owns the source port of the given connection.
virtual BOOL FollowConnection(CODConnection* pConnection)
Positions this symbol so that it follows the given connection.
virtual void GetAllDependents(CODComponentSet* pDependentSet)
Get all components connected to this symbol.
virtual void GetMovingConnections(CODConnectionSet& setConnections)
Gets all connections to this symbols that potentially move when the symbol moves.
virtual CODConnection* Connect(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)
Determines if the two given ports can be connected.
virtual CODConnection* Connect(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)
Create a connection between two ports.
virtual void Disconnect(CODPortComponent* pSourcePort, CODPortComponent* pTargetPort)
Delete a connection between two ports.
virtual void Disconnect(CODConnection* pConnection)
Delete a given connection.
virtual void Disconnect(CODComponent* pTargetComponent)
Delete all connections to the given symbol.
void DisconnectAll()
Delete all connections to this symbol.
int DisconnectAllExcept(CODComponentSet& setComponents)
Delete all connections except ones to the given set of components.
virtual BOOL Attach(CODConnection* pConnection)
Add an existing connection to the symbol.
virtual BOOL Detach(CODConnection* pConnection)
Remove the connection from the symbol.
virtual BOOL AttachDependent(CODConnection* pConnection)
Add the connection to the dependent symbol.
virtual BOOL DetachDependent(CODConnection* pConnection)
Remove the connection from the dependent symbol.
void AttachAllDependents()
Attach all connections belonging to this symbol.
void DetachAllDependents()
Detach all connections belonging to this symbol.
BOOL QueueConnectionEvent(CODPortComponent* pPort, const int nNotifyCode, const UINT nPriority)
Queues a connection event to connections on a given port.
BOOL QueueConnectionEvent(const int nNotifyCode, const UINT nPriority)
Queues a connection event on connections of every port.
void DispatchConnectionEvents(CODConnectionMap& mapNotified)
Dispatches all queued connection events.
void ClearConnectionEvents()
Removes all queued connection events without dispatching them.
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.
BOOL AddLabel(CODLabelComponent* pLabelComp)
Adds a label to the symbol.
BOOL InsertLabel(CODLabelComponent* pLabelComp, const int nLabelIdx)
Inserts a label into the symbol.
BOOL RemoveLabel(const int nLabelIdx)
Returns the number of labels in the symbol.
BOOL RemoveLabel(const int nLabelIdx)
Returns a pointer to the label at the given index.
BOOL RemoveLabel(const int nLabelIdx)
Removes a label from the symbol.
BOOL RemoveLabel(CODLabelComponent* pLabelComp)
Removes a label from the symbol.
void RemoveAllLabels()
Removes all labels from the symbol.
virtual CPoint CalcLabelPosition(CODLabelComponent* pLabel)
Calculates the position of a given label.
virtual CPoint SetOrigin(int x, int y)
Set the origin of this component relative to the container and in the container's units
virtual CPoint MoveOrigin(int xOff,int yOff)
Move the origin of this component by specified deltas
virtual CPoint OffsetOrigin(int xOff, int yOff)
Offset the origin of this component by specified deltas
virtual void Scale(float fScaleX, float fScaleY, float fOriginX, float fOriginY)
Scales the component in reference to a point.
virtual int GetTranslateSet(CODComponentSet& setComponents)
Return a list of components to be translated along with this component.
virtual void InitChildProperties(CODComponent* pChild)
Parent has a chance to initialize properties for new children
virtual CODRgn GetEdgeRgn()
Returns a region surrounding the edges of the component.
virtual CODRgn UpdateRgn(const BOOL bNotifyParents = FALSE)
Update the region data and bounding rectangle based on current points, transforms, or any other criteria.
virtual const CODRgn& DoRgnUpdate()
Calculates the region of the symbol.
virtual void OnLabelRgnUpdate(CODLabelComponent* pLabel)
Return a reference to the base region object.
virtual void OnLabelRgnUpdate(CODLabelComponent* pLabel)
Called by the framework to notify a parent that a label region has changed.
virtual IODEdge* GetEdge(const ODComponentId edgeId)
Return a pointer to the given edge.
virtual int GetNumEdges() const
Return a count of all edges touching the node.
virtual int GetNumEdgesLeaving() const
Return a count of edges leaving the node.
virtual int GetNumEdgesEntering() const
Return a count of edges entering the node.
virtual int GetEdges(IODEdgeCollection* pIEdges)
Retrieve all edges touching the node.
virtual int GetEdgesLeaving(IODEdgeCollection* pIEdges)
Retrieve all edges leaving the node.
virtual int GetEdgesEntering(IODEdgeCollection* pIEdges)
Retrieve all edges entering the node.
virtual IODNode* GetNodeAdjacent(IODEdge* pIEdge)
Retrieve the node adjacent to this node on a given edge.
virtual int GetNodesAdjacent(IODNodeCollection* pINodes)
Retrieve all adjacent nodes.
virtual int GetNodesAdjacentFrom(IODNodeCollection* pINodes)
Retrieve nodes adjacent from this node.
virtual int GetNodesAdjacentTo(IODNodeCollection* pINodes)
Retrieve nodes adjacent to this node.
virtual int GetNodesConnected(IODNodeCollection* pINodes)
Retrieve all connected nodes.
virtual int GetNodesConnectedFrom(IODNodeCollection* pINodes)
Retrieve nodes that are connected from this node.
virtual int GetNodesConnectedTo(IODNodeCollection* pINodes)
Retrieve nodes that are connected to this node.
virtual void OnDraw(CDC* pDC)
Does the actual drawing of the component.
virtual void OnAdd(CODComponent* pParent)
Called by the framework when the component is added to a parent.
virtual void OnRemove(CODComponent* pParent)
Called by the framework when the component is removed from its parent.
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 BOOL OnConnectionMove(CODConnection* pConnection)
Called by the framework when a given connection is moving.
virtual void OnDisconnect(CODConnection* pConnection)
Called by the framework before a connection is destroyed.
virtual BOOL OnRemoveDependent(CODConnection* pConnection)
Called by the framework when the dependent on the given connection is removed.
virtual void OnGroup(CODComponent* pGroup)
Called by the framework when the component is added to a group.
virtual bool HandleEvent(sfl::IEvent* pIEvent)
Receive an event and attempt to handle it.
BOOL LoadFromFile(LPCTSTR lpszPath)
Loads the symbol from a file.
BOOL LoadFromResource(UINT nID)
Loads the symbol from a resource.
BOOL LoadFromResource(UINT nID, HINSTANCE hInst)
Loads the symbol from a resource.
virtual void Serialize(CArchive& ar)
Serializes the symbol.
public:
Add a reference to this object.
public:
Release a reference to this object.
virtual void UpdateCenterPort()
Called by the framework to update the properties of the center port.