aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelvolume.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelvolume.cpp
parentREADME.txt (diff)
downloadmeta-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/llpanelvolume.cpp')
-rw-r--r--linden/indra/newview/llpanelvolume.cpp518
1 files changed, 518 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelvolume.cpp b/linden/indra/newview/llpanelvolume.cpp
new file mode 100644
index 0000000..afda5bd
--- /dev/null
+++ b/linden/indra/newview/llpanelvolume.cpp
@@ -0,0 +1,518 @@
1/**
2 * @file llpanelvolume.cpp
3 * @brief Object editing (position, scale, etc.) in the tools floater
4 *
5 * Copyright (c) 2001-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// file include
31#include "llpanelvolume.h"
32
33// linden library includes
34#include "llclickaction.h"
35#include "lleconomy.h"
36#include "llerror.h"
37#include "llfontgl.h"
38#include "llflexibleobject.h"
39#include "llmaterialtable.h"
40#include "llpermissionsflags.h"
41#include "llstring.h"
42#include "llvolume.h"
43#include "m3math.h"
44#include "material_codes.h"
45
46// project includes
47#include "llagent.h"
48#include "llbutton.h"
49#include "llcheckboxctrl.h"
50#include "llcolorswatch.h"
51#include "llcombobox.h"
52#include "llfirstuse.h"
53#include "llfocusmgr.h"
54#include "llmanipscale.h"
55#include "llpanelinventory.h"
56#include "llpreviewscript.h"
57#include "llresmgr.h"
58#include "llselectmgr.h"
59#include "llspinctrl.h"
60#include "lltextbox.h"
61#include "lltool.h"
62#include "lltoolcomp.h"
63#include "lltoolmgr.h"
64#include "llui.h"
65#include "llviewerobject.h"
66#include "llviewerregion.h"
67#include "llviewerwindow.h"
68#include "llvovolume.h"
69#include "llworld.h"
70#include "pipeline.h"
71#include "viewer.h"
72
73#include "lldrawpool.h"
74#include "llvieweruictrlfactory.h"
75
76// "Features" Tab
77
78BOOL LLPanelVolume::postBuild()
79{
80 // Flexible Objects Parameters
81 {
82 childSetCommitCallback("Flexible1D Checkbox Ctrl",onCommitIsFlexible,this);
83 childSetCommitCallback("FlexNumSections",onCommitFlexible,this);
84 childSetValidate("FlexNumSections",precommitValidate);
85 childSetCommitCallback("FlexGravity",onCommitFlexible,this);
86 childSetValidate("FlexGravity",precommitValidate);
87 childSetCommitCallback("FlexFriction",onCommitFlexible,this);
88 childSetValidate("FlexFriction",precommitValidate);
89 childSetCommitCallback("FlexWind",onCommitFlexible,this);
90 childSetValidate("FlexWind",precommitValidate);
91 childSetCommitCallback("FlexTension",onCommitFlexible,this);
92 childSetValidate("FlexTension",precommitValidate);
93 childSetCommitCallback("FlexForceX",onCommitFlexible,this);
94 childSetValidate("FlexForceX",precommitValidate);
95 childSetCommitCallback("FlexForceY",onCommitFlexible,this);
96 childSetValidate("FlexForceY",precommitValidate);
97 childSetCommitCallback("FlexForceZ",onCommitFlexible,this);
98 childSetValidate("FlexForceZ",precommitValidate);
99 }
100
101 // LIGHT Parameters
102 {
103 childSetCommitCallback("Light Checkbox Ctrl",onCommitIsLight,this);
104 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(this,"colorswatch");
105 if(LightColorSwatch){
106 LightColorSwatch->setOnCancelCallback(onLightCancelColor);
107 LightColorSwatch->setOnSelectCallback(onLightSelectColor);
108 childSetCommitCallback("colorswatch",onCommitLight,this);
109 }
110 childSetCommitCallback("Light Intensity",onCommitLight,this);
111 childSetValidate("Light Intensity",precommitValidate);
112 childSetCommitCallback("Light Radius",onCommitLight,this);
113 childSetValidate("Light Radius",precommitValidate);
114 childSetCommitCallback("Light Falloff",onCommitLight,this);
115 childSetValidate("Light Falloff",precommitValidate);
116 }
117
118 // Start with everyone disabled
119 clearCtrls();
120
121 return TRUE;
122}
123
124LLPanelVolume::LLPanelVolume(const std::string& name)
125 : LLPanel(name)
126{
127 setMouseOpaque(FALSE);
128
129}
130
131
132LLPanelVolume::~LLPanelVolume()
133{
134 // Children all cleaned up by default view destructor.
135}
136
137void LLPanelVolume::getState( )
138{
139 LLViewerObject* objectp = gSelectMgr->getFirstRootObject();
140 LLViewerObject* root_objectp = objectp;
141 if(!objectp)
142 {
143 objectp = gSelectMgr->getFirstObject();
144 // *FIX: shouldn't we just keep the child?
145 if (objectp)
146 {
147 LLViewerObject* parentp = objectp->getSubParent();
148
149 if (parentp)
150 {
151 root_objectp = parentp;
152 }
153 else
154 {
155 root_objectp = objectp;
156 }
157 }
158 }
159
160 LLVOVolume *volobjp = NULL;
161 if ( objectp && (objectp->getPCode() == LL_PCODE_VOLUME))
162 {
163 volobjp = (LLVOVolume *)objectp;
164 }
165
166 if( !objectp )
167 {
168 //forfeit focus
169 if (gFocusMgr.childHasKeyboardFocus(this))
170 {
171 gFocusMgr.setKeyboardFocus(NULL, NULL);
172 }
173
174 // Disable all text input fields
175 clearCtrls();
176
177 return;
178 }
179
180 BOOL owners_identical;
181 LLUUID owner_id;
182 LLString owner_name;
183 owners_identical = gSelectMgr->selectGetOwner(owner_id, owner_name);
184
185 // BUG? Check for all objects being editable?
186 BOOL editable = root_objectp->permModify();
187 BOOL single_volume = gSelectMgr->selectionAllPCode( LL_PCODE_VOLUME )
188 && gSelectMgr->getObjectCount() == 1;
189
190 // Select Single Message
191 if (single_volume)
192 {
193 childSetVisible("edit_object",true);
194 childSetEnabled("edit_object",true);
195 childSetVisible("select_single",false);
196 }
197 else
198 {
199 childSetVisible("edit_object",false);
200 childSetVisible("select_single",true);
201 childSetEnabled("select_single",true);
202 }
203
204 // Light properties
205 BOOL is_light = volobjp && volobjp->getIsLight();
206 childSetValue("Light Checkbox Ctrl",is_light);
207 childSetEnabled("Light Checkbox Ctrl",editable && single_volume && volobjp);
208
209 if (is_light && editable && single_volume)
210 {
211 childSetEnabled("label color",true);
212 //mLabelColor ->setEnabled( TRUE );
213 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(this,"colorswatch");
214 if(LightColorSwatch)
215 {
216 LightColorSwatch->setEnabled( TRUE );
217 LightColorSwatch->setValid( TRUE );
218 LightColorSwatch->set(volobjp->getLightBaseColor());
219 }
220 childSetEnabled("Light Intensity",true);
221 childSetEnabled("Light Radius",true);
222 childSetEnabled("Light Falloff",true);
223
224 childSetValue("Light Intensity",volobjp->getLightIntensity());
225 childSetValue("Light Radius",volobjp->getLightRadius());
226 childSetValue("Light Falloff",volobjp->getLightFalloff());
227
228 mLightSavedColor = volobjp->getLightColor();
229 }
230 else
231 {
232 childSetEnabled("label color",false);
233 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(this,"colorswatch");
234 if(LightColorSwatch)
235 {
236 LightColorSwatch->setEnabled( FALSE );
237 LightColorSwatch->setValid( FALSE );
238 }
239 childSetEnabled("Light Intensity",false);
240 childSetEnabled("Light Radius",false);
241 childSetEnabled("Light Falloff",false);
242 }
243
244 // Flexible properties
245 BOOL is_flexible = volobjp && volobjp->isFlexible();
246 childSetValue("Flexible1D Checkbox Ctrl",is_flexible);
247 if (is_flexible || (volobjp && volobjp->canBeFlexible()))
248 {
249 childSetEnabled("Flexible1D Checkbox Ctrl", editable && single_volume && volobjp);
250 }
251 else
252 {
253 childSetEnabled("Flexible1D Checkbox Ctrl", false);
254 }
255 if (is_flexible && editable && single_volume)
256 {
257 childSetVisible("FlexNumSections",true);
258 childSetVisible("FlexGravity",true);
259 childSetVisible("FlexTension",true);
260 childSetVisible("FlexFriction",true);
261 childSetVisible("FlexWind",true);
262 childSetVisible("FlexForceX",true);
263 childSetVisible("FlexForceY",true);
264 childSetVisible("FlexForceZ",true);
265
266 childSetEnabled("FlexNumSections",true);
267 childSetEnabled("FlexGravity",true);
268 childSetEnabled("FlexTension",true);
269 childSetEnabled("FlexFriction",true);
270 childSetEnabled("FlexWind",true);
271 childSetEnabled("FlexForceX",true);
272 childSetEnabled("FlexForceY",true);
273 childSetEnabled("FlexForceZ",true);
274
275 LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
276
277 childSetValue("FlexNumSections",(F32)attributes->getSimulateLOD());
278 childSetValue("FlexGravity",attributes->getGravity());
279 childSetValue("FlexTension",attributes->getTension());
280 childSetValue("FlexFriction",attributes->getAirFriction());
281 childSetValue("FlexWind",attributes->getWindSensitivity());
282 childSetValue("FlexForceX",attributes->getUserForce().mV[VX]);
283 childSetValue("FlexForceY",attributes->getUserForce().mV[VY]);
284 childSetValue("FlexForceZ",attributes->getUserForce().mV[VZ]);
285 }
286 else
287 {
288 childSetEnabled("FlexNumSections",false);
289 childSetEnabled("FlexGravity",false);
290 childSetEnabled("FlexTension",false);
291 childSetEnabled("FlexFriction",false);
292 childSetEnabled("FlexWind",false);
293 childSetEnabled("FlexForceX",false);
294 childSetEnabled("FlexForceY",false);
295 childSetEnabled("FlexForceZ",false);
296 }
297
298 mObject = objectp;
299 mRootObject = root_objectp;
300}
301
302// static
303BOOL LLPanelVolume::precommitValidate( LLUICtrl* ctrl, void* userdata )
304{
305 // TODO: Richard will fill this in later.
306 return TRUE; // FALSE means that validation failed and new value should not be commited.
307}
308
309
310void LLPanelVolume::refresh()
311{
312 getState();
313 if (mObject.notNull() && mObject->isDead())
314 {
315 mObject = NULL;
316 }
317
318 if (mRootObject.notNull() && mRootObject->isDead())
319 {
320 mRootObject = NULL;
321 }
322}
323
324
325void LLPanelVolume::draw()
326{
327 LLPanel::draw();
328}
329
330// virtual
331void LLPanelVolume::clearCtrls()
332{
333 LLPanel::clearCtrls();
334
335 childSetEnabled("select_single",false);
336 childSetVisible("select_single",true);
337 childSetEnabled("edit_object",false);
338 childSetVisible("edit_object",false);
339 childSetEnabled("Light Checkbox Ctrl",false);
340 childSetEnabled("label color",false);
341 childSetEnabled("label color",false);
342 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(this,"colorswatch");
343 if(LightColorSwatch)
344 {
345 LightColorSwatch->setEnabled( FALSE );
346 LightColorSwatch->setValid( FALSE );
347 }
348 childSetEnabled("Light Intensity",false);
349 childSetEnabled("Light Radius",false);
350 childSetEnabled("Light Falloff",false);
351
352 childSetEnabled("Flexible1D Checkbox Ctrl",false);
353 childSetEnabled("FlexNumSections",false);
354 childSetEnabled("FlexGravity",false);
355 childSetEnabled("FlexTension",false);
356 childSetEnabled("FlexFriction",false);
357 childSetEnabled("FlexWind",false);
358 childSetEnabled("FlexForceX",false);
359 childSetEnabled("FlexForceY",false);
360 childSetEnabled("FlexForceZ",false);
361}
362
363//
364// Static functions
365//
366
367void LLPanelVolume::sendIsLight()
368{
369 LLViewerObject* objectp = mObject;
370 if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
371 {
372 return;
373 }
374 LLVOVolume *volobjp = (LLVOVolume *)objectp;
375
376 BOOL value = childGetValue("Light Checkbox Ctrl");
377 volobjp->setIsLight(value);
378 llinfos << "update light sent" << llendl;
379}
380
381void LLPanelVolume::sendIsFlexible()
382{
383 LLViewerObject* objectp = mObject;
384 if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
385 {
386 return;
387 }
388 LLVOVolume *volobjp = (LLVOVolume *)objectp;
389
390 BOOL is_flexible = childGetValue("Flexible1D Checkbox Ctrl");
391 //BOOL is_flexible = mCheckFlexible1D->get();
392
393 if (is_flexible)
394 {
395 LLFirstUse::useFlexible();
396
397 if (objectp->getClickAction() == CLICK_ACTION_SIT)
398 {
399 gSelectMgr->selectionSetClickAction(CLICK_ACTION_NONE);
400 }
401
402 }
403
404 if (volobjp->setIsFlexible(is_flexible))
405 {
406 mObject->sendShapeUpdate();
407 gSelectMgr->selectionUpdatePhantom(volobjp->flagPhantom());
408 }
409
410 llinfos << "update flexible sent" << llendl;
411}
412
413void LLPanelVolume::onLightCancelColor(LLUICtrl* ctrl, void* userdata)
414{
415 LLPanelVolume* self = (LLPanelVolume*) userdata;
416 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(self,"colorswatch");
417 if(LightColorSwatch)
418 {
419 LightColorSwatch->setColor(self->mLightSavedColor);
420 }
421 onLightSelectColor(NULL, userdata);
422}
423
424void LLPanelVolume::onLightSelectColor(LLUICtrl* ctrl, void* userdata)
425{
426 LLPanelVolume* self = (LLPanelVolume*) userdata;
427 LLViewerObject* objectp = self->mObject;
428 if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
429 {
430 return;
431 }
432 LLVOVolume *volobjp = (LLVOVolume *)objectp;
433
434
435 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(self,"colorswatch");
436 if(LightColorSwatch)
437 {
438 LLColor4 clr = LightColorSwatch->get();
439 LLColor3 clr3( clr );
440 volobjp->setLightColor(clr3);
441 self->mLightSavedColor = clr;
442 }
443}
444
445// static
446void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata )
447{
448 LLPanelVolume* self = (LLPanelVolume*) userdata;
449 LLViewerObject* objectp = self->mObject;
450 if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
451 {
452 return;
453 }
454 LLVOVolume *volobjp = (LLVOVolume *)objectp;
455
456
457 volobjp->setLightIntensity((F32)self->childGetValue("Light Intensity").asReal());
458 volobjp->setLightRadius((F32)self->childGetValue("Light Radius").asReal());
459 volobjp->setLightFalloff((F32)self->childGetValue("Light Falloff").asReal());
460 LLColorSwatchCtrl* LightColorSwatch = gUICtrlFactory->getColorSwatchByName(self,"colorswatch");
461 if(LightColorSwatch)
462 {
463 LLColor4 clr = LightColorSwatch->get();
464 volobjp->setLightColor(LLColor3(clr));
465 }
466}
467
468// static
469void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata )
470{
471 LLPanelVolume* self = (LLPanelVolume*) userdata;
472 self->sendIsLight();
473}
474
475//----------------------------------------------------------------------------
476
477// static
478void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata )
479{
480 LLPanelVolume* self = (LLPanelVolume*) userdata;
481 LLViewerObject* objectp = self->mObject;
482 if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME))
483 {
484 return;
485 }
486
487 LLFlexibleObjectData *attributes = (LLFlexibleObjectData *)objectp->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
488 if (attributes)
489 {
490 LLFlexibleObjectData new_attributes;
491 new_attributes = *attributes;
492
493
494 new_attributes.setSimulateLOD(self->childGetValue("FlexNumSections").asInteger());//(S32)self->mSpinSections->get());
495 new_attributes.setGravity((F32)self->childGetValue("FlexGravity").asReal());
496 new_attributes.setTension((F32)self->childGetValue("FlexTension").asReal());
497 new_attributes.setAirFriction((F32)self->childGetValue("FlexFriction").asReal());
498 new_attributes.setWindSensitivity((F32)self->childGetValue("FlexWind").asReal());
499 F32 fx = (F32)self->childGetValue("FlexForceX").asReal();
500 F32 fy = (F32)self->childGetValue("FlexForceY").asReal();
501 F32 fz = (F32)self->childGetValue("FlexForceZ").asReal();
502 LLVector3 force(fx,fy,fz);
503
504 new_attributes.setUserForce(force);
505 objectp->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, new_attributes, true);
506 }
507
508 // Values may fail validation
509 self->refresh();
510}
511
512// static
513void LLPanelVolume::onCommitIsFlexible( LLUICtrl* ctrl, void* userdata )
514{
515 LLPanelVolume* self = (LLPanelVolume*) userdata;
516 self->sendIsFlexible();
517}
518