Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More natural logarithmic scale

  • Loading branch information...
commit 322021c64820b2135101bf02d265329be1bef5cc 1 parent 6db15fd
@kuzmas kuzmas authored
View
10 razorqt-panel/plugin-sysstat/razorsysstat.cpp
@@ -135,7 +135,9 @@ void RazorSysStatContent::updateSettings(const QSettings &settings)
netTransmittedColour = QColor(settings.value("net/transmittedColour", "0x808000").toString().toInt(NULL, 0) | 0xff000000);
netMaximumSpeed = PluginSysStat::netSpeedFromString(settings.value("net/maximumSpeed", "1 MB/s").toString());
logarithmicScale = settings.value("net/logarithmicScale", true).toBool();
- logarithmicScaleValue = settings.value("net/logarithmicScaleValue", 1.0).toDouble();
+
+ logScaleSteps = settings.value("net/logarithmicScaleSteps", 4).toInt();
+ logScaleMax = static_cast<qreal>(static_cast<int64_t>(1) << logScaleSteps);
netRealMaximumSpeed = static_cast<qreal>(static_cast<int64_t>(1) << netMaximumSpeed);
@@ -320,7 +322,7 @@ void RazorSysStatContent::swapUpdate(float used)
int height = historyImage[imageIndex].height() - titleFontPixelHeight;
int y_used = height - height * used + 0.5;
- drawLine(imageIndex, x, 0, y_used, bgColour);
+ drawLine(imageIndex, x, 0, y_used, bgColour);
drawLine(imageIndex, x, y_used, height, swapUsedColour);
++historyOffset;
@@ -341,8 +343,8 @@ void RazorSysStatContent::networkUpdate(unsigned received, unsigned transmitted)
qreal max_value = qMin(qMax(static_cast<qreal>(qMax(received, transmitted)) / netRealMaximumSpeed, 0.0), 1.0);
if (logarithmicScale)
{
- min_value = qLn(min_value * (qPow(M_E, logarithmicScaleValue) - 1.0) + 1.0) / logarithmicScaleValue;
- max_value = qLn(max_value * (qPow(M_E, logarithmicScaleValue) - 1.0) + 1.0) / logarithmicScaleValue;
+ min_value = qLn(min_value * (logScaleMax - 1.0) + 1.0) / qLn(2.0) / static_cast<qreal>(logScaleSteps);
+ max_value = qLn(max_value * (logScaleMax - 1.0) + 1.0) / qLn(2.0) / static_cast<qreal>(logScaleSteps);
}
int y_min = height - height * min_value + 0.5;
int y_max = height - height * max_value + 0.5;
View
3  razorqt-panel/plugin-sysstat/razorsysstat.h
@@ -114,7 +114,8 @@ protected slots:
int netMaximumSpeed;
qreal netRealMaximumSpeed;
bool logarithmicScale;
- double logarithmicScaleValue;
+ int logScaleSteps;
+ qreal logScaleMax;
int historyOffset;
QImage historyImage[2];
View
5 razorqt-panel/plugin-sysstat/razorsysstatconfiguration.cpp
@@ -137,8 +137,7 @@ void RazorSysStatConfiguration::loadSettings()
ui->maximumHS->setValue(PluginSysStat::netSpeedFromString(mSettings.value("net/maximumSpeed", "1 MB/s").toString()));
on_maximumHS_valueChanged(ui->maximumHS->value());
ui->logarithmicCB->setChecked(mSettings.value("net/logarithmicScale", true).toBool());
- ui->logScaleSB->setValue(mSettings.value("net/logarithmicScaleValue", 1.0).toDouble());
-
+ ui->logScaleSB->setValue(mSettings.value("net/logarithmicScaleSteps", 4).toInt());
lockSaving = false;
}
@@ -181,7 +180,7 @@ void RazorSysStatConfiguration::saveSettings()
mSettings.setValue("net/transmittedColour", QString("0x%1").arg(ui->netTransmittedF->palette().color(QPalette::Window).rgb() & 0x00ffffff, 6, 16, QChar('0')));
mSettings.setValue("net/maximumSpeed", PluginSysStat::netSpeedToString(ui->maximumHS->value()));
mSettings.setValue("net/logarithmicScale", ui->logarithmicCB->isChecked());
- mSettings.setValue("net/logarithmicScaleValue", ui->logScaleSB->value());
+ mSettings.setValue("net/logarithmicScaleSteps", ui->logScaleSB->value());
}
void RazorSysStatConfiguration::dialogButtonsAction(QAbstractButton *btn)
View
49 razorqt-panel/plugin-sysstat/razorsysstatconfiguration.ui
@@ -972,21 +972,18 @@
</layout>
</item>
<item row="3" column="1">
- <widget class="QDoubleSpinBox" name="logScaleSB">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="decimals">
- <number>1</number>
+ <widget class="QSpinBox" name="logScaleSB">
+ <property name="suffix">
+ <string> steps</string>
</property>
<property name="minimum">
- <double>0.000000000000000</double>
+ <number>1</number>
</property>
<property name="maximum">
- <double>3.000000000000000</double>
+ <number>64</number>
</property>
- <property name="singleStep">
- <double>0.100000000000000</double>
+ <property name="value">
+ <number>4</number>
</property>
</widget>
</item>
@@ -1262,38 +1259,6 @@
</hint>
</hints>
</connection>
- <connection>
- <sender>logarithmicCB</sender>
- <signal>toggled(bool)</signal>
- <receiver>logScaleSB</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>502</x>
- <y>201</y>
- </hint>
- <hint type="destinationlabel">
- <x>566</x>
- <y>201</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>logScaleSB</sender>
- <signal>valueChanged(double)</signal>
- <receiver>RazorSysStatConfiguration</receiver>
- <slot>saveSettings()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>703</x>
- <y>204</y>
- </hint>
- <hint type="destinationlabel">
- <x>732</x>
- <y>203</y>
- </hint>
- </hints>
- </connection>
</connections>
<slots>
<signal>maximumNetSpeedChanged(QString)</signal>
Please sign in to comment.
Something went wrong with that request. Please try again.