signal.h 2.7 KB
Newer Older
DreamSourceLab's avatar
DreamSourceLab committed
1
/*
DreamSourceLab's avatar
DreamSourceLab committed
2 3
 * This file is part of the DSView project.
 * DSView is based on PulseView.
DreamSourceLab's avatar
DreamSourceLab committed
4 5
 *
 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6
 * Copyright (C) 2013 DreamSourceLab <support@dreamsourcelab.com>
DreamSourceLab's avatar
DreamSourceLab committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * 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
 */


DreamSourceLab's avatar
DreamSourceLab committed
24 25
#ifndef DSVIEW_PV_SIGNAL_H
#define DSVIEW_PV_SIGNAL_H
DreamSourceLab's avatar
DreamSourceLab committed
26 27 28 29 30 31 32 33 34 35 36 37

#include <boost/shared_ptr.hpp>

#include <QColor>
#include <QPainter>
#include <QPen>
#include <QRect>
#include <QString>

#include <stdint.h>
#include <list>

DreamSourceLab's avatar
DreamSourceLab committed
38
#include <libsigrok4DSL/libsigrok.h>
DreamSourceLab's avatar
DreamSourceLab committed
39
#include "trace.h"
DreamSourceLab's avatar
DreamSourceLab committed
40 41 42 43 44 45 46

namespace pv {

namespace data {
class SignalData;
}

DreamSourceLab's avatar
DreamSourceLab committed
47 48
namespace device {
class DevInst;
DreamSourceLab's avatar
DreamSourceLab committed
49 50 51 52
}

namespace view {

DreamSourceLab's avatar
DreamSourceLab committed
53
class Signal : public Trace
DreamSourceLab's avatar
DreamSourceLab committed
54 55
{
private:
DreamSourceLab's avatar
v0.3  
DreamSourceLab committed
56

DreamSourceLab's avatar
DreamSourceLab committed
57 58

protected:
DreamSourceLab's avatar
DreamSourceLab committed
59
    Signal(boost::shared_ptr<pv::device::DevInst> dev_inst,
60
           sr_channel * const probe);
DreamSourceLab's avatar
DreamSourceLab committed
61

62 63 64
    /**
     * Copy constructor
     */
65
    Signal(const Signal &s, sr_channel * const probe);
66

DreamSourceLab's avatar
DreamSourceLab committed
67
public:
DreamSourceLab's avatar
DreamSourceLab committed
68
    virtual boost::shared_ptr<pv::data::SignalData> data() const = 0;
DreamSourceLab's avatar
DreamSourceLab committed
69 70

    /**
DreamSourceLab's avatar
DreamSourceLab committed
71
     * Returns true if the trace is visible and enabled.
DreamSourceLab's avatar
DreamSourceLab committed
72
     */
DreamSourceLab's avatar
DreamSourceLab committed
73
    bool enabled() const;
DreamSourceLab's avatar
DreamSourceLab committed
74

75 76 77 78 79
    /**
     * Sets the name of the signal.
     */
    void set_name(QString name);

DreamSourceLab's avatar
DreamSourceLab committed
80 81 82 83 84 85
	/**
	 * Paints the signal label into a QGLWidget.
	 * @param p the QPainter to paint into.
	 * @param right the x-coordinate of the right edge of the header
	 * 	area.
	 * @param hover true if the label is being hovered over by the mouse.
DreamSourceLab's avatar
DreamSourceLab committed
86
     * @param action mouse position for hover
DreamSourceLab's avatar
DreamSourceLab committed
87
	 */
DreamSourceLab's avatar
DreamSourceLab committed
88
    //virtual void paint_label(QPainter &p, int right, bool hover, int action);
DreamSourceLab's avatar
v0.3  
DreamSourceLab committed
89

90 91
    boost::shared_ptr<device::DevInst> get_device() const;

DreamSourceLab's avatar
DreamSourceLab committed
92 93 94 95 96 97 98 99 100 101 102 103
protected:

	/**
	 * Paints a zero axis across the viewport.
	 * @param p the QPainter to paint into.
	 * @param y the y-offset of the axis.
	 * @param left the x-coordinate of the left edge of the view.
	 * @param right the x-coordinate of the right edge of the view.
	 */
	void paint_axis(QPainter &p, int y, int left, int right);

protected:
DreamSourceLab's avatar
DreamSourceLab committed
104
    boost::shared_ptr<pv::device::DevInst> _dev_inst;
105
    sr_channel *const _probe;
DreamSourceLab's avatar
DreamSourceLab committed
106 107 108 109 110
};

} // namespace view
} // namespace pv

DreamSourceLab's avatar
DreamSourceLab committed
111
#endif // DSVIEW_PV_SIGNAL_H