logicsignal.h 3.32 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 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
 * Copyright (C) 2013 DreamSourceLab <dreamsourcelab@dreamsourcelab.com>
 *
 * 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_LOGICSIGNAL_H
#define DSVIEW_PV_LOGICSIGNAL_H
DreamSourceLab's avatar
DreamSourceLab committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

#include "signal.h"

#include <vector>

#include <boost/shared_ptr.hpp>

namespace pv {

namespace data {
class Logic;
class Analog;
}

namespace view {

class LogicSignal : public Signal
{
private:
	static const float Oversampling;

	static const QColor EdgeColour;
	static const QColor HighColour;
	static const QColor LowColour;

    static const QColor SignalColours[8];

    static const int StateHeight;
    static const int StateRound;

56
    enum LogicSetRegions{
57
        NONTRIG = 0,
58 59 60 61 62 63 64
        POSTRIG,
        HIGTRIG,
        NEGTRIG,
        LOWTRIG,
        EDGTRIG,
    };

DreamSourceLab's avatar
DreamSourceLab committed
65
public:
DreamSourceLab's avatar
DreamSourceLab committed
66 67 68
    LogicSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
                boost::shared_ptr<pv::data::Logic> data,
                const sr_channel * const probe);
DreamSourceLab's avatar
DreamSourceLab committed
69

70
    LogicSignal(boost::shared_ptr<view::LogicSignal> s,
71 72 73
                boost::shared_ptr<pv::data::Logic> data,
                const sr_channel * const probe);

DreamSourceLab's avatar
DreamSourceLab committed
74 75
	virtual ~LogicSignal();

DreamSourceLab's avatar
DreamSourceLab committed
76 77 78 79 80 81
    const sr_channel* probe() const;

    boost::shared_ptr<pv::data::SignalData> data() const;

    boost::shared_ptr<pv::data::Logic> logic_data() const;

82 83 84 85 86
    /**
     *
     */
    LogicSetRegions get_trig() const;
    void set_trig(int trig);
87
    void commit_trig();
88

DreamSourceLab's avatar
DreamSourceLab committed
89 90 91 92 93 94
	/**
	 * Paints the signal with a QPainter
	 * @param p the QPainter to paint into.
	 * @param left the x-coordinate of the left edge of the signal.
	 * @param right the x-coordinate of the right edge of the signal.
	 **/
DreamSourceLab's avatar
DreamSourceLab committed
95
    void paint_mid(QPainter &p, int left, int right);
DreamSourceLab's avatar
DreamSourceLab committed
96 97 98

    const std::vector< std::pair<uint64_t, bool> > cur_edges() const;

99 100
    bool measure(const QPointF &p, uint64_t &index0, uint64_t &index1, uint64_t &index2) const;

101 102
    bool edges(const QPointF &p, uint64_t start, uint64_t &rising, uint64_t &falling) const;

103 104 105 106
    bool mouse_press(int right, const QPoint pt);

    QRectF get_rect(LogicSetRegions type, int y, int right);

DreamSourceLab's avatar
DreamSourceLab committed
107
protected:
108
    void paint_type_options(QPainter &p, int right, const QPoint pt);
DreamSourceLab's avatar
DreamSourceLab committed
109 110 111 112 113 114 115 116 117 118 119

private:

	void paint_caps(QPainter &p, QLineF *const lines,
        std::vector< std::pair<uint64_t, bool> > &edges,
		bool level, double samples_per_pixel, double pixels_offset,
		float x_offset, float y_offset);

private:
	boost::shared_ptr<pv::data::Logic> _data;
    std::vector< std::pair<uint64_t, bool> > _cur_edges;
120
    LogicSetRegions _trig;
DreamSourceLab's avatar
DreamSourceLab committed
121 122 123 124 125
};

} // namespace view
} // namespace pv

DreamSourceLab's avatar
DreamSourceLab committed
126
#endif // DSVIEW_PV_LOGICSIGNAL_H