projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AnalogSignal: Use setting change handler for threshold display
[pulseview.git]
/
pv
/
views
/
trace
/
analogsignal.cpp
diff --git
a/pv/views/trace/analogsignal.cpp
b/pv/views/trace/analogsignal.cpp
index 58a186ecf0229cd28e7a2bd134f9e76613205667..5e7081d61145e0555dc8a048cc65c850c5f49de0 100644
(file)
--- a/
pv/views/trace/analogsignal.cpp
+++ b/
pv/views/trace/analogsignal.cpp
@@
-46,6
+46,7
@@
#include <libsigrokcxx/libsigrokcxx.hpp>
#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::bind;
using std::deque;
using std::div;
using std::div_t;
using std::deque;
using std::div;
using std::div_t;
@@
-54,6
+55,7
@@
using std::make_pair;
using std::min;
using std::numeric_limits;
using std::pair;
using std::min;
using std::numeric_limits;
using std::pair;
+using std::placeholders::_1;
using std::shared_ptr;
using std::vector;
using std::shared_ptr;
using std::vector;
@@
-111,7
+113,13
@@
AnalogSignal::AnalogSignal(
connect(analog_data, SIGNAL(min_max_changed(float, float)),
this, SLOT(on_min_max_changed(float, float)));
connect(analog_data, SIGNAL(min_max_changed(float, float)),
this, SLOT(on_min_max_changed(float, float)));
+ GlobalSettings::register_change_handler(GlobalSettings::Key_View_ShowConversionThresholds,
+ bind(&AnalogSignal::on_settingViewShowConversionThresholds_changed, this, _1));
+
GlobalSettings gs;
GlobalSettings gs;
+ show_conversion_thresholds_ =
+ gs.value(GlobalSettings::Key_View_ShowConversionThresholds).toBool();
+
div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt();
base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt();
base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
@@
-198,15
+206,10
@@
void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp)
if (!base_->enabled())
return;
if (!base_->enabled())
return;
- // TODO Register a change handler instead of querying this with every repaint
- GlobalSettings settings;
- const bool show_conversion_thresholds =
- settings.value(GlobalSettings::Key_View_ShowConversionThresholds).toBool();
-
const vector<double> thresholds = base_->get_conversion_thresholds();
// Only display thresholds if we have some and we show analog samples
const vector<double> thresholds = base_->get_conversion_thresholds();
// Only display thresholds if we have some and we show analog samples
- if ((thresholds.size() > 0) && show_conversion_thresholds &&
+ if ((thresholds.size() > 0) && show_conversion_thresholds
_
&&
((display_type_ == DisplayAnalog) || (display_type_ == DisplayBoth))) {
const int visual_y = get_visual_y();
((display_type_ == DisplayAnalog) || (display_type_ == DisplayBoth))) {
const int visual_y = get_visual_y();
@@
-1070,6
+1073,14
@@
void AnalogSignal::on_display_type_changed(int index)
owner_->row_item_appearance_changed(false, true);
}
owner_->row_item_appearance_changed(false, true);
}
+void AnalogSignal::on_settingViewShowConversionThresholds_changed(const QVariant new_value)
+{
+ show_conversion_thresholds_ = new_value.toBool();
+
+ if (owner_)
+ owner_->row_item_appearance_changed(false, true);
+}
+
} // namespace trace
} // namespace views
} // namespace pv
} // namespace trace
} // namespace views
} // namespace pv