X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fanalogsignal.cpp;h=be0abbf183aa78d30cd3748a8f578a0e5a06b5d4;hp=0419b03b698eb208496e15b75957c2eb8b6d9663;hb=4521022bf4ea07aff38bfa09fe0f7d5702b26475;hpb=de2fc10b2b067705e623b9781a332ad8fa3f4f88 diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index 0419b03b..be0abbf1 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -537,6 +537,7 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp) const int nh = min(neg_vdivs_, 1) * div_height_; const float high_offset = y - ph + signal_margin + 0.5f; const float low_offset = y + nh - signal_margin - 0.5f; + const float signal_height = low_offset - high_offset; shared_ptr segment = get_logic_segment_to_paint(); if (!segment || (segment->get_sample_count() == 0)) @@ -565,6 +566,11 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp) samples_per_pixel / LogicSignal::Oversampling, 0); assert(edges.size() >= 2); + const float first_sample_x = + pp.left() + (edges.front().first / samples_per_pixel - pixels_offset); + const float last_sample_x = + pp.left() + (edges.back().first / samples_per_pixel - pixels_offset); + // Check whether we need to paint the sampling points GlobalSettings settings; const bool show_sampling_points = @@ -572,14 +578,18 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp) (samples_per_pixel < 0.25); vector sampling_points; - float sampling_point_x = 0.0f; + float sampling_point_x = first_sample_x; int64_t sampling_point_sample = start_sample; const int w = 2; - if (show_sampling_points) { + if (show_sampling_points) sampling_points.reserve(end_sample - start_sample + 1); - sampling_point_x = (edges.cbegin()->first / samples_per_pixel - pixels_offset) + pp.left(); - } + + // Check whether we need to fill the high areas + const bool fill_high_areas = + settings.value(GlobalSettings::Key_View_FillSignalHighAreas).toBool(); + float high_start_x; + vector high_rects; // Paint the edges const unsigned int edge_count = edges.size() - 2; @@ -591,6 +601,14 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp) pixels_offset) + pp.left(); *line++ = QLineF(x, high_offset, x, low_offset); + if (fill_high_areas) { + if ((*i).second) + high_start_x = x; + else + high_rects.emplace_back(high_start_x, high_offset, + x - high_start_x, signal_height); + } + if (show_sampling_points) while (sampling_point_sample < (*i).first) { const float y = (*i).second ? low_offset : high_offset; @@ -612,6 +630,19 @@ void AnalogSignal::paint_logic_mid(QPainter &p, ViewItemPaintParams &pp) sampling_point_x += pixels_per_sample; }; + if (fill_high_areas) { + // Add last high rectangle if the signal is still high at the end of the view + if ((edges.cend() - 1)->second) + high_rects.emplace_back(high_start_x, high_offset, + last_sample_x - high_start_x, signal_height); + + const QColor fill_color = QColor::fromRgba(settings.value( + GlobalSettings::Key_View_FillSignalHighAreaColor).value()); + p.setPen(fill_color); + p.setBrush(fill_color); + p.drawRects((const QRectF*)(high_rects.data()), high_rects.size()); + } + p.setPen(LogicSignal::EdgeColor); p.drawLines(edge_lines, edge_count); delete[] edge_lines;