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();
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() { 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 LLHandle<LLObjectSelection> LLObjectSelectionHandle;
00335 
00336 class LLSelectMgr : public LLEditMenuHandler
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();
00364         virtual void undo();
00365 
00366         virtual BOOL canRedo();
00367         virtual void redo();
00368 
00369         virtual BOOL canDoDelete();
00370         virtual void doDelete();
00371 
00372         virtual void deselect();
00373         virtual BOOL canDeselect();
00374 
00375         virtual void duplicate();
00376         virtual BOOL canDuplicate();
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 
00423         // deselect only if nothing else currently referencing the selection
00424         void deselectUnused();
00425 
00426         // Deselect if the selection center is too far away from the agent.
00427         void deselectAllIfTooFar();
00428 
00429         // Removes all highlighted objects from current selection
00430         void deselectHighlightedObjects();
00431 
00432         void unhighlightObjectOnly(LLViewerObject *objectp);
00433         void unhighlightObjectAndFamily(LLViewerObject *objectp);
00434         void unhighlightAll();
00435 
00436         BOOL removeObjectFromSelections(const LLUUID &id);
00437 
00439         // Selection accessors
00441         LLObjectSelectionHandle getHoverObjects() { return mHoverObjects; }
00442         LLObjectSelectionHandle getSelection() { return mSelectedObjects; }
00443         // right now this just renders the selection with root/child colors instead of a single color
00444         LLObjectSelectionHandle getEditSelection() { convertTransient(); return mSelectedObjects; }
00445         LLObjectSelectionHandle getHighlightedObjects() { return mHighlightedObjects; }
00446 
00447         LLSelectNode *getHoverNode();
00448 
00450         // Grid manipulation
00452         void                    addGridObject(LLViewerObject* objectp);
00453         void                    clearGridObjects();
00454         void                    setGridMode(EGridMode mode);
00455         EGridMode               getGridMode() { return mGridMode; }
00456         void                    getGrid(LLVector3& origin, LLQuaternion& rotation, LLVector3 &scale);
00457 
00458         BOOL getTEMode()                { return mTEMode; }
00459         void setTEMode(BOOL b)  { mTEMode = b; }
00460 
00461         BOOL shouldShowSelection()      { return mShowSelection; }
00462 
00463         LLBBox getBBoxOfSelection() const;
00464         LLBBox getSavedBBoxOfSelection() const { return mSavedSelectionBBox; }
00465 
00466         void dump();
00467         void cleanup();
00468 
00469         void updateSilhouettes();
00470         void renderSilhouettes(BOOL for_hud);
00471         void enableSilhouette(BOOL enable) { mRenderSilhouettes = enable; }
00472         
00474         // Utility functions that operate on the current selection
00476         void saveSelectedObjectTransform(EActionType action_type);
00477         void saveSelectedObjectColors();
00478         void saveSelectedObjectTextures();
00479 
00480         void selectionUpdatePhysics(BOOL use_physics);
00481         void selectionUpdateTemporary(BOOL is_temporary);
00482         void selectionUpdatePhantom(BOOL is_ghost);
00483         void selectionUpdateCastShadows(BOOL cast_shadows);
00484         void selectionDump();
00485 
00486         BOOL selectionAllPCode(LLPCode code);           // all objects have this PCode
00487         BOOL selectionGetClickAction(U8 *out_action);
00488         bool selectionGetIncludeInSearch(bool* include_in_search_out); // true if all selected objects have same
00489 
00490         void selectionSetMaterial(U8 material);
00491         void selectionSetImage(const LLUUID& imageid); // could be item or asset id
00492         void selectionSetColor(const LLColor4 &color);
00493         void selectionSetColorOnly(const LLColor4 &color); // Set only the RGB channels
00494         void selectionSetAlphaOnly(const F32 alpha); // Set only the alpha channel
00495         void selectionRevertColors();
00496         BOOL selectionRevertTextures();
00497         void selectionSetBumpmap( U8 bumpmap );
00498         void selectionSetTexGen( U8 texgen );
00499         void selectionSetShiny( U8 shiny );
00500         void selectionSetFullbright( U8 fullbright );
00501         void selectionSetMediaTypeAndURL( U8 media_type, const std::string& media_url );
00502         void selectionSetClickAction(U8 action);
00503         void selectionSetIncludeInSearch(bool include_in_search);
00504 
00505         void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE);
00506         void selectionSetObjectName(const LLString& name);
00507         void selectionSetObjectDescription(const LLString& desc);
00508         void selectionSetObjectCategory(const LLCategory& category);
00509         void selectionSetObjectSaleInfo(const LLSaleInfo& sale_info);
00510 
00511         void selectionTexScaleAutofit(F32 repeats_per_meter);
00512         void adjustTexturesByScale(BOOL send_to_sim, BOOL stretch);
00513 
00514         void selectionResetRotation();                          // sets rotation quat to identity
00515         void selectionRotateAroundZ(F32 degrees);
00516         void sendGodlikeRequest(const LLString& request, const LLString& parameter);
00517 
00518 
00519         // will make sure all selected object meet current criteria, or deselect them otherwise
00520         void validateSelection();
00521 
00522         // returns TRUE if it is possible to select this object
00523         BOOL canSelectObject(LLViewerObject* object);
00524 
00525         // Returns TRUE if the viewer has information on all selected objects
00526         BOOL selectGetAllRootsValid();
00527         BOOL selectGetAllValid();
00528 
00529         // returns TRUE if you can modify all selected objects. 
00530         BOOL selectGetRootsModify();
00531         BOOL selectGetModify();
00532 
00533         // returns TRUE if selected objects can be transferred.
00534         BOOL selectGetRootsTransfer();
00535 
00536         // returns TRUE if selected objects can be copied.
00537         BOOL selectGetRootsCopy();
00538         
00539         BOOL selectGetCreator(LLUUID& id, LLString& name);                                      // TRUE if all have same creator, returns id
00540         BOOL selectGetOwner(LLUUID& id, LLString& name);                                        // TRUE if all objects have same owner, returns id
00541         BOOL selectGetLastOwner(LLUUID& id, LLString& name);                            // TRUE if all objects have same owner, returns id
00542 
00543         // returns TRUE if all are the same. id is stuffed with
00544         // the value found if available.
00545         BOOL selectGetGroup(LLUUID& id); 
00546         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
00547         BOOL selectGetOwnershipCost(S32* cost);                                                         // sum of all ownership costs
00548 
00549         BOOL selectIsGroupOwned();                                                                                      // TRUE if all root objects have valid data and are group owned.
00550 
00551         // returns TRUE if all the nodes are valid. Accumulates
00552         // permissions in the parameter.
00553         BOOL selectGetPermissions(LLPermissions& perm);
00554 
00555         // returns TRUE if anything is for sale. calculates the total
00556         // price and stores that value in price.
00557         BOOL selectIsForSale(S32& price);
00558 
00559         // returns TRUE if all nodes are valid. 
00560         BOOL selectGetCategory(LLCategory& category);
00561         
00562         // returns TRUE if all nodes are valid. method also stores an
00563         // accumulated sale info.
00564         BOOL selectGetSaleInfo(LLSaleInfo& sale_info);
00565 
00566         // returns TRUE if all nodes are valid. fills passed in object
00567         // with the aggregate permissions of the selection.
00568         BOOL selectGetAggregatePermissions(LLAggregatePermissions& ag_perm);
00569 
00570         // returns TRUE if all nodes are valid. fills passed in object
00571         // with the aggregate permissions for texture inventory items of the selection.
00572         BOOL selectGetAggregateTexturePermissions(LLAggregatePermissions& ag_perm);
00573 
00574         LLPermissions* findObjectPermissions(const LLViewerObject* object);
00575 
00576         void selectDelete();                                                    // Delete on simulator
00577         void selectForceDelete();                       // just delete, no into trash
00578         void selectDuplicate(const LLVector3& offset, BOOL select_copy);        // Duplicate on simulator
00579         void repeatDuplicate();
00580         void selectDuplicateOnRay(const LLVector3 &ray_start_region,
00581                                                                 const LLVector3 &ray_end_region,
00582                                                                 BOOL bypass_raycast,
00583                                                                 BOOL ray_end_is_intersection,
00584                                                                 const LLUUID &ray_target_id,
00585                                                                 BOOL copy_centers,
00586                                                                 BOOL copy_rotates,
00587                                                                 BOOL select_copy);
00588 
00589         void sendMultipleUpdate(U32 type);      // Position, rotation, scale all in one
00590         void sendOwner(const LLUUID& owner_id, const LLUUID& group_id, BOOL override = FALSE);
00591         void sendGroup(const LLUUID& group_id);
00592 
00593         // Category ID is the UUID of the folder you want to contain the purchase.
00594         // *NOTE: sale_info check doesn't work for multiple object buy,
00595         // which UI does not currently support sale info is used for
00596         // verification only, if it doesn't match region info then sale is
00597         // canceled
00598         void sendBuy(const LLUUID& buyer_id, const LLUUID& category_id, const LLSaleInfo sale_info);
00599         void sendAttach(U8 attachment_point);
00600         void sendDetach();
00601         void sendDropAttachment();
00602         void sendLink();
00603         void sendDelink();
00604         //void sendHinge(U8 type);
00605         //void sendDehinge();
00606         void sendSelect();
00607 
00608         void requestObjectPropertiesFamily(LLViewerObject* object);     // asks sim for creator, permissions, resources, etc.
00609         static void processObjectProperties(LLMessageSystem *mesgsys, void **user_data);
00610         static void processObjectPropertiesFamily(LLMessageSystem *mesgsys, void **user_data);
00611         static void processForceObjectSelect(LLMessageSystem* msg, void**);
00612 
00613         void requestGodInfo();
00614 
00615         LLVector3d              getSelectionCenterGlobal() const        { return mSelectionCenterGlobal; }
00616         void                    updateSelectionCenter();
00617 
00618         void resetAgentHUDZoom();
00619         void setAgentHUDZoom(F32 target_zoom, F32 current_zoom);
00620         void getAgentHUDZoom(F32 &target_zoom, F32 &current_zoom) const;
00621 
00622         void updatePointAt();
00623 
00624         // Internal list maintenance functions. TODO: Make these private!
00625         void remove(std::vector<LLViewerObject*>& objects);
00626         void remove(LLViewerObject* object, S32 te = SELECT_ALL_TES, BOOL undoable = TRUE);
00627         void removeAll();
00628         void addAsIndividual(LLViewerObject* object, S32 te = SELECT_ALL_TES, BOOL undoable = TRUE);
00629         void promoteSelectionToRoot();
00630         void demoteSelectionToIndividuals();
00631 
00632 private:
00633         void convertTransient(); // converts temporarily selected objects to full-fledged selections
00634         ESelectType getSelectTypeForObject(LLViewerObject* object);
00635         void addAsFamily(std::vector<LLViewerObject*>& objects, BOOL add_to_end = FALSE);
00636         void generateSilhouette(LLSelectNode *nodep, const LLVector3& view_point);
00637         // Send one message to each region containing an object on selection list.
00638         void sendListToRegions( const LLString& message_name,
00639                                                         void (*pack_header)(void *user_data), 
00640                                                         void (*pack_body)(LLSelectNode* node, void *user_data), 
00641                                                         void *user_data,
00642                                                         ESendType send_type);
00643 
00644         static void packAgentID(        void *);
00645         static void packAgentAndSessionID(void* user_data);
00646         static void packAgentAndGroupID(void* user_data);
00647         static void packAgentAndSessionAndGroupID(void* user_data);
00648         static void packAgentIDAndSessionAndAttachment(void*);
00649         static void packAgentGroupAndCatID(void*);
00650         static void packDeleteHeader(void* userdata);
00651         static void packDeRezHeader(void* user_data);
00652         static void packObjectID(       LLSelectNode* node, void *);
00653         static void packObjectIDAsParam(LLSelectNode* node, void *);
00654         static void packObjectIDAndRotation(    LLSelectNode* node, void *);
00655         static void packObjectLocalID(LLSelectNode* node, void *);
00656         static void packObjectClickAction(LLSelectNode* node, void* data);
00657         static void packObjectIncludeInSearch(LLSelectNode* node, void* data);
00658         static void packObjectName(LLSelectNode* node, void* user_data);
00659         static void packObjectDescription(LLSelectNode* node, void* user_data);
00660         static void packObjectCategory(LLSelectNode* node, void* user_data);
00661         static void packObjectSaleInfo(LLSelectNode* node, void* user_data);
00662         static void packBuyObjectIDs(LLSelectNode* node, void* user_data);
00663         static void packDuplicate(      LLSelectNode* node, void *duplicate_data);
00664         static void packDuplicateHeader(void*);
00665         static void packDuplicateOnRayHead(void *user_data);
00666         static void packPermissions(LLSelectNode* node, void *user_data);
00667         static void packDeselect(       LLSelectNode* node, void *user_data);
00668         static void packMultipleUpdate(LLSelectNode* node, void *user_data);
00669         static void packPhysics(LLSelectNode* node, void *user_data);
00670         static void packShape(LLSelectNode* node, void *user_data);
00671         static void packOwnerHead(void *user_data);
00672         static void packHingeHead(void *user_data);
00673         static void packPermissionsHead(void* user_data);
00674         static void packGodlikeHead(void* user_data);
00675         static void confirmDelete(S32 option, void* data);
00676         
00677 private:
00678         LLPointer<LLViewerImage>                                mSilhouetteImagep;
00679         LLObjectSelectionHandle                                 mSelectedObjects;
00680         LLObjectSelectionHandle                                 mHoverObjects;
00681         LLObjectSelectionHandle                                 mHighlightedObjects;
00682         std::set<LLPointer<LLViewerObject> >    mRectSelectedObjects;
00683         
00684         LLObjectSelection               mGridObjects;
00685         LLQuaternion                    mGridRotation;
00686         LLVector3                               mGridOrigin;
00687         LLVector3                               mGridScale;
00688         EGridMode                               mGridMode;
00689         BOOL                                    mGridValid;
00690 
00691 
00692         BOOL                                    mTEMode;                        // render te
00693         LLVector3d                              mSelectionCenterGlobal;
00694         LLBBox                                  mSelectionBBox;
00695 
00696         LLVector3d                              mLastSentSelectionCenterGlobal;
00697         BOOL                                    mShowSelection; // do we send the selection center name value and do we animate this selection?
00698         LLVector3d                              mLastCameraPos;         // camera position from last generation of selection silhouette
00699         BOOL                                    mRenderSilhouettes;     // do we render the silhouette
00700         LLBBox                                  mSavedSelectionBBox;
00701 
00702         LLFrameTimer                    mEffectsTimer;
00703         BOOL                                    mForceSelection;
00704 
00705         LLAnimPauseRequest              mPauseRequest;
00706 };
00707 
00708 extern LLSelectMgr* gSelectMgr;
00709 
00710 // Utilities
00711 void dialog_refresh_all();              // Update subscribers to the selection list
00712 
00713 // Templates
00714 //-----------------------------------------------------------------------------
00715 // getSelectedTEValue
00716 //-----------------------------------------------------------------------------
00717 template <typename T> bool LLObjectSelection::getSelectedTEValue(LLSelectedTEGetFunctor<T>* func, T& res)
00718 {
00719         bool have_first = false;
00720         bool have_selected = false;
00721         T selected_value = T();
00722 
00723         // Now iterate through all TEs to test for sameness
00724         bool identical = TRUE;
00725         for (iterator iter = begin(); iter != end(); iter++)
00726         {
00727                 LLSelectNode* node = *iter;
00728                 LLViewerObject* object = node->getObject();
00729                 S32 selected_te = -1;
00730                 if (object == getPrimaryObject())
00731                 {
00732                         selected_te = node->getLastSelectedTE();
00733                 }
00734                 for (S32 te = 0; te < object->getNumTEs(); ++te)
00735                 {
00736                         if (!node->isTESelected(te))
00737                         {
00738                                 continue;
00739                         }
00740                         T value = func->get(object, te);
00741                         if (!have_first)
00742                         {
00743                                 have_first = true;
00744                                 if (!have_selected)
00745                                 {
00746                                         selected_value = value;
00747                                 }
00748                         }
00749                         else
00750                         {
00751                                 if ( value != selected_value )
00752                                 {
00753                                         identical = false;
00754                                 }
00755                                 if (te == selected_te)
00756                                 {
00757                                         selected_value = value;
00758                                         have_selected = true;
00759                                 }
00760                         }
00761                 }
00762                 if (!identical && have_selected)
00763                 {
00764                         break;
00765                 }
00766         }
00767         if (have_first || have_selected)
00768         {
00769                 res = selected_value;
00770         }
00771         return identical;
00772 }
00773 
00774 
00775 #endif

Generated on Thu Jul 1 06:09:10 2010 for Second Life Viewer by  doxygen 1.4.7