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;
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 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),
void LogicSignal::paint_mid(QPainter &p, const RowItemPaintParams &pp)
{
- using pv::view::View;
-
QLineF *line;
vector< pair<int64_t, bool> > edges;
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 (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 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,
namespace pv {
namespace view {
-RowItemPaintParams::RowItemPaintParams(int left, int right) :
+RowItemPaintParams::RowItemPaintParams(
+ int left, int right, double scale, double offset) :
left_(left),
- right_(right) {
+ right_(right),
+ scale_(scale),
+ offset_(offset) {
assert(left <= right);
+ assert(scale > 0.0);
}
} // namespace view
class RowItemPaintParams
{
public:
- RowItemPaintParams(int left, int right);
+ RowItemPaintParams(int left, int right, double scale, double offset);
int left() const {
return left_;
return right_;
}
+ double scale() const {
+ return scale_;
+ }
+
+ double offset() const {
+ return offset_;
+ }
+
int width() const {
return right_ - left_;
}
+ double pixels_offset() const {
+ return offset_ / scale_;
+ }
+
private:
int left_;
int right_;
+ double scale_;
+ double offset_;
};
} // namespace view
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)