using Gst::Pipeline;
#endif
+using pv::views::trace::Signal;
+using pv::views::trace::AnalogSignal;
+using pv::views::trace::LogicSignal;
+
namespace pv {
shared_ptr<sigrok::Context> Session::sr_context;
qobject_cast<views::trace::View*>(viewbase.get());
if (trace_view) {
- unordered_set< shared_ptr<views::trace::Signal> >
- prev_sigs(trace_view->signals());
+ unordered_set< shared_ptr<Signal> > prev_sigs(trace_view->signals());
trace_view->clear_signals();
for (auto channel : sr_dev->channels()) {
shared_ptr<data::SignalBase> signalbase;
- shared_ptr<views::trace::Signal> signal;
+ shared_ptr<Signal> signal;
// Find the channel in the old signals
const auto iter = find_if(
prev_sigs.cbegin(), prev_sigs.cend(),
- [&](const shared_ptr<views::trace::Signal> &s) {
+ [&](const shared_ptr<Signal> &s) {
return s->base()->channel() == channel;
});
if (iter != prev_sigs.end()) {
if (b->channel() == channel)
signalbase = b;
+ shared_ptr<Signal> signal;
+
switch(channel->type()->id()) {
case SR_CHANNEL_LOGIC:
if (!signalbase) {
signalbase.get(), SLOT(on_capture_state_changed(int)));
}
- signal = shared_ptr<views::trace::Signal>(
- new views::trace::LogicSignal(*this,
- device_, signalbase));
- trace_view->add_signal(signal);
+ signal = shared_ptr<Signal>(new LogicSignal(*this, device_, signalbase));
break;
case SR_CHANNEL_ANALOG:
signalbase.get(), SLOT(on_capture_state_changed(int)));
}
- signal = shared_ptr<views::trace::Signal>(
- new views::trace::AnalogSignal(
- *this, signalbase));
- trace_view->add_signal(signal);
+ signal = shared_ptr<Signal>(new AnalogSignal(*this, signalbase));
break;
}
assert(false);
break;
}
+
+ // New views take their signal settings from the main view
+ if (!viewbase->is_main_view()) {
+ shared_ptr<pv::views::trace::View> main_tv =
+ dynamic_pointer_cast<pv::views::trace::View>(main_view_);
+ shared_ptr<Signal> main_signal =
+ main_tv->get_signal_by_signalbase(signalbase);
+ signal->restore_settings(main_signal->save_settings());
+ }
+
+ trace_view->add_signal(signal);
}
}
}
pv::Session &session,
shared_ptr<data::SignalBase> base) :
Signal(session, base),
+ value_at_hover_pos_(std::numeric_limits<float>::quiet_NaN()),
scale_index_(4), // 20 per div
pos_vdivs_(1),
neg_vdivs_(1),
resolution_(0),
display_type_(DisplayBoth),
- autoranging_(true),
- value_at_hover_pos_(std::numeric_limits<float>::quiet_NaN())
+ autoranging_(true)
{
axis_pen_ = AxisPen;
return base_->analog_data();
}
-void AnalogSignal::save_settings(QSettings &settings) const
+std::map<QString, QVariant> AnalogSignal::save_settings() const
{
- settings.setValue("pos_vdivs", pos_vdivs_);
- settings.setValue("neg_vdivs", neg_vdivs_);
- settings.setValue("scale_index", scale_index_);
- settings.setValue("display_type", display_type_);
- settings.setValue("autoranging", autoranging_);
- settings.setValue("div_height", div_height_);
+ std::map<QString, QVariant> result;
+
+ result["pos_vdivs"] = pos_vdivs_;
+ result["neg_vdivs"] = neg_vdivs_;
+ result["scale_index"] = scale_index_;
+ result["display_type"] = display_type_;
+ result["autoranging"] = pos_vdivs_;
+ result["div_height"] = div_height_;
+
+ return result;
}
-void AnalogSignal::restore_settings(QSettings &settings)
+void AnalogSignal::restore_settings(std::map<QString, QVariant> settings)
{
- if (settings.contains("pos_vdivs"))
- pos_vdivs_ = settings.value("pos_vdivs").toInt();
+ auto entry = settings.find("pos_vdivs");
+ if (entry != settings.end())
+ pos_vdivs_ = settings["pos_vdivs"].toInt();
- if (settings.contains("neg_vdivs"))
- neg_vdivs_ = settings.value("neg_vdivs").toInt();
+ entry = settings.find("neg_vdivs");
+ if (entry != settings.end())
+ neg_vdivs_ = settings["neg_vdivs"].toInt();
- if (settings.contains("scale_index")) {
- scale_index_ = settings.value("scale_index").toInt();
+ entry = settings.find("scale_index");
+ if (entry != settings.end()) {
+ scale_index_ = settings["scale_index"].toInt();
update_scale();
}
- if (settings.contains("display_type"))
- display_type_ = (DisplayType)(settings.value("display_type").toInt());
+ entry = settings.find("display_type");
+ if (entry != settings.end())
+ display_type_ = (DisplayType)(settings["display_type"].toInt());
- if (settings.contains("autoranging"))
- autoranging_ = settings.value("autoranging").toBool();
+ entry = settings.find("autoranging");
+ if (entry != settings.end())
+ autoranging_ = settings["autoranging"].toBool();
- if (settings.contains("div_height")) {
+ entry = settings.find("div_height");
+ if (entry != settings.end()) {
const int old_height = div_height_;
- div_height_ = settings.value("div_height").toInt();
+ div_height_ = settings["div_height"].toInt();
if ((div_height_ != old_height) && owner_) {
// Call order is important, otherwise the lazy event handler won't work
shared_ptr<pv::data::SignalData> data() const;
- virtual void save_settings(QSettings &settings) const;
-
- virtual void restore_settings(QSettings &settings);
+ virtual std::map<QString, QVariant> save_settings() const;
+ virtual void restore_settings(std::map<QString, QVariant> settings);
/**
* Computes the vertical extents of the contents of this row item.
double signal_min_, signal_max_; // Min/max values of this signal's analog data
- float scale_;
- int scale_index_;
-
- int div_height_;
- int pos_vdivs_, neg_vdivs_; // divs per positive/negative side
- float resolution_; // e.g. 10 for 10 V/div
-
bool show_analog_minor_grid_;
QColor high_fill_color_;
bool show_sampling_points_, fill_high_areas_;
- DisplayType display_type_;
- bool autoranging_;
int conversion_threshold_disp_mode_;
vector<float> value_at_pixel_pos_;
float prev_value_at_pixel_; // Only used during lookup table update
float min_value_at_pixel_, max_value_at_pixel_; // Only used during lookup table update
int current_pixel_pos_; // Only used during lookup table update
+
+ // ---------------------------------------------------------------------------
+ // Note: Make sure to update .. when adding a trace-configurable variable here
+ float scale_;
+ int scale_index_;
+
+ int div_height_;
+ int pos_vdivs_, neg_vdivs_; // divs per positive/negative side
+ float resolution_; // e.g. 10 for 10 V/div
+
+ DisplayType display_type_;
+ bool autoranging_;
};
} // namespace trace
return base_->logic_data();
}
-void LogicSignal::save_settings(QSettings &settings) const
+std::map<QString, QVariant> LogicSignal::save_settings() const
{
- settings.setValue("trace_height", signal_height_);
+ std::map<QString, QVariant> result;
+
+ result["trace_height"] = signal_height_;
+
+ return result;
}
-void LogicSignal::restore_settings(QSettings &settings)
+void LogicSignal::restore_settings(std::map<QString, QVariant> settings)
{
- if (settings.contains("trace_height")) {
+ auto entry = settings.find("trace_height");
+ if (entry != settings.end()) {
const int old_height = signal_height_;
- signal_height_ = settings.value("trace_height").toInt();
+ signal_height_ = settings["trace_height"].toInt();
if ((signal_height_ != old_height) && owner_) {
// Call order is important, otherwise the lazy event handler won't work
shared_ptr<pv::data::Logic> logic_data() const;
- virtual void save_settings(QSettings &settings) const;
- virtual void restore_settings(QSettings &settings);
+ virtual std::map<QString, QVariant> save_settings() const;
+ virtual void restore_settings(std::map<QString, QVariant> settings);
/**
* Computes the vertical extents of the contents of this row item.
void Signal::save_settings(QSettings &settings) const
{
- (void)settings;
+ std::map<QString, QVariant> settings_map = save_settings();
+
+ for (auto& entry : settings_map)
+ settings.setValue(entry.first, entry.second);
+}
+
+std::map<QString, QVariant> Signal::save_settings() const
+{
+ return std::map<QString, QVariant>();
}
void Signal::restore_settings(QSettings &settings)
+{
+ std::map<QString, QVariant> settings_map;
+
+ QStringList keys = settings.allKeys();
+ for (int i = 0; i < keys.size(); i++)
+ settings_map[keys.at(i)] = settings.value(keys.at(i));
+
+ restore_settings(settings_map);
+}
+
+void Signal::restore_settings(std::map<QString, QVariant> settings)
{
(void)settings;
}
+
void Signal::paint_back(QPainter &p, ViewItemPaintParams &pp)
{
if (base_->enabled())
#include <memory>
#include <QComboBox>
+#include <QString>
+#include <QVariant>
#include <QWidgetAction>
#include <cstdint>
shared_ptr<data::SignalBase> base() const;
virtual void save_settings(QSettings &settings) const;
+ virtual std::map<QString, QVariant> save_settings() const;
virtual void restore_settings(QSettings &settings);
+ virtual void restore_settings(std::map<QString, QVariant> settings);
void paint_back(QPainter &p, ViewItemPaintParams &pp);
return signals_;
}
+shared_ptr<Signal> View::get_signal_by_signalbase(shared_ptr<data::SignalBase> base) const
+{
+ shared_ptr<Signal> ret_val;
+
+ for (const shared_ptr<Signal> s : signals_)
+ if (s->base() == base) {
+ ret_val = s;
+ break;
+ }
+
+ return ret_val;
+}
+
void View::clear_signals()
{
ViewBase::clear_signals();
*/
unordered_set< shared_ptr<Signal> > signals() const;
+ shared_ptr<Signal> get_signal_by_signalbase(shared_ptr<data::SignalBase> base) const;
+
virtual void clear_signals();
void add_signal(const shared_ptr<Signal> signal);
void extents_changed(bool horz, bool vert);
private Q_SLOTS:
-
void on_signal_name_changed();
void on_splitter_moved();
delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate);
}
+bool ViewBase::is_main_view() const
+{
+ return is_main_view_;
+}
+
void ViewBase::reset_view_state()
{
current_segment_ = 0;
explicit ViewBase(Session &session, bool is_main_view = false, QMainWindow *parent = nullptr);
virtual ViewType get_type() const = 0;
+ bool is_main_view() const;
/**
* Resets the view to its default state after construction. It does however