llselectmgr.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLSELECTMGR_H
00033 #define LL_LLSELECTMGR_H
00034 
00035 #include "llcharacter.h"
00036 #include "lleditmenuhandler.h"
00037 #include "llstring.h"
00038 #include "llundo.h"
00039 #include "lluuid.h"
00040 #include "llmemory.h"
00041 #include "llsaleinfo.h"
00042 #include "llcategory.h"
00043 #include "v3dmath.h"
00044 #include "llquaternion.h"
00045 #include "llcoord.h"
00046 #include "llframetimer.h"
00047 #include "llbbox.h"
00048 #include "llpermissions.h"
00049 #include "llviewerobject.h"
00050 
00051 #include <deque>
00052 #include "boost/iterator/filter_iterator.hpp"
00053 
00054 class LLMessageSystem;
00055 class LLViewerImage;
00056 class LLViewerObject;
00057 class LLColor4;
00058 class LLVector3;
00059 class LLSelectNode;
00060 
00061 const S32 SELECT_ALL_TES = -1;
00062 const S32 SELECT_MAX_TES = 32;
00063 
00064 // Do something to all objects in the selection manager.
00065 // The BOOL return value can be used to indicate if all
00066 // objects are identical (gathering information) or if
00067 // the operation was successful.
00068 struct LLSelectedObjectFunctor
00069 {
00070         virtual ~LLSelectedObjectFunctor() {};
00071         virtual bool apply(LLViewerObject* object) = 0;
00072 };
00073 
00074 // Do something to all select nodes in the selection manager.
00075 // The BOOL return value can be used to indicate if all
00076 // objects are identical (gathering information) or if
00077 // the operation was successful.
00078 struct LLSelectedNodeFunctor
00079 {
00080         virtual ~LLSelectedNodeFunctor() {};
00081         virtual bool apply(LLSelectNode* node) = 0;
00082 };
00083 
00084 struct LLSelectedTEFunctor
00085 {
00086         virtual ~LLSelectedTEFunctor() {};
00087         virtual bool apply(LLViewerObject* object, S32 face) = 0;
00088 };
00089 
00090 template <typename T> struct LLSelectedTEGetFunctor
00091 {
00092         virtual ~LLSelectedTEGetFunctor() {};
00093         virtual T get(LLViewerObject* object, S32 te) = 0;
00094 };
00095 
00096 typedef enum e_send_type
00097 {
00098         SEND_ONLY_ROOTS,
00099         SEND_INDIVIDUALS,
00100         SEND_ROOTS_FIRST, // useful for serial undos on linked sets
00101         SEND_CHILDREN_FIRST // useful for serial transforms of linked sets
00102 } ESendType;
00103 
00104 typedef enum e_grid_mode
00105 {
00106         GRID_MODE_WORLD,
00107         GRID_MODE_LOCAL,
00108         GRID_MODE_REF_OBJECT
00109 } EGridMode;
00110 
00111 typedef enum e_action_type
00112 {
00113         SELECT_ACTION_TYPE_BEGIN,
00114         SELECT_ACTION_TYPE_PICK,
00115         SELECT_ACTION_TYPE_MOVE,
00116         SELECT_ACTION_TYPE_ROTATE,
00117         SELECT_ACTION_TYPE_SCALE,
00118         NUM_ACTION_TYPES
00119 }EActionType;
00120 
00121 typedef enum e_selection_type
00122 {
00123         SELECT_TYPE_WORLD,
00124         SELECT_TYPE_ATTACHMENT,
00125         SELECT_TYPE_HUD
00126 }ESelectType;
00127 
00128 // Contains information about a selected object, particularly which TEs are selected.
00129 class LLSelectNode
00130 {
00131 public:
00132         LLSelectNode(LLViewerObject* object, BOOL do_glow);
00133         LLSelectNode(const LLSelectNode& nodep);
00134         ~LLSelectNode();
00135 
00136         void selectAllTEs(BOOL b);
00137         void selectTE(S32 te_index, BOOL selected);
00138         BOOL isTESelected(S32 te_index);
00139         S32 getLastSelectedTE();
00140         void renderOneSilhouette(const LLColor4 &color);
00141         void setTransient(BOOL transient) { mTransient = transient; }
00142         BOOL isTransient() { return mTransient; }
00143         LLViewerObject* getObject();
00144         void setObject(LLViewerObject* object);
00145         // *NOTE: invalidate stored textures and colors when # faces change
00146         void saveColors();
00147         void saveTextures(const std::vector<LLUUID>& textures);
00148         void saveTextureScaleRatios();
00149 
00150         BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const;
00151 
00152 public:
00153         BOOL                    mIndividualSelection;           // For root objects and objects individually selected
00154 
00155         BOOL                    mTransient;
00156         BOOL                    mValid;                         // is extra information valid?
00157         LLPermissions*  mPermissions;
00158         LLSaleInfo              mSaleInfo;
00159         LLAggregatePermissions mAggregatePerm;
00160         LLAggregatePermissions mAggregateTexturePerm;
00161         LLAggregatePermissions mAggregateTexturePermOwner;
00162         LLString                mName;
00163         LLString                mDescription;
00164         LLCategory              mCategory;
00165         S16                             mInventorySerial;
00166         LLVector3               mSavedPositionLocal;    // for interactively modifying object position
00167         LLVector3               mLastPositionLocal;
00168         LLVector3d              mSavedPositionGlobal;   // for interactively modifying object position
00169         LLVector3               mSavedScale;                    // for interactively modifying object scale
00170         LLVector3               mLastScale;
00171         LLQuaternion    mSavedRotation;                 // for interactively modifying object rotation
00172         LLQuaternion    mLastRotation;
00173         BOOL                    mDuplicated;
00174         LLVector3d              mDuplicatePos;
00175         LLQuaternion    mDuplicateRot;
00176         LLUUID                  mItemID;
00177         LLUUID                  mFolderID;
00178         LLUUID                  mFromTaskID;
00179         LLString                mTouchName;
00180         LLString                mSitName;
00181         U64                             mCreationDate;
00182         std::vector<LLColor4>   mSavedColors;
00183         std::vector<LLUUID>             mSavedTextures;
00184         std::vector<LLVector3>  mTextureScaleRatios;
00185         std::vector<LLVector3>  mSilhouetteVertices;    // array of vertices to render silhouette of object
00186         std::vector<LLVector3>  mSilhouetteNormals;     // array of normals to render silhouette of object
00187         std::vector<S32>                mSilhouetteSegments;    // array of normals to render silhouette of object
00188         BOOL                                    mSilhouetteExists;      // need to generate silhouette?
00189 
00190 protected:
00191         LLPointer<LLViewerObject>       mObject;
00192         BOOL                    mTESelected[SELECT_MAX_TES];
00193         S32                             mLastTESelected;
00194 };
00195 
00196 class LLObjectSelection : public LLRefCount
00197 {
00198         friend class LLSelectMgr;
00199 
00200 protected:
00201         ~LLObjectSelection();
00202 
00203         // List
00204 public:
00205         typedef std::list<LLSelectNode*> list_t;
00206 private:
00207         list_t mList;
00208 
00209 public:
00210         // Iterators
00211         struct is_non_null
00212         {
00213                 bool operator()(LLSelectNode* node)
00214                 {
00215                         return (node->getObject() != NULL);
00216                 }
00217         };
00218         typedef boost::filter_iterator<is_non_null, list_t::iterator > iterator;
00219         iterator begin() { return iterator(mList.begin(), mList.end()); }
00220         iterator end() { return iterator(mList.end(), mList.end()); }
00221 
00222         struct is_valid
00223         {
00224                 bool operator()(LLSelectNode* node)
00225                 {
00226                         return (node->getObject() != NULL) && node->mValid;
00227                 }
00228         };
00229         typedef boost::filter_iterator<is_valid, list_t::iterator > valid_iterator;
00230         valid_iterator valid_begin() { return valid_iterator(mList.begin(), mList.end()); }
00231         valid_iterator valid_end() { return valid_iterator(mList.end(), mList.end()); }
00232 
00233         struct is_root
00234         {
00235                 bool operator()(LLSelectNode* node)
00236                 {
00237                         LLViewerObject* object = node->getObject();
00238                         return (object != NULL) && !node->mIndividualSelection && (object->isRootEdit() || object->isJointChild());
00239                 }
00240         };
00241         typedef boost::filter_iterator<is_root, list_t::iterator > root_iterator;
00242         root_iterator root_begin() { return root_iterator(mList.begin(), mList.end()); }
00243         root_iterator root_end() { return root_iterator(mList.end(), mList.end()); }
00244         
00245         struct is_valid_root
00246         {
00247                 bool operator()(LLSelectNode* node)
00248                 {
00249                         LLViewerObject* object = node->getObject();
00250                         return (object != NULL) && node->mValid && !node->mIndividualSelection && (object->isRootEdit() || object->isJointChild());
00251                 }
00252         };
00253         typedef boost::filter_iterator<is_root, list_t::iterator > valid_root_iterator;
00254         valid_root_iterator valid_root_begin() { return valid_root_iterator(mList.begin(), mList.end()); }
00255         valid_root_iterator valid_root_end() { return valid_root_iterator(mList.end(), mList.end()); }
00256         
00257         struct is_root_object
00258         {
00259                 bool operator()(LLSelectNode* node)
00260                 {
00261                         LLViewerObject* object = node->getObject();
00262                         return (object != NULL) && (object->isRootEdit() || object->isJointChild());
00263                 }
00264         };
00265         typedef boost::filter_iterator<is_root_object, list_t::iterator > root_object_iterator;
00266         root_object_iterator root_object_begin() { return root_object_iterator(mList.begin(), mList.end()); }
00267         root_object_iterator root_object_end() { return root_object_iterator(mList.end(), mList.end()); }
00268         
00269 public:
00270         LLObjectSelection();
00271 
00272         void updateEffects();
00273         void cleanupNodes();
00274 
00275         BOOL isEmpty() const;
00276 
00277         S32 getOwnershipCost(S32 &cost);
00278 
00279         LLSelectNode*   getFirstNode(LLSelectedNodeFunctor* func = NULL);
00280         LLSelectNode*   getFirstRootNode(LLSelectedNodeFunctor* func = NULL, BOOL non_root_ok = FALSE);
00281         LLViewerObject* getFirstSelectedObject(LLSelectedNodeFunctor* func, BOOL get_parent = FALSE);
00282         LLViewerObject* getFirstObject();
00283         LLViewerObject* getFirstRootObject(BOOL non_root_ok = FALSE);
00284         
00285         LLSelectNode*   getFirstMoveableNode(BOOL get_root_first = FALSE);
00286 
00287         LLViewerObject* getFirstEditableObject(BOOL get_parent = FALSE);
00288         LLViewerObject* getFirstCopyableObject(BOOL get_parent = FALSE);
00289         LLViewerObject* getFirstDeleteableObject();
00290         LLViewerObject* getFirstMoveableObject(BOOL get_parent = FALSE);
00291         LLViewerObject* getPrimaryObject() { return mPrimaryObject; }
00292 
00293         // iterate through texture entries
00294         template <typename T> bool getSelectedTEValue(LLSelectedTEGetFunctor<T>* func, T& res);
00295                 
00296         void addNode(LLSelectNode *nodep);
00297         void addNodeAtEnd(LLSelectNode *nodep);
00298         void moveNodeToFront(LLSelectNode *nodep);
00299         void removeNode(LLSelectNode *nodep);
00300         void deleteAllNodes();                  // Delete all nodes
00301         S32 getNumNodes();
00302         LLSelectNode* findNode(LLViewerObject* objectp);
00303 
00304         // count members
00305         S32 getObjectCount();
00306         S32 getTECount();
00307         S32 getRootObjectCount();
00308 
00309         BOOL contains(LLViewerObject* object);
00310         BOOL contains(LLViewerObject* object, S32 te);
00311 
00312         // returns TRUE is any node is currenly worn as an attachment
00313         BOOL isAttachment();
00314 
00315         // Apply functors to various subsets of the selected objects
00316         // If firstonly is FALSE, returns the AND of all apply() calls.
00317         // Else returns TRUE immediately if any apply() call succeeds (i.e. OR with early exit)
00318         bool applyToRootObjects(LLSelectedObjectFunctor* func, bool firstonly = false);
00319         bool applyToObjects(LLSelectedObjectFunctor* func, bool firstonly = false);
00320         bool applyToTEs(LLSelectedTEFunctor* func, bool firstonly = false);
00321         bool applyToRootNodes(LLSelectedNodeFunctor* func, bool firstonly = false);
00322         bool applyToNodes(LLSelectedNodeFunctor* func, bool firstonly = false);
00323 
00324         ESelectType getSelectType() const { return mSelectType; }
00325 
00326 private:
00327         const LLObjectSelection &operator=(const LLObjectSelection &);
00328 
00329         LLPointer<LLViewerObject> mPrimaryObject;
00330         std::map<LLPointer<LLViewerObject>, LLSelectNode*> mSelectNodeMap;
00331         ESelectType mSelectType;
00332 };
00333 
00334 typedef LLSafeHandle<LLObjectSelection> LLObjectSelectionHandle;
00335 
00336 class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
00337 {
00338 public:
00339         static BOOL                                     sRectSelectInclusive;   // do we need to surround an object to pick it?
00340         static BOOL                                     sRenderHiddenSelections;        // do we show selection silhouettes that are occluded?
00341         static BOOL                                     sRenderLightRadius;     // do we show the radius of selected lights?
00342         static F32                                      sHighlightThickness;
00343         static F32                                      sHighlightUScale;
00344         static F32                                      sHighlightVScale;
00345         static F32                                      sHighlightAlpha;
00346         static F32                                      sHighlightAlphaTest;
00347         static F32                                      sHighlightUAnim;
00348         static F32                                      sHighlightVAnim;
00349         static LLColor4                         sSilhouetteParentColor;
00350         static LLColor4                         sSilhouetteChildColor;
00351         static LLColor4                         sHighlightParentColor;
00352         static LLColor4                         sHighlightChildColor;
00353         static LLColor4                         sHighlightInspectColor;
00354         static LLColor4                         sContextSilhouetteColor;
00355 
00356 public:
00357         LLSelectMgr();
00358         ~LLSelectMgr();
00359 
00360         static void cleanupGlobals();
00361 
00362         // LLEditMenuHandler interface
00363         virtual BOOL canUndo() const;
00364         virtual void undo();
00365 
00366         virtual BOOL canRedo() const;
00367         virtual void redo();
00368 
00369         virtual BOOL canDoDelete() const;
00370         virtual void doDelete();
00371 
00372         virtual void deselect();
00373         virtual BOOL canDeselect() const;
00374 
00375         virtual void duplicate();
00376         virtual BOOL canDuplicate() const;
00377 
00378         void clearSelections();
00379         void update();
00380         void updateEffects(); // Update HUD effects
00381         void overrideObjectUpdates();
00382 
00383         // Returns the previous value of mForceSelection
00384         BOOL setForceSelection(BOOL force);
00385 
00387         // Selection methods
00389 
00391         // Add
00393 
00394         // For when you want just a child object.
00395         LLObjectSelectionHandle selectObjectOnly(LLViewerObject* object, S32 face = SELECT_ALL_TES);
00396 
00397         // This method is meant to select an object, and then select all
00398         // of the ancestors and descendents. This should be the normal behavior.
00399         LLObjectSelectionHandle selectObjectAndFamily(LLViewerObject* object, BOOL add_to_end = FALSE);
00400 
00401         // Same as above, but takes a list of objects.  Used by rectangle select.
00402         LLObjectSelectionHandle selectObjectAndFamily(const std::vector<LLViewerObject*>& object_list, BOOL send_to_sim = TRUE);
00403 
00404         // converts all objects currently highlighted to a selection, and returns it
00405         LLObjectSelectionHandle selectHighlightedObjects();
00406 
00407         LLObjectSelectionHandle setHoverObject(LLViewerObject *objectp);
00408 
00409         void highlightObjectOnly(LLViewerObject *objectp);
00410         void highlightObjectAndFamily(LLViewerObject *objectp);
00411         void highlightObjectAndFamily(const std::vector<LLViewerObject*>& list);
00412 
00414         // Remove
00416 
00417         void deselectObjectOnly(LLViewerObject* object, BOOL send_to_sim = TRUE);
00418         void deselectObjectAndFamily(LLViewerObject* object, BOOL send_to_sim = TRUE, BOOL include_entire_object = FALSE);
00419 
00420         // Send deselect messages to simulator, then clear the list
00421         void deselectAll();
00422         void deselectAllForStandingUp();
00423 
00424         // deselect only if nothing else currently referencing the selection
00425         void deselectUnused();
00426 
00427         // Deselect if the selection center is too far away from the agent.
00428         void deselectAllIfTooFar();
00429 
00430         // Removes all highlighted objects from current selection
00431         void deselectHighlightedObjects();
00432 
00433         void unhighlightObjectOnly(LLViewerObject *objectp);
00434         void unhighlightObjectAndFamily(LLViewerObject *objectp);
00435         void unhighlightAll();
00436 
00437         BOOL removeObjectFromSelections(const LLUUID &id);
00438 
00440         // Selection accessors
00442         LLObjectSelectionHandle getHoverObjects() { return mHoverObjects; }
00443         LLObjectSelectionHandle getSelection() { return mSelectedObjects; }
00444         // right now this just renders the selection with root/child colors instead of a single color
00445         LLObjectSelectionHandle getEditSelection() { convertTransient(); return mSelectedObjects; }
00446         LLObjectSelectionHandle getHighlightedObjects() { return mHighlightedObjects; }
00447 
00448         LLSelectNode *getHoverNode();
00449 
00451         // Grid manipulation
00453         void                    addGridObject(LLViewerObject* objectp);
00454         void                    clearGridObjects();
00455         void                    setGridMode(EGridMode mode);
00456         EGridMode               getGridMode() { return mGridMode; }
00457         void                    getGrid(LLVector3& origin, LLQuaternion& rotation, LLVector3 &scale);
00458 
00459         BOOL getTEMode()                { return mTEMode; }
00460         void setTEMode(BOOL b)  { mTEMode = b; }
00461 
00462         BOOL shouldShowSelection()      { return mShowSelection; }
00463 
00464         LLBBox getBBoxOfSelection() const;
00465         LLBBox getSavedBBoxOfSelection() const { return mSavedSelectionBBox; }
00466 
00467         void dump();
00468         void cleanup();
00469 
00470         void updateSilhouettes();
00471         void renderSilhouettes(BOOL for_hud);
00472         void enableSilhouette(BOOL enable) { mRenderSilhouettes = enable; }
00473         
00475         // Utility functions that operate on the current selection
00477         void saveSelectedObjectTransform(EActionType action_type);
00478         void saveSelectedObjectColors();
00479         void saveSelectedObjectTextures();
00480 
00481         void selectionUpdatePhysics(BOOL use_physics);
00482         void selectionUpdateTemporary(BOOL is_temporary);
00483         void selectionUpdatePhantom(BOOL is_ghost);
00484         void selectionUpdateCastShadows(BOOL cast_shadows);
00485         void selectionDump();
00486 
00487         BOOL selectionAllPCode(LLPCode code);           // all objects have this PCode
00488         BOOL selectionGetClickAction(U8 *out_action);
00489         bool selectionGetIncludeInSearch(bool* include_in_search_out); // true if all selected objects have same
00490         BOOL selectionGetGlow(F32 *glow);
00491 
00492         void selectionSetMaterial(U8 material);
00493         void selectionSetImage(const LLUUID& imageid); // could be item or asset id
00494         void selectionSetColor(const LLColor4 &color);
00495         void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels
00496         void selectionSetAlphaOnly(const F32 alpha); // Set only the alpha channel
00497         void selectionRevertColors();
00498         BOOL selectionRevertTextures();
00499         void selectionSetBumpmap( U8 bumpmap );
00500         void selectionSetTexGen( U8 texgen );
00501         void selectionSetShiny( U8 shiny );
00502         void selectionSetFullbright( U8 fullbright );
00503         void selectionSetMediaTypeAndURL( U8 media_type, const std::string& media_url );
00504         void selectionSetClickAction(U8 action);
00505         void selectionSetIncludeInSearch(bool include_in_search);
00506         void selectionSetGlow(const F32 glow);
00507 
00508         void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE);
00509         void selectionSetObjectName(const LLString& name);
00510         void selectionSetObjectDescription(const LLString& desc);
00511         void selectionSetObjectCategory(const LLCategory& category);
00512         void selectionSetObjectSaleInfo(const LLSaleInfo& sale_info);
00513 
00514         void selectionTexScaleAutofit(F32 repeats_per_meter);
00515         void adjustTexturesByScale(BOOL send_to_sim, BOOL stretch);
00516 
00517         void selectionResetRotation();                          // sets rotation quat to identity
00518         void selectionRotateAroundZ(F32 degrees);
00519         bool selectionMove(const LLVector3& displ, F32 rx, F32 ry, F32 rz,
00520                                            U32 update_type);
00521         void sendSelectionMove();
00522 
00523         void sendGodlikeRequest(const LLString& request, const LLString& parameter);
00524 
00525 
00526         // will make sure all selected object meet current criteria, or deselect them otherwise
00527         void validateSelection();
00528 
00529         // returns TRUE if it is possible to select this object
00530         BOOL canSelectObject(LLViewerObject* object);
00531 
00532         // Returns TRUE if the viewer has information on all selected objects
00533         BOOL selectGetAllRootsValid();
00534         BOOL selectGetAllValid();
00535 
00536         // returns TRUE if you can modify all selected objects. 
00537         BOOL selectGetRootsModify();
00538         BOOL selectGetModify();
00539 
00540         // returns TRUE if selected objects can be transferred.
00541         BOOL selectGetRootsTransfer();
00542 
00543         // returns TRUE if selected objects can be copied.
00544         BOOL selectGetRootsCopy();
00545         
00546         BOOL selectGetCreator(LLUUID& id, LLString& name);                                      // TRUE if all have same creator, returns id
00547         BOOL selectGetOwner(LLUUID& id, LLString& name);                                        // TRUE if all objects have same owner, returns id
00548         BOOL selectGetLastOwner(LLUUID& id, LLString& name);                            // TRUE if all objects have same owner, returns id
00549 
00550         // returns TRUE if all are the same. id is stuffed with
00551         // the value found if available.
00552         BOOL selectGetGroup(LLUUID& id); 
00553         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
00554         BOOL selectGetOwnershipCost(S32* cost);                                                         // sum of all ownership costs
00555 
00556         BOOL selectIsGroupOwned();                                                                                      // TRUE if all root objects have valid data and are group owned.
00557 
00558         // returns TRUE if all the nodes are valid. Accumulates
00559         // permissions in the parameter.
00560         BOOL selectGetPermissions(LLPermissions& perm);
00561 
00562         // returns TRUE if anything is for sale. calculates the total
00563         // price and stores that value in price.
00564         BOOL selectIsForSale(S32& price);
00565 
00566         // returns TRUE if all nodes are valid. 
00567         BOOL selectGetCategory(LLCategory& category);
00568         
00569         // returns TRUE if all nodes are valid. method also stores an
00570         // accumulated sale info.
00571         BOOL selectGetSaleInfo(LLSaleInfo& sale_info);
00572 
00573         // returns TRUE if all nodes are valid. fills passed in object
00574         // with the aggregate permissions of the selection.
00575         BOOL selectGetAggregatePermissions(LLAggregatePermissions& ag_perm);
00576 
00577         // returns TRUE if all nodes are valid. fills passed in object
00578         // with the aggregate permissions for texture inventory items of the selection.
00579         BOOL selectGetAggregateTexturePermissions(LLAggregatePermissions& ag_perm);
00580 
00581         LLPermissions* findObjectPermissions(const LLViewerObject* object);
00582 
00583         void selectDelete();                                                    // Delete on simulator
00584         void selectForceDelete();                       // just delete, no into trash
00585         void selectDuplicate(const LLVector3& offset, BOOL select_copy);        // Duplicate on simulator
00586         void repeatDuplicate();
00587         void selectDuplicateOnRay(const LLVector3 &ray_start_region,
00588                                                                 const LLVector3 &ray_end_region,
00589                                                                 BOOL bypass_raycast,
00590                                                                 BOOL ray_end_is_intersection,
00591                                                                 const LLUUID &ray_target_id,
00592                                                                 BOOL copy_centers,
00593                                                                 BOOL copy_rotates,
00594                                                                 BOOL select_copy);
00595 
00596         void sendMultipleUpdate(U32 type);      // Position, rotation, scale all in one
00597         void sendOwner(const LLUUID& owner_id, const LLUUID& group_id, BOOL override = FALSE);
00598         void sendGroup(const LLUUID& group_id);
00599 
00600         // Category ID is the UUID of the folder you want to contain the purchase.
00601         // *NOTE: sale_info check doesn't work for multiple object buy,
00602         // which UI does not currently support sale info is used for
00603         // verification only, if it doesn't match region info then sale is
00604         // canceled
00605         void sendBuy(const LLUUID& buyer_id, const LLUUID& category_id, const LLSaleInfo sale_info);
00606         void sendAttach(U8 attachment_point);
00607         void sendDetach();
00608         void sendDropAttachment();
00609         void sendLink();
00610         void sendDelink();
00611         //void sendHinge(U8 type);
00612         //void sendDehinge();
00613         void sendSelect();
00614 
00615         void requestObjectPropertiesFamily(LLViewerObject* object);     // asks sim for creator, permissions, resources, etc.
00616         static void processObjectProperties(LLMessageSystem *mesgsys, void **user_data);
00617         static void processObjectPropertiesFamily(LLMessageSystem *mesgsys, void **user_data);
00618         static void processForceObjectSelect(LLMessageSystem* msg, void**);
00619 
00620         void requestGodInfo();
00621 
00622         LLVector3d              getSelectionCenterGlobal() const        { return mSelectionCenterGlobal; }
00623         void                    updateSelectionCenter();
00624 
00625         void resetAgentHUDZoom();
00626         void setAgentHUDZoom(F32 target_zoom, F32 current_zoom);
00627         void getAgentHUDZoom(F32 &target_zoom, F32 &current_zoom) const;
00628 
00629         void updatePointAt();
00630 
00631         // Internal list maintenance functions. TODO: Make these private!
00632         void remove(std::vector<LLViewerObject*>& objects);
00633         void remove(LLViewerObject* object, S32 te = SELECT_ALL_TES, BOOL undoable = TRUE);
00634         void removeAll();
00635         void addAsIndividual(LLViewerObject* object, S32 te = SELECT_ALL_TES, BOOL undoable = TRUE);
00636         void promoteSelectionToRoot();
00637         void demoteSelectionToIndividuals();
00638 
00639 private:
00640         void convertTransient(); // converts temporarily selected objects to full-fledged selections
00641         ESelectType getSelectTypeForObject(LLViewerObject* object);
00642         void addAsFamily(std::vector<LLViewerObject*>& objects, BOOL add_to_end = FALSE);
00643         void generateSilhouette(LLSelectNode *nodep, const LLVector3& view_point);
00644         // Send one message to each region containing an object on selection list.
00645         void sendListToRegions( const LLString& message_name,
00646                                                         void (*pack_header)(void *user_data), 
00647                                                         void (*pack_body)(LLSelectNode* node, void *user_data), 
00648                                                         void *user_data,
00649                                                         ESendType send_type);
00650 
00651         static void packAgentID(        void *);
00652         static void packAgentAndSessionID(void* user_data);
00653         static void packAgentAndGroupID(void* user_data);
00654         static void packAgentAndSessionAndGroupID(void* user_data);
00655         static void packAgentIDAndSessionAndAttachment(void*);
00656         static void packAgentGroupAndCatID(void*);
00657         static void packDeleteHeader(void* userdata);
00658         static void packDeRezHeader(void* user_data);
00659         static void packObjectID(       LLSelectNode* node, void *);
00660         static void packObjectIDAsParam(LLSelectNode* node, void *);
00661         static void packObjectIDAndRotation(    LLSelectNode* node, void *);
00662         static void packObjectLocalID(LLSelectNode* node, void *);
00663         static void packObjectClickAction(LLSelectNode* node, void* data);
00664         static void packObjectIncludeInSearch(LLSelectNode* node, void* data);
00665         static void packObjectName(LLSelectNode* node, void* user_data);
00666         static void packObjectDescription(LLSelectNode* node, void* user_data);
00667         static void packObjectCategory(LLSelectNode* node, void* user_data);
00668         static void packObjectSaleInfo(LLSelectNode* node, void* user_data);
00669         static void packBuyObjectIDs(LLSelectNode* node, void* user_data);
00670         static void packDuplicate(      LLSelectNode* node, void *duplicate_data);
00671         static void packDuplicateHeader(void*);
00672         static void packDuplicateOnRayHead(void *user_data);
00673         static void packPermissions(LLSelectNode* node, void *user_data);
00674         static void packDeselect(       LLSelectNode* node, void *user_data);
00675         static void packMultipleUpdate(LLSelectNode* node, void *user_data);
00676         static void packPhysics(LLSelectNode* node, void *user_data);
00677         static void packShape(LLSelectNode* node, void *user_data);
00678         static void packOwnerHead(void *user_data);
00679         static void packHingeHead(void *user_data);
00680         static void packPermissionsHead(void* user_data);
00681         static void packGodlikeHead(void* user_data);
00682         static void confirmDelete(S32 option, void* data);
00683         
00684 private:
00685         LLPointer<LLViewerImage>                                mSilhouetteImagep;
00686         LLObjectSelectionHandle                                 mSelectedObjects;
00687         LLObjectSelectionHandle                                 mHoverObjects;
00688         LLObjectSelectionHandle                                 mHighlightedObjects;
00689         std::set<LLPointer<LLViewerObject> >    mRectSelectedObjects;
00690         
00691         LLObjectSelection               mGridObjects;
00692         LLQuaternion                    mGridRotation;
00693         LLVector3                               mGridOrigin;
00694         LLVector3                               mGridScale;
00695         EGridMode                               mGridMode;
00696         BOOL                                    mGridValid;
00697 
00698 
00699         BOOL                                    mTEMode;                        // render te
00700         LLVector3d                              mSelectionCenterGlobal;
00701         LLBBox                                  mSelectionBBox;
00702 
00703         LLVector3d                              mLastSentSelectionCenterGlobal;
00704         BOOL                                    mShowSelection; // do we send the selection center name value and do we animate this selection?
00705         LLVector3d                              mLastCameraPos;         // camera position from last generation of selection silhouette
00706         BOOL                                    mRenderSilhouettes;     // do we render the silhouette
00707         LLBBox                                  mSavedSelectionBBox;
00708 
00709         LLFrameTimer                    mEffectsTimer;
00710         BOOL                                    mForceSelection;
00711 
00712         LLAnimPauseRequest              mPauseRequest;
00713 };
00714 
00715 // Utilities
00716 void dialog_refresh_all();              // Update subscribers to the selection list
00717 
00718 // Templates
00719 //-----------------------------------------------------------------------------
00720 // getSelectedTEValue
00721 //-----------------------------------------------------------------------------
00722 template <typename T> bool LLObjectSelection::getSelectedTEValue(LLSelectedTEGetFunctor<T>* func, T& res)
00723 {
00724         bool have_first = false;
00725         bool have_selected = false;
00726         T selected_value = T();
00727 
00728         // Now iterate through all TEs to test for sameness
00729         bool identical = TRUE;
00730         for (iterator iter = begin(); iter != end(); iter++)
00731         {
00732                 LLSelectNode* node = *iter;
00733                 LLViewerObject* object = node->getObject();
00734                 S32 selected_te = -1;
00735                 if (object == getPrimaryObject())
00736                 {
00737                         selected_te = node->getLastSelectedTE();
00738                 }
00739                 for (S32 te = 0; te < object->getNumTEs(); ++te)
00740                 {
00741                         if (!node->isTESelected(te))
00742                         {
00743                                 continue;
00744                         }
00745                         T value = func->get(object, te);
00746                         if (!have_first)
00747                         {
00748                                 have_first = true;
00749                                 if (!have_selected)
00750                                 {
00751                                         selected_value = value;
00752                                 }
00753                         }
00754                         else
00755                         {
00756                                 if ( value != selected_value )
00757                                 {
00758                                         identical = false;
00759                                 }
00760                                 if (te == selected_te)
00761                                 {
00762                                         selected_value = value;
00763                                         have_selected = true;
00764                                 }
00765                         }
00766                 }
00767                 if (!identical && have_selected)
00768                 {
00769                         break;
00770                 }
00771         }
00772         if (have_first || have_selected)
00773         {
00774                 res = selected_value;
00775         }
00776         return identical;
00777 }
00778 
00779 
00780 #endif

Generated on Fri May 16 08:34:01 2008 for SecondLife by  doxygen 1.5.5