PulseView  0.3.0
A Qt-based sigrok GUI
cursorpair.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2013 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_CURSORPAIR_HPP
22 #define PULSEVIEW_PV_VIEW_CURSORPAIR_HPP
23 
24 #include "cursor.hpp"
25 
26 #include <memory>
27 
28 #include <QPainter>
29 
30 class QPainter;
31 
32 namespace pv {
33 namespace view {
34 
35 class CursorPair : public TimeItem
36 {
37 private:
38  static const int DeltaPadding;
39  static const QColor ViewportFillColour;
40 
41 public:
46  CursorPair(View &view);
47 
48 public:
52  bool enabled() const;
53 
57  std::shared_ptr<Cursor> first() const;
58 
62  std::shared_ptr<Cursor> second() const;
63 
67  void set_time(const pv::util::Timestamp& time) override;
68 
69  float get_x() const;
70 
71  QPoint point(const QRect &rect) const;
72 
73  pv::widgets::Popup* create_popup(QWidget *parent);
74 
75 public:
76  QRectF label_rect(const QRectF &rect) const;
77 
84  void paint_label(QPainter &p, const QRect &rect, bool hover);
85 
91  void paint_back(QPainter &p, const ViewItemPaintParams &pp);
92 
96  QString format_string();
97 
98  void compute_text_size(QPainter &p);
99 
100  std::pair<float, float> get_cursor_offsets() const;
101 
102 private:
103  std::shared_ptr<Cursor> first_, second_;
104 
105  QSizeF text_size_;
106 };
107 
108 } // namespace view
109 } // namespace pv
110 
111 #endif // PULSEVIEW_PV_VIEW_CURSORPAIR_HPP
void paint_back(QPainter &p, const ViewItemPaintParams &pp)
Definition: cursorpair.cpp:147
std::pair< float, float > get_cursor_offsets() const
Definition: cursorpair.cpp:185
CursorPair(View &view)
Definition: cursorpair.cpp:42
std::shared_ptr< Cursor > first() const
Definition: cursorpair.cpp:54
static const QColor ViewportFillColour
Definition: cursorpair.hpp:39
void paint_label(QPainter &p, const QRect &rect, bool hover)
Definition: cursorpair.cpp:105
std::shared_ptr< Cursor > second() const
Definition: cursorpair.cpp:59
float get_x() const
Definition: cursorpair.cpp:71
bool enabled() const
Definition: cursorpair.cpp:49
static const int DeltaPadding
Definition: cursorpair.hpp:38
void compute_text_size(QPainter &p)
Definition: cursorpair.cpp:177
pv::widgets::Popup * create_popup(QWidget *parent)
Definition: cursorpair.cpp:81
void set_time(const pv::util::Timestamp &time) override
Definition: cursorpair.cpp:64
QPoint point(const QRect &rect) const
Definition: cursorpair.cpp:76
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
Definition: util.hpp:58
std::shared_ptr< Cursor > first_
Definition: cursorpair.hpp:103
std::shared_ptr< Cursor > second_
Definition: cursorpair.hpp:103
QRectF label_rect(const QRectF &rect) const
Definition: cursorpair.cpp:87