Mercurial > hg > svgui
comparison layer/SpectrumLayer.cpp @ 264:7e9e533f1863
* few more measurement mode bits
author | Chris Cannam |
---|---|
date | Fri, 15 Jun 2007 12:55:16 +0000 |
parents | 6d113226bb4c |
children | a3a54632cd4c |
comparison
equal
deleted
inserted
replaced
263:16fffa24da02 | 264:7e9e533f1863 |
---|---|
253 SpectrumLayer::getValueExtents(float &, float &, bool &, QString &) const | 253 SpectrumLayer::getValueExtents(float &, float &, bool &, QString &) const |
254 { | 254 { |
255 return false; | 255 return false; |
256 } | 256 } |
257 | 257 |
258 bool | |
259 SpectrumLayer::getCrosshairExtents(View *v, QPainter &, | |
260 QPoint cursorPos, | |
261 std::vector<QRect> &extents) const | |
262 { | |
263 QRect vertical(cursorPos.x(), cursorPos.y(), 1, v->height() - cursorPos.y()); | |
264 extents.push_back(vertical); | |
265 | |
266 QRect horizontal(0, cursorPos.y(), v->width(), 12); | |
267 extents.push_back(horizontal); | |
268 | |
269 return true; | |
270 } | |
271 | |
272 float | 258 float |
273 SpectrumLayer::getFrequencyForX(float x, float w) const | 259 SpectrumLayer::getFrequencyForX(float x, float w) const |
274 { | 260 { |
275 float freq = 0; | 261 float freq = 0; |
276 | 262 |
325 | 311 |
326 bool | 312 bool |
327 SpectrumLayer::getXScaleValue(View *v, int x, | 313 SpectrumLayer::getXScaleValue(View *v, int x, |
328 float &value, QString &unit) const | 314 float &value, QString &unit) const |
329 { | 315 { |
330 value = getFrequencyForX(x, v->width() - m_xorigins[v]); | 316 value = getFrequencyForX(x - m_xorigins[v], v->width() - m_xorigins[v] - 1); |
331 unit = "Hz"; | 317 unit = "Hz"; |
332 return true; | 318 return true; |
333 } | 319 } |
334 | 320 |
321 bool | |
322 SpectrumLayer::getCrosshairExtents(View *v, QPainter &paint, | |
323 QPoint cursorPos, | |
324 std::vector<QRect> &extents) const | |
325 { | |
326 QRect vertical(cursorPos.x(), cursorPos.y(), 1, v->height() - cursorPos.y()); | |
327 extents.push_back(vertical); | |
328 | |
329 QRect horizontal(0, cursorPos.y(), v->width(), 12); | |
330 extents.push_back(horizontal); | |
331 | |
332 QRect label(cursorPos.x(), v->height() - paint.fontMetrics().height(), | |
333 paint.fontMetrics().width("123456 Hz") + 2, | |
334 paint.fontMetrics().height()); | |
335 extents.push_back(label); | |
336 | |
337 return true; | |
338 } | |
339 | |
335 void | 340 void |
336 SpectrumLayer::paintCrosshairs(View *v, QPainter &paint, | 341 SpectrumLayer::paintCrosshairs(View *v, QPainter &paint, |
337 QPoint cursorPos) const | 342 QPoint cursorPos) const |
338 { | 343 { |
339 paint.save(); | 344 paint.save(); |
346 | 351 |
347 paint.drawLine(xorigin, cursorPos.y(), v->width(), cursorPos.y()); | 352 paint.drawLine(xorigin, cursorPos.y(), v->width(), cursorPos.y()); |
348 paint.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), v->height()); | 353 paint.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), v->height()); |
349 | 354 |
350 float fundamental = getFrequencyForX(cursorPos.x() - xorigin, w); | 355 float fundamental = getFrequencyForX(cursorPos.x() - xorigin, w); |
356 | |
357 paint.drawText(cursorPos.x() + 2, v->height() - 2, | |
358 QString("%1 Hz").arg(fundamental)); | |
351 | 359 |
352 int harmonic = 2; | 360 int harmonic = 2; |
353 | 361 |
354 while (harmonic < 100) { | 362 while (harmonic < 100) { |
355 | 363 |