Loading common/view/view.cpp +1 −21 Original line number Diff line number Diff line Loading @@ -45,10 +45,8 @@ VIEW::VIEW( bool aIsDynamic ) : m_scale( 1.0 ), m_painter( NULL ), m_gal( NULL ), m_dynamic( aIsDynamic ), m_scaleLimits( 15000.0, 1.0 ) m_dynamic( aIsDynamic ) { m_panBoundary.SetMaximum(); m_needsUpdate.reserve( 32768 ); // Redraw everything at the beginning Loading Loading @@ -295,11 +293,6 @@ void VIEW::SetMirror( bool aMirrorX, bool aMirrorY ) void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor ) { if( aScale > m_scaleLimits.x ) aScale = m_scaleLimits.x; else if( aScale < m_scaleLimits.y ) aScale = m_scaleLimits.y; VECTOR2D a = ToScreen( aAnchor ); m_gal->SetZoomFactor( aScale ); Loading @@ -319,19 +312,6 @@ void VIEW::SetCenter( const VECTOR2D& aCenter ) { m_center = aCenter; if( !m_panBoundary.Contains( aCenter ) ) { if( aCenter.x < m_panBoundary.GetLeft() ) m_center.x = m_panBoundary.GetLeft(); else if( aCenter.x > m_panBoundary.GetRight() ) m_center.x = m_panBoundary.GetRight(); if( aCenter.y < m_panBoundary.GetTop() ) m_center.y = m_panBoundary.GetTop(); else if( aCenter.y > m_panBoundary.GetBottom() ) m_center.y = m_panBoundary.GetBottom(); } m_gal->SetLookAtPoint( m_center ); m_gal->ComputeWorldScreenMatrix(); Loading common/view/wx_view_controls.cpp +40 −4 Original line number Diff line number Diff line Loading @@ -66,6 +66,42 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled ) } void VIEW_CONTROLS::setCenter( const VECTOR2D& aCenter ) { if( !m_panBoundary.Contains( aCenter ) ) { VECTOR2D newCenter( aCenter ); if( aCenter.x < m_panBoundary.GetLeft() ) newCenter.x = m_panBoundary.GetLeft(); else if( aCenter.x > m_panBoundary.GetRight() ) newCenter.x = m_panBoundary.GetRight(); if( aCenter.y < m_panBoundary.GetTop() ) newCenter.y = m_panBoundary.GetTop(); else if( aCenter.y > m_panBoundary.GetBottom() ) newCenter.y = m_panBoundary.GetBottom(); m_view->SetCenter( newCenter ); } else { m_view->SetCenter( aCenter ); } } void VIEW_CONTROLS::setScale( double aScale, const VECTOR2D& aAnchor ) { if( aScale < m_minScale ) aScale = m_minScale; else if( aScale > m_maxScale ) aScale = m_maxScale; m_view->SetScale( aScale, aAnchor ); } void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) { bool isAutoPanning = false; Loading @@ -80,7 +116,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) VECTOR2D d = m_dragStartPoint - VECTOR2D( aEvent.GetX(), aEvent.GetY() ); VECTOR2D delta = m_view->ToWorld( d, false ); m_view->SetCenter( m_lookStartPoint + delta ); setCenter( m_lookStartPoint + delta ); aEvent.StopPropagation(); } else Loading Loading @@ -110,7 +146,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) VECTOR2D delta( aEvent.ControlDown() ? -scrollSpeed : 0.0, aEvent.ShiftDown() ? -scrollSpeed : 0.0 ); m_view->SetCenter( m_view->GetCenter() + delta ); setCenter( m_view->GetCenter() + delta ); } else { Loading @@ -133,7 +169,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) } VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) ); m_view->SetScale( m_view->GetScale() * zoomScale, anchor ); setScale( m_view->GetScale() * zoomScale, anchor ); } aEvent.Skip(); Loading Loading @@ -190,7 +226,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) dir = dir.Resize( borderSize ); dir = m_view->ToWorld( dir, false ); m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); setCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); // Notify tools that the cursor position has changed in the world coordinates wxMouseEvent moveEvent( EVT_REFRESH_MOUSE ); Loading include/view/view.h +0 −29 Original line number Diff line number Diff line Loading @@ -507,29 +507,6 @@ public: */ void UpdateItems(); /** * Function SetPanBoundary() * Sets limits for panning area. * @param aBoundary is the box that limits panning area. */ void SetPanBoundary( const BOX2I& aBoundary ) { m_panBoundary = aBoundary; } /** * Function SetScaleLimits() * Sets minimum and maximum values for scale. * @param aMaximum is the maximum value for scale.. * @param aMinimum is the minimum value for scale. */ void SetScaleLimits( double aMaximum, double aMinimum ) { wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) ); m_scaleLimits = VECTOR2D( aMaximum, aMinimum ); } static const int VIEW_MAX_LAYERS = 128; ///< maximum number of layers that may be shown private: Loading Loading @@ -670,12 +647,6 @@ private: /// Rendering order modifier for layers that are marked as top layers static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS; /// Panning boundaries BOX2I m_panBoundary; /// Zoom limits VECTOR2D m_scaleLimits; /// Items to be updated std::vector<VIEW_ITEM*> m_needsUpdate; }; Loading include/view/view_controls.h +44 −6 Original line number Diff line number Diff line Loading @@ -46,14 +46,40 @@ class VIEW; class VIEW_CONTROLS { public: VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_forceCursorPosition( false ), m_snappingEnabled( false ), m_grabMouse( false ), m_autoPanEnabled( false ), m_autoPanMargin( 0.1 ), m_autoPanSpeed( 0.15 ) {} VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_minScale( 4.0 ), m_maxScale( 15000 ), m_forceCursorPosition( false ), m_snappingEnabled( false ), m_grabMouse( false ), m_autoPanEnabled( false ), m_autoPanMargin( 0.1 ), m_autoPanSpeed( 0.15 ) { m_panBoundary.SetMaximum(); } virtual ~VIEW_CONTROLS() {} /** * Function SetPanBoundary() * Sets limits for panning area. * @param aBoundary is the box that limits panning area. */ void SetPanBoundary( const BOX2I& aBoundary ) { m_panBoundary = aBoundary; } /** * Function SetScaleLimits() * Sets minimum and maximum values for scale. * @param aMaximum is the maximum value for scale. * @param aMinimum is the minimum value for scale. */ void SetScaleLimits( double aMaximum, double aMinimum ) { wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) ); m_minScale = aMinimum; m_maxScale = aMaximum; } /** * Function SetSnapping() * Enables/disables snapping cursor to grid. Loading Loading @@ -146,11 +172,23 @@ public: virtual void ShowCursor( bool aEnabled ); protected: /// Sets center for VIEW, takes into account panning boundaries. void setCenter( const VECTOR2D& aCenter ); /// Sets scale for VIEW, takes into account scale limits. void setScale( double aScale, const VECTOR2D& aAnchor ); /// Pointer to controlled VIEW. VIEW* m_view; /// Current mouse position VECTOR2D m_mousePosition; /// Panning boundaries. BOX2I m_panBoundary; /// Scale lower limit. double m_minScale; /// Scale upper limit. double m_maxScale; /// Current cursor position VECTOR2D m_cursorPosition; Loading pcbnew/pcbframe.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ #include <dialog_plot.h> #include <convert_from_iu.h> #include <view/view.h> #include <view/view_controls.h> #include <painter.h> #include <class_track.h> Loading Loading @@ -583,7 +584,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const view->Add( aBoard->GetRatsnestViewItem() ); // Limit panning to the size of worksheet frame view->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() ); GetGalCanvas()->GetViewControls()->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() ); view->RecacheAllItems( true ); if( IsGalCanvasActive() ) Loading Loading
common/view/view.cpp +1 −21 Original line number Diff line number Diff line Loading @@ -45,10 +45,8 @@ VIEW::VIEW( bool aIsDynamic ) : m_scale( 1.0 ), m_painter( NULL ), m_gal( NULL ), m_dynamic( aIsDynamic ), m_scaleLimits( 15000.0, 1.0 ) m_dynamic( aIsDynamic ) { m_panBoundary.SetMaximum(); m_needsUpdate.reserve( 32768 ); // Redraw everything at the beginning Loading Loading @@ -295,11 +293,6 @@ void VIEW::SetMirror( bool aMirrorX, bool aMirrorY ) void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor ) { if( aScale > m_scaleLimits.x ) aScale = m_scaleLimits.x; else if( aScale < m_scaleLimits.y ) aScale = m_scaleLimits.y; VECTOR2D a = ToScreen( aAnchor ); m_gal->SetZoomFactor( aScale ); Loading @@ -319,19 +312,6 @@ void VIEW::SetCenter( const VECTOR2D& aCenter ) { m_center = aCenter; if( !m_panBoundary.Contains( aCenter ) ) { if( aCenter.x < m_panBoundary.GetLeft() ) m_center.x = m_panBoundary.GetLeft(); else if( aCenter.x > m_panBoundary.GetRight() ) m_center.x = m_panBoundary.GetRight(); if( aCenter.y < m_panBoundary.GetTop() ) m_center.y = m_panBoundary.GetTop(); else if( aCenter.y > m_panBoundary.GetBottom() ) m_center.y = m_panBoundary.GetBottom(); } m_gal->SetLookAtPoint( m_center ); m_gal->ComputeWorldScreenMatrix(); Loading
common/view/wx_view_controls.cpp +40 −4 Original line number Diff line number Diff line Loading @@ -66,6 +66,42 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled ) } void VIEW_CONTROLS::setCenter( const VECTOR2D& aCenter ) { if( !m_panBoundary.Contains( aCenter ) ) { VECTOR2D newCenter( aCenter ); if( aCenter.x < m_panBoundary.GetLeft() ) newCenter.x = m_panBoundary.GetLeft(); else if( aCenter.x > m_panBoundary.GetRight() ) newCenter.x = m_panBoundary.GetRight(); if( aCenter.y < m_panBoundary.GetTop() ) newCenter.y = m_panBoundary.GetTop(); else if( aCenter.y > m_panBoundary.GetBottom() ) newCenter.y = m_panBoundary.GetBottom(); m_view->SetCenter( newCenter ); } else { m_view->SetCenter( aCenter ); } } void VIEW_CONTROLS::setScale( double aScale, const VECTOR2D& aAnchor ) { if( aScale < m_minScale ) aScale = m_minScale; else if( aScale > m_maxScale ) aScale = m_maxScale; m_view->SetScale( aScale, aAnchor ); } void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) { bool isAutoPanning = false; Loading @@ -80,7 +116,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent ) VECTOR2D d = m_dragStartPoint - VECTOR2D( aEvent.GetX(), aEvent.GetY() ); VECTOR2D delta = m_view->ToWorld( d, false ); m_view->SetCenter( m_lookStartPoint + delta ); setCenter( m_lookStartPoint + delta ); aEvent.StopPropagation(); } else Loading Loading @@ -110,7 +146,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) VECTOR2D delta( aEvent.ControlDown() ? -scrollSpeed : 0.0, aEvent.ShiftDown() ? -scrollSpeed : 0.0 ); m_view->SetCenter( m_view->GetCenter() + delta ); setCenter( m_view->GetCenter() + delta ); } else { Loading @@ -133,7 +169,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent ) } VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) ); m_view->SetScale( m_view->GetScale() * zoomScale, anchor ); setScale( m_view->GetScale() * zoomScale, anchor ); } aEvent.Skip(); Loading Loading @@ -190,7 +226,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent ) dir = dir.Resize( borderSize ); dir = m_view->ToWorld( dir, false ); m_view->SetCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); setCenter( m_view->GetCenter() + dir * m_autoPanSpeed ); // Notify tools that the cursor position has changed in the world coordinates wxMouseEvent moveEvent( EVT_REFRESH_MOUSE ); Loading
include/view/view.h +0 −29 Original line number Diff line number Diff line Loading @@ -507,29 +507,6 @@ public: */ void UpdateItems(); /** * Function SetPanBoundary() * Sets limits for panning area. * @param aBoundary is the box that limits panning area. */ void SetPanBoundary( const BOX2I& aBoundary ) { m_panBoundary = aBoundary; } /** * Function SetScaleLimits() * Sets minimum and maximum values for scale. * @param aMaximum is the maximum value for scale.. * @param aMinimum is the minimum value for scale. */ void SetScaleLimits( double aMaximum, double aMinimum ) { wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) ); m_scaleLimits = VECTOR2D( aMaximum, aMinimum ); } static const int VIEW_MAX_LAYERS = 128; ///< maximum number of layers that may be shown private: Loading Loading @@ -670,12 +647,6 @@ private: /// Rendering order modifier for layers that are marked as top layers static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS; /// Panning boundaries BOX2I m_panBoundary; /// Zoom limits VECTOR2D m_scaleLimits; /// Items to be updated std::vector<VIEW_ITEM*> m_needsUpdate; }; Loading
include/view/view_controls.h +44 −6 Original line number Diff line number Diff line Loading @@ -46,14 +46,40 @@ class VIEW; class VIEW_CONTROLS { public: VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_forceCursorPosition( false ), m_snappingEnabled( false ), m_grabMouse( false ), m_autoPanEnabled( false ), m_autoPanMargin( 0.1 ), m_autoPanSpeed( 0.15 ) {} VIEW_CONTROLS( VIEW* aView ) : m_view( aView ), m_minScale( 4.0 ), m_maxScale( 15000 ), m_forceCursorPosition( false ), m_snappingEnabled( false ), m_grabMouse( false ), m_autoPanEnabled( false ), m_autoPanMargin( 0.1 ), m_autoPanSpeed( 0.15 ) { m_panBoundary.SetMaximum(); } virtual ~VIEW_CONTROLS() {} /** * Function SetPanBoundary() * Sets limits for panning area. * @param aBoundary is the box that limits panning area. */ void SetPanBoundary( const BOX2I& aBoundary ) { m_panBoundary = aBoundary; } /** * Function SetScaleLimits() * Sets minimum and maximum values for scale. * @param aMaximum is the maximum value for scale. * @param aMinimum is the minimum value for scale. */ void SetScaleLimits( double aMaximum, double aMinimum ) { wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) ); m_minScale = aMinimum; m_maxScale = aMaximum; } /** * Function SetSnapping() * Enables/disables snapping cursor to grid. Loading Loading @@ -146,11 +172,23 @@ public: virtual void ShowCursor( bool aEnabled ); protected: /// Sets center for VIEW, takes into account panning boundaries. void setCenter( const VECTOR2D& aCenter ); /// Sets scale for VIEW, takes into account scale limits. void setScale( double aScale, const VECTOR2D& aAnchor ); /// Pointer to controlled VIEW. VIEW* m_view; /// Current mouse position VECTOR2D m_mousePosition; /// Panning boundaries. BOX2I m_panBoundary; /// Scale lower limit. double m_minScale; /// Scale upper limit. double m_maxScale; /// Current cursor position VECTOR2D m_cursorPosition; Loading
pcbnew/pcbframe.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ #include <dialog_plot.h> #include <convert_from_iu.h> #include <view/view.h> #include <view/view_controls.h> #include <painter.h> #include <class_track.h> Loading Loading @@ -583,7 +584,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const view->Add( aBoard->GetRatsnestViewItem() ); // Limit panning to the size of worksheet frame view->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() ); GetGalCanvas()->GetViewControls()->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() ); view->RecacheAllItems( true ); if( IsGalCanvasActive() ) Loading