Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 1544:2d4107270015
Return true from getValueExtents always, just with no unit in the case where we don't have a nice neat scale. This should preserve the property of preventing other layers auto-aligning to us, while also ensuring we don't get overlooked for the purposes of drawing our own scale in a situation where a scale-less layer is on top of us
author | Chris Cannam |
---|---|
date | Wed, 16 Oct 2019 13:02:52 +0100 |
parents | 10fe8124dc17 |
children | a6e37c28d762 |
comparison
equal
deleted
inserted
replaced
1543:35c7b7a592f0 | 1544:2d4107270015 |
---|---|
353 | 353 |
354 bool | 354 bool |
355 WaveformLayer::getValueExtents(double &min, double &max, | 355 WaveformLayer::getValueExtents(double &min, double &max, |
356 bool &log, QString &unit) const | 356 bool &log, QString &unit) const |
357 { | 357 { |
358 unit = "V"; | 358 // This function serves two purposes. It's used to gather min and |
359 | 359 // max values for a given unit, for cases where there are |
360 // There is no point in returning extents here unless we have a | 360 // auto-align layers out there that aren't providing extents of |
361 // scale that anyone else can actually calculate with, which is | 361 // their own and that have no specific other layer with display |
362 // only the case if getDisplayExtents is returning successfully | 362 // extents to align to. It's also used to determine whether a |
363 // layer might be capable of drawing a scale for itself. | |
364 // | |
365 // This makes our situation a bit tricky. There's no point in | |
366 // returning extents that anyone else might try to align to unless | |
367 // we have a scale that they can actually calculate with, which is | |
368 // only the case for certain linear/log arrangements (see | |
369 // getDisplayExtents - we can test this case by checking whether | |
370 // getDisplayExtents returns successfully). | |
371 // | |
372 // However, there is a point in returning something that indicates | |
373 // our own capacity to draw a scale. If we don't do that, then we | |
374 // won't get a scale at all if e.g. we have a time-instant layer | |
375 // on top (or something else that doesn't care about the y axis). | |
376 // | |
377 // Our "solution" to this is to always return true and our | |
378 // extents, but with an empty unit unless we have the sort of nice | |
379 // linear/log scale that others can actually align to. | |
380 // | |
381 // It might be better to respond to capability requests - can draw | |
382 // scale, care about scale, can align unit X etc. | |
363 | 383 |
364 if (getDisplayExtents(min, max)) { | 384 if (getDisplayExtents(min, max)) { |
385 unit = "V"; | |
365 log = (m_scale == dBScale); | 386 log = (m_scale == dBScale); |
366 return true; | |
367 } else { | 387 } else { |
368 return false; | 388 max = 1.0; |
369 } | 389 min = -1.0; |
390 log = false; | |
391 unit = ""; | |
392 } | |
393 | |
394 return true; | |
370 } | 395 } |
371 | 396 |
372 bool | 397 bool |
373 WaveformLayer::getDisplayExtents(double &min, double &max) const | 398 WaveformLayer::getDisplayExtents(double &min, double &max) const |
374 { | 399 { |