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
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
update();
}
+void CursorHeader::mouseDoubleClickEvent(QMouseEvent *e)
+{
+ view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
+}
+
} // namespace view
} // namespace pv
void mouseReleaseEvent(QMouseEvent *);
void leaveEvent(QEvent*);
+ void mouseDoubleClickEvent(QMouseEvent *e);
+
int calculateTextHeight();
std::shared_ptr<TimeItem> mouse_down_item_;
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * 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 "timemarker.hpp"
+#include "view.hpp"
+
+#include <QColor>
+#include <QFormLayout>
+#include <QLineEdit>
+
+#include <libsigrok/libsigrok.hpp>
+
+#include <pv/widgets/popup.hpp>
+
+using std::shared_ptr;
+
+namespace pv {
+namespace view {
+
+const QColor Flag::FillColour(0x73, 0xD2, 0x16);
+
+Flag::Flag(View &view, double time, const QString &text) :
+ TimeMarker(view, FillColour, time),
+ text_(text)
+{
+}
+
+Flag::Flag(const Flag &flag) :
+ TimeMarker(flag.view_, FillColour, flag.time_)
+{
+}
+
+bool Flag::enabled() const
+{
+ return true;
+}
+
+QString Flag::get_text() const
+{
+ return text_;
+}
+
+pv::widgets::Popup* Flag::create_popup(QWidget *parent)
+{
+ pv::widgets::Popup *const popup = TimeMarker::create_popup(parent);
+ QFormLayout *const form = (QFormLayout*)popup->layout();
+
+ QLineEdit *const text_edit = new QLineEdit(popup);
+ text_edit->setText(text_);
+
+ connect(text_edit, SIGNAL(textChanged(const QString&)),
+ this, SLOT(on_text_changed(const QString&)));
+
+ form->insertRow(0, tr("Text"), text_edit);
+
+ return popup;
+}
+
+void Flag::on_text_changed(const QString &text)
+{
+ text_ = text;
+ view_.time_item_appearance_changed(true, false);
+}
+
+} // namespace view
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * 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_FLAG_H
+#define PULSEVIEW_PV_VIEW_FLAG_H
+
+#include "timemarker.hpp"
+
+namespace pv {
+namespace view {
+
+class Flag : public TimeMarker
+{
+ Q_OBJECT
+
+public:
+ static const QColor FillColour;
+
+public:
+ /**
+ * Constructor.
+ * @param view A reference to the view that owns this cursor pair.
+ * @param time The time to set the flag to.
+ * @param text The text of the marker.
+ */
+ Flag(View &view, double time, const QString &text);
+
+ /**
+ * Copy constructor.
+ */
+ Flag(const Flag &flag);
+
+ /**
+ * Returns true if the item is visible and enabled.
+ */
+ bool enabled() const;
+
+ /**
+ * Gets the text to show in the marker.
+ */
+ QString get_text() const;
+
+ pv::widgets::Popup* create_popup(QWidget *parent);
+
+private Q_SLOTS:
+ void on_text_changed(const QString &text);
+
+private:
+ QString text_;
+};
+
+} // namespace view
+} // namespace pv
+
+#endif // PULSEVIEW_PV_VIEW_FLAG_H
**/
void paint_fore(QPainter &p, const ViewItemPaintParams &pp);
- pv::widgets::Popup* create_popup(QWidget *parent);
+ virtual pv::widgets::Popup* create_popup(QWidget *parent);
private Q_SLOTS:
void on_value_changed(double value);
using pv::data::Segment;
using pv::util::format_time;
-using std::back_inserter;
using std::deque;
using std::dynamic_pointer_cast;
using std::list;
tick_prefix_(0),
show_cursors_(false),
cursors_(new CursorPair(*this)),
+ next_flag_text_('A'),
hover_point_(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
vector< shared_ptr<TimeItem> > View::time_items() const
{
- vector< shared_ptr<TimeItem> > items;
+ const vector<shared_ptr<Flag>> f(flags());
+ vector<shared_ptr<TimeItem>> items(f.begin(), f.end());
items.push_back(cursors_);
items.push_back(cursors_->first());
items.push_back(cursors_->second());
return cursors_;
}
+void View::add_flag(double time)
+{
+ flags_.push_back(shared_ptr<Flag>(new Flag(*this, time,
+ QString("%1").arg(next_flag_text_))));
+ next_flag_text_ = (next_flag_text_ >= 'Z') ? 'A' :
+ (next_flag_text_ + 1);
+ time_item_appearance_changed(true, true);
+}
+
+void View::remove_flag(std::shared_ptr<Flag> flag)
+{
+ flags_.remove(flag);
+ time_item_appearance_changed(true, true);
+}
+
+vector< std::shared_ptr<Flag> > View::flags() const
+{
+ vector< std::shared_ptr<Flag> > flags(flags_.begin(), flags_.end());
+ stable_sort(flags.begin(), flags.end(),
+ [](const shared_ptr<Flag> &a, const shared_ptr<Flag> &b) {
+ return a->time() < b->time();
+ });
+
+ return flags;
+}
+
const QPoint& View::hover_point() const
{
return hover_point_;
#include <stdint.h>
+#include <list>
#include <memory>
#include <set>
#include <unordered_map>
#include <pv/data/signaldata.hpp>
#include "cursorpair.hpp"
+#include "flag.hpp"
#include "rowitemowner.hpp"
namespace pv {
*/
std::shared_ptr<CursorPair> cursors() const;
+ /**
+ * Adds a new flag at a specified time.
+ */
+ void add_flag(double time);
+
+ /**
+ * Removes a flag from the list.
+ */
+ void remove_flag(std::shared_ptr<Flag> flag);
+
+ /**
+ * Gets the list of flags.
+ */
+ std::vector< std::shared_ptr<Flag> > flags() const;
+
const QPoint& hover_point() const;
void update_viewport();
bool show_cursors_;
std::shared_ptr<CursorPair> cursors_;
+ std::list< std::shared_ptr<Flag> > flags_;
+ char next_flag_text_;
+
QPoint hover_point_;
unsigned int sticky_events_;
${PROJECT_SOURCE_DIR}/pv/view/cursor.cpp
${PROJECT_SOURCE_DIR}/pv/view/cursorheader.cpp
${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp
+ ${PROJECT_SOURCE_DIR}/pv/view/flag.cpp
${PROJECT_SOURCE_DIR}/pv/view/header.cpp
${PROJECT_SOURCE_DIR}/pv/view/marginwidget.cpp
${PROJECT_SOURCE_DIR}/pv/view/logicsignal.cpp
${PROJECT_SOURCE_DIR}/pv/prop/binding/deviceoptions.hpp
${PROJECT_SOURCE_DIR}/pv/view/cursor.hpp
${PROJECT_SOURCE_DIR}/pv/view/cursorheader.hpp
+ ${PROJECT_SOURCE_DIR}/pv/view/flag.hpp
${PROJECT_SOURCE_DIR}/pv/view/header.hpp
${PROJECT_SOURCE_DIR}/pv/view/logicsignal.hpp
${PROJECT_SOURCE_DIR}/pv/view/marginwidget.hpp