projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
06993d0
)
Eliminated get_nominal_offset
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Fri, 18 Jan 2013 18:33:01 +0000
(18:33 +0000)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sat, 19 Jan 2013 21:00:09 +0000
(21:00 +0000)
pv/view/analogsignal.cpp
patch
|
blob
|
history
pv/view/analogsignal.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/signal.cpp
patch
|
blob
|
history
pv/view/signal.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 fb5eba6103ad6ba9f3f22936d86fe831d07a5d66..136080694bbb03029c21691efe0b9b3293ac5c3c 100644
(file)
--- a/
pv/view/analogsignal.cpp
+++ b/
pv/view/analogsignal.cpp
@@
-39,11
+39,12
@@
AnalogSignal::AnalogSignal(QString name, shared_ptr<data::Analog> data) :
_colour = Qt::blue;
}
_colour = Qt::blue;
}
-void AnalogSignal::paint(QPainter &p,
const QRect &rec
t, double scale,
+void AnalogSignal::paint(QPainter &p,
int y, int left, int righ
t, double scale,
double offset)
{
assert(scale > 0);
assert(_data);
double offset)
{
assert(scale > 0);
assert(_data);
+ assert(right >= left);
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
_data->get_snapshots();
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
_data->get_snapshots();
@@
-59,15
+60,13
@@
void AnalogSignal::paint(QPainter &p, const QRect &rect, double scale,
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
const double start = samplerate * (offset - start_time);
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
const double start = samplerate * (offset - start_time);
- const double end = start + samples_per_pixel *
rect.width(
);
+ const double end = start + samples_per_pixel *
(right - left
);
const int64_t start_sample = min(max((int64_t)floor(start),
(int64_t)0), last_sample);
const int64_t end_sample = min(max((int64_t)ceil(end),
(int64_t)0), last_sample);
const int64_t start_sample = min(max((int64_t)floor(start),
(int64_t)0), last_sample);
const int64_t end_sample = min(max((int64_t)ceil(end),
(int64_t)0), last_sample);
- const int y_offset = rect.center().y();
-
const float* samples = snapshot->get_samples();
assert(samples);
const float* samples = snapshot->get_samples();
assert(samples);
@@
-77,9
+76,8
@@
void AnalogSignal::paint(QPainter &p, const QRect &rect, double scale,
for (int64_t sample = start_sample;
sample != end_sample; sample++) {
const float x = (sample / samples_per_pixel -
for (int64_t sample = start_sample;
sample != end_sample; sample++) {
const float x = (sample / samples_per_pixel -
- pixels_offset) + rect.left();
- const float y = samples[sample] + y_offset;
- *point++ = QPointF(x, y);
+ pixels_offset) + left;
+ *point++ = QPointF(x, samples[sample] + y);
}
p.drawPoints(points, point - points);
}
p.drawPoints(points, point - points);
@@
-87,10
+85,5
@@
void AnalogSignal::paint(QPainter &p, const QRect &rect, double scale,
delete[] points;
}
delete[] points;
}
-int AnalogSignal::get_nominal_offset(const QRect &rect) const
-{
- return rect.center().y();
-}
-
} // namespace view
} // namespace pv
} // namespace view
} // namespace pv
diff --git
a/pv/view/analogsignal.h
b/pv/view/analogsignal.h
index 7bc0ed6eb6aaf25d9a605a22c1ab038dec3103a6..86471537abce44236291664b98a1e74084cc187d 100644
(file)
--- a/
pv/view/analogsignal.h
+++ b/
pv/view/analogsignal.h
@@
-42,21
+42,15
@@
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 rect the rectangular area to draw the trace 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 scale the scale in seconds per pixel.
* @param offset the time to show at the left hand edge of
* the view in seconds.
**/
* @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, const QRect &rect,
- double scale, double offset);
-
-private:
-
- /**
- * When painting into the rectangle, calculate the y
- * offset of the zero point.
- **/
- int get_nominal_offset(const QRect &rect) const;
+ void paint(QPainter &p, int y, int left, int right, double scale,
+ double offset);
private:
boost::shared_ptr<pv::data::Analog> _data;
private:
boost::shared_ptr<pv::data::Analog> _data;
diff --git
a/pv/view/header.cpp
b/pv/view/header.cpp
index a615e8513e7ff04d95b1b56af7c24299858af4c9..e0e280b2826dc3c988c362d1c2eaecaf0a508f29 100644
(file)
--- a/
pv/view/header.cpp
+++ b/
pv/view/header.cpp
@@
-71,11
+71,8
@@
boost::shared_ptr<pv::view::Signal> Header::get_mouse_over_signal(
{
assert(s);
{
assert(s);
- const QRect signal_heading_rect(
- 0, s->get_v_offset() - v_offset,
- w, View::SignalHeight);
-
- if (s->pt_in_label_rect(signal_heading_rect, pt))
+ if (s->pt_in_label_rect(s->get_v_offset() - v_offset,
+ 0, w, pt))
return s;
}
return s;
}
@@
-97,13
+94,10
@@
void Header::paintEvent(QPaintEvent*)
{
assert(s);
{
assert(s);
- const QRect signal_heading_rect(
- 0, s->get_v_offset() - v_offset,
- w, View::SignalHeight);
-
+ const int y = s->get_v_offset() - v_offset;
const bool highlight = !dragging && s->pt_in_label_rect(
const bool highlight = !dragging && s->pt_in_label_rect(
-
signal_heading_rect
, _mouse_point);
- s->paint_label(painter,
signal_heading_rect
, highlight);
+
y, 0, w
, _mouse_point);
+ s->paint_label(painter,
y, w
, highlight);
}
painter.end();
}
painter.end();
diff --git
a/pv/view/logicsignal.cpp
b/pv/view/logicsignal.cpp
index d23da5bbf021815a5b668ccfb624ebfb401d9e38..051da4d89af92ef1694c88cdd08901c487a15b2b 100644
(file)
--- a/
pv/view/logicsignal.cpp
+++ b/
pv/view/logicsignal.cpp
@@
-23,6
+23,7
@@
#include <math.h>
#include "logicsignal.h"
#include <math.h>
#include "logicsignal.h"
+#include "view.h"
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
@@
-62,18
+63,21
@@
LogicSignal::LogicSignal(QString name, shared_ptr<data::Logic> data,
_probe_index % countof(LogicSignalColours)];
}
_probe_index % countof(LogicSignalColours)];
}
-void LogicSignal::paint(QPainter &p,
const QRect &rect, double scale
,
- double offset)
+void LogicSignal::paint(QPainter &p,
int y, int left, int right
,
+
double scale,
double offset)
{
{
+ using pv::view::View;
+
QLineF *line;
vector< pair<int64_t, bool> > edges;
assert(scale > 0);
assert(_data);
QLineF *line;
vector< pair<int64_t, bool> > edges;
assert(scale > 0);
assert(_data);
+ assert(right >= left);
- const float high_offset =
rect.top()
+ 0.5f;
- const float low_offset =
rect.bottom()
+ 0.5f;
+ const float high_offset =
y - View::SignalHeight
+ 0.5f;
+ const float low_offset =
y
+ 0.5f;
const deque< shared_ptr<pv::data::LogicSnapshot> > &snapshots =
_data->get_snapshots();
const deque< shared_ptr<pv::data::LogicSnapshot> > &snapshots =
_data->get_snapshots();
@@
-89,7
+93,7
@@
void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
const double start = samplerate * (offset - start_time);
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
const double start = samplerate * (offset - start_time);
- const double end = start + samples_per_pixel *
rect.width(
);
+ const double end = start + samples_per_pixel *
(right - left
);
snapshot->get_subsampled_edges(edges,
min(max((int64_t)floor(start), (int64_t)0), last_sample),
snapshot->get_subsampled_edges(edges,
min(max((int64_t)floor(start), (int64_t)0), last_sample),
@@
-106,7
+110,7
@@
void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
edges.begin() + 1;
i != edges.end() - 1; i++) {
const float x = ((*i).first / samples_per_pixel -
edges.begin() + 1;
i != edges.end() - 1; i++) {
const float x = ((*i).first / samples_per_pixel -
- pixels_offset) +
rect.left()
;
+ pixels_offset) +
left
;
*line++ = QLineF(x, high_offset, x, low_offset);
}
*line++ = QLineF(x, high_offset, x, low_offset);
}
@@
-120,10
+124,10
@@
void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
p.setPen(HighColour);
paint_caps(p, cap_lines, edges, true, samples_per_pixel,
p.setPen(HighColour);
paint_caps(p, cap_lines, edges, true, samples_per_pixel,
- pixels_offset,
rect.left()
, high_offset);
+ pixels_offset,
left
, high_offset);
p.setPen(LowColour);
paint_caps(p, cap_lines, edges, false, samples_per_pixel,
p.setPen(LowColour);
paint_caps(p, cap_lines, edges, false, samples_per_pixel,
- pixels_offset,
rect.left()
, low_offset);
+ pixels_offset,
left
, low_offset);
delete[] cap_lines;
}
delete[] cap_lines;
}
@@
-148,10
+152,5
@@
void LogicSignal::paint_caps(QPainter &p, QLineF *const lines,
p.drawLines(lines, line - lines);
}
p.drawLines(lines, line - lines);
}
-int LogicSignal::get_nominal_offset(const QRect &rect) const
-{
- return rect.bottom();
-}
-
} // namespace view
} // namespace pv
} // namespace view
} // namespace pv
diff --git
a/pv/view/logicsignal.h
b/pv/view/logicsignal.h
index e20f13c7a9fdb803a285d19c1fd19657f3476513..ad88241da34de704c783e77a7acc4bfb63763b87 100644
(file)
--- a/
pv/view/logicsignal.h
+++ b/
pv/view/logicsignal.h
@@
-52,12
+52,15
@@
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 rect the rectangular area to draw the trace 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 scale the scale in seconds per pixel.
* @param offset the time to show at the left hand edge of
* the view in seconds.
**/
* @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, const QRect &rect, double scale, double offset);
+ void paint(QPainter &p, int y, int left, int right, double scale,
+ double offset);
private:
private:
@@
-66,12
+69,6
@@
private:
bool level, double samples_per_pixel, double pixels_offset,
float x_offset, float y_offset);
bool level, double samples_per_pixel, double pixels_offset,
float x_offset, float y_offset);
- /**
- * When painting into the rectangle, calculate the y
- * offset of the zero point.
- **/
- int get_nominal_offset(const QRect &rect) const;
-
private:
int _probe_index;
boost::shared_ptr<pv::data::Logic> _data;
private:
int _probe_index;
boost::shared_ptr<pv::data::Logic> _data;
diff --git
a/pv/view/signal.cpp
b/pv/view/signal.cpp
index 33cfef2d418839a588bc269ac36729b30e67ae2b..2469d981632b59d9f8eaadb0b8cc2248d41e831c 100644
(file)
--- a/
pv/view/signal.cpp
+++ b/
pv/view/signal.cpp
@@
-78,21
+78,20
@@
void Signal::select(bool select)
_selected = select;
}
_selected = select;
}
-void Signal::paint_label(QPainter &p,
const QRect &rec
t, bool hover)
+void Signal::paint_label(QPainter &p,
int y, int righ
t, bool hover)
{
p.setBrush(_colour);
const QColor colour = get_colour();
{
p.setBrush(_colour);
const QColor colour = get_colour();
- const float nominal_offset = get_nominal_offset(rect);
compute_text_size(p);
compute_text_size(p);
- const QRectF label_rect = get_label_rect(
rec
t);
+ const QRectF label_rect = get_label_rect(
y, righ
t);
// Paint the label
const QPointF points[] = {
label_rect.topLeft(),
label_rect.topRight(),
// Paint the label
const QPointF points[] = {
label_rect.topLeft(),
label_rect.topRight(),
- QPointF(r
ect.right(), nominal_offset
),
+ QPointF(r
ight, y
),
label_rect.bottomRight(),
label_rect.bottomLeft()
};
label_rect.bottomRight(),
label_rect.bottomLeft()
};
@@
-100,7
+99,7
@@
void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
const QPointF highlight_points[] = {
QPointF(label_rect.left() + 1, label_rect.top() + 1),
QPointF(label_rect.right(), label_rect.top() + 1),
const QPointF highlight_points[] = {
QPointF(label_rect.left() + 1, label_rect.top() + 1),
QPointF(label_rect.right(), label_rect.top() + 1),
- QPointF(r
ect.right() - 1, nominal_offset
),
+ QPointF(r
ight - 1, y
),
QPointF(label_rect.right(), label_rect.bottom() - 1),
QPointF(label_rect.left() + 1, label_rect.bottom() - 1)
};
QPointF(label_rect.right(), label_rect.bottom() - 1),
QPointF(label_rect.left() + 1, label_rect.bottom() - 1)
};
@@
-130,15
+129,15
@@
void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
}
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
}
-bool Signal::pt_in_label_rect(const QRect &rect, const QPoint &point)
+bool Signal::pt_in_label_rect(int y, int left, int right,
+ const QPoint &point)
{
{
- const QRectF label = get_label_rect(
rec
t);
+ const QRectF label = get_label_rect(
y, righ
t);
return QRectF(
QPointF(label.left() - LabelHitPadding,
label.top() - LabelHitPadding),
return QRectF(
QPointF(label.left() - LabelHitPadding,
label.top() - LabelHitPadding),
- QPointF(rect.right(),
- label.bottom() + LabelHitPadding)
- ).contains(point);
+ QPointF(right, label.bottom() + LabelHitPadding)
+ ).contains(point);
}
void Signal::compute_text_size(QPainter &p)
}
void Signal::compute_text_size(QPainter &p)
@@
-146,19
+145,17
@@
void Signal::compute_text_size(QPainter &p)
_text_size = p.boundingRect(QRectF(), 0, _name).size();
}
_text_size = p.boundingRect(QRectF(), 0, _name).size();
}
-QRectF Signal::get_label_rect(
const QRect &rec
t)
+QRectF Signal::get_label_rect(
int y, int righ
t)
{
using pv::view::View;
{
using pv::view::View;
- const float nominal_offset = get_nominal_offset(rect) + 0.5;
const QSizeF label_size(
_text_size.width() + View::LabelPadding.width() * 2,
_text_size.height() + View::LabelPadding.height() * 2);
const float label_arrow_length = label_size.height() / 2;
return QRectF(
const QSizeF label_size(
_text_size.width() + View::LabelPadding.width() * 2,
_text_size.height() + View::LabelPadding.height() * 2);
const float label_arrow_length = label_size.height() / 2;
return QRectF(
- rect.right() - label_arrow_length -
- label_size.width() - 0.5,
- nominal_offset - label_size.height() / 2,
+ right - label_arrow_length - label_size.width() - 0.5,
+ y + 0.5f - label_size.height() / 2,
label_size.width(), label_size.height());
}
label_size.width(), label_size.height());
}
diff --git
a/pv/view/signal.h
b/pv/view/signal.h
index 72019032e06a74e221f92c4d9ea0ddf57fa968e6..c35f557dcd7ac66a9ed6b80a5f7e563d6957fe92 100644
(file)
--- a/
pv/view/signal.h
+++ b/
pv/view/signal.h
@@
-91,30
+91,38
@@
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 rect the rectangular area to draw the trace 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 scale the scale in seconds per pixel.
* @param offset the time to show at the left hand edge of
* the view in seconds.
**/
* @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, const QRect &rect, double scale,
- double offset) = 0;
-
+ virtual void paint(QPainter &p, int y, int left, int right,
+ double scale, double offset) = 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 rect the rectangular area to draw the label 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 hover true if the label is being hovered over by the mouse.
*/
- virtual void paint_label(QPainter &p,
const QRect &rec
t,
+ virtual void paint_label(QPainter &p,
int y, int righ
t,
bool hover);
/**
* Determines if a point is in the header label rect.
bool hover);
/**
* Determines if a point is in the header label rect.
- * @param rect the rectangular area to draw the label into.
+ * @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 point the point to test.
*/
- bool pt_in_label_rect(const QRect &rect, const QPoint &point);
+ bool pt_in_label_rect(int y, int left, int right,
+ const QPoint &point);
private:
private:
@@
-126,17
+134,12
@@
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 rect The rectangle of the signal header.
+ * @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.
*/
* @return Returns the rectangle of the signal label.
*/
- QRectF get_label_rect(const QRect &rect);
-
-protected:
- /**
- * When painting into the rectangle, calculate the y
- * offset of the zero point.
- **/
- virtual int get_nominal_offset(const QRect &rect) const = 0;
+ QRectF get_label_rect(int y, int right);
protected:
QString _name;
protected:
QString _name;
diff --git
a/pv/view/view.cpp
b/pv/view/view.cpp
index 10f6613c55da3fd2f362e51c67ff365a708b4359..34676334dc67867ba9b17fa064498232693e74e0 100644
(file)
--- a/
pv/view/view.cpp
+++ b/
pv/view/view.cpp
@@
-228,7
+228,7
@@
void View::update_scroll()
void View::reset_signal_layout()
{
void View::reset_signal_layout()
{
- int offset = SignalMargin;
+ int offset = SignalMargin
+ SignalHeight
;
const vector< shared_ptr<Signal> > sigs(_session.get_signals());
BOOST_FOREACH(shared_ptr<Signal> s, sigs) {
s->set_v_offset(offset);
const vector< shared_ptr<Signal> > sigs(_session.get_signals());
BOOST_FOREACH(shared_ptr<Signal> s, sigs) {
s->set_v_offset(offset);
diff --git
a/pv/view/viewport.cpp
b/pv/view/viewport.cpp
index f39c8201421d43956e5b6e3bc72c2768ab0cf365..5882600524d1b77bdfaf0d02ce38ad2e040a96e3 100644
(file)
--- a/
pv/view/viewport.cpp
+++ b/
pv/view/viewport.cpp
@@
-74,11
+74,8
@@
void Viewport::paintEvent(QPaintEvent*)
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
{
assert(s);
BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
{
assert(s);
-
- const QRect signal_rect(0, s->get_v_offset() - v_offset,
- width(), View::SignalHeight);
-
- s->paint(p, signal_rect, _view.scale(), _view.offset());
+ s->paint(p, s->get_v_offset() - v_offset, 0, width(),
+ _view.scale(), _view.offset());
}
draw_cursors_foreground(p);
}
draw_cursors_foreground(p);