comparison view/View.cpp @ 1537:4f8c72adbf43

Clarify naming of some view-related methods. Rename LayerGeometryProvider::getValueExtents to getVisibleExtentsForUnit, and View::getTextLabelHeight to getTextLabelYCoord. Add View::getVisibleExtentsForAnyUnit to be used to determine which unit to adopt in a new e.g. box layer.
author Chris Cannam
date Tue, 15 Oct 2019 11:40:56 +0100
parents 395ef06beab1
children bfacecf7ea7e
comparison
equal deleted inserted replaced
1536:5a215033b853 1537:4f8c72adbf43
191 if (i == 0) return m_propertyContainer; 191 if (i == 0) return m_propertyContainer;
192 return m_fixedOrderLayers[i-1]; 192 return m_fixedOrderLayers[i-1];
193 } 193 }
194 194
195 bool 195 bool
196 View::getValueExtents(QString unit, double &min, double &max, bool &log) const 196 View::getVisibleExtentsForUnit(QString unit,
197 double &min, double &max,
198 bool &log) const
197 { 199 {
198 bool have = false; 200 bool have = false;
199 201
200 for (LayerList::const_iterator i = m_layerStack.begin(); 202 // Iterate in reverse order, so as to return display extents of
201 i != m_layerStack.end(); ++i) { 203 // topmost layer that fits the bill
202 204
205 for (auto i = m_layerStack.rbegin(); i != m_layerStack.rend(); ++i) {
206
207 Layer *layer = *i;
208
209 if (layer->isLayerDormant(this)) {
210 continue;
211 }
212
203 QString layerUnit; 213 QString layerUnit;
204 double layerMin = 0.0, layerMax = 0.0; 214 double layerMin = 0.0, layerMax = 0.0;
215 bool layerLog = false;
216
217 if (!layer->getValueExtents(layerMin, layerMax, layerLog, layerUnit)) {
218 continue;
219 }
220 if (layerUnit.toLower() != unit.toLower()) {
221 continue;
222 }
223
205 double displayMin = 0.0, displayMax = 0.0; 224 double displayMin = 0.0, displayMax = 0.0;
225
226 if (layer->getDisplayExtents(displayMin, displayMax)) {
227
228 min = displayMin;
229 max = displayMax;
230 log = layerLog;
231 have = true;
232 break;
233
234 } else {
235
236 if (!have || layerMin < min) min = layerMin;
237 if (!have || layerMax > max) max = layerMax;
238 if (!have && layerLog) log = true;
239 have = true;
240 }
241 }
242
243 return have;
244 }
245
246 bool
247 View::getVisibleExtentsForAnyUnit(double &min, double &max,
248 bool &log, QString &unit) const
249 {
250 bool have = false;
251
252 // Iterate in reverse order, so as to return display extents of
253 // topmost layer that fits the bill
254
255 for (auto i = m_layerStack.rbegin(); i != m_layerStack.rend(); ++i) {
256
257 Layer *layer = *i;
258
259 if (layer->isLayerDormant(this)) {
260 continue;
261 }
262
263 QString layerUnit;
264 double layerMin = 0.0, layerMax = 0.0;
206 bool layerLog = false; 265 bool layerLog = false;
207 266
208 if ((*i)->getValueExtents(layerMin, layerMax, layerLog, layerUnit) && 267 if (!layer->getValueExtents(layerMin, layerMax, layerLog, layerUnit)) {
209 layerUnit.toLower() == unit.toLower()) { 268 continue;
210 269 }
211 if ((*i)->getDisplayExtents(displayMin, displayMax)) { 270 if (layerUnit == "") {
212 271 continue;
213 min = displayMin; 272 }
214 max = displayMax; 273
215 log = layerLog; 274 double displayMin = 0.0, displayMax = 0.0;
216 have = true; 275
217 break; 276 if (layer->getDisplayExtents(displayMin, displayMax)) {
218 277
219 } else { 278 min = displayMin;
220 279 max = displayMax;
221 if (!have || layerMin < min) min = layerMin; 280 log = layerLog;
222 if (!have || layerMax > max) max = layerMax; 281 unit = layerUnit;
223 if (layerLog) log = true; 282 have = true;
224 have = true; 283 break;
225 }
226 } 284 }
227 } 285 }
228 286
229 return have; 287 return have;
230 } 288 }
231 289
232 int 290 int
233 View::getTextLabelHeight(const Layer *layer, QPainter &paint) const 291 View::getTextLabelYCoord(const Layer *layer, QPainter &paint) const
234 { 292 {
235 std::map<int, Layer *> sortedLayers; 293 std::map<int, Layer *> sortedLayers;
236 294
237 for (LayerList::const_iterator i = m_layerStack.begin(); 295 for (LayerList::const_iterator i = m_layerStack.begin();
238 i != m_layerStack.end(); ++i) { 296 i != m_layerStack.end(); ++i) {