]> sigrok.org Git - pulseview.git/blame - pv/view/analogsignal.cpp
LogicSignal: Don't depend on device_ being valid
[pulseview.git] / pv / view / 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>
aba1dd16 26
37b9fed4 27#include <QApplication>
73e377fe 28#include <QCheckBox>
368a37c2 29#include <QComboBox>
4cffac16 30#include <QFormLayout>
368a37c2
SA
31#include <QGridLayout>
32#include <QLabel>
4cffac16 33#include <QSpinBox>
03cc651d 34#include <QString>
37b9fed4 35
2acdb232
JH
36#include "analogsignal.hpp"
37#include "pv/data/analog.hpp"
f3d66e52 38#include "pv/data/analogsegment.hpp"
bf0edd2b 39#include "pv/data/signalbase.hpp"
2acdb232 40#include "pv/view/view.hpp"
8de1e1b2 41#include "pv/globalsettings.hpp"
aba1dd16 42
fe3a1c21 43#include <libsigrokcxx/libsigrokcxx.hpp>
e8d00928 44
6f925ba9
UH
45using std::deque;
46using std::div;
47using std::div_t;
819f4c25 48using std::max;
a5d93c27 49using std::make_pair;
819f4c25 50using std::min;
6f925ba9
UH
51using std::numeric_limits;
52using std::pair;
f9abf97e 53using std::shared_ptr;
aba1dd16
JH
54
55namespace pv {
f4e57597
SA
56namespace views {
57namespace TraceView {
aba1dd16 58
568b90d4
JH
59const QColor AnalogSignal::SignalColours[4] = {
60 QColor(0xC4, 0xA0, 0x00), // Yellow
61 QColor(0x87, 0x20, 0x7A), // Magenta
62 QColor(0x20, 0x4A, 0x87), // Blue
63 QColor(0x4E, 0x9A, 0x06) // Green
64};
65
46a0cadc
SA
66const QColor AnalogSignal::GridMajorColor = QColor(0, 0, 0, 40*256/100);
67const QColor AnalogSignal::GridMinorColor = QColor(0, 0, 0, 20*256/100);
37b9fed4 68
8de1e1b2
UH
69const QColor AnalogSignal::SamplingPointColour(0x77, 0x77, 0x77);
70
7c68ddae
JH
71const float AnalogSignal::EnvelopeThreshold = 256.0f;
72
4cffac16 73const int AnalogSignal::MaximumVDivs = 10;
368a37c2
SA
74const int AnalogSignal::MinScaleIndex = -6;
75const int AnalogSignal::MaxScaleIndex = 7;
4cffac16 76
03cc651d
SA
77const int AnalogSignal::InfoTextMarginRight = 20;
78const int AnalogSignal::InfoTextMarginBottom = 5;
79
b86aa8f4 80AnalogSignal::AnalogSignal(
2b81ae46 81 pv::Session &session,
cbd2a2de 82 shared_ptr<data::SignalBase> base) :
73a25a6e 83 Signal(session, base),
834a4f1b 84 scale_index_(4), // 20 per div
37b9fed4
SA
85 scale_index_drag_offset_(0),
86 div_height_(3 * QFontMetrics(QApplication::font()).height()),
459db2c5
SA
87 pos_vdivs_(1),
88 neg_vdivs_(1),
73e377fe 89 resolution_(0),
a970015f
SA
90 conversion_type_(data::SignalBase::NoConversion),
91 display_type_(DisplayBoth),
1f1d55ce 92 autoranging_(true)
aba1dd16 93{
85715407
SA
94 pv::data::Analog* analog_data =
95 dynamic_cast<pv::data::Analog*>(data().get());
96
97 connect(analog_data, SIGNAL(samples_added(QObject*, uint64_t, uint64_t)),
98 this, SLOT(on_samples_added()));
99
73a25a6e 100 base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
834a4f1b 101 update_scale();
aba1dd16
JH
102}
103
3009b5b3
JH
104shared_ptr<pv::data::SignalData> AnalogSignal::data() const
105{
cbd2a2de 106 return base_->analog_data();
9a0cd293
JH
107}
108
3a21afa6
SA
109void AnalogSignal::save_settings(QSettings &settings) const
110{
459db2c5
SA
111 settings.setValue("pos_vdivs", pos_vdivs_);
112 settings.setValue("neg_vdivs", neg_vdivs_);
3a21afa6 113 settings.setValue("scale_index", scale_index_);
a970015f
SA
114 settings.setValue("conversion_type", conversion_type_);
115 settings.setValue("display_type", display_type_);
73e377fe 116 settings.setValue("autoranging", autoranging_);
3a21afa6
SA
117}
118
119void AnalogSignal::restore_settings(QSettings &settings)
120{
459db2c5
SA
121 if (settings.contains("pos_vdivs"))
122 pos_vdivs_ = settings.value("pos_vdivs").toInt();
123
124 if (settings.contains("neg_vdivs"))
125 neg_vdivs_ = settings.value("neg_vdivs").toInt();
3a21afa6
SA
126
127 if (settings.contains("scale_index")) {
128 scale_index_ = settings.value("scale_index").toInt();
129 update_scale();
130 }
73e377fe 131
a970015f
SA
132 if (settings.contains("conversion_type"))
133 conversion_type_ = (data::SignalBase::ConversionType)(settings.value("conversion_type").toInt());
134
135 if (settings.contains("display_type"))
136 display_type_ = (DisplayType)(settings.value("display_type").toInt());
137
73e377fe
SA
138 if (settings.contains("autoranging"))
139 autoranging_ = settings.value("autoranging").toBool();
3a21afa6
SA
140}
141
6f925ba9 142pair<int, int> AnalogSignal::v_extents() const
a5d93c27 143{
459db2c5
SA
144 const int ph = pos_vdivs_ * div_height_;
145 const int nh = neg_vdivs_ * div_height_;
146 return make_pair(-ph, nh);
a5d93c27
JH
147}
148
214470fc
JH
149int AnalogSignal::scale_handle_offset() const
150{
459db2c5 151 const int h = (pos_vdivs_ + neg_vdivs_) * div_height_;
37b9fed4 152
8a2fafcc 153 return ((scale_index_drag_offset_ - scale_index_) *
37b9fed4 154 h / 4) - h / 2;
214470fc
JH
155}
156
157void AnalogSignal::scale_handle_dragged(int offset)
158{
459db2c5 159 const int h = (pos_vdivs_ + neg_vdivs_) * div_height_;
37b9fed4 160
8a2fafcc 161 scale_index_ = scale_index_drag_offset_ -
37b9fed4 162 (offset + h / 2) / (h / 4);
834a4f1b
SA
163
164 update_scale();
8a2fafcc
JH
165}
166
167void AnalogSignal::scale_handle_drag_release()
168{
169 scale_index_drag_offset_ = scale_index_;
834a4f1b 170 update_scale();
214470fc
JH
171}
172
5b5fa4da 173void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
fe08b6e8 174{
73a25a6e 175 if (base_->enabled()) {
99af6802 176 Trace::paint_back(p, pp);
97904bf7 177 paint_axis(p, pp, get_visual_y());
99af6802 178 }
fe08b6e8
JH
179}
180
5b5fa4da 181void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp)
aba1dd16 182{
cbd2a2de 183 assert(base_->analog_data());
8dbbc7f0 184 assert(owner_);
a8acb46e 185
be9e7b4b 186 const int y = get_visual_y();
01fd3263 187
73a25a6e 188 if (!base_->enabled())
cec48d16
JH
189 return;
190
37b9fed4
SA
191 paint_grid(p, y, pp.left(), pp.right());
192
f3d66e52 193 const deque< shared_ptr<pv::data::AnalogSegment> > &segments =
cbd2a2de 194 base_->analog_data()->analog_segments();
f3d66e52 195 if (segments.empty())
a8acb46e
JH
196 return;
197
f3d66e52
JH
198 const shared_ptr<pv::data::AnalogSegment> &segment =
199 segments.front();
a8acb46e 200
4c8a6a6d 201 const double pixels_offset = pp.pixels_offset();
69e33a1b 202 const double samplerate = max(1.0, segment->samplerate());
60d9b99a 203 const pv::util::Timestamp& start_time = segment->start_time();
f3d66e52 204 const int64_t last_sample = segment->get_sample_count() - 1;
4c8a6a6d 205 const double samples_per_pixel = samplerate * pp.scale();
60d9b99a
JS
206 const pv::util::Timestamp start = samplerate * (pp.offset() - start_time);
207 const pv::util::Timestamp end = start + samples_per_pixel * pp.width();
a8acb46e 208
60d9b99a 209 const int64_t start_sample = min(max(floor(start).convert_to<int64_t>(),
a8acb46e 210 (int64_t)0), last_sample);
60d9b99a 211 const int64_t end_sample = min(max((ceil(end) + 1).convert_to<int64_t>(),
a8acb46e
JH
212 (int64_t)0), last_sample);
213
7c68ddae 214 if (samples_per_pixel < EnvelopeThreshold)
f3d66e52 215 paint_trace(p, segment, y, pp.left(),
7c68ddae
JH
216 start_sample, end_sample,
217 pixels_offset, samples_per_pixel);
218 else
f3d66e52 219 paint_envelope(p, segment, y, pp.left(),
7c68ddae
JH
220 start_sample, end_sample,
221 pixels_offset, samples_per_pixel);
222}
223
03cc651d
SA
224void AnalogSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
225{
226 if (!enabled())
227 return;
228
229 const int y = get_visual_y();
230
231 // Show the info section on the right side of the trace
232 const QString infotext = QString("%1 V/div").arg(resolution_);
233
73a25a6e 234 p.setPen(base_->colour());
03cc651d
SA
235 p.setFont(QApplication::font());
236
237 const QRectF bounding_rect = QRectF(pp.left(),
238 y + v_extents().first,
239 pp.width() - InfoTextMarginRight,
240 v_extents().second - v_extents().first - InfoTextMarginBottom);
241
242 p.drawText(bounding_rect, Qt::AlignRight | Qt::AlignBottom, infotext);
243}
244
37b9fed4
SA
245void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right)
246{
46a0cadc
SA
247 p.setRenderHint(QPainter::Antialiasing, false);
248
459db2c5
SA
249 if (pos_vdivs_ > 0) {
250 p.setPen(QPen(GridMajorColor, 1, Qt::DashLine));
251 for (int i = 1; i <= pos_vdivs_; i++) {
252 const float dy = i * div_height_;
253 p.drawLine(QLineF(left, y - dy, right, y - dy));
254 }
255
256 p.setPen(QPen(GridMinorColor, 1, Qt::DashLine));
257 for (int i = 0; i < pos_vdivs_; i++) {
258 const float dy = i * div_height_;
259 const float dy25 = dy + (0.25 * div_height_);
260 const float dy50 = dy + (0.50 * div_height_);
261 const float dy75 = dy + (0.75 * div_height_);
262 p.drawLine(QLineF(left, y - dy25, right, y - dy25));
263 p.drawLine(QLineF(left, y - dy50, right, y - dy50));
264 p.drawLine(QLineF(left, y - dy75, right, y - dy75));
265 }
37b9fed4
SA
266 }
267
459db2c5
SA
268 if (neg_vdivs_ > 0) {
269 p.setPen(QPen(GridMajorColor, 1, Qt::DashLine));
270 for (int i = 1; i <= neg_vdivs_; i++) {
271 const float dy = i * div_height_;
272 p.drawLine(QLineF(left, y + dy, right, y + dy));
273 }
274
275 p.setPen(QPen(GridMinorColor, 1, Qt::DashLine));
276 for (int i = 0; i < neg_vdivs_; i++) {
277 const float dy = i * div_height_;
278 const float dy25 = dy + (0.25 * div_height_);
279 const float dy50 = dy + (0.50 * div_height_);
280 const float dy75 = dy + (0.75 * div_height_);
281 p.drawLine(QLineF(left, y + dy25, right, y + dy25));
282 p.drawLine(QLineF(left, y + dy50, right, y + dy50));
283 p.drawLine(QLineF(left, y + dy75, right, y + dy75));
284 }
37b9fed4 285 }
46a0cadc
SA
286
287 p.setRenderHint(QPainter::Antialiasing, true);
37b9fed4
SA
288}
289
7c68ddae 290void AnalogSignal::paint_trace(QPainter &p,
f3d66e52 291 const shared_ptr<pv::data::AnalogSegment> &segment,
7c68ddae
JH
292 int y, int left, const int64_t start, const int64_t end,
293 const double pixels_offset, const double samples_per_pixel)
294{
73a25a6e 295 p.setPen(base_->colour());
7c68ddae 296
76ce6c7a
UH
297 const int64_t points_count = end - start;
298
299 QPointF *points = new QPointF[points_count];
a8acb46e
JH
300 QPointF *point = points;
301
8de1e1b2
UH
302 QRectF *const sampling_points = new QRectF[points_count];
303 QRectF *sampling_point = sampling_points;
304
26a883ed
SA
305 pv::data::SegmentAnalogDataIterator* it =
306 segment->begin_sample_iteration(start);
307
8de1e1b2 308 const int w = 2;
7c68ddae 309 for (int64_t sample = start; sample != end; sample++) {
a8acb46e 310 const float x = (sample / samples_per_pixel -
2658961b 311 pixels_offset) + left;
26a883ed
SA
312
313 *point++ = QPointF(x, y - *((float*)it->value) * scale_);
8de1e1b2
UH
314 *sampling_point++ = QRectF(x - (w / 2), y - *((float*)it->value) * scale_ - (w / 2), w, w);
315
26a883ed 316 segment->continue_sample_iteration(it, 1);
a8acb46e 317 }
26a883ed 318 segment->end_sample_iteration(it);
a8acb46e 319
76ce6c7a 320 p.drawPolyline(points, points_count);
a8acb46e 321
8de1e1b2
UH
322 // Paint the sampling points if enabled
323 GlobalSettings settings;
324 const bool show_sampling_points =
325 settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool();
00f6bae9
UH
326
327 if (show_sampling_points && (samples_per_pixel < 0.25)) {
8de1e1b2
UH
328 p.setPen(SamplingPointColour);
329 p.drawRects(sampling_points, points_count);
330 }
331
a8acb46e 332 delete[] points;
8de1e1b2 333 delete[] sampling_points;
aba1dd16
JH
334}
335
7c68ddae 336void AnalogSignal::paint_envelope(QPainter &p,
f3d66e52 337 const shared_ptr<pv::data::AnalogSegment> &segment,
7c68ddae
JH
338 int y, int left, const int64_t start, const int64_t end,
339 const double pixels_offset, const double samples_per_pixel)
340{
f3d66e52 341 using pv::data::AnalogSegment;
7c68ddae 342
f3d66e52
JH
343 AnalogSegment::EnvelopeSection e;
344 segment->get_envelope_section(e, start, end, samples_per_pixel);
7c68ddae
JH
345
346 if (e.length < 2)
347 return;
348
819f4c25 349 p.setPen(QPen(Qt::NoPen));
73a25a6e 350 p.setBrush(base_->colour());
7c68ddae
JH
351
352 QRectF *const rects = new QRectF[e.length];
353 QRectF *rect = rects;
354
f3290553 355 for (uint64_t sample = 0; sample < e.length-1; sample++) {
7c68ddae
JH
356 const float x = ((e.scale * sample + e.start) /
357 samples_per_pixel - pixels_offset) + left;
f3d66e52 358 const AnalogSegment::EnvelopeSample *const s =
7c68ddae
JH
359 e.samples + sample;
360
361 // We overlap this sample with the next so that vertical
362 // gaps do not appear during steep rising or falling edges
834a4f1b
SA
363 const float b = y - max(s->max, (s+1)->min) * scale_;
364 const float t = y - min(s->min, (s+1)->max) * scale_;
7c68ddae
JH
365
366 float h = b - t;
f3290553 367 if (h >= 0.0f && h <= 1.0f)
7c68ddae 368 h = 1.0f;
f3290553 369 if (h <= 0.0f && h >= -1.0f)
7c68ddae
JH
370 h = -1.0f;
371
372 *rect++ = QRectF(x, t, 1.0f, h);
373 }
374
375 p.drawRects(rects, e.length);
376
377 delete[] rects;
378 delete[] e.samples;
379}
380
368a37c2 381float AnalogSignal::get_resolution(int scale_index)
8a2fafcc
JH
382{
383 const float seq[] = {1.0f, 2.0f, 5.0f};
834a4f1b 384
6f925ba9
UH
385 const int offset = numeric_limits<int>::max() / (2 * countof(seq));
386 const div_t d = div((int)(scale_index + countof(seq) * offset),
8a2fafcc 387 countof(seq));
834a4f1b 388
368a37c2
SA
389 return powf(10.0f, d.quot - offset) * seq[d.rem];
390}
391
392void AnalogSignal::update_scale()
393{
394 resolution_ = get_resolution(scale_index_);
834a4f1b 395 scale_ = div_height_ / resolution_;
8a2fafcc
JH
396}
397
73e377fe
SA
398void AnalogSignal::perform_autoranging(bool force_update)
399{
400 const deque< shared_ptr<pv::data::AnalogSegment> > &segments =
401 base_->analog_data()->analog_segments();
402
403 if (segments.empty())
404 return;
405
406 static double prev_min = 0, prev_max = 0;
407 double min = 0, max = 0;
408
409 for (shared_ptr<pv::data::AnalogSegment> segment : segments) {
6f925ba9 410 pair<double, double> mm = segment->get_min_max();
73e377fe
SA
411 min = std::min(min, mm.first);
412 max = std::max(max, mm.second);
413 }
414
415 if ((min == prev_min) && (max == prev_max) && !force_update)
416 return;
417
418 prev_min = min;
419 prev_max = max;
420
421 // Use all divs for the positive range if there are no negative values
422 if ((min == 0) && (neg_vdivs_ > 0)) {
423 pos_vdivs_ += neg_vdivs_;
424 neg_vdivs_ = 0;
425 }
426
681b6d5a
SA
427 // Split up the divs if there are negative values but no negative divs
428 if ((min < 0) && (neg_vdivs_ == 0)) {
429 neg_vdivs_ = pos_vdivs_ / 2;
430 pos_vdivs_ -= neg_vdivs_;
431 }
432
73e377fe
SA
433 double min_value_per_div;
434 if ((pos_vdivs_ > 0) && (neg_vdivs_ > 0))
435 min_value_per_div = std::max(max / pos_vdivs_, -min / neg_vdivs_);
436 else if (pos_vdivs_ > 0)
437 min_value_per_div = max / pos_vdivs_;
438 else
439 min_value_per_div = -min / neg_vdivs_;
440
441 // Find first scale value that is bigger than the value we need
442 for (int i = MinScaleIndex; i < MaxScaleIndex; i++)
443 if (get_resolution(i) > min_value_per_div) {
444 scale_index_ = i;
445 break;
446 }
447
448 update_scale();
449}
450
4cffac16
SA
451void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form)
452{
453 // Add the standard options
454 Signal::populate_popup_form(parent, form);
455
368a37c2
SA
456 QFormLayout *const layout = new QFormLayout;
457
458 // Add the number of vdivs
459db2c5
SA
459 QSpinBox *pvdiv_sb = new QSpinBox(parent);
460 pvdiv_sb->setRange(0, MaximumVDivs);
461 pvdiv_sb->setValue(pos_vdivs_);
462 connect(pvdiv_sb, SIGNAL(valueChanged(int)),
463 this, SLOT(on_pos_vdivs_changed(int)));
464 layout->addRow(tr("Number of pos vertical divs"), pvdiv_sb);
465
466 QSpinBox *nvdiv_sb = new QSpinBox(parent);
467 nvdiv_sb->setRange(0, MaximumVDivs);
468 nvdiv_sb->setValue(neg_vdivs_);
469 connect(nvdiv_sb, SIGNAL(valueChanged(int)),
470 this, SLOT(on_neg_vdivs_changed(int)));
471 layout->addRow(tr("Number of neg vertical divs"), nvdiv_sb);
368a37c2
SA
472
473 // Add the vertical resolution
474 resolution_cb_ = new QComboBox(parent);
475
476 for (int i = MinScaleIndex; i < MaxScaleIndex; i++) {
477 const QString label = QString("%1").arg(get_resolution(i));
478 resolution_cb_->insertItem(0, label, QVariant(i));
479 }
480
a970015f 481 int cur_idx = resolution_cb_->findData(QVariant(scale_index_));
368a37c2
SA
482 resolution_cb_->setCurrentIndex(cur_idx);
483
484 connect(resolution_cb_, SIGNAL(currentIndexChanged(int)),
485 this, SLOT(on_resolution_changed(int)));
486
487 QGridLayout *const vdiv_layout = new QGridLayout;
488 QLabel *const vdiv_unit = new QLabel(tr("V/div"));
489 vdiv_layout->addWidget(resolution_cb_, 0, 0);
490 vdiv_layout->addWidget(vdiv_unit, 0, 1);
491
492 layout->addRow(tr("Vertical resolution"), vdiv_layout);
493
73e377fe
SA
494 // Add the autoranging checkbox
495 QCheckBox* autoranging_cb = new QCheckBox();
496 autoranging_cb->setCheckState(autoranging_ ? Qt::Checked : Qt::Unchecked);
497
498 connect(autoranging_cb, SIGNAL(stateChanged(int)),
499 this, SLOT(on_autoranging_changed(int)));
500
501 layout->addRow(tr("Autoranging"), autoranging_cb);
502
a970015f
SA
503 // Add the conversion type dropdown
504 conversion_cb_ = new QComboBox();
505
506 conversion_cb_->addItem("none", data::SignalBase::NoConversion);
507 conversion_cb_->addItem("to logic via threshold", data::SignalBase::A2LConversionByTreshold);
508 conversion_cb_->addItem("to logic via schmitt-trigger", data::SignalBase::A2LConversionBySchmittTrigger);
509
510 cur_idx = conversion_cb_->findData(QVariant(conversion_type_));
511 conversion_cb_->setCurrentIndex(cur_idx);
512
513 layout->addRow(tr("Conversion"), conversion_cb_);
514
515 connect(conversion_cb_, SIGNAL(currentIndexChanged(int)),
516 this, SLOT(on_conversion_changed(int)));
517
518 // Add the display type dropdown
519 display_type_cb_ = new QComboBox();
520
521 display_type_cb_->addItem(tr("Analog"), DisplayAnalog);
522 display_type_cb_->addItem(tr("Converted"), DisplayConverted);
523 display_type_cb_->addItem(tr("Both"), DisplayBoth);
524
525 cur_idx = display_type_cb_->findData(QVariant(display_type_));
526 display_type_cb_->setCurrentIndex(cur_idx);
527
528 layout->addRow(tr("Traces to show:"), display_type_cb_);
529
368a37c2 530 form->addRow(layout);
4cffac16
SA
531}
532
85715407
SA
533void AnalogSignal::on_samples_added()
534{
535 perform_autoranging();
536
537 if (owner_) {
538 // Call order is important, otherwise the lazy event handler won't work
539 owner_->extents_changed(false, true);
540 owner_->row_item_appearance_changed(false, true);
541 }
542}
543
459db2c5
SA
544void AnalogSignal::on_pos_vdivs_changed(int vdivs)
545{
546 pos_vdivs_ = vdivs;
547
73e377fe
SA
548 if (autoranging_)
549 perform_autoranging(true);
550
459db2c5
SA
551 if (owner_) {
552 // Call order is important, otherwise the lazy event handler won't work
553 owner_->extents_changed(false, true);
554 owner_->row_item_appearance_changed(false, true);
555 }
556}
557
558void AnalogSignal::on_neg_vdivs_changed(int vdivs)
4cffac16 559{
459db2c5 560 neg_vdivs_ = vdivs;
4cffac16 561
73e377fe
SA
562 if (autoranging_)
563 perform_autoranging(true);
564
75d0779e
SA
565 if (owner_) {
566 // Call order is important, otherwise the lazy event handler won't work
4cffac16 567 owner_->extents_changed(false, true);
75d0779e
SA
568 owner_->row_item_appearance_changed(false, true);
569 }
4cffac16
SA
570}
571
368a37c2
SA
572void AnalogSignal::on_resolution_changed(int index)
573{
574 scale_index_ = resolution_cb_->itemData(index).toInt();
575 update_scale();
576
577 if (owner_)
578 owner_->row_item_appearance_changed(false, true);
579}
4cffac16 580
73e377fe
SA
581void AnalogSignal::on_autoranging_changed(int state)
582{
583 autoranging_ = (state == Qt::Checked);
584
585 if (autoranging_)
586 perform_autoranging(true);
587
85715407
SA
588 if (owner_) {
589 // Call order is important, otherwise the lazy event handler won't work
590 owner_->extents_changed(false, true);
73e377fe 591 owner_->row_item_appearance_changed(false, true);
85715407 592 }
73e377fe
SA
593}
594
a970015f
SA
595void AnalogSignal::on_conversion_changed(int index)
596{
597 conversion_type_ = (data::SignalBase::ConversionType)(conversion_cb_->itemData(index).toInt());
598 base_->set_conversion_type(conversion_type_);
599}
600
f4e57597
SA
601} // namespace TraceView
602} // namespace views
aba1dd16 603} // namespace pv