]> sigrok.org Git - pulseview.git/commitdiff
RowItemPaintParams: Renamed to ViewItemPaintParams
authorJoel Holdsworth <redacted>
Sat, 13 Dec 2014 11:08:26 +0000 (11:08 +0000)
committerJoel Holdsworth <redacted>
Sun, 28 Dec 2014 15:35:57 +0000 (15:35 +0000)
17 files changed:
CMakeLists.txt
pv/view/analogsignal.cpp
pv/view/analogsignal.hpp
pv/view/decodetrace.cpp
pv/view/decodetrace.hpp
pv/view/logicsignal.cpp
pv/view/logicsignal.hpp
pv/view/rowitem.cpp
pv/view/rowitem.hpp
pv/view/rowitempaintparams.cpp [deleted file]
pv/view/rowitempaintparams.hpp [deleted file]
pv/view/trace.cpp
pv/view/trace.hpp
pv/view/viewitempaintparams.cpp [new file with mode: 0644]
pv/view/viewitempaintparams.hpp [new file with mode: 0644]
pv/view/viewport.cpp
test/CMakeLists.txt

index 9635bfce4d25d66ae70f77c5c0cfa7c86f6a4311..401f918d82fd61c23b48b283be651d11d9bc65d3 100644 (file)
@@ -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
index 5b6d8a50ca3ac4e24d96d5892a73b7a155ecffdc..303227eb37fed6b2931ed7b7259a03ec816044b6 100644 (file)
@@ -87,13 +87,13 @@ std::pair<int, int> 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_);
index ad2b25ae18bee4d418d41cefa5b50847fbd35394..10cbab531810ad7d376da34d500d5276fd7576f8 100644 (file)
@@ -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,
index 71fbaa85c613d29dab29400edc5fe3d17c76c8c5..669a1d95d3a5347c89b0bb51f1925027a377612f 100644 (file)
@@ -160,21 +160,21 @@ pair<int, int> 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();
 
index a0f8e8000cbf66e5dc3b2d4b277f75970ce68d0f..edf3205b530479993cd96209af523ea48eea6353 100644 (file)
@@ -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;
index 4a8939d14eadaa6f298aa5f1e682c783685f9ffb..18619289e71f9fc357e6b1bfae65ae6b2b1af92e 100644 (file)
@@ -145,13 +145,13 @@ std::pair<int, int> 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_)
index c4588903ba83d3a5e6731d0b0a24c778620e4aa8..769b2fb6f3bd3a9359d63788cd1ee047c8211b14 100644 (file)
@@ -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,
index 597c4a138ec53fa4ecde9d924d4307be529abb4c..185e03ab36d83d951a041b1698f814eb7094d6d3 100644 (file)
@@ -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;
index e7f55c6268e290e6d102c0baaa2b2e09f87a22c1..6688bc5c90602a7dfd48d15a17acc873a233882e 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <QPropertyAnimation>
 
-#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 (file)
index c46d715..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * 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 <cassert>
-
-#include <QApplication>
-#include <QFontMetrics>
-
-#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 (file)
index ec66076..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * 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 <QFont>
-
-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
index b24afac24ac303d99275749342a7485f2633841f..1464b5eea135d19aa7ad70ad41820c703fd7871f 100644 (file)
@@ -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));
index 7d5158c3a0d36d237e3e2c9596ea87d399083483..294946155cc2f20f2737c2452428e293a44e5b17 100644 (file)
@@ -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 (file)
index 0000000..4edc30a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * 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 <cassert>
+
+#include <QApplication>
+#include <QFontMetrics>
+
+#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 (file)
index 0000000..3128ef4
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * 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 <QFont>
+
+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
index 75902af2bc7588ba08fc9d4b6fe883e886e108c8..556babcc94435de43d98cd833914f751430d9a97 100644 (file)
@@ -22,9 +22,9 @@
 #include <cmath>
 #include <algorithm>
 
-#include "rowitempaintparams.hpp"
 #include "signal.hpp"
 #include "view.hpp"
+#include "viewitempaintparams.hpp"
 #include "viewport.hpp"
 
 #include <pv/session.hpp>
@@ -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<RowItem> r : row_items)
index 064b4e593a3dc29542cf587051710461f5c9e668..b1fc61caa7799e895a14e30269243b3a3e3a8751 100644 (file)
@@ -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