From bf6a6001f9e82abd3aac25d8b7d3e559b0c98bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 17 Mar 2014 16:54:14 +0100 Subject: [PATCH] format fixes --- include/llmr/text/collision.hpp | 4 ++-- src/text/collision.cpp | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/llmr/text/collision.hpp b/include/llmr/text/collision.hpp index d207a0866..a4932ca4b 100644 --- a/include/llmr/text/collision.hpp +++ b/include/llmr/text/collision.hpp @@ -60,8 +60,8 @@ class Collision { Collision(); Placement place(const GlyphBoxes &boxes, const CollisionAnchor &anchor, - float minPlacementScale, float maxPlacementScale, float padding, - bool horizontal); + float minPlacementScale, float maxPlacementScale, + float padding, bool horizontal); float getPlacementScale(const GlyphBoxes &glyphs, float minPlacementScale, float maxPlacementScale, float pad); PlacementRange getPlacementRange(const GlyphBoxes &glyphs, diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 750495dc5..694763560 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -28,22 +28,23 @@ Collision::Collision() { CollisionAnchor{m, m}, 1, {{M_PI * 2, 0}}, false, 2); } - -GlyphBox getMergedGlyphs(const GlyphBoxes &glyphs, bool horizontal, const CollisionAnchor& anchor) { +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 = {{inf, inf}, {-inf, -inf}}; mergedGlyphs.rotate = horizontal; mergedGlyphs.anchor = anchor; - CollisionRect& box = mergedGlyphs.box; - for (const GlyphBox& glyph : glyphs) { - const CollisionRect& gbox = glyph.box; + CollisionRect &box = mergedGlyphs.box; + for (const GlyphBox &glyph : glyphs) { + const CollisionRect &gbox = glyph.box; box.tl.x = util::min(box.tl.x, gbox.tl.x); box.tl.y = util::min(box.tl.y, gbox.tl.y); box.br.x = util::max(box.br.x, gbox.br.x); box.br.y = util::max(box.br.y, gbox.br.y); - mergedGlyphs.minScale = util::max(mergedGlyphs.minScale, glyph.minScale); + mergedGlyphs.minScale = + util::max(mergedGlyphs.minScale, glyph.minScale); } return mergedGlyphs; @@ -55,7 +56,7 @@ Placement Collision::place(const GlyphBoxes &boxes, float padding, bool horizontal) { float minScale = std::numeric_limits::infinity(); - for (const GlyphBox& box : boxes) { + for (const GlyphBox &box : boxes) { minScale = util::min(minScale, box.minScale); } minPlacementScale = util::max(minPlacementScale, minScale); @@ -85,11 +86,14 @@ Placement Collision::place(const GlyphBoxes &boxes, } } - // Calculate the minimum scale the entire label can be shown without collisions - float scale = getPlacementScale(boxes, minPlacementScale, maxPlacementScale, padding); + // Calculate the minimum scale the entire label can be shown without + // collisions + float scale = + getPlacementScale(boxes, minPlacementScale, maxPlacementScale, padding); // Return if the label can never be placed without collision - if (scale < 0) return {}; + if (scale < 0) + return {}; // Calculate the range it is safe to rotate all glyphs PlacementRange rotationRange = getPlacementRange(glyphs, scale); @@ -100,7 +104,6 @@ Placement Collision::place(const GlyphBoxes &boxes, return {zoom, rotationRange}; } - float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementScale, float maxPlacementScale, float pad) {