llmaniptranslate.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * @file llmaniptranslate.h
  3. * @brief LLManipTranslate class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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. #ifndef LL_LLMANIPTRANSLATE_H
  33. #define LL_LLMANIPTRANSLATE_H
  34. #include "llmanip.h"
  35. #include "lltimer.h"
  36. #include "llvector4.h"
  37. #include "llquaternion.h"
  38. class LLManipTranslate final : public LLManip
  39. {
  40. protected:
  41. LOG_CLASS(LLManipTranslate);
  42. public:
  43. class ManipulatorHandle
  44. {
  45. public:
  46. LLVector3 mStartPosition;
  47. LLVector3 mEndPosition;
  48. EManipPart mManipID;
  49. F32 mHotSpotRadius;
  50. ManipulatorHandle(LLVector3 start_pos, LLVector3 end_pos,
  51. EManipPart id, F32 radius)
  52. : mStartPosition(start_pos),
  53. mEndPosition(end_pos),
  54. mManipID(id),
  55. mHotSpotRadius(radius)
  56. {
  57. }
  58. };
  59. LLManipTranslate(LLToolComposite* composite);
  60. static bool getSnapEnabled();
  61. static bool getSnapToMouseCursor();
  62. static F32 getGridDrawSize();
  63. static U32 getGridTexName();
  64. static void destroyGL();
  65. static void restoreGL();
  66. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  67. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  68. bool handleHover(S32 x, S32 y, MASK mask) override;
  69. void render() override;
  70. void handleSelect() override;
  71. void highlightManipulators(S32 x, S32 y) override;
  72. bool handleMouseDownOnPart(S32 x, S32 y, MASK mask) override;
  73. bool canAffectSelection() override;
  74. protected:
  75. enum EHandleType
  76. {
  77. HANDLE_CONE,
  78. HANDLE_BOX,
  79. HANDLE_SPHERE
  80. };
  81. void renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_size,
  82. F32 arrow_size, F32 handle_size, bool reverse_direction);
  83. void renderTranslationHandles();
  84. void renderText();
  85. void renderSnapGuides();
  86. void renderGrid(F32 x, F32 y, F32 size, F32 r, F32 g, F32 b, F32 a);
  87. void renderGridVert(F32 x_trans, F32 y_trans, F32 r, F32 g, F32 b,
  88. F32 alpha);
  89. void highlightIntersection(LLVector3 normal, LLVector3 selection_center,
  90. LLQuaternion grid_rotation,
  91. LLColor4 inner_color);
  92. F32 getMinGridScale();
  93. private:
  94. struct compare_manipulators
  95. {
  96. LL_INLINE bool operator()(const ManipulatorHandle* const a,
  97. const ManipulatorHandle* const b) const
  98. {
  99. if (a->mEndPosition.mV[VZ] != b->mEndPosition.mV[VZ])
  100. {
  101. return (a->mEndPosition.mV[VZ] < b->mEndPosition.mV[VZ]);
  102. }
  103. return a->mManipID < b->mManipID;
  104. }
  105. };
  106. private:
  107. S32 mLastHoverMouseX;
  108. S32 mLastHoverMouseY;
  109. S32 mMouseDownX;
  110. S32 mMouseDownY;
  111. F32 mAxisArrowLength; // pixels
  112. F32 mConeSize; // meters, world space
  113. F32 mArrowLengthMeters; // meters
  114. F32 mPlaneManipOffsetMeters;
  115. F32 mSnapOffsetMeters;
  116. F32 mSubdivisions;
  117. LLVector3 mManipNormal;
  118. LLVector3d mDragCursorStartGlobal;
  119. LLVector3d mDragSelectionStartGlobal;
  120. LLTimer mUpdateTimer;
  121. LLVector4 mManipulatorVertices[18];
  122. LLVector3 mSnapOffsetAxis;
  123. LLQuaternion mGridRotation;
  124. LLVector3 mGridOrigin;
  125. LLVector3 mGridScale;
  126. LLVector3 mArrowScales;
  127. LLVector3 mPlaneScales;
  128. LLVector4 mPlaneManipPositions;
  129. bool mMouseOutsideSlop; // true after mouse goes outside slop region
  130. bool mCopyMadeThisDrag;
  131. bool mInSnapRegime;
  132. };
  133. #endif