Introduce math signals
authorSoeren Apel <soeren@apelpie.net>
Sun, 2 Aug 2020 15:48:58 +0000 (17:48 +0200)
committerSoeren Apel <soeren@apelpie.net>
Sat, 15 Aug 2020 22:29:58 +0000 (00:29 +0200)
CMakeLists.txt
README
icons/add-math-signal.svg [new file with mode: 0644]
pulseview.qrc
pv/data/mathsignal.cpp [new file with mode: 0644]
pv/data/mathsignal.hpp [new file with mode: 0644]
pv/toolbars/mainbar.cpp
pv/toolbars/mainbar.hpp
pv/views/trace/view.cpp
test/CMakeLists.txt

index bd5de9ec8730296474c0b5365fbeaddd495a7264..aead6ee7e8e19446f5c961d8620b6a08d3de075f 100644 (file)
@@ -258,6 +258,7 @@ set(pulseview_SOURCES
        pv/data/analogsegment.cpp
        pv/data/logic.cpp
        pv/data/logicsegment.cpp
+       pv/data/mathsignal.cpp
        pv/data/signalbase.cpp
        pv/data/signaldata.cpp
        pv/data/segment.cpp
@@ -331,6 +332,7 @@ set(pulseview_HEADERS
        pv/data/analogsegment.hpp
        pv/data/logic.hpp
        pv/data/logicsegment.hpp
+       pv/data/mathsignal.hpp
        pv/data/signalbase.hpp
        pv/dialogs/connect.hpp
        pv/dialogs/inputoutputoptions.hpp
diff --git a/README b/README
index a35cb8d58c09c610aa51eee3ced239701c22e32b..96f17ab6fa5ad933b0ec4200a9ed0381f512a266 100644 (file)
--- a/README
+++ b/README
@@ -71,6 +71,11 @@ icons/information.svg: Bobarino
     GFDL 1.2 or later / CC-BY-SA 3.0
     https://en.wikipedia.org/wiki/File:Information.svg#Licensing
 
+icons/add-math-channel.svg: Inductiveload
+  https://en.wikipedia.org/wiki/File:Icon_Mathematical_Plot.svg
+  License:
+    Public Domain
+
 QDarkStyleSheet: Colin Duquesnoy
   https://github.com/ColinDuquesnoy/QDarkStyleSheet
   License:
diff --git a/icons/add-math-signal.svg b/icons/add-math-signal.svg
new file mode 100644 (file)
index 0000000..4fa7124
--- /dev/null
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg11300"
+   height="48px"
+   width="48px"
+   version="1.1"
+   sodipodi:docname="add-math-channel.svg"
+   inkscape:version="0.92.4 5da689c313, 2019-01-14">
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1920"
+     inkscape:window-height="1022"
+     id="namedview124"
+     showgrid="false"
+     inkscape:zoom="17.0625"
+     inkscape:cx="12.893773"
+     inkscape:cy="24"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg11300" />
+  <defs
+     id="defs3">
+    <radialGradient
+       id="radialGradient6719"
+       cx="605.71"
+       xlink:href="#linearGradient5060"
+       gradientUnits="userSpaceOnUse"
+       cy="486.65"
+       r="117.14"
+       gradientTransform="matrix(-2.7744,0,0,1.9697,112.76,-872.89)" />
+    <linearGradient
+       id="linearGradient5060">
+      <stop
+         id="stop5062"
+         offset="0" />
+      <stop
+         id="stop5064"
+         stop-opacity="0"
+         offset="1" />
+    </linearGradient>
+    <radialGradient
+       id="radialGradient6717"
+       cx="605.71"
+       xlink:href="#linearGradient5060"
+       gradientUnits="userSpaceOnUse"
+       cy="486.65"
+       r="117.14"
+       gradientTransform="matrix(2.7744,0,0,1.9697,-1891.6,-872.89)" />
+    <linearGradient
+       id="linearGradient6715"
+       y2="609.51"
+       gradientUnits="userSpaceOnUse"
+       y1="366.65"
+       gradientTransform="matrix(2.7744,0,0,1.9697,-1892.2,-872.89)"
+       x2="302.86"
+       x1="302.86">
+      <stop
+         id="stop5050"
+         stop-opacity="0"
+         offset="0" />
+      <stop
+         id="stop5056"
+         offset=".5" />
+      <stop
+         id="stop5052"
+         stop-opacity="0"
+         offset="1" />
+    </linearGradient>
+    <radialGradient
+       id="radialGradient2939"
+       cx="25.458"
+       gradientUnits="userSpaceOnUse"
+       cy="35.596"
+       r="20.531"
+       gradientTransform="matrix(2.1282,0,0,2.1283,-28.519,-40.418)">
+      <stop
+         id="stop2935"
+         stop-color="#9cbcde"
+         offset="0" />
+      <stop
+         id="stop2937"
+         stop-color="#204a87"
+         offset="1" />
+    </radialGradient>
+  </defs>
+  <metadata
+     id="metadata4">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:creator>
+          <cc:Agent>
+            <dc:title>Jakub Steiner</dc:title>
+          </cc:Agent>
+        </dc:creator>
+        <dc:source>http://jimmac.musichall.cz</dc:source>
+        <cc:license
+           rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
+        <dc:title>Accessibility</dc:title>
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li>accessibility</rdf:li>
+            <rdf:li>assist</rdf:li>
+          </rdf:Bag>
+        </dc:subject>
+      </cc:Work>
+      <cc:License
+         rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+        <cc:permits
+           rdf:resource="http://web.resource.org/cc/Reproduction" />
+        <cc:permits
+           rdf:resource="http://web.resource.org/cc/Distribution" />
+        <cc:requires
+           rdf:resource="http://web.resource.org/cc/Notice" />
+        <cc:requires
+           rdf:resource="http://web.resource.org/cc/Attribution" />
+        <cc:permits
+           rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+        <cc:requires
+           rdf:resource="http://web.resource.org/cc/ShareAlike" />
+      </cc:License>
+    </rdf:RDF>
+  </metadata>
+  <path
+     style="fill:none;stroke:#ff0000;stroke-width:1px"
+     inkscape:connector-curvature="0"
+     d="m 12.5,36 c 3,-8 8.155,-12.981 10.5,-13 3.431,-0.028 5,6 9,6 3.606,0 7,-11 8,-19"
+     id="path9990" />
+  <path
+     style="fill:none;stroke:#000000;stroke-width:2;stroke-opacity:1"
+     inkscape:connector-curvature="0"
+     d="M 12,10 V 36 H 38"
+     id="path9988" />
+  <path
+     style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-opacity:1;fill-opacity:1;stroke-linejoin:miter;paint-order:normal;stroke-linecap:round"
+     inkscape:connector-curvature="0"
+     d="m 12,7 -3,6 h 6 L 12,7"
+     id="path9992" />
+  <path
+     style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-opacity:1;fill-opacity:1;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-linecap:round"
+     inkscape:connector-curvature="0"
+     d="m 41,36 -6,-3 v 6 l 6,-3"
+     id="path9994" />
+  <g
+     style="fill:#000000;stroke:#000000;stroke-width:0.14230999;stroke-opacity:1;fill-opacity:1"
+     transform="matrix(3.5134,0,0,3.5134,-53.717,-11.668)"
+     id="g10167">
+    <g
+       style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:2.07540011;stroke-miterlimit:10.43299961;stroke-opacity:1;fill-opacity:1"
+       stroke-miterlimit="10.433"
+       transform="matrix(0.068571,0,0,-0.068571,-12,36)"
+       xml:space="preserve"
+       id="g10169"><path
+         inkscape:connector-curvature="0"
+         d="m 474.28,425.93 h 4.29 c 0.99,0 1.49,0 1.49,0.99 0,0.55 -0.5,0.55 -1.35,0.55 h -4.13 c 0.55,2.89 0.5,2.79 1.05,5.68 0.19,1.05 0.89,4.58 1.19,5.18 0.45,0.94 1.3,1.69 2.34,1.69 0.2,0 1.5,0 2.45,-0.89 -2.2,-0.2 -2.7,-1.95 -2.7,-2.69 0,-1.15 0.9,-1.75 1.85,-1.75 1.29,0 2.74,1.1 2.74,2.99 0,2.29 -2.29,3.44 -4.34,3.44 -1.69,0 -4.83,-0.9 -6.32,-5.83 -0.3,-1.05 -0.45,-1.54 -1.65,-7.82 h -3.43 c -0.95,0 -1.5,0 -1.5,-0.95 0,-0.59 0.45,-0.59 1.4,-0.59 h 3.29 l -3.74,-19.68 c -0.9,-4.83 -1.75,-9.37 -4.33,-9.37 -0.2,0 -1.45,0 -2.4,0.9 2.29,0.15 2.74,1.94 2.74,2.69 0,1.15 -0.89,1.74 -1.84,1.74 -1.29,0 -2.74,-1.09 -2.74,-2.98 0,-2.25 2.19,-3.44 4.24,-3.44 2.73,0 4.73,2.94 5.62,4.83 1.6,3.14 2.74,9.17 2.79,9.51 z"
+         id="path10171"
+         style="stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" /><path
+         inkscape:connector-curvature="0"
+         d="m 501.49,394.04 v 0.03 0.03 l -0.01,0.01 v 0.02 0.01 l -0.01,0.02 v 0.02 l -0.01,0.01 -0.01,0.02 -0.01,0.02 -0.01,0.03 -0.01,0.02 -0.02,0.02 -0.02,0.03 -0.02,0.03 -0.02,0.03 -0.03,0.03 -0.03,0.04 -0.01,0.02 -0.02,0.02 -0.02,0.02 -0.02,0.02 -0.02,0.02 -0.02,0.03 -0.02,0.02 -0.02,0.02 -0.02,0.03 -0.03,0.02 -0.02,0.03 -0.03,0.03 -0.02,0.03 -0.03,0.03 -0.03,0.03 -0.03,0.03 -0.03,0.03 -0.03,0.03 -0.04,0.04 -0.03,0.03 -0.04,0.04 -0.03,0.03 -0.04,0.04 -0.04,0.04 c -6.23,6.28 -7.82,15.69 -7.82,23.31 0,8.67 1.89,17.34 8.02,23.57 0.65,0.59 0.65,0.69 0.65,0.84 0,0.35 -0.2,0.5 -0.5,0.5 -0.5,0 -4.98,-3.39 -7.92,-9.72 -2.54,-5.47 -3.14,-11 -3.14,-15.19 0,-3.88 0.55,-9.91 3.29,-15.54 2.99,-6.12 7.27,-9.36 7.77,-9.36 0.3,0 0.5,0.15 0.5,0.49 z"
+         id="path10173"
+         style="stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" /><path
+         inkscape:connector-curvature="0"
+         d="m 521.64,421.04 0.03,0.13 0.03,0.15 0.05,0.17 0.04,0.18 0.06,0.19 0.06,0.21 0.06,0.21 0.07,0.23 0.08,0.23 0.09,0.24 0.1,0.25 0.1,0.24 0.11,0.25 0.12,0.25 0.13,0.25 0.14,0.25 0.15,0.24 0.15,0.24 0.17,0.23 0.18,0.22 0.18,0.22 0.2,0.2 0.21,0.19 0.22,0.18 0.23,0.16 0.25,0.14 0.12,0.07 0.13,0.06 0.13,0.05 0.14,0.05 0.14,0.05 0.14,0.04 0.14,0.03 0.15,0.03 0.15,0.02 0.16,0.02 0.16,0.01 h 0.16 c 0.25,0 1.45,0 2.49,-0.65 -1.4,-0.25 -2.39,-1.49 -2.39,-2.68 0,-0.8 0.55,-1.75 1.89,-1.75 1.1,0 2.69,0.9 2.69,2.89 0,2.59 -2.94,3.29 -4.63,3.29 -2.89,0 -4.64,-2.64 -5.23,-3.79 -1.24,3.29 -3.94,3.79 -5.38,3.79 -5.18,0 -8.02,-6.43 -8.02,-7.67 0,-0.5 0.5,-0.5 0.6,-0.5 0.39,0 0.54,0.1 0.64,0.54 1.7,5.29 4.99,6.53 6.68,6.53 0.94,0 2.69,-0.45 2.69,-3.33 0,-1.55 -0.85,-4.89 -2.69,-11.86 -0.8,-3.09 -2.54,-5.18 -4.73,-5.18 -0.3,0 -1.45,0 -2.49,0.65 1.24,0.25 2.34,1.29 2.34,2.69 0,1.34 -1.1,1.74 -1.85,1.74 -1.49,0 -2.73,-1.3 -2.73,-2.89 0,-2.29 2.48,-3.29 4.68,-3.29 3.28,0 5.08,3.49 5.22,3.79 0.61,-1.85 2.4,-3.79 5.39,-3.79 5.13,0 7.97,6.43 7.97,7.68 0,0.49 -0.45,0.49 -0.6,0.49 -0.45,0 -0.55,-0.2 -0.65,-0.55 -1.64,-5.33 -5.03,-6.52 -6.62,-6.52 -1.94,0 -2.74,1.59 -2.74,3.29 0,1.09 0.3,2.19 0.85,4.38 z"
+         id="path10175"
+         style="stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" /><path
+         inkscape:connector-curvature="0"
+         d="m 547.4,418.45 -0.01,0.37 v 0.39 l -0.01,0.39 -0.01,0.41 -0.04,0.84 -0.06,0.88 -0.09,0.92 -0.1,0.94 -0.14,0.98 -0.16,1 -0.2,1.02 -0.23,1.04 -0.27,1.05 -0.3,1.06 -0.35,1.06 -0.39,1.07 -0.22,0.53 -0.22,0.54 -0.24,0.53 -0.25,0.53 c -2.99,6.12 -7.27,9.36 -7.77,9.36 -0.3,0 -0.5,-0.2 -0.5,-0.5 0,-0.15 0,-0.25 0.94,-1.15 4.89,-4.92 7.73,-12.85 7.73,-23.26 0,-8.52 -1.85,-17.28 -8.02,-23.56 -0.65,-0.6 -0.65,-0.69 -0.65,-0.85 0,-0.29 0.2,-0.49 0.5,-0.49 0.5,0 4.98,3.38 7.92,9.71 2.54,5.48 3.14,11.01 3.14,15.19 z"
+         id="path10177"
+         style="stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1" /></g>  </g>
+</svg>
index 4427a759cf3266060af90815b94ee6dfadebd908..ceda06dfee4971dd07fb1676cbfaca18016cd4bb 100644 (file)
@@ -1,6 +1,7 @@
 <RCC>
     <qresource prefix="/">
        <file>icons/add-decoder.svg</file>
+       <file>icons/add-math-signal.svg</file>
        <file>icons/application-exit.png</file>
        <file>icons/channels.svg</file>
        <file>icons/decoder-delete.svg</file>
diff --git a/pv/data/mathsignal.cpp b/pv/data/mathsignal.cpp
new file mode 100644 (file)
index 0000000..1876168
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2020 Soeren Apel <soeren@apelpie.net>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <limits>
+
+#include <QDebug>
+
+#include "mathsignal.hpp"
+
+#include <pv/globalsettings.hpp>
+#include <pv/session.hpp>
+#include <pv/data/analogsegment.hpp>
+#include <pv/data/signalbase.hpp>
+
+using std::make_shared;
+
+namespace pv {
+namespace data {
+
+const int64_t MathSignal::ChunkLength = 256 * 1024;
+
+
+MathSignal::MathSignal(pv::Session &session) :
+       SignalBase(nullptr, SignalBase::MathChannel),
+       session_(session)
+{
+       shared_ptr<data::Analog> data(new data::Analog());
+       set_data(data);
+
+       shared_ptr<data::AnalogSegment> segment = make_shared<data::AnalogSegment>(
+               *data, data->get_segment_count(), session.get_samplerate());
+
+       data->push_segment(segment);
+}
+
+MathSignal::~MathSignal()
+{
+}
+
+void MathSignal::save_settings(QSettings &settings) const
+{
+       (void)settings;
+}
+
+void MathSignal::restore_settings(QSettings &settings)
+{
+       (void)settings;
+}
+
+} // namespace data
+} // namespace pv
diff --git a/pv/data/mathsignal.hpp b/pv/data/mathsignal.hpp
new file mode 100644 (file)
index 0000000..04380cd
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2020 Soeren Apel <soeren@apelpie.net>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PULSEVIEW_PV_DATA_MATHSIGNAL_HPP
+#define PULSEVIEW_PV_DATA_MATHSIGNAL_HPP
+
+#include <QSettings>
+#include <QString>
+
+#include <pv/data/analog.hpp>
+#include <pv/data/signalbase.hpp>
+#include <pv/util.hpp>
+
+using std::shared_ptr;
+
+namespace pv {
+class Session;
+
+namespace data {
+
+class SignalBase;
+class SignalData;
+
+class MathSignal : public SignalBase
+{
+       Q_OBJECT
+
+private:
+       static const int64_t ChunkLength;
+
+public:
+       MathSignal(pv::Session &session);
+       virtual ~MathSignal();
+
+       virtual void save_settings(QSettings &settings) const;
+       virtual void restore_settings(QSettings &settings);
+
+Q_SIGNALS:
+       void samples_cleared();
+
+       void samples_added(uint64_t segment_id, uint64_t start_sample,
+               uint64_t end_sample);
+
+       void min_max_changed(float min, float max);
+
+//private Q_SLOTS:
+//     void on_data_cleared();
+//     void on_data_received();
+
+//     void on_samples_added(SharedPtrToSegment segment, uint64_t start_sample,
+//             uint64_t end_sample);
+
+//     void on_min_max_changed(float min, float max);
+
+private:
+       pv::Session &session_;
+
+       QString error_message_;
+};
+
+} // namespace data
+} // namespace pv
+
+#endif // PULSEVIEW_PV_DATA_MATHSIGNAL_HPP
index 28ea0042227a6119890329208bdeedacc5277def..b35e14661373d88325eb4a28c1d73a580d587e4f 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <boost/algorithm/string/join.hpp>
 
+#include <pv/data/mathsignal.hpp>
 #include <pv/devicemanager.hpp>
 #include <pv/devices/hardwaredevice.hpp>
 #include <pv/devices/inputfile.hpp>
@@ -59,6 +60,7 @@ using std::back_inserter;
 using std::copy;
 using std::list;
 using std::make_pair;
+using std::make_shared;
 using std::map;
 using std::max;
 using std::min;
@@ -108,10 +110,11 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view
        sample_rate_("Hz", this),
        updating_sample_rate_(false),
        updating_sample_count_(false),
-       sample_count_supported_(false)
+       sample_count_supported_(false),
 #ifdef ENABLE_DECODE
-       , add_decoder_button_(new QToolButton())
+       add_decoder_button_(new QToolButton()),
 #endif
+       add_math_signal_button_(new QToolButton())
 {
        setObjectName(QString::fromUtf8("MainBar"));
 
@@ -240,6 +243,16 @@ MainBar::MainBar(Session &session, QWidget *parent, pv::views::trace::View *view
                this, SLOT(on_add_decoder_clicked()));
 #endif
 
+       // Setup the math signal button
+       add_math_signal_button_->setIcon(QIcon(":/icons/add-math-signal.svg"));
+       add_math_signal_button_->setPopupMode(QToolButton::InstantPopup);
+       add_math_signal_button_->setToolTip(tr("Add math signal"));
+       add_math_signal_button_->setShortcut(QKeySequence(Qt::Key_M));
+
+       connect(add_math_signal_button_, SIGNAL(clicked()),
+               this, SLOT(on_add_math_signal_clicked()));
+
+
        connect(&sample_count_, SIGNAL(value_changed()),
                this, SLOT(on_sample_count_changed()));
        connect(&sample_rate_, SIGNAL(value_changed()),
@@ -893,6 +906,12 @@ void MainBar::on_add_decoder_clicked()
        show_decoder_selector(&session_);
 }
 
+void MainBar::on_add_math_signal_clicked()
+{
+       shared_ptr<data::SignalBase> signal = make_shared<data::MathSignal>(session_);
+       session_.add_generated_signal(signal);
+}
+
 void MainBar::add_toolbar_widgets()
 {
        addWidget(new_view_button_);
@@ -912,6 +931,7 @@ void MainBar::add_toolbar_widgets()
        addSeparator();
        addWidget(add_decoder_button_);
 #endif
+       addWidget(add_math_signal_button_);
 }
 
 bool MainBar::eventFilter(QObject *watched, QEvent *event)
index eae43fa586a12aa9cebd1fcb52a68c24c6324147..e4aa39b6743f1a8484beaced925079269befe8c4 100644 (file)
@@ -145,6 +145,7 @@ private Q_SLOTS:
        void on_actionConnect_triggered();
 
        void on_add_decoder_clicked();
+       void on_add_math_signal_clicked();
 
 protected:
        void add_toolbar_widgets();
@@ -185,6 +186,8 @@ private:
 #ifdef ENABLE_DECODE
        QToolButton *add_decoder_button_;
 #endif
+
+       QToolButton *add_math_signal_button_;
 };
 
 } // namespace toolbars
index e2d9365efaf12d4c09a8a3df9b3891dd9ab38e94..a1a163b05aeb649b446a2e19596602fe3b7238dc 100644 (file)
@@ -365,6 +365,10 @@ void View::add_signalbase(const shared_ptr<data::SignalBase> signalbase)
                signal = shared_ptr<Signal>(new AnalogSignal(session_, signalbase));
                break;
 
+       case SignalBase::MathChannel:
+               signal = shared_ptr<Signal>(new AnalogSignal(session_, signalbase));
+               break;
+
        default:
                qDebug() << "Unknown signalbase type:" << signalbase->type();
                assert(false);
@@ -929,7 +933,7 @@ pair<Timestamp, Timestamp> View::get_time_extents() const
                return make_pair(0, 0);
 
        for (shared_ptr<Signal> s : signals_)
-               if (s->data()->segments().size() > 0)
+               if (s->data() && (s->data()->segments().size() > 0))
                        data.push_back(s->data());
 
        for (const shared_ptr<SignalData>& d : data) {
index 2b6cb87eacb05c12d4a7ec90a626b24a84cef280..79647a311cb352f13390322abfb018ca49bb1be5 100644 (file)
@@ -35,6 +35,7 @@ set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/data/analogsegment.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/logic.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/logicsegment.cpp
+       ${PROJECT_SOURCE_DIR}/pv/data/mathsignal.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/segment.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/signalbase.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/signaldata.cpp
@@ -116,6 +117,7 @@ set(pulseview_TEST_HEADERS
        ${PROJECT_SOURCE_DIR}/pv/data/analogsegment.hpp
        ${PROJECT_SOURCE_DIR}/pv/data/logic.hpp
        ${PROJECT_SOURCE_DIR}/pv/data/logicsegment.hpp
+       ${PROJECT_SOURCE_DIR}/pv/data/mathsignal.hpp
        ${PROJECT_SOURCE_DIR}/pv/data/signalbase.hpp
        ${PROJECT_SOURCE_DIR}/pv/devices/device.hpp
        ${PROJECT_SOURCE_DIR}/pv/dialogs/connect.hpp