Skip to content

Commit

Permalink
TriggerMarker: Added trigger marker
Browse files Browse the repository at this point in the history
  • Loading branch information
jhol committed Dec 14, 2014
1 parent 3c9d6d4 commit 1b4dc4a
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ set(pulseview_SOURCES
pv/view/trace.cpp
pv/view/tracegroup.cpp
pv/view/tracepalette.cpp
pv/view/triggermarker.cpp
pv/view/view.cpp
pv/view/viewitem.cpp
pv/view/viewitempaintparams.cpp
Expand Down Expand Up @@ -226,6 +227,7 @@ set(pulseview_HEADERS
pv/view/timemarker.hpp
pv/view/trace.hpp
pv/view/tracegroup.hpp
pv/view/triggermarker.hpp
pv/view/view.hpp
pv/view/viewitem.hpp
pv/view/viewport.hpp
Expand Down
51 changes: 51 additions & 0 deletions pv/view/triggermarker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* This file is part of the PulseView project.
*
* Copyright (C) 2014 Joel Holdsworth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "triggermarker.hpp"
#include "view.hpp"

#include <QColor>

#include <libsigrok/libsigrok.hpp>

using std::shared_ptr;

namespace pv {
namespace view {

const QColor TriggerMarker::FillColour(0xED, 0xD4, 0x00);

TriggerMarker::TriggerMarker(View &view) :
TimeMarker(view, FillColour, 0.0)
{
}

bool TriggerMarker::enabled() const
{
return (bool)view_.session().session()->trigger();
}

QString TriggerMarker::get_text() const
{
return "T";
}

} // namespace view
} // namespace pv
57 changes: 57 additions & 0 deletions pv/view/triggermarker.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* This file is part of the PulseView project.
*
* Copyright (C) 2014 Joel Holdsworth <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef PULSEVIEW_PV_VIEW_TRIGGERMARKER_H
#define PULSEVIEW_PV_VIEW_TRIGGERMARKER_H

#include "timemarker.hpp"

namespace pv {
namespace view {

class TriggerMarker : public TimeMarker
{
Q_OBJECT

public:
static const QColor FillColour;

public:
/**
* Constructor.
* @param view A reference to the view that owns this cursor pair.
*/
TriggerMarker(View &view);

/**
* Returns true if the item is visible and enabled.
*/
bool enabled() const;

/**
* Gets the text to show in the marker.
*/
QString get_text() const;
};

} // namespace view
} // namespace pv

#endif // PULSEVIEW_PV_VIEW_TRIGGERMARKER_H
15 changes: 13 additions & 2 deletions pv/view/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ using pv::data::SignalData;
using pv::data::Segment;
using pv::util::format_time;

using std::back_inserter;
using std::copy;
using std::deque;
using std::dynamic_pointer_cast;
using std::list;
Expand Down Expand Up @@ -102,6 +104,7 @@ View::View(Session &session, QWidget *parent) :
updating_scroll_(false),
tick_period_(0.0),
tick_prefix_(0),
trigger_marker_(new TriggerMarker(*this)),
show_cursors_(false),
cursors_(new CursorPair(*this)),
next_flag_text_('A'),
Expand Down Expand Up @@ -193,7 +196,8 @@ const Viewport* View::viewport() const
vector< shared_ptr<TimeItem> > View::time_items() const
{
const vector<shared_ptr<Flag>> f(flags());
vector<shared_ptr<TimeItem>> items(f.begin(), f.end());
vector<shared_ptr<TimeItem>> items = {trigger_marker_};
copy(f.begin(), f.end(), back_inserter(items));
items.push_back(cursors_);
items.push_back(cursors_->first());
items.push_back(cursors_->second());
Expand Down Expand Up @@ -339,6 +343,11 @@ pair<double, double> View::get_time_extents() const
return make_pair(left_time, right_time);
}

shared_ptr<TriggerMarker> View::trigger_marker()
{
return trigger_marker_;
}

bool View::cursors_shown() const
{
return show_cursors_;
Expand Down Expand Up @@ -627,8 +636,10 @@ void View::row_item_appearance_changed(bool label, bool content)
{
if (label)
header_->update();
if (content)
if (content) {
viewport_->update();
cursorheader_->update();
}
}

void View::time_item_appearance_changed(bool label, bool content)
Expand Down
8 changes: 8 additions & 0 deletions pv/view/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "cursorpair.hpp"
#include "flag.hpp"
#include "rowitemowner.hpp"
#include "triggermarker.hpp"

namespace pv {

Expand Down Expand Up @@ -142,6 +143,11 @@ class View : public QAbstractScrollArea, public RowItemOwner {

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

/**
* Returns a reference to the trigger marker.
*/
std::shared_ptr<TriggerMarker> trigger_marker();

/**
* Returns true if cursors are displayed. false otherwise.
*/
Expand Down Expand Up @@ -281,6 +287,8 @@ private Q_SLOTS:
double tick_period_;
unsigned int tick_prefix_;

std::shared_ptr<TriggerMarker> trigger_marker_;

bool show_cursors_;
std::shared_ptr<CursorPair> cursors_;

Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(pulseview_TEST_SOURCES
${PROJECT_SOURCE_DIR}/pv/view/trace.cpp
${PROJECT_SOURCE_DIR}/pv/view/tracegroup.cpp
${PROJECT_SOURCE_DIR}/pv/view/tracepalette.cpp
${PROJECT_SOURCE_DIR}/pv/view/triggermarker.cpp
${PROJECT_SOURCE_DIR}/pv/view/view.cpp
${PROJECT_SOURCE_DIR}/pv/view/viewitem.cpp
${PROJECT_SOURCE_DIR}/pv/view/viewitempaintparams.cpp
Expand Down Expand Up @@ -96,6 +97,7 @@ set(pulseview_TEST_HEADERS
${PROJECT_SOURCE_DIR}/pv/view/timemarker.hpp
${PROJECT_SOURCE_DIR}/pv/view/trace.hpp
${PROJECT_SOURCE_DIR}/pv/view/tracegroup.hpp
${PROJECT_SOURCE_DIR}/pv/view/triggermarker.hpp
${PROJECT_SOURCE_DIR}/pv/view/view.hpp
${PROJECT_SOURCE_DIR}/pv/view/viewitem.hpp
${PROJECT_SOURCE_DIR}/pv/view/viewport.hpp
Expand Down

0 comments on commit 1b4dc4a

Please sign in to comment.