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/llstatgraph.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/llstatgraph.cpp')
-rw-r--r-- | linden/indra/newview/llstatgraph.cpp | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/linden/indra/newview/llstatgraph.cpp b/linden/indra/newview/llstatgraph.cpp new file mode 100644 index 0000000..b2dec08 --- /dev/null +++ b/linden/indra/newview/llstatgraph.cpp | |||
@@ -0,0 +1,170 @@ | |||
1 | /** | ||
2 | * @file llstatgraph.cpp | ||
3 | * @brief Simpler compact stat graph with tooltip | ||
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 "llstatgraph.h" | ||
31 | |||
32 | #include "llmath.h" | ||
33 | #include "llui.h" | ||
34 | #include "llstat.h" | ||
35 | #include "llgl.h" | ||
36 | #include "llglheaders.h" | ||
37 | #include "llviewercontrol.h" | ||
38 | |||
39 | /////////////////////////////////////////////////////////////////////////////////// | ||
40 | |||
41 | LLStatGraph::LLStatGraph(const std::string& name, const LLRect& rect) | ||
42 | : LLView(name, rect, TRUE) | ||
43 | { | ||
44 | mStatp = NULL; | ||
45 | setToolTip(name); | ||
46 | mNumThresholds = 3; | ||
47 | mThresholdColors[0] = LLColor4(0.f, 1.f, 0.f, 1.f); | ||
48 | mThresholdColors[1] = LLColor4(1.f, 1.f, 0.f, 1.f); | ||
49 | mThresholdColors[2] = LLColor4(1.f, 0.f, 0.f, 1.f); | ||
50 | mThresholdColors[3] = LLColor4(1.f, 0.f, 0.f, 1.f); | ||
51 | mThresholds[0] = 50.f; | ||
52 | mThresholds[1] = 75.f; | ||
53 | mThresholds[2] = 100.f; | ||
54 | mMin = 0.f; | ||
55 | mMax = 125.f; | ||
56 | mPerSec = TRUE; | ||
57 | mValue = 0.f; | ||
58 | mPrecision = 0; | ||
59 | } | ||
60 | |||
61 | EWidgetType LLStatGraph::getWidgetType() const | ||
62 | { | ||
63 | return WIDGET_TYPE_STAT_GRAPH; | ||
64 | } | ||
65 | |||
66 | LLString LLStatGraph::getWidgetTag() const | ||
67 | { | ||
68 | return LL_STAT_GRAPH_TAG; | ||
69 | } | ||
70 | |||
71 | void LLStatGraph::draw() | ||
72 | { | ||
73 | if (getVisible()) | ||
74 | { | ||
75 | F32 range, frac; | ||
76 | range = mMax - mMin; | ||
77 | if (mStatp) | ||
78 | { | ||
79 | if (mPerSec) | ||
80 | { | ||
81 | mValue = mStatp->getMeanPerSec(); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | mValue = mStatp->getMean(); | ||
86 | } | ||
87 | } | ||
88 | frac = (mValue - mMin) / range; | ||
89 | frac = llmax(0.f, frac); | ||
90 | frac = llmin(1.f, frac); | ||
91 | |||
92 | if (mUpdateTimer.getElapsedTimeF32() > 0.5f) | ||
93 | { | ||
94 | char format_str[256]; | ||
95 | char tmp_str[256]; | ||
96 | sprintf(format_str, "%%s%%.%df%%s", mPrecision); | ||
97 | sprintf(tmp_str, format_str, mLabel.c_str(), mValue, mUnits.c_str()); | ||
98 | setToolTip(tmp_str); | ||
99 | |||
100 | mUpdateTimer.reset(); | ||
101 | } | ||
102 | |||
103 | LLColor4 color; | ||
104 | |||
105 | S32 i; | ||
106 | for (i = 0; i < mNumThresholds - 1; i++) | ||
107 | { | ||
108 | if (mThresholds[i] > mValue) | ||
109 | { | ||
110 | break; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | //gl_drop_shadow(0, mRect.getHeight(), mRect.getWidth(), 0, | ||
115 | // gColors.getColor("ColorDropShadow"), | ||
116 | // (S32) gSavedSettings.getF32("DropShadowFloater") ); | ||
117 | |||
118 | |||
119 | color = gColors.getColor( "MenuDefaultBgColor" ); | ||
120 | glColor4fv(color.mV); | ||
121 | gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0, TRUE); | ||
122 | |||
123 | glColor4fv(LLColor4::black.mV); | ||
124 | gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0, FALSE); | ||
125 | |||
126 | color = mThresholdColors[i]; | ||
127 | glColor4fv(color.mV); | ||
128 | gl_rect_2d(1, llround(frac*mRect.getHeight()), mRect.getWidth() - 1, 0, TRUE); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | void LLStatGraph::setValue(const F32 value) | ||
133 | { | ||
134 | mValue = value; | ||
135 | } | ||
136 | |||
137 | void LLStatGraph::setMin(const F32 min) | ||
138 | { | ||
139 | mMin = min; | ||
140 | } | ||
141 | |||
142 | void LLStatGraph::setMax(const F32 max) | ||
143 | { | ||
144 | mMax = max; | ||
145 | } | ||
146 | |||
147 | void LLStatGraph::setStat(LLStat *statp) | ||
148 | { | ||
149 | mStatp = statp; | ||
150 | } | ||
151 | |||
152 | void LLStatGraph::setLabel(const char *label) | ||
153 | { | ||
154 | mLabel = label; | ||
155 | } | ||
156 | |||
157 | void LLStatGraph::setUnits(const char *units) | ||
158 | { | ||
159 | mUnits = units; | ||
160 | } | ||
161 | |||
162 | void LLStatGraph::setPrecision(const S32 precision) | ||
163 | { | ||
164 | mPrecision = precision; | ||
165 | } | ||
166 | |||
167 | void LLStatGraph::setThreshold(const S32 i, F32 value) | ||
168 | { | ||
169 | mThresholds[i] = value; | ||
170 | } | ||