]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/signal.hpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / views / trace / signal.hpp
index 83472818034a8592bd60108607f7ef19fd7e8f09..e10e93eac4d2863d200c530fbcb7ff4a07e72b7d 100644 (file)
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP
-#define PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP
+#ifndef PULSEVIEW_PV_VIEWS_TRACE_SIGNAL_HPP
+#define PULSEVIEW_PV_VIEWS_TRACE_SIGNAL_HPP
 
 #include <memory>
 
 #include <QComboBox>
+#include <QString>
+#include <QVariant>
 #include <QWidgetAction>
 
 #include <cstdint>
 
-#include "signalscalehandle.hpp"
+#include <pv/data/logicsegment.hpp>
+
 #include "trace.hpp"
 #include "viewitemowner.hpp"
 
@@ -45,12 +48,21 @@ class SignalData;
 namespace views {
 namespace trace {
 
+/**
+ * The Signal class represents a series of numeric values that can be drawn.
+ * This is the main difference to the more generic @ref Trace class.
+ *
+ * It is generally accepted that Signal instances consider themselves to be
+ * individual channels on e.g. an oscilloscope, though it should be kept in
+ * mind that virtual signals (e.g. math) will also be served by the Signal
+ * class.
+ */
 class Signal : public Trace, public ViewItemOwner
 {
        Q_OBJECT
 
 protected:
-       Signal(pv::Session &session, shared_ptr<data::SignalBase> channel);
+       Signal(pv::Session &session, shared_ptr<data::SignalBase> signal);
 
 public:
        /**
@@ -58,7 +70,14 @@ public:
         */
        virtual void set_name(QString name);
 
-       virtual shared_ptr<pv::data::SignalData> data() const = 0;
+       /**
+        * Determines the closest level change (i.e. edge) to a given sample, which
+        * is useful for e.g. the "snap to edge" functionality.
+        *
+        * @param sample_pos Sample to use
+        * @return The changes left and right of the given position
+        */
+       virtual vector<data::LogicSegment::EdgePair> get_nearest_level_changes(uint64_t sample_pos) = 0;
 
        /**
         * Returns true if the trace is visible and enabled.
@@ -68,38 +87,19 @@ public:
        shared_ptr<data::SignalBase> base() const;
 
        virtual void save_settings(QSettings &settings) const;
+       virtual std::map<QString, QVariant> save_settings() const;
 
        virtual void restore_settings(QSettings &settings);
-
-       /**
-        * Returns a list of row items owned by this object.
-        */
-       const item_list& child_items() const;
+       virtual void restore_settings(std::map<QString, QVariant> settings);
 
        void paint_back(QPainter &p, ViewItemPaintParams &pp);
 
        virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
 
-       QMenu* create_context_menu(QWidget *parent);
+       QMenu* create_header_context_menu(QWidget *parent);
 
        void delete_pressed();
 
-       /**
-        * Returns the offset to show the drag handle.
-        */
-       virtual int scale_handle_offset() const = 0;
-
-       /**
-        * Handles the scale handle being dragged to an offset.
-        * @param offset the offset the scale handle was dragged to.
-        */
-       virtual void scale_handle_dragged(int offset) = 0;
-
-       /**
-        * Handles the scale handle being being released.
-        */
-       virtual void scale_handle_released() {};
-
 protected Q_SLOTS:
        virtual void on_name_changed(const QString &text);
 
@@ -110,9 +110,6 @@ protected Q_SLOTS:
 protected:
        pv::Session &session_;
 
-       const shared_ptr<SignalScaleHandle> scale_handle_;
-       const item_list items_;
-
        QComboBox *name_widget_;
 };
 
@@ -120,4 +117,4 @@ protected:
 } // namespace views
 } // namespace pv
 
-#endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_SIGNAL_HPP
+#endif // PULSEVIEW_PV_VIEWS_TRACE_SIGNAL_HPP