Mercurial > hg > svgui
comparison layer/Layer.cpp @ 274:b9380f679f70
* Fix centre line position
* Fix failure to update overview when generating peaks from wav file
* Provide y-coordinate scale values and differences for spectrum measurement
mode, and fix values for waveform (inc dB for both)
* Add Printer colour scheme (may be futile)
author | Chris Cannam |
---|---|
date | Mon, 02 Jul 2007 13:04:17 +0000 |
parents | e954c00cbe55 |
children | 3c402c6052f6 |
comparison
equal
deleted
inserted
replaced
273:e954c00cbe55 | 274:b9380f679f70 |
---|---|
117 const Model *m = getModel(); | 117 const Model *m = getModel(); |
118 if (!m) return false; | 118 if (!m) return false; |
119 | 119 |
120 value = float(v->getFrameForX(x)) / m->getSampleRate(); | 120 value = float(v->getFrameForX(x)) / m->getSampleRate(); |
121 unit = "s"; | 121 unit = "s"; |
122 return true; | |
123 } | |
124 | |
125 bool | |
126 Layer::getYScaleDifference(const View *v, int y0, int y1, | |
127 float &diff, QString &unit) const | |
128 { | |
129 float v0, v1; | |
130 if (!getYScaleValue(v, y0, v0, unit) || | |
131 !getYScaleValue(v, y1, v1, unit)) { | |
132 diff = 0.f; | |
133 return false; | |
134 } | |
135 diff = fabsf(v1 - v0); | |
122 return true; | 136 return true; |
123 } | 137 } |
124 | 138 |
125 bool | 139 bool |
126 Layer::MeasureRect::operator<(const MeasureRect &mr) const | 140 Layer::MeasureRect::operator<(const MeasureRect &mr) const |
234 if (!m_haveDraggingRect) return; | 248 if (!m_haveDraggingRect) return; |
235 | 249 |
236 m_draggingRect.pixrect = QRect(m_draggingRect.pixrect.x(), | 250 m_draggingRect.pixrect = QRect(m_draggingRect.pixrect.x(), |
237 m_draggingRect.pixrect.y(), | 251 m_draggingRect.pixrect.y(), |
238 e->x() - m_draggingRect.pixrect.x(), | 252 e->x() - m_draggingRect.pixrect.x(), |
239 e->y() - m_draggingRect.pixrect.y()) | 253 e->y() - m_draggingRect.pixrect.y()); |
240 .normalized(); | |
241 | 254 |
242 setMeasureRectYCoord(v, m_draggingRect, false, e->y()); | 255 setMeasureRectYCoord(v, m_draggingRect, false, e->y()); |
243 | 256 |
244 if (hasTimeXAxis()) { | 257 if (hasTimeXAxis()) { |
245 m_draggingRect.endFrame = v->getFrameForX(e->x()); | 258 m_draggingRect.endFrame = v->getFrameForX(e->x()); |
326 } | 339 } |
327 | 340 |
328 i->pixrect = QRect(x0, i->pixrect.y(), x1 - x0, i->pixrect.height()); | 341 i->pixrect = QRect(x0, i->pixrect.y(), x1 - x0, i->pixrect.height()); |
329 | 342 |
330 updateMeasureRectYCoords(v, *i); | 343 updateMeasureRectYCoords(v, *i); |
331 | |
332 i->pixrect = i->pixrect.normalized(); | |
333 } | 344 } |
334 } | 345 } |
335 | 346 |
336 void | 347 void |
337 Layer::updateMeasureRectYCoords(View *v, const MeasureRect &r) const | 348 Layer::updateMeasureRectYCoords(View *v, const MeasureRect &r) const |
394 if (r.endFrame <= long(v->getEndFrame())) { | 405 if (r.endFrame <= long(v->getEndFrame())) { |
395 x1 = v->getXForFrame(r.endFrame); | 406 x1 = v->getXForFrame(r.endFrame); |
396 } | 407 } |
397 | 408 |
398 QRect pr = QRect(x0, r.pixrect.y(), x1 - x0, r.pixrect.height()); | 409 QRect pr = QRect(x0, r.pixrect.y(), x1 - x0, r.pixrect.height()); |
399 | |
400 r.pixrect = pr; | 410 r.pixrect = pr; |
401 } | 411 } |
402 | 412 |
403 v->drawMeasurementRect(paint, this, r.pixrect, focus); | 413 v->drawMeasurementRect(paint, this, r.pixrect.normalized(), focus); |
404 } | 414 } |
405 | 415 |
406 QString | 416 QString |
407 Layer::toXmlString(QString indent, QString extraAttributes) const | 417 Layer::toXmlString(QString indent, QString extraAttributes) const |
408 { | 418 { |