acdbxref.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* Next available MSG number is 80 */
  2. /*
  3. //////////////////////////////////////////////////////////////////////////////
  4. //
  5. // Copyright 2015 Autodesk, Inc. All rights reserved.
  6. //
  7. // Use of this software is subject to the terms of the Autodesk license
  8. // agreement provided at the time of installation or download, or which
  9. // otherwise accompanies this software in either electronic or hard copy form.
  10. //
  11. //////////////////////////////////////////////////////////////////////////////
  12. AcDbXref.h
  13. This file contains the definition of the functions used to handle
  14. xrefs in DBX.
  15. acdbResolveCurrentXRefs --
  16. This function is used to resolve xrefs at drawing load.
  17. acdbResolveCurrentXRefs() will get and load xref database
  18. files and merge the symbol tables from the xrefs into the
  19. symbol tables of the host drawing. The host database should
  20. not be an xref in another drawing. If this is the case, the
  21. function does nothing. The acdbHostApplicationServices methods
  22. isRemoteFile(), getRemoteFile(), mapFile(), and findFile()
  23. will be used by acdbResolveCurrentXRefs() to access the xref
  24. files if these functions are provided. Otherwise, the xrefs
  25. will be accessed at the path assigned to them when the host
  26. drawing was saved.
  27. Some functionality is not included in the xref resolve. This includes:
  28. Xref notification events
  29. Xref message logging
  30. Xref lazy loading (The xref drawing will be opened in mode
  31. SH_DENYNO and AcDbDatabase::closeInput()
  32. will be called after the drawing is read.)
  33. Note This function supports xref resolution, but not xref
  34. database editing. You will not be able to reliably query or
  35. modify some elements of the xref databases. Nor will you be
  36. able to save your changes because the AcDbDatabase methods
  37. needed to restore the integrity of xref databases,
  38. restoreOriginalXrefSymbols() and restoreForwardingXrefSymbols(),
  39. are not implemented for ObjectDBX.
  40. */
  41. #pragma once
  42. #include "AdAChar.h"
  43. #include "xgraph.h"
  44. Acad::ErrorStatus acdbResolveCurrentXRefs(AcDbDatabase* pHostDb,
  45. bool useThreadEngine = true, bool doNewOnly = false);
  46. /* acdbAttachXref --
  47. This function is used to attach a new xref to the specified file
  48. (pFilename) to a given database (pDb)..
  49. A new block table record with the name specified by pBlockName
  50. will be created and resolved as an external reference.
  51. The id of the new record will be set into xrefBlkId.
  52. */
  53. Acad::ErrorStatus acdbAttachXref(AcDbDatabase* pHostDb,
  54. const ACHAR * pFilename,
  55. const ACHAR * pBlockName,
  56. AcDbObjectId& xrefBlkId);
  57. /* acdbOverlayhXref --
  58. This function is used to overlay a new xref to the specified file
  59. (pFilename) to a given database (pDb)..
  60. A new block table record with the name specified by pBlockName
  61. will be created and resolved as an external reference and flagged
  62. as an overlay. The id of the new record will be set into xrefBlkId.
  63. */
  64. Acad::ErrorStatus acdbOverlayXref(AcDbDatabase* pHostDb,
  65. const ACHAR * pFilename,
  66. const ACHAR * pBlockName,
  67. AcDbObjectId& xrefBlkId);
  68. /* acdbDetachXref --
  69. This function is used to detach a specified xref (xrefBlkId) from the
  70. given database (pDb). Note, references to the xref should be
  71. erased prior to using this function.
  72. */
  73. Acad::ErrorStatus acdbDetachXref(AcDbDatabase* pHostDb,
  74. const AcDbObjectId& xrefBlkId);
  75. Acad::ErrorStatus acdbUnloadXrefs(AcDbDatabase* pHostDb,
  76. const AcDbObjectIdArray& xrefBlkIds,
  77. const bool bQuiet = true);
  78. Acad::ErrorStatus acdbReloadXrefs(AcDbDatabase* pHostDb,
  79. const AcDbObjectIdArray& xrefBlkIds,
  80. bool bQuiet = true);
  81. Acad::ErrorStatus acdbBindXrefs(AcDbDatabase* pHostDb,
  82. const AcDbObjectIdArray& xrefBlkIds,
  83. const bool bInsertBind,
  84. const bool bAllowUnresolved = false,
  85. const bool bQuiet = true);
  86. Acad::ErrorStatus acdbXBindXrefs(AcDbDatabase* pHostDb,
  87. const AcDbObjectIdArray xrefSymbolIds,
  88. const bool bInsertBind,
  89. const bool bQuiet = true);
  90. // This function does nothing in an AutoCAD based host environment.
  91. // In a non-AutoCAD host environment this function will delete the
  92. // database pointed to by pHostDb and will clean up some AcDbGlobals
  93. // values.
  94. //
  95. void acdbReleaseHostDwg(AcDbDatabase* pHostDb);
  96. Acad::ErrorStatus
  97. acdbGetHostDwgXrefGraph(AcDbDatabase* pHostDb, AcDbXrefGraph& graph,
  98. Adesk::Boolean includeGhosts = Adesk::kFalse);
  99. // Class AcDbXrefObjectId
  100. //
  101. // The purpose of this class is to provide a convenient method for referring
  102. // to a specific AcDbObject within an XREF'd database. It is persistant
  103. // across drawing sessions, though the current DWG freeze requires that
  104. // it be serialized out through extended data of some form or another.
  105. class AcDbXrefObjectId {
  106. public:
  107. AcDbXrefObjectId();
  108. AcDbXrefObjectId(const AcDbXrefObjectId& other);
  109. AcDbXrefObjectId& operator= (const AcDbXrefObjectId& other);
  110. bool operator== (const AcDbXrefObjectId& other) const;
  111. bool operator!= (const AcDbXrefObjectId& other) const;
  112. bool isValid(void) const;
  113. bool isXref(void) const { return !m_handle.isNull(); }
  114. bool isNull(void) const { return m_localId.isNull(); }
  115. Acad::ErrorStatus setNull(void);
  116. Acad::ErrorStatus setXrefId(AcDbObjectId xrefBlkId, const AcDbHandle & hObject);
  117. Acad::ErrorStatus getXrefId(AcDbObjectId& xrefBlkId, AcDbHandle& hObject) const;
  118. Acad::ErrorStatus setLocalId(AcDbObjectId objId);
  119. Acad::ErrorStatus getLocalId(AcDbObjectId& objId) const;
  120. Acad::ErrorStatus resolveObjectId(AcDbObjectId& id) const;
  121. Acad::ErrorStatus serializeToResbuf(resbuf*& pResBuf, resbuf*& pEndOfChain) const;
  122. Acad::ErrorStatus serializeFromResbuf(const resbuf* pResBuf, resbuf*& pNextInChain);
  123. private:
  124. AcDbObjectId m_localId; // if m_handle.isNull(), this is a local objId
  125. // otherwise, it is the block table record of the xref
  126. AcDbHandle m_handle; // handle of the object we refer
  127. // to within the Xref
  128. };