projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
640d69c
)
Add a pointer to the current View inside Trace
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Mon, 26 Aug 2013 15:08:21 +0000
(16:08 +0100)
committer
Joel Holdsworth
<joel@airwebreahe.org.uk>
Sun, 29 Sep 2013 01:52:28 +0000
(10:52 +0900)
pv/view/analogsignal.cpp
patch
|
blob
|
history
pv/view/analogsignal.h
patch
|
blob
|
history
pv/view/decodesignal.cpp
patch
|
blob
|
history
pv/view/decodesignal.h
patch
|
blob
|
history
pv/view/header.cpp
patch
|
blob
|
history
pv/view/logicsignal.cpp
patch
|
blob
|
history
pv/view/logicsignal.h
patch
|
blob
|
history
pv/view/trace.cpp
patch
|
blob
|
history
pv/view/trace.h
patch
|
blob
|
history
pv/view/view.cpp
patch
|
blob
|
history
pv/view/viewport.cpp
patch
|
blob
|
history
diff --git
a/pv/view/analogsignal.cpp
b/pv/view/analogsignal.cpp
index 6aeef98a57aa14f474e7b7d0fdcacbae8158a07a..681386ff6b91f9c69e4f1a84f350b08675551b43 100644
(file)
--- a/
pv/view/analogsignal.cpp
+++ b/
pv/view/analogsignal.cpp
@@
-25,6
+25,7
@@
#include "analogsignal.h"
#include "pv/data/analog.h"
#include "pv/data/analogsnapshot.h"
#include "analogsignal.h"
#include "pv/data/analog.h"
#include "pv/data/analogsnapshot.h"
+#include "pv/view/view.h"
using namespace boost;
using namespace std;
using namespace boost;
using namespace std;
@@
-66,13
+67,19
@@
void AnalogSignal::set_scale(float scale)
_scale = scale;
}
_scale = scale;
}
-void AnalogSignal::paint(QPainter &p, int y, int left, int right, double scale,
- double offset)
+void AnalogSignal::paint(QPainter &p, int left, int right)
{
{
- assert(scale > 0);
assert(_data);
assert(right >= left);
assert(_data);
assert(right >= left);
+ assert(_view);
+ const int y = _v_offset - _view->v_offset();
+
+ const double scale = _view->scale();
+ assert(scale > 0);
+
+ const double offset = _view->offset();
+
if (!_probe->enabled)
return;
if (!_probe->enabled)
return;
diff --git
a/pv/view/analogsignal.h
b/pv/view/analogsignal.h
index 7815261ec8cf51d9352bbdb150a377591a062f26..002076a2cc5c8f95729dc70a31058b41a2e3f10b 100644
(file)
--- a/
pv/view/analogsignal.h
+++ b/
pv/view/analogsignal.h
@@
-54,15
+54,10
@@
public:
/**
* Paints the signal with a QPainter
* @param p the QPainter to paint into.
/**
* Paints the signal with a QPainter
* @param p the QPainter to paint into.
- * @param y the y-coordinate to draw the signal at.
* @param left the x-coordinate of the left edge of the signal.
* @param right the x-coordinate of the right edge of the signal.
* @param left the x-coordinate of the left edge of the signal.
* @param right the x-coordinate of the right edge of the signal.
- * @param scale the scale in seconds per pixel.
- * @param offset the time to show at the left hand edge of
- * the view in seconds.
**/
**/
- void paint(QPainter &p, int y, int left, int right, double scale,
- double offset);
+ void paint(QPainter &p, int left, int right);
private:
void paint_trace(QPainter &p,
private:
void paint_trace(QPainter &p,
diff --git
a/pv/view/decodesignal.cpp
b/pv/view/decodesignal.cpp
index d27178920faae4190e4343f893387a1603af3d86..556631c6cc059e5a8bb850fdce91cee7aaa29f2a 100644
(file)
--- a/
pv/view/decodesignal.cpp
+++ b/
pv/view/decodesignal.cpp
@@
-50,16
+50,11
@@
bool DecodeSignal::enabled() const
return true;
}
return true;
}
-void DecodeSignal::paint(QPainter &p, int y, int left, int right,
- double scale, double offset)
+void DecodeSignal::paint(QPainter &p, int left, int right)
{
(void)p;
{
(void)p;
- (void)y;
(void)left;
(void)right;
(void)left;
(void)right;
- (void)offset;
-
- assert(scale > 0);
}
const list<QAction*> DecodeSignal::get_context_bar_actions()
}
const list<QAction*> DecodeSignal::get_context_bar_actions()
diff --git
a/pv/view/decodesignal.h
b/pv/view/decodesignal.h
index 755fefe6e5c0efca893b38743d8a6720806a5d87..31804589cc8f7041862dc9f2b22a69cbab319f04 100644
(file)
--- a/
pv/view/decodesignal.h
+++ b/
pv/view/decodesignal.h
@@
-46,15
+46,10
@@
public:
/**
* Paints the trace with a QPainter
* @param p the QPainter to paint into.
/**
* Paints the trace with a QPainter
* @param p the QPainter to paint into.
- * @param y the y-coordinate to draw the signal at
* @param left the x-coordinate of the left edge of the signal
* @param right the x-coordinate of the right edge of the signal
* @param left the x-coordinate of the left edge of the signal
* @param right the x-coordinate of the right edge of the signal
- * @param scale the scale in seconds per pixel.
- * @param offset the time to show at the left hand edge of
- * the view in seconds.
**/
**/
- void paint(QPainter &p, int y, int left, int right,
- double scale, double offset);
+ void paint(QPainter &p, int left, int right);
const std::list<QAction*> get_context_bar_actions();
const std::list<QAction*> get_context_bar_actions();
diff --git
a/pv/view/header.cpp
b/pv/view/header.cpp
index e14a9f246ecfb39e7d390e9d9f96be136cdf80e9..b85b1bb1c0a03cc5ed11249d0e4dd96df2865d26 100644
(file)
--- a/
pv/view/header.cpp
+++ b/
pv/view/header.cpp
@@
-66,13
+66,10
@@
shared_ptr<Trace> Header::get_mouse_over_trace(const QPoint &pt)
const int w = width();
const vector< shared_ptr<Trace> > traces(_view.get_traces());
const int w = width();
const vector< shared_ptr<Trace> > traces(_view.get_traces());
- const int v_offset = _view.v_offset();
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
-
- if (t->pt_in_label_rect(t->get_v_offset() - v_offset,
- 0, w, pt))
+ if (t->pt_in_label_rect(0, w, pt))
return t;
}
return t;
}
@@
-98,16
+95,14
@@
void Header::paintEvent(QPaintEvent*)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
- const int v_offset = _view.v_offset();
const bool dragging = !_drag_traces.empty();
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
const bool dragging = !_drag_traces.empty();
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
- const int y = t->get_v_offset() - v_offset;
const bool highlight = !dragging && t->pt_in_label_rect(
const bool highlight = !dragging && t->pt_in_label_rect(
-
y,
0, w, _mouse_point);
- t->paint_label(painter,
y,
w, highlight);
+ 0, w, _mouse_point);
+ t->paint_label(painter, w, highlight);
}
painter.end();
}
painter.end();
diff --git
a/pv/view/logicsignal.cpp
b/pv/view/logicsignal.cpp
index 0c934cc72cb0f3de8a675332de3115deb86b9ee4..3624ccf0f26b2df1dce6624c95a78d974d69b5bd 100644
(file)
--- a/
pv/view/logicsignal.cpp
+++ b/
pv/view/logicsignal.cpp
@@
-28,6
+28,7
@@
#include "pv/sigsession.h"
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
#include "pv/sigsession.h"
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
+#include "pv/view/view.h"
using namespace boost;
using namespace std;
using namespace boost;
using namespace std;
@@
-156,8
+157,7
@@
const list<QAction*> LogicSignal::get_context_bar_actions()
return actions;
}
return actions;
}
-void LogicSignal::paint(QPainter &p, int y, int left, int right,
- double scale, double offset)
+void LogicSignal::paint(QPainter &p, int left, int right)
{
using pv::view::View;
{
using pv::view::View;
@@
-166,10
+166,17
@@
void LogicSignal::paint(QPainter &p, int y, int left, int right,
vector< pair<int64_t, bool> > edges;
assert(_probe);
vector< pair<int64_t, bool> > edges;
assert(_probe);
- assert(scale > 0);
assert(_data);
assert(right >= left);
assert(_data);
assert(right >= left);
+ assert(_view);
+ const int y = _v_offset - _view->v_offset();
+
+ const double scale = _view->scale();
+ assert(scale > 0);
+
+ const double offset = _view->offset();
+
if (!_probe->enabled)
return;
if (!_probe->enabled)
return;
diff --git
a/pv/view/logicsignal.h
b/pv/view/logicsignal.h
index 3b37c5d322ffe2b4b388f8c87cf1c82c0c88ac00..b0a328c1fc662e195bf66de423aa0f69b7bdd35b 100644
(file)
--- a/
pv/view/logicsignal.h
+++ b/
pv/view/logicsignal.h
@@
-59,15
+59,10
@@
public:
/**
* Paints the signal with a QPainter
* @param p the QPainter to paint into.
/**
* Paints the signal with a QPainter
* @param p the QPainter to paint into.
- * @param y the y-coordinate to draw the signal at.
* @param left the x-coordinate of the left edge of the signal.
* @param right the x-coordinate of the right edge of the signal.
* @param left the x-coordinate of the left edge of the signal.
* @param right the x-coordinate of the right edge of the signal.
- * @param scale the scale in seconds per pixel.
- * @param offset the time to show at the left hand edge of
- * the view in seconds.
**/
**/
- void paint(QPainter &p, int y, int left, int right, double scale,
- double offset);
+ void paint(QPainter &p, int left, int right);
private:
private:
diff --git
a/pv/view/trace.cpp
b/pv/view/trace.cpp
index 4de3f141cc87438bcf6f3d9b2ea1ef1b43822888..6c43c4c2238044c572fbe0edc4e7343449c06ba7 100644
(file)
--- a/
pv/view/trace.cpp
+++ b/
pv/view/trace.cpp
@@
-68,8
+68,17
@@
void Trace::set_v_offset(int v_offset)
_v_offset = v_offset;
}
_v_offset = v_offset;
}
-void Trace::
paint_label(QPainter &p, int y, int right, bool hover
)
+void Trace::
set_view(pv::view::View *view
)
{
{
+ assert(view);
+ _view = view;
+}
+
+void Trace::paint_label(QPainter &p, int right, bool hover)
+{
+ assert(_view);
+ const int y = _v_offset - _view->v_offset();
+
p.setBrush(_colour);
if (!enabled())
p.setBrush(_colour);
if (!enabled())
@@
-78,7
+87,7
@@
void Trace::paint_label(QPainter &p, int y, int right, bool hover)
const QColor colour = get_colour();
compute_text_size(p);
const QColor colour = get_colour();
compute_text_size(p);
- const QRectF label_rect = get_label_rect(
y,
right);
+ const QRectF label_rect = get_label_rect(right);
// Paint the label
const QPointF points[] = {
// Paint the label
const QPointF points[] = {
@@
-120,12
+129,11
@@
void Trace::paint_label(QPainter &p, int y, int right, bool hover)
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
}
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
}
-bool Trace::pt_in_label_rect(int y, int left, int right,
- const QPoint &point)
+bool Trace::pt_in_label_rect(int left, int right, const QPoint &point)
{
(void)left;
{
(void)left;
- const QRectF label = get_label_rect(
y,
right);
+ const QRectF label = get_label_rect(right);
return QRectF(
QPointF(label.left() - LabelHitPadding,
label.top() - LabelHitPadding),
return QRectF(
QPointF(label.left() - LabelHitPadding,
label.top() - LabelHitPadding),
@@
-140,10
+148,13
@@
void Trace::compute_text_size(QPainter &p)
p.boundingRect(QRectF(), 0, "Tg").height());
}
p.boundingRect(QRectF(), 0, "Tg").height());
}
-QRectF Trace::get_label_rect(int
y, int
right)
+QRectF Trace::get_label_rect(int right)
{
using pv::view::View;
{
using pv::view::View;
+ assert(_view);
+ const int y = _v_offset - _view->v_offset();
+
const QSizeF label_size(
_text_size.width() + View::LabelPadding.width() * 2,
ceilf((_text_size.height() + View::LabelPadding.height() * 2) / 2) * 2);
const QSizeF label_size(
_text_size.width() + View::LabelPadding.width() * 2,
ceilf((_text_size.height() + View::LabelPadding.height() * 2) / 2) * 2);
diff --git
a/pv/view/trace.h
b/pv/view/trace.h
index 61433e9c31388afb7cfe0ae2310ae76d0e97add1..4d6b49be0c4a551e5a9b942903c7502f8ecf0aab 100644
(file)
--- a/
pv/view/trace.h
+++ b/
pv/view/trace.h
@@
-36,6
+36,8
@@
class SigSession;
namespace view {
namespace view {
+class View;
+
class Trace : public SelectableItem
{
Q_OBJECT
class Trace : public SelectableItem
{
Q_OBJECT
@@
-82,41
+84,34
@@
public:
*/
virtual bool enabled() const = 0;
*/
virtual bool enabled() const = 0;
+ void set_view(pv::view::View *view);
+
/**
* Paints the trace with a QPainter
* @param p the QPainter to paint into.
/**
* Paints the trace with a QPainter
* @param p the QPainter to paint into.
- * @param y the y-coordinate to draw the signal at
* @param left the x-coordinate of the left edge of the signal
* @param right the x-coordinate of the right edge of the signal
* @param left the x-coordinate of the left edge of the signal
* @param right the x-coordinate of the right edge of the signal
- * @param scale the scale in seconds per pixel.
- * @param offset the time to show at the left hand edge of
- * the view in seconds.
**/
**/
- virtual void paint(QPainter &p, int y, int left, int right,
- double scale, double offset) = 0;
+ virtual void paint(QPainter &p, int left, int right) = 0;
/**
* Paints the signal label into a QGLWidget.
* @param p the QPainter to paint into.
/**
* Paints the signal label into a QGLWidget.
* @param p the QPainter to paint into.
- * @param y the y-coordinate of the signal.
* @param right the x-coordinate of the right edge of the header
* area.
* @param hover true if the label is being hovered over by the mouse.
*/
* @param right the x-coordinate of the right edge of the header
* area.
* @param hover true if the label is being hovered over by the mouse.
*/
- virtual void paint_label(QPainter &p, int y, int right,
- bool hover);
+ virtual void paint_label(QPainter &p, int right, bool hover);
/**
* Determines if a point is in the header label rect.
/**
* Determines if a point is in the header label rect.
- * @param y the y-coordinate of the signal.
* @param left the x-coordinate of the left edge of the header
* area.
* @param right the x-coordinate of the right edge of the header
* area.
* @param point the point to test.
*/
* @param left the x-coordinate of the left edge of the header
* area.
* @param right the x-coordinate of the right edge of the header
* area.
* @param point the point to test.
*/
- bool pt_in_label_rect(int y, int left, int right,
- const QPoint &point);
+ bool pt_in_label_rect(int left, int right, const QPoint &point);
private:
private:
@@
-128,18
+123,18
@@
private:
/**
* Computes the outline rectangle of a label.
* @param p the QPainter to lay out text with.
/**
* Computes the outline rectangle of a label.
* @param p the QPainter to lay out text with.
- * @param y the y-coordinate of the signal.
* @param right the x-coordinate of the right edge of the header
* area.
* @return Returns the rectangle of the signal label.
*/
* @param right the x-coordinate of the right edge of the header
* area.
* @return Returns the rectangle of the signal label.
*/
- QRectF get_label_rect(int
y, int
right);
+ QRectF get_label_rect(int right);
signals:
void text_changed();
protected:
pv::SigSession &_session;
signals:
void text_changed();
protected:
pv::SigSession &_session;
+ pv::view::View *_view;
QString _name;
QColor _colour;
QString _name;
QColor _colour;
diff --git
a/pv/view/view.cpp
b/pv/view/view.cpp
index b4815e704ac6b002f21fc0eb42aa6850e33619cf..026d2e7fda92a516e2032dcabac64d1a7d0d5fa5 100644
(file)
--- a/
pv/view/view.cpp
+++ b/
pv/view/view.cpp
@@
-384,10
+384,11
@@
void View::v_scroll_value_changed(int value)
void View::signals_changed()
{
int offset = SignalMargin + SignalHeight;
void View::signals_changed()
{
int offset = SignalMargin + SignalHeight;
- const vector< shared_ptr<Signal> > sigs(_session.get_signals());
- BOOST_FOREACH(shared_ptr<Signal> s, sigs) {
- s->init_context_bar_actions(NULL);
- s->set_v_offset(offset);
+ const vector< shared_ptr<Trace> > traces(get_traces());
+ BOOST_FOREACH(shared_ptr<Trace> t, traces) {
+ t->set_view(this);
+ t->init_context_bar_actions(NULL);
+ t->set_v_offset(offset);
offset += SignalHeight + 2 * SignalMargin;
}
offset += SignalHeight + 2 * SignalMargin;
}
diff --git
a/pv/view/viewport.cpp
b/pv/view/viewport.cpp
index 0e0ae8ae4ad0807f5b99abe1f31ca458f437af94..06fab904e75168fab06a9499574446959c93e9a3 100644
(file)
--- a/
pv/view/viewport.cpp
+++ b/
pv/view/viewport.cpp
@@
-69,12
+69,10
@@
void Viewport::paintEvent(QPaintEvent*)
_view.cursors().draw_viewport_background(p, rect());
// Plot the signal
_view.cursors().draw_viewport_background(p, rect());
// Plot the signal
- const int v_offset = _view.v_offset();
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
{
assert(t);
- t->paint(p, t->get_v_offset() - v_offset, 0, width(),
- _view.scale(), _view.offset());
+ t->paint(p, 0, width());
}
if (_view.cursors_shown())
}
if (_view.cursors_shown())