From eab85645333bf0e788dcb0c33e9211d9c78ec53a Mon Sep 17 00:00:00 2001 From: Colin Takushi Date: Sun, 26 Jan 2025 17:21:43 -0600 Subject: [PATCH 1/5] Inital allow for rotation when max zoomed in Signed-off-by: Colin Takushi --- drape_frontend/navigator.cpp | 15 ++++++++++++++- geometry/geometry_tests/screen_test.cpp | 3 ++- geometry/screenbase.cpp | 7 +++++-- geometry/screenbase.hpp | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index 93abf9bbd6..2b6d9ffbc9 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -176,7 +176,8 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, math::Matrix const newM = screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1 + offset, oldPt2 + offset, newPt1 + offset, newPt2 + offset, - doRotateScreen); + doRotateScreen, + true); ScreenBase tmp = screen; tmp.SetGtoPMatrix(newM); if (tmp.isPerspective()) @@ -196,7 +197,19 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, } if (!CheckMaxScale(tmp)) + { + if (doRotateScreen){ + math::Matrix const tmpM = + screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1 + offset, oldPt2 + offset, + newPt1 + offset, newPt2 + offset, + doRotateScreen, + false); + tmp.SetGtoPMatrix(tmpM); + } + else return false; + } + // re-checking the borders, as we might violate them a bit (don't know why). if (!CheckBorders(tmp)) diff --git a/geometry/geometry_tests/screen_test.cpp b/geometry/geometry_tests/screen_test.cpp index 8bdd8c9300..3d561ba921 100644 --- a/geometry/geometry_tests/screen_test.cpp +++ b/geometry/geometry_tests/screen_test.cpp @@ -151,7 +151,8 @@ UNIT_TEST(ScreenBase_CalcTransform) m2::PointD(0, 1), m2::PointD(1, 1), m2::PointD( s * sin(a) + dx, s * cos(a) + dy), m2::PointD(s * cos(a) + s * sin(a) + dx, -s * sin(a) + s * cos(a) + dy), - true /* allow rotate */); + true /* allow rotate */, + true /* allow scale*/); ScreenBase::ExtractGtoPParams(m, a1, s1, dx1, dy1); diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index a79cfec33e..79172cbdc9 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -225,9 +225,12 @@ int ScreenBase::GetHeight() const { return base::SignedRound(m_PixelRect.SizeY() ScreenBase::MatrixT const ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, m2::PointD const & newPt1, - m2::PointD const & newPt2, bool allowRotate) + m2::PointD const & newPt2, + bool allowRotate, + bool allowScale) { - double const s = newPt1.Length(newPt2) / oldPt1.Length(oldPt2); + + double const s = allowScale ? newPt1.Length(newPt2) / oldPt1.Length(oldPt2) : 1.0; double const a = allowRotate ? ang::AngleTo(newPt1, newPt2) - ang::AngleTo(oldPt1, oldPt2) : 0.0; MatrixT m = math::Shift( diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp index d0418031ee..3174eda08a 100644 --- a/geometry/screenbase.hpp +++ b/geometry/screenbase.hpp @@ -124,7 +124,7 @@ public: /// newPt2) static MatrixT const CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, m2::PointD const & newPt1, m2::PointD const & newPt2, - bool allowRotate); + bool allowRotate, bool allowScale); /// Setting GtoP matrix extracts the Angle and m_Org parameters, leaving PixelRect intact void SetGtoPMatrix(MatrixT const & m); -- 2.45.3 From baca976cce0be95993e4cebc74c49c036202398f Mon Sep 17 00:00:00 2001 From: Colin Takushi Date: Sun, 26 Jan 2025 17:24:20 -0600 Subject: [PATCH 2/5] Formatting: Signed-off-by: Colin Takushi --- drape_frontend/navigator.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index 2b6d9ffbc9..c00aaac494 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -193,12 +193,13 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, if (CanShrinkInto(tmp, worldR)) tmp = ShrinkInto(tmp, worldR); else - return false; + return false; } if (!CheckMaxScale(tmp)) { - if (doRotateScreen){ + if (doRotateScreen) + { math::Matrix const tmpM = screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1 + offset, oldPt2 + offset, newPt1 + offset, newPt2 + offset, @@ -207,8 +208,10 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, tmp.SetGtoPMatrix(tmpM); } else + { return false; } + } // re-checking the borders, as we might violate them a bit (don't know why). -- 2.45.3 From fd6722092d16da43063f941700a44b676706e080 Mon Sep 17 00:00:00 2001 From: Colin Takushi Date: Sun, 26 Jan 2025 17:30:54 -0600 Subject: [PATCH 3/5] move scale check up Signed-off-by: Colin Takushi --- drape_frontend/navigator.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index c00aaac494..4173e054d5 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -180,21 +180,6 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, true); ScreenBase tmp = screen; tmp.SetGtoPMatrix(newM); - if (tmp.isPerspective()) - tmp.MatchGandP3d(centerG, center3d); - - if (!skipMinScaleAndBordersCheck && !CheckMinScale(tmp)) - return false; - - m2::RectD const & worldR = df::GetWorldRect(); - - if (!skipMinScaleAndBordersCheck && !CheckBorders(tmp)) - { - if (CanShrinkInto(tmp, worldR)) - tmp = ShrinkInto(tmp, worldR); - else - return false; - } if (!CheckMaxScale(tmp)) { @@ -213,6 +198,21 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, } } + if (tmp.isPerspective()) + tmp.MatchGandP3d(centerG, center3d); + + if (!skipMinScaleAndBordersCheck && !CheckMinScale(tmp)) + return false; + + m2::RectD const & worldR = df::GetWorldRect(); + + if (!skipMinScaleAndBordersCheck && !CheckBorders(tmp)) + { + if (CanShrinkInto(tmp, worldR)) + tmp = ShrinkInto(tmp, worldR); + else + return false; + } // re-checking the borders, as we might violate them a bit (don't know why). if (!CheckBorders(tmp)) -- 2.45.3 From 53ef7b7b776ea60f3425e4a6d024d1acbe91fb0e Mon Sep 17 00:00:00 2001 From: Colin Takushi Date: Sun, 26 Jan 2025 17:31:59 -0600 Subject: [PATCH 4/5] formatting Signed-off-by: Colin Takushi --- drape_frontend/navigator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index 4173e054d5..bb094fc506 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -194,8 +194,8 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, } else { - return false; - } + return false; + } } if (tmp.isPerspective()) -- 2.45.3 From cd05a9e4f7b6e4599892468396973153fdc8e055 Mon Sep 17 00:00:00 2001 From: Colin Takushi Date: Sun, 26 Jan 2025 17:44:08 -0600 Subject: [PATCH 5/5] remove white space Signed-off-by: Colin Takushi --- drape_frontend/navigator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drape_frontend/navigator.cpp b/drape_frontend/navigator.cpp index bb094fc506..07f48a8382 100644 --- a/drape_frontend/navigator.cpp +++ b/drape_frontend/navigator.cpp @@ -211,7 +211,7 @@ bool Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, if (CanShrinkInto(tmp, worldR)) tmp = ShrinkInto(tmp, worldR); else - return false; + return false; } // re-checking the borders, as we might violate them a bit (don't know why). -- 2.45.3