Optimization and coding standard

This commit is contained in:
David Rowe 2014-11-13 11:06:40 -08:00
parent f0f12b0479
commit 8d4cecda62
2 changed files with 11 additions and 10 deletions

View file

@ -358,18 +358,19 @@ bool Overlays::isLoaded(unsigned int id) {
return overlay->isLoaded();
}
float Overlays::textWidth(unsigned int id, const QString& text) {
if (_overlays2D.contains(id)) {
Overlay* thisOverlay = _overlays2D[id];
const float Overlays::textWidth(unsigned int id, const QString& text) {
Overlay* thisOverlay = _overlays2D[id];
if (thisOverlay) {
if (typeid(*thisOverlay) == typeid(TextOverlay)) {
return static_cast<TextOverlay*>(thisOverlay)->textWidth(text);
}
}
if (_overlays3D.contains(id)) {
Overlay* thisOverlay = _overlays3D[id];
if (typeid(*thisOverlay) == typeid(Text3DOverlay)) {
return static_cast<Text3DOverlay*>(thisOverlay)->textWidth(text);
} else {
thisOverlay = _overlays3D[id];
if (thisOverlay) {
if (typeid(*thisOverlay) == typeid(Text3DOverlay)) {
return static_cast<Text3DOverlay*>(thisOverlay)->textWidth(text);
}
}
}
return 0.f;
return 0.0f;
}

View file

@ -67,7 +67,7 @@ public slots:
/// returns the width of the given text in the specified overlay if it is a text overlay: in pixels if it is a 2D text
/// overlay; in meters if it is a 3D text overlay
float textWidth(unsigned int id, const QString& text);
const float textWidth(unsigned int id, const QString& text);
private:
QMap<unsigned int, Overlay*> _overlays2D;