subselect.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // DESCRIPTION:
  13. //
  14. // Interface and classes that implements pickfirst based sub selection
  15. // and 'picking in space' for entities in a pickfirst set through
  16. // using a callback mechanism with the AcEdInputPointManager and
  17. // a specific kind of AcEdInputContextReactor.
  18. #pragma once
  19. #include "acedinpt.h"
  20. // Typedef mapping old name to new name
  21. typedef AcDbFullSubentPathArray AcSubentPathArray;
  22. class AcGiViewport;
  23. // This is the main class which contains all the implementation for
  24. // 'pick in space' hit testing and 'sub-entity-selection' based on
  25. // callbacks from the AcEdInputPointManager. This is a Filter class,
  26. // i.e. needs to be registered with the AcEdInputPointManager
  27. // through addSubSelectFilter(), and likewise removed by
  28. // removeSubSelectFilter() when the application is unloaded.
  29. //
  30. // For each type of entity that supports this kind of sub-selection
  31. // it is expected that they will derive a concrete SubSelect filter
  32. // from AcEdSSetSubSelectFilter, and implement the necessary methods
  33. // indicated below.
  34. //
  35. class AcEdSubSelectFilter
  36. {
  37. public:
  38. virtual ~AcEdSubSelectFilter() { }
  39. enum SubSelectStatus
  40. {
  41. kSubSelectionNone = 0, // No selection found
  42. kSubSelectionAugment, // Add to the pickfirst set
  43. kSubSelectionExclusive, // Remove other entities from the pickfirst set
  44. kSubSelectAll // Select the full entity
  45. };
  46. /**
  47. * Gets called by the AcEdInputPointManager instance when
  48. * the Filter is registered. This method is used to determine
  49. * which Filter to call back for doing 'pick in face' selection
  50. * for a candidate entity in the pickfirst set or ssget.
  51. *
  52. * In case of multiple filters registering themselves for the
  53. * same class, the first one wins.
  54. *
  55. * The internal tests use isKindOf(), i.e. derivation, to check
  56. * if a filter applies to a candidate entity or not.
  57. *
  58. * @param clsIds list of classes associated with the filter.
  59. *
  60. * @returns eOk if successful.
  61. */
  62. virtual Acad::ErrorStatus subSelectClassList(AcArray<AcRxClass*>& clsIds)
  63. { return Acad::eOk; }
  64. // The following three methods do the subselection and sub-highlight.
  65. /**
  66. * This method is used to ask the application to do the actual
  67. * hit test, testing for the point in an entity.
  68. *
  69. *
  70. * @param wvpt world pick point
  71. *
  72. * @param wvwdir world view direction (-z axis of view coord system)
  73. *
  74. * @param wvwxdir world x axis direction of view coordinate system
  75. *
  76. * @param wxaper aperture x rectangle side in world unit. Centered at
  77. * the pick point
  78. *
  79. * @param wyaper aperture y rectangle side in world unit. Centered at
  80. * the pick point
  81. *
  82. *
  83. * @param flags AcEdSSGetFlags for the current selection operation
  84. *
  85. * @param pEnt AcDbEntity that is to be tested.
  86. *
  87. * @returns true if point is in the entity.
  88. */
  89. virtual bool selectEntity(
  90. const AcGePoint3d& wvpt,
  91. const AcGeVector3d& wvwdir,
  92. const AcGeVector3d& wvwxdir,
  93. double wxaper,
  94. double wyaper,
  95. Adesk::Int32 flags,
  96. const AcGiViewport* pCurVp,
  97. AcDbEntity* pEnt) const
  98. { return false; }
  99. /**
  100. * If the above method, i.e. hitTestEntity() returns true,
  101. * then createSubSelect() will be invoked by the Input Point Manager,
  102. * requesting a list of sub-selections that will get highlighted.
  103. *
  104. * @param wpt1 corner1 of box in world coordinates
  105. *
  106. * @param wpt2 corner2 of box in world coordinates
  107. *
  108. * @param wvdir world view direction
  109. *
  110. * @param wvwxdir world Xaxis direction of view coordinate system
  111. *
  112. * @param wxaper aperture x rectangle side in world unit. Centered at
  113. * the pick point
  114. *
  115. * @param wyaper aperture y rectangle side in world unit. Centered at
  116. * the pick point
  117. *
  118. * @param seltype one of AcDb::kCrossing or AcDb::kWindow.
  119. *
  120. * @param bAugment if true, add to current subselection instead of
  121. * replacing it.
  122. *
  123. * @param bIsInPickfirst if true - the entity is already in the pickfirst
  124. * set. If false, the pickfirst logic will attempt
  125. * to subselect the entity directly if desired.
  126. *
  127. * @param bEvery True if all possible sub-entities should be returned
  128. *
  129. * @param pCurVP current viewport in which selection is occurring
  130. *
  131. * @param pEnt Entity to be sub-select tested against
  132. *
  133. * @param paths Result set of subentity paths.
  134. *
  135. * @result one of kSubSelectionNone, kSubSelectionAugment,
  136. * kSubSelectionExclusive. kSubSelectionExclusive
  137. * will remove any other selection in the pickfirst
  138. * set, while kSubSelectionAugment will not change
  139. * existing contents of the set.
  140. */
  141. virtual SubSelectStatus subSelectEntity(
  142. const AcGePoint3d& wpt1,
  143. const AcGePoint3d& wpt2,
  144. const AcGeVector3d& wvwdir,
  145. const AcGeVector3d& wvwxdir,
  146. double wxaper,
  147. double wyaper,
  148. AcDb::SelectType seltype,
  149. bool bAugment,
  150. bool bIsInPickfirstSet,
  151. bool bEvery,
  152. const AcGiViewport* pCurVP,
  153. AcDbEntity* pEnt,
  154. AcDbFullSubentPathArray& paths)
  155. { return kSubSelectionNone; }
  156. /**
  157. * If hitTestEntity() returns true then createSubSelect() will be invoked
  158. * by the Input Point Manager, requesting a list of sub-selections that
  159. * will get highlighted. This overload gets called after the preceding
  160. * signature if the preceding method returns kSubSelectNone.
  161. *
  162. * @param pResbuf result buffer chain describing the selection criteria
  163. * of the same form as returned by acedSSNameEx.
  164. *
  165. * @param bAugment if true, add to current subselection instead of
  166. * replacing it.
  167. *
  168. * @param bIsInPickfirst if true - the entity is already in the pickfirst
  169. * set. If false, the pickfirst logic will attempt
  170. * to subselect the entity directly if desired.
  171. *
  172. * @param bEvery if true return all possible sub-entities.
  173. *
  174. * @param pCurVP current viewport in which selection is occurring
  175. *
  176. * @param pEnt Entity to be sub-select tested against
  177. *
  178. * @param paths Result set of subentity paths.
  179. *
  180. * @result one of kSubSelectionNone, kSubSelectionAugment,
  181. * kSubSelectionExclusive. kSubSelectionExclusive
  182. * will remove any other selection in the pickfirst
  183. * set, while kSubSelectionAugment will not change
  184. * existing contents of the set.
  185. */
  186. virtual SubSelectStatus subSelectEntity(
  187. const resbuf* pResbuf,
  188. bool bAugment,
  189. bool bIsInPickfirstSet,
  190. bool bEvery,
  191. const AcGiViewport* pCurVP,
  192. AcDbEntity* pEnt,
  193. AcDbFullSubentPathArray& paths)
  194. { return kSubSelectionNone; }
  195. /**
  196. * Invoked to re-select, if necessary, based on the current entity
  197. * sub-selection state. Where the state is remembered is really upto
  198. * the Filter/Entity implementation.
  199. *
  200. * If the entity needs to have its sub-selection recomputed, this
  201. * method should modify paths to reflect the correct new subselection.
  202. * If the entity does not need to make any changes, paths will be left
  203. * alone.
  204. *
  205. * @param pEnt the entity whose subselection is being refreshed
  206. *
  207. * @param paths the current list of Full Subent paths that reflect the
  208. * current subselection state of the entity. This is both
  209. * and input and output argument. The entity can modify this
  210. * to reflect the true subentity paths for its current
  211. * subselection state. Else it can leave them alone.
  212. *
  213. * @returns true if the entity altered the paths argument. False if not
  214. */
  215. virtual bool reSubSelectEntity(AcDbEntity* pEnt,
  216. AcDbFullSubentPathArray& paths)
  217. { return false; }
  218. /**
  219. * In case the sub-selection is cancelled, the reactor is notified
  220. * by this method. Typical uses of this filter include tracking
  221. * sub selection state within the reactor. So this method says
  222. * to clear that state.
  223. *
  224. * @param id entity whose state is to be cancelled.
  225. *
  226. * @returns true if the entity was actually sub-selected.
  227. */
  228. virtual bool cancelSubSelect(AcDbEntity* pEnt)
  229. { return false; }
  230. /**
  231. * Similar method to cancelSubSelect, except - all entities
  232. * have been un-subselected, and the filter must take
  233. * appropriate action
  234. *
  235. * @returns true if an entity was actually sub-selected.
  236. */
  237. virtual bool cancelAllSubSelect()
  238. { return false; }
  239. /**
  240. * React to keyboard input - and take appropriate action,
  241. * if necessary. This is invoked only for the currently active filters.
  242. *
  243. * @param wMsg windows message, one of
  244. * WM_SYSKEYDOWN
  245. * WM_SYSKEYUP
  246. * WM_KEYDOWN
  247. * WM_KEYUP
  248. * WM_CHAR
  249. * etc.
  250. *
  251. * @param char character typed
  252. *
  253. * @param rptcnt repetition count
  254. *
  255. * @param flags windows flags (see OnKeyDown())
  256. *
  257. * @returns true if message was intercepted and no more processing
  258. * by other filters must happen. False if it is ok for the controlling
  259. * logic to invoke other filters' onKeyDown() message handling.
  260. */
  261. virtual bool onKey(Adesk::UInt32 wMsg, unsigned int nChar,
  262. unsigned int rptCnt, unsigned int flags)
  263. { return false; }
  264. /**
  265. * @returns true if the entity is subselected.
  266. */
  267. virtual bool isSubSelected(AcDbEntity* pEnt) const
  268. { return false; }
  269. };