AcGraphNode.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // CREATED BY: Pei Zhan March 2011
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #pragma once
  16. #pragma pack (push, 8)
  17. class AcImpGraphNode;
  18. class AcGraph;
  19. class ACDB_PORT AcGraphNode : public AcRxObject,
  20. public AcHeapOperators
  21. {
  22. public:
  23. ACRX_DECLARE_MEMBERS(AcGraphNode);
  24. /// <summary> Default destructor. </summary>
  25. ///
  26. virtual ~AcGraphNode();
  27. typedef Adesk::UInt32 Id;
  28. /// <summary> Null node id </summary>
  29. ///
  30. enum {
  31. kNullId = 0
  32. };
  33. /// <summary>
  34. /// Returns id of the Id object. Each AcGraphNode object has a unique id
  35. /// </summary>
  36. /// <returns> Id. </returns>
  37. ///
  38. Id nodeId() const;
  39. /// <summary>
  40. /// This function returns the pointer of its owning graph
  41. /// Returns NULL if no owning graph is defined
  42. /// </summary>
  43. /// <returns> pointer to the owning graph. </returns>
  44. AcGraph* owningGraph() const;
  45. /// <summary>
  46. /// This function connects this node to a node in an AcGraph, and call nodeToBeConnectedNotification
  47. /// on each node in the same AcGraph to notify about this event .
  48. /// Both the nodes must belong to the same graph otherwise it will return an error of eInvalidInput
  49. /// </summary>
  50. /// <returns> Acad::ErrorStatus </returns>
  51. Acad::ErrorStatus connectNode (AcGraphNode* pNode);
  52. /// <summary>
  53. /// This function disconnects this node from an adjacent node in an AcGraph, and call
  54. /// nodeToBeConnectedNotification on each node in the same AcGraph to notify about this event
  55. /// </summary>
  56. /// <returns> Acad::ErrorStatus </returns>
  57. Acad::ErrorStatus disconnectNode(AcGraphNode* pNode);
  58. /// <summary>
  59. /// This function disconnects this node from all its adjacent nodes in an AcGraph
  60. /// </summary>
  61. /// <returns> Acad::ErrorStatus </returns>
  62. Acad::ErrorStatus disconnectAllNodes();
  63. /// <summary>
  64. /// This function gets all its adjacent nodes in an AcGraph
  65. /// </summary>
  66. /// <returns> Acad::ErrorStatus </returns>
  67. Acad::ErrorStatus getAdjacentNodes(AcArray<AcGraphNode*>& adjacentNodes) const;
  68. /// <summary>
  69. /// This function backups all its data for a partial undo when a node is modified (for kModifyNodePartialUndoCode event).
  70. /// Derived class should call this method when its data is modified to ensure a successful undo operation
  71. /// </summary>
  72. /// <returns> none </returns>
  73. virtual void backup();
  74. /// <summary>
  75. /// This function checks if a node (pNode) is adjacent to this node
  76. /// </summary>
  77. /// <returns> true if it is an adjacent node</returns>
  78. bool isAdjacentTo(AcGraphNode *pNode) const;
  79. /// <summary>
  80. /// When a node is being connected to this node, this function gets called to notify
  81. /// about this event. Derived class can override this method and veto the new connection
  82. /// by returning Acad::eVetoed. In the base class, it simply returns Acad::eOk
  83. /// </summary>
  84. /// <param name="pNode"> Pointer of the node that is connecting to this node. </param>
  85. /// <returns> Acad::ErrorStatus </returns>
  86. virtual Acad::ErrorStatus nodeToBeConnectedNotification(AcGraphNode *pNode);
  87. /// <summary>
  88. /// When a node is being disconnected from this node , this function gets called to notify
  89. /// about this event. Derived class can override this method and veto the action by
  90. /// returning Acad::eVetoed. In the base class, it simply returns Acad::eOk
  91. /// </summary>
  92. /// <param name="pNode"> Pointer of the node that is being disconnected from this node. </param>
  93. /// <returns> Acad::ErrorStatus </returns>
  94. virtual Acad::ErrorStatus nodeToBeDisconnectedNotification(AcGraphNode* pNode);
  95. /// <summary>
  96. /// When a node is being moved from one graph to another, this function gets called to notify
  97. /// about this event. Derived class can override this method and veto the action by
  98. /// returning Acad::eVetoed, also an array of nodes can be returned to indicate to move this node
  99. /// what other nodes need to be moved as well.
  100. /// In the base class, the default implementation simply returns Acad::eOk.
  101. /// </summary>
  102. /// <param name="pGraph"> input graph that this node is to be moved to. </param>
  103. /// <param name="otherNodesToMove"> output array of nodes that should also be moved. </param>
  104. /// <returns> Acad::ErrorStatus </returns>
  105. virtual Acad::ErrorStatus nodeToBeMovedNotification(AcGraph *pGraph, AcArray<AcGraphNode *> & otherNodesToMove);
  106. /// <summary>
  107. /// This function is called by dwgOut(). Its purpose is to allow the object to write out its data.
  108. /// </summary>
  109. /// <returns> Acad::ErrorStatus </returns>
  110. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
  111. /// <summary>
  112. /// This function is called by dwgIn(). Its purpose is to allow the object to read in its data.
  113. /// </summary>
  114. /// <returns> Acad::ErrorStatus </returns>
  115. virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler*);
  116. /// <summary>
  117. /// This function is called by dxfOut(). Its purpose is to allow the object to write out its data.
  118. /// </summary>
  119. /// <returns> Acad::ErrorStatus </returns>
  120. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler*) const;
  121. /// <summary>
  122. /// This function is called by dxfIn(). Its purpose is to allow the object to read in its data.
  123. /// </summary>
  124. /// <returns> Acad::ErrorStatus </returns>
  125. virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler*);
  126. protected:
  127. /// <summary> Protected default constructor. </summary>
  128. ///
  129. explicit AcGraphNode(bool bCreateImp = true);
  130. AcImpGraphNode* mpImpGraphNode;
  131. private:
  132. /// <summary>
  133. /// Disabled copy constructor
  134. /// </summary>
  135. AcGraphNode(const AcGraphNode &node);
  136. /// <summary>
  137. /// Disabled assignment operator
  138. /// </summary>
  139. AcGraphNode &operator = (const AcGraphNode &node);
  140. friend class AcGraph;
  141. friend class AcImpGraph;
  142. };
  143. #pragma pack (pop)