diff --git a/map/framework.cpp b/map/framework.cpp index ef762a57d1..e5d9ba768f 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -808,7 +808,36 @@ void FrameWork::AddRedrawCommandSure() template void FrameWork::ShowRect(m2::RectD const & rect) { - m_navigator.SetFromRect(rect); + m2::RectD r(rect); + + m2::PointD center = rect.Center(); + + double minWidthX = MercatorBounds::ConvertMetresToX(center.x, m_metresMinWidth); + double minWidthY = MercatorBounds::ConvertMetresToY(center.y, m_metresMinWidth); + + double k = m_navigator.Screen().PixelRect().SizeX() * 1.0 / m_minRulerWidth; + + if ((r.SizeX() == 0) || (r.SizeY() == 0)) + { + r = m2::RectD(center.x - MercatorBounds::ConvertMetresToX(center.x, m_metresMinWidth / 2), + center.y - MercatorBounds::ConvertMetresToY(center.y, m_metresMinWidth / 2), + center.x + MercatorBounds::ConvertMetresToX(center.x, m_metresMinWidth / 2), + center.y + MercatorBounds::ConvertMetresToY(center.y, m_metresMinWidth / 2)); + + r.Scale(k); + } + else + { + if (k * r.SizeX() < minWidthX) + k *= minWidthX / (k * r.SizeX()); + + if (k * r.SizeY() < minWidthY) + k *= minWidthY / (k * r.SizeY()); + + r.Scale(k); + } + + m_navigator.SetFromRect(r); UpdateNow(); } diff --git a/map/navigator.cpp b/map/navigator.cpp index 1b5bf7d830..721da6ceb1 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -286,8 +286,8 @@ bool Navigator::CheckMaxScale(ScreenBase const & screen) bool Navigator::CheckMinScale(ScreenBase const & screen) { - m2::PointD const pt0 = screen.GlobalRect().Center(); - m2::PointD const pt1 = screen.PtoG(screen.GtoP(pt0) + m2::PointD(m_pxMinWidth, 0)); + m2::PointD const pt0 = screen.PtoG(m_Screen.PixelRect().Center() - m2::PointD(m_pxMinWidth / 2, 0)); + m2::PointD const pt1 = screen.PtoG(m_Screen.PixelRect().Center() + m2::PointD(m_pxMinWidth / 2, 0)); double lonDiff = fabs(MercatorBounds::XToLon(pt1.x) - MercatorBounds::XToLon(pt0.x)); double metresDiff = lonDiff / MercatorBounds::degreeInMetres; return metresDiff >= m_metresMinWidth - 1; diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 90737f2561..e8086258dc 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -280,5 +280,6 @@ namespace qt void DrawWidget::ShowFeature(m2::RectD const & rect) { m_framework.ShowRect(rect); + UpdateScaleControl(); } } diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index c77dd28c8c..46d835f137 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -394,7 +394,7 @@ void MainWindow::OnSearchPanelItemClicked(int row, int) QTableWidget * table = static_cast(m_Docks[3]->widget()); QRectF rect = table->item(row, 0)->data(Qt::UserRole).toRectF(); m2::RectD r2(rect.left(), rect.bottom(), rect.right(), rect.top()); - r2.Inflate(0.0001, 0.0001); +// r2.Inflate(0.0001, 0.0001); m_pDrawWidget->ShowFeature(r2); }