Mercurial > hg > svgui
comparison view/View.cpp @ 1548:bd6af89982d7
Permit getScaleProvidingLayerForUnit to return a dormant layer if there is no visible alternative. This is necessary to avoid the scale disappearing in Tony when the spectrogram is toggled off.
author | Chris Cannam |
---|---|
date | Thu, 17 Oct 2019 14:44:22 +0100 |
parents | b4b5b8dd5fe1 |
children | 27f3e64489e1 |
comparison
equal
deleted
inserted
replaced
1547:e6362cf5ff1d | 1548:bd6af89982d7 |
---|---|
245 Layer * | 245 Layer * |
246 View::getScaleProvidingLayerForUnit(QString unit) const | 246 View::getScaleProvidingLayerForUnit(QString unit) const |
247 { | 247 { |
248 // Return the layer which is used to provide the min/max/log for | 248 // Return the layer which is used to provide the min/max/log for |
249 // any auto-align layer of a given unit. This is also the layer | 249 // any auto-align layer of a given unit. This is also the layer |
250 // that will draw the scale, if possible. It is the topmost | 250 // that will draw the scale, if possible. |
251 // visible layer having that unit that is not also auto-aligning. | 251 // |
252 // If there is none such, return null. | 252 // The returned layer is |
253 // | |
254 // - the topmost visible layer having that unit that is not also | |
255 // auto-aligning; or if there is no such layer, | |
256 // | |
257 // - the topmost layer of any visibility having that unit that is | |
258 // not also auto-aligning (because a dormant layer can still draw | |
259 // a scale, and it makes sense for layers aligned to it not to | |
260 // jump about when its visibility is toggled); or if there is no | |
261 // such layer, | |
262 // | |
263 // - none | |
264 | |
265 Layer *dormantOption = nullptr; | |
253 | 266 |
254 for (auto i = m_layerStack.rbegin(); i != m_layerStack.rend(); ++i) { | 267 for (auto i = m_layerStack.rbegin(); i != m_layerStack.rend(); ++i) { |
255 | 268 |
256 Layer *layer = *i; | 269 Layer *layer = *i; |
257 | 270 |
258 #ifdef DEBUG_VIEW_SCALE_CHOICE | 271 #ifdef DEBUG_VIEW_SCALE_CHOICE |
259 SVCERR << "View[" << getId() << "]::getScaleProvidingLayerForUnit(" | 272 SVCERR << "View[" << getId() << "]::getScaleProvidingLayerForUnit(" |
260 << unit << "): Looking at layer " << layer | 273 << unit << "): Looking at layer " << layer |
261 << " (" << layer->getLayerPresentationName() << ")" << endl; | 274 << " (" << layer->getLayerPresentationName() << ")" << endl; |
262 #endif | 275 #endif |
263 | |
264 if (layer->isLayerDormant(this)) { | |
265 #ifdef DEBUG_VIEW_SCALE_CHOICE | |
266 SVCERR << "... it's dormant" << endl; | |
267 #endif | |
268 continue; | |
269 } | |
270 | 276 |
271 QString layerUnit; | 277 QString layerUnit; |
272 double layerMin = 0.0, layerMax = 0.0; | 278 double layerMin = 0.0, layerMax = 0.0; |
273 bool layerLog = false; | 279 bool layerLog = false; |
274 | 280 |
276 #ifdef DEBUG_VIEW_SCALE_CHOICE | 282 #ifdef DEBUG_VIEW_SCALE_CHOICE |
277 SVCERR << "... it has no value extents" << endl; | 283 SVCERR << "... it has no value extents" << endl; |
278 #endif | 284 #endif |
279 continue; | 285 continue; |
280 } | 286 } |
287 | |
281 if (layerUnit.toLower() != unit.toLower()) { | 288 if (layerUnit.toLower() != unit.toLower()) { |
282 #ifdef DEBUG_VIEW_SCALE_CHOICE | 289 #ifdef DEBUG_VIEW_SCALE_CHOICE |
283 SVCERR << "... it has the wrong unit (" << layerUnit << ")" << endl; | 290 SVCERR << "... it has the wrong unit (" << layerUnit << ")" << endl; |
284 #endif | 291 #endif |
285 continue; | 292 continue; |
291 SVCERR << "... it has no display extents (is auto-aligning or not alignable)" << endl; | 298 SVCERR << "... it has no display extents (is auto-aligning or not alignable)" << endl; |
292 #endif | 299 #endif |
293 continue; | 300 continue; |
294 } | 301 } |
295 | 302 |
303 if (layer->isLayerDormant(this)) { | |
304 #ifdef DEBUG_VIEW_SCALE_CHOICE | |
305 SVCERR << "... it's dormant" << endl; | |
306 #endif | |
307 if (!dormantOption) { | |
308 dormantOption = layer; | |
309 } | |
310 continue; | |
311 } | |
312 | |
296 #ifdef DEBUG_VIEW_SCALE_CHOICE | 313 #ifdef DEBUG_VIEW_SCALE_CHOICE |
297 SVCERR << "... it's good" << endl; | 314 SVCERR << "... it's good" << endl; |
298 #endif | 315 #endif |
299 | |
300 return layer; | 316 return layer; |
301 } | 317 } |
302 | 318 |
303 return nullptr; | 319 return dormantOption; |
304 } | 320 } |
305 | 321 |
306 bool | 322 bool |
307 View::getVisibleExtentsForAnyUnit(double &min, double &max, | 323 View::getVisibleExtentsForAnyUnit(double &min, double &max, |
308 bool &log, QString &unit) const | 324 bool &log, QString &unit) const |