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