llpanelworldmap.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /**
  2. * @file llpanelworldmap.h
  3. * @brief LLPanelWorldMap class header file
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. * Copyright (c) 2009-2021, Henri Beauchamp.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. // View of the global map of the world.
  34. // The data (model) for the global map is in LLWorldMap.
  35. #ifndef LL_LLPANELWORLDMAP_H
  36. #define LL_LLPANELWORLDMAP_H
  37. #include "llpanel.h"
  38. #include "llvector3.h"
  39. #include "llvector3d.h"
  40. #include "llcolor4.h"
  41. #include "llworldmap.h"
  42. constexpr S32 DEFAULT_TRACKING_ARROW_SIZE = 16;
  43. class LLColor4;
  44. class LLItemInfo;
  45. class LLTextBox;
  46. class LLPanelWorldMap final : public LLPanel
  47. {
  48. public:
  49. LLPanelWorldMap(const std::string& name, const LLRect& rect, U32 layer);
  50. static void initClass();
  51. static void cleanupClass();
  52. // Scale and pan are shared across all instances.
  53. static void setScale(F32 scale);
  54. static void setPan(S32 x, S32 y, bool snap = true);
  55. void reshape(S32 width, S32 height, bool call_from_parent = true) override;
  56. void setVisible(bool visible) override;
  57. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  58. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  59. bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
  60. bool handleHover(S32 x, S32 y, MASK mask) override;
  61. bool handleToolTip(S32 x, S32 y, std::string& msg, LLRect* rect) override;
  62. void draw() override;
  63. void drawGenericItems(const LLWorldMap::item_info_list_t& items,
  64. LLUIImagePtr image);
  65. void drawGenericItem(const LLItemInfo& item, LLUIImagePtr image);
  66. void drawImage(const LLVector3d& global_pos, LLUIImagePtr image,
  67. const LLColor4& color = LLColor4::white);
  68. void drawImageStack(const LLVector3d& global_pos, LLUIImagePtr image,
  69. U32 count, F32 offset, const LLColor4& color);
  70. void drawAgents();
  71. void drawEvents();
  72. void drawFrustum();
  73. U32 updateVisibleBlocks();
  74. LLVector3 globalPosToView(const LLVector3d& global_pos);
  75. LLVector3d viewPosToGlobal(S32 x, S32 y);
  76. // Draw the tracking indicator, doing the right thing if it's outside
  77. // the view area.
  78. void drawTracking(const LLVector3d& pos_global, const LLColor4& color,
  79. bool draw_arrow = true,
  80. const std::string& label = std::string(),
  81. const std::string& tooltip = std::string(),
  82. S32 vert_offset = 0);
  83. static void drawTrackingArrow(const LLRect& view_rect, S32 x, S32 y,
  84. const LLColor4& color,
  85. S32 arrow_size = DEFAULT_TRACKING_ARROW_SIZE);
  86. static void drawTrackingCircle(const LLRect& rect, S32 x, S32 y,
  87. const LLColor4& color,
  88. S32 min_thickness, S32 overlap);
  89. static void drawIconName(F32 x_pixels, F32 y_pixels, const LLColor4& color,
  90. const std::string& first_line,
  91. const std::string& second_line);
  92. // Prevents accidental double clicks
  93. LL_INLINE static void clearLastClick() { sHandledLastClick = false; }
  94. LL_INLINE static void setDefaultZ(F32 z) { sDefaultZ = z; }
  95. protected:
  96. bool checkItemHit(S32 x, S32 y, LLItemInfo& item, LLUUID& id, bool track);
  97. void handleClick(S32 x, S32 y, MASK mask, S32& hit_type, LLUUID& id);
  98. void setDirectionPos(LLTextBox* text_box, F32 rotation);
  99. void updateDirections();
  100. public:
  101. LLTextBox* mTextBoxEast;
  102. LLTextBox* mTextBoxNorth;
  103. LLTextBox* mTextBoxWest;
  104. LLTextBox* mTextBoxSouth;
  105. LLTextBox* mTextBoxSouthEast;
  106. LLTextBox* mTextBoxNorthEast;
  107. LLTextBox* mTextBoxNorthWest;
  108. LLTextBox* mTextBoxSouthWest;
  109. LLTextBox* mTextBoxScrollHint;
  110. LLColor4 mBackgroundColor;
  111. U32 mLayer;
  112. S32 mSelectIDStart;
  113. S32 mMouseDownPanX; // value at start of drag
  114. S32 mMouseDownPanY; // value at start of drag
  115. S32 mMouseDownX;
  116. S32 mMouseDownY;
  117. bool mPanning; // Are we mid-pan from a user drag ?
  118. bool mItemPicked;
  119. typedef std::vector<U64> handle_list_t;
  120. handle_list_t mVisibleRegions; // set every frame
  121. static LLUIImagePtr sAvatarSmallImage;
  122. static LLUIImagePtr sAvatarYouImage;
  123. static LLUIImagePtr sAvatarYouLargeImage;
  124. static LLUIImagePtr sAvatarLevelImage;
  125. static LLUIImagePtr sAvatarAboveImage;
  126. static LLUIImagePtr sAvatarBelowImage;
  127. static LLUIImagePtr sTelehubImage;
  128. static LLUIImagePtr sInfohubImage;
  129. static LLUIImagePtr sHomeImage;
  130. static LLUIImagePtr sEventImage;
  131. static LLUIImagePtr sEventMatureImage;
  132. static LLUIImagePtr sEventAdultImage;
  133. static LLUIImagePtr sTrackCircleImage;
  134. static LLUIImagePtr sTrackArrowImage;
  135. static LLUIImagePtr sClassifiedsImage;
  136. static LLUIImagePtr sForSaleImage;
  137. static LLUIImagePtr sForSaleAdultImage;
  138. static F32 sThreshold;
  139. static F32 sPixelsPerMeter; // world meters to map pixels
  140. static F32 sMapScale; // scale = size of a region in pixels
  141. static F32 sPanX; // in pixels
  142. static F32 sPanY; // in pixels
  143. static F32 sTargetPanX; // in pixels
  144. static F32 sTargetPanY; // in pixels
  145. static S32 sTrackingArrowX;
  146. static S32 sTrackingArrowY;
  147. static F32 sDefaultZ; // in meters
  148. static bool sHandledLastClick;
  149. };
  150. #endif