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