From 22178d6832115112656f145359d4acbd55770e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 20 Jan 2014 11:50:45 +0100 Subject: [PATCH] rename settings => Settings --- include/llmr/map/map.hpp | 4 ++-- include/llmr/map/settings.hpp | 12 +++++----- include/llmr/renderer/painter.hpp | 5 ++-- macosx/main.mm | 39 +++++++++++++++---------------- macosx/settings.hpp | 4 ++-- macosx/settings.mm | 8 +++---- src/map/map.cpp | 38 +++++++++++++++--------------- src/renderer/painter.cpp | 4 ++-- 8 files changed, 57 insertions(+), 57 deletions(-) diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 37fd9ab1e..109a8c709 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -13,7 +13,7 @@ namespace llmr { class map { public: - map(settings *settings); + map(Settings& settings); ~map(); void setup(); @@ -49,7 +49,7 @@ private: void update(); private: - settings *settings; + Settings& settings; transform *transform; painter *painter; diff --git a/include/llmr/map/settings.hpp b/include/llmr/map/settings.hpp index 3b236387b..8f2e12810 100644 --- a/include/llmr/map/settings.hpp +++ b/include/llmr/map/settings.hpp @@ -3,16 +3,16 @@ namespace llmr { -class settings { +class Settings { public: virtual void save() = 0; // Make noncopyable - settings() = default; - settings(const settings&) = delete; - settings(const settings&&) = delete; - settings &operator=(const settings&) = delete; - settings &operator=(const settings&&) = delete; + Settings() = default; + Settings(const Settings&) = delete; + Settings(const Settings&&) = delete; + Settings &operator=(const Settings&) = delete; + Settings &operator=(const Settings&&) = delete; public: // position diff --git a/include/llmr/renderer/painter.hpp b/include/llmr/renderer/painter.hpp index 9a16a2ee4..11535814c 100644 --- a/include/llmr/renderer/painter.hpp +++ b/include/llmr/renderer/painter.hpp @@ -1,6 +1,7 @@ #ifndef LLMR_RENDERER_PAINTER #define LLMR_RENDERER_PAINTER +#include "../map/settings.hpp" #include "shader-fill.hpp" #include "shader-line.hpp" #include "shader-outline.hpp" @@ -12,7 +13,7 @@ class tile; class painter { public: - painter(class transform *transform, class settings *settings); + painter(class transform *transform, Settings& settings); // Make noncopyable painter(const painter&) = delete; @@ -39,7 +40,7 @@ public: private: transform *transform; - settings *settings; + Settings& settings; float matrix[16]; Shader *currentShader; diff --git a/macosx/main.mm b/macosx/main.mm index 3f8d8a54f..b053da148 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -13,8 +13,8 @@ public: tracking(false), rotating(false), last_click(-1), - settings(new llmr::macosx_settings()), - map(new llmr::map(settings)) { + settings(), + map(settings) { } void init() { @@ -35,16 +35,16 @@ public: glfwMakeContextCurrent(window); - settings->load(); - map->setup(); + settings.load(); + map.setup(); int width, height; glfwGetWindowSize(window, &width, &height); - map->resize(width, height); + map.resize(width, height); glfwSwapInterval(1); - map->loadSettings(); + map.loadSettings(); glfwSetCursorPosCallback(window, mousemove); glfwSetMouseButtonCallback(window, mouseclick); @@ -70,13 +70,13 @@ public: glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_TAB: - view->map->toggleDebug(); + view->map.toggleDebug(); break; case GLFW_KEY_R: - if (!mods) view->map->resetPosition(); + if (!mods) view->map.resetPosition(); break; case GLFW_KEY_N: - if (!mods) view->map->resetNorth(); + if (!mods) view->map.resetNorth(); break; } } @@ -102,12 +102,12 @@ public: scale = 1.0 / scale; } - view->map->scaleBy(scale, view->last_x, view->last_y); + view->map.scaleBy(scale, view->last_x, view->last_y); } static void resize(GLFWwindow *window, int width, int height) { MapView *view = (MapView *)glfwGetWindowUserPointer(window); - view->map->resize(width, height); + view->map.resize(width, height); } static void mouseclick(GLFWwindow *window, int button, int action, int modifiers) { @@ -125,7 +125,7 @@ public: if (action == GLFW_RELEASE) { double now = glfwGetTime(); if (now - view->last_click < 0.4) { - view->map->scaleBy(2.0, view->last_x, view->last_y); + view->map.scaleBy(2.0, view->last_x, view->last_y); } view->last_click = now; } @@ -135,9 +135,9 @@ public: static void mousemove(GLFWwindow *window, double x, double y) { MapView *view = (MapView *)glfwGetWindowUserPointer(window); if (view->tracking) { - view->map->moveBy(x - view->last_x, y - view->last_y); + view->map.moveBy(x - view->last_x, y - view->last_y); } else if (view->rotating) { - view->map->rotateBy(view->start_x, view->start_y, view->last_x, view->last_y, x, y); + view->map.rotateBy(view->start_x, view->start_y, view->last_x, view->last_y, x, y); } view->last_x = x; view->last_y = y; @@ -162,7 +162,7 @@ public: } bool render() { - return map->render(); + return map.render(); } void fps() { @@ -180,7 +180,6 @@ public: } ~MapView() { - delete map; glfwTerminate(); } @@ -195,8 +194,8 @@ public: double last_click; GLFWwindow *window; - llmr::macosx_settings *settings; - llmr::map *map; + llmr::Settings_MacOSX settings; + llmr::map map; }; NSOperationQueue *queue = NULL; @@ -242,7 +241,7 @@ void request(void *, tile::ptr tile) { tile->setData((uint8_t *)[data bytes], [data length]); if (tile->parse()) { dispatch_async(dispatch_get_main_queue(), ^ { - view->map->tileLoaded(tile); + view->map.tileLoaded(tile); }); return; } @@ -250,7 +249,7 @@ void request(void *, tile::ptr tile) { } dispatch_async(dispatch_get_main_queue(), ^ { - view->map->tileFailed(tile); + view->map.tileFailed(tile); }); }]; } diff --git a/macosx/settings.hpp b/macosx/settings.hpp index 7c23f829e..7f5866c50 100644 --- a/macosx/settings.hpp +++ b/macosx/settings.hpp @@ -5,9 +5,9 @@ namespace llmr { -class macosx_settings : public settings { +class Settings_MacOSX : public Settings { public: - macosx_settings(); + Settings_MacOSX(); virtual void save(); virtual void load(); virtual void clear(); diff --git a/macosx/settings.mm b/macosx/settings.mm index 31395781f..7b7d294f6 100644 --- a/macosx/settings.mm +++ b/macosx/settings.mm @@ -5,7 +5,7 @@ using namespace llmr; -macosx_settings::macosx_settings() { +Settings_MacOSX::Settings_MacOSX() { NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: // position @@ -23,7 +23,7 @@ macosx_settings::macosx_settings() { [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; } -void macosx_settings::load() { +void Settings_MacOSX::load() { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; // position @@ -36,7 +36,7 @@ void macosx_settings::load() { debug = [defaults boolForKey:@"debug"]; } -void macosx_settings::save() { +void Settings_MacOSX::save() { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys: @@ -57,6 +57,6 @@ void macosx_settings::save() { [defaults synchronize]; } -void macosx_settings::clear() { +void Settings_MacOSX::clear() { // TODO } diff --git a/src/map/map.cpp b/src/map/map.cpp index c6940f71c..fc9e55abb 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -10,7 +10,7 @@ using namespace llmr; -map::map(class settings *settings) +map::map(Settings& settings) : settings(settings), transform(new class transform()), painter(new class painter(transform, settings)), @@ -27,9 +27,9 @@ void map::setup() { } void map::loadSettings() { - transform->setAngle(settings->angle); - transform->setScale(settings->scale); - transform->setLonLat(settings->longitude, settings->latitude); + transform->setAngle(settings.angle); + transform->setScale(settings.scale); + transform->setLonLat(settings.longitude, settings.latitude); update(); } @@ -43,33 +43,33 @@ void map::moveBy(double dx, double dy) { transform->moveBy(dx, dy); update(); - transform->getLonLat(settings->longitude, settings->latitude); - settings->save(); + transform->getLonLat(settings.longitude, settings.latitude); + settings.save(); } void map::scaleBy(double ds, double cx, double cy) { transform->scaleBy(ds, cx, cy); update(); - transform->getLonLat(settings->longitude, settings->latitude); - settings->scale = transform->getScale(); - settings->save(); + transform->getLonLat(settings.longitude, settings.latitude); + settings.scale = transform->getScale(); + settings.save(); } void map::rotateBy(double cx, double cy, double sx, double sy, double ex, double ey) { transform->rotateBy(cx, cy, sx, sy, ex, ey); update(); - settings->angle = transform->getAngle(); - settings->save(); + settings.angle = transform->getAngle(); + settings.save(); } void map::resetNorth() { transform->setAngle(0, 0.5); // 500 ms update(); - settings->angle = transform->getAngle(); - settings->save(); + settings.angle = transform->getAngle(); + settings.save(); } void map::resetPosition() { @@ -78,17 +78,17 @@ void map::resetPosition() { transform->setZoom(0); update(); - transform->getLonLat(settings->longitude, settings->latitude); - settings->scale = transform->getScale(); - settings->angle = transform->getAngle(); - settings->save(); + transform->getLonLat(settings.longitude, settings.latitude); + settings.scale = transform->getScale(); + settings.angle = transform->getAngle(); + settings.save(); } void map::toggleDebug() { - settings->debug = !settings->debug; + settings.debug = !settings.debug; update(); - settings->save(); + settings.save(); } void map::update() { diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 70e405ec1..f4d35220d 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -27,7 +27,7 @@ GLshort tile_border_vertices[] = { 0, 0 }; -painter::painter(class transform *transform, class settings *settings) +painter::painter(class transform *transform, Settings& settings) : transform(transform), settings(settings), currentShader(NULL), @@ -161,7 +161,7 @@ void painter::render(const tile::ptr& tile) { glDrawArrays(GL_LINE_STRIP, 0, tile->lineVertex.length()); - if (settings->debug) { + if (settings.debug) { renderDebug(tile); } }