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