dbMultiModesGrip.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. //
  13. // dbMultiModesGrip.h - public header file for AcDbMultiModesGripPE API
  14. //
  15. #ifndef _DBMULTIMODESGRIP_H
  16. #define _DBMULTIMODESGRIP_H
  17. #include "acdb.h"
  18. #include "dbmain.h"
  19. #pragma pack (push, 8)
  20. ////////////////////////////////////////////////////////////////////////
  21. // class AcDbMultiModesGripPE (abstract)
  22. ////////////////////////////////////////////////////////////////////////
  23. /// <summary>
  24. /// The protocol extension interface that specifies how, when implemented and
  25. /// registered as a protocol extension to an AcDbEntity derived class, to
  26. /// communicate with the grip editing complex for information on what alternatives
  27. /// it can provide to stretching grip points. These alternatives are represented
  28. /// as an array of modes (of type AcDbMultiModesGripPE::GripMode). The grip editing
  29. /// complex will be responsible for querying all available modes, interacting with user
  30. /// to set the current mode or switching between modes, and either proceeding with dragging
  31. /// a grip (if the current mode's action type is kDragOn), or calling moveGripPointsAt
  32. /// once (if the current mode's action type is kImmediate), or executing a command
  33. /// (if the current mode's action type is kCommand). Clients who implement
  34. /// AcDbMultiModesGripPE are responsible to maintain the "current" mode and provide
  35. /// runtime behavior for any given mode.
  36. /// </summary>
  37. ///
  38. /// <remarks>
  39. /// On hovering a warm grip, the AutoCAD grip complex querys the grip'ed
  40. /// object for this protocol exetension and retrieve available modes. The
  41. /// current mode can be set during warm grip stage through a multi-mode
  42. /// UI or during hot grip editing, through Ctrl-cycling or context menu
  43. /// selection.
  44. ///
  45. /// Client who implements this PE for a given object type (AcDbEntity derived)
  46. /// should either own the object type so it can directly make its moveGripPointsAt
  47. /// mode-aware, or should overrule the object's runtime moveGripPointsAt behavior
  48. /// through AcDbGripOverrule.
  49. /// </remarks>
  50. ///
  51. class ADESK_NO_VTABLE AcDbMultiModesGripPE : public AcRxObject
  52. {
  53. public:
  54. ACRX_DECLARE_MEMBERS(AcDbMultiModesGripPE);
  55. /// <summary>
  56. /// The type of a grip.
  57. /// </summary>
  58. enum GripType
  59. {
  60. /// <summary>
  61. /// The primary grip. Always shown if host's GRIPS variable is not 0;
  62. /// </summary>
  63. kPrimary,
  64. /// <summary>
  65. /// The secondary grip. Only shown when host's GRIPS variable is 2;
  66. /// </summary>
  67. kSecondary
  68. };
  69. /// <summary>
  70. /// The numerical identifier of a grip mode.
  71. /// </summary>
  72. enum GripModeIdentifier
  73. {
  74. /// <summary>
  75. /// Default
  76. /// </summary>
  77. kNone = 0,
  78. /// <summary>
  79. /// Stretch at the grip point
  80. /// </summary>
  81. kMove,
  82. /// <summary>
  83. /// The start of custom mode types.
  84. /// All custom mode types should be larger than this value.
  85. /// </summary>
  86. kCustomStart = 100,
  87. };
  88. /// <summary>
  89. /// The type of actions the grip editing complex takes when a mode
  90. /// is becoming current.
  91. /// </summary>
  92. enum GripActionType
  93. {
  94. /// <summary>
  95. /// Instructs the grip editor to proceed with dragging. The mode
  96. /// specific behavior is determined by object's moveGripPointsAt
  97. /// current mode awareness.
  98. /// </summary>
  99. kDragOn = 0,
  100. /// <summary>
  101. /// Instructs the grip editor to call moveGripPointsAt once and
  102. /// end dragging sequence.
  103. /// </summary>
  104. kImmediate,
  105. /// <summary>
  106. /// External command, specified as GripMode::CommandString, is called.
  107. /// </summary>
  108. kCommand,
  109. };
  110. /// <summary>
  111. /// The type of canvas cursor can be specified for each mode.
  112. /// </summary>
  113. enum GripCursorType
  114. {
  115. /// <summary>
  116. /// No cursor change, using default.
  117. /// </summary>
  118. kcNone = 0,
  119. /// <summary>
  120. /// Default cursor combined with a plus sign.
  121. /// </summary>
  122. kcCrosshairPlus,
  123. /// <summary>
  124. /// Default cursor combined with a minus sign.
  125. /// </summary>
  126. kcCrosshairMinus,
  127. /// <summary>
  128. /// Default cursor combined with a curve sign.
  129. /// </summary>
  130. kcCrosshairCurve,
  131. /// <summary>
  132. /// Default cursor combined with a straight line sign.
  133. /// </summary>
  134. kcCrosshairLine,
  135. /// <summary>
  136. /// Default cursor combined with an angle sign. For future use.
  137. /// </summary>
  138. kcCrosshairAngle,
  139. };
  140. /// <summary>
  141. /// The type that contains all information to present a single mode.
  142. /// </summary>
  143. struct GripMode
  144. {
  145. /// <summary>
  146. /// Default constructor
  147. /// </summary>
  148. GripMode();
  149. /// <summary>
  150. /// The unique identifier among the collection of modes this PE implements.
  151. /// </summary>
  152. unsigned int Mode;
  153. /// <summary>
  154. /// The display string of this mode in various UI elements (including haver menu and object context menu).
  155. /// </summary>
  156. AcString DisplayString;
  157. /// <summary>
  158. /// The string tool tip of this mode. (For future use.)
  159. /// </summary>
  160. AcString ToolTip;
  161. /// <summary>
  162. /// The command line version of display string for this mode.
  163. /// </summary>
  164. AcString CLIDisplayString;
  165. /// <summary>
  166. /// The command line prompt string when this mode is switched as current.
  167. /// </summary>
  168. AcString CLIPromptString;
  169. /// <summary>
  170. /// The command line keyword list associated to CLIPromptString.
  171. /// </summary>
  172. AcString CLIKeywordList;
  173. /// <summary>
  174. /// The type of cursor this mode uses.
  175. /// </summary>
  176. GripCursorType CursorType;
  177. /// <summary>
  178. /// The action type of this mode uses.
  179. /// </summary>
  180. GripActionType ActionType;
  181. /// <summary>
  182. /// Optional. If the action type is kCommand, the command used for this mode.
  183. /// </summary>
  184. AcString CommandString;
  185. };
  186. /// <summary>
  187. /// Queries an object, on a given grip point, for the available modes it provides. It also
  188. /// returns the mode that is current.
  189. /// </summary>
  190. /// <param name="pThis">
  191. /// The AcDbEntity whose modes are requested. The object needs to be open
  192. /// at least for read.
  193. /// </param>
  194. /// <param name="pGripData"> The grip whose modes are requested. </param>
  195. /// <param name="modes"> The returned array of availabe modes. </param>
  196. /// <param name="curMode"> The returned identifier of current mode. </param>
  197. /// <returns> true if successful. </returns>
  198. ///
  199. virtual bool getGripModes(AcDbEntity* pThis,
  200. AcDbGripData* pGripData,
  201. AcArray<GripMode>& modes,
  202. unsigned int& curMode) const = 0;
  203. /// <summary>
  204. /// Gets the current mode identifier.
  205. /// </summary>
  206. /// <param name="pThis"> The AcDbEntity whose current mode id is requested. </param>
  207. /// <param name="pGripData"> The grip whose mode id is requested. </param>
  208. /// <returns> The returned identifier of current mode. </returns>
  209. ///
  210. virtual unsigned int mode(AcDbEntity* pThis, AcDbGripData* pGripData) const = 0;
  211. /// <summary>
  212. /// Gets the current mode.
  213. /// </summary>
  214. /// <param name="pThis"> The AcDbEntity whose current mode is requested. </param>
  215. /// <param name="pGripData"> The grip whose mode is requested. </param>
  216. /// <returns> The mode object which is current. </returns>
  217. ///
  218. virtual GripMode modeEx(AcDbEntity* pThis, AcDbGripData* pGripData) const = 0;
  219. /// <summary>
  220. /// Sets the current mode.
  221. /// </summary>
  222. /// <param name="pThis"> The AcDbEntity whose current mode is to be set current. </param>
  223. /// <param name="pGripData"> The grip whose current mode is to be set current. </param>
  224. /// <param name="newMode"> The numerical identifier for the new current mode. </param>
  225. /// <returns> true of successful. </returns>
  226. ///
  227. virtual bool setMode(AcDbEntity* pThis, AcDbGripData* pGripData, unsigned int newMode) = 0;
  228. /// <summary>
  229. /// Gets the grip type of a given grip.
  230. /// </summary>
  231. /// <param name="pThis"> The AcDbEntity whose grip type is requested. </param>
  232. /// <param name="pGripData"> The grip whose grip type is requested. </param>
  233. /// <returns> The grip type of the grip. </returns>
  234. ///
  235. virtual GripType gripType(AcDbEntity* pThis, AcDbGripData* pGripData) const = 0;
  236. /// <summary>
  237. /// resets current mode to default (up to each concrate class to say what is the default).
  238. /// </summary>
  239. /// <param name="pThis"> The AcDbEntity whose current mode is reset to default. </param>
  240. virtual void reset(AcDbEntity* pThis) = 0;
  241. };
  242. inline AcDbMultiModesGripPE::GripMode::GripMode()
  243. : Mode(AcDbMultiModesGripPE::kMove)
  244. , ActionType(kDragOn)
  245. {
  246. }
  247. #pragma pack (pop)
  248. #endif // _DBMULTIMODESGRIP_H