dbSun.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. //----- AcDbSun.h : Declaration of the AcDbSun class
  13. //-----------------------------------------------------------------------------
  14. // DESCRIPTION:
  15. //
  16. // This API extends AcDb to support creation of the Sun object
  17. // AcDbObject
  18. // AcDbSun
  19. #pragma once
  20. #include "dbmain.h"
  21. #pragma warning( disable: 4275 4251 )
  22. #ifdef SCENEOE
  23. #define DLLIMPEXP __declspec(dllexport)
  24. #else
  25. //----- Note: we don't use __declspec(dllimport) here, because of the
  26. //----- "local vtable" problem with msvc. If you use __declspec(dllimport),
  27. //----- then, when a client dll does a new on the class, the object's
  28. //----- vtable pointer points to a vtable allocated in that client
  29. //----- dll. If the client dll then passes the object to another dll,
  30. //----- and the client dll is then unloaded, the vtable becomes invalid
  31. //----- and any virtual calls on the object will access invalid memory.
  32. //-----
  33. //----- By not using __declspec(dllimport), we guarantee that the
  34. //----- vtable is allocated in the server dll during the ctor and the
  35. //----- client dll does not overwrite the vtable pointer after calling
  36. //----- the ctor. And, since we expect the server dll to remain in
  37. //----- memory indefinitely, there is no problem with vtables unexpectedly
  38. //----- going away.
  39. #define DLLIMPEXP
  40. #endif
  41. #include "AcGiLightTraits.h"
  42. #include "rxboiler.h"
  43. #include "dbLight.h"
  44. //forward declaration for the imp class
  45. class AcDbImpSun;
  46. /// <summary>
  47. /// Container for all properties relating to a sun object.
  48. /// A sun exists as a hard-owned child of an AcDbViewportTableRecord
  49. /// or an AcDbViewport object. It is created when a sun-related operation
  50. /// is first performed (for example, changing a property on the Sun Properties
  51. /// ESW or a sun-related parameter in the 3DUI dashboard). It is set and
  52. /// accessed by the methods setSun() and sunId() defined on both viewport classes.
  53. /// The properties defined in this class correspond to fields on the Sun property
  54. /// palette, but may also be set and queried by other clients.
  55. /// </summary>
  56. class LIGHTDLLIMPEXP AcDbSun : public AcDbObject
  57. {
  58. public:
  59. ACRX_DECLARE_MEMBERS(AcDbSun);
  60. private:
  61. static Adesk::UInt32 kCurrentVersionNumber;
  62. public:
  63. /// <summary>
  64. /// Constructor.
  65. /// </summary>
  66. AcDbSun();
  67. /// <summary>
  68. /// Destructor.
  69. /// </summary>
  70. ~AcDbSun();
  71. // AcGiDrawable methods
  72. virtual AcGiDrawable* drawable();
  73. virtual DrawableType drawableType() const { return AcGiDrawable::kDistantLight; }
  74. // AcDbObject methods
  75. virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler *pFiler) const;
  76. virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler *pFiler);
  77. virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler *pFiler) const;
  78. virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler *pFiler);
  79. virtual Acad::ErrorStatus decomposeForSave(
  80. AcDb::AcDbDwgVersion ver,
  81. AcDbObject*& replaceObj,
  82. AcDbObjectId& replaceId,
  83. Adesk::Boolean& exchangeXData);
  84. /// <summary>
  85. /// Gets the Sun's on/off state.
  86. /// </summary>
  87. ///
  88. /// <returns>
  89. /// True if the Sun status is on.
  90. /// </returns>
  91. virtual bool isOn() const;
  92. /// <summary>
  93. /// Sets the Sun on/off status.
  94. /// </summary>
  95. ///
  96. /// <param name="value">
  97. /// If true, the Sun status is "turned on"; it adds light to the model.
  98. /// </param>
  99. ///
  100. /// <returns>
  101. /// Acad::eOk if the operation is successful.
  102. /// </returns>
  103. virtual Acad::ErrorStatus setOn(bool value);
  104. /// <summary>
  105. /// Gets the Sun light intensity.
  106. /// </summary>
  107. ///
  108. /// <returns>
  109. /// The intensity of the Sun's light.
  110. /// </returns>
  111. virtual double intensity() const;
  112. /// <summary>
  113. /// Sets the Sun's light intensity.
  114. /// </summary>
  115. ///
  116. /// <param name="intensity">
  117. /// The intensity of the Sun light. A value of 0.0 effectively
  118. /// turns the Sun light off.
  119. /// </param>
  120. ///
  121. /// <returns>
  122. /// Acad::eOk if the operation is successful.
  123. /// </returns>
  124. virtual Acad::ErrorStatus setIntensity(double intensity);
  125. /// <summary>
  126. /// Gets the color of the Sun's light.
  127. /// </summary>
  128. ///
  129. /// <returns>
  130. /// The color of the Sun's light.
  131. /// </returns>
  132. virtual const AcCmColor& sunColor() const;
  133. /// <summary>
  134. /// Sets the color of the Sun's light.
  135. /// </summary>
  136. ///
  137. /// <param name="color">
  138. /// The color of the emitted light from the Sun object.
  139. /// </param>
  140. ///
  141. /// <returns>
  142. /// Acad::eOk if the operation is successful.
  143. /// </returns>
  144. virtual Acad::ErrorStatus setSunColor(const AcCmColor& color);
  145. /// <summary>
  146. /// Gets the shadow parameters: shadow type, map size, edge softness, and on/off state.
  147. /// </summary>
  148. ///
  149. /// <returns>
  150. /// A reference to a const AcGiShadowParameters object, containing shadow parameters
  151. /// such as shadow type, map size, edge softness, and on/off state.
  152. /// </returns>
  153. virtual const AcGiShadowParameters& shadowParameters() const;
  154. /// <summary>
  155. /// Sets the shadow parameters: shadow type, map size, edge softness, and on/off state.
  156. /// </summary>
  157. ///
  158. /// <param name="params">
  159. /// The shadow parameters contained in an instance of an AcGiShadowParameters object.
  160. /// </param>
  161. virtual void setShadowParameters(const AcGiShadowParameters& params);
  162. /// <summary>
  163. /// Sets the Date and Time for the Sun, which affects its position relative to the model.
  164. /// </summary>
  165. ///
  166. /// <param name="datetime">
  167. /// The date and time of the sun.
  168. /// </param>
  169. ///
  170. /// <returns>
  171. /// Acad::eOk if the operation is successful.
  172. /// </returns>
  173. ///
  174. /// <remarks>
  175. /// Other parameters that affect the position of the sun: latitude, longitude,
  176. /// north direction, and time zone.
  177. /// </remarks>
  178. virtual Acad::ErrorStatus setDateTime(const AcDbDate& datetime);
  179. /// <summary>
  180. /// Gets the Date and Time for the Sun, two of the factors affecting the position
  181. /// of the sun relative to the model.
  182. /// </summary>
  183. ///
  184. /// <returns>
  185. /// The date and the time of the sun.
  186. /// </returns>
  187. ///
  188. /// <remarks>
  189. /// Other parameters that affect the position of the sun: latitude, longitude,
  190. /// north direction, and time zone.
  191. /// </remarks>
  192. virtual const AcDbDate& dateTime() const;
  193. /// <summary>
  194. /// Turns on and off Daylight Saving Time. This affects the interpretation
  195. /// of the Sun Time parameter.
  196. /// </summary>
  197. ///
  198. /// <param name="value">
  199. /// True to turn on Daylight Saving time.
  200. /// </param>
  201. ///
  202. /// <returns>
  203. /// Acad::eOk if the operation is successful.
  204. /// </returns>
  205. virtual Acad::ErrorStatus setDayLightSavingsOn(bool value);
  206. /// <summary>
  207. /// Gets the Daylight Saving Time on/off status.
  208. /// </summary>
  209. ///
  210. /// <returns>
  211. /// True if Daylight Saving Time is On.
  212. /// </returns>
  213. virtual bool isDayLightSavingsOn() const;
  214. /// <summary>
  215. /// For internal use only.
  216. /// </summary>
  217. virtual Acad::ErrorStatus setAzimuth(double azimuth);
  218. /// <summary>
  219. /// For internal use only.
  220. /// </summary>
  221. virtual double azimuth() const;
  222. /// <summary>
  223. /// For internal use only.
  224. /// </summary>
  225. virtual Acad::ErrorStatus setAltitude(double altitude);
  226. /// <summary>
  227. /// For internal use only.
  228. /// </summary>
  229. virtual double altitude() const;
  230. /// <summary>
  231. /// Gets the direction (vector) of the sun's light rays.
  232. /// </summary>
  233. ///
  234. /// <returns>
  235. /// The direction vector of sunlight, from the Sun to the model.
  236. /// </returns>
  237. virtual const AcGeVector3d& sunDirection() const;
  238. /// <summary>
  239. /// For internal use only.
  240. /// </summary>
  241. virtual void setSunDirection(const AcGeVector3d& sundir);
  242. /// <summary>
  243. /// Sets the sky parameters: render sky, multiplier, haze, horizon height,
  244. /// horizon blur, ground color, night color, aerial perspective on/off,
  245. /// visibility
  246. /// </summary>
  247. ///
  248. /// <param name="params">
  249. /// Input sky parameters: render sky, multiplier, haze, horizon height,
  250. /// horizon blur, ground color, night color, aerial perspective on/off,
  251. /// visibility
  252. /// </param>
  253. ///
  254. /// <returns>
  255. /// Returns eOk on success. Returns an error if the sky parameter
  256. /// information could not be set, or if any of the values passed in are
  257. /// invalid.
  258. /// </returns>
  259. Acad::ErrorStatus setSkyParameters(const AcGiSkyParameters& params);
  260. /// <summary>
  261. /// Gets the sky parameters: render sky, multiplier, haze, horizon height,
  262. /// horizon blur, ground color, night color, aerial perspective on/off,
  263. /// visibility
  264. /// </summary>
  265. ///
  266. /// <param name="params">
  267. /// Output sky parameters: render sky, multiplier, haze, horizon height,
  268. /// horizon blur, ground color, night color, aerial perspective on/off,
  269. /// visibility
  270. /// </param>
  271. ///
  272. /// <returns>
  273. /// Returns eOk on success. Returns an error if the sky parameter
  274. /// information could not be retrieved.
  275. /// </returns>
  276. Acad::ErrorStatus skyParameters(AcGiSkyParameters& params) const;
  277. protected:
  278. // AcGiDrawable methods
  279. virtual Adesk::UInt32 subSetAttributes(AcGiDrawableTraits* pTraits);
  280. private:
  281. AcDbImpSun * mpAcDbImpSun;
  282. };