/* ** This method returns the value as text string. The actual value is ** get with GetValue() so we don't have to worry about m_Invert. ** ** autoScale If true, scale the value automatically to some sensible range. ** scale The scale to use if autoScale is false. ** decimals Number of decimals used in the value. If -1, get rid of ".00000" for dynamic variables. ** percentual Return the value as % from the maximum value. */ const WCHAR* Measure::GetFormattedValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual) { static WCHAR buffer[128]; WCHAR format[32]; if (percentual) { double val = 100.0 * GetRelativeValue(); _snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals); _snwprintf_s(buffer, _TRUNCATE, format, val); } else if (autoScale != AUTOSCALE_OFF) { GetScaledValue(autoScale, decimals, GetValue(), buffer, _countof(buffer)); } else { double val = GetValue() / scale; if (decimals == -1) { int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", val); RemoveTrailingZero(buffer, len); } else { _snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals); _snwprintf_s(buffer, _TRUNCATE, format, val); } } return CheckSubstitute(buffer); }
void AngularMeter::AddMinorTick(double value){ double scaledValue = GetScaledValue(value); if (_minorTicks < MAX_TICKS -1){ _minorTickScaledValues[_minorTicks] = scaledValue; _minorTickRealValues[_minorTicks] = value; _minorTicks++; } }
/* ** This method returns the value as text string. The actual value is ** get with GetValue() so we don't have to worry about m_Invert. ** ** autoScale If true, scale the value automatically to some sensible range. ** scale The scale to use if autoScale is false. ** decimals Number of decimals used in the value. If -1, get rid of ".00000" for dynamic variables. ** percentual Return the value as % from the maximum value. */ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual) { static WCHAR buffer[MAX_LINE_LENGTH]; WCHAR format[32]; if (percentual) { double val = 100.0 * GetRelativeValue(); if (decimals == 0) { _itow_s((int)val, buffer, 10); } else { _snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals); _snwprintf_s(buffer, _TRUNCATE, format, val); } } else if (autoScale != AUTOSCALE_OFF) { GetScaledValue(autoScale, decimals, GetValue(), buffer, _countof(buffer)); } else { double val = GetValue() / scale; if (decimals == 0) { val += (val >= 0) ? 0.5 : -0.5; _snwprintf_s(buffer, _TRUNCATE, L"%lli", (LONGLONG)val); } else if (decimals == -1) { int len = _snwprintf_s(buffer, _TRUNCATE, L"%.5f", val); RemoveTrailingZero(buffer, len); } else { _snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals); _snwprintf_s(buffer, _TRUNCATE, format, val); } } return CheckSubstitute(buffer); }
void AngularMeter::SetAlertThreshold(double val){ _scaledAlertValue = GetScaledValue( val ); _realAlertValue = val; Refresh(); }
void AngularMeter::SetWarningThreshold(double val){ _scaledWarningValue = GetScaledValue( val ); _realWarningValue = val; Refresh(); }
void AngularMeter::SetValue(double val) { _scaledValue = GetScaledValue( val ); _realVal = val; Refresh(); }
void MCvarSlider::OnSliderMoved( int newValue ) { if (_ButtonCvar) { _ButtonCvar->SetValue( GetScaledValue() ); } }