From bed8de2ad6f2765bc7c005899252708c72af2596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 17 Mar 2014 16:58:04 +0100 Subject: force explicit types --- include/llmr/text/collision.hpp | 16 ++++++++-------- include/llmr/text/rotation_range.hpp | 11 +++++++---- src/text/collision.cpp | 8 ++++---- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/llmr/text/collision.hpp b/include/llmr/text/collision.hpp index a4932ca4b5..02369b3f9d 100644 --- a/include/llmr/text/collision.hpp +++ b/include/llmr/text/collision.hpp @@ -12,9 +12,9 @@ namespace llmr { // These are the glyph boxes that we want to have placed. struct GlyphBox { - GlyphBox() {} - GlyphBox(const CollisionRect &bbox, const CollisionRect &box, - float minScale) + explicit GlyphBox() {} + explicit GlyphBox(const CollisionRect &bbox, const CollisionRect &box, + float minScale) : bbox(bbox), box(box), minScale(minScale) {} CollisionAnchor anchor; @@ -40,8 +40,8 @@ struct PlacementBox { }; struct Placement { - Placement() {} - Placement(float zoom, const PlacementRange &rotationRange) + explicit Placement() {} + explicit Placement(float zoom, const PlacementRange &rotationRange) : zoom(zoom), rotationRange(rotationRange) {} float zoom = -1.0f; @@ -56,7 +56,7 @@ class Collision { typedef boost::geometry::index::rtree< PlacementValue, boost::geometry::index::quadratic<16>> Tree; - public: +public: Collision(); Placement place(const GlyphBoxes &boxes, const CollisionAnchor &anchor, @@ -70,9 +70,9 @@ class Collision { float placementScale, const PlacementRange &placementRange, bool horizontal, float padding); - private: +private: Tree tree; }; } -#endif \ No newline at end of file +#endif diff --git a/include/llmr/text/rotation_range.hpp b/include/llmr/text/rotation_range.hpp index bf40c0c6a2..9999b1ade7 100644 --- a/include/llmr/text/rotation_range.hpp +++ b/include/llmr/text/rotation_range.hpp @@ -23,11 +23,14 @@ typedef std::array CollisionCorners; struct CollisionRect { CollisionPoint tl; CollisionPoint br; - inline CollisionRect() {} - inline CollisionRect(CollisionPoint::Type ax, CollisionPoint::Type ay, - CollisionPoint::Type bx, CollisionPoint::Type by) + inline explicit CollisionRect() {} + inline explicit CollisionRect(CollisionPoint::Type ax, + CollisionPoint::Type ay, + CollisionPoint::Type bx, + CollisionPoint::Type by) : tl(ax, ay), br(bx, by) {} - inline CollisionRect(const CollisionPoint &tl, const CollisionPoint &br) + inline explicit CollisionRect(const CollisionPoint &tl, + const CollisionPoint &br) : tl(tl), br(br) {} }; diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 6947635609..42083a3512 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -32,7 +32,7 @@ GlyphBox getMergedGlyphs(const GlyphBoxes &glyphs, bool horizontal, const CollisionAnchor &anchor) { GlyphBox mergedGlyphs; const float inf = std::numeric_limits::infinity(); - mergedGlyphs.box = {{inf, inf}, {-inf, -inf}}; + mergedGlyphs.box = CollisionRect{{inf, inf}, {-inf, -inf}}; mergedGlyphs.rotate = horizontal; mergedGlyphs.anchor = anchor; @@ -80,7 +80,7 @@ Placement Collision::place(const GlyphBoxes &boxes, diag = sqrt( util::max(x12 + y12, x12 + y22, x22 + y12, x22 + y22)); - glyph.bbox = {{-diag, -diag}, {diag, diag}}; + glyph.bbox = CollisionRect{{-diag, -diag}, {diag, diag}}; } else { glyph.bbox = glyph.box; } @@ -93,7 +93,7 @@ Placement Collision::place(const GlyphBoxes &boxes, // Return if the label can never be placed without collision if (scale < 0) - return {}; + return Placement{}; // Calculate the range it is safe to rotate all glyphs PlacementRange rotationRange = getPlacementRange(glyphs, scale); @@ -101,7 +101,7 @@ Placement Collision::place(const GlyphBoxes &boxes, float zoom = log(scale) / log(2); - return {zoom, rotationRange}; + return Placement{zoom, rotationRange}; } float Collision::getPlacementScale(const GlyphBoxes &glyphs, -- cgit v1.2.1