pv/toolbars/samplingbar.cpp
pv/view/analogsignal.cpp
pv/view/cursor.cpp
+ pv/view/cursorpair.cpp
pv/view/header.cpp
pv/view/logicsignal.cpp
pv/view/ruler.cpp
public:
/**
* Constructor.
- * @param colour A reference to the colour of this cursor.
+ * @param view A reference to the view that owns this cursor pair.
* @param time The time to set the flag to.
*/
Cursor(const View &view, double time);
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 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 "cursorpair.h"
+
+#include "view.h"
+
+namespace pv {
+namespace view {
+
+CursorPair::CursorPair(const View &view) :
+ _first(view, 0.0),
+ _second(view, 1.0),
+ _view(view)
+{
+}
+
+const Cursor& CursorPair::first() const
+{
+ return _first;
+}
+
+Cursor& CursorPair::first()
+{
+ return _first;
+}
+
+const Cursor& CursorPair::second() const
+{
+ return _second;
+}
+
+Cursor& CursorPair::second()
+{
+ return _second;
+}
+
+} // namespace view
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 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_CURSORPAIR_H
+#define PULSEVIEW_PV_VIEW_CURSORPAIR_H
+
+#include "cursor.h"
+
+class QPainter;
+
+namespace pv {
+namespace view {
+
+class CursorPair
+{
+public:
+ /**
+ * Constructor.
+ * @param view A reference to the view that owns this cursor pair.
+ */
+ CursorPair(const View &view);
+
+ /**
+ * Returns a reference to the first cursor.
+ */
+ Cursor& first();
+
+ /**
+ * Returns a reference to the first cursor.
+ */
+ const Cursor& first() const;
+
+ /**
+ * Returns a reference to the second cursor.
+ */
+ Cursor& second();
+
+ /**
+ * Returns a reference to the second cursor.
+ */
+ const Cursor& second() const;
+
+private:
+ Cursor _first, _second;
+ const View &_view;
+};
+
+} // namespace view
+} // namespace pv
+
+#endif // PULSEVIEW_PV_VIEW_CURSORPAIR_H
_grabbed_marker = NULL;
if (_view.cursors_shown()) {
- std::pair<Cursor, Cursor> &cursors =
- _view.cursors();
- if (cursors.first.get_label_rect(
+ CursorPair &cursors = _view.cursors();
+ if (cursors.first().get_label_rect(
rect()).contains(e->pos()))
- _grabbed_marker = &cursors.first;
- else if (cursors.second.get_label_rect(
+ _grabbed_marker = &cursors.first();
+ else if (cursors.second().get_label_rect(
rect()).contains(e->pos()))
- _grabbed_marker = &cursors.second;
+ _grabbed_marker = &cursors.second();
}
}
}
return;
const QRect r = rect();
- pair<Cursor, Cursor> &cursors = _view.cursors();
- cursors.first.paint_label(p, r, prefix);
- cursors.second.paint_label(p, r, prefix);
+ CursorPair &cursors = _view.cursors();
+ cursors.first().paint_label(p, r, prefix);
+ cursors.second().paint_label(p, r, prefix);
}
void Ruler::draw_hover_mark(QPainter &p)
_v_offset(0),
_updating_scroll(false),
_show_cursors(false),
- _cursors(pair<Cursor, Cursor>(Cursor(*this, 0.0),
- Cursor(*this, 1.0))),
+ _cursors(*this),
_hover_point(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
connect(&_session, SIGNAL(data_updated()),
this, SLOT(data_updated()));
- connect(&_cursors.first, SIGNAL(time_changed()),
+ connect(&_cursors.first(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
- connect(&_cursors.second, SIGNAL(time_changed()),
+ connect(&_cursors.second(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
connect(_header, SIGNAL(signals_moved()),
_viewport->update();
}
-std::pair<Cursor, Cursor>& View::cursors()
+CursorPair& View::cursors()
{
return _cursors;
}
#include <stdint.h>
-#include <utility>
-
#include <QAbstractScrollArea>
#include <QSizeF>
-#include "cursor.h"
+#include "cursorpair.h"
namespace pv {
/**
* Returns a reference to the pair of cursors.
*/
- std::pair<Cursor, Cursor>& cursors();
+ CursorPair& cursors();
const QPoint& hover_point() const;
bool _updating_scroll;
bool _show_cursors;
- std::pair<Cursor, Cursor> _cursors;
+ CursorPair _cursors;
QPoint _hover_point;
};
p.setPen(Qt::NoPen);
p.setBrush(QBrush(View::CursorAreaColour));
- const pair<Cursor, Cursor> &c = _view.cursors();
- const float x1 = (c.first.time() - _view.offset()) / _view.scale();
- const float x2 = (c.second.time() - _view.offset()) / _view.scale();
+ const CursorPair &c = _view.cursors();
+ const float x1 = (c.first().time() - _view.offset()) / _view.scale();
+ const float x2 = (c.second().time() - _view.offset()) / _view.scale();
const int l = (int)max(min(x1, x2), 0.0f);
const int r = (int)min(max(x1, x2), (float)width());
return;
const QRect r = rect();
- pair<Cursor, Cursor> &cursors = _view.cursors();
- cursors.first.paint(p, r);
- cursors.second.paint(p, r);
+ CursorPair &cursors = _view.cursors();
+ cursors.first().paint(p, r);
+ cursors.second().paint(p, r);
}
void Viewport::on_signals_moved()