acgi.h 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. //
  12. // This is the Graphics Interface for view independent and dependent
  13. // elaboration of AcDb Entities.
  14. //
  15. // The AutoCAD Graphics Interface (AcGi) is a set of objects comprising
  16. // an API for elaborating the graphics representation of new AutoCAD
  17. // entitites. These objects support many geometric primitives,
  18. // transformation matrix querying, and graphical attributes.
  19. #ifndef _ACGI_H
  20. #define _ACGI_H 1
  21. #include "adesk.h"
  22. // Required for RX
  23. //
  24. #define ACGI_SERVICES ACRX_T(/*MSG0*/"AcGiServices")
  25. // Gcc not allow forward declaration of enum
  26. // I am moving some enum definitions to acgidefs.h
  27. // So other header files can include that file instead of forward declaration.
  28. #include "acgidefs.h"
  29. #include "rxobject.h"
  30. #include "AdAChar.h"
  31. #include "dbpl.h"
  32. #include "gemat3d.h"
  33. #include "gemat2d.h"
  34. #include "gepnt2d.h"
  35. #include "dbcolor.h"
  36. #include "acdb.h"
  37. #include "AcGiStyleAttributes.h"
  38. #include "assert.h"
  39. #include "AcGiParameter.h"
  40. #pragma pack (push, 8)
  41. struct AcGiSentScanLines
  42. {
  43. enum IsmRequestStatus {
  44. eOk, // No Failure.
  45. eInvalidInput, // unknown image organization
  46. eInvalidColorDepth, // mColorDepth to big or too small for request
  47. eInvalidPixelRequest, // IefAffine (matrix scaling) failed for some reason
  48. eInvalidDeliveryMethod, // Frame buffer delivery + compression - not valid
  49. eNoValidCompressors, // no compressors for image data
  50. eInsufficientMemory // low memory conditions.. very bad
  51. };
  52. Adesk::Int8 * mpPixelBuffer; // one pointer per scan line
  53. Adesk::UInt32 mRowBytes; // number of bytes per scan line
  54. void * mpImageId; // image id ptr
  55. Adesk::Int16 mIsCancelled; // boolean: user cancelled
  56. Adesk::Int16 mHasFailed; // boolean: request failed
  57. Adesk::UInt32 mBytes;
  58. IsmRequestStatus mRequestStatus;
  59. };
  60. struct AcGiRequestScanLines
  61. {
  62. enum IEDitherMethod
  63. {
  64. kIEAnyPalette,
  65. kCustomDithering,
  66. kCustomDitheringMethod
  67. };
  68. enum IEColorSystem
  69. {
  70. kBitonal,
  71. kCMY,
  72. kCMYK,
  73. kRGB
  74. };
  75. enum ImagePaletteType
  76. {
  77. kFromDevice,
  78. kFromIeWholeImage
  79. };
  80. AcGiRequestScanLines()
  81. : mPixelMinX (0)
  82. , mPixelMinY (0)
  83. , mPixelMaxX (0)
  84. , mPixelMaxY (0)
  85. , mpImageId (0)
  86. , mImageOrg (kAcGiBitonal)
  87. , mImageOrient (kAcGiXLeftToRightTopFirst)
  88. , mWindowId (0)
  89. , mColorDepth (8)
  90. , mPaletteIncarnation (0)
  91. , mpPalette (0)
  92. , mIsDisplay (0)
  93. , mRasterRatio (1.0)
  94. , mPaletteType (kFromDevice)
  95. , mpDataBuffer (0)
  96. , mRowWidth (0)
  97. , mpBoundaryPoints (0)
  98. , mnContours (0)
  99. , mpCounts (0)
  100. , mScalingType (kDefaultScale)
  101. , mScaleFilterType (kDefaultScaleFilter)
  102. , mRotationFilterType (kDefaultRotationFilter)
  103. , mnTotalChunks (0)
  104. , mnThisChunk (0)
  105. {
  106. }
  107. Adesk::UInt32 mPixelMinX; // requested pixel corners
  108. Adesk::UInt32 mPixelMinY;
  109. Adesk::UInt32 mPixelMaxX;
  110. Adesk::UInt32 mPixelMaxY;
  111. AcGePoint2d mLowerLeft; // requested lower left corner
  112. AcGePoint2d mUpperRight; // requested upper right corner
  113. void * mpImageId; // image handle
  114. AcGiImageOrg mImageOrg; // enum type: palette, RGB
  115. AcGiImageOrient mImageOrient; // enum type
  116. Adesk::Int16 mWindowId; // acad window id
  117. Adesk::Int16 mColorDepth; // bits per pixel
  118. union {
  119. Adesk::Int16 mBackgroundIndex;
  120. Adesk::Int8 mBackgroundRGB[3];
  121. } mBackgroundColor; // current background color
  122. union {
  123. Adesk::Int16 mTransparentIndex;
  124. Adesk::Int8 mTransparentRGB[3];
  125. } mTransparentColor; // current background color
  126. union {
  127. Adesk::Int16 mEntityIndex;
  128. Adesk::Int8 mEntityRGB[3];
  129. } mEntityColor; // bitonal image foregrnd color
  130. Adesk::Int32 mPaletteIncarnation; // unique palette indentifier
  131. Adesk::Int8 * mpPalette; // pointer to 256 RGB triples
  132. Adesk::Int16 mIsDisplay; // boolean: TRUE=dsply, FALSE=hrdcpy
  133. double mRasterRatio; // raster resolution
  134. AcGeMatrix2d mPixelToDc; // source pixel-to-dc transform
  135. ImagePaletteType mPaletteType;
  136. void * mpDataBuffer;
  137. Adesk::Int32 mRowWidth;
  138. Adesk::Int32 mNumRows;
  139. Adesk::Int32 const *mpBoundaryPoints; // array of x,y pairs
  140. Adesk::UInt32 mnContours; // number of contours
  141. Adesk::Int32 const *mpCounts; // pt count for each contour
  142. AcGiScaleType mScalingType;
  143. AcGiScaleFilterType mScaleFilterType;
  144. AcGiRotationFilterType mRotationFilterType;
  145. short mnTotalChunks; // how many chunks will be requested
  146. short mnThisChunk; // 1 based count of chunks
  147. };
  148. struct AcGiClipBoundary
  149. {
  150. AcGeVector3d m_vNormal;
  151. AcGePoint3d m_ptPoint;
  152. AcGePoint2dArray m_aptPoints;
  153. AcGeMatrix3d m_xToClipSpace;// Transformation from model to clip space
  154. AcGeMatrix3d m_xInverseBlockRefXForm; // Xform from block space to world
  155. Adesk::Boolean m_bClippingFront;
  156. Adesk::Boolean m_bClippingBack;
  157. double m_dFrontClipZ;
  158. double m_dBackClipZ;
  159. Adesk::Boolean m_bDrawBoundary;
  160. };
  161. class OwnerDraw3d
  162. {
  163. public:
  164. virtual ~OwnerDraw3d(void) {};
  165. };
  166. // To be removed
  167. enum AcGiColorIntensity
  168. {
  169. kAcGiMinColorIntensity = 0x0,
  170. kAcGiColorIntensity1 = 0x1,
  171. kAcGiColorIntensity2 = 0x2,
  172. kAcGiColorIntensity3 = 0x3,
  173. kAcGiColorIntensity4 = 0x4,
  174. kAcGiColorIntensity5 = 0x5,
  175. kAcGiColorIntensity6 = 0x6,
  176. kAcGiMaxColorIntensity = 0x7
  177. };
  178. class AcGiColorRGB
  179. {
  180. public:
  181. AcGiColorRGB (void)
  182. : red (0.0)
  183. , green (0.0)
  184. , blue (0.0)
  185. { }
  186. AcGiColorRGB (double r, double g, double b)
  187. : red (r)
  188. , green (g)
  189. , blue (b)
  190. { }
  191. double red;
  192. double green;
  193. double blue;
  194. };
  195. inline AcGiColorRGB operator* (const AcGiColorRGB& c1, const AcGiColorRGB& c2)
  196. {
  197. return AcGiColorRGB(c1.red * c2.red,
  198. c1.green * c2.green,
  199. c1.blue * c2.blue);
  200. }
  201. inline AcGiColorRGB operator* (const AcGiColorRGB& c, double s)
  202. {
  203. return AcGiColorRGB(s * c.red,
  204. s * c.green,
  205. s * c.blue);
  206. }
  207. inline AcGiColorRGB operator* (double s, const AcGiColorRGB& c)
  208. {
  209. return c * s;
  210. }
  211. inline AcGiColorRGB operator+ (const AcGiColorRGB& c1, const AcGiColorRGB& c2)
  212. {
  213. return AcGiColorRGB(c1.red + c2.red,
  214. c1.green + c2.green,
  215. c1.blue + c2.blue);
  216. }
  217. class AcGiColorRGBA
  218. {
  219. public:
  220. AcGiColorRGBA (void)
  221. : red (0.0)
  222. , green (0.0)
  223. , blue (0.0)
  224. , alpha (1.0)
  225. { }
  226. AcGiColorRGBA (double r, double g, double b, double a)
  227. : red (r)
  228. , green (g)
  229. , blue (b)
  230. , alpha (a)
  231. { }
  232. double red;
  233. double green;
  234. double blue;
  235. double alpha;
  236. };
  237. inline AcGiColorRGBA operator* (const AcGiColorRGBA& c1, const AcGiColorRGBA& c2)
  238. {
  239. return AcGiColorRGBA(c1.red * c2.red,
  240. c1.green * c2.green,
  241. c1.blue * c2.blue,
  242. c1.alpha * c2.alpha);
  243. }
  244. inline AcGiColorRGBA operator*(const AcGiColorRGBA& c, double s)
  245. {
  246. return AcGiColorRGBA(s * c.red,
  247. s * c.green,
  248. s * c.blue,
  249. s * c.alpha);
  250. }
  251. inline AcGiColorRGBA operator* (double s, const AcGiColorRGBA& c)
  252. {
  253. return c * s;
  254. }
  255. inline AcGiColorRGBA operator+ (const AcGiColorRGBA& c1, const AcGiColorRGBA& c2)
  256. {
  257. return AcGiColorRGBA(c1.red + c2.red,
  258. c1.green + c2.green,
  259. c1.blue + c2.blue,
  260. c1.alpha + c2.alpha);
  261. }
  262. class AcGiPixelBGRA32
  263. {
  264. public:
  265. AcGiPixelBGRA32 ()
  266. {
  267. m_bgra.b = 0;
  268. m_bgra.g = 0;
  269. m_bgra.r = 0;
  270. m_bgra.a = 255;
  271. }
  272. AcGiPixelBGRA32(Adesk::UInt32 bgra)
  273. : m_whole (bgra)
  274. { }
  275. AcGiPixelBGRA32 (Adesk::UInt8 blue,
  276. Adesk::UInt8 green,
  277. Adesk::UInt8 red,
  278. Adesk::UInt8 alpha)
  279. {
  280. m_bgra.b = blue;
  281. m_bgra.g = green;
  282. m_bgra.r = red;
  283. m_bgra.a = alpha;
  284. }
  285. Adesk::UInt32 getBGRA () const;
  286. Adesk::UInt32 getRGBA () const;
  287. Adesk::UInt8 blue () const;
  288. Adesk::UInt8 green () const;
  289. Adesk::UInt8 red () const;
  290. Adesk::UInt8 alpha () const;
  291. void setBGRA (Adesk::UInt32 bgra);
  292. void setBGRA (Adesk::UInt8 blue,
  293. Adesk::UInt8 green,
  294. Adesk::UInt8 red,
  295. Adesk::UInt8 alpha);
  296. void setRGBA (Adesk::UInt32 rgba);
  297. void setRGBA (Adesk::UInt8 red,
  298. Adesk::UInt8 green,
  299. Adesk::UInt8 blue,
  300. Adesk::UInt8 alpha);
  301. void setBlue (Adesk::UInt8 blue);
  302. void setGreen (Adesk::UInt8 green);
  303. void setRed (Adesk::UInt8 red);
  304. void setAlpha (Adesk::UInt8 alpha);
  305. private:
  306. union {
  307. Adesk::UInt32 m_whole;
  308. #if defined(_ADESK_WINDOWS_)
  309. struct PIXEL{
  310. #else
  311. // The GCC compiler requires the PIXEL struct to be anonymous as well.
  312. // I don't think we need the PIXEL struct identifier, so this should work.
  313. // If not, we'll have to provide a name for the union and update al the code
  314. // to use that name.
  315. //
  316. struct {
  317. #endif
  318. Adesk::UInt8 b, g, r, a;
  319. }m_bgra;
  320. };
  321. };
  322. inline Adesk::UInt32 AcGiPixelBGRA32::getBGRA() const
  323. {
  324. return m_whole;
  325. }
  326. inline Adesk::UInt32 AcGiPixelBGRA32::getRGBA() const
  327. {
  328. return (Adesk::UInt32)(m_bgra.a)<<24
  329. | (Adesk::UInt32)(m_bgra.b)<<16
  330. | (Adesk::UInt32)(m_bgra.g)<<8
  331. | (Adesk::UInt32)(m_bgra.r);
  332. }
  333. inline Adesk::UInt8 AcGiPixelBGRA32::blue() const
  334. {
  335. return m_bgra.b;
  336. }
  337. inline Adesk::UInt8 AcGiPixelBGRA32::green() const
  338. {
  339. return m_bgra.g;
  340. }
  341. inline Adesk::UInt8 AcGiPixelBGRA32::red() const
  342. {
  343. return m_bgra.r;
  344. }
  345. inline Adesk::UInt8 AcGiPixelBGRA32::alpha() const
  346. {
  347. return m_bgra.a;
  348. }
  349. inline void AcGiPixelBGRA32::setBGRA(Adesk::UInt32 bgra)
  350. {
  351. m_whole = bgra;
  352. }
  353. inline void AcGiPixelBGRA32::setBGRA(Adesk::UInt8 blue,
  354. Adesk::UInt8 green,
  355. Adesk::UInt8 red,
  356. Adesk::UInt8 alpha)
  357. {
  358. m_bgra.b = blue;
  359. m_bgra.g = green;
  360. m_bgra.r = red;
  361. m_bgra.a = alpha;
  362. }
  363. inline void AcGiPixelBGRA32::setRGBA(Adesk::UInt32 rgba)
  364. {
  365. m_bgra.r = (Adesk::UInt8)(rgba & 0x000000FF);
  366. m_bgra.g = (Adesk::UInt8)((rgba & 0x0000FF00) >> 8);
  367. m_bgra.b = (Adesk::UInt8)((rgba & 0x00FF0000) >> 16);
  368. m_bgra.a = (Adesk::UInt8)((rgba & 0xFF000000) >> 24);
  369. }
  370. inline void AcGiPixelBGRA32::setRGBA(Adesk::UInt8 red,
  371. Adesk::UInt8 green,
  372. Adesk::UInt8 blue,
  373. Adesk::UInt8 alpha)
  374. {
  375. m_bgra.r = red;
  376. m_bgra.g = green;
  377. m_bgra.b = blue;
  378. m_bgra.a = alpha;
  379. }
  380. inline void AcGiPixelBGRA32::setBlue(Adesk::UInt8 blue)
  381. {
  382. m_bgra.b = blue;
  383. }
  384. inline void AcGiPixelBGRA32::setGreen(Adesk::UInt8 green)
  385. {
  386. m_bgra.g = green;
  387. }
  388. inline void AcGiPixelBGRA32::setRed(Adesk::UInt8 red)
  389. {
  390. m_bgra.r = red;
  391. }
  392. inline void AcGiPixelBGRA32::setAlpha(Adesk::UInt8 alpha)
  393. {
  394. m_bgra.a = alpha;
  395. }
  396. class AcGiImageBGRA32
  397. {
  398. public:
  399. AcGiImageBGRA32 ()
  400. : m_nImageWidth (0)
  401. , m_nImageHeight (0)
  402. , m_pImageData (NULL)
  403. { }
  404. AcGiImageBGRA32 (Adesk::UInt32 imageWidth,
  405. Adesk::UInt32 imageHeight,
  406. AcGiPixelBGRA32* imageData)
  407. : m_nImageWidth (imageWidth)
  408. , m_nImageHeight (imageHeight)
  409. , m_pImageData (imageData)
  410. { }
  411. AcGiPixelBGRA32* image () const;
  412. Adesk::UInt32 width () const;
  413. Adesk::UInt32 height () const;
  414. void setImage (Adesk::UInt32 imageWidth,
  415. Adesk::UInt32 imageHeight,
  416. AcGiPixelBGRA32* imageData);
  417. private:
  418. AcGiPixelBGRA32* m_pImageData;
  419. Adesk::UInt32 m_nImageWidth;
  420. Adesk::UInt32 m_nImageHeight;
  421. };
  422. inline AcGiPixelBGRA32* AcGiImageBGRA32::image() const
  423. {
  424. return m_pImageData;
  425. }
  426. inline Adesk::UInt32 AcGiImageBGRA32::width() const
  427. {
  428. return m_nImageWidth;
  429. }
  430. inline Adesk::UInt32 AcGiImageBGRA32::height() const
  431. {
  432. return m_nImageHeight;
  433. }
  434. inline void AcGiImageBGRA32::setImage (Adesk::UInt32 imageWidth,
  435. Adesk::UInt32 imageHeight,
  436. AcGiPixelBGRA32* imageData)
  437. {
  438. m_nImageWidth = imageWidth;
  439. m_nImageHeight = imageHeight;
  440. m_pImageData = imageData;
  441. }
  442. class AcGiSubEntityTraits;
  443. class AcGiDrawableTraits;
  444. class AcGiSubEntityTraitsImp;
  445. class AcGiWorldGeometry;
  446. class AcGiViewport;
  447. class AcGiViewportGeometry;
  448. class AcGiImpEdgeData;
  449. class AcGiImpFaceData;
  450. class AcGiImpVertexData;
  451. class AcGiImpTextStyle;
  452. class AcGiTextStyle;
  453. class AcGiEdgeData;
  454. class AcGiFaceData;
  455. class AcGiVertexData;
  456. class OwnerDraw;
  457. class AcGiImpVariant;
  458. class AcGiVariant;
  459. class AcGiContextImp;
  460. class AcGiContext;
  461. class AcGiCommonDraw;
  462. class AcGiGeometry;
  463. class AcCmEntityColor;
  464. struct TextParams;
  465. struct FontInfo;
  466. class AcGiMapper;
  467. class AcGiViewportTraits;
  468. class AcGiVisualStyleTraits;
  469. class AcGiContextualColors;
  470. class AcGiGdiDrawObject;
  471. class AcGiImpHatchPatternDefinition;
  472. class AcGiImpHatchPattern;
  473. class AcGiFill;
  474. class AcGiImpFill;
  475. class AcGiImpGradientFill;
  476. typedef void (*AcGiWorldSegmentCallback)(const AcGePoint3d *);
  477. bool acgiIsValidClipBoundary(const AcGePoint2dArray& pts);
  478. Acad::ErrorStatus acgiGetRegenBlockRefStack(AcDbObjectIdArray& blkRefs);
  479. class AcGiVariant : public AcRxObject
  480. //
  481. // Class for handling variant data
  482. //
  483. {
  484. public:
  485. ACRX_DECLARE_MEMBERS(AcGiVariant);
  486. AcGiVariant(void);
  487. virtual ~AcGiVariant(void);
  488. AcGiVariant (const AcGiVariant & value);
  489. AcGiVariant & operator= (const AcGiVariant & value);
  490. virtual bool operator==(const AcGiVariant & value) const;
  491. // note that a variant copy is a deep copy. If describing a hierarchical
  492. // data structure, the entire structure is duplicated
  493. // AcRxObject protocol
  494. virtual Acad::ErrorStatus copyFrom(const AcRxObject* other);
  495. enum VariantType
  496. {
  497. kUndefined = 0,
  498. kBoolean,
  499. kInt,
  500. kDouble,
  501. kColor,
  502. kString,
  503. kTable,
  504. };
  505. class EnumType
  506. {
  507. public:
  508. explicit EnumType (int value) : m_value(value) { }
  509. template <typename T>
  510. operator T () { return static_cast<T>(m_value); }
  511. template <typename T>
  512. bool operator== (T right) const { return static_cast<int>(right) == m_value; }
  513. template <typename T>
  514. bool operator!= (T right) const { return !(*this == right); }
  515. protected:
  516. int m_value;
  517. };
  518. AcGiVariant(bool);
  519. AcGiVariant(Adesk::Int32);
  520. AcGiVariant(double);
  521. AcGiVariant(const AcCmColor&);
  522. AcGiVariant(const ACHAR *);
  523. VariantType type() const;
  524. void set(bool);
  525. void set(Adesk::Int32);
  526. void set(double);
  527. void set(const AcCmColor&);
  528. void set(const ACHAR *);
  529. bool asBoolean() const;
  530. int asInt() const;
  531. double asDouble() const;
  532. AcCmColor asColor() const;
  533. AcString asString() const;
  534. ACDB_PORT float asFloat() const;
  535. ACDB_PORT char asChar() const;
  536. ACDB_PORT unsigned char asUchar() const;
  537. ACDB_PORT short asShort() const;
  538. ACDB_PORT unsigned short asUshort() const;
  539. ACDB_PORT unsigned int asUint() const;
  540. ACDB_PORT Adesk::Int32 asLong() const;
  541. ACDB_PORT Adesk::UInt32 asUlong() const;
  542. ACDB_PORT EnumType asEnum() const;
  543. // table access..
  544. Acad::ErrorStatus getElem(const ACHAR * pKey, AcGiVariant & value) const;
  545. const AcGiVariant* getElem(const ACHAR * pKey) const;
  546. void setElem(const ACHAR * pKey, const AcGiVariant&);
  547. void deleteElem(const ACHAR * pKey);
  548. int getElemCount() const;
  549. Acad::ErrorStatus getElemAt(int nIndex, ACHAR*&, AcGiVariant &) const; // caller is responsible for deleting returned ACHAR*
  550. AcGiVariant* getElemAt(int nIndex, ACHAR*&) const; // caller is responsible for deleting returned ACHAR*
  551. static bool isEquivalent(const AcGiVariant*, const AcGiVariant*);
  552. private:
  553. AcGiImpVariant * mpAcGiImpVariant;
  554. };
  555. template <typename T>
  556. inline bool operator== (T left, const AcGiVariant::EnumType right)
  557. {
  558. return (right == left);
  559. }
  560. template <typename T>
  561. inline bool operator!= (T left, const AcGiVariant::EnumType right)
  562. {
  563. return (right != left);
  564. }
  565. //
  566. // AcGiKernelDescriptor is used to describe the capabilities of
  567. // a graphics kernel, or to specify the desired capabilities.
  568. //
  569. // Sample usage:
  570. // const AcGiKernelDescriptor &descriptor = context()->kernel.getDescriptor();
  571. // static const AcUniqueString *kRequestedFeature = AcUniqueString::Intern(L"Requested Feature");
  572. // if (descriptor.supports(kRequestedFeature))
  573. // ...
  574. //
  575. // The default graphics kernel supports nothing.
  576. class AcGiKernelDescriptor : public AcArray<const AcUniqueString *>
  577. {
  578. public:
  579. // Require support for a given capability.
  580. void addRequirement(const AcUniqueString *capability) { append(capability); }
  581. // Query support for a given capability.
  582. bool supports(const AcUniqueString *capability) const { return contains(capability); }
  583. bool supports(const AcGiKernelDescriptor& desc) const
  584. {
  585. int len = desc.length();
  586. for (int i=0; i<len; i++)
  587. {
  588. if (!contains(desc[i]))
  589. return false;
  590. }
  591. return true;
  592. }
  593. };
  594. class AcGiGraphicsKernel
  595. {
  596. public:
  597. virtual ~AcGiGraphicsKernel() { }
  598. virtual const AcGiKernelDescriptor &getDescriptor(void) const { return m_descriptor; }
  599. private:
  600. AcGiKernelDescriptor m_descriptor;
  601. };
  602. #pragma warning (push)
  603. #pragma warning (disable : 4100) // unreferenced formal parameter
  604. class AcGiContext : public AcRxObject
  605. //
  606. // The base class for drawing contexts
  607. //
  608. {
  609. public:
  610. ACRX_DECLARE_MEMBERS(AcGiContext);
  611. virtual Adesk::Boolean isPsOut() const = 0;
  612. virtual Adesk::Boolean isPlotGeneration() const = 0;
  613. virtual AcDbDatabase *database() const = 0;
  614. virtual bool isBoundaryClipping() const = 0;
  615. // Which kernel is implementing this AcGi interface? The descriptor is very useful.
  616. // The default implementation is a kernel that supports nothing.
  617. virtual class AcGiGraphicsKernel &graphicsKernel() { static AcGiGraphicsKernel kernel; return kernel; }
  618. // If your object requires to be redrawn for translation
  619. // transforms (MOVE) you can force the system to rerequest
  620. // graphics for all objects in the current drag, including
  621. // yourself. Use this option only if you really need to.
  622. // E.g. If your object needs to update for each step in a
  623. // MOVE drag
  624. //
  625. virtual void disableFastMoveDrag() const { }
  626. // Returns false if this is root level entity, e.g. a line in modelspace
  627. // and true if the object is contained within another object like a
  628. // block for example.
  629. //
  630. virtual bool isNesting() const { return false; }
  631. virtual AcCmEntityColor effectiveColor() const { return AcCmEntityColor(); }
  632. virtual AcDb::LineWeight byBlockLineWeight() const { return AcDb::kLnWt000; }
  633. virtual AcDbObjectId byBlockPlotStyleNameId() const { return nullptr; }
  634. virtual AcDbObjectId byBlockMaterialId() const { return AcDbObjectId::kNull; }
  635. virtual bool supportsTrueTypeText() { return false; }
  636. virtual bool supportsOwnerDraw() { return false; }
  637. virtual bool supportsFillTrait() const { return false; }
  638. ///////////////////////////////////////////////////////////////////////////
  639. ///////////////////////////////////////////////////////////////////////////
  640. // These APIs is provided for internal use only, do not use them
  641. // in external applications
  642. //
  643. virtual AcGiContextImp *getImpPtr() { return nullptr; }
  644. virtual const AcGiContextImp *getConstImpPtr() const { return nullptr; }
  645. //
  646. // End of Internal use only API
  647. ///////////////////////////////////////////////////////////////////////////
  648. ///////////////////////////////////////////////////////////////////////////
  649. protected:
  650. friend class AcGiTextHook;
  651. friend class CShFont;
  652. friend class AcDbImpText;
  653. ///////////////////////////////////////////////////////////////////////////
  654. ///////////////////////////////////////////////////////////////////////////
  655. // These APIs is provided for internal use only, do not use them
  656. // in external applications
  657. //
  658. virtual AcGiWorldSegmentCallback wSegTaker() const { return nullptr; }
  659. virtual int getTrueTypeBoundingBox(AcGePoint3d const & /*location*/,
  660. const wchar_t * /*text*/,
  661. int /*length*/, TextParams const * /*tp*/,
  662. AcGePoint3d * /*bbox*/, float * /*char_widths*/) { return 0; }
  663. virtual int getTrueTypeTextExtents(ACHAR const *, unsigned int, double,
  664. int, int,
  665. int, short, short, double, double,
  666. AcGePoint2d &,AcGePoint2d &) { return -1; }
  667. virtual int setTrueTypeTransform(const AcGePoint3d &,const AcGeVector3d &,
  668. double, double, double, bool, bool) { return 0; }
  669. virtual int drawTrueTypeText(const ACHAR *,double,int,bool,
  670. const TextParams &,unsigned int) { return 0; }
  671. virtual int restoreTrueTypeTransform() { return 0; }
  672. virtual void bypassHiddenLineRemoval() { }
  673. virtual int setTextStyle(int);
  674. virtual Adesk::LongPtr loadTrueTypeFont(const ACHAR *, bool, bool, int, int, FontInfo &) { return 0; }
  675. //
  676. // End of Internal use only API
  677. ///////////////////////////////////////////////////////////////////////////
  678. ///////////////////////////////////////////////////////////////////////////
  679. };
  680. class AcGiCommonDraw : public AcRxObject
  681. //
  682. // The base class for drawing contexts
  683. //
  684. {
  685. public:
  686. ACRX_DECLARE_MEMBERS(AcGiCommonDraw);
  687. virtual AcGiRegenType regenType() const = 0;
  688. virtual Adesk::Boolean regenAbort() const = 0;
  689. virtual AcGiSubEntityTraits &subEntityTraits() const = 0;
  690. virtual AcGiGeometry *rawGeometry() const = 0;
  691. virtual Adesk::Boolean isDragging() const = 0;
  692. // This function operates against the current active viewport
  693. //
  694. virtual double deviation(const AcGiDeviationType,
  695. const AcGePoint3d &) const = 0;
  696. virtual Adesk::UInt32 numberOfIsolines() const = 0;
  697. virtual AcGiContext *context() = 0;
  698. virtual bool secondaryCall() const { return false; }
  699. };
  700. class AcGiWorldDraw: public AcGiCommonDraw
  701. //
  702. // This class provides an API for generating graphics
  703. // in model coordinates. These graphics cannot be
  704. // controlled by any viewport, as can AcGiViewportDraw.
  705. //
  706. {
  707. public:
  708. ACRX_DECLARE_MEMBERS(AcGiWorldDraw);
  709. virtual AcGiWorldGeometry& geometry() const = 0;
  710. };
  711. class AcGiViewportDraw: public AcGiCommonDraw
  712. //
  713. // This class provides an API for generating graphics
  714. // that can be sent to a particular viewport.
  715. //
  716. {
  717. public:
  718. ACRX_DECLARE_MEMBERS(AcGiViewportDraw);
  719. virtual AcGiViewport& viewport() const = 0;
  720. virtual AcGiViewportGeometry& geometry() const = 0;
  721. virtual Adesk::UInt32 sequenceNumber() const = 0;
  722. // why is the following method's arg const?
  723. virtual Adesk::Boolean isValidId(const Adesk::ULongPtr acgiId) const =0;
  724. virtual AcDbObjectId viewportObjectId() const = 0;
  725. };
  726. class AcGiViewport: public AcRxObject
  727. //
  728. // This class returns viewport info.
  729. //
  730. {
  731. public:
  732. ACRX_DECLARE_MEMBERS(AcGiViewport);
  733. // Get various view transformations.
  734. //
  735. virtual void getModelToEyeTransform(AcGeMatrix3d&) const = 0;
  736. virtual void getEyeToModelTransform(AcGeMatrix3d&) const = 0;
  737. virtual void getWorldToEyeTransform(AcGeMatrix3d&) const = 0;
  738. virtual void getEyeToWorldTransform(AcGeMatrix3d&) const = 0;
  739. // Perspective information.
  740. //
  741. virtual Adesk::Boolean isPerspective() const = 0;
  742. virtual Adesk::Boolean doPerspective(AcGePoint3d&) const = 0;
  743. virtual Adesk::Boolean doInversePerspective(AcGePoint3d&) const = 0;
  744. // Pixel information.
  745. //
  746. virtual void getNumPixelsInUnitSquare(const AcGePoint3d& givenWorldpt,
  747. AcGePoint2d& pixelArea,
  748. bool includePerspective = true) const = 0;
  749. // Camera information.
  750. //
  751. virtual void getCameraLocation(AcGePoint3d& location) const = 0;
  752. virtual void getCameraTarget(AcGePoint3d& target) const = 0;
  753. virtual void getCameraUpVector(AcGeVector3d& upVector) const = 0;
  754. // Viewport information.
  755. //
  756. virtual Adesk::ULongPtr viewportId() const = 0;
  757. virtual Adesk::Int16 acadWindowId() const = 0;
  758. virtual void getViewportDcCorners(AcGePoint2d& lower_left,
  759. AcGePoint2d& upper_right) const = 0;
  760. // Clipping
  761. //
  762. virtual Adesk::Boolean getFrontAndBackClipValues(Adesk::Boolean& clip_front,
  763. Adesk::Boolean& clip_back,
  764. double& front,
  765. double& back) const = 0;
  766. // The factor returned here affects the linetype scaling in this viewport
  767. // 1.0 is the default. Returning a value of 2 will ensure
  768. // that the pattern is twice as big as per default.
  769. //
  770. virtual double linetypeScaleMultiplier() const = 0;
  771. // If the calculated total pattern length of a linetyped object is less
  772. // than this (value in drawing units). Then a continuous pattern is used
  773. // instead. Several factors affect the linetype pattern length.
  774. // linetypeScaleMultiplier() is one of them. Note: If you set this value
  775. // high you could completely prevent the use of linetypes.
  776. //
  777. virtual double linetypeGenerationCriteria() const = 0;
  778. // Returns true if the layer is not frozen in this viewport and not globally
  779. // frozen. Indicating that geometry on this layer should be regenerated.
  780. //
  781. virtual Adesk::Boolean layerVisible(const AcDbObjectId & /*idLayer*/) const { return Adesk::kTrue; }
  782. virtual AcGeVector3d viewDir() const { return AcGeVector3d::kZAxis; }
  783. // Provides access to color information that is context-sensitive.
  784. //
  785. virtual const AcGiContextualColors* contextualColors() const { return NULL; }
  786. };
  787. class AcGiContextualColors : public AcRxObject
  788. {
  789. //
  790. // This class returns color information for objects that can have different colors
  791. // in different display contexts.
  792. //
  793. public:
  794. ACRX_DECLARE_MEMBERS(AcGiContextualColors);
  795. // Access to colors.
  796. virtual Adesk::UInt32 gridMajorLines() const = 0;
  797. virtual Adesk::UInt32 gridMinorLines() const = 0;
  798. virtual Adesk::UInt32 gridAxisLines() const = 0;
  799. virtual int gridMajorLineTintXYZ() const = 0;
  800. virtual int gridMinorLineTintXYZ() const = 0;
  801. virtual int gridAxisLineTintXYZ() const = 0;
  802. virtual Adesk::UInt32 lightGlyphs() const = 0;
  803. virtual Adesk::UInt32 lightHotspot() const = 0;
  804. virtual Adesk::UInt32 lightFalloff() const = 0;
  805. virtual Adesk::UInt32 lightStartLimit() const = 0;
  806. virtual Adesk::UInt32 lightEndLimit() const = 0;
  807. virtual Adesk::UInt32 cameraGlyphs() const = 0;
  808. virtual Adesk::UInt32 cameraFrustrum() const = 0;
  809. virtual Adesk::UInt32 cameraClipping() const = 0;
  810. // Access to context parameters.
  811. virtual void setContextFlags(Adesk::UInt32 flg, bool set = true) = 0;
  812. virtual bool flagsSet(Adesk::UInt32 flg) const = 0;
  813. };
  814. class AcGiContextualColors2 : public AcGiContextualColors
  815. {
  816. //
  817. // This class returns color information for objects that can have different colors
  818. // in different display contexts. This class also includes the web mesh color
  819. // for photometric lights.
  820. //
  821. public:
  822. ACRX_DECLARE_MEMBERS(AcGiContextualColors2);
  823. virtual AcCmColor webMeshColor (void) const = 0;
  824. virtual AcCmColor webMeshMissingColor(void) const = 0;
  825. virtual AcCmColor lightShapeColor (void) const = 0;
  826. virtual AcCmColor lightDistanceColor (void) const = 0;
  827. };
  828. /* AutoCAD reserves a block of 64K marker ids for custom use. The range from INT_MIN thu INT_MIN+65535
  829. Callers of setSelectionMarker should not use this range except for the values below.
  830. The value of 0 has special meaning and indicates no selection marker.
  831. */
  832. #define AcGiSelectionMarkerACADReserveStart (-2147483647 - 1) // INT_MIN without using limits.h
  833. #define AcGiSelectionMarkerACADReserveEnd (AcGiSelectionMarkerACADReserveStart + 65535)
  834. #define AcGiSelectionMarkerACADSelectionPreviewOff (AcGiSelectionMarkerACADReserveStart + 1) // turn off selection preview display
  835. #define AcGiSelectionMarkerACADSelectionPreviewOn (AcGiSelectionMarkerACADReserveStart + 2) // turn on selection preview display
  836. class AcGiSubEntityTraits: public AcRxObject
  837. //
  838. // This class applies attributes to subsequently drawn AcGi geometry
  839. // primitives.
  840. //
  841. {
  842. public:
  843. ACRX_DECLARE_MEMBERS(AcGiSubEntityTraits);
  844. enum DrawFlags
  845. {
  846. kNoDrawFlags = 0,
  847. kDrawBackfaces = 1,
  848. kDrawHatchGroup = 2,
  849. kDrawFrontfacesOnly = 4,
  850. kDrawGradientFill = 8,
  851. kDrawSolidFill = 16,
  852. kDrawNoLineWeight = 32,
  853. kDrawNoOptimization = 64,
  854. kDrawUseAcGiEntityForDgnLineType = 128, // For Autodesk Internal Use Only
  855. kDrawFillTextBoundaryStart = 256,
  856. kDrawFillTextBoundaryEnd = 512,
  857. kDrawFillSelectionWindow = 1024
  858. };
  859. enum ShadowFlags
  860. {
  861. kShadowsCastAndReceive = 0x00,
  862. kShadowsDoesNotCast = 0x01,
  863. kShadowsDoesNotReceive = 0x02,
  864. kShadowsIgnore = kShadowsDoesNotCast | kShadowsDoesNotReceive,
  865. };
  866. enum SelectionFlags
  867. {
  868. kNoSelectionFlags = 0x00,
  869. kSelectionIgnore = 0x01
  870. };
  871. // Set properties of drawn objects.
  872. //
  873. virtual void setColor (const Adesk::UInt16 color) = 0;
  874. virtual void setTrueColor (const AcCmEntityColor& color) = 0;
  875. virtual void setLayer (const AcDbObjectId layerId) = 0;
  876. virtual void setLineType (const AcDbObjectId linetypeId) = 0;
  877. virtual void setSelectionMarker (const Adesk::LongPtr markerId) = 0;
  878. virtual void setFillType (const AcGiFillType) = 0;
  879. virtual void setLineWeight (const AcDb::LineWeight lw) = 0;
  880. virtual void setLineTypeScale (double dScale = 1.0) = 0;
  881. virtual void setThickness (double dThickness) = 0;
  882. virtual void setVisualStyle (const AcDbObjectId visualStyleId);
  883. virtual void setPlotStyleName (AcDb::PlotStyleNameType /*type*/,
  884. const AcDbObjectId & /*id*/ = AcDbObjectId::kNull) { }
  885. virtual void setMaterial (const AcDbObjectId materialId);
  886. virtual void setMapper (const AcGiMapper * mapper);
  887. virtual void setSectionable (bool bSectionable);
  888. virtual Acad::ErrorStatus setDrawFlags (Adesk::UInt32 flags);
  889. virtual Acad::ErrorStatus setShadowFlags (ShadowFlags flags);
  890. virtual void setSelectionGeom (bool bSelectionflag);
  891. virtual void setTransparency (const AcCmTransparency &transparency);
  892. virtual void setFill (const AcGiFill* pFill);
  893. // Return current settings.
  894. //
  895. virtual Adesk::UInt16 color (void) const = 0;
  896. virtual AcCmEntityColor trueColor (void) const = 0;
  897. virtual AcDbObjectId layerId (void) const = 0;
  898. virtual AcDbObjectId lineTypeId (void) const = 0;
  899. virtual AcGiFillType fillType (void) const = 0;
  900. virtual AcDb::LineWeight lineWeight (void) const = 0;
  901. virtual double lineTypeScale (void) const = 0;
  902. virtual double thickness (void) const = 0;
  903. virtual AcDbObjectId visualStyle (void) const;
  904. virtual AcDb::PlotStyleNameType getPlotStyleNameId (AcDbObjectId & /*idResult*/) const
  905. { return AcDb::kPlotStyleNameByLayer; }
  906. virtual AcDbObjectId materialId (void) const;
  907. virtual const AcGiMapper * mapper (void) const;
  908. virtual bool sectionable (void) const;
  909. virtual Adesk::UInt32 drawFlags (void) const;
  910. virtual ShadowFlags shadowFlags (void) const;
  911. virtual bool selectionGeom (void) const;
  912. virtual AcCmTransparency transparency (void) const;
  913. virtual const AcGiFill* fill (void) const;
  914. virtual void pushMarkerOverride(bool /*flag*/, const Adesk::LongPtr /*markerId*/) { }
  915. virtual void popMarkerOverride(void) { }
  916. virtual void clearMarkerOverride(void) { }
  917. };
  918. inline void
  919. AcGiSubEntityTraits::setMaterial(const AcDbObjectId /*materialId*/)
  920. {
  921. }
  922. inline AcDbObjectId
  923. AcGiSubEntityTraits::materialId(void) const
  924. {
  925. return AcDbObjectId::kNull;
  926. }
  927. inline
  928. void AcGiSubEntityTraits::setMapper(const AcGiMapper * /*mapper*/)
  929. {
  930. }
  931. inline const AcGiMapper *
  932. AcGiSubEntityTraits::mapper(void) const
  933. {
  934. return NULL;
  935. }
  936. inline void
  937. AcGiSubEntityTraits::setVisualStyle(AcDbObjectId /*visualStyleId*/)
  938. {
  939. }
  940. inline AcDbObjectId
  941. AcGiSubEntityTraits::visualStyle(void) const
  942. {
  943. return AcDbObjectId::kNull;
  944. }
  945. inline void
  946. AcGiSubEntityTraits::setSectionable(bool /*bSectionable*/)
  947. {
  948. }
  949. inline bool
  950. AcGiSubEntityTraits::sectionable(void) const
  951. {
  952. return false;
  953. }
  954. inline Acad::ErrorStatus
  955. AcGiSubEntityTraits::setDrawFlags(Adesk::UInt32 /*flags*/)
  956. {
  957. return Acad::eNotImplementedYet;
  958. }
  959. inline Adesk::UInt32
  960. AcGiSubEntityTraits::drawFlags(void) const
  961. {
  962. return 0;
  963. }
  964. inline Acad::ErrorStatus
  965. AcGiSubEntityTraits::setShadowFlags(ShadowFlags /*flags*/)
  966. {
  967. return Acad::eNotImplementedYet;
  968. }
  969. inline AcGiSubEntityTraits::ShadowFlags
  970. AcGiSubEntityTraits::shadowFlags(void) const
  971. {
  972. return kShadowsCastAndReceive;
  973. }
  974. inline void
  975. AcGiSubEntityTraits::setSelectionGeom(bool)
  976. {
  977. }
  978. inline bool
  979. AcGiSubEntityTraits::selectionGeom(void) const
  980. {
  981. return false;
  982. }
  983. inline void
  984. AcGiSubEntityTraits::setTransparency(const AcCmTransparency&)
  985. {
  986. }
  987. inline AcCmTransparency
  988. AcGiSubEntityTraits::transparency(void) const
  989. {
  990. return AcCmTransparency(); // empty object
  991. }
  992. inline void AcGiSubEntityTraits::setFill(const AcGiFill * /*pFill*/)
  993. {
  994. }
  995. inline const AcGiFill *AcGiSubEntityTraits::fill(void) const
  996. {
  997. return nullptr;
  998. }
  999. class AcGiDrawableTraits : public AcGiSubEntityTraits
  1000. //
  1001. // This class applies attributes to all AcGi geometry primitives
  1002. // for this drawable. This class is available to a drawable only during
  1003. // the setAttributes() call.
  1004. //
  1005. {
  1006. public:
  1007. ACRX_DECLARE_MEMBERS(AcGiDrawableTraits);
  1008. enum HighlightProperty
  1009. {
  1010. kVertexRolloverHighlightSize,
  1011. };
  1012. // Rather than using individual calls to the settings it is more efficient
  1013. // to make this single call for an entity.
  1014. //
  1015. virtual void setupForEntity (AcDbEntity *pEntity);
  1016. // Drawables that emit light can add one or more to the model. A unique
  1017. // object id must be used for each light, though an object may pass
  1018. // in its own object id.
  1019. // This implementation ignores light information, so derived classes
  1020. // must override this method in order to collect and use the illumination.
  1021. //
  1022. virtual void addLight (const AcDbObjectId& lightId);
  1023. virtual void setLinePattern (const AcGiLineType linePattern);
  1024. virtual AcGiLineType linePattern (void) const;
  1025. virtual Acad::ErrorStatus setSelectionFlags (const SelectionFlags flags);
  1026. virtual SelectionFlags selectionFlags (void) const;
  1027. virtual Acad::ErrorStatus setHighlightProperty (HighlightProperty property,
  1028. AcGiVariant& value);
  1029. virtual AcGiVariant highlightProperty (HighlightProperty property) const;
  1030. virtual AcGiContext *context (void) const { return nullptr; }
  1031. protected:
  1032. friend class AcDbImpLayerTableRecord;
  1033. enum LayerFlags {
  1034. kNone = 0x00,
  1035. kOff = 0x01,
  1036. kFrozen = 0x02,
  1037. kZero = 0x04,
  1038. kLocked = 0x08
  1039. };
  1040. virtual void setLayerFlags (Adesk::UInt8 /*flags*/) { }
  1041. };
  1042. // Default implementation does nothing with the illumination data.
  1043. //
  1044. inline void
  1045. AcGiDrawableTraits::addLight(const AcDbObjectId& /*lightId*/)
  1046. {
  1047. }
  1048. inline void
  1049. AcGiDrawableTraits::setLinePattern (const AcGiLineType /*linePattern*/)
  1050. {
  1051. }
  1052. inline AcGiLineType
  1053. AcGiDrawableTraits::linePattern (void) const
  1054. {
  1055. return kLineTypeSolid;
  1056. }
  1057. inline Acad::ErrorStatus
  1058. AcGiDrawableTraits::setSelectionFlags (const SelectionFlags /*flags*/)
  1059. {
  1060. return Acad::eOk;
  1061. }
  1062. inline AcGiSubEntityTraits::SelectionFlags
  1063. AcGiDrawableTraits::selectionFlags (void) const
  1064. {
  1065. return kNoSelectionFlags;
  1066. }
  1067. inline Acad::ErrorStatus
  1068. AcGiDrawableTraits::setHighlightProperty(HighlightProperty /*property*/,
  1069. AcGiVariant& /*value*/)
  1070. {
  1071. return Acad::eOk;
  1072. }
  1073. inline AcGiVariant
  1074. AcGiDrawableTraits::highlightProperty(HighlightProperty /*property*/) const
  1075. {
  1076. return AcGiVariant();
  1077. }
  1078. class AcGiNonEntityTraits : public AcGiDrawableTraits
  1079. //
  1080. // This class implements empty AcGiDrawableTraits and AcGiSubEntityTraits
  1081. // interfaces, to allow non-entity drawables such as materials to elaborate
  1082. // their unique properties through AcGiDrawableTraits
  1083. //
  1084. {
  1085. public:
  1086. ACRX_DECLARE_MEMBERS(AcGiNonEntityTraits);
  1087. // AcGiDrawableTraits interface
  1088. virtual void setupForEntity (AcDbEntity* pEntity);
  1089. virtual void addLight(const AcDbObjectId& id);
  1090. // AcGiSubEntityTraits interface
  1091. virtual void setColor (const Adesk::UInt16 color);
  1092. virtual Adesk::UInt16 color (void) const;
  1093. virtual void setTrueColor (const AcCmEntityColor& color);
  1094. virtual AcCmEntityColor trueColor (void) const;
  1095. virtual void setLayer (const AcDbObjectId layerId);
  1096. virtual AcDbObjectId layerId (void) const;
  1097. virtual void setLineType (const AcDbObjectId linetypeId);
  1098. virtual AcDbObjectId lineTypeId (void) const;
  1099. virtual void setSelectionMarker (const Adesk::LongPtr markerId);
  1100. virtual void setFillType (const AcGiFillType fillType);
  1101. virtual AcGiFillType fillType (void) const;
  1102. virtual void setLineWeight (const AcDb::LineWeight lw);
  1103. virtual AcDb::LineWeight lineWeight (void) const;
  1104. virtual void setThickness (double thickness);
  1105. virtual double thickness (void) const;
  1106. virtual void setLineTypeScale (double dScale);
  1107. virtual double lineTypeScale (void) const;
  1108. virtual void setMaterial (const AcDbObjectId matId);
  1109. virtual AcDbObjectId materialId (void) const;
  1110. virtual void setSelectionGeom (bool bSelectionflag);
  1111. virtual bool selectionGeom ( void ) const;
  1112. virtual void setTransparency (const AcCmTransparency& transparency);
  1113. virtual AcCmTransparency transparency (void) const;
  1114. };
  1115. inline void
  1116. AcGiNonEntityTraits::setupForEntity (AcDbEntity* /*pEntity*/)
  1117. {
  1118. assert(false);
  1119. }
  1120. inline void
  1121. AcGiNonEntityTraits::addLight(const AcDbObjectId& /*id*/)
  1122. {
  1123. assert(false);
  1124. }
  1125. inline void
  1126. AcGiNonEntityTraits::setColor (const Adesk::UInt16 /*color*/)
  1127. {
  1128. assert(false);
  1129. }
  1130. inline Adesk::UInt16
  1131. AcGiNonEntityTraits::color (void) const
  1132. {
  1133. assert(false);
  1134. return 0;
  1135. }
  1136. inline void
  1137. AcGiNonEntityTraits::setTrueColor (const AcCmEntityColor& /*color*/)
  1138. {
  1139. assert(false);
  1140. }
  1141. inline AcCmEntityColor
  1142. AcGiNonEntityTraits::trueColor (void) const
  1143. {
  1144. assert(false);
  1145. return AcCmEntityColor();
  1146. }
  1147. inline void
  1148. AcGiNonEntityTraits::setLayer (const AcDbObjectId /*layerId*/)
  1149. {
  1150. assert(false);
  1151. }
  1152. inline AcDbObjectId
  1153. AcGiNonEntityTraits::layerId (void) const
  1154. {
  1155. assert(false);
  1156. return AcDbObjectId::kNull;
  1157. }
  1158. inline void
  1159. AcGiNonEntityTraits::setLineType (const AcDbObjectId /*linetypeId*/)
  1160. {
  1161. assert(false);
  1162. }
  1163. inline AcDbObjectId AcGiNonEntityTraits::lineTypeId (void) const
  1164. {
  1165. assert(false);
  1166. return AcDbObjectId::kNull;
  1167. }
  1168. inline void
  1169. AcGiNonEntityTraits::setMaterial(const AcDbObjectId /*matId*/)
  1170. {
  1171. assert(false);
  1172. }
  1173. inline AcDbObjectId AcGiNonEntityTraits::materialId (void) const
  1174. {
  1175. assert(false);
  1176. return AcDbObjectId::kNull;
  1177. }
  1178. inline void
  1179. AcGiNonEntityTraits::setSelectionMarker (const Adesk::LongPtr /*markerId*/)
  1180. {
  1181. assert(false);
  1182. }
  1183. inline void
  1184. AcGiNonEntityTraits::setFillType (const AcGiFillType /*fillType*/)
  1185. {
  1186. assert(false);
  1187. }
  1188. inline AcGiFillType
  1189. AcGiNonEntityTraits::fillType (void) const
  1190. {
  1191. assert(false);
  1192. return kAcGiFillAlways;
  1193. }
  1194. inline void
  1195. AcGiNonEntityTraits::setLineWeight (const AcDb::LineWeight /*lw*/)
  1196. {
  1197. assert(false);
  1198. }
  1199. inline AcDb::LineWeight
  1200. AcGiNonEntityTraits::lineWeight (void) const
  1201. {
  1202. assert(false);
  1203. return AcDb::kLnWt000;
  1204. }
  1205. inline void
  1206. AcGiNonEntityTraits::setThickness (double /*thickness*/)
  1207. {
  1208. assert(false);
  1209. }
  1210. inline double
  1211. AcGiNonEntityTraits::thickness (void) const
  1212. {
  1213. assert(false);
  1214. return 0.0;
  1215. }
  1216. inline void
  1217. AcGiNonEntityTraits::setLineTypeScale (double /*dScale*/)
  1218. {
  1219. assert(false);
  1220. }
  1221. inline double
  1222. AcGiNonEntityTraits::lineTypeScale (void) const
  1223. {
  1224. assert(false);
  1225. return 0.0;
  1226. }
  1227. inline void
  1228. AcGiNonEntityTraits::setSelectionGeom ( bool )
  1229. {
  1230. assert(false);
  1231. }
  1232. inline bool
  1233. AcGiNonEntityTraits::selectionGeom ( void ) const
  1234. {
  1235. assert(false);
  1236. return false;
  1237. }
  1238. inline void
  1239. AcGiNonEntityTraits::setTransparency (const AcCmTransparency& )
  1240. {
  1241. assert(false);
  1242. }
  1243. inline AcCmTransparency
  1244. AcGiNonEntityTraits::transparency (void) const
  1245. {
  1246. assert(false);
  1247. return AcCmTransparency();
  1248. }
  1249. #ifndef _WINDEF_
  1250. struct HDC__ ;
  1251. typedef struct HDC__ * HDC;
  1252. #endif
  1253. class AcGiGdiDrawObject: public AcRxObject
  1254. {
  1255. public:
  1256. ACRX_DECLARE_MEMBERS(AcGiGdiDrawObject);
  1257. virtual Adesk::Boolean draw(HDC hDC, int x, int y, int w, int h) = 0;
  1258. virtual int width() const = 0;
  1259. virtual int height() const = 0;
  1260. virtual void addRef() = 0;
  1261. virtual void delRef() = 0;
  1262. };
  1263. class AcGiPolyline
  1264. {
  1265. public:
  1266. AcGiPolyline ()
  1267. : m_nbPoints (0)
  1268. , m_pVertexList (NULL)
  1269. , m_pNormal (NULL)
  1270. , m_lBaseSubEntMarker(-1)
  1271. , m_linetypeGen (kEndToEnd)
  1272. , m_pSubEntMarkerList(NULL)
  1273. , m_pArcSegmentFlags(NULL)
  1274. { }
  1275. AcGiPolyline ( Adesk::UInt32 nbPoints,
  1276. AcGePoint3d* pVertexList,
  1277. AcGeVector3d* pNormal = NULL,
  1278. Adesk::LongPtr lBaseSubEntMarker = -1)
  1279. : m_nbPoints (nbPoints)
  1280. , m_pVertexList (pVertexList)
  1281. , m_pNormal (pNormal)
  1282. , m_lBaseSubEntMarker(lBaseSubEntMarker)
  1283. , m_linetypeGen (kEndToEnd)
  1284. , m_pSubEntMarkerList(NULL)
  1285. , m_pArcSegmentFlags(NULL)
  1286. { }
  1287. enum LinetypeGeneration { kPerSegment, kEndToEnd };
  1288. Adesk::UInt32 points() const;
  1289. const AcGePoint3d* vertexList() const;
  1290. const AcGeVector3d* normal() const;
  1291. LinetypeGeneration linetypeGen() const;
  1292. Adesk::LongPtr baseSubEntMarker() const;
  1293. const Adesk::LongPtr* subEntMarkerList() const;
  1294. const bool* arcSegmentFlags() const;
  1295. void setVertexList(Adesk::UInt32 nbPoints,
  1296. const AcGePoint3d* pVertexList);
  1297. void setNormal(const AcGeVector3d* pNormal);
  1298. void setLinetypeGen(LinetypeGeneration ltgen);
  1299. void setBaseSubEntMarker(Adesk::LongPtr lBaseSubEntMarker);
  1300. void setSubEntMarkerList(const Adesk::LongPtr* pSubEntMarkerList);
  1301. void setArcSegmentFlags(const bool *pArcSegmentFlags);
  1302. private:
  1303. Adesk::UInt32 m_nbPoints;
  1304. const AcGePoint3d* m_pVertexList;
  1305. const AcGeVector3d* m_pNormal;
  1306. LinetypeGeneration m_linetypeGen;
  1307. Adesk::LongPtr m_lBaseSubEntMarker;
  1308. const Adesk::LongPtr* m_pSubEntMarkerList;
  1309. const bool* m_pArcSegmentFlags;
  1310. };
  1311. inline Adesk::UInt32 AcGiPolyline::points() const
  1312. {
  1313. return m_nbPoints;
  1314. }
  1315. inline const AcGePoint3d* AcGiPolyline::vertexList() const
  1316. {
  1317. return m_pVertexList;
  1318. }
  1319. inline const AcGeVector3d* AcGiPolyline::normal() const
  1320. {
  1321. return m_pNormal;
  1322. }
  1323. inline Adesk::LongPtr AcGiPolyline::baseSubEntMarker() const
  1324. {
  1325. return m_lBaseSubEntMarker;
  1326. }
  1327. inline AcGiPolyline::LinetypeGeneration AcGiPolyline::linetypeGen() const
  1328. {
  1329. return m_linetypeGen;
  1330. }
  1331. inline const Adesk::LongPtr* AcGiPolyline::subEntMarkerList() const
  1332. {
  1333. return m_pSubEntMarkerList;
  1334. }
  1335. inline const bool* AcGiPolyline::arcSegmentFlags() const
  1336. {
  1337. return m_pArcSegmentFlags;
  1338. }
  1339. inline void AcGiPolyline::setVertexList(
  1340. Adesk::UInt32 nbPoints,
  1341. const AcGePoint3d* pVertexList)
  1342. {
  1343. m_nbPoints = nbPoints;
  1344. m_pVertexList = pVertexList;
  1345. }
  1346. inline void AcGiPolyline::setNormal(const AcGeVector3d* pNormal)
  1347. {
  1348. m_pNormal = pNormal;
  1349. }
  1350. inline void AcGiPolyline::setBaseSubEntMarker(Adesk::LongPtr lBaseSubEntMarker)
  1351. {
  1352. m_lBaseSubEntMarker = lBaseSubEntMarker;
  1353. }
  1354. inline void AcGiPolyline::setLinetypeGen(AcGiPolyline::LinetypeGeneration ltgen)
  1355. {
  1356. m_linetypeGen = ltgen;
  1357. }
  1358. inline void AcGiPolyline::setSubEntMarkerList(const Adesk::LongPtr* pSubEntMarkerList)
  1359. {
  1360. m_pSubEntMarkerList = pSubEntMarkerList;
  1361. }
  1362. inline void AcGiPolyline::setArcSegmentFlags(const bool* pArcSegmentFlags)
  1363. {
  1364. m_pArcSegmentFlags = pArcSegmentFlags;
  1365. }
  1366. typedef enum {
  1367. kAcGiWorldPosition,
  1368. kAcGiViewportPosition,
  1369. kAcGiScreenPosition,
  1370. kAcGiScreenLocalOriginPosition,
  1371. kAcGiWorldWithScreenOffsetPosition
  1372. } AcGiPositionTransformBehavior;
  1373. typedef enum {
  1374. kAcGiWorldScale,
  1375. kAcGiViewportScale,
  1376. kAcGiScreenScale,
  1377. kAcGiViewportLocalOriginScale,
  1378. kAcGiScreenLocalOriginScale
  1379. } AcGiScaleTransformBehavior;
  1380. typedef enum {
  1381. kAcGiWorldOrientation,
  1382. kAcGiScreenOrientation,
  1383. kAcGiZAxisOrientation
  1384. } AcGiOrientationTransformBehavior;
  1385. class AcGiGeometry: public AcRxObject
  1386. //
  1387. // The base class for geometry toolkits
  1388. //
  1389. {
  1390. public:
  1391. ACRX_DECLARE_MEMBERS(AcGiGeometry);
  1392. enum TransparencyMode
  1393. {
  1394. kTransparencyOff, // pixel alpha ignored, all pixels are opaque
  1395. kTransparency1Bit, // pixel alpha determines transparency on/off,
  1396. // with 0 to 254 completely transparent and 255 completely opaque
  1397. kTransparency8Bit, // pixel alpha determines transparency level,
  1398. // from 0 (completely transparent) to 255 (completely opaque)
  1399. };
  1400. // Coordinate transformations.
  1401. //
  1402. virtual void getModelToWorldTransform(AcGeMatrix3d&) const = 0;
  1403. virtual void getWorldToModelTransform(AcGeMatrix3d&) const = 0;
  1404. virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal) = 0;// Uses arbitrary Axis algorythm
  1405. virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat) = 0;
  1406. virtual Adesk::Boolean popModelTransform() = 0;
  1407. virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset) = 0;
  1408. virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset) = 0;
  1409. virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents) = 0;
  1410. virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents) = 0;
  1411. virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior) = 0;
  1412. // For drawing various primitives.
  1413. //
  1414. virtual Adesk::Boolean circle(const AcGePoint3d& center,
  1415. const double radius,
  1416. const AcGeVector3d& normal) const = 0;
  1417. virtual Adesk::Boolean circle(const AcGePoint3d&, const AcGePoint3d&,
  1418. const AcGePoint3d&) const = 0;
  1419. virtual Adesk::Boolean circularArc(const AcGePoint3d& center,
  1420. const double radius,
  1421. const AcGeVector3d& normal,
  1422. const AcGeVector3d& startVector,
  1423. const double sweepAngle,
  1424. const AcGiArcType arcType = kAcGiArcSimple) const = 0;
  1425. virtual Adesk::Boolean circularArc(const AcGePoint3d& start,
  1426. const AcGePoint3d& point,
  1427. const AcGePoint3d& end,
  1428. const AcGiArcType arcType = kAcGiArcSimple) const = 0;
  1429. virtual Adesk::Boolean polyline(const Adesk::UInt32 nbPoints,
  1430. const AcGePoint3d* pVertexList,
  1431. const AcGeVector3d* pNormal = NULL,
  1432. Adesk::LongPtr lBaseSubEntMarker = -1) const = 0;
  1433. virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const = 0;
  1434. virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines,
  1435. const AcGiPolyline* pPolylines) const = 0;
  1436. virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints,
  1437. const AcGePoint3d* pVertexList) const = 0;
  1438. virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices,
  1439. const Adesk::UInt32* numPolygonPositions,
  1440. const AcGePoint3d* polygonPositions,
  1441. const Adesk::UInt32* numPolygonPoints,
  1442. const AcGePoint3d* polygonPoints,
  1443. const AcCmEntityColor* outlineColors = NULL,
  1444. const AcGiLineType* outlineTypes = NULL,
  1445. const AcCmEntityColor* fillColors = NULL,
  1446. const AcCmTransparency* fillOpacities = NULL) const = 0;
  1447. virtual Adesk::Boolean mesh(const Adesk::UInt32 rows,
  1448. const Adesk::UInt32 columns,
  1449. const AcGePoint3d* pVertexList,
  1450. const AcGiEdgeData* pEdgeData = NULL,
  1451. const AcGiFaceData* pFaceData = NULL,
  1452. const AcGiVertexData* pVertexData = NULL,
  1453. const bool bAutoGenerateNormals = true
  1454. ) const = 0;
  1455. virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex,
  1456. const AcGePoint3d* pVertexList,
  1457. const Adesk::UInt32 faceListSize,
  1458. const Adesk::Int32* pFaceList,
  1459. const AcGiEdgeData* pEdgeData = NULL,
  1460. const AcGiFaceData* pFaceData = NULL,
  1461. const AcGiVertexData* pVertexData = NULL,
  1462. const struct resbuf* pResBuf = NULL,
  1463. const bool bAutoGenerateNormals = true
  1464. ) const = 0;
  1465. virtual Adesk::Boolean text(const AcGePoint3d& position,
  1466. const AcGeVector3d& normal,
  1467. const AcGeVector3d& direction,
  1468. const double height,
  1469. const double width,
  1470. const double oblique,
  1471. const ACHAR* pMsg) const = 0;
  1472. virtual Adesk::Boolean text(const AcGePoint3d& position,
  1473. const AcGeVector3d& normal,
  1474. const AcGeVector3d& direction,
  1475. const ACHAR* pMsg,
  1476. const Adesk::Int32 length,
  1477. const Adesk::Boolean raw,
  1478. const AcGiTextStyle &pTextStyle
  1479. ) const = 0;
  1480. virtual Adesk::Boolean xline(const AcGePoint3d&,
  1481. const AcGePoint3d&) const = 0;
  1482. virtual Adesk::Boolean ray(const AcGePoint3d&,
  1483. const AcGePoint3d&) const = 0;
  1484. virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf,
  1485. Adesk::UInt32 fromIndex = 0,
  1486. Adesk::UInt32 numSegs = 0
  1487. ) const = 0;
  1488. virtual Adesk::Boolean draw(AcGiDrawable*) const = 0;
  1489. virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource,
  1490. const AcGePoint3d& position,
  1491. const AcGeVector3d& u, //orientation and magnitude of width
  1492. const AcGeVector3d& v, //orientation and magnitude of height
  1493. TransparencyMode transparencyMode = kTransparency8Bit
  1494. ) const = 0;
  1495. virtual Adesk::Boolean rowOfDots(int count,
  1496. const AcGePoint3d& start,
  1497. const AcGeVector3d& step
  1498. ) const = 0;
  1499. virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center,
  1500. const AcGeVector3d& normal,
  1501. double majorAxisLength,
  1502. double minorAxisLength,
  1503. double startDegreeInRads,
  1504. double endDegreeInRads,
  1505. double tiltDegreeInRads,
  1506. AcGiArcType arcType = kAcGiArcSimple
  1507. ) const = 0 ;
  1508. // If you push a clip boundary onto the stack you must pop it;
  1509. //
  1510. virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary) = 0;
  1511. virtual void popClipBoundary() = 0;
  1512. virtual Adesk::Boolean worldLine(const AcGePoint3d pnts[2]) {
  1513. AcGePoint3d polyPnts[2];
  1514. AcGeMatrix3d mat;
  1515. getWorldToModelTransform(mat);
  1516. polyPnts[0] = mat * pnts[0];
  1517. polyPnts[1] = mat * pnts[1];
  1518. return polyline(2, polyPnts);
  1519. };
  1520. // array of points
  1521. virtual Adesk::Boolean polypoint( const Adesk::UInt32 nbPoints,
  1522. const AcGePoint3d* pVertexList,
  1523. const AcGeVector3d* pNormal = NULL,
  1524. const Adesk::LongPtr *pSubEntMarkers = NULL ) const {
  1525. AcGePoint3d pline[2];
  1526. Adesk::Boolean retval = Adesk::kFalse;
  1527. for (Adesk::UInt32 i = 0; i < nbPoints; i++) {
  1528. pline[1] = pline[0] = pVertexList[i];
  1529. retval = polyline(2, pline, pNormal ? &pNormal[i] : NULL, pSubEntMarkers ? pSubEntMarkers[i] : -1);
  1530. if (retval)
  1531. return retval;
  1532. }
  1533. return retval;
  1534. };
  1535. virtual Adesk::Boolean ownerDraw(AcGiGdiDrawObject* /*pObject*/,
  1536. const AcGePoint3d& /*position*/,
  1537. const AcGeVector3d& /*u*/,
  1538. const AcGeVector3d& /*v*/
  1539. ) const { return Adesk::kTrue; };
  1540. virtual Adesk::Boolean edge(const AcArray<AcGeCurve2d*>& edges) const = 0;
  1541. };
  1542. class AcGiWorldGeometry: public AcGiGeometry
  1543. //
  1544. // This class contains the view independent, model coordinate,
  1545. // 3D geometry methods.
  1546. //
  1547. {
  1548. public:
  1549. ACRX_DECLARE_MEMBERS(AcGiWorldGeometry);
  1550. virtual void setExtents(AcGePoint3d *pNewExtents) const = 0;
  1551. // If this drawable is a block and has AcDbAttributes it must call
  1552. // this method exactly once before sending the attributes to
  1553. // draw(). Once this is called the object may draw only attributes
  1554. // and no more primitives
  1555. // The attributes must be the last objects rendered
  1556. //
  1557. virtual void startAttributesSegment() {};
  1558. };
  1559. class AcGiViewportGeometry: public AcGiGeometry
  1560. //
  1561. // This class contains the view dependent, model and drawing coordinate,
  1562. // 3D geometry methods.
  1563. //
  1564. {
  1565. public:
  1566. ACRX_DECLARE_MEMBERS(AcGiViewportGeometry);
  1567. virtual Adesk::Boolean polylineEye(const Adesk::UInt32 nbPoints,
  1568. const AcGePoint3d* pPoints) const = 0;
  1569. virtual Adesk::Boolean polygonEye(const Adesk::UInt32 nbPoints,
  1570. const AcGePoint3d* pPoints) const = 0;
  1571. virtual Adesk::Boolean polylineDc(const Adesk::UInt32 nbPoints,
  1572. const AcGePoint3d* pPoints) const = 0;
  1573. virtual Adesk::Boolean polygonDc(const Adesk::UInt32 nbPoints,
  1574. const AcGePoint3d* pPoints) const = 0;
  1575. enum ImageSource {
  1576. kFromDwg,
  1577. kFromOleObject,
  1578. kFromRender
  1579. };
  1580. virtual Adesk::Boolean rasterImageDc(
  1581. const AcGePoint3d& origin,
  1582. const AcGeVector3d& u,
  1583. const AcGeVector3d& v,
  1584. const AcGeMatrix2d& pixelToDc,
  1585. AcDbObjectId entityId,
  1586. AcGiImageOrg imageOrg,
  1587. Adesk::UInt32 imageWidth,
  1588. Adesk::UInt32 imageHeight,
  1589. Adesk::Int16 imageColorDepth,
  1590. Adesk::Boolean transparency,
  1591. ImageSource source,
  1592. const AcGeVector3d& unrotatedU,
  1593. const AcGiImageOrg origionalImageOrg,
  1594. const AcGeMatrix2d& unrotatedPixelToDc,
  1595. const Adesk::UInt32 unrotatedImageWidth,
  1596. const Adesk::UInt32 unrotatedImageHeight
  1597. ) const = 0;
  1598. virtual Adesk::Boolean ownerDrawDc(
  1599. Adesk::Int32 vpnumber,
  1600. Adesk::Int32 left,
  1601. Adesk::Int32 top,
  1602. Adesk::Int32 right,
  1603. Adesk::Int32 bottom,
  1604. const OwnerDraw* pOwnerDraw
  1605. ) const = 0;
  1606. virtual Adesk::Boolean ownerDraw3d(
  1607. AcGePoint3d& /*minBounds*/,
  1608. AcGePoint3d& /*maxBounds*/,
  1609. OwnerDraw3d* /*pOwnerDraw*/
  1610. ) const { return Adesk::kFalse; };
  1611. };
  1612. #pragma warning (pop) // disabled 4100 - unreferenced formal parameter
  1613. class ACDB_PORT AcGiEdgeData : public AcGiParameter
  1614. //
  1615. // This class contains arrays of edge attributes for meshes and shells.
  1616. //
  1617. // NOTE:
  1618. // Setting an 'improper' size array of color, layers, etc.
  1619. // will cause unpredictable or fatal results.
  1620. //
  1621. {
  1622. public:
  1623. ACRX_DECLARE_MEMBERS_READWRITE(AcGiEdgeData, AcGiImpEdgeData);
  1624. ~AcGiEdgeData();
  1625. AcGiEdgeData();
  1626. virtual void setColors(const short *colors);
  1627. virtual void setTrueColors(const AcCmEntityColor *colors);
  1628. virtual void setLayers(const AcDbObjectId *layers);
  1629. virtual void setLineTypes(const AcDbObjectId *linetypes);
  1630. virtual void setSelectionMarkers(const Adesk::LongPtr* pSelectionMarkers);
  1631. virtual void setVisibility(const Adesk::UInt8* pVisibility);
  1632. virtual short* colors() const;
  1633. virtual AcCmEntityColor* trueColors() const;
  1634. virtual AcDbObjectId* layerIds() const;
  1635. virtual AcDbObjectId* linetypeIds() const;
  1636. virtual Adesk::LongPtr* selectionMarkers() const;
  1637. virtual Adesk::UInt8* visibility() const;
  1638. };
  1639. class ACDB_PORT AcGiFaceData: public AcGiParameter
  1640. //
  1641. // This class contains arrays of face attributes for meshes and shells.
  1642. //
  1643. // NOTE:
  1644. // Setting an 'improper' size array of color, layers, etc.
  1645. // will cause unpredictable or fatal results.
  1646. //
  1647. {
  1648. public:
  1649. ACRX_DECLARE_MEMBERS_READWRITE(AcGiFaceData, AcGiImpFaceData);
  1650. ~AcGiFaceData();
  1651. AcGiFaceData();
  1652. virtual void setColors(const short *colors);
  1653. virtual void setTrueColors(const AcCmEntityColor *colors);
  1654. virtual void setLayers(const AcDbObjectId *layers);
  1655. virtual void setSelectionMarkers(const Adesk::LongPtr* pSelectionMarkers);
  1656. virtual void setNormals(const AcGeVector3d* pNormals);
  1657. virtual void setVisibility(const Adesk::UInt8* vis);
  1658. virtual void setMaterials(const AcDbObjectId * materials);
  1659. virtual void setMappers(const AcGiMapper * mappers);
  1660. virtual void setTransparency(const AcCmTransparency *transparency);
  1661. virtual short* colors() const;
  1662. virtual AcCmEntityColor* trueColors() const;
  1663. virtual AcDbObjectId* layerIds() const;
  1664. virtual Adesk::LongPtr* selectionMarkers() const;
  1665. virtual AcGeVector3d* normals() const;
  1666. virtual Adesk::UInt8* visibility() const;
  1667. virtual AcDbObjectId* materials() const;
  1668. virtual AcGiMapper* mappers() const;
  1669. virtual AcCmTransparency* transparency() const;
  1670. };
  1671. class ACDB_PORT AcGiVertexData: public AcGiParameter
  1672. //
  1673. // This class contains arrays of vertex attributes for meshes and shells.
  1674. //
  1675. // NOTE:
  1676. // Setting an 'improper' size array of color, layers, etc.
  1677. // will cause unpredictable or fatal results.
  1678. //
  1679. {
  1680. public:
  1681. enum MapChannel
  1682. {
  1683. kAllChannels,
  1684. kMapChannels
  1685. };
  1686. ACRX_DECLARE_MEMBERS_READWRITE(AcGiVertexData, AcGiImpVertexData);
  1687. ~AcGiVertexData();
  1688. AcGiVertexData();
  1689. virtual void setNormals(const AcGeVector3d* pNormals);
  1690. virtual AcGeVector3d* normals() const;
  1691. virtual void setOrientationFlag(const AcGiOrientationType oflag);
  1692. virtual AcGiOrientationType orientationFlag() const;
  1693. virtual void setTrueColors(const AcCmEntityColor *colors);
  1694. virtual AcCmEntityColor* trueColors() const;
  1695. virtual void setMappingCoords (MapChannel mapChannel, const AcGePoint3d* pCoords);
  1696. virtual AcGePoint3d* mappingCoords (MapChannel mapChannel) const;
  1697. };
  1698. class AcGiTextStyle: public AcGiParameter
  1699. //
  1700. // This class contains methods to create and modify a text
  1701. // style object
  1702. //
  1703. {
  1704. public:
  1705. ACRX_DECLARE_MEMBERS_READWRITE(AcGiTextStyle, AcGiImpTextStyle);
  1706. ~AcGiTextStyle();
  1707. AcGiTextStyle(AcDbDatabase* pDb = NULL);
  1708. AcGiTextStyle(
  1709. const ACHAR* fontName,
  1710. const ACHAR* bigFontName,
  1711. const double textSize,
  1712. const double xScale,
  1713. const double obliqueAngle,
  1714. const double trPercent,
  1715. const Adesk::Boolean isBackward,
  1716. const Adesk::Boolean isUpsideDown,
  1717. const Adesk::Boolean isVertical,
  1718. const Adesk::Boolean isOverlined,
  1719. const Adesk::Boolean isUnderlined,
  1720. const Adesk::Boolean isStrikethrough = false,
  1721. const ACHAR* styleName = NULL);
  1722. // Unicode: change from char to int, since in the implementation, the returned
  1723. // result is actually bitmask indicating some status result.
  1724. virtual int loadStyleRec(AcDbDatabase* pDb = NULL) const;
  1725. virtual void setTextSize(const double size);
  1726. virtual void setXScale(const double xScale);
  1727. virtual void setObliquingAngle(const double obliquingAngle);
  1728. virtual void setTrackingPercent(const double trPercent);
  1729. virtual void setBackward(const Adesk::Boolean isBackward);
  1730. virtual void setUpsideDown(const Adesk::Boolean isUpsideDown);
  1731. virtual void setVertical(const Adesk::Boolean isVertical);
  1732. virtual void setUnderlined(const Adesk::Boolean isUnderlined);
  1733. virtual void setOverlined(const Adesk::Boolean isOverlined);
  1734. virtual void setStrikethrough(const Adesk::Boolean isStrikethrough);
  1735. virtual void setFileName(const ACHAR * fontName);
  1736. virtual void setBigFontFileName(const ACHAR * bigFontFileName);
  1737. virtual double textSize() const;
  1738. virtual double xScale() const;
  1739. virtual double obliquingAngle() const;
  1740. virtual double trackingPercent() const;
  1741. virtual Adesk::Boolean isBackward() const;
  1742. virtual Adesk::Boolean isUpsideDown() const;
  1743. virtual Adesk::Boolean isVertical() const;
  1744. virtual Adesk::Boolean isUnderlined() const;
  1745. virtual Adesk::Boolean isOverlined() const;
  1746. virtual Adesk::Boolean isStrikethrough() const;
  1747. virtual const ACHAR * fileName() const;
  1748. virtual const ACHAR * bigFontFileName() const;
  1749. virtual AcGePoint2d extents(const ACHAR * pStr,
  1750. const Adesk::Boolean penups,
  1751. const int len,
  1752. const Adesk::Boolean raw,
  1753. AcGiWorldDraw *ctxt = NULL) const;
  1754. virtual const ACHAR * styleName() const;
  1755. virtual Acad::ErrorStatus setStyleName(const ACHAR *);
  1756. virtual Acad::ErrorStatus setFont(const ACHAR * pTypeface,
  1757. Adesk::Boolean bold,
  1758. Adesk::Boolean italic,
  1759. int charset, int pitchAndFamily);
  1760. // Unicode: change pTypeface to AcString?
  1761. virtual Acad::ErrorStatus font(ACHAR *& pTypeface, Adesk::Boolean& bold,
  1762. Adesk::Boolean& italic, int& charset, int& pitchAndFamily) const;
  1763. virtual Acad::ErrorStatus extentsBox( const ACHAR * pStr,
  1764. const Adesk::Boolean penups,
  1765. const int len,
  1766. const Adesk::Boolean raw,
  1767. AcGePoint2d &extMin,
  1768. AcGePoint2d &extMax,
  1769. AcGiWorldDraw *ctxt = NULL) const;
  1770. virtual void setTrackKerning(double trackPercent) const;
  1771. virtual bool preLoaded() const;
  1772. virtual void setPreLoaded(bool);
  1773. };
  1774. class ACDB_PORT AcGiFill : public AcRxObject
  1775. {
  1776. public:
  1777. ACRX_DECLARE_MEMBERS(AcGiFill);
  1778. AcGiFill();
  1779. AcGiFill(const AcGiFill&);
  1780. virtual ~AcGiFill();
  1781. double deviation() const;
  1782. void setDeviation(double dev);
  1783. private:
  1784. AcGiImpFill *mpImp;
  1785. };
  1786. class ACDB_PORT AcGiHatchPatternDefinition
  1787. {
  1788. public:
  1789. AcGiHatchPatternDefinition();
  1790. AcGiHatchPatternDefinition(const AcGiHatchPatternDefinition &def);
  1791. AcGiHatchPatternDefinition(double angle,
  1792. double baseX,
  1793. double baseY,
  1794. double offsetX,
  1795. double offsetY,
  1796. const AcGeDoubleArray& dashList);
  1797. ~AcGiHatchPatternDefinition();
  1798. double angle() const;
  1799. double baseX() const;
  1800. double baseY() const;
  1801. double offsetX() const;
  1802. double offsetY() const;
  1803. const AcGeDoubleArray& dashList() const;
  1804. AcGiHatchPatternDefinition & operator = (const AcGiHatchPatternDefinition &def);
  1805. private:
  1806. AcGiImpHatchPatternDefinition * mpImp;
  1807. };
  1808. class ACDB_PORT AcGiHatchPattern : public AcGiFill
  1809. {
  1810. public:
  1811. ACRX_DECLARE_MEMBERS(AcGiHatchPattern);
  1812. AcGiHatchPattern(const AcArray<AcGiHatchPatternDefinition>& );
  1813. AcGiHatchPattern(const AcGiHatchPattern&);
  1814. virtual ~AcGiHatchPattern();
  1815. const AcArray<AcGiHatchPatternDefinition>& patternLines () const;
  1816. private:
  1817. AcGiImpHatchPattern *mpImp;
  1818. };
  1819. class ACDB_PORT AcGiGradientFill : public AcGiFill
  1820. {
  1821. public:
  1822. enum GradientType
  1823. {
  1824. kLinear,
  1825. kCylinder,
  1826. kInvCylinder,
  1827. kSpherical,
  1828. kHemispherical,
  1829. kCurved,
  1830. kInvSpherical,
  1831. kInvHemispherical,
  1832. kInvCurved
  1833. };
  1834. ACRX_DECLARE_MEMBERS(AcGiGradientFill);
  1835. AcGiGradientFill(double gradientAngle,
  1836. double gradientShift,
  1837. bool bAdjustAspect,
  1838. AcArray<AcCmColor>& gradientColors,
  1839. AcGiGradientFill::GradientType type);
  1840. AcGiGradientFill(const AcGiGradientFill&);
  1841. virtual ~AcGiGradientFill();
  1842. void setGradientAngle(double val);
  1843. double gradientAngle() const;
  1844. void setGradientShift(double val);
  1845. double gradientShift() const;
  1846. void setIsAdjustAspect(bool val);
  1847. bool isAdjustAspect() const;
  1848. void setGradientColors(const AcArray<AcCmColor>& val);
  1849. const AcArray<AcCmColor>& gradientColors() const;
  1850. void setGradientType(AcGiGradientFill::GradientType type);
  1851. const AcGiGradientFill::GradientType gradientType() const;
  1852. private:
  1853. AcGiImpGradientFill *mpImp;
  1854. };
  1855. #pragma pack (pop)
  1856. #endif