PageRenderTime 49ms CodeModel.GetById 15ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewervisualparam.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 164 lines | 78 code | 22 blank | 64 comment | 7 complexity | 170576eac476c3149d0c4077de9cd9fd MD5 | raw file
  1/** 
  2 * @file llviewervisualparam.cpp
  3 * @brief Implementation of LLViewerVisualParam class
  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//-----------------------------------------------------------------------------
 28// Header Files
 29//-----------------------------------------------------------------------------
 30#include "llviewerprecompiledheaders.h"
 31
 32#include "llviewervisualparam.h"
 33#include "llxmltree.h"
 34#include "llui.h"
 35#include "llwearable.h"
 36
 37//-----------------------------------------------------------------------------
 38// LLViewerVisualParamInfo()
 39//-----------------------------------------------------------------------------
 40LLViewerVisualParamInfo::LLViewerVisualParamInfo()
 41	:
 42	mWearableType( LLWearableType::WT_INVALID ),
 43	mCrossWearable(FALSE),
 44	mCamDist( 0.5f ),
 45	mCamAngle( 0.f ),
 46	mCamElevation( 0.f ),
 47	mEditGroupDisplayOrder( 0 ),
 48	mShowSimple(FALSE),
 49	mSimpleMin(0.f),
 50	mSimpleMax(100.f)
 51{
 52}
 53
 54LLViewerVisualParamInfo::~LLViewerVisualParamInfo()
 55{
 56}
 57
 58//-----------------------------------------------------------------------------
 59// parseXml()
 60//-----------------------------------------------------------------------------
 61BOOL LLViewerVisualParamInfo::parseXml(LLXmlTreeNode *node)
 62{
 63	llassert( node->hasName( "param" ) );
 64
 65	if (!LLVisualParamInfo::parseXml(node))
 66		return FALSE;
 67	
 68	// VIEWER SPECIFIC PARAMS
 69	
 70	std::string wearable;
 71	static LLStdStringHandle wearable_string = LLXmlTree::addAttributeString("wearable");
 72	if( node->getFastAttributeString( wearable_string, wearable) )
 73	{
 74		mWearableType = LLWearableType::typeNameToType( wearable );
 75	}
 76
 77	static LLStdStringHandle edit_group_string = LLXmlTree::addAttributeString("edit_group");
 78	if (!node->getFastAttributeString( edit_group_string, mEditGroup))
 79	{
 80		mEditGroup = "";
 81	}
 82
 83	static LLStdStringHandle cross_wearable_string = LLXmlTree::addAttributeString("cross_wearable");
 84	if (!node->getFastAttributeBOOL(cross_wearable_string, mCrossWearable))
 85	{
 86		mCrossWearable = FALSE;
 87	}
 88
 89	// Optional camera offsets from the current joint center.  Used for generating "hints" (thumbnails).
 90	static LLStdStringHandle camera_distance_string = LLXmlTree::addAttributeString("camera_distance");
 91	node->getFastAttributeF32( camera_distance_string, mCamDist );
 92	static LLStdStringHandle camera_angle_string = LLXmlTree::addAttributeString("camera_angle");
 93	node->getFastAttributeF32( camera_angle_string, mCamAngle );	// in degrees
 94	static LLStdStringHandle camera_elevation_string = LLXmlTree::addAttributeString("camera_elevation");
 95	node->getFastAttributeF32( camera_elevation_string, mCamElevation );
 96
 97	mCamAngle += 180;
 98
 99	static S32 params_loaded = 0;
100
101	// By default, parameters are displayed in the order in which they appear in the xml file.
102	// "edit_group_order" overriddes.
103	static LLStdStringHandle edit_group_order_string = LLXmlTree::addAttributeString("edit_group_order");
104	if( !node->getFastAttributeF32( edit_group_order_string, mEditGroupDisplayOrder ) )
105	{
106		mEditGroupDisplayOrder = (F32)params_loaded;
107	}
108
109	params_loaded++;
110	
111	return TRUE;
112}
113
114/*virtual*/ void LLViewerVisualParamInfo::toStream(std::ostream &out)
115{
116	LLVisualParamInfo::toStream(out);
117
118	out << mWearableType << "\t";
119	out << mEditGroup << "\t";
120	out << mEditGroupDisplayOrder << "\t";
121}
122
123//-----------------------------------------------------------------------------
124// LLViewerVisualParam()
125//-----------------------------------------------------------------------------
126LLViewerVisualParam::LLViewerVisualParam()
127{
128}
129
130//-----------------------------------------------------------------------------
131// setInfo()
132//-----------------------------------------------------------------------------
133
134BOOL LLViewerVisualParam::setInfo(LLViewerVisualParamInfo *info)
135{
136	llassert(mInfo == NULL);
137	if (info->mID < 0)
138		return FALSE;
139	mInfo = info;
140	mID = info->mID;
141	setWeight(getDefaultWeight(), FALSE );
142	return TRUE;
143}
144
145/*
146//=============================================================================
147// These virtual functions should always be overridden,
148// but are included here for use as templates
149//=============================================================================
150
151//-----------------------------------------------------------------------------
152// parseData()
153//-----------------------------------------------------------------------------
154BOOL LLViewerVisualParam::parseData(LLXmlTreeNode *node)
155{
156	LLViewerVisualParamInfo* info = new LLViewerVisualParamInfo;
157
158	info->parseXml(node);
159	if (!setInfo(info))
160		return FALSE;
161	
162	return TRUE;
163}
164*/