From f4e57597347e47a4ea58fbdc7b0a22e07f1c0ede Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Mon, 26 Sep 2016 08:45:38 +0200 Subject: [PATCH 1/1] Change namespace for the trace view and implement ViewBase --- CMakeLists.txt | 2 + pv/mainwindow.cpp | 52 +++++----- pv/mainwindow.hpp | 12 +-- pv/session.cpp | 166 +++++++++++++++++--------------- pv/session.hpp | 22 ++--- pv/toolbars/mainbar.cpp | 38 ++++++-- pv/view/analogsignal.cpp | 6 +- pv/view/analogsignal.hpp | 12 ++- pv/view/cursor.cpp | 6 +- pv/view/cursor.hpp | 12 ++- pv/view/cursorpair.cpp | 6 +- pv/view/cursorpair.hpp | 12 ++- pv/view/decodetrace.cpp | 6 +- pv/view/decodetrace.hpp | 12 ++- pv/view/flag.cpp | 8 +- pv/view/flag.hpp | 14 +-- pv/view/header.cpp | 6 +- pv/view/header.hpp | 17 ++-- pv/view/logicsignal.cpp | 6 +- pv/view/logicsignal.hpp | 12 ++- pv/view/marginwidget.cpp | 6 +- pv/view/marginwidget.hpp | 10 +- pv/view/rowitem.cpp | 6 +- pv/view/rowitem.hpp | 14 +-- pv/view/ruler.cpp | 6 +- pv/view/ruler.hpp | 16 +-- pv/view/signal.cpp | 6 +- pv/view/signal.hpp | 12 ++- pv/view/signalscalehandle.cpp | 8 +- pv/view/signalscalehandle.hpp | 12 ++- pv/view/timeitem.cpp | 6 +- pv/view/timeitem.hpp | 12 ++- pv/view/timemarker.cpp | 6 +- pv/view/timemarker.hpp | 12 ++- pv/view/trace.cpp | 8 +- pv/view/trace.hpp | 12 ++- pv/view/tracegroup.cpp | 10 +- pv/view/tracegroup.hpp | 18 ++-- pv/view/tracepalette.cpp | 8 +- pv/view/tracepalette.hpp | 15 +-- pv/view/tracetreeitem.cpp | 6 +- pv/view/tracetreeitem.hpp | 16 +-- pv/view/tracetreeitemowner.cpp | 8 +- pv/view/tracetreeitemowner.hpp | 24 ++--- pv/view/triggermarker.cpp | 6 +- pv/view/triggermarker.hpp | 12 ++- pv/view/view.cpp | 132 +++++++++++++------------ pv/view/view.hpp | 55 ++++++----- pv/view/viewitem.cpp | 6 +- pv/view/viewitem.hpp | 6 +- pv/view/viewitemiterator.hpp | 12 ++- pv/view/viewitemowner.cpp | 8 +- pv/view/viewitemowner.hpp | 14 +-- pv/view/viewitempaintparams.cpp | 6 +- pv/view/viewitempaintparams.hpp | 12 ++- pv/view/viewport.cpp | 8 +- pv/view/viewport.hpp | 19 ++-- pv/view/viewwidget.cpp | 6 +- pv/view/viewwidget.hpp | 21 ++-- pv/views/viewbase.cpp | 110 +++++++++++++++++++++ pv/views/viewbase.hpp | 90 +++++++++++++++++ 61 files changed, 779 insertions(+), 428 deletions(-) create mode 100644 pv/views/viewbase.cpp create mode 100644 pv/views/viewbase.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a28f4f3..b70a905 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,6 +262,7 @@ set(pulseview_SOURCES pv/view/viewitempaintparams.cpp pv/view/viewport.cpp pv/view/viewwidget.cpp + pv/views/viewbase.cpp pv/widgets/colourbutton.cpp pv/widgets/colourpopup.cpp pv/widgets/devicetoolbutton.cpp @@ -314,6 +315,7 @@ set(pulseview_HEADERS pv/view/viewitem.hpp pv/view/viewport.hpp pv/view/viewwidget.hpp + pv/views/viewbase.hpp pv/widgets/colourbutton.hpp pv/widgets/colourpopup.hpp pv/widgets/devicetoolbutton.hpp diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 98ca7ba..f64345c 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -118,7 +118,7 @@ MainWindow::~MainWindow() // Remove the QMainWindow dock->setWidget(0); - const std::shared_ptr view = entry.second; + const std::shared_ptr view = entry.second; for (shared_ptr session : sessions_) if (session->has_view(view)) @@ -141,7 +141,7 @@ QAction* MainWindow::action_about() const return action_about_; } -shared_ptr MainWindow::get_active_view() const +shared_ptr MainWindow::get_active_view() const { // If there's only one view, use it... if (view_docks_.size() == 1) @@ -166,12 +166,10 @@ shared_ptr MainWindow::get_active_view() const return nullptr; } -shared_ptr MainWindow::add_view(const QString &title, - view::ViewType type, Session &session) +shared_ptr MainWindow::add_view(const QString &title, + views::ViewType type, Session &session) { - shared_ptr v; - - if (type == pv::view::TraceView) { + if (type == views::ViewTypeTrace) { shared_ptr dock = make_shared(title, this); dock->setObjectName(title); addDockWidget(Qt::TopDockWidgetArea, dock.get()); @@ -180,7 +178,8 @@ shared_ptr MainWindow::add_view(const QString &title, QMainWindow *dock_main = new QMainWindow(dock.get()); dock_main->setWindowFlags(Qt::Widget); // Remove Qt::Window flag - v = make_shared(session, dock_main); + shared_ptr v = + make_shared(session, dock_main); view_docks_[dock] = v; session.register_view(v); @@ -197,8 +196,9 @@ shared_ptr MainWindow::add_view(const QString &title, connect(close_btn, SIGNAL(clicked(bool)), this, SLOT(on_view_close_clicked())); - if (type == view::TraceView) { - connect(&session, SIGNAL(trigger_event(util::Timestamp)), v.get(), + if (type == views::ViewTypeTrace) { + connect(&session, SIGNAL(trigger_event(util::Timestamp)), + qobject_cast(v.get()), SLOT(trigger_event(util::Timestamp))); v->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked()); @@ -220,9 +220,11 @@ shared_ptr MainWindow::add_view(const QString &title, connect(v.get(), SIGNAL(always_zoom_to_fit_changed(bool)), main_bar.get(), SLOT(on_always_zoom_to_fit_changed(bool))); } + + return v; } - return v; + return nullptr; } shared_ptr MainWindow::add_session() @@ -232,22 +234,22 @@ shared_ptr MainWindow::add_session() shared_ptr session = make_shared(device_manager_, name); - connect(session.get(), SIGNAL(add_view(const QString&, view::ViewType, Session*)), - this, SLOT(on_add_view(const QString&, view::ViewType, Session*))); + connect(session.get(), SIGNAL(add_view(const QString&, views::ViewType, Session*)), + this, SLOT(on_add_view(const QString&, views::ViewType, Session*))); connect(session.get(), SIGNAL(name_changed()), this, SLOT(on_session_name_changed())); sessions_.push_back(session); - shared_ptr main_view = - add_view(name, pv::view::TraceView, *session); + shared_ptr main_view = + add_view(name, views::ViewTypeTrace, *session); return session; } void MainWindow::remove_session(shared_ptr session) { - for (shared_ptr view : session->views()) { + for (shared_ptr view : session->views()) { // Find the dock the view is contained in and close it for (auto entry : view_docks_) if (entry.second == view) @@ -374,7 +376,7 @@ bool MainWindow::restoreState(const QByteArray &state, int version) return false; } -void MainWindow::on_add_view(const QString &title, view::ViewType type, +void MainWindow::on_add_view(const QString &title, views::ViewType type, Session *session) { // We get a pointer and need a reference @@ -385,7 +387,7 @@ void MainWindow::on_add_view(const QString &title, view::ViewType type, void MainWindow::on_focus_changed() { - shared_ptr view; + shared_ptr view; bool title_set = false; view = get_active_view(); @@ -413,7 +415,7 @@ void MainWindow::on_session_name_changed() Session *session = qobject_cast(QObject::sender()); assert(session); - for (shared_ptr view : session->views()) { + for (shared_ptr view : session->views()) { // Get the dock that contains the view for (auto entry : view_docks_) if (entry.second == view) { @@ -431,7 +433,7 @@ void MainWindow::on_new_view(Session *session) // We get a pointer and need a reference for (std::shared_ptr s : sessions_) if (s.get() == session) - add_view(session->name(), pv::view::TraceView, *s); + add_view(session->name(), views::ViewTypeTrace, *s); } void MainWindow::on_view_close_clicked() @@ -448,7 +450,7 @@ void MainWindow::on_view_close_clicked() } // Get the view contained in the dock widget - shared_ptr view; + shared_ptr view; for (auto entry : view_docks_) if (entry.first.get() == dock) @@ -470,14 +472,18 @@ void MainWindow::on_view_close_clicked() void MainWindow::on_actionViewStickyScrolling_triggered() { - shared_ptr view = get_active_view(); + shared_ptr viewbase = get_active_view(); + views::TraceView::View* view = + qobject_cast(viewbase.get()); if (view) view->enable_sticky_scrolling(action_view_sticky_scrolling_->isChecked()); } void MainWindow::on_actionViewColouredBg_triggered() { - shared_ptr view = get_active_view(); + shared_ptr viewbase = get_active_view(); + views::TraceView::View* view = + qobject_cast(viewbase.get()); if (view) view->enable_coloured_bg(action_view_coloured_bg_->isChecked()); } diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 3cd269f..ddad670 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -28,7 +28,7 @@ #include #include "session.hpp" -#include "view/viewwidget.hpp" +#include "views/viewbase.hpp" struct srd_decoder; @@ -72,10 +72,10 @@ public: QAction* action_view_coloured_bg() const; QAction* action_about() const; - std::shared_ptr get_active_view() const; + std::shared_ptr get_active_view() const; - std::shared_ptr add_view(const QString &title, - view::ViewType type, Session &session); + std::shared_ptr add_view(const QString &title, + views::ViewType type, Session &session); std::shared_ptr add_session(); @@ -96,7 +96,7 @@ private: virtual bool restoreState(const QByteArray &state, int version = 0); private Q_SLOTS: - void on_add_view(const QString &title, view::ViewType type, + void on_add_view(const QString &title, views::ViewType type, Session *session); void on_focus_changed(); @@ -118,7 +118,7 @@ private: std::list< std::shared_ptr > sessions_; std::map< std::shared_ptr, - std::shared_ptr > view_docks_; + std::shared_ptr > view_docks_; QAction *const action_view_sticky_scrolling_; QAction *const action_view_coloured_bg_; diff --git a/pv/session.cpp b/pv/session.cpp index f6fb708..3c5bcc4 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -149,12 +149,12 @@ void Session::set_name(QString name) name_changed(); } -const std::list< std::shared_ptr > Session::views() const +const std::list< std::shared_ptr > Session::views() const { return views_; } -std::shared_ptr Session::main_view() const +std::shared_ptr Session::main_view() const { return main_view_; } @@ -243,7 +243,7 @@ void Session::save_settings(QSettings &settings) const main_view_->save_settings(settings); settings.endGroup(); - for (shared_ptr view : views_) { + for (shared_ptr view : views_) { if (view != main_view_) { settings.beginGroup("view" + QString::number(views++)); view->save_settings(settings); @@ -338,7 +338,7 @@ void Session::restore_settings(QSettings &settings) settings.beginGroup("view" + QString::number(i)); if (i > 0) { - view::ViewType type = (view::ViewType)settings.value("type").toInt(); + views::ViewType type = (views::ViewType)settings.value("type").toInt(); add_view(name_, type, this); views_.back()->restore_settings(settings); } else @@ -366,10 +366,10 @@ void Session::set_device(shared_ptr device) name_changed(); // Remove all stored data - for (std::shared_ptr view : views_) { + for (std::shared_ptr view : views_) { view->clear_signals(); #ifdef ENABLE_DECODE - view->clear_decode_traces(); + view->clear_decode_signals(); #endif } for (const shared_ptr d : all_signal_data_) @@ -472,7 +472,7 @@ void Session::stop_capture() sampling_thread_.join(); } -void Session::register_view(std::shared_ptr view) +void Session::register_view(std::shared_ptr view) { if (views_.empty()) { main_view_ = view; @@ -483,9 +483,9 @@ void Session::register_view(std::shared_ptr view) update_signals(); } -void Session::deregister_view(std::shared_ptr view) +void Session::deregister_view(std::shared_ptr view) { - views_.remove_if([&](std::shared_ptr v) { + views_.remove_if([&](std::shared_ptr v) { return v == view; }); if (views_.empty()) { @@ -496,9 +496,9 @@ void Session::deregister_view(std::shared_ptr view) } } -bool Session::has_view(std::shared_ptr view) +bool Session::has_view(std::shared_ptr view) { - for (std::shared_ptr v : views_) + for (std::shared_ptr v : views_) if (v == view) return true; @@ -569,8 +569,8 @@ bool Session::add_decoder(srd_decoder *const dec) signalbase->set_decoder_stack(decoder_stack); signalbases_.insert(signalbase); - for (std::shared_ptr view : views_) - view->add_decode_trace(signalbase); + for (std::shared_ptr view : views_) + view->add_decode_signal(signalbase); } catch (std::runtime_error e) { return false; } @@ -585,8 +585,8 @@ bool Session::add_decoder(srd_decoder *const dec) void Session::remove_decode_signal(shared_ptr signalbase) { - for (std::shared_ptr view : views_) - view->remove_decode_trace(signalbase); + for (std::shared_ptr view : views_) + view->remove_decode_signal(signalbase); } #endif @@ -609,10 +609,10 @@ void Session::update_signals() if (!device_) { signalbases_.clear(); logic_data_.reset(); - for (std::shared_ptr view : views_) { + for (std::shared_ptr view : views_) { view->clear_signals(); #ifdef ENABLE_DECODE - view->clear_decode_traces(); + view->clear_decode_signals(); #endif } return; @@ -624,10 +624,10 @@ void Session::update_signals() if (!sr_dev) { signalbases_.clear(); logic_data_.reset(); - for (std::shared_ptr view : views_) { + for (std::shared_ptr view : views_) { view->clear_signals(); #ifdef ENABLE_DECODE - view->clear_decode_traces(); + view->clear_decode_signals(); #endif } return; @@ -655,70 +655,76 @@ void Session::update_signals() } // Make the signals list - for (std::shared_ptr view : views_) { - unordered_set< shared_ptr > prev_sigs(view->signals()); - view->clear_signals(); - - for (auto channel : sr_dev->channels()) { - shared_ptr signalbase; - shared_ptr signal; - - // Find the channel in the old signals - const auto iter = std::find_if( - prev_sigs.cbegin(), prev_sigs.cend(), - [&](const shared_ptr &s) { - return s->base()->channel() == channel; - }); - if (iter != prev_sigs.end()) { - // Copy the signal from the old set to the new - signal = *iter; - view->add_signal(signal); - } else { - // Find the signalbase for this channel if possible - signalbase.reset(); - for (const shared_ptr b : signalbases_) - if (b->channel() == channel) - signalbase = b; - - switch(channel->type()->id()) { - case SR_CHANNEL_LOGIC: - if (!signalbase) { - signalbase = shared_ptr( - new data::SignalBase(channel)); - signalbases_.insert(signalbase); - - all_signal_data_.insert(logic_data_); - signalbase->set_data(logic_data_); + for (std::shared_ptr viewbase : views_) { + views::TraceView::View *trace_view = + qobject_cast(viewbase.get()); + + if (trace_view) { + unordered_set< shared_ptr > + prev_sigs(trace_view->signals()); + trace_view->clear_signals(); + + for (auto channel : sr_dev->channels()) { + shared_ptr signalbase; + shared_ptr signal; + + // Find the channel in the old signals + const auto iter = std::find_if( + prev_sigs.cbegin(), prev_sigs.cend(), + [&](const shared_ptr &s) { + return s->base()->channel() == channel; + }); + if (iter != prev_sigs.end()) { + // Copy the signal from the old set to the new + signal = *iter; + trace_view->add_signal(signal); + } else { + // Find the signalbase for this channel if possible + signalbase.reset(); + for (const shared_ptr b : signalbases_) + if (b->channel() == channel) + signalbase = b; + + switch(channel->type()->id()) { + case SR_CHANNEL_LOGIC: + if (!signalbase) { + signalbase = shared_ptr( + new data::SignalBase(channel)); + signalbases_.insert(signalbase); + + all_signal_data_.insert(logic_data_); + signalbase->set_data(logic_data_); + } + + signal = shared_ptr( + new views::TraceView::LogicSignal(*this, + device_, signalbase)); + trace_view->add_signal(signal); + break; + + case SR_CHANNEL_ANALOG: + { + if (!signalbase) { + signalbase = shared_ptr( + new data::SignalBase(channel)); + signalbases_.insert(signalbase); + + shared_ptr data(new data::Analog()); + all_signal_data_.insert(data); + signalbase->set_data(data); + } + + signal = shared_ptr( + new views::TraceView::AnalogSignal( + *this, signalbase)); + trace_view->add_signal(signal); + break; } - signal = shared_ptr( - new view::LogicSignal(*this, - device_, signalbase)); - view->add_signal(signal); - break; - - case SR_CHANNEL_ANALOG: - { - if (!signalbase) { - signalbase = shared_ptr( - new data::SignalBase(channel)); - signalbases_.insert(signalbase); - - shared_ptr data(new data::Analog()); - all_signal_data_.insert(data); - signalbase->set_data(data); + default: + assert(0); + break; } - - signal = shared_ptr( - new view::AnalogSignal( - *this, signalbase)); - view->add_signal(signal); - break; - } - - default: - assert(0); - break; } } } diff --git a/pv/session.hpp b/pv/session.hpp index 19860b6..95a50c2 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -42,7 +42,7 @@ #include #include "util.hpp" -#include "view/viewwidget.hpp" +#include "views/viewbase.hpp" struct srd_decoder; struct srd_channel; @@ -78,8 +78,8 @@ namespace toolbars { class MainBar; } -namespace view { -class View; +namespace views { +class ViewBase; } class Session : public QObject @@ -110,9 +110,9 @@ public: void set_name(QString name); - const std::list< std::shared_ptr > views() const; + const std::list< std::shared_ptr > views() const; - std::shared_ptr main_view() const; + std::shared_ptr main_view() const; void set_main_bar(std::shared_ptr main_bar); @@ -137,11 +137,11 @@ public: double get_samplerate() const; - void register_view(std::shared_ptr view); + void register_view(std::shared_ptr view); - void deregister_view(std::shared_ptr view); + void deregister_view(std::shared_ptr view); - bool has_view(std::shared_ptr view); + bool has_view(std::shared_ptr view); const std::unordered_set< std::shared_ptr > signalbases() const; @@ -183,8 +183,8 @@ private: std::shared_ptr device_; QString default_name_, name_; - std::list< std::shared_ptr > views_; - std::shared_ptr main_view_; + std::list< std::shared_ptr > views_; + std::shared_ptr main_view_; std::shared_ptr main_bar_; @@ -221,7 +221,7 @@ Q_SIGNALS: void frame_ended(); - void add_view(const QString &title, view::ViewType type, + void add_view(const QString &title, views::ViewType type, Session *session); }; diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index b21d5a9..ea36a77 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -809,7 +809,10 @@ void MainBar::export_file(shared_ptr format, // Selection only? Verify that the cursors are active and fetch their values if (selection_only) { - if (!session_.main_view()->cursors()->enabled()) { + views::TraceView::View *trace_view = + qobject_cast(session_.main_view().get()); + + if (!trace_view->cursors()->enabled()) { show_session_error(tr("Missing Cursors"), tr("You need to set the " \ "cursors before you can save the data enclosed by them " \ "to a session file (e.g. using ALT-V - Show Cursors).")); @@ -818,8 +821,8 @@ void MainBar::export_file(shared_ptr format, const double samplerate = session_.get_samplerate(); - const pv::util::Timestamp& start_time = session_.main_view()->cursors()->first()->time(); - const pv::util::Timestamp& end_time = session_.main_view()->cursors()->second()->time(); + const pv::util::Timestamp& start_time = trace_view->cursors()->first()->time(); + const pv::util::Timestamp& end_time = trace_view->cursors()->second()->time(); const uint64_t start_sample = std::max((double)0, start_time.convert_to() * samplerate); @@ -1010,31 +1013,46 @@ void MainBar::on_actionConnect_triggered() void MainBar::on_actionViewZoomIn_triggered() { - session_.main_view()->zoom(1); + views::TraceView::View *trace_view = + qobject_cast(session_.main_view().get()); + + trace_view->zoom(1); } void MainBar::on_actionViewZoomOut_triggered() { - session_.main_view()->zoom(-1); + views::TraceView::View *trace_view = + qobject_cast(session_.main_view().get()); + + trace_view->zoom(-1); } void MainBar::on_actionViewZoomFit_triggered() { - session_.main_view()->zoom_fit(action_view_zoom_fit_->isChecked()); + views::TraceView::View *trace_view = + qobject_cast(session_.main_view().get()); + + trace_view->zoom_fit(action_view_zoom_fit_->isChecked()); } void MainBar::on_actionViewZoomOneToOne_triggered() { - session_.main_view()->zoom_one_to_one(); + views::TraceView::View *trace_view = + qobject_cast(session_.main_view().get()); + + trace_view->zoom_one_to_one(); } void MainBar::on_actionViewShowCursors_triggered() { - const bool show = !session_.main_view()->cursors_shown(); + views::TraceView::View *trace_view = + qobject_cast(session_.main_view().get()); + + const bool show = !trace_view->cursors_shown(); if (show) - session_.main_view()->centre_cursors(); + trace_view->centre_cursors(); - session_.main_view()->show_cursors(show); + trace_view->show_cursors(show); } void MainBar::on_always_zoom_to_fit_changed(bool state) diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 0d38314..2000477 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -48,7 +48,8 @@ using std::shared_ptr; using std::deque; namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor AnalogSignal::SignalColours[4] = { QColor(0xC4, 0xA0, 0x00), // Yellow @@ -385,5 +386,6 @@ void AnalogSignal::on_resolution_changed(int index) owner_->row_item_appearance_changed(false, true); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index 1369a76..08edda3 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_ANALOGSIGNAL_HPP -#define PULSEVIEW_PV_VIEW_ANALOGSIGNAL_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_ANALOGSIGNAL_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_ANALOGSIGNAL_HPP #include "signal.hpp" @@ -35,7 +35,8 @@ class AnalogSegment; class SignalBase; } -namespace view { +namespace views { +namespace TraceView { class AnalogSignal : public Signal { @@ -146,7 +147,8 @@ private: float resolution_; // e.g. 10 for 10 V/div }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_ANALOGSIGNAL_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_ANALOGSIGNAL_HPP diff --git a/pv/view/cursor.cpp b/pv/view/cursor.cpp index 7432e30..4f2ef12 100644 --- a/pv/view/cursor.cpp +++ b/pv/view/cursor.cpp @@ -40,7 +40,8 @@ using std::shared_ptr; using std::numeric_limits; namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor Cursor::FillColour(52, 101, 164); @@ -97,5 +98,6 @@ shared_ptr Cursor::get_other_cursor() const cursors->second() : cursors->first(); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/cursor.hpp b/pv/view/cursor.hpp index e64beaa..319d3a7 100644 --- a/pv/view/cursor.hpp +++ b/pv/view/cursor.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_CURSOR_HPP -#define PULSEVIEW_PV_VIEW_CURSOR_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSOR_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSOR_HPP #include "timemarker.hpp" @@ -30,7 +30,8 @@ class QPainter; namespace pv { -namespace view { +namespace views { +namespace TraceView { class Cursor : public TimeMarker { @@ -69,7 +70,8 @@ private: std::shared_ptr get_other_cursor() const; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_CURSOR_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSOR_HPP diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index f9d3e53..e2c8083 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -34,7 +34,8 @@ using std::shared_ptr; using std::pair; namespace pv { -namespace view { +namespace views { +namespace TraceView { const int CursorPair::DeltaPadding = 8; const QColor CursorPair::ViewportFillColour(220, 231, 243); @@ -192,5 +193,6 @@ pair CursorPair::get_cursor_offsets() const ((second_->time() - view_.offset()) / view_.scale()).convert_to()); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/cursorpair.hpp b/pv/view/cursorpair.hpp index 7cbd4f0..110f9ea 100644 --- a/pv/view/cursorpair.hpp +++ b/pv/view/cursorpair.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_CURSORPAIR_HPP -#define PULSEVIEW_PV_VIEW_CURSORPAIR_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP #include "cursor.hpp" @@ -30,7 +30,8 @@ class QPainter; namespace pv { -namespace view { +namespace views { +namespace TraceView { class CursorPair : public TimeItem { @@ -105,7 +106,8 @@ private: QSizeF text_size_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_CURSORPAIR_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_CURSORPAIR_HPP diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 832b249..af8afc0 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -72,7 +72,8 @@ using std::unordered_set; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor DecodeTrace::DecodeColours[4] = { QColor(0xEF, 0x29, 0x29), // Red @@ -1009,5 +1010,6 @@ void DecodeTrace::on_show_hide_decoder(int index) owner_->row_item_appearance_changed(false, true); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp index f569532..7e9c081 100644 --- a/pv/view/decodetrace.hpp +++ b/pv/view/decodetrace.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_DECODETRACE_HPP -#define PULSEVIEW_PV_VIEW_DECODETRACE_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_DECODETRACE_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_DECODETRACE_HPP #include "trace.hpp" @@ -58,7 +58,8 @@ namespace widgets { class DecoderGroupBox; } -namespace view { +namespace views { +namespace TraceView { class DecodeTrace : public Trace { @@ -218,7 +219,8 @@ private: QSignalMapper delete_mapper_, show_hide_mapper_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_DECODETRACE_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_DECODETRACE_HPP diff --git a/pv/view/flag.cpp b/pv/view/flag.cpp index 779ea2e..3afd255 100644 --- a/pv/view/flag.cpp +++ b/pv/view/flag.cpp @@ -33,7 +33,8 @@ using std::shared_ptr; namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor Flag::FillColour(0x73, 0xD2, 0x16); @@ -45,7 +46,7 @@ Flag::Flag(View &view, const pv::util::Timestamp& time, const QString &text) : Flag::Flag(const Flag &flag) : TimeMarker(flag.view_, FillColour, flag.time_), - std::enable_shared_from_this(flag) + std::enable_shared_from_this(flag) { } @@ -108,5 +109,6 @@ void Flag::on_text_changed(const QString &text) view_.time_item_appearance_changed(true, false); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/flag.hpp b/pv/view/flag.hpp index bc82934..1311d4a 100644 --- a/pv/view/flag.hpp +++ b/pv/view/flag.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_FLAG_HPP -#define PULSEVIEW_PV_VIEW_FLAG_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_FLAG_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_FLAG_HPP #include @@ -28,10 +28,11 @@ class QMenu; namespace pv { -namespace view { +namespace views { +namespace TraceView { class Flag : public TimeMarker, - public std::enable_shared_from_this + public std::enable_shared_from_this { Q_OBJECT @@ -77,7 +78,8 @@ private: QString text_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_FLAG_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_FLAG_HPP diff --git a/pv/view/header.cpp b/pv/view/header.cpp index ba0f9e6..4ad28cf 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -49,7 +49,8 @@ using std::stable_sort; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { const int Header::Padding = 12; const int Header::BaselineOffset = 5; @@ -218,5 +219,6 @@ void Header::on_ungroup() } while (restart); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/header.hpp b/pv/view/header.hpp index deb984d..9ea1ff4 100644 --- a/pv/view/header.hpp +++ b/pv/view/header.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_HEADER_HPP -#define PULSEVIEW_PV_VIEW_HEADER_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_HEADER_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_HEADER_HPP #include #include @@ -28,7 +28,8 @@ #include "marginwidget.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class TraceTreeItem; class View; @@ -63,7 +64,7 @@ private: /** * Gets the row items. */ - std::vector< std::shared_ptr > items(); + std::vector< std::shared_ptr > items(); /** * Gets the first view item which has a label that contains @c pt . @@ -71,8 +72,7 @@ private: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - std::shared_ptr get_mouse_over_item( - const QPoint &pt); + std::shared_ptr get_mouse_over_item(const QPoint &pt); private: void paintEvent(QPaintEvent *event); @@ -88,7 +88,8 @@ private Q_SLOTS: void on_ungroup(); }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_HEADER_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_HEADER_HPP diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index b8be8bb..bc0961f 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -59,7 +59,8 @@ using sigrok::TriggerMatch; using sigrok::TriggerMatchType; namespace pv { -namespace view { +namespace views { +namespace TraceView { const float LogicSignal::Oversampling = 2.0f; @@ -485,5 +486,6 @@ void LogicSignal::on_trigger() modify_trigger(); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index 8274b61..ce843df 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_LOGICSIGNAL_HPP -#define PULSEVIEW_PV_VIEW_LOGICSIGNAL_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP #include @@ -44,7 +44,8 @@ namespace data { class Logic; } -namespace view { +namespace views { +namespace TraceView { class LogicSignal : public Signal { @@ -145,7 +146,8 @@ private: static QCache pixmap_cache_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_LOGICSIGNAL_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp index 7e4fcdf..4c37287 100644 --- a/pv/view/marginwidget.cpp +++ b/pv/view/marginwidget.cpp @@ -30,7 +30,8 @@ using std::shared_ptr; namespace pv { -namespace view { +namespace views { +namespace TraceView { MarginWidget::MarginWidget(View &parent) : ViewWidget(parent) @@ -74,5 +75,6 @@ void MarginWidget::keyPressEvent(QKeyEvent *event) } } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/marginwidget.hpp b/pv/view/marginwidget.hpp index 455aaf9..b785877 100644 --- a/pv/view/marginwidget.hpp +++ b/pv/view/marginwidget.hpp @@ -28,7 +28,8 @@ #include "viewwidget.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class ViewItem; @@ -37,7 +38,7 @@ class MarginWidget : public ViewWidget Q_OBJECT public: - MarginWidget(pv::view::View &parent); + MarginWidget(View &parent); /** * The extended area that the margin widget would like to be sized to. @@ -52,7 +53,7 @@ protected: * @param item the view item that has been clicked. */ virtual void item_clicked( - const std::shared_ptr &item); + const std::shared_ptr &item); /** * Shows the popup of a the specified @c ViewItem . @@ -66,7 +67,8 @@ protected: virtual void keyPressEvent(QKeyEvent *event); }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv #endif // PULSEVIEW_PV_MARGINWIDGET_HPP diff --git a/pv/view/rowitem.cpp b/pv/view/rowitem.cpp index 4ad8b59..f41ea52 100644 --- a/pv/view/rowitem.cpp +++ b/pv/view/rowitem.cpp @@ -21,11 +21,13 @@ #include "rowitem.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { void RowItem::hover_point_changed() { } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/rowitem.hpp b/pv/view/rowitem.hpp index 1c48786..d2e2dd9 100644 --- a/pv/view/rowitem.hpp +++ b/pv/view/rowitem.hpp @@ -18,13 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_ROWITEM_HPP -#define PULSEVIEW_PV_VIEW_ROWITEM_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_ROWITEM_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_ROWITEM_HPP -#include "viewitem.hpp" +#include namespace pv { -namespace view { +namespace views { +namespace TraceView { class RowItem : public ViewItem { @@ -34,7 +35,8 @@ public: virtual void hover_point_changed(); }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_ROWITEM_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_ROWITEM_HPP diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index f6ec4ac..a8d25fc 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -33,7 +33,8 @@ using std::shared_ptr; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { const float Ruler::RulerHeight = 2.5f; // x Text Height const int Ruler::MinorTickSubdivision = 4; @@ -271,5 +272,6 @@ void Ruler::resizeEvent(QResizeEvent*) invalidate_tick_position_cache(); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index 923cceb..f6ce99d 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_RULER_HPP -#define PULSEVIEW_PV_VIEW_RULER_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_RULER_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_RULER_HPP #include #include @@ -36,7 +36,8 @@ struct tick_position_test_2; } namespace pv { -namespace view { +namespace views { +namespace TraceView { class TimeItem; class ViewItem; @@ -109,7 +110,7 @@ private: /** * Gets the time items. */ - std::vector< std::shared_ptr > items() override; + std::vector< std::shared_ptr > items() override; /** * Gets the first view item which has a label that contains @c pt . @@ -117,7 +118,7 @@ private: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - std::shared_ptr get_mouse_over_item( + std::shared_ptr get_mouse_over_item( const QPoint &pt) override; void paintEvent(QPaintEvent *event) override; @@ -174,7 +175,8 @@ private Q_SLOTS: void invalidate_tick_position_cache(); }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_RULER_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_RULER_HPP diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index ad139f7..59817eb 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -40,7 +40,8 @@ using std::shared_ptr; using std::make_shared; namespace pv { -namespace view { +namespace views { +namespace TraceView { const char *const ChannelNames[] = { "CLK", @@ -183,5 +184,6 @@ void Signal::on_enabled_changed(bool enabled) owner_->extents_changed(true, true); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/signal.hpp b/pv/view/signal.hpp index 5bac1f4..35081cd 100644 --- a/pv/view/signal.hpp +++ b/pv/view/signal.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_SIGNAL_HPP -#define PULSEVIEW_PV_VIEW_SIGNAL_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP #include @@ -41,7 +41,8 @@ class SignalBase; class SignalData; } -namespace view { +namespace views { +namespace TraceView { class Signal : public Trace, public ViewItemOwner { @@ -115,7 +116,8 @@ protected: QComboBox *name_widget_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_SIGNAL_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP diff --git a/pv/view/signalscalehandle.cpp b/pv/view/signalscalehandle.cpp index a4c2b41..074bfb1 100644 --- a/pv/view/signalscalehandle.cpp +++ b/pv/view/signalscalehandle.cpp @@ -30,7 +30,8 @@ using std::max; using std::min; namespace pv { -namespace view { +namespace views { +namespace TraceView { SignalScaleHandle::SignalScaleHandle(Signal &owner) : owner_(owner) @@ -103,5 +104,6 @@ void SignalScaleHandle::paint_fore(QPainter &p, const ViewItemPaintParams &pp) p.drawEllipse(r); } -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv diff --git a/pv/view/signalscalehandle.hpp b/pv/view/signalscalehandle.hpp index 9d1ae93..67dcf14 100644 --- a/pv/view/signalscalehandle.hpp +++ b/pv/view/signalscalehandle.hpp @@ -18,13 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_SIGNALSCALEHANDLE_HPP -#define PULSEVIEW_PV_VIEW_SIGNALSCALEHANDLE_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNALSCALEHANDLE_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNALSCALEHANDLE_HPP #include "rowitem.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class Signal; @@ -87,7 +88,8 @@ private: Signal &owner_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_SIGNALSCALEHANDLE_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNALSCALEHANDLE_HPP diff --git a/pv/view/timeitem.cpp b/pv/view/timeitem.cpp index ec8dd1a..e2ad342 100644 --- a/pv/view/timeitem.cpp +++ b/pv/view/timeitem.cpp @@ -22,7 +22,8 @@ #include "view.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { TimeItem::TimeItem(View &view) : view_(view) { @@ -34,5 +35,6 @@ void TimeItem::drag_by(const QPoint &delta) view_.scale()); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/timeitem.hpp b/pv/view/timeitem.hpp index cd6f5f2..35cbab3 100644 --- a/pv/view/timeitem.hpp +++ b/pv/view/timeitem.hpp @@ -18,13 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_TIMEITEM_HPP -#define PULSEVIEW_PV_VIEW_TIMEITEM_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TIMEITEM_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TIMEITEM_HPP #include "viewitem.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class View; @@ -58,7 +59,8 @@ protected: View &view_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_TIMEITEM_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TIMEITEM_HPP diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index b5662e4..52fcf45 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -38,7 +38,8 @@ using std::max; using std::min; namespace pv { -namespace view { +namespace views { +namespace TraceView { const int TimeMarker::ArrowSize = 4; @@ -191,5 +192,6 @@ void TimeMarker::on_value_changed(const pv::util::Timestamp& value) set_time(value); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/timemarker.hpp b/pv/view/timemarker.hpp index c65dab7..2280363 100644 --- a/pv/view/timemarker.hpp +++ b/pv/view/timemarker.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_MARKER_HPP -#define PULSEVIEW_PV_VIEW_MARKER_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_MARKER_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_MARKER_HPP #include #include @@ -37,7 +37,8 @@ namespace widgets { class TimestampSpinBox; } -namespace view { +namespace views { +namespace TraceView { class View; @@ -127,7 +128,8 @@ protected: bool updating_value_widget_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_MARKER_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_MARKER_HPP diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index d9cccdb..3bdf725 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -36,7 +36,8 @@ #include namespace pv { -namespace view { +namespace views { +namespace TraceView { const QPen Trace::AxisPen(QColor(0, 0, 0, 30*256/100)); const int Trace::LabelHitPadding = 2; @@ -140,8 +141,6 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent) QRectF Trace::label_rect(const QRectF &rect) const { - using pv::view::View; - QFontMetrics m(QApplication::font()); const QSize text_size( m.boundingRect(QRect(), 0, base_->name()).width(), m.height()); @@ -278,5 +277,6 @@ void Trace::on_colouredit_changed(const QColor &colour) set_colour(colour); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index 0a6735f..9f0ecd4 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_TRACE_HPP -#define PULSEVIEW_PV_VIEW_TRACE_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACE_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACE_HPP #include #include @@ -41,7 +41,8 @@ namespace widgets { class Popup; } -namespace view { +namespace views { +namespace TraceView { class Trace : public TraceTreeItem { @@ -135,7 +136,8 @@ private: QFormLayout *popup_form_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_TRACE_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACE_HPP diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index 9c1d49f..5abcc86 100644 --- a/pv/view/tracegroup.cpp +++ b/pv/view/tracegroup.cpp @@ -33,7 +33,8 @@ using std::shared_ptr; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { const int TraceGroup::Padding = 8; const int TraceGroup::Width = 12; @@ -64,13 +65,13 @@ const pv::Session& TraceGroup::session() const return owner_->session(); } -pv::view::View* TraceGroup::view() +View* TraceGroup::view() { assert(owner_); return owner_->view(); } -const pv::view::View* TraceGroup::view() const +const View* TraceGroup::view() const { assert(owner_); return owner_->view(); @@ -222,5 +223,6 @@ void TraceGroup::extents_changed(bool horz, bool vert) owner_->extents_changed(horz, vert); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/tracegroup.hpp b/pv/view/tracegroup.hpp index 6407f1b..badddf7 100644 --- a/pv/view/tracegroup.hpp +++ b/pv/view/tracegroup.hpp @@ -18,14 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_TRACEGROUP_HPP -#define PULSEVIEW_PV_VIEW_TRACEGROUP_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEGROUP_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEGROUP_HPP #include "tracetreeitem.hpp" #include "tracetreeitemowner.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class TraceGroup : public TraceTreeItem, public TraceTreeItemOwner { @@ -61,12 +62,12 @@ public: /** * Returns the view of the owner. */ - virtual pv::view::View* view(); + virtual View* view(); /** * Returns the view of the owner. */ - virtual const pv::view::View* view() const; + virtual const View* view() const; /** * Computes the vertical extents of the contents of this row item. @@ -127,7 +128,8 @@ private Q_SLOTS: void on_ungroup(); }; -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv -#endif // PULSEVIEW_PV_VIEW_TRACEGROUP_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEGROUP_HPP diff --git a/pv/view/tracepalette.cpp b/pv/view/tracepalette.cpp index 3dcb63d..5a1eda2 100644 --- a/pv/view/tracepalette.cpp +++ b/pv/view/tracepalette.cpp @@ -21,7 +21,8 @@ #include "tracepalette.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor TracePalette::Colours[Cols * Rows] = { @@ -66,5 +67,6 @@ const QColor TracePalette::Colours[Cols * Rows] = { QColor(0xFF, 0xFF, 0xFF), // White }; -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv diff --git a/pv/view/tracepalette.hpp b/pv/view/tracepalette.hpp index e878a22..bf5f92c 100644 --- a/pv/view/tracepalette.hpp +++ b/pv/view/tracepalette.hpp @@ -18,13 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_TRACEPALETTE_HPP -#define PULSEVIEW_PV_TRACEPALETTE_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEPALETTE_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEPALETTE_HPP #include namespace pv { -namespace view { +namespace views { +namespace TraceView { class TracePalette { @@ -34,8 +35,8 @@ public: static const QColor Colours[Cols * Rows]; }; +} // namespace TraceView +} // namespace views +} // namespace pv -} // view -} // pv - -#endif // PULSEVIEW_PV_VIEW_TRACEPALETTE_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACEPALETTE_HPP diff --git a/pv/view/tracetreeitem.cpp b/pv/view/tracetreeitem.cpp index 44c5d4b..d859ebb 100644 --- a/pv/view/tracetreeitem.cpp +++ b/pv/view/tracetreeitem.cpp @@ -25,7 +25,8 @@ #include "tracetreeitem.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { TraceTreeItem::TraceTreeItem() : owner_(nullptr), @@ -143,5 +144,6 @@ void TraceTreeItem::set_bgcolour_state(bool state) bgcolour_state_ = state; } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/tracetreeitem.hpp b/pv/view/tracetreeitem.hpp index 8317db7..56e1d73 100644 --- a/pv/view/tracetreeitem.hpp +++ b/pv/view/tracetreeitem.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_TRACETREEITEM_HPP -#define PULSEVIEW_PV_VIEW_TRACETREEITEM_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP #include @@ -28,12 +28,13 @@ #include "rowitem.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class TraceTreeItemOwner; class TraceTreeItem : public RowItem, - public std::enable_shared_from_this + public std::enable_shared_from_this { Q_OBJECT Q_PROPERTY(int visual_v_offset @@ -91,7 +92,7 @@ public: * Sets the owner this trace in the view trace hierachy. * @param The new owner of the trace. */ - void set_owner(pv::view::TraceTreeItemOwner *owner); + void set_owner(TraceTreeItemOwner *owner); /** * Gets the visual y-offset of the axis. @@ -136,7 +137,8 @@ private: QPropertyAnimation v_offset_animation_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_TRACETREEITEM_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP diff --git a/pv/view/tracetreeitemowner.cpp b/pv/view/tracetreeitemowner.cpp index 1449d81..528e0a0 100644 --- a/pv/view/tracetreeitemowner.cpp +++ b/pv/view/tracetreeitemowner.cpp @@ -35,7 +35,8 @@ using std::static_pointer_cast; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { const ViewItemOwner::item_list& TraceTreeItemOwner::child_items() const { @@ -132,5 +133,6 @@ void TraceTreeItemOwner::restack_items() { } -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv diff --git a/pv/view/tracetreeitemowner.hpp b/pv/view/tracetreeitemowner.hpp index 6d4b6d1..b5f1a3a 100644 --- a/pv/view/tracetreeitemowner.hpp +++ b/pv/view/tracetreeitemowner.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_TRACETREEITEMOWNER_HPP -#define PULSEVIEW_PV_VIEW_TRACETREEITEMOWNER_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEMOWNER_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEMOWNER_HPP #include "viewitemowner.hpp" #include "tracetreeitem.hpp" @@ -28,7 +28,8 @@ namespace pv { class Session; -namespace view { +namespace views { +namespace TraceView { class TraceTreeItem; class View; @@ -39,24 +40,24 @@ public: /** * Returns the view of the owner. */ - virtual pv::view::View* view() = 0; + virtual View* view() = 0; /** * Returns the view of the owner. */ - virtual const pv::view::View* view() const = 0; + virtual const View* view() const = 0; virtual int owner_visual_v_offset() const = 0; /** - * Returns the session of the onwer. + * Returns the session of the owner. */ - virtual pv::Session& session() = 0; + virtual Session& session() = 0; /** * Returns the session of the owner. */ - virtual const pv::Session& session() const = 0; + virtual const Session& session() const = 0; /** * Returns the number of nested parents that this row item owner has. @@ -111,7 +112,8 @@ public: virtual void extents_changed(bool horz, bool vert) = 0; }; -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv -#endif // PULSEVIEW_PV_VIEW_TRACETREEITEMOWNER_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEMOWNER_HPP diff --git a/pv/view/triggermarker.cpp b/pv/view/triggermarker.cpp index f15672b..9be3285 100644 --- a/pv/view/triggermarker.cpp +++ b/pv/view/triggermarker.cpp @@ -22,7 +22,8 @@ #include "view.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor TriggerMarker::Colour(0x00, 0x00, 0xB0); @@ -78,5 +79,6 @@ void TriggerMarker::paint_fore(QPainter &p, const ViewItemPaintParams &pp) p.drawLine(QPointF(x, pp.top()), QPointF(x, pp.bottom())); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/triggermarker.hpp b/pv/view/triggermarker.hpp index cbbcb36..3be22fa 100644 --- a/pv/view/triggermarker.hpp +++ b/pv/view/triggermarker.hpp @@ -18,13 +18,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_TRIGGER_MARKER_HPP -#define PULSEVIEW_PV_VIEW_TRIGGER_MARKER_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRIGGER_MARKER_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRIGGER_MARKER_HPP #include "timeitem.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { class TriggerMarker : public TimeItem { @@ -80,7 +81,8 @@ private: pv::util::Timestamp time_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_TRIGGER_MARKER_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRIGGER_MARKER_HPP diff --git a/pv/view/view.cpp b/pv/view/view.cpp index c69e75c..a086d23 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -95,7 +96,8 @@ using std::vector; using std::weak_ptr; namespace pv { -namespace view { +namespace views { +namespace TraceView { const Timestamp View::MaxScale("1e9"); const Timestamp View::MinScale("1e-12"); @@ -105,12 +107,41 @@ const int View::MaxViewAutoUpdateRate = 25; // No more than 25 Hz with sticky sc const int View::ScaleUnits[3] = {1, 2, 5}; + +CustomAbstractScrollArea::CustomAbstractScrollArea(QWidget *parent) : + QAbstractScrollArea(parent) +{ +} + +void CustomAbstractScrollArea::setViewportMargins(int left, int top, int right, int bottom) +{ + QAbstractScrollArea::setViewportMargins(left, top, right, bottom); +} + +bool CustomAbstractScrollArea::viewportEvent(QEvent *event) +{ + switch (event->type()) { + case QEvent::Paint: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonDblClick: + case QEvent::MouseMove: + case QEvent::Wheel: + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + return false; + default: + return QAbstractScrollArea::viewportEvent(event); + } +} + View::View(Session &session, QWidget *parent) : - QAbstractScrollArea(parent), - session_(session), + ViewBase(session, parent), viewport_(new Viewport(*this)), ruler_(new Ruler(*this)), header_(new Header(*this)), + scrollarea_(this), scale_(1e-3), offset_(0), updating_scroll_(false), @@ -126,20 +157,11 @@ View::View(Session &session, QWidget *parent) : trigger_markers_(), hover_point_(-1, -1) { - connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), + connect(scrollarea_.horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(h_scroll_value_changed(int))); - connect(verticalScrollBar(), SIGNAL(valueChanged(int)), + connect(scrollarea_.verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(v_scroll_value_changed())); - connect(&session_, SIGNAL(signals_changed()), - this, SLOT(signals_changed())); - connect(&session_, SIGNAL(capture_state_changed(int)), - this, SLOT(capture_state_updated(int))); - connect(&session_, SIGNAL(data_received()), - this, SLOT(data_updated())); - connect(&session_, SIGNAL(frame_ended()), - this, SLOT(data_updated())); - connect(header_, SIGNAL(selection_changed()), ruler_, SLOT(clear_selection())); connect(ruler_, SIGNAL(selection_changed()), @@ -162,7 +184,13 @@ View::View(Session &session, QWidget *parent) : delayed_view_updater_.setSingleShot(true); delayed_view_updater_.setInterval(1000 / MaxViewAutoUpdateRate); - setViewport(viewport_); + /* To let the scroll area fill up the parent QWidget (this), we need a layout */ + QHBoxLayout *layout = new QHBoxLayout(this); + setLayout(layout); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(&scrollarea_); + + scrollarea_.setViewport(viewport_); viewport_->installEventFilter(this); ruler_->installEventFilter(this); @@ -190,7 +218,7 @@ const Session& View::session() const return session_; } -std::unordered_set< std::shared_ptr > View::signals() const +std::unordered_set< std::shared_ptr > View::signals() const { return signals_; } @@ -200,25 +228,25 @@ void View::clear_signals() signals_.clear(); } -void View::add_signal(const shared_ptr signal) +void View::add_signal(const shared_ptr signal) { signals_.insert(signal); } #ifdef ENABLE_DECODE -void View::clear_decode_traces() +void View::clear_decode_signals() { decode_traces_.clear(); } -void View::add_decode_trace(shared_ptr signalbase) +void View::add_decode_signal(shared_ptr signalbase) { - shared_ptr d( - new view::DecodeTrace(session_, signalbase, decode_traces_.size())); + shared_ptr d( + new DecodeTrace(session_, signalbase, decode_traces_.size())); decode_traces_.push_back(d); } -void View::remove_decode_trace(shared_ptr signalbase) +void View::remove_decode_signal(shared_ptr signalbase) { for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++) if ((*i)->base() == signalbase) { @@ -258,7 +286,7 @@ void View::save_settings(QSettings &settings) const oa << boost::serialization::make_nvp("offset", offset_); settings.setValue("offset", QString::fromStdString(ss.str())); - for (shared_ptr signal : signals_) { + for (shared_ptr signal : signals_) { settings.beginGroup(signal->base()->internal_name()); signal->save_settings(settings); settings.endGroup(); @@ -281,7 +309,7 @@ void View::restore_settings(QSettings &settings) set_offset(offset); } - for (shared_ptr signal : signals_) { + for (shared_ptr signal : signals_) { settings.beginGroup(signal->base()->internal_name()); signal->restore_settings(settings); settings.endGroup(); @@ -330,12 +358,12 @@ void View::set_offset(const pv::util::Timestamp& offset) int View::owner_visual_v_offset() const { - return -verticalScrollBar()->sliderPosition(); + return -scrollarea_.verticalScrollBar()->sliderPosition(); } void View::set_v_offset(int offset) { - verticalScrollBar()->setSliderPosition(offset); + scrollarea_.verticalScrollBar()->setSliderPosition(offset); header_->update(); viewport_->update(); } @@ -730,6 +758,8 @@ void View::calculate_tick_spacing() void View::update_scroll() { assert(viewport_); + QScrollBar *hscrollbar = scrollarea_.horizontalScrollBar(); + QScrollBar *vscrollbar = scrollarea_.verticalScrollBar(); const QSize areaSize = viewport_->size(); @@ -741,31 +771,31 @@ void View::update_scroll() int major_tick_distance = (tick_period_ / scale_).convert_to(); - horizontalScrollBar()->setPageStep(areaSize.width() / 2); - horizontalScrollBar()->setSingleStep(major_tick_distance); + hscrollbar->setPageStep(areaSize.width() / 2); + hscrollbar->setSingleStep(major_tick_distance); updating_scroll_ = true; if (length < MaxScrollValue) { - horizontalScrollBar()->setRange(0, length); - horizontalScrollBar()->setSliderPosition(offset.convert_to()); + hscrollbar->setRange(0, length); + hscrollbar->setSliderPosition(offset.convert_to()); } else { - horizontalScrollBar()->setRange(0, MaxScrollValue); - horizontalScrollBar()->setSliderPosition( + hscrollbar->setRange(0, MaxScrollValue); + hscrollbar->setSliderPosition( (offset_ * MaxScrollValue / (scale_ * length)).convert_to()); } updating_scroll_ = false; // Set the vertical scrollbar - verticalScrollBar()->setPageStep(areaSize.height()); - verticalScrollBar()->setSingleStep(areaSize.height() / 8); + vscrollbar->setPageStep(areaSize.height()); + vscrollbar->setSingleStep(areaSize.height() / 8); const pair extents = v_extents(); // Don't change the scrollbar range if there are no traces if (extents.first != extents.second) - verticalScrollBar()->setRange(extents.first - areaSize.height(), + vscrollbar->setRange(extents.first - areaSize.height(), extents.second); if (scroll_needs_defaults) @@ -774,7 +804,7 @@ void View::update_scroll() void View::reset_scroll() { - verticalScrollBar()->setRange(0, 0); + scrollarea_.verticalScrollBar()->setRange(0, 0); } void View::set_scroll_default() @@ -807,8 +837,8 @@ void View::set_scroll_default() void View::update_layout() { - setViewportMargins( - header_->sizeHint().width() - pv::view::Header::BaselineOffset, + scrollarea_.setViewportMargins( + header_->sizeHint().width() - Header::BaselineOffset, ruler_->sizeHint().height(), 0, 0); ruler_->setGeometry(viewport_->x(), 0, viewport_->width(), ruler_->extended_size_hint().height()); @@ -923,24 +953,6 @@ bool View::eventFilter(QObject *object, QEvent *event) return QObject::eventFilter(object, event); } -bool View::viewportEvent(QEvent *event) -{ - switch (event->type()) { - case QEvent::Paint: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseButtonDblClick: - case QEvent::MouseMove: - case QEvent::Wheel: - case QEvent::TouchBegin: - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - return false; - default: - return QAbstractScrollArea::viewportEvent(event); - } -} - void View::resizeEvent(QResizeEvent*) { update_layout(); @@ -982,7 +994,7 @@ void View::h_scroll_value_changed(int value) sticky_scrolling_changed(false); } - const int range = horizontalScrollBar()->maximum(); + const int range = scrollarea_.horizontalScrollBar()->maximum(); if (range < MaxScrollValue) set_offset(scale_ * value); else { @@ -1012,7 +1024,8 @@ void View::signals_changed() // Do we need to set the vertical scrollbar to its default position later? // We do if there are no traces, i.e. the scroll bar has no range set bool reset_scrollbar = - verticalScrollBar()->minimum() == verticalScrollBar()->maximum(); + (scrollarea_.verticalScrollBar()->minimum() == + scrollarea_.verticalScrollBar()->maximum()); if (!session_.device()) { reset_scroll(); @@ -1251,5 +1264,6 @@ void View::on_hover_point_changed() r->hover_point_changed(); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/view.hpp b/pv/view/view.hpp index cb1035c..0412c69 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_VIEW_HPP -#define PULSEVIEW_PV_VIEW_VIEW_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEW_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEW_HPP #include @@ -34,6 +34,7 @@ #include #include +#include #include #include "cursorpair.hpp" @@ -48,7 +49,9 @@ namespace pv { class Session; -namespace view { +namespace views { + +namespace TraceView { class CursorHeader; class DecodeTrace; @@ -59,7 +62,16 @@ class Trace; class Viewport; class TriggerMarker; -class View : public QAbstractScrollArea, public TraceTreeItemOwner { +class CustomAbstractScrollArea : public QAbstractScrollArea { + Q_OBJECT + +public: + CustomAbstractScrollArea(QWidget *parent = 0); + void setViewportMargins(int left, int top, int right, int bottom); + bool viewportEvent(QEvent *event); +}; + +class View : public ViewBase, public TraceTreeItemOwner { Q_OBJECT private: @@ -86,37 +98,37 @@ public: /** * Returns the signals contained in this view. */ - std::unordered_set< std::shared_ptr > signals() const; + std::unordered_set< std::shared_ptr > signals() const; - void clear_signals(); + virtual void clear_signals(); - void add_signal(const std::shared_ptr signal); + virtual void add_signal(const std::shared_ptr signal); #ifdef ENABLE_DECODE - void clear_decode_traces(); + virtual void clear_decode_signals(); - void add_decode_trace(std::shared_ptr signalbase); + virtual void add_decode_signal(std::shared_ptr signalbase); - void remove_decode_trace(std::shared_ptr signalbase); + virtual void remove_decode_signal(std::shared_ptr signalbase); #endif /** * Returns the view of the owner. */ - virtual pv::view::View* view(); + virtual View* view(); /** * Returns the view of the owner. */ - virtual const pv::view::View* view() const; + virtual const View* view() const; Viewport* viewport(); const Viewport* viewport() const; - void save_settings(QSettings &settings) const; + virtual void save_settings(QSettings &settings) const; - void restore_settings(QSettings &settings); + virtual void restore_settings(QSettings &settings); /** * Gets a list of time markers. @@ -310,8 +322,6 @@ private: bool eventFilter(QObject *object, QEvent *event); - bool viewportEvent(QEvent *event); - void resizeEvent(QResizeEvent *event); public: @@ -372,18 +382,18 @@ private Q_SLOTS: void set_time_unit(pv::util::TimeUnit time_unit); private: - Session &session_; - Viewport *viewport_; Ruler *ruler_; Header *header_; - std::unordered_set< std::shared_ptr > signals_; + std::unordered_set< std::shared_ptr > signals_; #ifdef ENABLE_DECODE - std::vector< std::shared_ptr > decode_traces_; + std::vector< std::shared_ptr > decode_traces_; #endif + CustomAbstractScrollArea scrollarea_; + /// The view time scale in seconds per pixel. double scale_; @@ -417,7 +427,8 @@ private: bool scroll_needs_defaults; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_VIEW_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEW_HPP diff --git a/pv/view/viewitem.cpp b/pv/view/viewitem.cpp index e9602f8..7e581d9 100644 --- a/pv/view/viewitem.cpp +++ b/pv/view/viewitem.cpp @@ -27,7 +27,8 @@ #include namespace pv { -namespace view { +namespace views { +namespace TraceView { const QSizeF ViewItem::LabelPadding(4, 0); const int ViewItem::HighlightRadius = 3; @@ -135,5 +136,6 @@ QColor ViewItem::select_text_colour(QColor background) return (background.lightness() > 110) ? Qt::black : Qt::white; } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/viewitem.hpp b/pv/view/viewitem.hpp index a4eb6ae..63fd101 100644 --- a/pv/view/viewitem.hpp +++ b/pv/view/viewitem.hpp @@ -37,7 +37,8 @@ namespace widgets { class Popup; } -namespace view { +namespace views { +namespace TraceView { class ViewItemOwner; @@ -172,7 +173,8 @@ private: bool selected_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv #endif // PULSEVIEW_PV_VIEWITEM_HPP diff --git a/pv/view/viewitemiterator.hpp b/pv/view/viewitemiterator.hpp index eed67a9..403b196 100644 --- a/pv/view/viewitemiterator.hpp +++ b/pv/view/viewitemiterator.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_VIEWITEMITERATOR_HPP -#define PULSEVIEW_PV_VIEW_VIEWITEMITERATOR_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMITERATOR_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMITERATOR_HPP #include #include @@ -32,7 +32,8 @@ #include namespace pv { -namespace view { +namespace views { +namespace TraceView { template class ViewItemIterator { @@ -123,7 +124,8 @@ void swap(ViewItemIterator& a, ViewItemIterator& b) a.swap(b); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_VIEWITEMITERATOR_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMITERATOR_HPP diff --git a/pv/view/viewitemowner.cpp b/pv/view/viewitemowner.cpp index 8a70478..292d04e 100644 --- a/pv/view/viewitemowner.cpp +++ b/pv/view/viewitemowner.cpp @@ -34,7 +34,8 @@ using std::shared_ptr; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { ViewItemOwner::iterator ViewItemOwner::begin() { @@ -56,5 +57,6 @@ ViewItemOwner::const_iterator ViewItemOwner::end() const return const_iterator(this); } -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv diff --git a/pv/view/viewitemowner.hpp b/pv/view/viewitemowner.hpp index 49c251e..d31df80 100644 --- a/pv/view/viewitemowner.hpp +++ b/pv/view/viewitemowner.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_VIEWITEMOWNER_HPP -#define PULSEVIEW_PV_VIEW_VIEWITEMOWNER_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMOWNER_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMOWNER_HPP #include #include @@ -30,7 +30,8 @@ namespace pv { class Session; -namespace view { +namespace views { +namespace TraceView { class ViewItem; class View; @@ -90,7 +91,8 @@ protected: item_list items_; }; -} // view -} // pv +} // namespace TraceView +} // namespace views +} // namespace pv -#endif // PULSEVIEW_PV_VIEW_VIEWITEMOWNER_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMOWNER_HPP diff --git a/pv/view/viewitempaintparams.cpp b/pv/view/viewitempaintparams.cpp index 998045c..1727bd5 100644 --- a/pv/view/viewitempaintparams.cpp +++ b/pv/view/viewitempaintparams.cpp @@ -26,7 +26,8 @@ #include "viewitempaintparams.hpp" namespace pv { -namespace view { +namespace views { +namespace TraceView { ViewItemPaintParams::ViewItemPaintParams( const QRect &rect, double scale, const pv::util::Timestamp& offset) : @@ -47,5 +48,6 @@ int ViewItemPaintParams::text_height() return QFontMetrics(font()).height(); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/viewitempaintparams.hpp b/pv/view/viewitempaintparams.hpp index bba0d70..354d8c5 100644 --- a/pv/view/viewitempaintparams.hpp +++ b/pv/view/viewitempaintparams.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_VIEWITEMPAINTPARAMS_HPP -#define PULSEVIEW_PV_VIEW_VIEWITEMPAINTPARAMS_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMPAINTPARAMS_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMPAINTPARAMS_HPP #include "pv/util.hpp" @@ -27,7 +27,8 @@ #include namespace pv { -namespace view { +namespace views { +namespace TraceView { class ViewItemPaintParams { @@ -86,7 +87,8 @@ private: pv::util::Timestamp offset_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_VIEWITEMPAINTPARAMS_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWITEMPAINTPARAMS_HPP diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 6e07a2a..564b331 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -32,6 +32,8 @@ #include +#include + using std::abs; using std::back_inserter; using std::copy; @@ -45,7 +47,8 @@ using std::stable_sort; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { Viewport::Viewport(View &parent) : ViewWidget(parent), @@ -223,5 +226,6 @@ void Viewport::wheelEvent(QWheelEvent *event) } } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/viewport.hpp b/pv/view/viewport.hpp index e4c5042..a8062fb 100644 --- a/pv/view/viewport.hpp +++ b/pv/view/viewport.hpp @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_VIEW_VIEWPORT_HPP -#define PULSEVIEW_PV_VIEW_VIEWPORT_HPP +#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWPORT_HPP +#define PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWPORT_HPP #include @@ -34,7 +34,8 @@ class QPaintEvent; class Session; namespace pv { -namespace view { +namespace views { +namespace TraceView { class View; @@ -51,7 +52,7 @@ private: * @param item The item that is being hovered over, or @c nullptr * if no view item is being hovered over. */ - void item_hover(const std::shared_ptr &item); + void item_hover(const std::shared_ptr &item); /** * Gets the first view item which has a hit-box that contains @c pt . @@ -59,8 +60,7 @@ private: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - std::shared_ptr get_mouse_over_item( - const QPoint &pt); + std::shared_ptr get_mouse_over_item(const QPoint &pt); /** * Sets this item into the dragged state. @@ -81,7 +81,7 @@ private: /** * Gets the items in the view widget. */ - std::vector< std::shared_ptr > items(); + std::vector< std::shared_ptr > items(); /** * Handles touch begin update and end events. @@ -104,7 +104,8 @@ private: bool pinch_zoom_active_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv -#endif // PULSEVIEW_PV_VIEW_VIEWPORT_HPP +#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_VIEWPORT_HPP diff --git a/pv/view/viewwidget.cpp b/pv/view/viewwidget.cpp index 79326d2..3bd8c6b 100644 --- a/pv/view/viewwidget.cpp +++ b/pv/view/viewwidget.cpp @@ -31,7 +31,8 @@ using std::shared_ptr; using std::vector; namespace pv { -namespace view { +namespace views { +namespace TraceView { ViewWidget::ViewWidget(View &parent) : QWidget(&parent), @@ -298,5 +299,6 @@ void ViewWidget::leaveEvent(QEvent*) update(); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv diff --git a/pv/view/viewwidget.hpp b/pv/view/viewwidget.hpp index e6d2aa6..cfcbda4 100644 --- a/pv/view/viewwidget.hpp +++ b/pv/view/viewwidget.hpp @@ -28,12 +28,8 @@ class QTouchEvent; namespace pv { -namespace view { - -enum ViewType { - TraceView, - TabularDecodeView -}; +namespace views { +namespace TraceView { class View; class ViewItem; @@ -52,7 +48,7 @@ protected: * @remarks the default implementation does nothing. */ virtual void item_hover( - const std::shared_ptr &item); + const std::shared_ptr &item); /** * Indicates the event an a view item has been clicked. @@ -60,7 +56,7 @@ protected: * @remarks the default implementation does nothing. */ virtual void item_clicked( - const std::shared_ptr &item); + const std::shared_ptr &item); /** * Returns true if the selection of row items allows dragging. @@ -99,7 +95,7 @@ protected: /** * Gets the items in the view widget. */ - virtual std::vector< std::shared_ptr > items() = 0; + virtual std::vector< std::shared_ptr > items() = 0; /** * Gets the first view item which has a hit-box that contains @c pt . @@ -107,7 +103,7 @@ protected: * @return the view item that has been found, or and empty * @c shared_ptr if no item was found. */ - virtual std::shared_ptr get_mouse_over_item( + virtual std::shared_ptr get_mouse_over_item( const QPoint &pt) = 0; /** @@ -144,14 +140,15 @@ Q_SIGNALS: void selection_changed(); protected: - pv::view::View &view_; + pv::views::TraceView::View &view_; QPoint mouse_point_; QPoint mouse_down_point_; std::shared_ptr mouse_down_item_; bool item_dragging_; }; -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv #endif // PULSEVIEW_PV_VIEWWIDGET_HPP diff --git a/pv/views/viewbase.cpp b/pv/views/viewbase.cpp new file mode 100644 index 0000000..382e115 --- /dev/null +++ b/pv/views/viewbase.cpp @@ -0,0 +1,110 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * Copyright (C) 2016 Soeren Apel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef ENABLE_DECODE +#include +#endif + +#include + +#include "pv/session.hpp" +#include "pv/util.hpp" + +using std::shared_ptr; + +namespace pv { +namespace views { + +ViewBase::ViewBase(Session &session, QWidget *parent) : + session_(session) +{ + (void)parent; + + connect(&session_, SIGNAL(signals_changed()), + this, SLOT(signals_changed())); + connect(&session_, SIGNAL(capture_state_changed(int)), + this, SLOT(capture_state_updated(int))); + connect(&session_, SIGNAL(data_received()), + this, SLOT(data_updated())); + connect(&session_, SIGNAL(frame_ended()), + this, SLOT(data_updated())); +} + +Session& ViewBase::session() +{ + return session_; +} + +const Session& ViewBase::session() const +{ + return session_; +} + +void ViewBase::clear_signals() +{ +} + +#ifdef ENABLE_DECODE +void ViewBase::clear_decode_signals() +{ +} + +void ViewBase::add_decode_signal(shared_ptr signalbase) +{ + (void)signalbase; +} + +void ViewBase::remove_decode_signal(shared_ptr signalbase) +{ + (void)signalbase; +} +#endif + +void ViewBase::save_settings(QSettings &settings) const +{ + (void)settings; +} + +void ViewBase::restore_settings(QSettings &settings) +{ + (void)settings; +} + +void ViewBase::trigger_event(util::Timestamp location) +{ + (void)location; +} + +void ViewBase::signals_changed() +{ +} + +void ViewBase::capture_state_updated(int state) +{ + (void)state; +} + +void ViewBase::data_updated() +{ +} + +} // namespace view +} // namespace pv diff --git a/pv/views/viewbase.hpp b/pv/views/viewbase.hpp new file mode 100644 index 0000000..1ac8475 --- /dev/null +++ b/pv/views/viewbase.hpp @@ -0,0 +1,90 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * Copyright (C) 2016 Soeren Apel + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PULSEVIEW_PV_VIEWS_VIEWBASE_HPP +#define PULSEVIEW_PV_VIEWS_VIEWBASE_HPP + +#include + +#include +#include +#include + +#include + +#include +#include + +namespace pv { + +class Session; + +namespace view { +class DecodeTrace; +class Signal; +} + +namespace views { + +enum ViewType { + ViewTypeTrace, + ViewTypeTabularDecode +}; + +class ViewBase : public QWidget { + Q_OBJECT + +public: + explicit ViewBase(Session &session, QWidget *parent = 0); + + Session& session(); + const Session& session() const; + + virtual void clear_signals(); + +#ifdef ENABLE_DECODE + virtual void clear_decode_signals(); + + virtual void add_decode_signal(std::shared_ptr signalbase); + + virtual void remove_decode_signal(std::shared_ptr signalbase); +#endif + + virtual void save_settings(QSettings &settings) const; + + virtual void restore_settings(QSettings &settings); + +public Q_SLOTS: + virtual void trigger_event(util::Timestamp location); + virtual void signals_changed(); + virtual void capture_state_updated(int state); + virtual void data_updated(); + +protected: + Session &session_; + + util::TimeUnit time_unit_; +}; + +} // namespace views +} // namespace pv + +#endif // PULSEVIEW_PV_VIEWS_VIEWBASE_HPP -- 2.30.2