| 241 | } |
| 242 | |
| 243 | bool 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 | |
| 272 | void SpectrumTrace::paint_back(QPainter &p, int left, int right, QColor fore, QColor back) |
nothing calls this directly
no test coverage detected