From 8d634081d8b0cc741dd34d8c646474ff6754aea8 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 3 Nov 2012 09:18:16 +0000 Subject: [PATCH 1/1] Moved Signal and LogicSignal into pv::view --- CMakeLists.txt | 4 ++-- pv/sigsession.cpp | 8 +++++--- pv/sigsession.h | 7 +++++-- pv/view/header.cpp | 6 +++--- pv/view/header.h | 6 ++---- pv/{ => view}/logicsignal.cpp | 17 ++++++++++------- pv/{ => view}/logicsignal.h | 7 +++++-- pv/{ => view}/signal.cpp | 4 +++- pv/{ => view}/signal.h | 2 ++ pv/view/viewport.cpp | 2 +- 10 files changed, 38 insertions(+), 25 deletions(-) rename pv/{ => view}/logicsignal.cpp (91%) rename pv/{ => view}/logicsignal.h (94%) rename pv/{ => view}/signal.cpp (98%) rename pv/{ => view}/signal.h (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1513d6d..812176e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,15 +84,15 @@ set(pulseview_SOURCES pv/datasnapshot.cpp pv/logicdata.cpp pv/logicdatasnapshot.cpp - pv/logicsignal.cpp pv/mainwindow.cpp pv/samplingbar.cpp pv/signaldata.cpp pv/sigsession.cpp - pv/signal.cpp pv/view/cursor.cpp pv/view/header.cpp + pv/view/logicsignal.cpp pv/view/ruler.cpp + pv/view/signal.cpp pv/view/timemarker.cpp pv/view/view.cpp pv/view/viewport.cpp diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 40c46f0..81ccca7 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -22,7 +22,7 @@ #include "logicdata.h" #include "logicdatasnapshot.h" -#include "logicsignal.h" +#include "view/logicsignal.h" #include @@ -94,7 +94,7 @@ void SigSession::start_capture(struct sr_dev_inst *sdi, sr_session_destroy(); } -vector< shared_ptr >& SigSession::get_signals() +vector< shared_ptr >& SigSession::get_signals() { return _signals; } @@ -107,6 +107,8 @@ boost::shared_ptr SigSession::get_data() void SigSession::data_feed_in(const struct sr_dev_inst *sdi, struct sr_datafeed_packet *packet) { + using view::LogicSignal; + assert(sdi); assert(packet); @@ -136,7 +138,7 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, sdi->probes, i); if(probe->enabled) { - boost::shared_ptr signal( + shared_ptr signal( new LogicSignal(probe->name, _logic_data, probe->index)); diff --git a/pv/sigsession.h b/pv/sigsession.h index b6e5a56..29929a9 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -36,7 +36,10 @@ namespace pv { class LogicData; class LogicDataSnapshot; + +namespace view { class Signal; +} class SigSession : public QObject { @@ -52,7 +55,7 @@ public: void start_capture(struct sr_dev_inst* sdi, uint64_t record_length, uint64_t sample_rate); - std::vector< boost::shared_ptr >& + std::vector< boost::shared_ptr >& get_signals(); boost::shared_ptr get_data(); @@ -65,7 +68,7 @@ private: struct sr_datafeed_packet *packet); private: - std::vector< boost::shared_ptr > _signals; + std::vector< boost::shared_ptr > _signals; boost::shared_ptr _logic_data; boost::shared_ptr _cur_logic_snapshot; diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 284bb37..2f02e77 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -21,7 +21,7 @@ #include "header.h" #include "view.h" -#include "../signal.h" +#include "signal.h" #include "../sigsession.h" #include @@ -126,7 +126,7 @@ void Header::contextMenuEvent(QContextMenuEvent *event) void Header::on_action_set_name_triggered() { - boost::shared_ptr context_signal = _context_signal; + shared_ptr context_signal = _context_signal; if(!context_signal) return; @@ -139,7 +139,7 @@ void Header::on_action_set_name_triggered() void Header::on_action_set_colour_triggered() { - boost::shared_ptr context_signal = _context_signal; + shared_ptr context_signal = _context_signal; if(!context_signal) return; diff --git a/pv/view/header.h b/pv/view/header.h index b9cf8da..efc126e 100644 --- a/pv/view/header.h +++ b/pv/view/header.h @@ -26,11 +26,9 @@ #include namespace pv { - -class Signal; - namespace view { +class Signal; class View; class Header : public QWidget @@ -60,7 +58,7 @@ private: QPoint _mouse_point; - boost::shared_ptr _context_signal; + boost::shared_ptr _context_signal; QAction *_action_set_name; QAction *_action_set_colour; }; diff --git a/pv/logicsignal.cpp b/pv/view/logicsignal.cpp similarity index 91% rename from pv/logicsignal.cpp rename to pv/view/logicsignal.cpp index 0c1933d..cf3f3e5 100644 --- a/pv/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -22,14 +22,15 @@ #include -#include "logicdata.h" -#include "logicdatasnapshot.h" #include "logicsignal.h" +#include "../logicdata.h" +#include "../logicdatasnapshot.h" using namespace boost; using namespace std; namespace pv { +namespace view { const float LogicSignal::Margin = 10.0f; const float LogicSignal::Oversampling = 2.0f; @@ -75,12 +76,13 @@ void LogicSignal::paint(QPainter &p, const QRect &rect, double scale, const float high_offset = rect.top() + Margin + 0.5f; const float low_offset = rect.bottom() - Margin + 0.5f; - const deque< shared_ptr > &snapshots = + const deque< shared_ptr > &snapshots = _data->get_snapshots(); if(snapshots.empty()) return; - const shared_ptr &snapshot = snapshots.front(); + const shared_ptr &snapshot = + snapshots.front(); const double pixels_offset = offset / scale; const double samplerate = _data->get_samplerate(); @@ -101,7 +103,7 @@ void LogicSignal::paint(QPainter &p, const QRect &rect, double scale, QLineF *const edge_lines = new QLineF[edge_count]; line = edge_lines; - for(vector::const_iterator i = + for(vector::const_iterator i = edges.begin() + 1; i != edges.end() - 1; i++) { const float x = ((*i).first / samples_per_pixel - @@ -134,8 +136,8 @@ void LogicSignal::paint_caps(QPainter &p, QLineF *const lines, { QLineF *line = lines; - for(vector::const_iterator i = edges.begin(); - i != (edges.end() - 1); i++) + for(vector::const_iterator i = + edges.begin(); i != (edges.end() - 1); i++) if((*i).second == level) { *line++ = QLineF( ((*i).first / samples_per_pixel - @@ -152,4 +154,5 @@ int LogicSignal::get_nominal_offset(const QRect &rect) const return rect.bottom() - Margin; } +} // namespace view } // namespace pv diff --git a/pv/logicsignal.h b/pv/view/logicsignal.h similarity index 94% rename from pv/logicsignal.h rename to pv/view/logicsignal.h index b1ef777..dd4a030 100644 --- a/pv/logicsignal.h +++ b/pv/view/logicsignal.h @@ -29,6 +29,8 @@ namespace pv { class LogicData; +namespace view { + class LogicSignal : public Signal { private: @@ -43,7 +45,7 @@ private: public: LogicSignal(QString name, - boost::shared_ptr data, + boost::shared_ptr data, int probe_index); /** @@ -71,9 +73,10 @@ private: private: int _probe_index; - boost::shared_ptr _data; + boost::shared_ptr _data; }; +} // namespace view } // namespace pv #endif // PULSEVIEW_PV_LOGICSIGNAL_H diff --git a/pv/signal.cpp b/pv/view/signal.cpp similarity index 98% rename from pv/signal.cpp rename to pv/view/signal.cpp index 04c5792..3e951b3 100644 --- a/pv/signal.cpp +++ b/pv/view/signal.cpp @@ -21,9 +21,10 @@ #include #include "signal.h" -#include "view/view.h" +#include "view.h" namespace pv { +namespace view { const int Signal::LabelHitPadding = 2; @@ -128,4 +129,5 @@ QRectF Signal::get_label_rect(const QRect &rect) label_size.width(), label_size.height()); } +} // namespace view } // namespace pv diff --git a/pv/signal.h b/pv/view/signal.h similarity index 98% rename from pv/signal.h rename to pv/view/signal.h index 2afe952..8adee96 100644 --- a/pv/signal.h +++ b/pv/view/signal.h @@ -31,6 +31,7 @@ #include namespace pv { +namespace view { class SignalData; @@ -120,6 +121,7 @@ protected: QSizeF _text_size; }; +} // namespace view } // namespace pv #endif // PULSEVIEW_PV_SIGNAL_H diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 2dcf9dc..d9b0ff1 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -21,8 +21,8 @@ #include "view.h" #include "viewport.h" +#include "signal.h" #include "../sigsession.h" -#include "../signal.h" #include -- 2.30.2