lltracker.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * @file lltracker.h
  3. * @brief Container for objects user is tracking.
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewergpl$
  6. *
  7. * Copyright (c) 2003-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. // A singleton class for tracking stuff.
  33. //
  34. // TODO -- LLAvatarTracker functionality should probably be moved
  35. // to the LLTracker class.
  36. #ifndef LL_LLTRACKER_H
  37. #define LL_LLTRACKER_H
  38. #include "llpointer.h"
  39. #include "llstring.h"
  40. #include "lluuid.h"
  41. #include "llvector3d.h"
  42. class LLHUDText;
  43. class LLTracker
  44. {
  45. protected:
  46. LOG_CLASS(LLTracker);
  47. public:
  48. enum ETrackingStatus
  49. {
  50. TRACKING_NOTHING = 0,
  51. TRACKING_AVATAR = 1,
  52. TRACKING_LANDMARK = 2,
  53. TRACKING_LOCATION = 3,
  54. };
  55. enum ETrackingLocationType
  56. {
  57. LOCATION_NOTHING,
  58. LOCATION_EVENT,
  59. LOCATION_ITEM,
  60. };
  61. LLTracker();
  62. ~LLTracker();
  63. // These are static so that they can be used a callbacks
  64. LL_INLINE ETrackingStatus getTrackingStatus() { return mTrackingStatus; }
  65. LL_INLINE ETrackingLocationType getTrackedLocationType() { return mTrackingLocationType; }
  66. LL_INLINE bool isTracking() { return mTrackingStatus != TRACKING_NOTHING; }
  67. LL_INLINE void clearFocus() { mTrackingStatus = TRACKING_NOTHING; }
  68. LL_INLINE const LLUUID& getTrackedLandmarkAssetID() { return mTrackedLandmarkAssetID; }
  69. LL_INLINE const LLUUID& getTrackedLandmarkItemID() { return mTrackedLandmarkItemID; }
  70. void trackAvatar(const LLUUID& avatar_id, const std::string& name);
  71. void trackLandmark(const LLUUID& landmark_asset_id,
  72. const LLUUID& landmark_item_id,
  73. const std::string& name);
  74. void trackLocation(const LLVector3d& pos, const std::string& full_name,
  75. const std::string& tooltip,
  76. ETrackingLocationType location_type = LOCATION_NOTHING);
  77. void stopTracking(bool clear_ui = false);
  78. // Returns global pos of tracked thing
  79. LLVector3d getTrackedPositionGlobal();
  80. bool hasLandmarkPosition();
  81. LL_INLINE const std::string& getTrackedLocationName() { return mTrackedLocationName; }
  82. void drawHUDArrow();
  83. // Draw in-world 3D tracking stuff
  84. void render3D();
  85. bool handleMouseDown(S32 x, S32 y);
  86. LL_INLINE const std::string& getLabel() { return mLabel; }
  87. LL_INLINE const std::string& getToolTip() { return mToolTip; }
  88. protected:
  89. static void renderBeacon(LLVector3d pos_global, const LLColor4& color,
  90. LLHUDText* hud_textp, const std::string& label);
  91. void stopTrackingAvatar(bool clear_ui = false);
  92. void stopTrackingLocation(bool clear_ui = false);
  93. void stopTrackingLandmark(bool clear_ui = false);
  94. void drawMarker(const LLVector3d& pos_global, const LLColor4& color);
  95. void setLandmarkVisited();
  96. void cacheLandmarkPosition();
  97. void purgeBeaconText();
  98. protected:
  99. ETrackingStatus mTrackingStatus;
  100. ETrackingLocationType mTrackingLocationType;
  101. LLPointer<LLHUDText> mBeaconText;
  102. S32 mHUDArrowCenterX;
  103. S32 mHUDArrowCenterY;
  104. LLVector3d mTrackedPositionGlobal;
  105. LLUUID mTrackedLandmarkAssetID;
  106. LLUUID mTrackedLandmarkItemID;
  107. std::string mLabel;
  108. std::string mToolTip;
  109. std::string mTrackedLandmarkName;
  110. std::string mTrackedLocationName;
  111. uuid_vec_t mLandmarkAssetIDList;
  112. uuid_vec_t mLandmarkItemIDList;
  113. bool mIsTrackingLocation;
  114. bool mHasReachedLandmark;
  115. bool mHasLandmarkPosition;
  116. bool mLandmarkHasBeenVisited;
  117. };
  118. extern LLTracker gTracker;
  119. #endif