Skip to content

Commit 1b4dc4a

Browse files
committed
TriggerMarker: Added trigger marker
1 parent 3c9d6d4 commit 1b4dc4a

6 files changed

Lines changed: 133 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ set(pulseview_SOURCES
183183
pv/view/trace.cpp
184184
pv/view/tracegroup.cpp
185185
pv/view/tracepalette.cpp
186+
pv/view/triggermarker.cpp
186187
pv/view/view.cpp
187188
pv/view/viewitem.cpp
188189
pv/view/viewitempaintparams.cpp
@@ -226,6 +227,7 @@ set(pulseview_HEADERS
226227
pv/view/timemarker.hpp
227228
pv/view/trace.hpp
228229
pv/view/tracegroup.hpp
230+
pv/view/triggermarker.hpp
229231
pv/view/view.hpp
230232
pv/view/viewitem.hpp
231233
pv/view/viewport.hpp

pv/view/triggermarker.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
#include <QColor>
25+
26+
#include <libsigrok/libsigrok.hpp>
27+
28+
using std::shared_ptr;
29+
30+
namespace pv {
31+
namespace view {
32+
33+
const QColor TriggerMarker::FillColour(0xED, 0xD4, 0x00);
34+
35+
TriggerMarker::TriggerMarker(View &view) :
36+
TimeMarker(view, FillColour, 0.0)
37+
{
38+
}
39+
40+
bool TriggerMarker::enabled() const
41+
{
42+
return (bool)view_.session().session()->trigger();
43+
}
44+
45+
QString TriggerMarker::get_text() const
46+
{
47+
return "T";
48+
}
49+
50+
} // namespace view
51+
} // namespace pv

pv/view/triggermarker.hpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
#ifndef PULSEVIEW_PV_VIEW_TRIGGERMARKER_H
22+
#define PULSEVIEW_PV_VIEW_TRIGGERMARKER_H
23+
24+
#include "timemarker.hpp"
25+
26+
namespace pv {
27+
namespace view {
28+
29+
class TriggerMarker : public TimeMarker
30+
{
31+
Q_OBJECT
32+
33+
public:
34+
static const QColor FillColour;
35+
36+
public:
37+
/**
38+
* Constructor.
39+
* @param view A reference to the view that owns this cursor pair.
40+
*/
41+
TriggerMarker(View &view);
42+
43+
/**
44+
* Returns true if the item is visible and enabled.
45+
*/
46+
bool enabled() const;
47+
48+
/**
49+
* Gets the text to show in the marker.
50+
*/
51+
QString get_text() const;
52+
};
53+
54+
} // namespace view
55+
} // namespace pv
56+
57+
#endif // PULSEVIEW_PV_VIEW_TRIGGERMARKER_H

pv/view/view.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ using pv::data::SignalData;
6060
using pv::data::Segment;
6161
using pv::util::format_time;
6262

63+
using std::back_inserter;
64+
using std::copy;
6365
using std::deque;
6466
using std::dynamic_pointer_cast;
6567
using std::list;
@@ -102,6 +104,7 @@ View::View(Session &session, QWidget *parent) :
102104
updating_scroll_(false),
103105
tick_period_(0.0),
104106
tick_prefix_(0),
107+
trigger_marker_(new TriggerMarker(*this)),
105108
show_cursors_(false),
106109
cursors_(new CursorPair(*this)),
107110
next_flag_text_('A'),
@@ -193,7 +196,8 @@ const Viewport* View::viewport() const
193196
vector< shared_ptr<TimeItem> > View::time_items() const
194197
{
195198
const vector<shared_ptr<Flag>> f(flags());
196-
vector<shared_ptr<TimeItem>> items(f.begin(), f.end());
199+
vector<shared_ptr<TimeItem>> items = {trigger_marker_};
200+
copy(f.begin(), f.end(), back_inserter(items));
197201
items.push_back(cursors_);
198202
items.push_back(cursors_->first());
199203
items.push_back(cursors_->second());
@@ -339,6 +343,11 @@ pair<double, double> View::get_time_extents() const
339343
return make_pair(left_time, right_time);
340344
}
341345

346+
shared_ptr<TriggerMarker> View::trigger_marker()
347+
{
348+
return trigger_marker_;
349+
}
350+
342351
bool View::cursors_shown() const
343352
{
344353
return show_cursors_;
@@ -627,8 +636,10 @@ void View::row_item_appearance_changed(bool label, bool content)
627636
{
628637
if (label)
629638
header_->update();
630-
if (content)
639+
if (content) {
631640
viewport_->update();
641+
cursorheader_->update();
642+
}
632643
}
633644

634645
void View::time_item_appearance_changed(bool label, bool content)

pv/view/view.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "cursorpair.hpp"
3838
#include "flag.hpp"
3939
#include "rowitemowner.hpp"
40+
#include "triggermarker.hpp"
4041

4142
namespace pv {
4243

@@ -142,6 +143,11 @@ class View : public QAbstractScrollArea, public RowItemOwner {
142143

143144
std::pair<double, double> get_time_extents() const;
144145

146+
/**
147+
* Returns a reference to the trigger marker.
148+
*/
149+
std::shared_ptr<TriggerMarker> trigger_marker();
150+
145151
/**
146152
* Returns true if cursors are displayed. false otherwise.
147153
*/
@@ -281,6 +287,8 @@ private Q_SLOTS:
281287
double tick_period_;
282288
unsigned int tick_prefix_;
283289

290+
std::shared_ptr<TriggerMarker> trigger_marker_;
291+
284292
bool show_cursors_;
285293
std::shared_ptr<CursorPair> cursors_;
286294

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ set(pulseview_TEST_SOURCES
5555
${PROJECT_SOURCE_DIR}/pv/view/trace.cpp
5656
${PROJECT_SOURCE_DIR}/pv/view/tracegroup.cpp
5757
${PROJECT_SOURCE_DIR}/pv/view/tracepalette.cpp
58+
${PROJECT_SOURCE_DIR}/pv/view/triggermarker.cpp
5859
${PROJECT_SOURCE_DIR}/pv/view/view.cpp
5960
${PROJECT_SOURCE_DIR}/pv/view/viewitem.cpp
6061
${PROJECT_SOURCE_DIR}/pv/view/viewitempaintparams.cpp
@@ -96,6 +97,7 @@ set(pulseview_TEST_HEADERS
9697
${PROJECT_SOURCE_DIR}/pv/view/timemarker.hpp
9798
${PROJECT_SOURCE_DIR}/pv/view/trace.hpp
9899
${PROJECT_SOURCE_DIR}/pv/view/tracegroup.hpp
100+
${PROJECT_SOURCE_DIR}/pv/view/triggermarker.hpp
99101
${PROJECT_SOURCE_DIR}/pv/view/view.hpp
100102
${PROJECT_SOURCE_DIR}/pv/view/viewitem.hpp
101103
${PROJECT_SOURCE_DIR}/pv/view/viewport.hpp

0 commit comments

Comments
 (0)