PageRenderTime 43ms CodeModel.GetById 20ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/lltracker.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 154 lines | 90 code | 31 blank | 33 comment | 2 complexity | 391cce70b1a7916ce4ef31a8a4fbd6f1 MD5 | raw file
  1/** 
  2 * @file lltracker.h
  3 * @brief Container for objects user is tracking.
  4 *
  5 * $LicenseInfo:firstyear=2003&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
 27// A singleton class for tracking stuff.
 28//
 29// TODO -- LLAvatarTracker functionality should probably be moved
 30// to the LLTracker class. 
 31
 32
 33#ifndef LL_LLTRACKER_H
 34#define LL_LLTRACKER_H
 35
 36#include "lldarray.h"
 37#include "llpointer.h"
 38#include "llstring.h"
 39#include "lluuid.h"
 40#include "v3dmath.h"
 41
 42class LLHUDText;
 43
 44
 45class LLTracker
 46{
 47public:
 48	enum ETrackingStatus
 49	{
 50		TRACKING_NOTHING = 0,
 51		TRACKING_AVATAR = 1,
 52		TRACKING_LANDMARK = 2,
 53		TRACKING_LOCATION = 3,
 54	};
 55
 56	enum ETrackingLocationType
 57	{
 58		LOCATION_NOTHING,
 59		LOCATION_EVENT,
 60		LOCATION_ITEM,
 61	};
 62
 63	static LLTracker* instance() 
 64	{ 
 65		if (!sTrackerp)
 66		{
 67			sTrackerp = new LLTracker();
 68		}
 69		return sTrackerp; 
 70	}
 71
 72	static void cleanupInstance() { delete sTrackerp; sTrackerp = NULL; }
 73
 74	//static void drawTrackerArrow(); 
 75	// these are static so that they can be used a callbacks
 76	static ETrackingStatus getTrackingStatus() { return instance()->mTrackingStatus; }
 77	static ETrackingLocationType getTrackedLocationType() { return instance()->mTrackingLocationType; }
 78	static BOOL isTracking(void*) { return instance()->mTrackingStatus != TRACKING_NOTHING; }
 79	static void stopTracking(void*);
 80	static void clearFocus();
 81	
 82	static const LLUUID& getTrackedLandmarkAssetID() { return instance()->mTrackedLandmarkAssetID; }
 83	static const LLUUID& getTrackedLandmarkItemID()	 { return instance()->mTrackedLandmarkItemID; }
 84
 85	static void	trackAvatar( const LLUUID& avatar_id, const std::string& name );
 86	static void	trackLandmark( const LLUUID& landmark_asset_id, const LLUUID& landmark_item_id , const std::string& name);
 87	static void	trackLocation(const LLVector3d& pos, const std::string& full_name, const std::string& tooltip, ETrackingLocationType location_type = LOCATION_NOTHING);
 88
 89	// returns global pos of tracked thing
 90	static LLVector3d 	getTrackedPositionGlobal();
 91
 92	static BOOL 		hasLandmarkPosition();
 93	static const std::string& getTrackedLocationName();
 94
 95	static void drawHUDArrow();
 96
 97	// Draw in-world 3D tracking stuff
 98	static void	render3D();
 99
100	static BOOL handleMouseDown(S32 x, S32 y);
101
102	static LLTracker* sTrackerp;
103	static BOOL sCheesyBeacon;
104	
105	static const std::string& getLabel() { return instance()->mLabel; }
106	static const std::string& getToolTip() { return instance()->mToolTip; }
107protected:
108	LLTracker();
109	~LLTracker();
110
111	static void renderBeacon( LLVector3d pos_global, 
112							 const LLColor4& color, 
113							 LLHUDText* hud_textp, 
114							 const std::string& label );
115
116	void stopTrackingAll(BOOL clear_ui = FALSE);
117	void stopTrackingAvatar(BOOL clear_ui = FALSE);
118	void stopTrackingLocation(BOOL clear_ui = FALSE);
119	void stopTrackingLandmark(BOOL clear_ui = FALSE);
120
121	void drawMarker(const LLVector3d& pos_global, const LLColor4& color);
122	void setLandmarkVisited();
123	void cacheLandmarkPosition();
124	void purgeBeaconText();
125
126protected:
127	ETrackingStatus 		mTrackingStatus;
128	ETrackingLocationType	mTrackingLocationType;
129	LLPointer<LLHUDText>	mBeaconText;
130	S32 mHUDArrowCenterX;
131	S32 mHUDArrowCenterY;
132
133	LLVector3d				mTrackedPositionGlobal;
134
135	std::string				mLabel;
136	std::string				mToolTip;
137
138	std::string				mTrackedLandmarkName;
139	LLUUID					mTrackedLandmarkAssetID;
140	LLUUID					mTrackedLandmarkItemID;
141	LLDynamicArray<LLUUID>	mLandmarkAssetIDList;
142	LLDynamicArray<LLUUID>	mLandmarkItemIDList;
143	BOOL					mHasReachedLandmark;
144	BOOL 					mHasLandmarkPosition;
145	BOOL					mLandmarkHasBeenVisited;
146
147	std::string				mTrackedLocationName;
148	BOOL					mIsTrackingLocation;
149	BOOL					mHasReachedLocation;
150};
151
152
153#endif
154