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

Method measure

DSView/pv/view/spectrumtrace.cpp:243–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243bool SpectrumTrace::measure(const QPoint &p)
244{
245 _hover_en = false;
246 if(!_view || !enabled())
247 return false;
248
249 const QRect window = get_view_rect();
250 if (!window.contains(p))
251 return false;
252
253 const std::vector<double> samples(_spectrum_stack->get_fft_spectrum());
254 if(samples.empty())
255 return false;
256
257 const unsigned int full_size = (_spectrum_stack->get_sample_num()/2);
258 const double view_off = full_size * _offset;
259 const double view_size = full_size*_scale;
260 const double sample_per_pixels = view_size/window.width();
261 _hover_index = std::round(p.x() * sample_per_pixels + view_off);
262
263 if (_hover_index < full_size)
264 _hover_en = true;
265
266 //_view->set_update(_viewport, true);
267 _view->update();
268 return true;
269}
270
271
272void SpectrumTrace::paint_back(QPainter &p, int left, int right, QColor fore, QColor back)

Callers

nothing calls this directly

Calls 4

get_fft_spectrumMethod · 0.80
emptyMethod · 0.80
get_sample_numMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected