/indra/newview/lltoolgrab.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 144 lines · 81 code · 35 blank · 28 comment · 0 complexity · f166496a2adf2ac749647275575f8004 MD5 · raw file

  1. /**
  2. * @file lltoolgrab.h
  3. * @brief LLToolGrab class header file
  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_TOOLGRAB_H
  27. #define LL_TOOLGRAB_H
  28. #include "lltool.h"
  29. #include "v3math.h"
  30. #include "llquaternion.h"
  31. #include "llsingleton.h"
  32. #include "lluuid.h"
  33. #include "llviewerwindow.h" // for LLPickInfo
  34. class LLView;
  35. class LLTextBox;
  36. class LLViewerObject;
  37. class LLPickInfo;
  38. // Message utilities
  39. void send_ObjectGrab_message(LLViewerObject* object, const LLPickInfo & pick, const LLVector3 &grab_offset);
  40. void send_ObjectDeGrab_message(LLViewerObject* object, const LLPickInfo & pick);
  41. class LLToolGrab : public LLTool, public LLSingleton<LLToolGrab>
  42. {
  43. public:
  44. LLToolGrab( LLToolComposite* composite = NULL );
  45. ~LLToolGrab();
  46. /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
  47. /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  48. /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  49. /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  50. /*virtual*/ void render(); // 3D elements
  51. /*virtual*/ void draw(); // 2D elements
  52. virtual void handleSelect();
  53. virtual void handleDeselect();
  54. virtual LLViewerObject* getEditingObject();
  55. virtual LLVector3d getEditingPointGlobal();
  56. virtual BOOL isEditing();
  57. virtual void stopEditing();
  58. virtual void onMouseCaptureLost();
  59. BOOL hasGrabOffset() { return TRUE; } // HACK
  60. LLVector3 getGrabOffset(S32 x, S32 y); // HACK
  61. // Capture the mouse and start grabbing.
  62. BOOL handleObjectHit(const LLPickInfo& info);
  63. // Certain grabs should not highlight the "Build" toolbar button
  64. BOOL getHideBuildHighlight() { return mHideBuildHighlight; }
  65. static void pickCallback(const LLPickInfo& pick_info);
  66. private:
  67. LLVector3d getGrabPointGlobal();
  68. void startGrab();
  69. void stopGrab();
  70. void startSpin();
  71. void stopSpin();
  72. void handleHoverSpin(S32 x, S32 y, MASK mask);
  73. void handleHoverActive(S32 x, S32 y, MASK mask);
  74. void handleHoverNonPhysical(S32 x, S32 y, MASK mask);
  75. void handleHoverInactive(S32 x, S32 y, MASK mask);
  76. void handleHoverFailed(S32 x, S32 y, MASK mask);
  77. private:
  78. enum EGrabMode { GRAB_INACTIVE, GRAB_ACTIVE_CENTER, GRAB_NONPHYSICAL, GRAB_LOCKED, GRAB_NOOBJECT };
  79. EGrabMode mMode;
  80. BOOL mVerticalDragging;
  81. BOOL mHitLand;
  82. LLTimer mGrabTimer; // send simulator time between hover movements
  83. LLVector3 mGrabOffsetFromCenterInitial; // meters from CG of object
  84. LLVector3d mGrabHiddenOffsetFromCamera; // in cursor hidden drag, how far is grab offset from camera
  85. LLVector3d mDragStartPointGlobal; // projected into world
  86. LLVector3d mDragStartFromCamera; // drag start relative to camera
  87. LLPickInfo mGrabPick;
  88. S32 mLastMouseX;
  89. S32 mLastMouseY;
  90. S32 mAccumDeltaX; // since cursor hidden, how far have you moved?
  91. S32 mAccumDeltaY;
  92. BOOL mHasMoved; // has mouse moved off center at all?
  93. BOOL mOutsideSlop; // has mouse moved outside center 5 pixels?
  94. BOOL mDeselectedThisClick;
  95. S32 mLastFace;
  96. LLVector2 mLastUVCoords;
  97. LLVector2 mLastSTCoords;
  98. LLVector3 mLastIntersection;
  99. LLVector3 mLastNormal;
  100. LLVector3 mLastBinormal;
  101. LLVector3 mLastGrabPos;
  102. BOOL mSpinGrabbing;
  103. LLQuaternion mSpinRotation;
  104. BOOL mHideBuildHighlight;
  105. };
  106. extern BOOL gGrabBtnVertical;
  107. extern BOOL gGrabBtnSpin;
  108. extern LLTool* gGrabTransientTool;
  109. #endif // LL_TOOLGRAB_H