MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / paint_mid

Method paint_mid

DSView/pv/view/decodetrace.cpp:215–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215void DecodeTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColor back)
216{
217 using namespace pv::data::decode;
218
219 assert(_decoder_stack);
220 const QString err = _decoder_stack->error_message();
221 if (!err.isEmpty())
222 {
223 draw_error(p, err, left, right);
224 }
225
226 const double scale = _view->scale();
227 assert(scale > 0);
228
229 double samplerate = _decoder_stack->samplerate();
230
231 _cur_row_headings.clear();
232
233 // Show sample rate as 1Hz when it is unknown
234 if (samplerate == 0.0)
235 samplerate = 1.0;
236
237 const int64_t pixels_offset = _view->offset();
238 const double samples_per_pixel = samplerate * scale;
239
240 uint64_t start_sample = (uint64_t)max((left + pixels_offset) *
241 samples_per_pixel, 0.0);
242 uint64_t end_sample = (uint64_t)max((right + pixels_offset) *
243 samples_per_pixel, 0.0);
244
245 for(auto dec : _decoder_stack->stack()) {
246 start_sample = max(dec->decode_start(), start_sample);
247 end_sample = min(dec->decode_end(), end_sample);
248 break;
249 }
250
251 if (end_sample < start_sample)
252 return;
253
254 const int annotation_height = _view->get_signalHeight();
255
256 // Iterate through the rows
257 assert(_view);
258 int y = get_y() - (_totalHeight - annotation_height)*0.5;
259
260 assert(_decoder_stack);
261
262 for(auto dec :_decoder_stack->stack()) {
263 if (dec->shown()) {
264 const std::map<const pv::data::decode::Row, bool> rows = _decoder_stack->get_rows_gshow();
265 for (std::map<const pv::data::decode::Row, bool>::const_iterator i = rows.begin();
266 i != rows.end(); i++) {
267 if ((*i).first.decoder() == dec->decoder() &&
268 _decoder_stack->has_annotations((*i).first)) {
269 if ((*i).second) {
270 const Row &row = (*i).first;
271
272 const uint64_t min_annotation =

Callers

nothing calls this directly

Calls 15

error_messageMethod · 0.80
scaleMethod · 0.80
offsetMethod · 0.80
decode_startMethod · 0.80
get_signalHeightMethod · 0.80
shownMethod · 0.80
get_rows_gshowMethod · 0.80
has_annotationsMethod · 0.80
emptyMethod · 0.80
samplerateMethod · 0.45
clearMethod · 0.45
decode_endMethod · 0.45

Tested by

no test coverage detected