Skip to content

Commit

Permalink
WIP: Flag: Added time marker flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jhol committed Nov 30, 2014
1 parent 3e3da13 commit 089071a
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ set(pulseview_SOURCES
pv/view/cursor.cpp
pv/view/cursorheader.cpp
pv/view/cursorpair.cpp
pv/view/flag.cpp
pv/view/header.cpp
pv/view/marginwidget.cpp
pv/view/logicsignal.cpp
Expand Down Expand Up @@ -212,6 +213,7 @@ set(pulseview_HEADERS
pv/toolbars/samplingbar.hpp
pv/view/cursor.hpp
pv/view/cursorheader.hpp
pv/view/flag.hpp
pv/view/header.hpp
pv/view/logicsignal.hpp
pv/view/marginwidget.hpp
Expand Down
10 changes: 10 additions & 0 deletions pv/view/cursorheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ void CursorHeader::paintEvent(QPaintEvent*)
// Draw the trigger marker
view_.trigger_marker().paint_label(p, r);

// Draw the flags
std::vector<Flag> flags(view_.flags());
for (Flag &f : flags)
f.paint_label(p, r);

// Draw the cursors
if (view_.cursors_shown())
view_.cursors().draw_markers(p, r);
Expand Down Expand Up @@ -141,5 +146,10 @@ void CursorHeader::mouseReleaseEvent(QMouseEvent *)
grabbed_marker_.reset();
}

void CursorHeader::mouseDoubleClickEvent(QMouseEvent *e)
{
view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
}

} // namespace view
} // namespace pv
2 changes: 2 additions & 0 deletions pv/view/cursorheader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class CursorHeader : public MarginWidget
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *);

void mouseDoubleClickEvent(QMouseEvent *e);

int calculateTextHeight();

std::weak_ptr<TimeMarker> grabbed_marker_;
Expand Down
51 changes: 51 additions & 0 deletions pv/view/flag.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 Flag::FillColour(0x73, 0xD2, 0x16);

Flag::Flag(View &view, double time) :
TimeMarker(view, FillColour, time)
{
}

Flag::Flag(const Flag &flag) :
TimeMarker(flag.view_, FillColour, flag.time_)
{
}

QString Flag::get_text() const
{
return "";
}

} // namespace view
} // namespace pv
11 changes: 11 additions & 0 deletions pv/view/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,17 @@ const CursorPair& View::cursors() const
return cursors_;
}

void View::add_flag(double time)
{
flags_.push_back(Flag(*this, time));
appearance_changed(false, true);
}

const std::vector<Flag>& View::flags() const
{
return flags_;
}

const QPoint& View::hover_point() const
{
return hover_point_;
Expand Down
13 changes: 13 additions & 0 deletions pv/view/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <pv/data/signaldata.hpp>

#include "cursorpair.hpp"
#include "flag.hpp"
#include "rowitemowner.hpp"
#include "triggermarker.hpp"

Expand Down Expand Up @@ -167,6 +168,16 @@ class View : public QAbstractScrollArea, public RowItemOwner {
*/
const CursorPair& cursors() const;

/**
* Adds a new flag at a specified time.
*/
void add_flag(double time);

/**
* Gets the list of flags.
*/
const std::vector<Flag>& flags() const;

const QPoint& hover_point() const;

void update_viewport();
Expand Down Expand Up @@ -284,6 +295,8 @@ private Q_SLOTS:
bool show_cursors_;
CursorPair cursors_;

std::vector<Flag> flags_;

QPoint hover_point_;

unsigned int sticky_events_;
Expand Down

0 comments on commit 089071a

Please sign in to comment.