PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llmanip.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 165 lines | 107 code | 26 blank | 32 comment | 0 complexity | f86de69fb17fda5bc450cdee5835fec0 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmanip.h
  3. * @brief LLManip class definition
  4. *
  5. * $LicenseInfo:firstyear=2001&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. #ifndef LL_MANIP_H
  27. #define LL_MANIP_H
  28. #include "lltool.h"
  29. //#include "v3math.h"
  30. class LLView;
  31. class LLTextBox;
  32. class LLViewerObject;
  33. class LLToolComposite;
  34. class LLVector3;
  35. class LLObjectSelection;
  36. const S32 MIN_DIVISION_PIXEL_WIDTH = 9;
  37. class LLManip : public LLTool
  38. {
  39. public:
  40. typedef enum e_manip_part
  41. {
  42. LL_NO_PART = 0,
  43. // Translation
  44. LL_X_ARROW,
  45. LL_Y_ARROW,
  46. LL_Z_ARROW,
  47. LL_YZ_PLANE,
  48. LL_XZ_PLANE,
  49. LL_XY_PLANE,
  50. // Scale
  51. LL_CORNER_NNN,
  52. LL_CORNER_NNP,
  53. LL_CORNER_NPN,
  54. LL_CORNER_NPP,
  55. LL_CORNER_PNN,
  56. LL_CORNER_PNP,
  57. LL_CORNER_PPN,
  58. LL_CORNER_PPP,
  59. // Faces
  60. LL_FACE_POSZ,
  61. LL_FACE_POSX,
  62. LL_FACE_POSY,
  63. LL_FACE_NEGX,
  64. LL_FACE_NEGY,
  65. LL_FACE_NEGZ,
  66. // Edges
  67. LL_EDGE_NEGX_NEGY,
  68. LL_EDGE_NEGX_POSY,
  69. LL_EDGE_POSX_NEGY,
  70. LL_EDGE_POSX_POSY,
  71. LL_EDGE_NEGY_NEGZ,
  72. LL_EDGE_NEGY_POSZ,
  73. LL_EDGE_POSY_NEGZ,
  74. LL_EDGE_POSY_POSZ,
  75. LL_EDGE_NEGZ_NEGX,
  76. LL_EDGE_NEGZ_POSX,
  77. LL_EDGE_POSZ_NEGX,
  78. LL_EDGE_POSZ_POSX,
  79. // Rotation Manip
  80. LL_ROT_GENERAL,
  81. LL_ROT_X,
  82. LL_ROT_Y,
  83. LL_ROT_Z,
  84. LL_ROT_ROLL
  85. } EManipPart;
  86. // For use in loops and range checking.
  87. typedef enum e_select_part_ranges
  88. {
  89. LL_ARROW_MIN = LL_X_ARROW,
  90. LL_ARROW_MAX = LL_Z_ARROW,
  91. LL_CORNER_MIN = LL_CORNER_NNN,
  92. LL_CORNER_MAX = LL_CORNER_PPP,
  93. LL_FACE_MIN = LL_FACE_POSZ,
  94. LL_FACE_MAX = LL_FACE_NEGZ,
  95. LL_EDGE_MIN = LL_EDGE_NEGX_NEGY,
  96. LL_EDGE_MAX = LL_EDGE_POSZ_POSX
  97. } EManipPartRanges;
  98. public:
  99. static void rebuild(LLViewerObject* vobj);
  100. LLManip( const std::string& name, LLToolComposite* composite );
  101. virtual BOOL handleMouseDownOnPart(S32 x, S32 y, MASK mask) = 0;
  102. void renderGuidelines(BOOL draw_x = TRUE, BOOL draw_y = TRUE, BOOL draw_z = TRUE);
  103. static void renderXYZ(const LLVector3 &vec);
  104. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  105. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  106. virtual void highlightManipulators(S32 x, S32 y) = 0;
  107. virtual void handleSelect();
  108. virtual void handleDeselect();
  109. virtual BOOL canAffectSelection() = 0;
  110. EManipPart getHighlightedPart() { return mHighlightedPart; }
  111. LLSafeHandle<LLObjectSelection> getSelection();
  112. protected:
  113. LLVector3 getSavedPivotPoint() const;
  114. LLVector3 getPivotPoint();
  115. void getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal);
  116. BOOL getManipAxis(LLViewerObject* object, EManipPart manip, LLVector3 &axis);
  117. F32 getSubdivisionLevel(const LLVector3 &reference_point, const LLVector3 &translate_axis, F32 grid_scale, S32 min_pixel_spacing = MIN_DIVISION_PIXEL_WIDTH);
  118. void renderTickValue(const LLVector3& pos, F32 value, const std::string& suffix, const LLColor4 &color);
  119. void renderTickText(const LLVector3& pos, const std::string& suffix, const LLColor4 &color);
  120. void updateGridSettings();
  121. BOOL getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal) const;
  122. BOOL getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal);
  123. BOOL nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param );
  124. LLColor4 setupSnapGuideRenderPass(S32 pass);
  125. protected:
  126. LLFrameTimer mHelpTextTimer;
  127. BOOL mInSnapRegime;
  128. LLSafeHandle<LLObjectSelection> mObjectSelection;
  129. EManipPart mHighlightedPart;
  130. EManipPart mManipPart;
  131. static F32 sHelpTextVisibleTime;
  132. static F32 sHelpTextFadeTime;
  133. static S32 sNumTimesHelpTextShown;
  134. static S32 sMaxTimesShowHelpText;
  135. static F32 sGridMaxSubdivisionLevel;
  136. static F32 sGridMinSubdivisionLevel;
  137. static LLVector2 sTickLabelSpacing;
  138. };
  139. #endif