]>
Commit | Line | Data |
---|---|---|
28a4c9c5 | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
28a4c9c5 JH |
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 | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
28a4c9c5 JH |
18 | */ |
19 | ||
f4e57597 SA |
20 | #ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP |
21 | #define PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP | |
640d091b | 22 | |
0f1f98fe JH |
23 | #include <QCache> |
24 | ||
2acdb232 | 25 | #include "signal.hpp" |
28a4c9c5 | 26 | |
f9abf97e | 27 | #include <memory> |
28a4c9c5 | 28 | |
6f925ba9 UH |
29 | using std::pair; |
30 | using std::shared_ptr; | |
31 | using std::vector; | |
32 | ||
0f1f98fe | 33 | class QIcon; |
767281c8 JH |
34 | class QToolBar; |
35 | ||
e8d00928 | 36 | namespace sigrok { |
da5e6727 | 37 | class TriggerMatchType; |
e8d00928 ML |
38 | } |
39 | ||
51e77110 JH |
40 | namespace pv { |
41 | ||
da30ecb7 JH |
42 | namespace devices { |
43 | class Device; | |
44 | } | |
45 | ||
1b1ec774 JH |
46 | namespace data { |
47 | class Logic; | |
48 | } | |
28a4c9c5 | 49 | |
f4e57597 SA |
50 | namespace views { |
51 | namespace TraceView { | |
8d634081 | 52 | |
28a4c9c5 JH |
53 | class LogicSignal : public Signal |
54 | { | |
b08d7222 JH |
55 | Q_OBJECT |
56 | ||
a8fd2759 | 57 | public: |
17d94d7c | 58 | static const float Oversampling; |
131e8012 | 59 | |
64b60583 JH |
60 | static const QColor EdgeColour; |
61 | static const QColor HighColour; | |
62 | static const QColor LowColour; | |
e9c8e87c | 63 | static const QColor SamplingPointColour; |
131e8012 | 64 | |
299d0e75 | 65 | static const QColor SignalColours[10]; |
3e46726a | 66 | |
ddfda54d JH |
67 | static QColor TriggerMarkerBackgroundColour; |
68 | static const int TriggerMarkerPadding; | |
69 | static const char* TriggerMarkerIcons[8]; | |
70 | ||
2b81ae46 | 71 | LogicSignal(pv::Session &session, |
6f925ba9 UH |
72 | shared_ptr<devices::Device> device, |
73 | shared_ptr<data::SignalBase> base); | |
28a4c9c5 | 74 | |
c6246dc5 | 75 | virtual ~LogicSignal() = default; |
f459c540 | 76 | |
6f925ba9 | 77 | shared_ptr<pv::data::SignalData> data() const; |
9a0cd293 | 78 | |
6f925ba9 | 79 | shared_ptr<pv::data::Logic> logic_data() const; |
e0fc5810 | 80 | |
a5d93c27 JH |
81 | /** |
82 | * Computes the vertical extents of the contents of this row item. | |
83 | * @return A pair containing the minimum and maximum y-values. | |
84 | */ | |
6f925ba9 | 85 | pair<int, int> v_extents() const; |
a5d93c27 | 86 | |
214470fc JH |
87 | /** |
88 | * Returns the offset to show the drag handle. | |
89 | */ | |
90 | int scale_handle_offset() const; | |
91 | ||
92 | /** | |
93 | * Handles the scale handle being dragged to an offset. | |
94 | * @param offset the offset the scale handle was dragged to. | |
95 | */ | |
96 | void scale_handle_dragged(int offset); | |
97 | ||
fe08b6e8 JH |
98 | /** |
99 | * Paints the mid-layer of the signal with a QPainter | |
100 | * @param p the QPainter to paint into. | |
3eb29afd | 101 | * @param pp the painting parameters object to paint with.. |
223d0c37 | 102 | */ |
60938e04 | 103 | void paint_mid(QPainter &p, ViewItemPaintParams &pp); |
e3f65ace | 104 | |
ddfda54d JH |
105 | /** |
106 | * Paints the foreground layer of the signal with a QPainter | |
107 | * @param p the QPainter to paint into. | |
3eb29afd | 108 | * @param pp the painting parameters object to paint with. |
223d0c37 | 109 | */ |
60938e04 | 110 | virtual void paint_fore(QPainter &p, ViewItemPaintParams &pp); |
ddfda54d | 111 | |
2858b391 | 112 | private: |
f4270878 | 113 | void paint_caps(QPainter &p, QLineF *const lines, |
6f925ba9 | 114 | vector< pair<int64_t, bool> > &edges, |
131e8012 | 115 | bool level, double samples_per_pixel, double pixels_offset, |
ce6e73a8 | 116 | float x_offset, float y_offset); |
131e8012 | 117 | |
767281c8 JH |
118 | void init_trigger_actions(QWidget *parent); |
119 | ||
6f925ba9 | 120 | const vector<int32_t> get_trigger_types() const; |
c063290a | 121 | QAction* action_from_trigger_type(const sigrok::TriggerMatchType *type); |
aa5e9140 JH |
122 | const sigrok::TriggerMatchType* trigger_type_from_action( |
123 | QAction *action); | |
767281c8 | 124 | void populate_popup_form(QWidget *parent, QFormLayout *form); |
640bd149 | 125 | void modify_trigger(); |
b08d7222 | 126 | |
0f1f98fe | 127 | static const QIcon* get_icon(const char *path); |
ddfda54d | 128 | static const QPixmap* get_pixmap(const char *path); |
0f1f98fe | 129 | |
e9213170 | 130 | private Q_SLOTS: |
b1e8c93d | 131 | void on_trigger(); |
b08d7222 | 132 | |
28a4c9c5 | 133 | private: |
303d6ea6 JH |
134 | int signal_height_; |
135 | ||
6f925ba9 | 136 | shared_ptr<pv::devices::Device> device_; |
8dbbc7f0 JH |
137 | |
138 | const sigrok::TriggerMatchType *trigger_match_; | |
139 | QToolBar *trigger_bar_; | |
140 | QAction *trigger_none_; | |
141 | QAction *trigger_rising_; | |
142 | QAction *trigger_high_; | |
143 | QAction *trigger_falling_; | |
144 | QAction *trigger_low_; | |
145 | QAction *trigger_change_; | |
0f1f98fe JH |
146 | |
147 | static QCache<QString, const QIcon> icon_cache_; | |
ddfda54d | 148 | static QCache<QString, const QPixmap> pixmap_cache_; |
28a4c9c5 | 149 | }; |
51e77110 | 150 | |
f4e57597 SA |
151 | } // namespace TraceView |
152 | } // namespace views | |
51e77110 | 153 | } // namespace pv |
640d091b | 154 | |
f4e57597 | 155 | #endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_LOGICSIGNAL_HPP |