comparison layer/NoteLayer.cpp @ 667:2727bc3aab59

Avoid reloading the default 0->0 scale extents for a note layer as 0->1
author Chris Cannam
date Tue, 16 Jul 2013 17:51:37 +0100
parents ab9fefdaa103
children 47735c9518e7 1a0dfcbffaf1
comparison
equal deleted inserted replaced
666:12e6efc8cdc0 667:2727bc3aab59
234 if (shouldConvertMIDIToHz()) { 234 if (shouldConvertMIDIToHz()) {
235 min = Pitch::getFrequencyForPitch(lrintf(min)); 235 min = Pitch::getFrequencyForPitch(lrintf(min));
236 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 236 max = Pitch::getFrequencyForPitch(lrintf(max + 1));
237 } 237 }
238 238
239 #ifdef DEBUG_NOTE_LAYER
240 std::cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << std::endl;
241 #endif
242
239 return true; 243 return true;
240 } 244 }
241 245
242 bool 246 bool
243 NoteLayer::setDisplayExtents(float min, float max) 247 NoteLayer::setDisplayExtents(float min, float max)
253 } 257 }
254 258
255 m_scaleMinimum = min; 259 m_scaleMinimum = min;
256 m_scaleMaximum = max; 260 m_scaleMaximum = max;
257 261
258 // SVDEBUG << "NoteLayer::setDisplayExtents: min = " << min << ", max = " << max << endl; 262 #ifdef DEBUG_NOTE_LAYER
263 std::cerr << "NoteLayer::setDisplayExtents: min = " << min << ", max = " << max << std::endl;
264 #endif
259 265
260 emit layerParametersChanged(); 266 emit layerParametersChanged();
261 return true; 267 return true;
262 } 268 }
263 269
334 } 340 }
335 if (newmax > max) { 341 if (newmax > max) {
336 newmax = max; 342 newmax = max;
337 } 343 }
338 344
339 SVDEBUG << "NoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; 345 #ifdef DEBUG_NOTE_LAYER
346 std::cerr << "NoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << std::endl;
347 #endif
340 348
341 setDisplayExtents(newmin, newmax); 349 setDisplayExtents(newmin, newmax);
342 } 350 }
343 351
344 RangeMapper * 352 RangeMapper *
1276 attributes.value("verticalScale").toInt(&ok); 1284 attributes.value("verticalScale").toInt(&ok);
1277 if (ok) setVerticalScale(scale); 1285 if (ok) setVerticalScale(scale);
1278 1286
1279 float min = attributes.value("scaleMinimum").toFloat(&ok); 1287 float min = attributes.value("scaleMinimum").toFloat(&ok);
1280 float max = attributes.value("scaleMaximum").toFloat(&alsoOk); 1288 float max = attributes.value("scaleMaximum").toFloat(&alsoOk);
1281 if (ok && alsoOk) setDisplayExtents(min, max); 1289 if (ok && alsoOk && min != max) setDisplayExtents(min, max);
1282 } 1290 }
1283 1291
1284 1292