Commit 6fdba8a0bd4508c7ccb780e668579fede3d54b01

Authored by dendvz
Committed by David Gräff
1 parent 86d3b6e9

Slider granularity enhancement, trigger level & position slider view fix

openhantek/src/dsowidget.cpp
@@ -75,7 +75,7 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso:: @@ -75,7 +75,7 @@ DsoWidget::DsoWidget(DsoSettingsScope *scope, DsoSettingsView *view, const Dso::
75 for (int marker = 0; marker < MARKER_COUNT; ++marker) { 75 for (int marker = 0; marker < MARKER_COUNT; ++marker) {
76 markerSlider->addSlider(QString::number(marker + 1), marker); 76 markerSlider->addSlider(QString::number(marker + 1), marker);
77 markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2); 77 markerSlider->setLimits(marker, -DIVS_TIME / 2, DIVS_TIME / 2);
78 - markerSlider->setStep(marker, 0.2); 78 + markerSlider->setStep(marker, DIVS_TIME / 100.0);
79 markerSlider->setValue(marker, scope->horizontal.marker[marker]); 79 markerSlider->setValue(marker, scope->horizontal.marker[marker]);
80 markerSlider->setIndexVisible(marker, true); 80 markerSlider->setIndexVisible(marker, true);
81 } 81 }
@@ -241,7 +241,7 @@ void DsoWidget::adaptTriggerLevelSlider(ChannelID channel) { @@ -241,7 +241,7 @@ void DsoWidget::adaptTriggerLevelSlider(ChannelID channel) {
241 triggerLevelSlider->setLimits( 241 triggerLevelSlider->setLimits(
242 (int)channel, (-DIVS_VOLTAGE / 2 - scope->voltage[channel].offset) * scope->gain(channel), 242 (int)channel, (-DIVS_VOLTAGE / 2 - scope->voltage[channel].offset) * scope->gain(channel),
243 (DIVS_VOLTAGE / 2 - scope->voltage[channel].offset) * scope->gain(channel)); 243 (DIVS_VOLTAGE / 2 - scope->voltage[channel].offset) * scope->gain(channel));
244 - triggerLevelSlider->setStep((int)channel, scope->gain(channel) * 0.2); 244 + triggerLevelSlider->setStep((int)channel, scope->gain(channel) * 0.05);
245 } 245 }
246 246
247 /// \brief Show/Hide a line of the measurement table. 247 /// \brief Show/Hide a line of the measurement table.
openhantek/src/utils/printutils.cpp
@@ -50,11 +50,11 @@ QString valueToString(double value, Unit unit, int precision) { @@ -50,11 +50,11 @@ QString valueToString(double value, Unit unit, int precision) {
50 case UNIT_VOLTS: { 50 case UNIT_VOLTS: {
51 // Voltage string representation 51 // Voltage string representation
52 int logarithm = floor(log10(fabs(value))); 52 int logarithm = floor(log10(fabs(value)));
53 - if (value < 1e-3) 53 + if (fabs(value) < 1e-3)
54 return QApplication::tr("%L1 µV").arg(value / 1e-6, 0, format, 54 return QApplication::tr("%L1 µV").arg(value / 1e-6, 0, format,
55 (precision <= 0) ? precision 55 (precision <= 0) ? precision
56 : qBound(0, precision - 7 - logarithm, precision)); 56 : qBound(0, precision - 7 - logarithm, precision));
57 - else if (value < 1.0) 57 + else if (fabs(value) < 1.0)
58 return QApplication::tr("%L1 mV").arg(value / 1e-3, 0, format, 58 return QApplication::tr("%L1 mV").arg(value / 1e-3, 0, format,
59 (precision <= 0) ? precision : (precision - 4 - logarithm)); 59 (precision <= 0) ? precision : (precision - 4 - logarithm));
60 else 60 else
@@ -69,26 +69,26 @@ QString valueToString(double value, Unit unit, int precision) { @@ -69,26 +69,26 @@ QString valueToString(double value, Unit unit, int precision) {
69 69
70 case UNIT_SECONDS: 70 case UNIT_SECONDS:
71 // Time string representation 71 // Time string representation
72 - if (value < 1e-9) 72 + if (fabs(value) < 1e-9)
73 return QApplication::tr("%L1 ps").arg( 73 return QApplication::tr("%L1 ps").arg(
74 value / 1e-12, 0, format, 74 value / 1e-12, 0, format,
75 (precision <= 0) ? precision : qBound(0, precision - 13 - (int)floor(log10(fabs(value))), precision)); 75 (precision <= 0) ? precision : qBound(0, precision - 13 - (int)floor(log10(fabs(value))), precision));
76 - else if (value < 1e-6) 76 + else if (fabs(value) < 1e-6)
77 return QApplication::tr("%L1 ns").arg(value / 1e-9, 0, format, 77 return QApplication::tr("%L1 ns").arg(value / 1e-9, 0, format,
78 (precision <= 0) ? precision 78 (precision <= 0) ? precision
79 : (precision - 10 - (int)floor(log10(fabs(value))))); 79 : (precision - 10 - (int)floor(log10(fabs(value)))));
80 - else if (value < 1e-3) 80 + else if (fabs(value) < 1e-3)
81 return QApplication::tr("%L1 µs").arg(value / 1e-6, 0, format, 81 return QApplication::tr("%L1 µs").arg(value / 1e-6, 0, format,
82 (precision <= 0) ? precision 82 (precision <= 0) ? precision
83 : (precision - 7 - (int)floor(log10(fabs(value))))); 83 : (precision - 7 - (int)floor(log10(fabs(value)))));
84 - else if (value < 1.0) 84 + else if (fabs(value) < 1.0)
85 return QApplication::tr("%L1 ms").arg(value / 1e-3, 0, format, 85 return QApplication::tr("%L1 ms").arg(value / 1e-3, 0, format,
86 (precision <= 0) ? precision 86 (precision <= 0) ? precision
87 : (precision - 4 - (int)floor(log10(fabs(value))))); 87 : (precision - 4 - (int)floor(log10(fabs(value)))));
88 - else if (value < 60) 88 + else if (fabs(value) < 60)
89 return QApplication::tr("%L1 s").arg( 89 return QApplication::tr("%L1 s").arg(
90 value, 0, format, (precision <= 0) ? precision : (precision - 1 - (int)floor(log10(fabs(value))))); 90 value, 0, format, (precision <= 0) ? precision : (precision - 1 - (int)floor(log10(fabs(value)))));
91 - else if (value < 3600) 91 + else if (fabs(value) < 3600)
92 return QApplication::tr("%L1 min").arg( 92 return QApplication::tr("%L1 min").arg(
93 value / 60, 0, format, (precision <= 0) ? precision : (precision - 1 - (int)floor(log10(value / 60)))); 93 value / 60, 0, format, (precision <= 0) ? precision : (precision - 1 - (int)floor(log10(value / 60))));
94 else 94 else
@@ -99,13 +99,13 @@ QString valueToString(double value, Unit unit, int precision) { @@ -99,13 +99,13 @@ QString valueToString(double value, Unit unit, int precision) {
99 case UNIT_HERTZ: { 99 case UNIT_HERTZ: {
100 // Frequency string representation 100 // Frequency string representation
101 int logarithm = floor(log10(fabs(value))); 101 int logarithm = floor(log10(fabs(value)));
102 - if (value < 1e3) 102 + if (fabs(value) < 1e3)
103 return QApplication::tr("%L1 Hz").arg( 103 return QApplication::tr("%L1 Hz").arg(
104 value, 0, format, (precision <= 0) ? precision : qBound(0, precision - 1 - logarithm, precision)); 104 value, 0, format, (precision <= 0) ? precision : qBound(0, precision - 1 - logarithm, precision));
105 - else if (value < 1e6) 105 + else if (fabs(value) < 1e6)
106 return QApplication::tr("%L1 kHz").arg(value / 1e3, 0, format, 106 return QApplication::tr("%L1 kHz").arg(value / 1e3, 0, format,
107 (precision <= 0) ? precision : precision + 2 - logarithm); 107 (precision <= 0) ? precision : precision + 2 - logarithm);
108 - else if (value < 1e9) 108 + else if (fabs(value) < 1e9)
109 return QApplication::tr("%L1 MHz").arg(value / 1e6, 0, format, 109 return QApplication::tr("%L1 MHz").arg(value / 1e6, 0, format,
110 (precision <= 0) ? precision : precision + 5 - logarithm); 110 (precision <= 0) ? precision : precision + 5 - logarithm);
111 else 111 else
@@ -115,13 +115,13 @@ QString valueToString(double value, Unit unit, int precision) { @@ -115,13 +115,13 @@ QString valueToString(double value, Unit unit, int precision) {
115 case UNIT_SAMPLES: { 115 case UNIT_SAMPLES: {
116 // Sample count string representation 116 // Sample count string representation
117 int logarithm = floor(log10(fabs(value))); 117 int logarithm = floor(log10(fabs(value)));
118 - if (value < 1e3) 118 + if (fabs(value) < 1e3)
119 return QApplication::tr("%L1 S").arg( 119 return QApplication::tr("%L1 S").arg(
120 value, 0, format, (precision <= 0) ? precision : qBound(0, precision - 1 - logarithm, precision)); 120 value, 0, format, (precision <= 0) ? precision : qBound(0, precision - 1 - logarithm, precision));
121 - else if (value < 1e6) 121 + else if (fabs(value) < 1e6)
122 return QApplication::tr("%L1 kS").arg(value / 1e3, 0, format, 122 return QApplication::tr("%L1 kS").arg(value / 1e3, 0, format,
123 (precision <= 0) ? precision : precision + 2 - logarithm); 123 (precision <= 0) ? precision : precision + 2 - logarithm);
124 - else if (value < 1e9) 124 + else if (fabs(value) < 1e9)
125 return QApplication::tr("%L1 MS").arg(value / 1e6, 0, format, 125 return QApplication::tr("%L1 MS").arg(value / 1e6, 0, format,
126 (precision <= 0) ? precision : precision + 5 - logarithm); 126 (precision <= 0) ? precision : precision + 5 - logarithm);
127 else 127 else
openhantek/src/widgets/levelslider.cpp
@@ -59,7 +59,7 @@ int LevelSlider::postMargin() const { return this-&gt;_postMargin; } @@ -59,7 +59,7 @@ int LevelSlider::postMargin() const { return this-&gt;_postMargin; }
59 /// \brief Add a new slider to the slider container. 59 /// \brief Add a new slider to the slider container.
60 /// \param index The index where the slider should be inserted, 0 to append. 60 /// \param index The index where the slider should be inserted, 0 to append.
61 /// \return The index of the slider, -1 on error. 61 /// \return The index of the slider, -1 on error.
62 -int LevelSlider::addSlider(int index) { return this->addSlider("0", index); } 62 +int LevelSlider::addSlider(int index) { return this->addSlider("", index); }
63 63
64 /// \brief Add a new slider to the slider container. 64 /// \brief Add a new slider to the slider container.
65 /// \param text The text that will be shown next to the slider. 65 /// \param text The text that will be shown next to the slider.