diff options
Diffstat (limited to 'indra/newview/llselectmgr.h')
-rw-r--r-- | indra/newview/llselectmgr.h | 193 |
1 files changed, 123 insertions, 70 deletions
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 992cc1e906..7478ed5f9a 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -2,31 +2,25 @@ * @file llselectmgr.h * @brief A manager for selected objects and TEs. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -35,7 +29,6 @@ #include "llcharacter.h" #include "lleditmenuhandler.h" -#include "llstring.h" #include "llundo.h" #include "lluuid.h" #include "llpointer.h" @@ -48,14 +41,15 @@ #include "llframetimer.h" #include "llbbox.h" #include "llpermissions.h" -#include "llviewerobject.h" #include "llcontrol.h" +#include "llviewerobject.h" // LLObjectSelection::getSelectedTEValue template + #include <deque> -#include "boost/iterator/filter_iterator.hpp" +#include <boost/iterator/filter_iterator.hpp> +#include <boost/signals2.hpp> class LLMessageSystem; -class LLViewerImage; -class LLViewerObject; +class LLViewerTexture; class LLColor4; class LLVector3; class LLSelectNode; @@ -139,6 +133,7 @@ public: void selectTE(S32 te_index, BOOL selected); BOOL isTESelected(S32 te_index); S32 getLastSelectedTE(); + S32 getTESelectMask() { return mTESelectMask; } void renderOneSilhouette(const LLColor4 &color); void setTransient(BOOL transient) { mTransient = transient; } BOOL isTransient() { return mTransient; } @@ -146,7 +141,7 @@ public: void setObject(LLViewerObject* object); // *NOTE: invalidate stored textures and colors when # faces change void saveColors(); - void saveTextures(const std::vector<LLUUID>& textures); + void saveTextures(const uuid_vec_t& textures); void saveTextureScaleRatios(); BOOL allowOperationOnNode(PermissionBit op, U64 group_proxy_power) const; @@ -182,7 +177,7 @@ public: std::string mSitName; U64 mCreationDate; std::vector<LLColor4> mSavedColors; - std::vector<LLUUID> mSavedTextures; + uuid_vec_t mSavedTextures; std::vector<LLVector3> mTextureScaleRatios; std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object @@ -191,7 +186,7 @@ public: protected: LLPointer<LLViewerObject> mObject; - BOOL mTESelected[SELECT_MAX_TES]; + S32 mTESelectMask; S32 mLastTESelected; }; @@ -202,13 +197,9 @@ class LLObjectSelection : public LLRefCount protected: ~LLObjectSelection(); - // List public: typedef std::list<LLSelectNode*> list_t; -private: - list_t mList; -public: // Iterators struct is_non_null { @@ -234,11 +225,7 @@ public: struct is_root { - bool operator()(LLSelectNode* node) - { - LLViewerObject* object = node->getObject(); - return (object != NULL) && !node->mIndividualSelection && (object->isRootEdit() || object->isJointChild()); - } + bool operator()(LLSelectNode* node); }; typedef boost::filter_iterator<is_root, list_t::iterator > root_iterator; root_iterator root_begin() { return root_iterator(mList.begin(), mList.end()); } @@ -246,11 +233,7 @@ public: struct is_valid_root { - bool operator()(LLSelectNode* node) - { - LLViewerObject* object = node->getObject(); - return (object != NULL) && node->mValid && !node->mIndividualSelection && (object->isRootEdit() || object->isJointChild()); - } + bool operator()(LLSelectNode* node); }; typedef boost::filter_iterator<is_root, list_t::iterator > valid_root_iterator; valid_root_iterator valid_root_begin() { return valid_root_iterator(mList.begin(), mList.end()); } @@ -258,11 +241,7 @@ public: struct is_root_object { - bool operator()(LLSelectNode* node) - { - LLViewerObject* object = node->getObject(); - return (object != NULL) && (object->isRootEdit() || object->isJointChild()); - } + bool operator()(LLSelectNode* node); }; typedef boost::filter_iterator<is_root_object, list_t::iterator > root_object_iterator; root_object_iterator root_object_begin() { return root_object_iterator(mList.begin(), mList.end()); } @@ -272,7 +251,6 @@ public: LLObjectSelection(); void updateEffects(); - void cleanupNodes(); BOOL isEmpty() const; @@ -288,16 +266,14 @@ public: LLViewerObject* getFirstCopyableObject(BOOL get_parent = FALSE); LLViewerObject* getFirstDeleteableObject(); LLViewerObject* getFirstMoveableObject(BOOL get_parent = FALSE); + + /// Return the object that lead to this selection, possible a child LLViewerObject* getPrimaryObject() { return mPrimaryObject; } // iterate through texture entries template <typename T> bool getSelectedTEValue(LLSelectedTEGetFunctor<T>* func, T& res); - - void addNode(LLSelectNode *nodep); - void addNodeAtEnd(LLSelectNode *nodep); - void moveNodeToFront(LLSelectNode *nodep); - void removeNode(LLSelectNode *nodep); - void deleteAllNodes(); // Delete all nodes + template <typename T> bool isMultipleTEValue(LLSelectedTEGetFunctor<T>* func, const T& ignore_value); + S32 getNumNodes(); LLSelectNode* findNode(LLViewerObject* objectp); @@ -306,6 +282,7 @@ public: S32 getTECount(); S32 getRootObjectCount(); + BOOL isMultipleTESelected(); BOOL contains(LLViewerObject* object); BOOL contains(LLViewerObject* object, S32 te); @@ -324,6 +301,16 @@ public: ESelectType getSelectType() const { return mSelectType; } private: + void addNode(LLSelectNode *nodep); + void addNodeAtEnd(LLSelectNode *nodep); + void moveNodeToFront(LLSelectNode *nodep); + void removeNode(LLSelectNode *nodep); + void deleteAllNodes(); + void cleanupNodes(); + + +private: + list_t mList; const LLObjectSelection &operator=(const LLObjectSelection &); LLPointer<LLViewerObject> mPrimaryObject; @@ -333,6 +320,11 @@ private: typedef LLSafeHandle<LLObjectSelection> LLObjectSelectionHandle; +// Build time optimization, generate this once in .cpp file +#ifndef LLSELECTMGR_CPP +extern template class LLSelectMgr* LLSingleton<class LLSelectMgr>::getInstance(); +#endif + class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr> { public: @@ -355,6 +347,7 @@ public: static LLColor4 sContextSilhouetteColor; LLCachedControl<bool> mHideSelectedObjects; + LLCachedControl<bool> mRenderHighlightSelections; LLCachedControl<bool> mAllowSelectAvatar; LLCachedControl<bool> mDebugSelectMgr; @@ -396,20 +389,25 @@ public: // Add //////////////////////////////////////////////////////////////// - // For when you want just a child object. - LLObjectSelectionHandle selectObjectOnly(LLViewerObject* object, S32 face = SELECT_ALL_TES); - // This method is meant to select an object, and then select all - // of the ancestors and descendents. This should be the normal behavior. + // of the ancestors and descendants. This should be the normal behavior. + // + // *NOTE: You must hold on to the object selection handle, otherwise + // the objects will be automatically deselected in 1 frame. LLObjectSelectionHandle selectObjectAndFamily(LLViewerObject* object, BOOL add_to_end = FALSE); + // For when you want just a child object. + LLObjectSelectionHandle selectObjectOnly(LLViewerObject* object, S32 face = SELECT_ALL_TES); + // Same as above, but takes a list of objects. Used by rectangle select. LLObjectSelectionHandle selectObjectAndFamily(const std::vector<LLViewerObject*>& object_list, BOOL send_to_sim = TRUE); // converts all objects currently highlighted to a selection, and returns it LLObjectSelectionHandle selectHighlightedObjects(); - LLObjectSelectionHandle setHoverObject(LLViewerObject *objectp); + LLObjectSelectionHandle setHoverObject(LLViewerObject *objectp, S32 face = -1); + LLSelectNode *getHoverNode(); + LLSelectNode *getPrimaryHoverNode(); void highlightObjectOnly(LLViewerObject *objectp); void highlightObjectAndFamily(LLViewerObject *objectp); @@ -444,14 +442,11 @@ public: //////////////////////////////////////////////////////////////// // Selection accessors //////////////////////////////////////////////////////////////// - LLObjectSelectionHandle getHoverObjects() { return mHoverObjects; } LLObjectSelectionHandle getSelection() { return mSelectedObjects; } // right now this just renders the selection with root/child colors instead of a single color LLObjectSelectionHandle getEditSelection() { convertTransient(); return mSelectedObjects; } LLObjectSelectionHandle getHighlightedObjects() { return mHighlightedObjects; } - LLSelectNode *getHoverNode(); - //////////////////////////////////////////////////////////////// // Grid manipulation //////////////////////////////////////////////////////////////// @@ -505,7 +500,7 @@ public: void selectionSetTexGen( U8 texgen ); void selectionSetShiny( U8 shiny ); void selectionSetFullbright( U8 fullbright ); - void selectionSetMediaTypeAndURL( U8 media_type, const std::string& media_url ); + void selectionSetMedia( U8 media_type, const LLSD &media_data ); void selectionSetClickAction(U8 action); void selectionSetIncludeInSearch(bool include_in_search); void selectionSetGlow(const F32 glow); @@ -537,6 +532,7 @@ public: // Returns TRUE if the viewer has information on all selected objects BOOL selectGetAllRootsValid(); BOOL selectGetAllValid(); + BOOL selectGetAllValidAndObjectsFound(); // returns TRUE if you can modify all selected objects. BOOL selectGetRootsModify(); @@ -611,7 +607,7 @@ public: // verification only, if it doesn't match region info then sale is // canceled void sendBuy(const LLUUID& buyer_id, const LLUUID& category_id, const LLSaleInfo sale_info); - void sendAttach(U8 attachment_point); + void sendAttach(U8 attachment_point, bool replace); void sendDetach(); void sendDropAttachment(); void sendLink(); @@ -649,6 +645,7 @@ private: ESelectType getSelectTypeForObject(LLViewerObject* object); void addAsFamily(std::vector<LLViewerObject*>& objects, BOOL add_to_end = FALSE); void generateSilhouette(LLSelectNode *nodep, const LLVector3& view_point); + void updateSelectionSilhouette(LLObjectSelectionHandle object_handle, S32& num_sils_genned, std::vector<LLViewerObject*>& changed_objects); // Send one message to each region containing an object on selection list. void sendListToRegions( const std::string& message_name, void (*pack_header)(void *user_data), @@ -656,6 +653,7 @@ private: void *user_data, ESendType send_type); + static void packAgentID( void *); static void packAgentAndSessionID(void* user_data); static void packAgentAndGroupID(void* user_data); @@ -666,7 +664,7 @@ private: static void packDeRezHeader(void* user_data); static void packObjectID( LLSelectNode* node, void *); static void packObjectIDAsParam(LLSelectNode* node, void *); - static void packObjectIDAndRotation( LLSelectNode* node, void *); + static void packObjectIDAndRotation(LLSelectNode* node, void *); static void packObjectLocalID(LLSelectNode* node, void *); static void packObjectClickAction(LLSelectNode* node, void* data); static void packObjectIncludeInSearch(LLSelectNode* node, void* data); @@ -688,9 +686,15 @@ private: static void packPermissionsHead(void* user_data); static void packGodlikeHead(void* user_data); static bool confirmDelete(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle); - + +public: + // Observer/callback support for when object selection changes or + // properties are received/updated + typedef boost::signals2::signal< void ()> update_signal_t; + update_signal_t mUpdateSignal; + private: - LLPointer<LLViewerImage> mSilhouetteImagep; + LLPointer<LLViewerTexture> mSilhouetteImagep; LLObjectSelectionHandle mSelectedObjects; LLObjectSelectionHandle mHoverObjects; LLObjectSelectionHandle mHighlightedObjects; @@ -720,8 +724,10 @@ private: LLAnimPauseRequest mPauseRequest; }; -// Utilities -void dialog_refresh_all(); // Update subscribers to the selection list +// *DEPRECATED: For callbacks or observers, use +// LLSelectMgr::getInstance()->mUpdateSignal.connect( callback ) +// Update subscribers to the selection list +void dialog_refresh_all(); // Templates //----------------------------------------------------------------------------- @@ -784,5 +790,52 @@ template <typename T> bool LLObjectSelection::getSelectedTEValue(LLSelectedTEGet return identical; } +// Templates +//----------------------------------------------------------------------------- +// isMultipleTEValue iterate through all TEs and test for uniqueness +// with certain return value ignored when performing the test. +// e.g. when testing if the selection has a unique non-empty homeurl : +// you can set ignore_value = "" and it will only compare among the non-empty +// homeUrls and ignore the empty ones. +//----------------------------------------------------------------------------- +template <typename T> bool LLObjectSelection::isMultipleTEValue(LLSelectedTEGetFunctor<T>* func, const T& ignore_value) +{ + bool have_first = false; + T selected_value = T(); + + // Now iterate through all TEs to test for sameness + bool unique = TRUE; + for (iterator iter = begin(); iter != end(); iter++) + { + LLSelectNode* node = *iter; + LLViewerObject* object = node->getObject(); + for (S32 te = 0; te < object->getNumTEs(); ++te) + { + if (!node->isTESelected(te)) + { + continue; + } + T value = func->get(object, te); + if(value == ignore_value) + { + continue; + } + if (!have_first) + { + have_first = true; + } + else + { + if (value !=selected_value ) + { + unique = false; + return !unique; + } + } + } + } + return !unique; +} + #endif |