projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
97904bf
)
RowItemPaintParams: Bundled scale and offset
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Mon, 24 Nov 2014 19:28:34 +0000
(19:28 +0000)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Tue, 9 Dec 2014 18:24:59 +0000
(18:24 +0000)
pv/view/analogsignal.cpp
patch
|
blob
|
history
pv/view/logicsignal.cpp
patch
|
blob
|
history
pv/view/rowitempaintparams.cpp
patch
|
blob
|
history
pv/view/rowitempaintparams.hpp
patch
|
blob
|
history
pv/view/viewport.cpp
patch
|
blob
|
history
diff --git
a/pv/view/analogsignal.cpp
b/pv/view/analogsignal.cpp
index 325ab6bd301e00e610f51e9997367b0a9cb9cd58..5d838506cedb1877ccf3b284b92735ba2cf0025f 100644
(file)
--- a/
pv/view/analogsignal.cpp
+++ b/
pv/view/analogsignal.cpp
@@
-100,14
+100,6
@@
void AnalogSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
const int y = get_visual_y();
const int y = get_visual_y();
- const View *const view = owner_->view();
- assert(view);
-
- const double scale = view->scale();
- assert(scale > 0);
-
- const double offset = view->offset();
-
if (!channel_->enabled())
return;
if (!channel_->enabled())
return;
@@
-119,12
+111,12
@@
void AnalogSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
const shared_ptr<pv::data::AnalogSnapshot> &snapshot =
snapshots.front();
const shared_ptr<pv::data::AnalogSnapshot> &snapshot =
snapshots.front();
- const double pixels_offset =
offset / scale
;
+ const double pixels_offset =
pp.pixels_offset()
;
const double samplerate = data_->samplerate();
const double start_time = data_->get_start_time();
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samplerate = data_->samplerate();
const double start_time = data_->get_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 samples_per_pixel = samplerate *
pp.scale()
;
+ const double start = samplerate * (
pp.offset()
- start_time);
const double end = start + samples_per_pixel * pp.width();
const int64_t start_sample = min(max((int64_t)floor(start),
const double end = start + samples_per_pixel * pp.width();
const int64_t start_sample = min(max((int64_t)floor(start),
diff --git
a/pv/view/logicsignal.cpp
b/pv/view/logicsignal.cpp
index 1ee99cb90595a46a9ff57fceae478d57399cf78b..3acf1b5cb03ebf53c8a632075a07f32adfa0f7f3 100644
(file)
--- a/
pv/view/logicsignal.cpp
+++ b/
pv/view/logicsignal.cpp
@@
-153,8
+153,6
@@
void LogicSignal::paint_back(QPainter &p, const RowItemPaintParams &pp)
void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
{
void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
{
- using pv::view::View;
-
QLineF *line;
vector< pair<int64_t, bool> > edges;
QLineF *line;
vector< pair<int64_t, bool> > edges;
@@
-165,14
+163,6
@@
void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
const int y = get_visual_y();
const int y = get_visual_y();
- const View *const view = owner_->view();
- assert(view);
-
- const double scale = view->scale();
- assert(scale > 0);
-
- const double offset = view->offset();
-
if (!channel_->enabled())
return;
if (!channel_->enabled())
return;
@@
-193,11
+183,11
@@
void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
if (samplerate == 0.0)
samplerate = 1.0;
if (samplerate == 0.0)
samplerate = 1.0;
- const double pixels_offset =
offset / scale
;
+ const double pixels_offset =
pp.pixels_offset()
;
const double start_time = data_->get_start_time();
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double start_time = data_->get_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 samples_per_pixel = samplerate *
pp.scale()
;
+ const double start = samplerate * (
pp.offset()
- start_time);
const double end = start + samples_per_pixel * pp.width();
snapshot->get_subsampled_edges(edges,
const double end = start + samples_per_pixel * pp.width();
snapshot->get_subsampled_edges(edges,
diff --git
a/pv/view/rowitempaintparams.cpp
b/pv/view/rowitempaintparams.cpp
index 013c2a238da9b2470d55754a018f9011a7233f17..af5f675a5ea6ad956b6880f8367a84265bb139b6 100644
(file)
--- a/
pv/view/rowitempaintparams.cpp
+++ b/
pv/view/rowitempaintparams.cpp
@@
-25,10
+25,14
@@
namespace pv {
namespace view {
namespace pv {
namespace view {
-RowItemPaintParams::RowItemPaintParams(int left, int right) :
+RowItemPaintParams::RowItemPaintParams(
+ int left, int right, double scale, double offset) :
left_(left),
left_(left),
- right_(right) {
+ right_(right),
+ scale_(scale),
+ offset_(offset) {
assert(left <= right);
assert(left <= right);
+ assert(scale > 0.0);
}
} // namespace view
}
} // namespace view
diff --git
a/pv/view/rowitempaintparams.hpp
b/pv/view/rowitempaintparams.hpp
index 062b3cdd5db2a6b8ca1cdff872e224edbcc34600..5c71edcbbcb10783f7cd06ed1e50758af9f05e3c 100644
(file)
--- a/
pv/view/rowitempaintparams.hpp
+++ b/
pv/view/rowitempaintparams.hpp
@@
-27,7
+27,7
@@
namespace view {
class RowItemPaintParams
{
public:
class RowItemPaintParams
{
public:
- RowItemPaintParams(int left, int right);
+ RowItemPaintParams(int left, int right
, double scale, double offset
);
int left() const {
return left_;
int left() const {
return left_;
@@
-37,13
+37,27
@@
public:
return right_;
}
return right_;
}
+ double scale() const {
+ return scale_;
+ }
+
+ double offset() const {
+ return offset_;
+ }
+
int width() const {
return right_ - left_;
}
int width() const {
return right_ - left_;
}
+ double pixels_offset() const {
+ return offset_ / scale_;
+ }
+
private:
int left_;
int right_;
private:
int left_;
int right_;
+ double scale_;
+ double offset_;
};
} // namespace view
};
} // namespace view
diff --git
a/pv/view/viewport.cpp
b/pv/view/viewport.cpp
index bc010b4bd02fa3cd11270397c87e2588df2af461..f5f0ab59fb2f949caf1bef931b506d0d859b185a 100644
(file)
--- a/
pv/view/viewport.cpp
+++ b/
pv/view/viewport.cpp
@@
-70,7
+70,7
@@
void Viewport::paintEvent(QPaintEvent*)
if (view_.cursors_shown())
view_.cursors().draw_viewport_background(p, rect());
if (view_.cursors_shown())
view_.cursors().draw_viewport_background(p, rect());
- const RowItemPaintParams pp(0, width());
+ const RowItemPaintParams pp(0, width()
, view_.scale(), view_.offset()
);
// Plot the signal
for (const shared_ptr<RowItem> r : row_items)
// Plot the signal
for (const shared_ptr<RowItem> r : row_items)