diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-11 13:30:03 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-13 10:28:44 -0700 |
commit | f1c06f8d837b57c1b10677fb5317f0bf20987cf6 (patch) | |
tree | fe64a8ca383b76318f0ee10c778460f5a879b3ad /src | |
parent | a2670336d4387782bb607092f3a06814bdf4eb8d (diff) | |
download | qtlocation-mapboxgl-f1c06f8d837b57c1b10677fb5317f0bf20987cf6.tar.gz |
[all] Remove redundant scale-related camera methods
We don't need to have two different measurement systems for map zoom.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 20 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 46 | ||||
-rw-r--r-- | src/mbgl/map/transform.hpp | 22 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 1 |
5 files changed, 13 insertions, 80 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 45b2f26568..19b1222f0e 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -532,23 +532,7 @@ void Map::resetPosition(const EdgeInsets& padding) { } -#pragma mark - Scale - -void Map::scaleBy(double ds, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - impl->cameraMutated = true; - impl->transform.scaleBy(ds, anchor, animation); - impl->onUpdate(Update::RecalculateStyle); -} - -void Map::setScale(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - impl->cameraMutated = true; - impl->transform.setScale(scale, anchor, animation); - impl->onUpdate(Update::RecalculateStyle); -} - -double Map::getScale() const { - return impl->transform.getScale(); -} +#pragma mark - Zoom void Map::setZoom(double zoom, const AnimationOptions& animation) { impl->cameraMutated = true; @@ -620,7 +604,7 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed scaleY -= (padding.top + padding.bottom) / height; minScale = util::min(scaleX, scaleY); } - double zoom = util::log2(getScale() * minScale); + double zoom = getZoom() + util::log2(minScale); zoom = util::clamp(zoom, getMinZoom(), getMaxZoom()); // Calculate the center point of a virtual bounds that is extended in all directions by padding. diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index eab40a6ee5..67729f7fe2 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -384,52 +384,28 @@ ScreenCoordinate Transform::getScreenCoordinate(const EdgeInsets& padding) const #pragma mark - Zoom -void Transform::scaleBy(double ds, const AnimationOptions& animation) { - scaleBy(ds, optional<ScreenCoordinate> {}, animation); -} - -void Transform::scaleBy(double ds, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - if (std::isnan(ds)) return; - double scale = util::clamp(state.scale * ds, state.min_scale, state.max_scale); - setScale(scale, anchor, animation); -} - void Transform::setZoom(double zoom, const AnimationOptions& animation) { - setZoom(zoom, optional<ScreenCoordinate> {}, animation); + CameraOptions camera; + camera.zoom = zoom; + easeTo(camera, animation); } void Transform::setZoom(double zoom, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - setScale(state.zoomScale(zoom), anchor, animation); + CameraOptions camera; + camera.zoom = zoom; + camera.anchor = anchor; + easeTo(camera, animation); } void Transform::setZoom(double zoom, const EdgeInsets& padding, const AnimationOptions& animation) { - setScale(state.zoomScale(zoom), padding, animation); -} - -double Transform::getZoom() const { - return state.getZoom(); -} - -double Transform::getScale() const { - return state.scale; -} - -void Transform::setScale(double scale, const AnimationOptions& animation) { - setScale(scale, optional<ScreenCoordinate> {}, animation); -} - -void Transform::setScale(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { - if (std::isnan(scale)) return; CameraOptions camera; - camera.zoom = state.scaleZoom(scale); - camera.anchor = anchor; + camera.zoom = zoom; + if (!padding.isFlush()) camera.anchor = getScreenCoordinate(padding); easeTo(camera, animation); } -void Transform::setScale(double scale, const EdgeInsets& padding, const AnimationOptions& animation) { - optional<ScreenCoordinate> anchor; - if (!padding.isFlush()) anchor = getScreenCoordinate(padding); - setScale(scale, anchor, animation); +double Transform::getZoom() const { + return state.getZoom(); } #pragma mark - Bounds diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index 993f8f2c5f..2c59a6c1aa 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -65,26 +65,6 @@ public: // Zoom - /** Scales the map, keeping the given point fixed within the view. - @param ds The difference in scale factors to scale the map by. */ - void scaleBy(double ds, const AnimationOptions& = {}); - /** Scales the map, keeping the given point fixed within the view. - @param ds The difference in scale factors to scale the map by. - @param anchor A point relative to the top-left corner of the view. - If unspecified, the center point is fixed within the view. */ - void scaleBy(double ds, optional<ScreenCoordinate> anchor, const AnimationOptions& = {}); - /** Sets the scale factor, keeping the given point fixed within the view. - @param scale The new scale factor. */ - void setScale(double scale, const AnimationOptions& = {}); - /** Sets the scale factor, keeping the given point fixed within the view. - @param scale The new scale factor. - @param anchor A point relative to the top-left corner of the view. - If unspecified, the center point is fixed within the view. */ - void setScale(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& = {}); - /** Sets the scale factor, keeping the center point fixed within the inset view. - @param scale The new scale factor. - @param padding The viewport padding that affects the fixed center point. */ - void setScale(double scale, const EdgeInsets& padding, const AnimationOptions& = {}); /** Sets the zoom level, keeping the given point fixed within the view. @param zoom The new zoom level. */ void setZoom(double zoom, const AnimationOptions& = {}); @@ -99,8 +79,6 @@ public: void setZoom(double zoom, const EdgeInsets& padding, const AnimationOptions& = {}); /** Returns the zoom level. */ double getZoom() const; - /** Returns the scale factor. */ - double getScale() const; // Angle diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index f1c59533ae..fe90d4b2e4 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -136,10 +136,6 @@ double TransformState::getZoomFraction() const { return getZoom() - getIntegerZoom(); } -double TransformState::getScale() const { - return scale; -} - #pragma mark - Bounds void TransformState::setLatLngBounds(const LatLngBounds& bounds_) { diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index 174aaa7ee6..85d5d96700 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -45,7 +45,6 @@ public: double pixel_y() const; // Zoom - double getScale() const; double getZoom() const; int32_t getIntegerZoom() const; double getZoomFraction() const; |