PageRenderTime 28ms CodeModel.GetById 14ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

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