]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #ifndef PULSEVIEW_PV_VIEW_LOGICSIGNAL_H | |
22 | #define PULSEVIEW_PV_VIEW_LOGICSIGNAL_H | |
23 | ||
24 | #include "signal.hpp" | |
25 | ||
26 | #include <memory> | |
27 | ||
28 | class QToolBar; | |
29 | ||
30 | namespace sigrok { | |
31 | class Device; | |
32 | class TriggerMatchType; | |
33 | } | |
34 | ||
35 | namespace pv { | |
36 | ||
37 | namespace data { | |
38 | class Logic; | |
39 | } | |
40 | ||
41 | namespace view { | |
42 | ||
43 | class LogicSignal : public Signal | |
44 | { | |
45 | Q_OBJECT | |
46 | ||
47 | private: | |
48 | static const int SignalHeight; | |
49 | static const int SignalMargin; | |
50 | ||
51 | static const float Oversampling; | |
52 | ||
53 | static const QColor EdgeColour; | |
54 | static const QColor HighColour; | |
55 | static const QColor LowColour; | |
56 | ||
57 | static const QColor SignalColours[10]; | |
58 | ||
59 | public: | |
60 | LogicSignal(pv::Session &session, | |
61 | std::shared_ptr<sigrok::Device> device, | |
62 | std::shared_ptr<sigrok::Channel> channel, | |
63 | std::shared_ptr<pv::data::Logic> data); | |
64 | ||
65 | virtual ~LogicSignal(); | |
66 | ||
67 | std::shared_ptr<pv::data::SignalData> data() const; | |
68 | ||
69 | std::shared_ptr<pv::data::Logic> logic_data() const; | |
70 | ||
71 | /** | |
72 | * Computes the vertical extents of the contents of this row item. | |
73 | * @return A pair containing the minimum and maximum y-values. | |
74 | */ | |
75 | std::pair<int, int> v_extents() const; | |
76 | ||
77 | /** | |
78 | * Paints the background layer of the signal with a QPainter | |
79 | * @param p the QPainter to paint into. | |
80 | * @param left the x-coordinate of the left edge of the signal. | |
81 | * @param right the x-coordinate of the right edge of the signal. | |
82 | **/ | |
83 | void paint_back(QPainter &p, int left, int right); | |
84 | ||
85 | /** | |
86 | * Paints the mid-layer of the signal with a QPainter | |
87 | * @param p the QPainter to paint into. | |
88 | * @param left the x-coordinate of the left edge of the signal. | |
89 | * @param right the x-coordinate of the right edge of the signal. | |
90 | **/ | |
91 | void paint_mid(QPainter &p, int left, int right); | |
92 | ||
93 | private: | |
94 | void paint_caps(QPainter &p, QLineF *const lines, | |
95 | std::vector< std::pair<int64_t, bool> > &edges, | |
96 | bool level, double samples_per_pixel, double pixels_offset, | |
97 | float x_offset, float y_offset); | |
98 | ||
99 | void init_trigger_actions(QWidget *parent); | |
100 | ||
101 | QAction* match_action(const sigrok::TriggerMatchType *match); | |
102 | const sigrok::TriggerMatchType *action_match(QAction *action); | |
103 | void populate_popup_form(QWidget *parent, QFormLayout *form); | |
104 | void modify_trigger(); | |
105 | ||
106 | private Q_SLOTS: | |
107 | void on_trigger(); | |
108 | ||
109 | private: | |
110 | std::shared_ptr<sigrok::Device> device_; | |
111 | std::shared_ptr<pv::data::Logic> data_; | |
112 | ||
113 | const sigrok::TriggerMatchType *trigger_match_; | |
114 | QToolBar *trigger_bar_; | |
115 | QAction *trigger_none_; | |
116 | QAction *trigger_rising_; | |
117 | QAction *trigger_high_; | |
118 | QAction *trigger_falling_; | |
119 | QAction *trigger_low_; | |
120 | QAction *trigger_change_; | |
121 | }; | |
122 | ||
123 | } // namespace view | |
124 | } // namespace pv | |
125 | ||
126 | #endif // PULSEVIEW_PV_VIEW_LOGICSIGNAL_H |