dbunderlaydef.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. // DESCRIPTION: Exported class for underlay definitions in dwg file - AcDbUnderlayDefintion
  13. #ifndef ACDB_DBUNDERLAYDEF_H
  14. #define ACDB_DBUNDERLAYDEF_H
  15. #pragma once
  16. #include "dbmain.h"
  17. #include "acstring.h"
  18. #pragma pack (push, 8)
  19. class AcDbUnderlayItem;
  20. class AcDbUnderlayHost;
  21. class IAcReadStream;
  22. /// <summary>
  23. /// Abstract class that handles the linkage to the external underlay content. Underlays are similar to raster images
  24. /// but their content is snappable. An AcDbUnderlayDefinition is referenced by 0 or more AcDbUnderlayReferences.
  25. /// The AcDbUnderlayRefernece is responsible for the placement of the content within the drawing while AcDbUnderlayDefinition
  26. /// handles the linkage to the underlay content.
  27. /// Instances of AcDbUnderlayReference derived concrete classes are inserted in a block table record.
  28. /// Instances of AcDbUnderlayDefinition derived concrete classes are inserted into a dictionay off of the named object dictionary.
  29. /// </summary>
  30. class ADESK_NO_VTABLE AcDbUnderlayDefinition: public AcDbObject
  31. {
  32. public:
  33. ACDB_DECLARE_MEMBERS(AcDbUnderlayDefinition);
  34. ///<summary>Default constructor.</summary>
  35. AcDbUnderlayDefinition();
  36. ///<summary>Destructor.</summary>
  37. virtual ~AcDbUnderlayDefinition() = 0;
  38. /// <summary>
  39. /// Sets the name of the file that this underlay references. This name can be the following form:
  40. /// 1. relative path (relative to the host drawing)
  41. /// 2. file name only (will be searched on the support search path)
  42. /// 3. full path
  43. /// </summary>
  44. /// <param name="file">Name of the file</param>
  45. /// <returns>Returns Acad::eOk if successful.</returns>
  46. Acad::ErrorStatus setSourceFileName(const ACHAR* file);
  47. /// <summary>
  48. /// Gets the name of the file that this underlay references. This name is in the form (relative or full path) that the user specified.
  49. /// </summary>
  50. /// <returns>Returns a pointer to the internal datamember that holds the source file path.
  51. /// The string should not be modified or freed and it may get invalidated if modifications are made to underlay definition.</returns>
  52. const ACHAR* getSourceFileName() const;
  53. /// <summary>
  54. /// This function returns a pointer to an IAcReadStream for the file that
  55. /// this underlay references, or NULL if there is no file available.
  56. /// </summary>
  57. IAcReadStream* getReadStream() const;
  58. /// <summary>
  59. /// Gets the name of the file that this underlay references. This name is always a full path.
  60. /// </summary>
  61. /// <param name="file">Variable that is set to point to the internal datamember that holds the active file path upon successful return.
  62. /// The string should not be modified or freed and it may get invalidated if modifications are made to underlay definition.</param>
  63. /// <returns>Returns Acad::eOk if successful.</returns>
  64. Acad::ErrorStatus getActiveFileName(const ACHAR*& file) const;
  65. /// <summary>
  66. /// Gets the name of the file that this underlay references. This name is always a full path.
  67. /// </summary>
  68. /// <param name="file">Variable that is set to hold the source file path upon successful return.</param>
  69. /// <returns>Returns Acad::eOk if successful.</returns>
  70. Acad::ErrorStatus getActiveFileName(AcString& file) const;
  71. /// <summary>
  72. /// Sets the name of the underlay item that this underlay should reference.
  73. /// </summary>
  74. /// <param name="item">Name of the item</param>
  75. /// <returns>Returns Acad::eOk if successful.</returns>
  76. Acad::ErrorStatus setItemName(const ACHAR* item);
  77. /// <summary>
  78. /// Gets the name of the underlay item that this underlay currently references.
  79. /// </summary>
  80. /// <returns>Returns a pointer to the internal datamember that holds the item name.
  81. /// The string should not be modified or freed and it may get invalidated if modifications are made to underlay definition.</returns>
  82. const ACHAR* getItemName() const;
  83. /// <summary>
  84. /// Sets the source path and underlay item that this underlay should reference. Calls unload() to unload any previous underlay item.
  85. /// </summary>
  86. /// <param name="sourceFileName">Source file path.</param>
  87. /// <param name="activeFileName">Current or active file path. This points to the file where it is currently found.</param>
  88. /// <param name="pItem">The item to be referenced. The underlay definition takes ownership of the item and it should *not* be deleted by the client.</param>
  89. /// <returns>Returns Acad::eOk if successful.</returns>
  90. Acad::ErrorStatus setUnderlayItem(const ACHAR* sourceFileName, const ACHAR* activeFileName, AcDbUnderlayItem* pItem);
  91. /// <summary>
  92. /// Gets the underlay item that this underlay currently references.
  93. /// </summary>
  94. /// <returns>Returns a pointer to the internal datamember that holds the item.
  95. /// The object should not be modified or freed and it may get invalidated if modifications are made to underlay definition.</returns>
  96. const AcDbUnderlayItem* getUnderlayItem() const;
  97. /// <summary>
  98. /// Attempts to load the file returned by getActiveFileName().
  99. /// </summary>
  100. /// <param name="password">Optional password. I password is NULL but is necessary to open file this function will prompt the user.</param>
  101. /// <returns>Returns Acad::eOk if successful.</returns>
  102. Acad::ErrorStatus load(const wchar_t* password);
  103. /// <summary>
  104. /// Unloads the underlay file. References will behave as the file was never loaded.
  105. /// </summary>
  106. void unload();
  107. /// <summary>
  108. /// Gets a boolean indicating whether the underlay is currently loaded.
  109. /// </summary>
  110. /// <returns>Returns true, if the underlay is loaded.</returns>
  111. bool isLoaded() const;
  112. /// <summary>
  113. /// Gets the name of the dictionary that holds the AcDbUnderlayDefinition objects in the named objects dictionary.
  114. /// </summary>
  115. /// <param name="underlayDefinitionType">The class descriptor of the underlay type for which to retrive the dictionary name for.</param>
  116. /// <returns>Returns the name of the dictionary that holds the AcDbUnderlayDefinition objects in the named objects dictionary.</returns>
  117. static AcString dictionaryKey(const AcRxClass* underlayDefinitionType);
  118. private:
  119. /// <summary>
  120. /// When overridden in derived classes it gets the underlay host to be used by this underlay definition.
  121. /// </summary>
  122. /// <returns>Returns the underlay host to be used by this underlay definition.</returns>
  123. virtual const AcDbUnderlayHost* getUnderlayHost() const = 0;
  124. };
  125. /// <summary>
  126. /// Represents DWF underlays in the drawing. Underlays are similar to raster images
  127. /// but their content is snappable.
  128. /// </summary>
  129. class AcDbDwfDefinition: public AcDbUnderlayDefinition
  130. {
  131. public:
  132. ACDB_DECLARE_MEMBERS(AcDbDwfDefinition);
  133. ///<summary>Default constructor.</summary>
  134. AcDbDwfDefinition();
  135. ///<summary>Destructor.</summary>
  136. virtual ~AcDbDwfDefinition();
  137. ///<summary>returns true if this is a DWFx file</summary>
  138. Adesk::Boolean isDWFx(void) const;
  139. private:
  140. virtual const AcDbUnderlayHost* getUnderlayHost() const;
  141. };
  142. /// <summary>
  143. /// Represents DGN underlays in the drawing. Underlays are similar to raster images
  144. /// but their content is snappable.
  145. /// </summary>
  146. class AcDbDgnDefinition: public AcDbUnderlayDefinition
  147. {
  148. public:
  149. ACDB_DECLARE_MEMBERS(AcDbDgnDefinition);
  150. ///<summary>Default constructor.</summary>
  151. AcDbDgnDefinition();
  152. ///<summary>Destructor.</summary>
  153. virtual ~AcDbDgnDefinition();
  154. /// <summary>
  155. /// Gets a boolean indicating whether the underlay uses master units
  156. /// in the DGN file when the DGN file is being translated to DWG for
  157. /// the underlay to use.
  158. /// </summary>
  159. /// <returns>
  160. /// Returns true, if the underlay uses Master units during translation.
  161. /// </returns>
  162. bool useMasterUnits() const;
  163. /// <summary>
  164. /// Sets a boolean indicating whether the underlay uses master units
  165. /// in the DGN file when the DGN file is being translated to DWG for
  166. /// the underlay to use.
  167. /// </summary>
  168. /// <param name="useMaster">
  169. /// Input bool indicating whether or not to use master units during translation.
  170. /// </param>
  171. void setUseMasterUnits(bool useMaster);
  172. /// <summary>
  173. /// Gets the xref depth value (if any) the underlay uses. This depth
  174. /// value is used if the dwg file is exported as DGN. For DWG to DGN
  175. /// translation, Dgn underlays become Dgn xrefs and will be given
  176. /// this depth value.
  177. /// </summary>
  178. /// <returns>
  179. /// Returns the xref depth value, or -1 if there is no depth value.
  180. /// </returns>
  181. int xrefDepth() const;
  182. /// <summary>
  183. /// Sets the xref depth value (if any) the underlay uses. This depth
  184. /// value is used if the dwg file is exported as DGN. For DWG to DGN
  185. /// translation, Dgn underlays become Dgn xrefs and will be given
  186. /// this depth value.
  187. /// </summary>
  188. /// <param name="depth">
  189. /// Input value to be used as the depth when this underlay becomes
  190. /// a DGN reference during a DGNEXPORT. A value of -1 indicates that
  191. /// no depth value should be stored for this underlay.
  192. /// </param>
  193. void setXrefDepth(int depth);
  194. /// <summary>
  195. /// Gets a boolean indicating whether raster images should be displayed
  196. /// in referenced (xref) DGN files.
  197. /// </summary>
  198. /// <returns>
  199. /// Returns true, if images should be displayed in referenced DGN files.
  200. /// </returns>
  201. bool showRasterRef() const;
  202. /// <summary>
  203. /// Sets a boolean indicating whether raster images should be displayed
  204. /// in referenced DGN files.
  205. /// </summary>
  206. /// <param name="useMaster">
  207. /// Input bool indicating whether or not to display raster images in
  208. /// referenced DGN files.
  209. /// </param>
  210. void setShowRasterRef(bool bShow);
  211. private:
  212. virtual const AcDbUnderlayHost* getUnderlayHost() const;
  213. };
  214. class AcDbPdfDefinition: public AcDbUnderlayDefinition
  215. {
  216. public:
  217. ACDB_DECLARE_MEMBERS(AcDbPdfDefinition);
  218. ///<summary>Default constructor.</summary>
  219. ACDB_PORT AcDbPdfDefinition();
  220. ///<summary>Destructor.</summary>
  221. ACDB_PORT virtual ~AcDbPdfDefinition();
  222. private:
  223. virtual const AcDbUnderlayHost* getUnderlayHost() const;
  224. };
  225. #pragma pack (pop)
  226. #endif