diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolselectland.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/lltoolselectland.cpp')
-rw-r--r-- | linden/indra/newview/lltoolselectland.cpp | 242 |
1 files changed, 242 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolselectland.cpp b/linden/indra/newview/lltoolselectland.cpp new file mode 100644 index 0000000..c0c0818 --- /dev/null +++ b/linden/indra/newview/lltoolselectland.cpp | |||
@@ -0,0 +1,242 @@ | |||
1 | /** | ||
2 | * @file lltoolselectland.cpp | ||
3 | * @brief LLToolSelectLand class implementation | ||
4 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "lltoolselectland.h" | ||
31 | |||
32 | // indra includes | ||
33 | #include "llparcel.h" | ||
34 | |||
35 | // Viewer includes | ||
36 | #include "llagent.h" | ||
37 | #include "llviewercontrol.h" | ||
38 | #include "llfloatertools.h" | ||
39 | #include "llselectmgr.h" | ||
40 | #include "llstatusbar.h" | ||
41 | #include "lltoolview.h" | ||
42 | #include "llviewerparcelmgr.h" | ||
43 | #include "llviewerwindow.h" | ||
44 | #include "viewer.h" | ||
45 | |||
46 | // Globals | ||
47 | LLToolSelectLand *gToolParcel = NULL; | ||
48 | |||
49 | // | ||
50 | // Member functions | ||
51 | // | ||
52 | |||
53 | LLToolSelectLand::LLToolSelectLand( ) | ||
54 | : LLTool( "Parcel" ), | ||
55 | mDragStartGlobal(), | ||
56 | mDragEndGlobal(), | ||
57 | mDragEndValid(FALSE), | ||
58 | mDragStartX(0), | ||
59 | mDragStartY(0), | ||
60 | mDragEndX(0), | ||
61 | mDragEndY(0), | ||
62 | mMouseOutsideSlop(FALSE), | ||
63 | mWestSouthBottom(), | ||
64 | mEastNorthTop(), | ||
65 | mLastShowParcelOwners(FALSE) | ||
66 | { } | ||
67 | |||
68 | |||
69 | BOOL LLToolSelectLand::handleMouseDown(S32 x, S32 y, MASK mask) | ||
70 | { | ||
71 | BOOL hit_land = gViewerWindow->mousePointOnLandGlobal(x, y, &mDragStartGlobal); | ||
72 | if (hit_land) | ||
73 | { | ||
74 | setMouseCapture( TRUE ); | ||
75 | |||
76 | mDragStartX = x; | ||
77 | mDragStartY = y; | ||
78 | mDragEndX = x; | ||
79 | mDragEndY = y; | ||
80 | |||
81 | mDragEndValid = TRUE; | ||
82 | mDragEndGlobal = mDragStartGlobal; | ||
83 | |||
84 | sanitize_corners(mDragStartGlobal, mDragEndGlobal, mWestSouthBottom, mEastNorthTop); | ||
85 | |||
86 | mWestSouthBottom -= LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); | ||
87 | mEastNorthTop += LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); | ||
88 | |||
89 | roundXY(mWestSouthBottom); | ||
90 | roundXY(mEastNorthTop); | ||
91 | |||
92 | mMouseOutsideSlop = TRUE; //FALSE; | ||
93 | |||
94 | gParcelMgr->deselectLand(); | ||
95 | } | ||
96 | |||
97 | return hit_land; | ||
98 | } | ||
99 | |||
100 | |||
101 | BOOL LLToolSelectLand::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
102 | { | ||
103 | LLVector3d pos_global; | ||
104 | BOOL hit_land = gViewerWindow->mousePointOnLandGlobal(x, y, &pos_global); | ||
105 | if (hit_land) | ||
106 | { | ||
107 | // Auto-select this parcel | ||
108 | gParcelMgr->selectParcelAt( pos_global ); | ||
109 | return TRUE; | ||
110 | } | ||
111 | return FALSE; | ||
112 | } | ||
113 | |||
114 | |||
115 | BOOL LLToolSelectLand::handleMouseUp(S32 x, S32 y, MASK mask) | ||
116 | { | ||
117 | if( hasMouseCapture() ) | ||
118 | { | ||
119 | setMouseCapture( FALSE ); | ||
120 | |||
121 | if (mMouseOutsideSlop && mDragEndValid) | ||
122 | { | ||
123 | // Take the drag start and end locations, then map the southwest | ||
124 | // point down to the next grid location, and the northeast point up | ||
125 | // to the next grid location. | ||
126 | |||
127 | sanitize_corners(mDragStartGlobal, mDragEndGlobal, mWestSouthBottom, mEastNorthTop); | ||
128 | |||
129 | mWestSouthBottom -= LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); | ||
130 | mEastNorthTop += LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); | ||
131 | |||
132 | roundXY(mWestSouthBottom); | ||
133 | roundXY(mEastNorthTop); | ||
134 | |||
135 | // Don't auto-select entire parcel. | ||
136 | gParcelMgr->selectLand( mWestSouthBottom, mEastNorthTop, FALSE ); | ||
137 | } | ||
138 | |||
139 | mMouseOutsideSlop = FALSE; | ||
140 | mDragEndValid = FALSE; | ||
141 | |||
142 | return TRUE; | ||
143 | } | ||
144 | return FALSE; | ||
145 | } | ||
146 | |||
147 | |||
148 | BOOL LLToolSelectLand::handleHover(S32 x, S32 y, MASK mask) | ||
149 | { | ||
150 | if( hasMouseCapture() ) | ||
151 | { | ||
152 | if (mMouseOutsideSlop || outsideSlop(x, y, mDragStartX, mDragStartY)) | ||
153 | { | ||
154 | mMouseOutsideSlop = TRUE; | ||
155 | |||
156 | // Must do this every frame, in case the camera moved or the land moved | ||
157 | // since last frame. | ||
158 | |||
159 | // If doesn't hit land, doesn't change old value | ||
160 | LLVector3d land_global; | ||
161 | BOOL hit_land = gViewerWindow->mousePointOnLandGlobal(x, y, &land_global); | ||
162 | if (hit_land) | ||
163 | { | ||
164 | mDragEndValid = TRUE; | ||
165 | mDragEndGlobal = land_global; | ||
166 | |||
167 | sanitize_corners(mDragStartGlobal, mDragEndGlobal, mWestSouthBottom, mEastNorthTop); | ||
168 | |||
169 | mWestSouthBottom -= LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); | ||
170 | mEastNorthTop += LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); | ||
171 | |||
172 | roundXY(mWestSouthBottom); | ||
173 | roundXY(mEastNorthTop); | ||
174 | |||
175 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (active, land)" << llendl; | ||
176 | gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); | ||
177 | } | ||
178 | else | ||
179 | { | ||
180 | mDragEndValid = FALSE; | ||
181 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (active, no land)" << llendl; | ||
182 | gViewerWindow->getWindow()->setCursor(UI_CURSOR_NO); | ||
183 | } | ||
184 | |||
185 | mDragEndX = x; | ||
186 | mDragEndY = y; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (active, in slop)" << llendl; | ||
191 | gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); | ||
192 | } | ||
193 | } | ||
194 | else | ||
195 | { | ||
196 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (inactive)" << llendl; | ||
197 | gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW); | ||
198 | } | ||
199 | |||
200 | return TRUE; | ||
201 | } | ||
202 | |||
203 | |||
204 | void LLToolSelectLand::render() | ||
205 | { | ||
206 | if( hasMouseCapture() && /*mMouseOutsideSlop &&*/ mDragEndValid) | ||
207 | { | ||
208 | gParcelMgr->renderRect( mWestSouthBottom, mEastNorthTop ); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | void LLToolSelectLand::handleSelect() | ||
213 | { | ||
214 | gFloaterTools->setStatusText("Click and drag to select land"); | ||
215 | mLastShowParcelOwners = gSavedSettings.getBOOL("ShowParcelOwners"); | ||
216 | gSavedSettings.setBOOL("ShowParcelOwners", TRUE); | ||
217 | } | ||
218 | |||
219 | |||
220 | void LLToolSelectLand::handleDeselect() | ||
221 | { | ||
222 | gFloaterTools->setStatusText(""); | ||
223 | //gParcelMgr->deselectLand(); | ||
224 | gSavedSettings.setBOOL("ShowParcelOwners", mLastShowParcelOwners); | ||
225 | } | ||
226 | |||
227 | |||
228 | void LLToolSelectLand::roundXY(LLVector3d &vec) | ||
229 | { | ||
230 | vec.mdV[VX] = llround( vec.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); | ||
231 | vec.mdV[VY] = llround( vec.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); | ||
232 | } | ||
233 | |||
234 | |||
235 | // true if x,y outside small box around start_x,start_y | ||
236 | BOOL LLToolSelectLand::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y) | ||
237 | { | ||
238 | S32 dx = x - start_x; | ||
239 | S32 dy = y - start_y; | ||
240 | |||
241 | return (dx <= -2 || 2 <= dx || dy <= -2 || 2 <= dy); | ||
242 | } | ||