PulseView  0.3.0
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, 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_MARKER_HPP
22 #define PULSEVIEW_PV_VIEW_MARKER_HPP
23 
24 #include <QColor>
25 #include <QDoubleSpinBox>
26 #include <QObject>
27 #include <QRectF>
28 #include <QWidgetAction>
29 
30 #include "timeitem.hpp"
31 
32 class QPainter;
33 class QRect;
34 
35 namespace pv {
36 namespace widgets {
37  class TimestampSpinBox;
38 }
39 
40 namespace view {
41 
42 class View;
43 
44 class TimeMarker : public TimeItem
45 {
46  Q_OBJECT
47 
48 public:
49  static const int ArrowSize;
50 
51 protected:
58  TimeMarker(View &view, const QColor &colour, const pv::util::Timestamp& time);
59 
60 public:
64  const pv::util::Timestamp& time() const;
65 
69  void set_time(const pv::util::Timestamp& time) override;
70 
71  float get_x() const;
72 
77  QPoint point(const QRect &rect) const;
78 
84  QRectF label_rect(const QRectF &rect) const;
85 
91  QRectF hit_box_rect(const ViewItemPaintParams &pp) const;
92 
96  virtual QString get_text() const = 0;
97 
104  void paint_label(QPainter &p, const QRect &rect, bool hover);
105 
111  void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
112 
113  virtual pv::widgets::Popup* create_popup(QWidget *parent);
114 
115 private Q_SLOTS:
116  void on_value_changed(const pv::util::Timestamp& value);
117 
118 protected:
119  const QColor &colour_;
120 
122 
123  QSizeF text_size_;
124 
125  QWidgetAction *value_action_;
128 };
129 
130 } // namespace view
131 } // namespace pv
132 
133 #endif // PULSEVIEW_PV_VIEW_MARKER_HPP
const QColor & colour_
Definition: timemarker.hpp:119
float get_x() const
Definition: timemarker.cpp:74
void paint_fore(QPainter &p, const ViewItemPaintParams &pp)
Definition: timemarker.cpp:156
void paint_label(QPainter &p, const QRect &rect, bool hover)
Definition: timemarker.cpp:105
virtual QString get_text() const =0
static const int ArrowSize
Definition: timemarker.hpp:49
virtual pv::widgets::Popup * create_popup(QWidget *parent)
Definition: timemarker.cpp:166
pv::widgets::TimestampSpinBox * value_widget_
Definition: timemarker.hpp:126
pv::util::Timestamp time_
Definition: timemarker.hpp:121
const pv::util::Timestamp & time() const
Definition: timemarker.cpp:56
QRectF label_rect(const QRectF &rect) const
Definition: timemarker.cpp:84
QPoint point(const QRect &rect) const
Definition: timemarker.cpp:79
QRectF hit_box_rect(const ViewItemPaintParams &pp) const
Definition: timemarker.cpp:98
TimeMarker(View &view, const QColor &colour, const pv::util::Timestamp &time)
Definition: timemarker.cpp:45
void set_time(const pv::util::Timestamp &time) override
Definition: timemarker.cpp:61
QWidgetAction * value_action_
Definition: timemarker.hpp:125
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
Definition: util.hpp:58
void on_value_changed(const pv::util::Timestamp &value)
Definition: timemarker.cpp:188