llpanelminimap.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /**
  2. * @file llpanelminimap.h (was llnetmap.h)
  3. * @brief Displays agent and surrounding regions, objects, and avatars.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Original code by James Cook. Copyright (c) 2001-2009, Linden Research, Inc.
  8. * Copyright (c) 2009-2022, Henri Beauchamp.
  9. * Changes by Henri Beauchamp:
  10. * - Rewrote and optimized part of the code.
  11. * - Added unknown altitude avatar plot type (the dash-like dot).
  12. * - Allowed both old style (T-like dots) and new style (V-like tiny icons)
  13. * for above/below-agent avatar plots.
  14. * - Added per-avatar dots colouring (via Lua).
  15. * - Added animesh, path-finding and physical objects plotting.
  16. * - Added agent sim borders drawing.
  17. * - _Mostly_ fixed terrain textures never rendering (via changes done in
  18. * llvlcomposition.cpp and in the texture cache) and added a terrain texture
  19. * manual refreshing feature to deal with the cases when they still fail to
  20. * render.
  21. * - Backported (and improved) the optional rendering of banned parcels (from
  22. * LL's viewer) and parcel borders (from LL's viewer for the nice but slow
  23. * algorithm and from Singularity+Catznip for the fast but less pretty one).
  24. * - Added parcel info ("About land" floater) for parcels in the context menu.
  25. *
  26. * Second Life Viewer Source Code
  27. * The source code in this file ("Source Code") is provided by Linden Lab
  28. * to you under the terms of the GNU General Public License, version 2.0
  29. * ("GPL"), unless you have obtained a separate licensing agreement
  30. * ("Other License"), formally executed by you and Linden Lab. Terms of
  31. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  32. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  33. *
  34. * There are special exceptions to the terms and conditions of the GPL as
  35. * it is applied to this Source Code. View the full text of the exception
  36. * in the file doc/FLOSS-exception.txt in this software distribution, or
  37. * online at
  38. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  39. *
  40. * By copying, modifying or distributing this software, you acknowledge
  41. * that you have read and understood your obligations described above,
  42. * and agree to abide by those obligations.
  43. *
  44. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  45. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  46. * COMPLETENESS OR PERFORMANCE.
  47. * $/LicenseInfo$
  48. */
  49. #ifndef LL_LLPANELMINIMAP_H
  50. #define LL_LLPANELMINIMAP_H
  51. #include "llimage.h"
  52. #include "llmemberlistener.h"
  53. #include "llpanel.h"
  54. #include "llvector3.h"
  55. #include "llvector3d.h"
  56. #include "llcolor4.h"
  57. class LLFontGL;
  58. class LLTextBox;
  59. class LLViewerTexture;
  60. class LLViewerRegion;
  61. typedef enum e_minimap_center
  62. {
  63. MAP_CENTER_NONE = 0,
  64. MAP_CENTER_CAMERA = 1
  65. } EMiniMapCenter;
  66. class LLPanelMiniMap final : public LLPanel
  67. {
  68. friend class LLDrawObjects;
  69. friend class LLPlotPuppets;
  70. friend class LLPlotChars;
  71. friend class LLPlotPhysical;
  72. friend class LLDrawParcels;
  73. friend class LLShowParcelInfo;
  74. friend class LLEnableParcelInfo;
  75. public:
  76. LLPanelMiniMap(const std::string& name);
  77. bool postBuild() override;
  78. void draw() override;
  79. void reshape(S32 width, S32 height, bool from_parent = true) override;
  80. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  81. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  82. bool handleHover(S32 x, S32 y, MASK mask) override;
  83. bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
  84. bool handleRightMouseDown(S32 x, S32 y, MASK mask) override;
  85. bool handleScrollWheel(S32 x, S32 y, S32 clicks) override;
  86. bool handleToolTip(S32 x, S32 y, std::string& msg, LLRect* rect) override;
  87. void renderScaledPointGlobal(const LLVector3d& pos, const LLColor4U& color,
  88. F32 radius);
  89. LL_INLINE void addPathFindingCharacter(const LLVector3d& global_pos)
  90. {
  91. mPathfindingCharsPos.emplace_back(global_pos);
  92. }
  93. LL_INLINE void addPhysicalObject(const LLVector3d& global_pos)
  94. {
  95. mPhysicalObjectsPos.emplace_back(global_pos);
  96. }
  97. private:
  98. void setScale(F32 scale);
  99. LL_INLINE void setPan(F32 x, F32 y) { mTargetPanX = x; mTargetPanY = y; }
  100. void renderPoint(const LLVector3 &pos, const LLColor4U& color,
  101. S32 diameter, S32 relative_height = 0);
  102. LLVector3 globalPosToView(const LLVector3d& glob_pos, bool rotated) const;
  103. LLVector3d viewPosToGlobal(S32 x,S32 y, bool rotated) const;
  104. void drawTracking(const LLVector3d& pos_global, bool rotated,
  105. const LLColor4& color, bool draw_arrow = true);
  106. // Note: pos.mV[VZ] is the relative altitude
  107. void drawAvatar(const LLColor4& color, const LLVector3& pos);
  108. void setDirectionPos(LLTextBox* text_box, F32 rotation);
  109. void updateMinorDirections();
  110. LLVector3d getPosCenterGlobal() const;
  111. bool createRawImage(LLPointer<LLImageRaw>& rawimagep);
  112. void createObjectImage();
  113. void createParcelImage();
  114. void updateObjectImage(const LLVector3d& pos_center_global);
  115. void updateParcelImage(const LLVector3d& pos_center_global, LLColor4U c);
  116. void renderParcelBorders(const LLViewerRegion* regionp, const LLColor4U& c,
  117. S32 img_width, S32 img_height);
  118. LL_INLINE bool isAgentUnderCursor() { return mClosestAgentToCursor.notNull(); }
  119. LL_INLINE static bool isAgentUnderCursor(void*)
  120. {
  121. return sInstance && sInstance->mClosestAgentToCursor.notNull();
  122. }
  123. static bool outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y, S32 slop);
  124. static void showAgentProfile(void*);
  125. class LLScaleMap final : public LLMemberListener<LLPanelMiniMap>
  126. {
  127. public:
  128. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  129. const LLSD& userdata) override;
  130. };
  131. class LLCenterMap final : public LLMemberListener<LLPanelMiniMap>
  132. {
  133. public:
  134. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  135. const LLSD& userdata) override;
  136. };
  137. class LLCheckCenterMap final : public LLMemberListener<LLPanelMiniMap>
  138. {
  139. public:
  140. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  141. const LLSD& userdata) override;
  142. };
  143. class LLRotateMap final : public LLMemberListener<LLPanelMiniMap>
  144. {
  145. public:
  146. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  147. const LLSD&) override;
  148. };
  149. class LLCheckRotateMap final : public LLMemberListener<LLPanelMiniMap>
  150. {
  151. public:
  152. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  153. const LLSD& userdata) override;
  154. };
  155. class LLDrawWater final : public LLMemberListener<LLPanelMiniMap>
  156. {
  157. public:
  158. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  159. const LLSD&) override;
  160. };
  161. class LLCheckDrawWater final : public LLMemberListener<LLPanelMiniMap>
  162. {
  163. public:
  164. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  165. const LLSD& userdata) override;
  166. };
  167. class LLDrawObjects final : public LLMemberListener<LLPanelMiniMap>
  168. {
  169. public:
  170. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  171. const LLSD&) override;
  172. };
  173. class LLCheckDrawObjects final : public LLMemberListener<LLPanelMiniMap>
  174. {
  175. public:
  176. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  177. const LLSD& userdata) override;
  178. };
  179. class LLPlotPuppets final : public LLMemberListener<LLPanelMiniMap>
  180. {
  181. public:
  182. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  183. const LLSD&) override;
  184. };
  185. class LLCheckPlotPuppets final : public LLMemberListener<LLPanelMiniMap>
  186. {
  187. public:
  188. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  189. const LLSD& userdata) override;
  190. };
  191. class LLPlotChars final : public LLMemberListener<LLPanelMiniMap>
  192. {
  193. public:
  194. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  195. const LLSD&) override;
  196. };
  197. class LLCheckPlotChars final : public LLMemberListener<LLPanelMiniMap>
  198. {
  199. public:
  200. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  201. const LLSD& userdata) override;
  202. };
  203. class LLEnablePlotChars final : public LLMemberListener<LLPanelMiniMap>
  204. {
  205. public:
  206. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  207. const LLSD& userdata) override;
  208. };
  209. class LLPlotPhysical final : public LLMemberListener<LLPanelMiniMap>
  210. {
  211. public:
  212. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  213. const LLSD&) override;
  214. };
  215. class LLCheckPlotPhysical final : public LLMemberListener<LLPanelMiniMap>
  216. {
  217. public:
  218. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  219. const LLSD& userdata) override;
  220. };
  221. class LLEnablePlotPhysical final : public LLMemberListener<LLPanelMiniMap>
  222. {
  223. public:
  224. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  225. const LLSD& userdata) override;
  226. };
  227. class LLDrawBorders final : public LLMemberListener<LLPanelMiniMap>
  228. {
  229. public:
  230. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  231. const LLSD&) override;
  232. };
  233. class LLCheckDrawBorders final : public LLMemberListener<LLPanelMiniMap>
  234. {
  235. public:
  236. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  237. const LLSD& userdata) override;
  238. };
  239. class LLDrawBans final : public LLMemberListener<LLPanelMiniMap>
  240. {
  241. public:
  242. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  243. const LLSD&) override;
  244. };
  245. class LLCheckDrawBans final : public LLMemberListener<LLPanelMiniMap>
  246. {
  247. public:
  248. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  249. const LLSD& userdata) override;
  250. };
  251. class LLDrawParcels final : public LLMemberListener<LLPanelMiniMap>
  252. {
  253. public:
  254. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  255. const LLSD&) override;
  256. };
  257. class LLCheckDrawParcels final : public LLMemberListener<LLPanelMiniMap>
  258. {
  259. public:
  260. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  261. const LLSD& userdata) override;
  262. };
  263. class LLShowParcelInfo final : public LLMemberListener<LLPanelMiniMap>
  264. {
  265. public:
  266. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  267. const LLSD&) override;
  268. };
  269. class LLEnableParcelInfo final : public LLMemberListener<LLPanelMiniMap>
  270. {
  271. public:
  272. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  273. const LLSD& userdata) override;
  274. };
  275. class LLRefreshTerrain final : public LLMemberListener<LLPanelMiniMap>
  276. {
  277. public:
  278. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  279. const LLSD&) override;
  280. };
  281. class LLStopTracking final : public LLMemberListener<LLPanelMiniMap>
  282. {
  283. public:
  284. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  285. const LLSD&) override;
  286. };
  287. class LLEnableTracking final : public LLMemberListener<LLPanelMiniMap>
  288. {
  289. public:
  290. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  291. const LLSD& userdata) override;
  292. };
  293. class LLShowAgentProfile final : public LLMemberListener<LLPanelMiniMap>
  294. {
  295. public:
  296. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  297. const LLSD&) override;
  298. };
  299. class LLEnableProfile final : public LLMemberListener<LLPanelMiniMap>
  300. {
  301. public:
  302. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  303. const LLSD& userdata) override;
  304. };
  305. class LLDrawLegend final : public LLMemberListener<LLPanelMiniMap>
  306. {
  307. public:
  308. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  309. const LLSD&) override;
  310. };
  311. class LLCheckDrawLegend final : public LLMemberListener<LLPanelMiniMap>
  312. {
  313. public:
  314. bool handleEvent(LLPointer<LLOldEvents::LLEvent>,
  315. const LLSD& userdata) override;
  316. };
  317. public:
  318. static S32 sMiniMapCenter;
  319. static bool sRotateMap;
  320. static bool sMiniMapRotate;
  321. private:
  322. LLHandle<LLView> mPopupMenuHandle;
  323. LLVector3d mPosGlobaltAtLastRightClick;
  324. LLVector3d mObjectImageCenterGlobal;
  325. LLVector3d mParcelImageCenterGlobal;
  326. LLPointer<LLImageRaw> mObjectRawImagep;
  327. LLPointer<LLImageRaw> mParcelRawImagep;
  328. LLPointer<LLViewerTexture> mObjectImagep;
  329. LLPointer<LLViewerTexture> mParcelImagep;
  330. LLTextBox* mNorthLabel;
  331. LLTextBox* mSouthLabel;
  332. LLTextBox* mWestLabel;
  333. LLTextBox* mEastLabel;
  334. LLTextBox* mNorthWestLabel;
  335. LLTextBox* mNorthEastLabel;
  336. LLTextBox* mSouthWestLabel;
  337. LLTextBox* mSouthEastLabel;
  338. LLFontGL* mFontp;
  339. typedef std::vector<LLVector3d> objs_pos_vec_t;
  340. objs_pos_vec_t mPathfindingCharsPos;
  341. objs_pos_vec_t mPhysicalObjectsPos;
  342. LLUUID mClosestAgentToCursor;
  343. LLUUID mClosestAgentAtLastRightClick;
  344. LLColor4 mBackgroundColor;
  345. std::string mMapToolTip;
  346. std::string mRegionPrefix;
  347. std::string mParcelPrefix;
  348. std::string mOwnerPrefix;
  349. std::string mLegendAvatar;
  350. std::string mLegendFriend;
  351. std::string mLegendPhysical;
  352. std::string mLegendPathFinding;
  353. std::string mLegendAnimesh;
  354. S32 mFriendLegendDeltaX;
  355. // Size of a region in pixels
  356. F32 mScale;
  357. // World meters to map pixels
  358. F32 mPixelsPerMeter;
  359. // Texels per meter on map
  360. F32 mObjectMapTPM;
  361. // Width of object map in pixels
  362. F32 mObjectMapPixels;
  363. F32 mDotRadius; // Size of avatar markers
  364. F32 mTargetPanX;
  365. F32 mTargetPanY;
  366. F32 mCurPanX;
  367. F32 mCurPanY;
  368. S32 mMouseDownPanX; // Value at start of drag
  369. S32 mMouseDownPanY; // Value at start of drag
  370. S32 mMouseDownX;
  371. S32 mMouseDownY;
  372. bool mPanning; // Map has been dragged
  373. bool mUpdateObjectImage;
  374. bool mUpdateParcelImage;
  375. bool mHasDrawnParcels;
  376. static LLPanelMiniMap* sInstance;
  377. };
  378. #endif