PageRenderTime 63ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/indra/newview/llselectmgr.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 866 lines | 599 code | 140 blank | 127 comment | 27 complexity | 09e7fd96c5cdde594cbd6b688e6ea8ef MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llselectmgr.h
  3. * @brief A manager for selected objects and TEs.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLSELECTMGR_H
  27. #define LL_LLSELECTMGR_H
  28. #include "llcharacter.h"
  29. #include "lleditmenuhandler.h"
  30. #include "llundo.h"
  31. #include "lluuid.h"
  32. #include "llpointer.h"
  33. #include "llsafehandle.h"
  34. #include "llsaleinfo.h"
  35. #include "llcategory.h"
  36. #include "v3dmath.h"
  37. #include "llquaternion.h"
  38. #include "llcoord.h"
  39. #include "llframetimer.h"
  40. #include "llbbox.h"
  41. #include "llpermissions.h"
  42. #include "llcontrol.h"
  43. #include "llviewerobject.h" // LLObjectSelection::getSelectedTEValue template
  44. #include <deque>
  45. #include <boost/iterator/filter_iterator.hpp>
  46. #include <boost/signals2.hpp>
  47. class LLMessageSystem;
  48. class LLViewerTexture;
  49. class LLColor4;
  50. class LLVector3;
  51. class LLSelectNode;
  52. const S32 SELECT_ALL_TES = -1;
  53. const S32 SELECT_MAX_TES = 32;
  54. // Do something to all objects in the selection manager.
  55. // The BOOL return value can be used to indicate if all
  56. // objects are identical (gathering information) or if
  57. // the operation was successful.
  58. struct LLSelectedObjectFunctor
  59. {
  60. virtual ~LLSelectedObjectFunctor() {};
  61. virtual bool apply(LLViewerObject* object) = 0;
  62. };
  63. // Do something to all select nodes in the selection manager.
  64. // The BOOL return value can be used to indicate if all
  65. // objects are identical (gathering information) or if
  66. // the operation was successful.
  67. struct LLSelectedNodeFunctor
  68. {
  69. virtual ~LLSelectedNodeFunctor() {};
  70. virtual bool apply(LLSelectNode* node) = 0;
  71. };
  72. struct LLSelectedTEFunctor
  73. {
  74. virtual ~LLSelectedTEFunctor() {};
  75. virtual bool apply(LLViewerObject* object, S32 face) = 0;
  76. };
  77. template <typename T> struct LLSelectedTEGetFunctor
  78. {
  79. virtual ~LLSelectedTEGetFunctor() {};
  80. virtual T get(LLViewerObject* object, S32 te) = 0;
  81. };
  82. typedef enum e_send_type
  83. {
  84. SEND_ONLY_ROOTS,
  85. SEND_INDIVIDUALS,
  86. SEND_ROOTS_FIRST, // useful for serial undos on linked sets
  87. SEND_CHILDREN_FIRST // useful for serial transforms of linked sets
  88. } ESendType;
  89. typedef enum e_grid_mode
  90. {
  91. GRID_MODE_WORLD,
  92. GRID_MODE_LOCAL,
  93. GRID_MODE_REF_OBJECT
  94. } EGridMode;
  95. typedef enum e_action_type
  96. {
  97. SELECT_ACTION_TYPE_BEGIN,
  98. SELECT_ACTION_TYPE_PICK,
  99. SELECT_ACTION_TYPE_MOVE,
  100. SELECT_ACTION_TYPE_ROTATE,
  101. SELECT_ACTION_TYPE_SCALE,
  102. NUM_ACTION_TYPES
  103. }EActionType;
  104. typedef enum e_selection_type
  105. {
  106. SELECT_TYPE_WORLD,
  107. SELECT_TYPE_ATTACHMENT,
  108. SELECT_TYPE_HUD
  109. }ESelectType;
  110. // Contains information about a selected object, particularly which TEs are selected.
  111. class LLSelectNode
  112. {
  113. public:
  114. LLSelectNode(LLViewerObject* object, BOOL do_glow);
  115. LLSelectNode(const LLSelectNode& nodep);
  116. ~LLSelectNode();
  117. void selectAllTEs(BOOL b);
  118. void selectTE(S32 te_index, BOOL selected);
  119. BOOL isTESelected(S32 te_index);
  120. S32 getLastSelectedTE();
  121. S32 getTESelectMask() { return mTESelectMask; }
  122. void renderOneWireframe(const LLColor4& color);
  123. void renderOneSilhouette(const LLColor4 &color);
  124. void setTransient(BOOL transient) { mTransient = transient; }
  125. BOOL isTransient() { return mTransient; }
  126. LLViewerObject* getObject();
  127. void setObject(LLViewerObject* object);
  128. // *NOTE: invalidate stored textures and colors when # faces change
  129. void saveColors();
  130. void saveTextures(const uuid_vec_t& textures);
  131. void saveTextureScaleRatios();
  132. BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
  133. public:
  134. BOOL mIndividualSelection; // For root objects and objects individually selected
  135. BOOL mTransient;
  136. BOOL mValid; // is extra information valid?
  137. LLPermissions* mPermissions;
  138. LLSaleInfo mSaleInfo;
  139. LLAggregatePermissions mAggregatePerm;
  140. LLAggregatePermissions mAggregateTexturePerm;
  141. LLAggregatePermissions mAggregateTexturePermOwner;
  142. std::string mName;
  143. std::string mDescription;
  144. LLCategory mCategory;
  145. S16 mInventorySerial;
  146. LLVector3 mSavedPositionLocal; // for interactively modifying object position
  147. LLVector3 mLastPositionLocal;
  148. LLVector3d mSavedPositionGlobal; // for interactively modifying object position
  149. LLVector3 mSavedScale; // for interactively modifying object scale
  150. LLVector3 mLastScale;
  151. LLQuaternion mSavedRotation; // for interactively modifying object rotation
  152. LLQuaternion mLastRotation;
  153. BOOL mDuplicated;
  154. LLVector3d mDuplicatePos;
  155. LLQuaternion mDuplicateRot;
  156. LLUUID mItemID;
  157. LLUUID mFolderID;
  158. LLUUID mFromTaskID;
  159. std::string mTouchName;
  160. std::string mSitName;
  161. U64 mCreationDate;
  162. std::vector<LLColor4> mSavedColors;
  163. uuid_vec_t mSavedTextures;
  164. std::vector<LLVector3> mTextureScaleRatios;
  165. std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object
  166. std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object
  167. BOOL mSilhouetteExists; // need to generate silhouette?
  168. protected:
  169. LLPointer<LLViewerObject> mObject;
  170. S32 mTESelectMask;
  171. S32 mLastTESelected;
  172. };
  173. class LLObjectSelection : public LLRefCount
  174. {
  175. friend class LLSelectMgr;
  176. protected:
  177. ~LLObjectSelection();
  178. public:
  179. typedef std::list<LLSelectNode*> list_t;
  180. // Iterators
  181. struct is_non_null
  182. {
  183. bool operator()(LLSelectNode* node)
  184. {
  185. return (node->getObject() != NULL);
  186. }
  187. };
  188. typedef boost::filter_iterator<is_non_null, list_t::iterator > iterator;
  189. iterator begin() { return iterator(mList.begin(), mList.end()); }
  190. iterator end() { return iterator(mList.end(), mList.end()); }
  191. struct is_valid
  192. {
  193. bool operator()(LLSelectNode* node)
  194. {
  195. return (node->getObject() != NULL) && node->mValid;
  196. }
  197. };
  198. typedef boost::filter_iterator<is_valid, list_t::iterator > valid_iterator;
  199. valid_iterator valid_begin() { return valid_iterator(mList.begin(), mList.end()); }
  200. valid_iterator valid_end() { return valid_iterator(mList.end(), mList.end()); }
  201. struct is_root
  202. {
  203. bool operator()(LLSelectNode* node);
  204. };
  205. typedef boost::filter_iterator<is_root, list_t::iterator > root_iterator;
  206. root_iterator root_begin() { return root_iterator(mList.begin(), mList.end()); }
  207. root_iterator root_end() { return root_iterator(mList.end(), mList.end()); }
  208. struct is_valid_root
  209. {
  210. bool operator()(LLSelectNode* node);
  211. };
  212. typedef boost::filter_iterator<is_valid_root, list_t::iterator > valid_root_iterator;
  213. valid_root_iterator valid_root_begin() { return valid_root_iterator(mList.begin(), mList.end()); }
  214. valid_root_iterator valid_root_end() { return valid_root_iterator(mList.end(), mList.end()); }
  215. struct is_root_object
  216. {
  217. bool operator()(LLSelectNode* node);
  218. };
  219. typedef boost::filter_iterator<is_root_object, list_t::iterator > root_object_iterator;
  220. root_object_iterator root_object_begin() { return root_object_iterator(mList.begin(), mList.end()); }
  221. root_object_iterator root_object_end() { return root_object_iterator(mList.end(), mList.end()); }
  222. public:
  223. LLObjectSelection();
  224. void updateEffects();
  225. BOOL isEmpty() const;
  226. LLSelectNode* getFirstNode(LLSelectedNodeFunctor* func = NULL);
  227. LLSelectNode* getFirstRootNode(LLSelectedNodeFunctor* func = NULL, BOOL non_root_ok = FALSE);
  228. LLViewerObject* getFirstSelectedObject(LLSelectedNodeFunctor* func, BOOL get_parent = FALSE);
  229. LLViewerObject* getFirstObject();
  230. LLViewerObject* getFirstRootObject(BOOL non_root_ok = FALSE);
  231. LLSelectNode* getFirstMoveableNode(BOOL get_root_first = FALSE);
  232. LLViewerObject* getFirstEditableObject(BOOL get_parent = FALSE);
  233. LLViewerObject* getFirstCopyableObject(BOOL get_parent = FALSE);
  234. LLViewerObject* getFirstDeleteableObject();
  235. LLViewerObject* getFirstMoveableObject(BOOL get_parent = FALSE);
  236. /// Return the object that lead to this selection, possible a child
  237. LLViewerObject* getPrimaryObject() { return mPrimaryObject; }
  238. // iterate through texture entries
  239. template <typename T> bool getSelectedTEValue(LLSelectedTEGetFunctor<T>* func, T& res);
  240. template <typename T> bool isMultipleTEValue(LLSelectedTEGetFunctor<T>* func, const T& ignore_value);
  241. S32 getNumNodes();
  242. LLSelectNode* findNode(LLViewerObject* objectp);
  243. // count members
  244. S32 getObjectCount();
  245. F32 getSelectedObjectCost();
  246. F32 getSelectedLinksetCost();
  247. F32 getSelectedPhysicsCost();
  248. F32 getSelectedLinksetPhysicsCost();
  249. S32 getSelectedObjectRenderCost();
  250. F32 getSelectedObjectStreamingCost(S32* total_bytes = NULL, S32* visible_bytes = NULL);
  251. U32 getSelectedObjectTriangleCount(S32* vcount = NULL);
  252. S32 getTECount();
  253. S32 getRootObjectCount();
  254. BOOL isMultipleTESelected();
  255. BOOL contains(LLViewerObject* object);
  256. BOOL contains(LLViewerObject* object, S32 te);
  257. // returns TRUE is any node is currenly worn as an attachment
  258. BOOL isAttachment();
  259. // Apply functors to various subsets of the selected objects
  260. // If firstonly is FALSE, returns the AND of all apply() calls.
  261. // Else returns TRUE immediately if any apply() call succeeds (i.e. OR with early exit)
  262. bool applyToRootObjects(LLSelectedObjectFunctor* func, bool firstonly = false);
  263. bool applyToObjects(LLSelectedObjectFunctor* func);
  264. bool applyToTEs(LLSelectedTEFunctor* func, bool firstonly = false);
  265. bool applyToRootNodes(LLSelectedNodeFunctor* func, bool firstonly = false);
  266. bool applyToNodes(LLSelectedNodeFunctor* func, bool firstonly = false);
  267. ESelectType getSelectType() const { return mSelectType; }
  268. private:
  269. void addNode(LLSelectNode *nodep);
  270. void addNodeAtEnd(LLSelectNode *nodep);
  271. void moveNodeToFront(LLSelectNode *nodep);
  272. void removeNode(LLSelectNode *nodep);
  273. void deleteAllNodes();
  274. void cleanupNodes();
  275. private:
  276. list_t mList;
  277. const LLObjectSelection &operator=(const LLObjectSelection &);
  278. LLPointer<LLViewerObject> mPrimaryObject;
  279. std::map<LLPointer<LLViewerObject>, LLSelectNode*> mSelectNodeMap;
  280. ESelectType mSelectType;
  281. };
  282. typedef LLSafeHandle<LLObjectSelection> LLObjectSelectionHandle;
  283. // Build time optimization, generate this once in .cpp file
  284. #ifndef LLSELECTMGR_CPP
  285. extern template class LLSelectMgr* LLSingleton<class LLSelectMgr>::getInstance();
  286. #endif
  287. class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
  288. {
  289. public:
  290. static BOOL sRectSelectInclusive; // do we need to surround an object to pick it?
  291. static BOOL sRenderHiddenSelections; // do we show selection silhouettes that are occluded?
  292. static BOOL sRenderLightRadius; // do we show the radius of selected lights?
  293. static F32 sHighlightThickness;
  294. static F32 sHighlightUScale;
  295. static F32 sHighlightVScale;
  296. static F32 sHighlightAlpha;
  297. static F32 sHighlightAlphaTest;
  298. static F32 sHighlightUAnim;
  299. static F32 sHighlightVAnim;
  300. static LLColor4 sSilhouetteParentColor;
  301. static LLColor4 sSilhouetteChildColor;
  302. static LLColor4 sHighlightParentColor;
  303. static LLColor4 sHighlightChildColor;
  304. static LLColor4 sHighlightInspectColor;
  305. static LLColor4 sContextSilhouetteColor;
  306. LLCachedControl<bool> mHideSelectedObjects;
  307. LLCachedControl<bool> mRenderHighlightSelections;
  308. LLCachedControl<bool> mAllowSelectAvatar;
  309. LLCachedControl<bool> mDebugSelectMgr;
  310. public:
  311. LLSelectMgr();
  312. ~LLSelectMgr();
  313. static void cleanupGlobals();
  314. // LLEditMenuHandler interface
  315. virtual BOOL canUndo() const;
  316. virtual void undo();
  317. virtual BOOL canRedo() const;
  318. virtual void redo();
  319. virtual BOOL canDoDelete() const;
  320. virtual void doDelete();
  321. virtual void deselect();
  322. virtual BOOL canDeselect() const;
  323. virtual void duplicate();
  324. virtual BOOL canDuplicate() const;
  325. void clearSelections();
  326. void update();
  327. void updateEffects(); // Update HUD effects
  328. void overrideObjectUpdates();
  329. // Returns the previous value of mForceSelection
  330. BOOL setForceSelection(BOOL force);
  331. ////////////////////////////////////////////////////////////////
  332. // Selection methods
  333. ////////////////////////////////////////////////////////////////
  334. ////////////////////////////////////////////////////////////////
  335. // Add
  336. ////////////////////////////////////////////////////////////////
  337. // This method is meant to select an object, and then select all
  338. // of the ancestors and descendants. This should be the normal behavior.
  339. //
  340. // *NOTE: You must hold on to the object selection handle, otherwise
  341. // the objects will be automatically deselected in 1 frame.
  342. LLObjectSelectionHandle selectObjectAndFamily(LLViewerObject* object, BOOL add_to_end = FALSE);
  343. // For when you want just a child object.
  344. LLObjectSelectionHandle selectObjectOnly(LLViewerObject* object, S32 face = SELECT_ALL_TES);
  345. // Same as above, but takes a list of objects. Used by rectangle select.
  346. LLObjectSelectionHandle selectObjectAndFamily(const std::vector<LLViewerObject*>& object_list, BOOL send_to_sim = TRUE);
  347. // converts all objects currently highlighted to a selection, and returns it
  348. LLObjectSelectionHandle selectHighlightedObjects();
  349. LLObjectSelectionHandle setHoverObject(LLViewerObject *objectp, S32 face = -1);
  350. LLSelectNode *getHoverNode();
  351. LLSelectNode *getPrimaryHoverNode();
  352. void highlightObjectOnly(LLViewerObject *objectp);
  353. void highlightObjectAndFamily(LLViewerObject *objectp);
  354. void highlightObjectAndFamily(const std::vector<LLViewerObject*>& list);
  355. ////////////////////////////////////////////////////////////////
  356. // Remove
  357. ////////////////////////////////////////////////////////////////
  358. void deselectObjectOnly(LLViewerObject* object, BOOL send_to_sim = TRUE);
  359. void deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_sim = TRUE, BOOL include_entire_object = FALSE);
  360. // Send deselect messages to simulator, then clear the list
  361. void deselectAll();
  362. void deselectAllForStandingUp();
  363. // deselect only if nothing else currently referencing the selection
  364. void deselectUnused();
  365. // Deselect if the selection center is too far away from the agent.
  366. void deselectAllIfTooFar();
  367. // Removes all highlighted objects from current selection
  368. void deselectHighlightedObjects();
  369. void unhighlightObjectOnly(LLViewerObject *objectp);
  370. void unhighlightObjectAndFamily(LLViewerObject *objectp);
  371. void unhighlightAll();
  372. BOOL removeObjectFromSelections(const LLUUID &id);
  373. ////////////////////////////////////////////////////////////////
  374. // Selection editing
  375. ////////////////////////////////////////////////////////////////
  376. bool linkObjects();
  377. bool unlinkObjects();
  378. bool enableLinkObjects();
  379. bool enableUnlinkObjects();
  380. ////////////////////////////////////////////////////////////////
  381. // Selection accessors
  382. ////////////////////////////////////////////////////////////////
  383. LLObjectSelectionHandle getSelection() { return mSelectedObjects; }
  384. // right now this just renders the selection with root/child colors instead of a single color
  385. LLObjectSelectionHandle getEditSelection() { convertTransient(); return mSelectedObjects; }
  386. LLObjectSelectionHandle getHighlightedObjects() { return mHighlightedObjects; }
  387. ////////////////////////////////////////////////////////////////
  388. // Grid manipulation
  389. ////////////////////////////////////////////////////////////////
  390. void addGridObject(LLViewerObject* objectp);
  391. void clearGridObjects();
  392. void setGridMode(EGridMode mode);
  393. EGridMode getGridMode() { return mGridMode; }
  394. void getGrid(LLVector3& origin, LLQuaternion& rotation, LLVector3 &scale);
  395. BOOL getTEMode() { return mTEMode; }
  396. void setTEMode(BOOL b) { mTEMode = b; }
  397. BOOL shouldShowSelection() { return mShowSelection; }
  398. LLBBox getBBoxOfSelection() const;
  399. LLBBox getSavedBBoxOfSelection() const { return mSavedSelectionBBox; }
  400. void dump();
  401. void cleanup();
  402. void updateSilhouettes();
  403. void renderSilhouettes(BOOL for_hud);
  404. void enableSilhouette(BOOL enable) { mRenderSilhouettes = enable; }
  405. ////////////////////////////////////////////////////////////////
  406. // Utility functions that operate on the current selection
  407. ////////////////////////////////////////////////////////////////
  408. void saveSelectedObjectTransform(EActionType action_type);
  409. void saveSelectedObjectColors();
  410. void saveSelectedObjectTextures();
  411. void selectionUpdatePhysics(BOOL use_physics);
  412. void selectionUpdateTemporary(BOOL is_temporary);
  413. void selectionUpdatePhantom(BOOL is_ghost);
  414. void selectionUpdateCastShadows(BOOL cast_shadows);
  415. void selectionDump();
  416. BOOL selectionAllPCode(LLPCode code); // all objects have this PCode
  417. BOOL selectionGetClickAction(U8 *out_action);
  418. bool selectionGetIncludeInSearch(bool* include_in_search_out); // true if all selected objects have same
  419. BOOL selectionGetGlow(F32 *glow);
  420. void selectionSetPhysicsType(U8 type);
  421. void selectionSetGravity(F32 gravity);
  422. void selectionSetFriction(F32 friction);
  423. void selectionSetDensity(F32 density);
  424. void selectionSetRestitution(F32 restitution);
  425. void selectionSetMaterial(U8 material);
  426. void selectionSetImage(const LLUUID& imageid); // could be item or asset id
  427. void selectionSetColor(const LLColor4 &color);
  428. void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels
  429. void selectionSetAlphaOnly(const F32 alpha); // Set only the alpha channel
  430. void selectionRevertColors();
  431. BOOL selectionRevertTextures();
  432. void selectionSetBumpmap( U8 bumpmap );
  433. void selectionSetTexGen( U8 texgen );
  434. void selectionSetShiny( U8 shiny );
  435. void selectionSetFullbright( U8 fullbright );
  436. void selectionSetMedia( U8 media_type, const LLSD &media_data );
  437. void selectionSetClickAction(U8 action);
  438. void selectionSetIncludeInSearch(bool include_in_search);
  439. void selectionSetGlow(const F32 glow);
  440. void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE);
  441. void selectionSetObjectName(const std::string& name);
  442. void selectionSetObjectDescription(const std::string& desc);
  443. void selectionSetObjectCategory(const LLCategory& category);
  444. void selectionSetObjectSaleInfo(const LLSaleInfo& sale_info);
  445. void selectionTexScaleAutofit(F32 repeats_per_meter);
  446. void adjustTexturesByScale(BOOL send_to_sim, BOOL stretch);
  447. void selectionResetRotation(); // sets rotation quat to identity
  448. void selectionRotateAroundZ(F32 degrees);
  449. bool selectionMove(const LLVector3& displ, F32 rx, F32 ry, F32 rz,
  450. U32 update_type);
  451. void sendSelectionMove();
  452. void sendGodlikeRequest(const std::string& request, const std::string& parameter);
  453. // will make sure all selected object meet current criteria, or deselect them otherwise
  454. void validateSelection();
  455. // returns TRUE if it is possible to select this object
  456. BOOL canSelectObject(LLViewerObject* object);
  457. // Returns TRUE if the viewer has information on all selected objects
  458. BOOL selectGetAllRootsValid();
  459. BOOL selectGetAllValid();
  460. BOOL selectGetAllValidAndObjectsFound();
  461. // returns TRUE if you can modify all selected objects.
  462. BOOL selectGetRootsModify();
  463. BOOL selectGetModify();
  464. // returns TRUE if selected objects can be transferred.
  465. BOOL selectGetRootsTransfer();
  466. // returns TRUE if selected objects can be copied.
  467. BOOL selectGetRootsCopy();
  468. BOOL selectGetCreator(LLUUID& id, std::string& name); // TRUE if all have same creator, returns id
  469. BOOL selectGetOwner(LLUUID& id, std::string& name); // TRUE if all objects have same owner, returns id
  470. BOOL selectGetLastOwner(LLUUID& id, std::string& name); // TRUE if all objects have same owner, returns id
  471. // returns TRUE if all are the same. id is stuffed with
  472. // the value found if available.
  473. BOOL selectGetGroup(LLUUID& id);
  474. BOOL selectGetPerm( U8 which_perm, U32* mask_on, U32* mask_off); // TRUE if all have data, returns two masks, each indicating which bits are all on and all off
  475. BOOL selectIsGroupOwned(); // TRUE if all root objects have valid data and are group owned.
  476. // returns TRUE if all the nodes are valid. Accumulates
  477. // permissions in the parameter.
  478. BOOL selectGetPermissions(LLPermissions& perm);
  479. // Get a bunch of useful sale information for the object(s) selected.
  480. // "_mixed" is true if not all objects have the same setting.
  481. void selectGetAggregateSaleInfo(U32 &num_for_sale,
  482. BOOL &is_for_sale_mixed,
  483. BOOL &is_sale_price_mixed,
  484. S32 &total_sale_price,
  485. S32 &individual_sale_price);
  486. // returns TRUE if all nodes are valid.
  487. BOOL selectGetCategory(LLCategory& category);
  488. // returns TRUE if all nodes are valid. method also stores an
  489. // accumulated sale info.
  490. BOOL selectGetSaleInfo(LLSaleInfo& sale_info);
  491. // returns TRUE if all nodes are valid. fills passed in object
  492. // with the aggregate permissions of the selection.
  493. BOOL selectGetAggregatePermissions(LLAggregatePermissions& ag_perm);
  494. // returns TRUE if all nodes are valid. fills passed in object
  495. // with the aggregate permissions for texture inventory items of the selection.
  496. BOOL selectGetAggregateTexturePermissions(LLAggregatePermissions& ag_perm);
  497. LLPermissions* findObjectPermissions(const LLViewerObject* object);
  498. void selectDelete(); // Delete on simulator
  499. void selectForceDelete(); // just delete, no into trash
  500. void selectDuplicate(const LLVector3& offset, BOOL select_copy); // Duplicate on simulator
  501. void repeatDuplicate();
  502. void selectDuplicateOnRay(const LLVector3 &ray_start_region,
  503. const LLVector3 &ray_end_region,
  504. BOOL bypass_raycast,
  505. BOOL ray_end_is_intersection,
  506. const LLUUID &ray_target_id,
  507. BOOL copy_centers,
  508. BOOL copy_rotates,
  509. BOOL select_copy);
  510. void sendMultipleUpdate(U32 type); // Position, rotation, scale all in one
  511. void sendOwner(const LLUUID& owner_id, const LLUUID& group_id, BOOL override = FALSE);
  512. void sendGroup(const LLUUID& group_id);
  513. // Category ID is the UUID of the folder you want to contain the purchase.
  514. // *NOTE: sale_info check doesn't work for multiple object buy,
  515. // which UI does not currently support sale info is used for
  516. // verification only, if it doesn't match region info then sale is
  517. // canceled
  518. void sendBuy(const LLUUID& buyer_id, const LLUUID& category_id, const LLSaleInfo sale_info);
  519. void sendAttach(U8 attachment_point, bool replace);
  520. void sendDetach();
  521. void sendDropAttachment();
  522. void sendLink();
  523. void sendDelink();
  524. //void sendHinge(U8 type);
  525. //void sendDehinge();
  526. void sendSelect();
  527. void requestObjectPropertiesFamily(LLViewerObject* object); // asks sim for creator, permissions, resources, etc.
  528. static void processObjectProperties(LLMessageSystem *mesgsys, void **user_data);
  529. static void processObjectPropertiesFamily(LLMessageSystem *mesgsys, void **user_data);
  530. static void processForceObjectSelect(LLMessageSystem* msg, void**);
  531. void requestGodInfo();
  532. LLVector3d getSelectionCenterGlobal() const { return mSelectionCenterGlobal; }
  533. void updateSelectionCenter();
  534. void resetAgentHUDZoom();
  535. void setAgentHUDZoom(F32 target_zoom, F32 current_zoom);
  536. void getAgentHUDZoom(F32 &target_zoom, F32 &current_zoom) const;
  537. void updatePointAt();
  538. // Internal list maintenance functions. TODO: Make these private!
  539. void remove(std::vector<LLViewerObject*>& objects);
  540. void remove(LLViewerObject* object, S32 te = SELECT_ALL_TES, BOOL undoable = TRUE);
  541. void removeAll();
  542. void addAsIndividual(LLViewerObject* object, S32 te = SELECT_ALL_TES, BOOL undoable = TRUE);
  543. void promoteSelectionToRoot();
  544. void demoteSelectionToIndividuals();
  545. private:
  546. void convertTransient(); // converts temporarily selected objects to full-fledged selections
  547. ESelectType getSelectTypeForObject(LLViewerObject* object);
  548. void addAsFamily(std::vector<LLViewerObject*>& objects, BOOL add_to_end = FALSE);
  549. void generateSilhouette(LLSelectNode *nodep, const LLVector3& view_point);
  550. void updateSelectionSilhouette(LLObjectSelectionHandle object_handle, S32& num_sils_genned, std::vector<LLViewerObject*>& changed_objects);
  551. // Send one message to each region containing an object on selection list.
  552. void sendListToRegions( const std::string& message_name,
  553. void (*pack_header)(void *user_data),
  554. void (*pack_body)(LLSelectNode* node, void *user_data),
  555. void *user_data,
  556. ESendType send_type);
  557. static void packAgentID( void *);
  558. static void packAgentAndSessionID(void* user_data);
  559. static void packAgentAndGroupID(void* user_data);
  560. static void packAgentAndSessionAndGroupID(void* user_data);
  561. static void packAgentIDAndSessionAndAttachment(void*);
  562. static void packAgentGroupAndCatID(void*);
  563. static void packDeleteHeader(void* userdata);
  564. static void packDeRezHeader(void* user_data);
  565. static void packObjectID( LLSelectNode* node, void *);
  566. static void packObjectIDAsParam(LLSelectNode* node, void *);
  567. static void packObjectIDAndRotation(LLSelectNode* node, void *);
  568. static void packObjectLocalID(LLSelectNode* node, void *);
  569. static void packObjectClickAction(LLSelectNode* node, void* data);
  570. static void packObjectIncludeInSearch(LLSelectNode* node, void* data);
  571. static void packObjectName(LLSelectNode* node, void* user_data);
  572. static void packObjectDescription(LLSelectNode* node, void* user_data);
  573. static void packObjectCategory(LLSelectNode* node, void* user_data);
  574. static void packObjectSaleInfo(LLSelectNode* node, void* user_data);
  575. static void packBuyObjectIDs(LLSelectNode* node, void* user_data);
  576. static void packDuplicate( LLSelectNode* node, void *duplicate_data);
  577. static void packDuplicateHeader(void*);
  578. static void packDuplicateOnRayHead(void *user_data);
  579. static void packPermissions(LLSelectNode* node, void *user_data);
  580. static void packDeselect( LLSelectNode* node, void *user_data);
  581. static void packMultipleUpdate(LLSelectNode* node, void *user_data);
  582. static void packPhysics(LLSelectNode* node, void *user_data);
  583. static void packShape(LLSelectNode* node, void *user_data);
  584. static void packOwnerHead(void *user_data);
  585. static void packHingeHead(void *user_data);
  586. static void packPermissionsHead(void* user_data);
  587. static void packGodlikeHead(void* user_data);
  588. static bool confirmDelete(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle);
  589. public:
  590. // Observer/callback support for when object selection changes or
  591. // properties are received/updated
  592. typedef boost::signals2::signal< void ()> update_signal_t;
  593. update_signal_t mUpdateSignal;
  594. private:
  595. LLPointer<LLViewerTexture> mSilhouetteImagep;
  596. LLObjectSelectionHandle mSelectedObjects;
  597. LLObjectSelectionHandle mHoverObjects;
  598. LLObjectSelectionHandle mHighlightedObjects;
  599. std::set<LLPointer<LLViewerObject> > mRectSelectedObjects;
  600. LLObjectSelection mGridObjects;
  601. LLQuaternion mGridRotation;
  602. LLVector3 mGridOrigin;
  603. LLVector3 mGridScale;
  604. EGridMode mGridMode;
  605. BOOL mGridValid;
  606. BOOL mTEMode; // render te
  607. LLVector3d mSelectionCenterGlobal;
  608. LLBBox mSelectionBBox;
  609. LLVector3d mLastSentSelectionCenterGlobal;
  610. BOOL mShowSelection; // do we send the selection center name value and do we animate this selection?
  611. LLVector3d mLastCameraPos; // camera position from last generation of selection silhouette
  612. BOOL mRenderSilhouettes; // do we render the silhouette
  613. LLBBox mSavedSelectionBBox;
  614. LLFrameTimer mEffectsTimer;
  615. BOOL mForceSelection;
  616. LLAnimPauseRequest mPauseRequest;
  617. };
  618. // *DEPRECATED: For callbacks or observers, use
  619. // LLSelectMgr::getInstance()->mUpdateSignal.connect( callback )
  620. // Update subscribers to the selection list
  621. void dialog_refresh_all();
  622. // Templates
  623. //-----------------------------------------------------------------------------
  624. // getSelectedTEValue
  625. //-----------------------------------------------------------------------------
  626. template <typename T> bool LLObjectSelection::getSelectedTEValue(LLSelectedTEGetFunctor<T>* func, T& res)
  627. {
  628. bool have_first = false;
  629. bool have_selected = false;
  630. T selected_value = T();
  631. // Now iterate through all TEs to test for sameness
  632. bool identical = TRUE;
  633. for (iterator iter = begin(); iter != end(); iter++)
  634. {
  635. LLSelectNode* node = *iter;
  636. LLViewerObject* object = node->getObject();
  637. S32 selected_te = -1;
  638. if (object == getPrimaryObject())
  639. {
  640. selected_te = node->getLastSelectedTE();
  641. }
  642. for (S32 te = 0; te < object->getNumTEs(); ++te)
  643. {
  644. if (!node->isTESelected(te))
  645. {
  646. continue;
  647. }
  648. T value = func->get(object, te);
  649. if (!have_first)
  650. {
  651. have_first = true;
  652. if (!have_selected)
  653. {
  654. selected_value = value;
  655. }
  656. }
  657. else
  658. {
  659. if ( value != selected_value )
  660. {
  661. identical = false;
  662. }
  663. if (te == selected_te)
  664. {
  665. selected_value = value;
  666. have_selected = true;
  667. }
  668. }
  669. }
  670. if (!identical && have_selected)
  671. {
  672. break;
  673. }
  674. }
  675. if (have_first || have_selected)
  676. {
  677. res = selected_value;
  678. }
  679. return identical;
  680. }
  681. // Templates
  682. //-----------------------------------------------------------------------------
  683. // isMultipleTEValue iterate through all TEs and test for uniqueness
  684. // with certain return value ignored when performing the test.
  685. // e.g. when testing if the selection has a unique non-empty homeurl :
  686. // you can set ignore_value = "" and it will only compare among the non-empty
  687. // homeUrls and ignore the empty ones.
  688. //-----------------------------------------------------------------------------
  689. template <typename T> bool LLObjectSelection::isMultipleTEValue(LLSelectedTEGetFunctor<T>* func, const T& ignore_value)
  690. {
  691. bool have_first = false;
  692. T selected_value = T();
  693. // Now iterate through all TEs to test for sameness
  694. bool unique = TRUE;
  695. for (iterator iter = begin(); iter != end(); iter++)
  696. {
  697. LLSelectNode* node = *iter;
  698. LLViewerObject* object = node->getObject();
  699. for (S32 te = 0; te < object->getNumTEs(); ++te)
  700. {
  701. if (!node->isTESelected(te))
  702. {
  703. continue;
  704. }
  705. T value = func->get(object, te);
  706. if(value == ignore_value)
  707. {
  708. continue;
  709. }
  710. if (!have_first)
  711. {
  712. have_first = true;
  713. }
  714. else
  715. {
  716. if (value !=selected_value )
  717. {
  718. unique = false;
  719. return !unique;
  720. }
  721. }
  722. }
  723. }
  724. return !unique;
  725. }
  726. #endif