imgent.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. #ifndef __IMGENT_H
  13. #define __IMGENT_H
  14. #include "dbents.h"
  15. #include "dbimage.h"
  16. #include "acgi.h"
  17. #include "gept3dar.h"
  18. #include "gebndpln.h"
  19. #include "geplin2d.h"
  20. #include "dbproxy.h"
  21. #pragma pack (push, 8)
  22. const double kEpsilon = 1.0e-7;
  23. const int kAllEntityProxyFlags =
  24. AcDbProxyEntity::kEraseAllowed |
  25. AcDbProxyEntity::kTransformAllowed |
  26. AcDbProxyEntity::kColorChangeAllowed |
  27. AcDbProxyEntity::kLayerChangeAllowed |
  28. AcDbProxyEntity::kLinetypeChangeAllowed |
  29. AcDbProxyEntity::kMaterialChangeAllowed |
  30. AcDbProxyEntity::kLinetypeScaleChangeAllowed |
  31. AcDbProxyEntity::kVisibilityChangeAllowed;
  32. // Opaque types
  33. //
  34. class RasterImageImp;
  35. // Make compiler shut up
  36. //
  37. #pragma warning( disable : 4275 )
  38. #ifdef ISMDLLACCESS
  39. #undef ISMDLLACCESS
  40. #endif
  41. #ifdef ISMDLLACCESSDATA
  42. #undef ISMDLLACCESSDATA
  43. #endif
  44. #ifdef ISM_OBJ // For DwgUnplugged ISMobj.arx:
  45. // Classes to be exported have to have ISMDLLACCESS definition in its header.
  46. // Example: class ISMDLLACCESS AcDbImpRasterImageDef
  47. #define ISMDLLACCESS __declspec(dllexport)
  48. #define ISMDLLACCESSDATA
  49. #else
  50. #define ISMDLLACCESS
  51. #define ISMDLLACCESSDATA __declspec(dllimport)
  52. #endif
  53. ////////////////////// AcDbRasterImage ///////////////////
  54. //
  55. class ISMDLLACCESS AcDbRasterImage : public AcDbImage
  56. {
  57. public:
  58. static ClassVersion classVersion();
  59. ACRX_DECLARE_MEMBERS(AcDbRasterImage);
  60. AcDbRasterImage();
  61. virtual ~AcDbRasterImage();
  62. RasterImageImp* ptrImp() const;
  63. RasterImageImp* setPtrImp(RasterImageImp* pImp);
  64. //////////////////// AcDbObject overrides ////////////////////
  65. //
  66. virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* filer);
  67. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* filer) const;
  68. virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* filer);
  69. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* filer) const;
  70. virtual Acad::ErrorStatus subSwapIdWith(
  71. AcDbObjectId otherId,
  72. Adesk::Boolean swapXdata = Adesk::kFalse,
  73. Adesk::Boolean swapExtDict = Adesk::kFalse
  74. );
  75. //////////////////// AcDbEntity overrides ////////////////////
  76. //
  77. virtual void saveAs(AcGiWorldDraw* mode, AcDb::SaveType st);
  78. virtual bool castShadows() const;
  79. virtual void setCastShadows(bool newVal);
  80. virtual bool receiveShadows() const;
  81. virtual void setReceiveShadows(bool newVal);
  82. ////////////////////// AcDbImage specific protocol ////////////////////
  83. //
  84. virtual AcGiSentScanLines* getScanLines(
  85. const AcGiRequestScanLines& req
  86. ) const;
  87. virtual Adesk::Boolean freeScanLines(
  88. AcGiSentScanLines* pSSL
  89. ) const;
  90. ////////////////////// AcDbRasterImage specific protocol ////////////////////
  91. //
  92. virtual Acad::ErrorStatus setImageDefId(AcDbObjectId imageId);
  93. virtual AcDbObjectId imageDefId() const;
  94. virtual void setReactorId(AcDbObjectId reactorId);
  95. virtual AcDbObjectId reactorId() const;
  96. // Image plane orientation
  97. //
  98. virtual Adesk::Boolean setOrientation(
  99. const AcGePoint3d& origin,
  100. const AcGeVector3d& uCorner,
  101. const AcGeVector3d& vOnPlane);
  102. virtual void getOrientation(
  103. AcGePoint3d& origin,
  104. AcGeVector3d& u,
  105. AcGeVector3d& v) const;
  106. virtual AcGeVector2d scale() const;
  107. virtual AcGeVector2d imageSize(Adesk::Boolean bGetCachedValue
  108. = Adesk::kFalse) const;
  109. // Clip boundary management protocol
  110. //
  111. enum ClipBoundaryType
  112. {
  113. kInvalid,
  114. kRect,
  115. kPoly
  116. };
  117. #ifndef _ADESK_MAC_
  118. virtual Acad::ErrorStatus setClipBoundaryToWholeImage(AcGeVector2d& size);
  119. Acad::ErrorStatus setClipBoundaryToWholeImage()
  120. {
  121. AcGeVector2d size(0, 0);
  122. return setClipBoundaryToWholeImage(size);
  123. }
  124. #else
  125. virtual Acad::ErrorStatus setClipBoundaryToWholeImage(
  126. AcGeVector2d& size);
  127. virtual Acad::ErrorStatus setClipBoundaryToWholeImage()
  128. {
  129. AcGeVector2d size(0, 0);
  130. return setClipBoundaryToWholeImage(size);
  131. }
  132. #endif // Nodef _ADESK_MAC_
  133. virtual Acad::ErrorStatus setClipBoundary(
  134. ClipBoundaryType type,
  135. const AcGePoint2dArray&
  136. );
  137. virtual const AcGePoint2dArray& clipBoundary() const;
  138. virtual ClipBoundaryType clipBoundaryType() const;
  139. Adesk::Boolean isClipped() const;
  140. // Returns either clip boundary or image extents vertices.
  141. // Used for object snapping and intersection.
  142. //
  143. virtual Acad::ErrorStatus getVertices(
  144. AcGePoint3dArray& verts
  145. ) const;
  146. // Image pixel to model coordinate transform
  147. //
  148. virtual Acad::ErrorStatus getPixelToModelTransform(AcGeMatrix3d&) const;
  149. // Per-entity image display and plot options.
  150. //
  151. enum ImageDisplayOpt
  152. {
  153. kShow = 1,
  154. kShowUnAligned = 2,
  155. kClip = 4,
  156. kTransparent = 8
  157. };
  158. virtual void setDisplayOpt(
  159. ImageDisplayOpt option,
  160. Adesk::Boolean bValue
  161. );
  162. virtual Adesk::Boolean isSetDisplayOpt(ImageDisplayOpt option) const;
  163. virtual Acad::ErrorStatus setBrightness( Adesk::Int8 value );
  164. virtual Adesk::Int8 brightness() const;
  165. virtual Acad::ErrorStatus setContrast( Adesk::Int8 value );
  166. virtual Adesk::Int8 contrast() const;
  167. virtual Acad::ErrorStatus setFade( Adesk::Int8 value );
  168. virtual Adesk::Int8 fade() const;
  169. virtual Adesk::Boolean isClipInverted() const;
  170. virtual void setClipInverted(Adesk::Boolean newVal);
  171. double width() const;
  172. double height() const;
  173. double imageHeight() const;
  174. double imageWidth() const;
  175. Acad::ErrorStatus setHeight(double);
  176. Acad::ErrorStatus setWidth(double);
  177. AcGePoint3d position() const;
  178. double rotation() const;
  179. Acad::ErrorStatus setRotation(double rotation);
  180. //aliases for setDisplayOpt/isSetDisplayOpt
  181. bool isImageShown() const;
  182. void setShowImage(bool value);
  183. bool isImageTransparent() const;
  184. void setImageTransparency(bool value);
  185. bool isShownClipped() const;
  186. void setShowClipped(bool value);
  187. protected:
  188. virtual Acad::ErrorStatus subExplode(AcDbVoidPtrArray& entitySet) const;
  189. virtual Adesk::Boolean subWorldDraw(AcGiWorldDraw* mode);
  190. virtual void subViewportDraw(AcGiViewportDraw* mode);
  191. virtual void subList() const;
  192. virtual Acad::ErrorStatus subGetOsnapPoints(
  193. AcDb::OsnapMode osnapMode,
  194. Adesk::GsMarker gsSelectionMark,
  195. const AcGePoint3d& pickPoint,
  196. const AcGePoint3d& lastPoint,
  197. const AcGeMatrix3d& viewXform,
  198. AcGePoint3dArray& snapPoints,
  199. AcDbIntArray & geomIds
  200. ) const;
  201. virtual Acad::ErrorStatus subGetGripPoints(
  202. AcDbGripDataPtrArray& grips,
  203. const double curViewUnitSize,
  204. const int gripSize,
  205. const AcGeVector3d& curViewDir,
  206. const int bitflags
  207. ) const;
  208. virtual Acad::ErrorStatus subGetGripPoints(
  209. AcGePoint3dArray& gripPoints,
  210. AcDbIntArray& osnapModes,
  211. AcDbIntArray & geomIds
  212. ) const;
  213. virtual void subGripStatus (const AcDb::GripStat status);
  214. virtual Acad::ErrorStatus subMoveGripPointsAt(
  215. const AcDbVoidPtrArray& gripAppData,
  216. const AcGeVector3d& offset,
  217. const int bitflags);
  218. virtual Acad::ErrorStatus subMoveGripPointsAt(
  219. const AcDbIntArray& indices,
  220. const AcGeVector3d& offset);
  221. virtual Acad::ErrorStatus subGetStretchPoints(
  222. AcGePoint3dArray& stretchPoints
  223. ) const;
  224. virtual Acad::ErrorStatus subMoveStretchPointsAt(
  225. const AcDbIntArray& indices,
  226. const AcGeVector3d& offset
  227. );
  228. virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform);
  229. virtual Acad::ErrorStatus subGetTransformedCopy(
  230. const AcGeMatrix3d& xform,
  231. AcDbEntity*& ent
  232. ) const;
  233. virtual Acad::ErrorStatus subGetSubentPathsAtGsMarker(
  234. AcDb::SubentType type,
  235. Adesk::GsMarker gsMark,
  236. const AcGePoint3d& pickPoint,
  237. const AcGeMatrix3d& viewXform,
  238. int& numPaths,
  239. AcDbFullSubentPath*& subentPaths,
  240. int numInserts = 0,
  241. AcDbObjectId* entAndInsertStack = 0
  242. ) const;
  243. virtual Acad::ErrorStatus subGetGsMarkersAtSubentPath(
  244. const AcDbFullSubentPath& subPath,
  245. AcArray<Adesk::GsMarker>& gsMarkers
  246. ) const;
  247. virtual AcDbEntity* subSubentPtr(const AcDbFullSubentPath& id) const;
  248. virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
  249. virtual Acad::ErrorStatus subIntersectWith(
  250. const AcDbEntity* ent,
  251. AcDb::Intersect intType,
  252. AcGePoint3dArray& points,
  253. Adesk::GsMarker thisGsMarker = 0,
  254. Adesk::GsMarker otherGsMarker = 0
  255. ) const;
  256. virtual Acad::ErrorStatus subIntersectWith(
  257. const AcDbEntity* ent,
  258. AcDb::Intersect intType,
  259. const AcGePlane& projPlane,
  260. AcGePoint3dArray& points,
  261. Adesk::GsMarker thisGsMarker = 0,
  262. Adesk::GsMarker otherGsMarker = 0
  263. ) const;
  264. virtual Acad::ErrorStatus subGetGeomExtents(AcDbExtents& extents) const;
  265. friend class AcDbImpRasterImage;
  266. void baseList() const;
  267. private:
  268. // These are here because otherwise dllexport tries to export the
  269. // private methods of AcDbObject. They're private in AcDbObject
  270. // because vc5 does not properly support array new and delete.
  271. // It tends to call the wrong delete operator and to not call
  272. // the dtors on all elements in the array. So we make them
  273. // private in order to prevent usage of them.
  274. //
  275. #ifdef MEM_DEBUG
  276. #undef new
  277. #undef delete
  278. #endif
  279. void *operator new[](size_t) throw() { return (void*)0;}
  280. void operator delete[](void *) {};
  281. void *operator new[](size_t, const char *, int) throw() { return (void*)0;}
  282. #ifdef MEM_DEBUG
  283. #define new DEBUG_NEW
  284. #define delete DEBUG_DELETE
  285. #endif
  286. RasterImageImp* mpImp;
  287. static ClassVersion mVersion;
  288. };
  289. //////////////////// inlines ////////////////////
  290. //
  291. //returns the implementation class pointer
  292. inline RasterImageImp*
  293. AcDbRasterImage::ptrImp() const
  294. {
  295. return mpImp;
  296. }
  297. //sets the implementation class pointer
  298. inline RasterImageImp*
  299. AcDbRasterImage::setPtrImp(RasterImageImp* pImp)
  300. {
  301. RasterImageImp* oldImp=mpImp;
  302. mpImp=pImp;
  303. return oldImp;
  304. }
  305. inline ClassVersion
  306. AcDbRasterImage::classVersion()
  307. { return mVersion; }
  308. inline void
  309. pixelToModel(
  310. const AcGeMatrix3d& pixToMod,
  311. const AcGePoint2d& pixPt,
  312. AcGePoint3d& modPt)
  313. {
  314. // Transform pixel coordinates to model space.
  315. //
  316. modPt.set(pixPt.x, pixPt.y, 0);
  317. modPt.transformBy(pixToMod);
  318. }
  319. inline void
  320. modelToPixel(
  321. const AcGeMatrix3d& modToPix,
  322. const AcGePoint3d& modPt,
  323. AcGePoint2d& pixPt)
  324. {
  325. // Transform model coordinates to pixel space.
  326. //
  327. AcGePoint3d modelPt = modPt;
  328. modelPt.transformBy(modToPix);
  329. pixPt.set(modelPt.x, modelPt.y);
  330. }
  331. inline void
  332. modelToPixel(
  333. const AcGeVector3d& viewDir,
  334. const AcGeMatrix3d& modToPix,
  335. const AcGePlane& plane,
  336. const AcGePoint3d& modPt,
  337. AcGePoint2d& pixPt)
  338. {
  339. // Project the point in the viewpoint direction
  340. // onto the plane of the image.
  341. //
  342. AcGePoint3d ptOnPlane = modPt.project(plane, viewDir);
  343. ptOnPlane.transformBy(modToPix);
  344. pixPt.set(ptOnPlane.x, ptOnPlane.y);
  345. }
  346. #pragma warning( default : 4275 )
  347. #pragma pack (pop)
  348. #endif // __IMGENT_H