comparison layer/SpectrogramLayer.cpp @ 273:e954c00cbe55

* proper (though ugly) handling of y coord for measure rects in scrollable layers
author Chris Cannam
date Fri, 29 Jun 2007 16:50:59 +0000
parents 4ed1446ad604
children 8acd30ed735c
comparison
equal deleted inserted replaced
272:87e4c880b4c8 273:e954c00cbe55
3064 { 3064 {
3065 if (!m_model) return 0; 3065 if (!m_model) return 0;
3066 return new SpectrogramRangeMapper(m_model->getSampleRate(), m_fftSize); 3066 return new SpectrogramRangeMapper(m_model->getSampleRate(), m_fftSize);
3067 } 3067 }
3068 3068
3069 void
3070 SpectrogramLayer::updateMeasureRectYCoords(View *v, const MeasureRect &r) const
3071 {
3072 int y0 = 0;
3073 if (r.startY > 0.0) y0 = getYForFrequency(v, r.startY);
3074
3075 int y1 = y0;
3076 if (r.endY > 0.0) y1 = getYForFrequency(v, r.endY);
3077
3078 // std::cerr << "SpectrogramLayer::updateMeasureRectYCoords: start " << r.startY << " -> " << y0 << ", end " << r.endY << " -> " << y1 << std::endl;
3079
3080 r.pixrect = QRect(r.pixrect.x(), y0, r.pixrect.width(), y1 - y0);
3081 }
3082
3083 void
3084 SpectrogramLayer::setMeasureRectYCoord(View *v, MeasureRect &r, bool start, int y) const
3085 {
3086 if (start) {
3087 r.startY = getFrequencyForY(v, y);
3088 r.endY = r.startY;
3089 } else {
3090 r.endY = getFrequencyForY(v, y);
3091 }
3092 // std::cerr << "SpectrogramLayer::setMeasureRectYCoord: start " << r.startY << " <- " << y << ", end " << r.endY << " <- " << y << std::endl;
3093
3094 }
3095
3069 QString 3096 QString
3070 SpectrogramLayer::toXmlString(QString indent, QString extraAttributes) const 3097 SpectrogramLayer::toXmlString(QString indent, QString extraAttributes) const
3071 { 3098 {
3072 QString s; 3099 QString s;
3073 3100