PulseView  unreleased development snapshot
A Qt-based sigrok GUI
timemarker.hpp
Go to the documentation of this file.
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, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PULSEVIEW_PV_VIEWS_TRACE_TIMEMARKER_HPP
21 #define PULSEVIEW_PV_VIEWS_TRACE_TIMEMARKER_HPP
22 
23 #include <QColor>
24 #include <QDoubleSpinBox>
25 #include <QObject>
26 #include <QRectF>
27 #include <QWidgetAction>
28 
29 #include "timeitem.hpp"
30 
31 class QPainter;
32 class QRect;
33 
34 namespace pv {
35 namespace widgets {
36  class TimestampSpinBox;
37 }
38 
39 namespace views {
40 namespace trace {
41 
42 class View;
43 
48 class TimeMarker : public TimeItem
49 {
50  Q_OBJECT
51 
52 public:
53  static const int ArrowSize;
54 
55 protected:
62  TimeMarker(View &view, const QColor &color, const pv::util::Timestamp& time);
63 
64 public:
68  virtual const pv::util::Timestamp time() const override;
69 
73  void set_time(const pv::util::Timestamp& time) override;
74 
75  float get_x() const override;
76 
81  QPoint drag_point(const QRect &rect) const override;
82 
88  QRectF label_rect(const QRectF &rect) const override;
89 
95  QRectF hit_box_rect(const ViewItemPaintParams &pp) const override;
96 
100  virtual QString get_display_text() const;
101 
106  virtual QString get_text() const = 0;
107 
111  virtual void set_text(const QString &text);
112 
119  void paint_label(QPainter &p, const QRect &rect, bool hover) override;
120 
126  void paint_fore(QPainter &p, ViewItemPaintParams &pp) override;
127 
128  virtual pv::widgets::Popup* create_popup(QWidget *parent) override;
129 
130 private Q_SLOTS:
131  void on_popup_closed();
132 
133  void on_value_changed(const pv::util::Timestamp& value);
134 
135 protected:
136  const QColor &color_;
137 
139 
140  QSizeF text_size_;
141 
142  QWidgetAction *value_action_;
144 };
145 
146 } // namespace trace
147 } // namespace views
148 } // namespace pv
149 
150 #endif // PULSEVIEW_PV_VIEWS_TRACE_TIMEMARKER_HPP
pv::util::Timestamp time_
Definition: timemarker.hpp:138
T value(details::expression_node< T > *n)
Definition: exprtk.hpp:12358
QWidgetAction * value_action_
Definition: timemarker.hpp:142
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
Definition: util.hpp:67
static const int ArrowSize
Definition: timemarker.hpp:53
pv::widgets::TimestampSpinBox * value_widget_
Definition: timemarker.hpp:143