MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / paint_mid_align

Method paint_mid_align

DSView/pv/view/logicsignal.cpp:108–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void LogicSignal::paint_mid_align(QPainter &p, int left, int right, QColor fore, QColor back, uint64_t end_align_sample)
109{
110 using pv::view::View;
111
112 (void)back;
113
114 assert(_data);
115 assert(_view);
116 assert(right >= left);
117
118 const int y = get_y() + _totalHeight * 0.5;
119 const double scale = _view->scale();
120 assert(scale > 0);
121 const int64_t offset = _view->offset();
122
123 const int high_offset = y - _totalHeight + 0.5f;
124 const int low_offset = y + 0.5f;
125
126 double samplerate = _data->samplerate();
127 if (_data->empty() || samplerate == 0)
128 return;
129
130 if (!_data->has_data(_probe->index))
131 return;
132
133 if (end_align_sample >= _data->get_ring_sample_count())
134 end_align_sample = _data->get_ring_sample_count() - 1;
135
136 const int64_t last_sample = end_align_sample;
137 const double samples_per_pixel = samplerate * scale;
138
139 uint16_t width = right - left;
140 const double start = offset * samples_per_pixel;
141 const double end = (offset + width + 1) * samples_per_pixel;
142 const uint64_t end_index = min(max((int64_t)floor(end), (int64_t)0), last_sample);
143 const uint64_t start_index = max((uint64_t)floor(start), (uint64_t)0);
144
145 if (start_index > end_index)
146 return;
147
148 width = min(width, (uint16_t)ceil((end_index + 1)/samples_per_pixel - offset));
149 const uint16_t max_togs = width / TogMaxScale;
150
151 const bool first_sample = _data->get_display_edges(_cur_pulses, _cur_edges,
152 start_index, end_index, width, max_togs,
153 offset,
154 samples_per_pixel, _probe->index);
155 assert(_cur_pulses.size() >= width);
156
157 int preX = 0;
158 int preY = first_sample ? high_offset : low_offset;
159 int x = preX;
160 std::vector<QLine> wave_lines;
161
162 if (_cur_edges.size() < max_togs) {
163 std::vector<std::pair<uint16_t, bool>>::const_iterator i;
164 for (i = _cur_edges.begin() + 1; i != _cur_edges.end() - 1; i++) {
165 x = (*i).first;

Callers

nothing calls this directly

Calls 10

scaleMethod · 0.80
offsetMethod · 0.80
emptyMethod · 0.80
get_display_edgesMethod · 0.80
sizeMethod · 0.80
samplerateMethod · 0.45
has_dataMethod · 0.45
get_ring_sample_countMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected