PulseView  0.3.0
A Qt-based sigrok GUI
triggermarker.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2014 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 #include "triggermarker.hpp"
22 #include "view.hpp"
23 
24 namespace pv {
25 namespace view {
26 
27 const QColor TriggerMarker::Colour(0x00, 0x00, 0xB0);
28 
30  TimeItem(view),
31  time_(time)
32 {
33 }
34 
36  TimeItem(marker.view_),
37  time_(marker.time_)
38 {
39 }
40 
42 {
43  return true;
44 }
45 
47 {
48  return false;
49 }
50 
52 {
53  time_ = time;
54 
56 }
57 
58 float TriggerMarker::get_x() const
59 {
60  return ((time_ - view_.offset()) / view_.scale()).convert_to<float>();
61 }
62 
63 QPoint TriggerMarker::point(const QRect &rect) const
64 {
65  return QPoint(get_x(), rect.bottom());
66 }
67 
68 void TriggerMarker::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
69 {
70  if (!enabled())
71  return;
72 
73  QPen pen(Colour);
74  pen.setStyle(Qt::DashLine);
75 
76  const float x = get_x();
77  p.setPen(pen);
78  p.drawLine(QPointF(x, pp.top()), QPointF(x, pp.bottom()));
79 }
80 
81 } // namespace view
82 } // namespace pv
TriggerMarker(View &view, const pv::util::Timestamp &time)
QPoint point(const QRect &rect) const override
void set_time(const pv::util::Timestamp &time) override
float get_x() const override
void time_item_appearance_changed(bool label, bool content)
Definition: view.cpp:855
void paint_fore(QPainter &p, const ViewItemPaintParams &pp) override
double scale() const
Definition: view.cpp:220
static const QColor Colour
pv::util::Timestamp time_
bool is_draggable() const override
const pv::util::Timestamp & offset() const
Definition: view.cpp:233
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.
Definition: util.hpp:58
bool enabled() const override