]> sigrok.org Git - pulseview.git/blame - pv/views/trace/analogsignal.cpp
Implement "show conversion thresholds as dots" mode
[pulseview.git] / pv / views / trace / analogsignal.cpp
CommitLineData
aba1dd16
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
aba1dd16
JH
18 */
19
20#include <extdef.h>
21
3b68d03d
JH
22#include <cassert>
23#include <cmath>
8a2fafcc
JH
24#include <cstdlib>
25#include <limits>
a8fd2759 26#include <vector>
aba1dd16 27
37b9fed4 28#include <QApplication>
73e377fe 29#include <QCheckBox>
368a37c2 30#include <QComboBox>
4cffac16 31#include <QFormLayout>
368a37c2
SA
32#include <QGridLayout>
33#include <QLabel>
03cc651d 34#include <QString>
37b9fed4 35
2acdb232 36#include "analogsignal.hpp"
1573bf16
SA
37#include "logicsignal.hpp"
38#include "view.hpp"
39
2acdb232 40#include "pv/data/analog.hpp"
f3d66e52 41#include "pv/data/analogsegment.hpp"
a8fd2759
SA
42#include "pv/data/logic.hpp"
43#include "pv/data/logicsegment.hpp"
bf0edd2b 44#include "pv/data/signalbase.hpp"
8de1e1b2 45#include "pv/globalsettings.hpp"
aba1dd16 46
fe3a1c21 47#include <libsigrokcxx/libsigrokcxx.hpp>
e8d00928 48
2601ce96 49using std::bind;
6f925ba9
UH
50using std::deque;
51using std::div;
52using std::div_t;
819f4c25 53using std::max;
a5d93c27 54using std::make_pair;
819f4c25 55using std::min;
6f925ba9
UH
56using std::numeric_limits;
57using std::pair;
2601ce96 58using std::placeholders::_1;
f9abf97e 59using std::shared_ptr;
a8fd2759 60using std::vector;
aba1dd16 61
2b6e7a72
SA
62using pv::data::SignalBase;
63
aba1dd16 64namespace pv {
f4e57597 65namespace views {
1573bf16 66namespace trace {
aba1dd16 67
568b90d4
JH
68const QColor AnalogSignal::SignalColours[4] = {
69 QColor(0xC4, 0xA0, 0x00), // Yellow
70 QColor(0x87, 0x20, 0x7A), // Magenta
71 QColor(0x20, 0x4A, 0x87), // Blue
72 QColor(0x4E, 0x9A, 0x06) // Green
73};
74
561ba3ae 75const QPen AnalogSignal::AxisPen(QColor(0, 0, 0, 30 * 256 / 100), 2);
c063290a
UH
76const QColor AnalogSignal::GridMajorColor = QColor(0, 0, 0, 40 * 256 / 100);
77const QColor AnalogSignal::GridMinorColor = QColor(0, 0, 0, 20 * 256 / 100);
37b9fed4 78
8de1e1b2 79const QColor AnalogSignal::SamplingPointColour(0x77, 0x77, 0x77);
d37ff80d
SA
80const QColor AnalogSignal::SamplingPointColourLo = QColor(200, 0, 0, 80 * 256 / 100);
81const QColor AnalogSignal::SamplingPointColourNe = QColor(0, 0, 0, 80 * 256 / 100);
82const QColor AnalogSignal::SamplingPointColourHi = QColor(0, 200, 0, 80 * 256 / 100);
8de1e1b2 83
4433246b 84const QColor AnalogSignal::ThresholdColor = QColor(0, 0, 0, 30 * 256 / 100);
1d150cd6 85const QColor AnalogSignal::ThresholdColorLo = QColor(255, 0, 0, 8 * 256 / 100);
78bf7ce5 86const QColor AnalogSignal::ThresholdColorNe = QColor(0, 0, 0, 10 * 256 / 100);
1d150cd6 87const QColor AnalogSignal::ThresholdColorHi = QColor(0, 255, 0, 8 * 256 / 100);
4433246b 88
fdfd5b3e
SA
89const int64_t AnalogSignal::TracePaintBlockSize = 1024 * 1024; // 4 MiB (due to float)
90const float AnalogSignal::EnvelopeThreshold = 64.0f;
7c68ddae 91
4cffac16 92const int AnalogSignal::MaximumVDivs = 10;
368a37c2
SA
93const int AnalogSignal::MinScaleIndex = -6;
94const int AnalogSignal::MaxScaleIndex = 7;
4cffac16 95
03cc651d
SA
96const int AnalogSignal::InfoTextMarginRight = 20;
97const int AnalogSignal::InfoTextMarginBottom = 5;
98
b86aa8f4 99AnalogSignal::AnalogSignal(
2b81ae46 100 pv::Session &session,
cbd2a2de 101 shared_ptr<data::SignalBase> base) :
73a25a6e 102 Signal(session, base),
834a4f1b 103 scale_index_(4), // 20 per div
37b9fed4 104 scale_index_drag_offset_(0),
459db2c5
SA
105 pos_vdivs_(1),
106 neg_vdivs_(1),
73e377fe 107 resolution_(0),
a970015f 108 display_type_(DisplayBoth),
1f1d55ce 109 autoranging_(true)
aba1dd16 110{
561ba3ae
SA
111 axis_pen_ = AxisPen;
112
85715407
SA
113 pv::data::Analog* analog_data =
114 dynamic_cast<pv::data::Analog*>(data().get());
115
c6d9cf65
SA
116 connect(analog_data, SIGNAL(min_max_changed(float, float)),
117 this, SLOT(on_min_max_changed(float, float)));
85715407 118
90ee1ed9
SA
119 GlobalSettings::register_change_handler(GlobalSettings::Key_View_ConversionThresholdDispMode,
120 bind(&AnalogSignal::on_settingViewConversionThresholdDispMode_changed, this, _1));
2601ce96 121
cbb50547 122 GlobalSettings gs;
90ee1ed9
SA
123 conversion_threshold_disp_mode_ =
124 gs.value(GlobalSettings::Key_View_ConversionThresholdDispMode).toInt();
2601ce96 125
cbb50547
SA
126 div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt();
127
73a25a6e 128 base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
834a4f1b 129 update_scale();
aba1dd16
JH
130}
131
3009b5b3
JH
132shared_ptr<pv::data::SignalData> AnalogSignal::data() const
133{
cbd2a2de 134 return base_->analog_data();
9a0cd293
JH
135}
136
3a21afa6
SA
137void AnalogSignal::save_settings(QSettings &settings) const
138{
459db2c5
SA
139 settings.setValue("pos_vdivs", pos_vdivs_);
140 settings.setValue("neg_vdivs", neg_vdivs_);
3a21afa6 141 settings.setValue("scale_index", scale_index_);
a970015f 142 settings.setValue("display_type", display_type_);
73e377fe 143 settings.setValue("autoranging", autoranging_);
cbb50547 144 settings.setValue("div_height", div_height_);
3a21afa6
SA
145}
146
147void AnalogSignal::restore_settings(QSettings &settings)
148{
459db2c5
SA
149 if (settings.contains("pos_vdivs"))
150 pos_vdivs_ = settings.value("pos_vdivs").toInt();
151
152 if (settings.contains("neg_vdivs"))
153 neg_vdivs_ = settings.value("neg_vdivs").toInt();
3a21afa6
SA
154
155 if (settings.contains("scale_index")) {
156 scale_index_ = settings.value("scale_index").toInt();
157 update_scale();
158 }
73e377fe 159
a970015f
SA
160 if (settings.contains("display_type"))
161 display_type_ = (DisplayType)(settings.value("display_type").toInt());
162
73e377fe
SA
163 if (settings.contains("autoranging"))
164 autoranging_ = settings.value("autoranging").toBool();
cbb50547
SA
165
166 if (settings.contains("div_height")) {
167 const int old_height = div_height_;
168 div_height_ = settings.value("div_height").toInt();
169
170 if ((div_height_ != old_height) && owner_) {
171 // Call order is important, otherwise the lazy event handler won't work
172 owner_->extents_changed(false, true);
173 owner_->row_item_appearance_changed(false, true);
174 }
175 }
3a21afa6
SA
176}
177
6f925ba9 178pair<int, int> AnalogSignal::v_extents() const
a5d93c27 179{
459db2c5
SA
180 const int ph = pos_vdivs_ * div_height_;
181 const int nh = neg_vdivs_ * div_height_;
182 return make_pair(-ph, nh);
a5d93c27
JH
183}
184
214470fc
JH
185int AnalogSignal::scale_handle_offset() const
186{
459db2c5 187 const int h = (pos_vdivs_ + neg_vdivs_) * div_height_;
37b9fed4 188
c063290a 189 return ((scale_index_drag_offset_ - scale_index_) * h / 4) - h / 2;
214470fc
JH
190}
191
192void AnalogSignal::scale_handle_dragged(int offset)
193{
459db2c5 194 const int h = (pos_vdivs_ + neg_vdivs_) * div_height_;
37b9fed4 195
c063290a 196 scale_index_ = scale_index_drag_offset_ - (offset + h / 2) / (h / 4);
834a4f1b
SA
197
198 update_scale();
8a2fafcc
JH
199}
200
201void AnalogSignal::scale_handle_drag_release()
202{
203 scale_index_drag_offset_ = scale_index_;
834a4f1b 204 update_scale();
214470fc
JH
205}
206
60938e04 207void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp)
fe08b6e8 208{
1d150cd6
SA
209 if (!base_->enabled())
210 return;
211
90ee1ed9
SA
212 bool paint_thr_bg =
213 conversion_threshold_disp_mode_ == GlobalSettings::ConvThrDispMode_Background;
214
1d150cd6
SA
215 const vector<double> thresholds = base_->get_conversion_thresholds();
216
217 // Only display thresholds if we have some and we show analog samples
90ee1ed9 218 if ((thresholds.size() > 0) && paint_thr_bg &&
1d150cd6
SA
219 ((display_type_ == DisplayAnalog) || (display_type_ == DisplayBoth))) {
220
221 const int visual_y = get_visual_y();
222 const pair<int, int> extents = v_extents();
223 const int top = visual_y + extents.first;
224 const int btm = visual_y + extents.second;
225
226 // Draw high/neutral/low areas
227 if (thresholds.size() == 2) {
228 const double thr_lo = visual_y - thresholds[0] * scale_;
229 const double thr_hi = visual_y - thresholds[1] * scale_;
230
231 p.fillRect(QRectF(pp.left(), top, pp.width(), thr_hi - top),
232 QBrush(ThresholdColorHi));
233 p.fillRect(QRectF(pp.left(), thr_hi, pp.width(), thr_lo - thr_hi),
234 QBrush(ThresholdColorNe));
235 p.fillRect(QRectF(pp.left(), thr_lo, pp.width(), btm - thr_lo),
236 QBrush(ThresholdColorLo));
237 } else {
238 const double thr = visual_y - thresholds[0] * scale_;
239
240 p.fillRect(QRectF(pp.left(), top, pp.width(), thr - top),
241 QBrush(ThresholdColorHi));
242 p.fillRect(QRectF(pp.left(), thr, pp.width(), btm - thr),
243 QBrush(ThresholdColorLo));
244 }
245
246 paint_axis(p, pp, get_visual_y());
247 } else {
99af6802 248 Trace::paint_back(p, pp);
97904bf7 249 paint_axis(p, pp, get_visual_y());
99af6802 250 }
fe08b6e8
JH
251}
252
60938e04 253void AnalogSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp)
aba1dd16 254{
cbd2a2de 255 assert(base_->analog_data());
8dbbc7f0 256 assert(owner_);
a8acb46e 257
be9e7b4b 258 const int y = get_visual_y();
01fd3263 259
73a25a6e 260 if (!base_->enabled())
cec48d16
JH
261 return;
262
a8fd2759
SA
263 if ((display_type_ == DisplayAnalog) || (display_type_ == DisplayBoth)) {
264 paint_grid(p, y, pp.left(), pp.right());
265
266 const deque< shared_ptr<pv::data::AnalogSegment> > &segments =
267 base_->analog_data()->analog_segments();
268 if (segments.empty())
269 return;
270
271 const shared_ptr<pv::data::AnalogSegment> &segment =
272 segments.front();
273
274 const double pixels_offset = pp.pixels_offset();
275 const double samplerate = max(1.0, segment->samplerate());
276 const pv::util::Timestamp& start_time = segment->start_time();
277 const int64_t last_sample = segment->get_sample_count() - 1;
278 const double samples_per_pixel = samplerate * pp.scale();
279 const pv::util::Timestamp start = samplerate * (pp.offset() - start_time);
280 const pv::util::Timestamp end = start + samples_per_pixel * pp.width();
281
282 const int64_t start_sample = min(max(floor(start).convert_to<int64_t>(),
283 (int64_t)0), last_sample);
284 const int64_t end_sample = min(max((ceil(end) + 1).convert_to<int64_t>(),
285 (int64_t)0), last_sample);
286
287 if (samples_per_pixel < EnvelopeThreshold)
288 paint_trace(p, segment, y, pp.left(),
289 start_sample, end_sample,
290 pixels_offset, samples_per_pixel);
291 else
292 paint_envelope(p, segment, y, pp.left(),
293 start_sample, end_sample,
294 pixels_offset, samples_per_pixel);
295 }
a8acb46e 296
1d150cd6
SA
297 if ((display_type_ == DisplayConverted) || (display_type_ == DisplayBoth))
298 paint_logic_mid(p, pp);
7c68ddae
JH
299}
300
60938e04 301void AnalogSignal::paint_fore(QPainter &p, ViewItemPaintParams &pp)
03cc651d
SA
302{
303 if (!enabled())
304 return;
305
b8c4a95b
SA
306 if ((display_type_ == DisplayAnalog) || (display_type_ == DisplayBoth)) {
307 const int y = get_visual_y();
03cc651d 308
b8c4a95b
SA
309 // Show the info section on the right side of the trace
310 const QString infotext = QString("%1 V/div").arg(resolution_);
03cc651d 311
b8c4a95b
SA
312 p.setPen(base_->colour());
313 p.setFont(QApplication::font());
03cc651d 314
b8c4a95b
SA
315 const QRectF bounding_rect = QRectF(pp.left(),
316 y + v_extents().first,
317 pp.width() - InfoTextMarginRight,
318 v_extents().second - v_extents().first - InfoTextMarginBottom);
03cc651d 319
b8c4a95b
SA
320 p.drawText(bounding_rect, Qt::AlignRight | Qt::AlignBottom, infotext);
321 }
03cc651d
SA
322}
323
37b9fed4
SA
324void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right)
325{
46a0cadc
SA
326 p.setRenderHint(QPainter::Antialiasing, false);
327
8ad61f40
UH
328 GlobalSettings settings;
329 const bool show_analog_minor_grid =
330 settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool();
331
459db2c5
SA
332 if (pos_vdivs_ > 0) {
333 p.setPen(QPen(GridMajorColor, 1, Qt::DashLine));
334 for (int i = 1; i <= pos_vdivs_; i++) {
335 const float dy = i * div_height_;
336 p.drawLine(QLineF(left, y - dy, right, y - dy));
337 }
8ad61f40 338 }
459db2c5 339
8ad61f40 340 if ((pos_vdivs_ > 0) && show_analog_minor_grid) {
459db2c5
SA
341 p.setPen(QPen(GridMinorColor, 1, Qt::DashLine));
342 for (int i = 0; i < pos_vdivs_; i++) {
343 const float dy = i * div_height_;
344 const float dy25 = dy + (0.25 * div_height_);
345 const float dy50 = dy + (0.50 * div_height_);
346 const float dy75 = dy + (0.75 * div_height_);
347 p.drawLine(QLineF(left, y - dy25, right, y - dy25));
348 p.drawLine(QLineF(left, y - dy50, right, y - dy50));
349 p.drawLine(QLineF(left, y - dy75, right, y - dy75));
350 }
37b9fed4
SA
351 }
352
459db2c5
SA
353 if (neg_vdivs_ > 0) {
354 p.setPen(QPen(GridMajorColor, 1, Qt::DashLine));
355 for (int i = 1; i <= neg_vdivs_; i++) {
356 const float dy = i * div_height_;
357 p.drawLine(QLineF(left, y + dy, right, y + dy));
358 }
8ad61f40 359 }
459db2c5 360
8ad61f40 361 if ((pos_vdivs_ > 0) && show_analog_minor_grid) {
459db2c5
SA
362 p.setPen(QPen(GridMinorColor, 1, Qt::DashLine));
363 for (int i = 0; i < neg_vdivs_; i++) {
364 const float dy = i * div_height_;
365 const float dy25 = dy + (0.25 * div_height_);
366 const float dy50 = dy + (0.50 * div_height_);
367 const float dy75 = dy + (0.75 * div_height_);
368 p.drawLine(QLineF(left, y + dy25, right, y + dy25));
369 p.drawLine(QLineF(left, y + dy50, right, y + dy50));
370 p.drawLine(QLineF(left, y + dy75, right, y + dy75));
371 }
37b9fed4 372 }
46a0cadc
SA
373
374 p.setRenderHint(QPainter::Antialiasing, true);
37b9fed4
SA
375}
376
7c68ddae 377void AnalogSignal::paint_trace(QPainter &p,
f3d66e52 378 const shared_ptr<pv::data::AnalogSegment> &segment,
7c68ddae
JH
379 int y, int left, const int64_t start, const int64_t end,
380 const double pixels_offset, const double samples_per_pixel)
381{
fdfd5b3e
SA
382 if (end <= start)
383 return;
384
d37ff80d
SA
385 bool paint_thr_dots =
386 (base_->get_conversion_type() != data::SignalBase::NoConversion) &&
387 (conversion_threshold_disp_mode_ == GlobalSettings::ConvThrDispMode_Dots);
388
389 vector<double> thresholds;
390 if (paint_thr_dots)
391 thresholds = base_->get_conversion_thresholds();
392
fdfd5b3e
SA
393 // Calculate and paint the sampling points if enabled and useful
394 GlobalSettings settings;
395 const bool show_sampling_points =
d37ff80d
SA
396 (settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool() ||
397 paint_thr_dots) && (samples_per_pixel < 0.25);
fdfd5b3e 398
73a25a6e 399 p.setPen(base_->colour());
7c68ddae 400
76ce6c7a
UH
401 const int64_t points_count = end - start;
402
403 QPointF *points = new QPointF[points_count];
a8acb46e
JH
404 QPointF *point = points;
405
d37ff80d 406 vector<QRectF> sampling_points[3];
8de1e1b2 407
fdfd5b3e
SA
408 int64_t sample_count = min(points_count, TracePaintBlockSize);
409 int64_t block_sample = 0;
b82243f7
SA
410 float *sample_block = new float[TracePaintBlockSize];
411 segment->get_samples(start, start + sample_count, sample_block);
26a883ed 412
8de1e1b2 413 const int w = 2;
fdfd5b3e
SA
414 for (int64_t sample = start; sample != end; sample++, block_sample++) {
415
416 if (block_sample == TracePaintBlockSize) {
417 block_sample = 0;
fdfd5b3e 418 sample_count = min(points_count - sample, TracePaintBlockSize);
b82243f7 419 segment->get_samples(sample, sample + sample_count, sample_block);
fdfd5b3e
SA
420 }
421
a8acb46e 422 const float x = (sample / samples_per_pixel -
2658961b 423 pixels_offset) + left;
26a883ed 424
fdfd5b3e 425 *point++ = QPointF(x, y - sample_block[block_sample] * scale_);
8de1e1b2 426
d37ff80d
SA
427 if (show_sampling_points) {
428 int idx = 0; // Neutral
429
430 if (paint_thr_dots) {
431 if (thresholds.size() == 1)
432 idx = (sample_block[block_sample] >= thresholds[0]) ? 2 : 1;
433 else if (thresholds.size() == 2) {
434 if (sample_block[block_sample] > thresholds[1])
435 idx = 2; // High
436 else if (sample_block[block_sample] < thresholds[0])
437 idx = 1; // Low
438 }
439 }
440
441 sampling_points[idx].push_back(
442 QRectF(x - (w / 2), y - sample_block[block_sample] * scale_ - (w / 2), w, w));
443 }
a8acb46e 444 }
fdfd5b3e 445 delete[] sample_block;
a8acb46e 446
76ce6c7a 447 p.drawPolyline(points, points_count);
a8acb46e 448
fdfd5b3e 449 if (show_sampling_points) {
d37ff80d
SA
450 if (paint_thr_dots) {
451 p.setPen(SamplingPointColourNe);
452 p.drawRects(sampling_points[0].data(), sampling_points[0].size());
453 p.setPen(SamplingPointColourLo);
454 p.drawRects(sampling_points[1].data(), sampling_points[1].size());
455 p.setPen(SamplingPointColourHi);
456 p.drawRects(sampling_points[2].data(), sampling_points[2].size());
457 } else {
458 p.setPen(SamplingPointColour);
459 p.drawRects(sampling_points[0].data(), sampling_points[0].size());
460 }
8de1e1b2
UH
461 }
462
a8acb46e 463 delete[] points;
aba1dd16
JH
464}
465
7c68ddae 466void AnalogSignal::paint_envelope(QPainter &p,
f3d66e52 467 const shared_ptr<pv::data::AnalogSegment> &segment,
7c68ddae
JH
468 int y, int left, const int64_t start, const int64_t end,
469 const double pixels_offset, const double samples_per_pixel)
470{
f3d66e52 471 using pv::data::AnalogSegment;
7c68ddae 472
f3d66e52
JH
473 AnalogSegment::EnvelopeSection e;
474 segment->get_envelope_section(e, start, end, samples_per_pixel);
7c68ddae
JH
475
476 if (e.length < 2)
477 return;
478
819f4c25 479 p.setPen(QPen(Qt::NoPen));
73a25a6e 480 p.setBrush(base_->colour());
7c68ddae
JH
481
482 QRectF *const rects = new QRectF[e.length];
483 QRectF *rect = rects;
484
c063290a 485 for (uint64_t sample = 0; sample < e.length - 1; sample++) {
7c68ddae
JH
486 const float x = ((e.scale * sample + e.start) /
487 samples_per_pixel - pixels_offset) + left;
f3d66e52 488 const AnalogSegment::EnvelopeSample *const s =
7c68ddae
JH
489 e.samples + sample;
490
491 // We overlap this sample with the next so that vertical
492 // gaps do not appear during steep rising or falling edges
c063290a
UH
493 const float b = y - max(s->max, (s + 1)->min) * scale_;
494 const float t = y - min(s->min, (s + 1)->max) * scale_;
7c68ddae
JH
495
496 float h = b - t;
f3290553 497 if (h >= 0.0f && h <= 1.0f)
7c68ddae 498 h = 1.0f;
f3290553 499 if (h <= 0.0f && h >= -1.0f)
7c68ddae
JH
500 h = -1.0f;
501
502 *rect++ = QRectF(x, t, 1.0f, h);
503 }
504
505 p.drawRects(rects, e.length);
506
507 delete[] rects;
508 delete[] e.samples;
509}
510
60938e04 511void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp)
a8fd2759
SA
512{
513 QLineF *line;
514
515 vector< pair<int64_t, bool> > edges;
516
517 assert(base_);
518
519 const int y = get_visual_y();
520
6c0df7c4 521 if (!base_->enabled() || !base_->logic_data())
a8fd2759
SA
522 return;
523
524 const int signal_margin =
525 QFontMetrics(QApplication::font()).height() / 2;
526
527 const int ph = min(pos_vdivs_, 1) * div_height_;
528 const int nh = min(neg_vdivs_, 1) * div_height_;
529 const float high_offset = y - ph + signal_margin + 0.5f;
530 const float low_offset = y + nh - signal_margin - 0.5f;
531
532 const deque< shared_ptr<pv::data::LogicSegment> > &segments =
533 base_->logic_data()->logic_segments();
6c0df7c4 534
a8fd2759
SA
535 if (segments.empty())
536 return;
537
538 const shared_ptr<pv::data::LogicSegment> &segment =
539 segments.front();
540
541 double samplerate = segment->samplerate();
542
543 // Show sample rate as 1Hz when it is unknown
544 if (samplerate == 0.0)
545 samplerate = 1.0;
546
547 const double pixels_offset = pp.pixels_offset();
548 const pv::util::Timestamp& start_time = segment->start_time();
549 const int64_t last_sample = segment->get_sample_count() - 1;
550 const double samples_per_pixel = samplerate * pp.scale();
124be547 551 const double pixels_per_sample = 1 / samples_per_pixel;
a8fd2759
SA
552 const pv::util::Timestamp start = samplerate * (pp.offset() - start_time);
553 const pv::util::Timestamp end = start + samples_per_pixel * pp.width();
554
555 const int64_t start_sample = min(max(floor(start).convert_to<int64_t>(),
556 (int64_t)0), last_sample);
557 const uint64_t end_sample = min(max(ceil(end).convert_to<int64_t>(),
558 (int64_t)0), last_sample);
559
560 segment->get_subsampled_edges(edges, start_sample, end_sample,
561 samples_per_pixel / LogicSignal::Oversampling, 0);
562 assert(edges.size() >= 2);
563
124be547
SA
564 // Check whether we need to paint the sampling points
565 GlobalSettings settings;
566 const bool show_sampling_points =
567 settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool() &&
568 (samples_per_pixel < 0.25);
569
570 vector<QRectF> sampling_points;
571 float sampling_point_x = 0.0f;
572 int64_t sampling_point_sample = start_sample;
573 const int w = 2;
574
575 if (show_sampling_points) {
576 sampling_points.reserve(end_sample - start_sample + 1);
577 sampling_point_x = (edges.cbegin()->first / samples_per_pixel - pixels_offset) + pp.left();
578 }
579
a8fd2759
SA
580 // Paint the edges
581 const unsigned int edge_count = edges.size() - 2;
582 QLineF *const edge_lines = new QLineF[edge_count];
583 line = edge_lines;
584
585 for (auto i = edges.cbegin() + 1; i != edges.cend() - 1; i++) {
586 const float x = ((*i).first / samples_per_pixel -
587 pixels_offset) + pp.left();
588 *line++ = QLineF(x, high_offset, x, low_offset);
124be547
SA
589
590 if (show_sampling_points)
591 while (sampling_point_sample < (*i).first) {
592 const float y = (*i).second ? low_offset : high_offset;
593 sampling_points.emplace_back(
594 QRectF(sampling_point_x - (w / 2), y - (w / 2), w, w));
595 sampling_point_sample++;
596 sampling_point_x += pixels_per_sample;
597 };
a8fd2759
SA
598 }
599
124be547
SA
600 // Calculate the sample points from the last edge to the end of the trace
601 if (show_sampling_points)
602 while ((uint64_t)sampling_point_sample <= end_sample) {
603 // Signal changed after the last edge, so the level is inverted
604 const float y = (edges.cend() - 1)->second ? high_offset : low_offset;
605 sampling_points.emplace_back(
606 QRectF(sampling_point_x - (w / 2), y - (w / 2), w, w));
607 sampling_point_sample++;
608 sampling_point_x += pixels_per_sample;
609 };
610
a8fd2759
SA
611 p.setPen(LogicSignal::EdgeColour);
612 p.drawLines(edge_lines, edge_count);
613 delete[] edge_lines;
614
615 // Paint the caps
616 const unsigned int max_cap_line_count = edges.size();
617 QLineF *const cap_lines = new QLineF[max_cap_line_count];
618
619 p.setPen(LogicSignal::HighColour);
620 paint_logic_caps(p, cap_lines, edges, true, samples_per_pixel,
621 pixels_offset, pp.left(), high_offset);
622 p.setPen(LogicSignal::LowColour);
623 paint_logic_caps(p, cap_lines, edges, false, samples_per_pixel,
624 pixels_offset, pp.left(), low_offset);
625
626 delete[] cap_lines;
627
a8fd2759 628 // Paint the sampling points
124be547
SA
629 if (show_sampling_points) {
630 p.setPen(SamplingPointColour);
631 p.drawRects(sampling_points.data(), sampling_points.size());
a8fd2759 632 }
a8fd2759
SA
633}
634
635void AnalogSignal::paint_logic_caps(QPainter &p, QLineF *const lines,
636 vector< pair<int64_t, bool> > &edges, bool level,
637 double samples_per_pixel, double pixels_offset, float x_offset,
638 float y_offset)
639{
640 QLineF *line = lines;
641
642 for (auto i = edges.begin(); i != (edges.end() - 1); i++)
643 if ((*i).second == level) {
644 *line++ = QLineF(
645 ((*i).first / samples_per_pixel -
646 pixels_offset) + x_offset, y_offset,
647 ((*(i+1)).first / samples_per_pixel -
648 pixels_offset) + x_offset, y_offset);
649 }
650
651 p.drawLines(lines, line - lines);
652}
653
368a37c2 654float AnalogSignal::get_resolution(int scale_index)
8a2fafcc
JH
655{
656 const float seq[] = {1.0f, 2.0f, 5.0f};
834a4f1b 657
6f925ba9
UH
658 const int offset = numeric_limits<int>::max() / (2 * countof(seq));
659 const div_t d = div((int)(scale_index + countof(seq) * offset),
8a2fafcc 660 countof(seq));
834a4f1b 661
368a37c2
SA
662 return powf(10.0f, d.quot - offset) * seq[d.rem];
663}
664
665void AnalogSignal::update_scale()
666{
667 resolution_ = get_resolution(scale_index_);
834a4f1b 668 scale_ = div_height_ / resolution_;
8a2fafcc
JH
669}
670
52c900ac
SA
671void AnalogSignal::update_conversion_widgets()
672{
2b6e7a72 673 SignalBase::ConversionType conv_type = base_->get_conversion_type();
52c900ac
SA
674
675 // Enable or disable widgets depending on conversion state
2b6e7a72
SA
676 conv_threshold_cb_->setEnabled(conv_type != SignalBase::NoConversion);
677 display_type_cb_->setEnabled(conv_type != SignalBase::NoConversion);
52c900ac
SA
678
679 conv_threshold_cb_->clear();
680
681 vector < pair<QString, int> > presets = base_->get_conversion_presets();
682
683 // Prevent the combo box from firing the "edit text changed" signal
684 // as that would involuntarily select the first entry
685 conv_threshold_cb_->blockSignals(true);
686
687 // Set available options depending on chosen conversion
688 for (pair<QString, int> preset : presets)
689 conv_threshold_cb_->addItem(preset.first, preset.second);
690
691 map < QString, QVariant > options = base_->get_conversion_options();
692
b9cdbe03 693 if (conv_type == SignalBase::A2LConversionByThreshold) {
52c900ac 694 const vector<double> thresholds = base_->get_conversion_thresholds(
b9cdbe03 695 SignalBase::A2LConversionByThreshold, true);
52c900ac
SA
696 conv_threshold_cb_->addItem(
697 QString("%1V").arg(QString::number(thresholds[0], 'f', 1)), -1);
698 }
699
2b6e7a72 700 if (conv_type == SignalBase::A2LConversionBySchmittTrigger) {
52c900ac 701 const vector<double> thresholds = base_->get_conversion_thresholds(
2b6e7a72 702 SignalBase::A2LConversionBySchmittTrigger, true);
52c900ac
SA
703 conv_threshold_cb_->addItem(QString("%1V/%2V").arg(
704 QString::number(thresholds[0], 'f', 1),
705 QString::number(thresholds[1], 'f', 1)), -1);
706 }
707
708 int preset_id = base_->get_current_conversion_preset();
709 conv_threshold_cb_->setCurrentIndex(
710 conv_threshold_cb_->findData(preset_id));
711
712 conv_threshold_cb_->blockSignals(false);
713}
714
430b94aa 715void AnalogSignal::perform_autoranging(bool keep_divs, bool force_update)
73e377fe
SA
716{
717 const deque< shared_ptr<pv::data::AnalogSegment> > &segments =
718 base_->analog_data()->analog_segments();
719
720 if (segments.empty())
721 return;
722
723 static double prev_min = 0, prev_max = 0;
724 double min = 0, max = 0;
725
726 for (shared_ptr<pv::data::AnalogSegment> segment : segments) {
6f925ba9 727 pair<double, double> mm = segment->get_min_max();
73e377fe
SA
728 min = std::min(min, mm.first);
729 max = std::max(max, mm.second);
730 }
731
732 if ((min == prev_min) && (max == prev_max) && !force_update)
733 return;
734
735 prev_min = min;
736 prev_max = max;
737
430b94aa
SA
738 // If we're allowed to alter the div assignment...
739 if (!keep_divs) {
740 // Use all divs for the positive range if there are no negative values
741 if ((min == 0) && (neg_vdivs_ > 0)) {
742 pos_vdivs_ += neg_vdivs_;
743 neg_vdivs_ = 0;
744 }
73e377fe 745
430b94aa
SA
746 // Split up the divs if there are negative values but no negative divs
747 if ((min < 0) && (neg_vdivs_ == 0)) {
748 neg_vdivs_ = pos_vdivs_ / 2;
749 pos_vdivs_ -= neg_vdivs_;
750 }
681b6d5a
SA
751 }
752
430b94aa
SA
753 // If there is still no positive div when we need it, add one
754 // (this can happen when pos_vdivs==neg_vdivs==0)
17c7f31c 755 if ((max > 0) && (pos_vdivs_ == 0)) {
430b94aa 756 pos_vdivs_ = 1;
17c7f31c
SA
757 owner_->extents_changed(false, true);
758 }
430b94aa
SA
759
760 // If there is still no negative div when we need it, add one
761 // (this can happen when pos_vdivs was 0 or 1 when trying to split)
17c7f31c 762 if ((min < 0) && (neg_vdivs_ == 0)) {
430b94aa 763 neg_vdivs_ = 1;
17c7f31c
SA
764 owner_->extents_changed(false, true);
765 }
430b94aa 766
73e377fe
SA
767 double min_value_per_div;
768 if ((pos_vdivs_ > 0) && (neg_vdivs_ > 0))
769 min_value_per_div = std::max(max / pos_vdivs_, -min / neg_vdivs_);
770 else if (pos_vdivs_ > 0)
771 min_value_per_div = max / pos_vdivs_;
772 else
773 min_value_per_div = -min / neg_vdivs_;
774
775 // Find first scale value that is bigger than the value we need
776 for (int i = MinScaleIndex; i < MaxScaleIndex; i++)
777 if (get_resolution(i) > min_value_per_div) {
778 scale_index_ = i;
779 break;
780 }
781
782 update_scale();
783}
784
4cffac16
SA
785void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form)
786{
787 // Add the standard options
788 Signal::populate_popup_form(parent, form);
789
368a37c2
SA
790 QFormLayout *const layout = new QFormLayout;
791
cbb50547 792 // Add div-related settings
430b94aa
SA
793 pvdiv_sb_ = new QSpinBox(parent);
794 pvdiv_sb_->setRange(0, MaximumVDivs);
795 pvdiv_sb_->setValue(pos_vdivs_);
796 connect(pvdiv_sb_, SIGNAL(valueChanged(int)),
459db2c5 797 this, SLOT(on_pos_vdivs_changed(int)));
430b94aa 798 layout->addRow(tr("Number of pos vertical divs"), pvdiv_sb_);
459db2c5 799
430b94aa
SA
800 nvdiv_sb_ = new QSpinBox(parent);
801 nvdiv_sb_->setRange(0, MaximumVDivs);
802 nvdiv_sb_->setValue(neg_vdivs_);
803 connect(nvdiv_sb_, SIGNAL(valueChanged(int)),
459db2c5 804 this, SLOT(on_neg_vdivs_changed(int)));
430b94aa 805 layout->addRow(tr("Number of neg vertical divs"), nvdiv_sb_);
368a37c2 806
cbb50547
SA
807 div_height_sb_ = new QSpinBox(parent);
808 div_height_sb_->setRange(20, 1000);
809 div_height_sb_->setSingleStep(5);
810 div_height_sb_->setSuffix(tr(" pixels"));
811 div_height_sb_->setValue(div_height_);
812 connect(div_height_sb_, SIGNAL(valueChanged(int)),
813 this, SLOT(on_div_height_changed(int)));
814 layout->addRow(tr("Div height"), div_height_sb_);
815
368a37c2
SA
816 // Add the vertical resolution
817 resolution_cb_ = new QComboBox(parent);
818
819 for (int i = MinScaleIndex; i < MaxScaleIndex; i++) {
820 const QString label = QString("%1").arg(get_resolution(i));
821 resolution_cb_->insertItem(0, label, QVariant(i));
822 }
823
a970015f 824 int cur_idx = resolution_cb_->findData(QVariant(scale_index_));
368a37c2
SA
825 resolution_cb_->setCurrentIndex(cur_idx);
826
827 connect(resolution_cb_, SIGNAL(currentIndexChanged(int)),
828 this, SLOT(on_resolution_changed(int)));
829
830 QGridLayout *const vdiv_layout = new QGridLayout;
831 QLabel *const vdiv_unit = new QLabel(tr("V/div"));
832 vdiv_layout->addWidget(resolution_cb_, 0, 0);
833 vdiv_layout->addWidget(vdiv_unit, 0, 1);
834
835 layout->addRow(tr("Vertical resolution"), vdiv_layout);
836
73e377fe
SA
837 // Add the autoranging checkbox
838 QCheckBox* autoranging_cb = new QCheckBox();
839 autoranging_cb->setCheckState(autoranging_ ? Qt::Checked : Qt::Unchecked);
840
841 connect(autoranging_cb, SIGNAL(stateChanged(int)),
842 this, SLOT(on_autoranging_changed(int)));
843
844 layout->addRow(tr("Autoranging"), autoranging_cb);
845
a970015f
SA
846 // Add the conversion type dropdown
847 conversion_cb_ = new QComboBox();
848
2b6e7a72
SA
849 conversion_cb_->addItem(tr("none"),
850 SignalBase::NoConversion);
851 conversion_cb_->addItem(tr("to logic via threshold"),
b9cdbe03 852 SignalBase::A2LConversionByThreshold);
2b6e7a72
SA
853 conversion_cb_->addItem(tr("to logic via schmitt-trigger"),
854 SignalBase::A2LConversionBySchmittTrigger);
a970015f 855
06b6ce26 856 cur_idx = conversion_cb_->findData(QVariant(base_->get_conversion_type()));
a970015f
SA
857 conversion_cb_->setCurrentIndex(cur_idx);
858
7c84c074 859 layout->addRow(tr("Conversion"), conversion_cb_);
a970015f
SA
860
861 connect(conversion_cb_, SIGNAL(currentIndexChanged(int)),
862 this, SLOT(on_conversion_changed(int)));
863
52c900ac
SA
864 // Add the conversion threshold settings
865 conv_threshold_cb_ = new QComboBox();
866 conv_threshold_cb_->setEditable(true);
867
868 layout->addRow(tr("Conversion threshold(s)"), conv_threshold_cb_);
869
870 connect(conv_threshold_cb_, SIGNAL(currentIndexChanged(int)),
871 this, SLOT(on_conv_threshold_changed(int)));
872 connect(conv_threshold_cb_, SIGNAL(editTextChanged(const QString)),
873 this, SLOT(on_conv_threshold_changed())); // index will be -1
874
a970015f
SA
875 // Add the display type dropdown
876 display_type_cb_ = new QComboBox();
877
c6b017fb
SA
878 display_type_cb_->addItem(tr("analog"), DisplayAnalog);
879 display_type_cb_->addItem(tr("converted"), DisplayConverted);
880 display_type_cb_->addItem(tr("analog+converted"), DisplayBoth);
a970015f
SA
881
882 cur_idx = display_type_cb_->findData(QVariant(display_type_));
883 display_type_cb_->setCurrentIndex(cur_idx);
884
c6b017fb 885 layout->addRow(tr("Show traces for"), display_type_cb_);
a970015f 886
b8c4a95b
SA
887 connect(display_type_cb_, SIGNAL(currentIndexChanged(int)),
888 this, SLOT(on_display_type_changed(int)));
889
52c900ac
SA
890 // Update the conversion widget contents and states
891 update_conversion_widgets();
892
368a37c2 893 form->addRow(layout);
4cffac16
SA
894}
895
c6d9cf65 896void AnalogSignal::on_min_max_changed(float min, float max)
85715407 897{
c6d9cf65
SA
898 (void)min;
899 (void)max;
900
901 if (autoranging_)
902 perform_autoranging(false, false);
85715407
SA
903}
904
459db2c5
SA
905void AnalogSignal::on_pos_vdivs_changed(int vdivs)
906{
430b94aa
SA
907 if (vdivs == pos_vdivs_)
908 return;
909
459db2c5
SA
910 pos_vdivs_ = vdivs;
911
80067e49
SA
912 // There has to be at least one div, positive or negative
913 if ((neg_vdivs_ == 0) && (pos_vdivs_ == 0)) {
914 pos_vdivs_ = 1;
915 if (pvdiv_sb_)
916 pvdiv_sb_->setValue(pos_vdivs_);
917 }
918
430b94aa
SA
919 if (autoranging_) {
920 perform_autoranging(true, true);
921
922 // It could be that a positive or negative div was added, so update
923 if (pvdiv_sb_) {
924 pvdiv_sb_->setValue(pos_vdivs_);
925 nvdiv_sb_->setValue(neg_vdivs_);
926 }
927 }
73e377fe 928
459db2c5
SA
929 if (owner_) {
930 // Call order is important, otherwise the lazy event handler won't work
931 owner_->extents_changed(false, true);
932 owner_->row_item_appearance_changed(false, true);
933 }
934}
935
936void AnalogSignal::on_neg_vdivs_changed(int vdivs)
4cffac16 937{
430b94aa
SA
938 if (vdivs == neg_vdivs_)
939 return;
940
459db2c5 941 neg_vdivs_ = vdivs;
4cffac16 942
80067e49
SA
943 // There has to be at least one div, positive or negative
944 if ((neg_vdivs_ == 0) && (pos_vdivs_ == 0)) {
945 pos_vdivs_ = 1;
946 if (pvdiv_sb_)
947 pvdiv_sb_->setValue(pos_vdivs_);
948 }
949
430b94aa
SA
950 if (autoranging_) {
951 perform_autoranging(true, true);
952
953 // It could be that a positive or negative div was added, so update
954 if (pvdiv_sb_) {
955 pvdiv_sb_->setValue(pos_vdivs_);
956 nvdiv_sb_->setValue(neg_vdivs_);
957 }
958 }
73e377fe 959
75d0779e
SA
960 if (owner_) {
961 // Call order is important, otherwise the lazy event handler won't work
4cffac16 962 owner_->extents_changed(false, true);
75d0779e
SA
963 owner_->row_item_appearance_changed(false, true);
964 }
4cffac16
SA
965}
966
cbb50547
SA
967void AnalogSignal::on_div_height_changed(int height)
968{
969 div_height_ = height;
970 update_scale();
971
972 if (owner_) {
973 // Call order is important, otherwise the lazy event handler won't work
974 owner_->extents_changed(false, true);
975 owner_->row_item_appearance_changed(false, true);
976 }
977}
978
368a37c2
SA
979void AnalogSignal::on_resolution_changed(int index)
980{
981 scale_index_ = resolution_cb_->itemData(index).toInt();
982 update_scale();
983
984 if (owner_)
985 owner_->row_item_appearance_changed(false, true);
986}
4cffac16 987
73e377fe
SA
988void AnalogSignal::on_autoranging_changed(int state)
989{
990 autoranging_ = (state == Qt::Checked);
991
992 if (autoranging_)
430b94aa 993 perform_autoranging(false, true);
73e377fe 994
85715407
SA
995 if (owner_) {
996 // Call order is important, otherwise the lazy event handler won't work
997 owner_->extents_changed(false, true);
73e377fe 998 owner_->row_item_appearance_changed(false, true);
85715407 999 }
73e377fe
SA
1000}
1001
a970015f
SA
1002void AnalogSignal::on_conversion_changed(int index)
1003{
2b6e7a72 1004 SignalBase::ConversionType old_conv_type = base_->get_conversion_type();
a8fd2759 1005
2b6e7a72
SA
1006 SignalBase::ConversionType conv_type =
1007 (SignalBase::ConversionType)(conversion_cb_->itemData(index).toInt());
a8fd2759 1008
06b6ce26
SA
1009 if (conv_type != old_conv_type) {
1010 base_->set_conversion_type(conv_type);
52c900ac 1011 update_conversion_widgets();
06b6ce26
SA
1012
1013 if (owner_)
1014 owner_->row_item_appearance_changed(false, true);
a8fd2759 1015 }
a970015f
SA
1016}
1017
52c900ac
SA
1018void AnalogSignal::on_conv_threshold_changed(int index)
1019{
2b6e7a72 1020 SignalBase::ConversionType conv_type = base_->get_conversion_type();
52c900ac
SA
1021
1022 // Note: index is set to -1 if the text in the combo box matches none of
1023 // the entries in the combo box
1024
1025 if ((index == -1) && (conv_threshold_cb_->currentText().length() == 0))
1026 return;
1027
1028 // The combo box entry with the custom value has user_data set to -1
1029 const int user_data = conv_threshold_cb_->findText(
1030 conv_threshold_cb_->currentText());
1031
1032 const bool use_custom_thr = (index == -1) || (user_data == -1);
1033
b9cdbe03 1034 if (conv_type == SignalBase::A2LConversionByThreshold && use_custom_thr) {
52c900ac
SA
1035 // Not one of the preset values, try to parse the combo box text
1036 // Note: Regex loosely based on
1037 // https://txt2re.com/index-c++.php3?s=0.1V&1&-13
1038 QString re1 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
1039 QString re2 = "([a-zA-Z]*)"; // SI unit
1040 QRegExp regex(re1 + re2);
1041
1042 const QString text = conv_threshold_cb_->currentText();
1043 if (!regex.exactMatch(text))
1044 return; // String doesn't match the regex
1045
1046 QStringList tokens = regex.capturedTexts();
1047
1048 // For now, we simply assume that the unit is volt without modifiers
1049 const double thr = tokens.at(1).toDouble();
1050
932bc246
SA
1051 // Only restart the conversion if the threshold was updated.
1052 // We're starting a delayed conversion because the user may still be
1053 // typing and the UI would lag if we kept on restarting it immediately
52c900ac 1054 if (base_->set_conversion_option("threshold_value", thr))
932bc246 1055 base_->start_conversion(true);
52c900ac
SA
1056 }
1057
2b6e7a72 1058 if (conv_type == SignalBase::A2LConversionBySchmittTrigger && use_custom_thr) {
52c900ac
SA
1059 // Not one of the preset values, try to parse the combo box text
1060 // Note: Regex loosely based on
1061 // https://txt2re.com/index-c++.php3?s=0.1V/0.2V&2&14&-22&3&15
1062 QString re1 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
1063 QString re2 = "([a-zA-Z]*)"; // SI unit
1064 QString re3 = "\\/"; // Forward slash, not captured
1065 QString re4 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
1066 QString re5 = "([a-zA-Z]*)"; // SI unit
1067 QRegExp regex(re1 + re2 + re3 + re4 + re5);
1068
1069 const QString text = conv_threshold_cb_->currentText();
1070 if (!regex.exactMatch(text))
1071 return; // String doesn't match the regex
1072
1073 QStringList tokens = regex.capturedTexts();
1074
1075 // For now, we simply assume that the unit is volt without modifiers
1076 const double low_thr = tokens.at(1).toDouble();
1077 const double high_thr = tokens.at(3).toDouble();
1078
932bc246
SA
1079 // Only restart the conversion if one of the options was updated.
1080 // We're starting a delayed conversion because the user may still be
1081 // typing and the UI would lag if we kept on restarting it immediately
52c900ac
SA
1082 bool o1 = base_->set_conversion_option("threshold_value_low", low_thr);
1083 bool o2 = base_->set_conversion_option("threshold_value_high", high_thr);
1084 if (o1 || o2)
932bc246 1085 base_->start_conversion(true); // Start delayed conversion
52c900ac
SA
1086 }
1087
f0f9c856 1088 base_->set_conversion_preset((SignalBase::ConversionPreset)index);
52c900ac 1089
932bc246
SA
1090 // Immediately start the conversion if we're not using custom values
1091 // (i.e. we're using one of the presets)
1092 if (!use_custom_thr)
52c900ac
SA
1093 base_->start_conversion();
1094}
1095
1096void AnalogSignal::on_delayed_conversion_starter()
1097{
1098 base_->start_conversion();
1099}
1100
b8c4a95b
SA
1101void AnalogSignal::on_display_type_changed(int index)
1102{
1103 display_type_ = (DisplayType)(display_type_cb_->itemData(index).toInt());
1104
1105 if (owner_)
1106 owner_->row_item_appearance_changed(false, true);
1107}
1108
90ee1ed9 1109void AnalogSignal::on_settingViewConversionThresholdDispMode_changed(const QVariant new_value)
2601ce96 1110{
90ee1ed9 1111 conversion_threshold_disp_mode_ = new_value.toInt();
2601ce96
SA
1112
1113 if (owner_)
1114 owner_->row_item_appearance_changed(false, true);
1115}
1116
1573bf16 1117} // namespace trace
f4e57597 1118} // namespace views
aba1dd16 1119} // namespace pv