endif()
if(ENABLE_TESTS)
- find_package(Boost 1.53 COMPONENTS filesystem system thread unit_test_framework REQUIRED)
+ find_package(Boost 1.53 COMPONENTS filesystem serialization system thread unit_test_framework REQUIRED)
else()
- find_package(Boost 1.53 COMPONENTS filesystem system thread REQUIRED)
+ find_package(Boost 1.53 COMPONENTS filesystem serialization system thread REQUIRED)
endif()
# Find the platform's thread library (needed for C++11 threads).
shared_ptr<Session> session = make_shared<Session>(device_manager_, name);
+ connect(session.get(), SIGNAL(add_view(const QString&, view::ViewType, Session*)),
+ this, SLOT(on_add_view(const QString&, view::ViewType, Session*)));
+
sessions_.push_back(session);
shared_ptr<view::View> main_view =
return false;
}
+void MainWindow::on_add_view(const QString &title, view::ViewType type,
+ Session *session)
+{
+ // We get a pointer and need a reference
+ for (std::shared_ptr<Session> s : sessions_)
+ if (s.get() == session)
+ add_view(title, type, *s);
+}
+
void MainWindow::on_actionViewStickyScrolling_triggered()
{
shared_ptr<pv::view::View> view = get_active_view();
virtual bool restoreState(const QByteArray &state, int version = 0);
private Q_SLOTS:
+ void on_add_view(const QString &title, view::ViewType type,
+ Session *session);
+
void on_actionViewStickyScrolling_triggered();
void on_actionViewColouredBg_triggered();
{
map<string, string> dev_info;
list<string> key_list;
- int stacks = 0;
+ int stacks = 0, views = 0;
if (device_) {
shared_ptr<devices::HardwareDevice> hw_device =
}
settings.setValue("decoder_stacks", stacks);
+
+ // Save view states and their signal settings
+ // Note: main_view must be saved as view0
+ settings.beginGroup("view" + QString::number(views++));
+ main_view_->save_settings(settings);
+ settings.endGroup();
+
+ for (shared_ptr<view::View> view : views_) {
+ if (view != main_view_) {
+ settings.beginGroup("view" + QString::number(views++));
+ view->save_settings(settings);
+ settings.endGroup();
+ }
+ }
+
+ settings.setValue("views", views);
}
}
settings.endGroup();
}
#endif
+
+ // Restore views
+ int views = settings.value("views").toInt();
+
+ for (int i = 0; i < views; i++) {
+ settings.beginGroup("view" + QString::number(i));
+
+ if (i > 0) {
+ view::ViewType type = (view::ViewType)settings.value("type").toInt();
+ add_view(name_, type, this);
+ views_.back()->restore_settings(settings);
+ } else
+ main_view_->restore_settings(settings);
+
+ settings.endGroup();
+ }
}
}
main_view_ = view;
}
- views_.insert(view);
+ views_.push_back(view);
}
void Session::deregister_view(std::shared_ptr<pv::view::View> view)
{
- views_.erase(view);
+ views_.remove_if([&](std::shared_ptr<pv::view::View> v) {
+ return v == view; });
if (views_.empty()) {
main_view_.reset();
bool Session::has_view(std::shared_ptr<pv::view::View> view)
{
- return views_.find(view) != views_.end();
+ for (std::shared_ptr<pv::view::View> v : views_)
+ if (v == view)
+ return true;
+
+ return false;
}
double Session::get_samplerate() const
#include <QString>
#include "util.hpp"
+#include "view/viewwidget.hpp"
struct srd_decoder;
struct srd_channel;
std::shared_ptr<devices::Device> device_;
QString default_name_, name_;
- std::unordered_set< std::shared_ptr<pv::view::View> > views_;
+ std::list< std::shared_ptr<pv::view::View> > views_;
std::shared_ptr<pv::view::View> main_view_;
std::shared_ptr<pv::toolbars::MainBar> main_bar_;
void data_received();
void frame_ended();
+
+ void add_view(const QString &title, view::ViewType type,
+ Session *session);
};
} // namespace pv
return base_->analog_data();
}
+void AnalogSignal::save_settings(QSettings &settings) const
+{
+ settings.setValue("vdivs", vdivs_);
+ settings.setValue("scale_index", scale_index_);
+}
+
+void AnalogSignal::restore_settings(QSettings &settings)
+{
+ if (settings.contains("vdivs"))
+ vdivs_ = settings.value("vdivs").toInt();
+
+ if (settings.contains("scale_index")) {
+ scale_index_ = settings.value("scale_index").toInt();
+ update_scale();
+ }
+}
+
std::pair<int, int> AnalogSignal::v_extents() const
{
const int h = vdivs_ * div_height_;
std::shared_ptr<pv::data::SignalData> data() const;
+ virtual void save_settings(QSettings &settings) const;
+
+ virtual void restore_settings(QSettings &settings);
+
/**
* Computes the vertical extents of the contents of this row item.
* @return A pair containing the minimum and maximum y-values.
return base_;
}
+void Signal::save_settings(QSettings &settings) const
+{
+ (void)settings;
+}
+
+void Signal::restore_settings(QSettings &settings)
+{
+ (void)settings;
+}
+
const ViewItemOwner::item_list& Signal::child_items() const
{
return items_;
std::shared_ptr<data::SignalBase> base() const;
+ virtual void save_settings(QSettings &settings) const;
+
+ virtual void restore_settings(QSettings &settings);
+
/**
* Returns a list of row items owned by this object.
*/
#include <cassert>
#include <climits>
#include <cmath>
+#include <iostream>
#include <iterator>
#include <mutex>
#include <unordered_set>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/serialization/serialization.hpp>
#include <boost/thread/locks.hpp>
#include <QApplication>
return viewport_;
}
+void View::save_settings(QSettings &settings) const
+{
+ settings.setValue("scale", scale_);
+
+ std::stringstream ss;
+ boost::archive::text_oarchive oa(ss);
+ oa << boost::serialization::make_nvp("offset", offset_);
+ settings.setValue("offset", QString::fromStdString(ss.str()));
+
+ for (shared_ptr<view::Signal> signal : signals_) {
+ settings.beginGroup(signal->base()->internal_name());
+ signal->save_settings(settings);
+ settings.endGroup();
+ }
+}
+
+void View::restore_settings(QSettings &settings)
+{
+ if (settings.contains("scale"))
+ set_scale(settings.value("scale").toDouble());
+
+ if (settings.contains("offset")) {
+ util::Timestamp offset;
+ std::stringstream ss;
+ ss << settings.value("offset").toString().toStdString();
+
+ boost::archive::text_iarchive ia(ss);
+ ia >> boost::serialization::make_nvp("offset", offset);
+
+ set_offset(offset);
+ }
+
+ for (shared_ptr<view::Signal> signal : signals_) {
+ settings.beginGroup(signal->base()->internal_name());
+ signal->restore_settings(settings);
+ settings.endGroup();
+ }
+}
+
vector< shared_ptr<TimeItem> > View::time_items() const
{
const vector<shared_ptr<Flag>> f(flags());
const Viewport* viewport() const;
+ void save_settings(QSettings &settings) const;
+
+ void restore_settings(QSettings &settings);
+
/**
* Gets a list of time markers.
*/