From ef1f01a8bd4daddcf65cf14be1155a22ea00ba50 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 3 Aug 2018 14:00:05 +0200 Subject: [PATCH] VIEW: use BOX2D for view boundary --- common/view/wx_view_controls.cpp | 6 +++--- include/view/view.h | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index e94088c4a9..2eff2af7a0 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -345,8 +345,8 @@ void WX_VIEW_CONTROLS::onScroll( wxScrollWinEvent& aEvent ) if( type == wxEVT_SCROLLWIN_THUMBTRACK ) { - VECTOR2D center = m_view->GetCenter(); - const BOX2I& boundary = m_view->GetBoundary(); + auto center = m_view->GetCenter(); + const auto& boundary = m_view->GetBoundary(); // Flip scroll direction in flipped view const double xstart = ( m_view->IsMirroredX() ? @@ -609,7 +609,7 @@ wxPoint WX_VIEW_CONTROLS::getMouseScreenPosition() const void WX_VIEW_CONTROLS::UpdateScrollbars() { const BOX2D viewport = m_view->GetViewport(); - const BOX2I& boundary = m_view->GetBoundary(); + const BOX2D& boundary = m_view->GetBoundary(); m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often m_scrollScale.y = 2e3 / viewport.GetHeight(); diff --git a/include/view/view.h b/include/view/view.h index 35e917feab..46cee235a3 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -277,16 +277,27 @@ public: * Sets limits for view area. * @param aBoundary is the box that limits view area. */ - inline void SetBoundary( const BOX2I& aBoundary ) + inline void SetBoundary( const BOX2D& aBoundary ) { m_boundary = aBoundary; } + /** + * Function SetBoundary() + * Sets limits for view area. + * @param aBoundary is the box that limits view area. + */ + inline void SetBoundary( const BOX2I& aBoundary ) + { + m_boundary.SetOrigin( aBoundary.GetOrigin() ); + m_boundary.SetEnd( aBoundary.GetEnd() ); + } + /** * Function GetBoundary() * @return Current view area boundary. */ - inline const BOX2I& GetBoundary() const + inline const BOX2D& GetBoundary() const { return m_boundary; } @@ -688,7 +699,7 @@ public: std::shared_ptr MakeOverlay(); -private: +protected: struct VIEW_LAYER { bool visible; ///< is the layer to be rendered? @@ -813,7 +824,7 @@ private: double m_scale; /// View boundaries - BOX2I m_boundary; + BOX2D m_boundary; /// Scale lower limit double m_minScale;