llviewervisualparam.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * @file llviewervisualparam.cpp
  3. * @brief Implementation of LLViewerVisualParam class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "linden_common.h"
  33. #include "llviewervisualparam.h"
  34. #include "llxmltree.h"
  35. #include "llwearable.h"
  36. //-----------------------------------------------------------------------------
  37. // LLViewerVisualParamInfo class
  38. //-----------------------------------------------------------------------------
  39. LLViewerVisualParamInfo::LLViewerVisualParamInfo()
  40. : mWearableType(LLWearableType::WT_INVALID),
  41. mCrossWearable(false),
  42. mCamDist(0.5f),
  43. mCamAngle(0.f),
  44. mCamElevation(0.f),
  45. mEditGroupDisplayOrder(0),
  46. mSimpleMin(0.f),
  47. mSimpleMax(100.f)
  48. {
  49. }
  50. bool LLViewerVisualParamInfo::parseXml(LLXmlTreeNode* node)
  51. {
  52. llassert(node->hasName("param"));
  53. if (!LLVisualParamInfo::parseXml(node))
  54. {
  55. return false;
  56. }
  57. // VIEWER SPECIFIC PARAMS
  58. std::string wearable;
  59. static LLStdStringHandle wearable_string = LLXmlTree::addAttributeString("wearable");
  60. if(node->getFastAttributeString(wearable_string, wearable))
  61. {
  62. mWearableType = LLWearableType::typeNameToType(wearable);
  63. }
  64. static LLStdStringHandle edit_group_string = LLXmlTree::addAttributeString("edit_group");
  65. if (!node->getFastAttributeString(edit_group_string, mEditGroup))
  66. {
  67. mEditGroup = "";
  68. }
  69. static LLStdStringHandle cross_wearable_string = LLXmlTree::addAttributeString("cross_wearable");
  70. if (!node->getFastAttributeBool(cross_wearable_string, mCrossWearable))
  71. {
  72. mCrossWearable = false;
  73. }
  74. // Optional camera offsets from the current joint center. Used for
  75. // generating "hints" (thumbnails).
  76. static LLStdStringHandle camera_distance_string = LLXmlTree::addAttributeString("camera_distance");
  77. node->getFastAttributeF32(camera_distance_string, mCamDist);
  78. static LLStdStringHandle camera_angle_string = LLXmlTree::addAttributeString("camera_angle");
  79. node->getFastAttributeF32(camera_angle_string, mCamAngle); // in degrees
  80. static LLStdStringHandle camera_elevation_string = LLXmlTree::addAttributeString("camera_elevation");
  81. node->getFastAttributeF32(camera_elevation_string, mCamElevation);
  82. mCamAngle += 180;
  83. static S32 params_loaded = 0;
  84. // By default, parameters are displayed in the order in which they appear
  85. // in the xml file. "edit_group_order" overriddes.
  86. static LLStdStringHandle edit_group_order_string = LLXmlTree::addAttributeString("edit_group_order");
  87. if(!node->getFastAttributeF32(edit_group_order_string, mEditGroupDisplayOrder))
  88. {
  89. mEditGroupDisplayOrder = (F32)params_loaded;
  90. }
  91. ++params_loaded;
  92. return true;
  93. }
  94. //-----------------------------------------------------------------------------
  95. // LLViewerVisualParam class
  96. //-----------------------------------------------------------------------------
  97. LLViewerVisualParam::LLViewerVisualParam()
  98. : LLVisualParam()
  99. {
  100. }
  101. LLViewerVisualParam::LLViewerVisualParam(const LLViewerVisualParam& other)
  102. : LLVisualParam(other)
  103. {
  104. }
  105. bool LLViewerVisualParam::setInfo(LLViewerVisualParamInfo* info)
  106. {
  107. llassert(mInfo == NULL);
  108. if (info->mID < 0)
  109. {
  110. return false;
  111. }
  112. mInfo = info;
  113. mID = info->mID;
  114. setWeight(getDefaultWeight(), false);
  115. return true;
  116. }