From: Joel Holdsworth Date: Sat, 13 Dec 2014 11:08:26 +0000 (+0000) Subject: RowItemPaintParams: Renamed to ViewItemPaintParams X-Git-Tag: pulseview-0.3.0~354 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=5b5fa4da3b7112414b9f51e6626ae7f4bf606f02 RowItemPaintParams: Renamed to ViewItemPaintParams --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9635bfce..401f918d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,7 +175,6 @@ set(pulseview_SOURCES pv/view/logicsignal.cpp pv/view/rowitem.cpp pv/view/rowitemowner.cpp - pv/view/rowitempaintparams.cpp pv/view/ruler.cpp pv/view/signal.cpp pv/view/timeitem.cpp @@ -185,6 +184,7 @@ set(pulseview_SOURCES pv/view/tracepalette.cpp pv/view/view.cpp pv/view/viewitem.cpp + pv/view/viewitempaintparams.cpp pv/view/viewport.cpp pv/widgets/colourbutton.cpp pv/widgets/colourpopup.cpp diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 5b6d8a50..303227eb 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -87,13 +87,13 @@ std::pair AnalogSignal::v_extents() const return make_pair(-NominalHeight / 2, NominalHeight / 2); } -void AnalogSignal::paint_back(QPainter &p, const RowItemPaintParams &pp) +void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (channel_->enabled()) paint_axis(p, pp, get_visual_y()); } -void AnalogSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) +void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { assert(data_); assert(owner_); diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index ad2b25ae..10cbab53 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -66,14 +66,14 @@ public: * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with.. **/ - void paint_back(QPainter &p, const RowItemPaintParams &pp); + void paint_back(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the mid-layer of the signal with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with.. **/ - void paint_mid(QPainter &p, const RowItemPaintParams &pp); + void paint_mid(QPainter &p, const ViewItemPaintParams &pp); private: void paint_trace(QPainter &p, diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 71fbaa85..669a1d95 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -160,21 +160,21 @@ pair DecodeTrace::v_extents() const { /// @todo Replace this with an implementation that knows the true /// height of the trace - const int row_height = (RowItemPaintParams::text_height() * 6) / 4; + const int row_height = (ViewItemPaintParams::text_height() * 6) / 4; return make_pair(-row_height / 2, row_height * 7 / 2); } -void DecodeTrace::paint_back(QPainter &p, const RowItemPaintParams &pp) +void DecodeTrace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { Trace::paint_back(p, pp); paint_axis(p, pp, get_visual_y()); } -void DecodeTrace::paint_mid(QPainter &p, const RowItemPaintParams &pp) +void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { using namespace pv::data::decode; - text_height_ = RowItemPaintParams::text_height(); + text_height_ = ViewItemPaintParams::text_height(); row_height_ = (text_height_ * 6) / 4; const int annotation_height = (text_height_ * 5) / 4; @@ -224,7 +224,7 @@ void DecodeTrace::paint_mid(QPainter &p, const RowItemPaintParams &pp) draw_unresolved_period(p, annotation_height, pp.left(), pp.right()); } -void DecodeTrace::paint_fore(QPainter &p, const RowItemPaintParams &pp) +void DecodeTrace::paint_fore(QPainter &p, const ViewItemPaintParams &pp) { using namespace pv::data::decode; @@ -333,7 +333,7 @@ QMenu* DecodeTrace::create_context_menu(QWidget *parent) } void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, - QPainter &p, int h, const RowItemPaintParams &pp, int y, + QPainter &p, int h, const ViewItemPaintParams &pp, int y, size_t base_colour) const { double samples_per_pixel, pixels_offset; @@ -435,7 +435,7 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, } void DecodeTrace::draw_error(QPainter &p, const QString &message, - const RowItemPaintParams &pp) + const ViewItemPaintParams &pp) { const int y = get_visual_y(); diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp index a0f8e800..edf3205b 100644 --- a/pv/view/decodetrace.hpp +++ b/pv/view/decodetrace.hpp @@ -101,21 +101,21 @@ public: * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with.. **/ - void paint_back(QPainter &p, const RowItemPaintParams &pp); + void paint_back(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the mid-layer of the trace with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with. **/ - void paint_mid(QPainter &p, const RowItemPaintParams &pp); + void paint_mid(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the foreground layer of the trace with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with. **/ - void paint_fore(QPainter &p, const RowItemPaintParams &pp); + void paint_fore(QPainter &p, const ViewItemPaintParams &pp); void populate_popup_form(QWidget *parent, QFormLayout *form); @@ -125,7 +125,7 @@ public: private: void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p, - int text_height, const RowItemPaintParams &pp, int y, + int text_height, const ViewItemPaintParams &pp, int y, size_t base_colour) const; void draw_instant(const pv::data::decode::Annotation &a, QPainter &p, @@ -136,7 +136,7 @@ private: double end, int y) const; void draw_error(QPainter &p, const QString &message, - const RowItemPaintParams &pp); + const ViewItemPaintParams &pp); void draw_unresolved_period(QPainter &p, int h, int left, int right) const; diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 4a8939d1..18619289 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -145,13 +145,13 @@ std::pair LogicSignal::v_extents() const return make_pair(-SignalHeight - SignalMargin, SignalMargin); } -void LogicSignal::paint_back(QPainter &p, const RowItemPaintParams &pp) +void LogicSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (channel_->enabled()) paint_axis(p, pp, get_visual_y()); } -void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) +void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { QLineF *line; @@ -225,7 +225,7 @@ void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp) delete[] cap_lines; } -void LogicSignal::paint_fore(QPainter &p, const RowItemPaintParams &pp) +void LogicSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp) { // Draw the trigger marker if (!trigger_match_) diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index c4588903..769b2fb6 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -86,21 +86,21 @@ public: * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with.. **/ - void paint_back(QPainter &p, const RowItemPaintParams &pp); + void paint_back(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the mid-layer of the signal with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with.. **/ - void paint_mid(QPainter &p, const RowItemPaintParams &pp); + void paint_mid(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the foreground layer of the signal with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with. **/ - virtual void paint_fore(QPainter &p, const RowItemPaintParams &pp); + virtual void paint_fore(QPainter &p, const ViewItemPaintParams &pp); private: void paint_caps(QPainter &p, QLineF *const lines, diff --git a/pv/view/rowitem.cpp b/pv/view/rowitem.cpp index 597c4a13..185e03ab 100644 --- a/pv/view/rowitem.cpp +++ b/pv/view/rowitem.cpp @@ -120,19 +120,19 @@ QPoint RowItem::point() const return QPoint(0, visual_v_offset()); } -void RowItem::paint_back(QPainter &p, const RowItemPaintParams &pp) +void RowItem::paint_back(QPainter &p, const ViewItemPaintParams &pp) { (void)p; (void)pp; } -void RowItem::paint_mid(QPainter &p, const RowItemPaintParams &pp) +void RowItem::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { (void)p; (void)pp; } -void RowItem::paint_fore(QPainter &p, const RowItemPaintParams &pp) +void RowItem::paint_fore(QPainter &p, const ViewItemPaintParams &pp) { (void)p; (void)pp; diff --git a/pv/view/rowitem.hpp b/pv/view/rowitem.hpp index e7f55c62..6688bc5c 100644 --- a/pv/view/rowitem.hpp +++ b/pv/view/rowitem.hpp @@ -25,7 +25,7 @@ #include -#include "rowitempaintparams.hpp" +#include "viewitempaintparams.hpp" #include "viewitem.hpp" namespace pv { @@ -110,21 +110,21 @@ public: * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with. **/ - virtual void paint_back(QPainter &p, const RowItemPaintParams &pp); + virtual void paint_back(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the mid-layer of the trace with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with. **/ - virtual void paint_mid(QPainter &p, const RowItemPaintParams &pp); + virtual void paint_mid(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the foreground layer of the trace with a QPainter * @param p the QPainter to paint into. * @param pp the painting parameters object to paint with. **/ - virtual void paint_fore(QPainter &p, const RowItemPaintParams &pp); + virtual void paint_fore(QPainter &p, const ViewItemPaintParams &pp); /** * Paints the signal label. diff --git a/pv/view/rowitempaintparams.cpp b/pv/view/rowitempaintparams.cpp deleted file mode 100644 index c46d715b..00000000 --- a/pv/view/rowitempaintparams.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Joel Holdsworth - * - * 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 - */ - -#include - -#include -#include - -#include "rowitempaintparams.hpp" - -namespace pv { -namespace view { - -RowItemPaintParams::RowItemPaintParams( - int left, int right, double scale, double offset) : - left_(left), - right_(right), - scale_(scale), - offset_(offset) { - assert(left <= right); - assert(scale > 0.0); -} - -QFont RowItemPaintParams::font() -{ - return QApplication::font(); -} - -int RowItemPaintParams::text_height() { - QFontMetrics m(font()); - return m.boundingRect(QRect(), 0, "Tg").height(); -} - -} // namespace view -} // namespace pv diff --git a/pv/view/rowitempaintparams.hpp b/pv/view/rowitempaintparams.hpp deleted file mode 100644 index ec66076b..00000000 --- a/pv/view/rowitempaintparams.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Joel Holdsworth - * - * 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_VIEW_ROWITEMPAINTPARAMS_H -#define PULSEVIEW_PV_VIEW_ROWITEMPAINTPARAMS_H - -#include - -namespace pv { -namespace view { - -class RowItemPaintParams -{ -public: - RowItemPaintParams(int left, int right, double scale, double offset); - - int left() const { - return left_; - } - - int right() const { - return right_; - } - - double scale() const { - return scale_; - } - - double offset() const { - return offset_; - } - - int width() const { - return right_ - left_; - } - - double pixels_offset() const { - return offset_ / scale_; - } - -public: - static QFont font(); - - static int text_height(); - -private: - int left_; - int right_; - double scale_; - double offset_; -}; - -} // namespace view -} // namespace pv - -#endif // PULSEVIEW_PV_VIEW_ROWITEMPAINTPARAMS_H diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index b24afac2..1464b5ee 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -162,7 +162,7 @@ QRectF Trace::label_rect(const QRectF &rect) const label_size.height()); } -void Trace::paint_axis(QPainter &p, const RowItemPaintParams &pp, int y) +void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y) { p.setPen(AxisPen); p.drawLine(QPointF(pp.left(), y + 0.5f), QPointF(pp.right(), y + 0.5f)); diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index 7d5158c3..29494615 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -99,7 +99,7 @@ protected: * @param pp the painting parameters object to paint with. * @param y the y-offset of the axis. */ - void paint_axis(QPainter &p, const RowItemPaintParams &pp, int y); + void paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y); void add_colour_option(QWidget *parent, QFormLayout *form); diff --git a/pv/view/viewitempaintparams.cpp b/pv/view/viewitempaintparams.cpp new file mode 100644 index 00000000..4edc30a3 --- /dev/null +++ b/pv/view/viewitempaintparams.cpp @@ -0,0 +1,52 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 Joel Holdsworth + * + * 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 + */ + +#include + +#include +#include + +#include "viewitempaintparams.hpp" + +namespace pv { +namespace view { + +ViewItemPaintParams::ViewItemPaintParams( + int left, int right, double scale, double offset) : + left_(left), + right_(right), + scale_(scale), + offset_(offset) { + assert(left <= right); + assert(scale > 0.0); +} + +QFont ViewItemPaintParams::font() +{ + return QApplication::font(); +} + +int ViewItemPaintParams::text_height() { + QFontMetrics m(font()); + return m.boundingRect(QRect(), 0, "Tg").height(); +} + +} // namespace view +} // namespace pv diff --git a/pv/view/viewitempaintparams.hpp b/pv/view/viewitempaintparams.hpp new file mode 100644 index 00000000..3128ef48 --- /dev/null +++ b/pv/view/viewitempaintparams.hpp @@ -0,0 +1,73 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 Joel Holdsworth + * + * 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_VIEW_ROWITEMPAINTPARAMS_H +#define PULSEVIEW_PV_VIEW_ROWITEMPAINTPARAMS_H + +#include + +namespace pv { +namespace view { + +class ViewItemPaintParams +{ +public: + ViewItemPaintParams(int left, int right, double scale, double offset); + + int left() const { + return left_; + } + + int right() const { + return right_; + } + + double scale() const { + return scale_; + } + + double offset() const { + return offset_; + } + + int width() const { + return right_ - left_; + } + + double pixels_offset() const { + return offset_ / scale_; + } + +public: + static QFont font(); + + static int text_height(); + +private: + int left_; + int right_; + double scale_; + double offset_; +}; + +} // namespace view +} // namespace pv + +#endif // PULSEVIEW_PV_VIEW_ROWITEMPAINTPARAMS_H diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index 75902af2..556babcc 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -22,9 +22,9 @@ #include #include -#include "rowitempaintparams.hpp" #include "signal.hpp" #include "view.hpp" +#include "viewitempaintparams.hpp" #include "viewport.hpp" #include @@ -70,7 +70,7 @@ void Viewport::paintEvent(QPaintEvent*) if (view_.cursors_shown()) view_.cursors()->draw_viewport_background(p, rect()); - const RowItemPaintParams pp(0, width(), view_.scale(), view_.offset()); + const ViewItemPaintParams pp(0, width(), view_.scale(), view_.offset()); // Plot the signal for (const shared_ptr r : row_items) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 064b4e59..b1fc61ca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -47,7 +47,6 @@ set(pulseview_TEST_SOURCES ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.cpp ${PROJECT_SOURCE_DIR}/pv/view/rowitem.cpp ${PROJECT_SOURCE_DIR}/pv/view/rowitemowner.cpp - ${PROJECT_SOURCE_DIR}/pv/view/rowitempaintparams.cpp ${PROJECT_SOURCE_DIR}/pv/view/ruler.cpp ${PROJECT_SOURCE_DIR}/pv/view/signal.cpp ${PROJECT_SOURCE_DIR}/pv/view/timeitem.cpp @@ -57,6 +56,7 @@ set(pulseview_TEST_SOURCES ${PROJECT_SOURCE_DIR}/pv/view/tracepalette.cpp ${PROJECT_SOURCE_DIR}/pv/view/view.cpp ${PROJECT_SOURCE_DIR}/pv/view/viewitem.cpp + ${PROJECT_SOURCE_DIR}/pv/view/viewitempaintparams.cpp ${PROJECT_SOURCE_DIR}/pv/view/viewport.cpp ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp