Loading common/draw_frame.cpp +20 −38 Original line number Diff line number Diff line Loading @@ -424,8 +424,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) if( IsGalCanvasActive() ) { GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x, screen->GetGrid().m_Size.y ) ); GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size ) ); GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } Loading Loading @@ -456,22 +455,14 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) return; GetScreen()->SetZoom( selectedZoom ); if( IsGalCanvasActive() ) { // Apply computed view settings to GAL KIGFX::VIEW* view = GetGalCanvas()->GetView(); KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoom = 1.0 / ( zoomFactor * GetZoom() ); view->SetScale( zoom ); GetGalCanvas()->Refresh(); } else RedrawScreen( GetScrollCenterPosition(), false ); } // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) mgr->RunAction( "common.Control.zoomPreset", true, id ); } Loading Loading @@ -1026,38 +1017,29 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); // Display the same view after canvas switching if( aEnable ) { BASE_SCREEN* screen = GetScreen(); // Switch to GAL rendering if( !IsGalCanvasActive() ) // Display the same view after canvas switching if( aEnable ) // Switch to GAL rendering { // Set up viewport double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() ); view->SetScale( zoom ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); } // Set up grid settings gal->SetGridVisibility( IsGridVisible() ); gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) ); gal->SetGridSize( VECTOR2D( screen->GetGridSize() ) ); gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) ); } else { // Switch to standard rendering if( IsGalCanvasActive() ) else // Switch to standard rendering { // Change view settings only if GAL was active previously double zoom = 1.0 / ( zoomFactor * view->GetScale() ); m_canvas->SetZoom( zoom ); VECTOR2D center = view->GetCenter(); RedrawScreen( wxPoint( center.x, center.y ), false ); } AdjustScrollBars( wxPoint( center.x, center.y ) ); } m_canvas->SetEvtHandlerEnabled( !aEnable ); Loading common/zoom.cpp +27 −14 Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ #include <fctsys.h> #include <id.h> #include <class_drawpanel.h> #include <class_draw_panel_gal.h> #include <gal/graphics_abstraction_layer.h> #include <view/view.h> #include <class_base_screen.h> #include <draw_frame.h> Loading @@ -46,6 +44,9 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) { if( IsGalCanvasActive() ) return; AdjustScrollBars( aCenterPoint ); // Move the mouse cursor to the on grid graphic cursor position Loading @@ -58,6 +59,9 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore ) { if( IsGalCanvasActive() ) return; wxPoint dPos = posBefore - m_canvas->GetClientSize() / 2; // relative screen position to center before zoom wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() ); // screen position of crosshair after zoom wxPoint newCenter = m_canvas->ToLogicalXY( newScreenPos - dPos ); Loading Loading @@ -186,18 +190,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) break; default: unsigned i; i = id - ID_POPUP_ZOOM_LEVEL_START; if( i >= screen->m_ZoomList.size() ) { wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ), __TFILE__, __LINE__, i ); return; } if( screen->SetZoom( screen->m_ZoomList[i] ) ) RedrawScreen( center, true ); SetPresetZoom( id - ID_POPUP_ZOOM_LEVEL_START ); } UpdateStatusBar(); Loading @@ -216,6 +209,26 @@ void EDA_DRAW_FRAME::SetPrevZoom() } void EDA_DRAW_FRAME::SetPresetZoom( int aIndex ) { BASE_SCREEN* screen = GetScreen(); if( aIndex >= (int) screen->m_ZoomList.size() ) { wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ), __TFILE__, __LINE__, aIndex ); return; } m_zoomSelectBox->SetSelection( aIndex ); if( screen->SetZoom( screen->m_ZoomList[aIndex] ) ) RedrawScreen( GetScrollCenterPosition(), true ); UpdateStatusBar(); } /* add the zoom list menu the the MasterMenu. * used in OnRightClick(wxMouseEvent& event) */ Loading include/class_base_screen.h +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public: int m_ScreenNumber; int m_NumberOfScreens; std::vector<double> m_ZoomList; ///< standard zoom (i.e. scale) coefficients. std::vector<int> m_ZoomList; ///< standard zoom (i.e. scale) coefficients. bool m_IsPrinting; public: Loading include/draw_frame.h +13 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,12 @@ public: */ virtual const wxString GetZoomLevelIndicator() const; /** * Function GetZoomLevelCoeff * returns the coefficient to convert internal display scale factor to zoom level. */ inline double GetZoomLevelCoeff() const { return m_zoomLevelCoeff; } void EraseMsgBox(); void Process_PageSettings( wxCommandEvent& event ); Loading Loading @@ -505,6 +511,13 @@ public: */ void SetPrevZoom(); /** * Function SetPresetZoom() * changes zoom to one of the preset values. * @param aIndex is the zoom index from the list. */ void SetPresetZoom( int aIndex ); /** * Function RedrawScreen * redraws the entire screen area by updating the scroll bars and mouse pointer in Loading pcbnew/tools/common_actions.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -181,30 +181,34 @@ TOOL_ACTION COMMON_ACTIONS::arcPosture( "pcbnew.InteractiveDrawing.arcPosture", // View Controls TOOL_ACTION COMMON_ACTIONS::zoomIn( "pcbnew.Control.zoomIn", TOOL_ACTION COMMON_ACTIONS::zoomIn( "common.Control.zoomIn", AS_GLOBAL, WXK_F1, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomOut( "pcbnew.Control.zoomOut", TOOL_ACTION COMMON_ACTIONS::zoomOut( "common.Control.zoomOut", AS_GLOBAL, WXK_F2, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomInCenter( "pcbnew.Control.zoomInCenter", TOOL_ACTION COMMON_ACTIONS::zoomInCenter( "common.Control.zoomInCenter", AS_GLOBAL, 0, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomOutCenter( "pcbnew.Control.zoomOutCenter", TOOL_ACTION COMMON_ACTIONS::zoomOutCenter( "common.Control.zoomOutCenter", AS_GLOBAL, 0, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomCenter( "pcbnew.Control.zoomCenter", TOOL_ACTION COMMON_ACTIONS::zoomCenter( "common.Control.zoomCenter", AS_GLOBAL, WXK_F4, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "pcbnew.Control.zoomFitScreen", TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen", AS_GLOBAL, WXK_HOME, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomPreset( "common.Control.zoomPreset", AS_GLOBAL, 0, "", "" ); // Display modes TOOL_ACTION COMMON_ACTIONS::trackDisplayMode( "pcbnew.Control.trackDisplayMode", Loading Loading
common/draw_frame.cpp +20 −38 Original line number Diff line number Diff line Loading @@ -424,8 +424,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) if( IsGalCanvasActive() ) { GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size.x, screen->GetGrid().m_Size.y ) ); GetGalCanvas()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGrid().m_Size ) ); GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } Loading Loading @@ -456,22 +455,14 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) return; GetScreen()->SetZoom( selectedZoom ); if( IsGalCanvasActive() ) { // Apply computed view settings to GAL KIGFX::VIEW* view = GetGalCanvas()->GetView(); KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); double zoom = 1.0 / ( zoomFactor * GetZoom() ); view->SetScale( zoom ); GetGalCanvas()->Refresh(); } else RedrawScreen( GetScrollCenterPosition(), false ); } // Notify GAL TOOL_MANAGER* mgr = GetToolManager(); if( mgr && IsGalCanvasActive() ) mgr->RunAction( "common.Control.zoomPreset", true, id ); } Loading Loading @@ -1026,38 +1017,29 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) KIGFX::GAL* gal = GetGalCanvas()->GetGAL(); double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor(); // Display the same view after canvas switching if( aEnable ) { BASE_SCREEN* screen = GetScreen(); // Switch to GAL rendering if( !IsGalCanvasActive() ) // Display the same view after canvas switching if( aEnable ) // Switch to GAL rendering { // Set up viewport double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() ); view->SetScale( zoom ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); } // Set up grid settings gal->SetGridVisibility( IsGridVisible() ); gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) ); gal->SetGridSize( VECTOR2D( screen->GetGridSize() ) ); gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) ); } else { // Switch to standard rendering if( IsGalCanvasActive() ) else // Switch to standard rendering { // Change view settings only if GAL was active previously double zoom = 1.0 / ( zoomFactor * view->GetScale() ); m_canvas->SetZoom( zoom ); VECTOR2D center = view->GetCenter(); RedrawScreen( wxPoint( center.x, center.y ), false ); } AdjustScrollBars( wxPoint( center.x, center.y ) ); } m_canvas->SetEvtHandlerEnabled( !aEnable ); Loading
common/zoom.cpp +27 −14 Original line number Diff line number Diff line Loading @@ -33,8 +33,6 @@ #include <fctsys.h> #include <id.h> #include <class_drawpanel.h> #include <class_draw_panel_gal.h> #include <gal/graphics_abstraction_layer.h> #include <view/view.h> #include <class_base_screen.h> #include <draw_frame.h> Loading @@ -46,6 +44,9 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) { if( IsGalCanvasActive() ) return; AdjustScrollBars( aCenterPoint ); // Move the mouse cursor to the on grid graphic cursor position Loading @@ -58,6 +59,9 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore ) { if( IsGalCanvasActive() ) return; wxPoint dPos = posBefore - m_canvas->GetClientSize() / 2; // relative screen position to center before zoom wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() ); // screen position of crosshair after zoom wxPoint newCenter = m_canvas->ToLogicalXY( newScreenPos - dPos ); Loading Loading @@ -186,18 +190,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) break; default: unsigned i; i = id - ID_POPUP_ZOOM_LEVEL_START; if( i >= screen->m_ZoomList.size() ) { wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ), __TFILE__, __LINE__, i ); return; } if( screen->SetZoom( screen->m_ZoomList[i] ) ) RedrawScreen( center, true ); SetPresetZoom( id - ID_POPUP_ZOOM_LEVEL_START ); } UpdateStatusBar(); Loading @@ -216,6 +209,26 @@ void EDA_DRAW_FRAME::SetPrevZoom() } void EDA_DRAW_FRAME::SetPresetZoom( int aIndex ) { BASE_SCREEN* screen = GetScreen(); if( aIndex >= (int) screen->m_ZoomList.size() ) { wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ), __TFILE__, __LINE__, aIndex ); return; } m_zoomSelectBox->SetSelection( aIndex ); if( screen->SetZoom( screen->m_ZoomList[aIndex] ) ) RedrawScreen( GetScrollCenterPosition(), true ); UpdateStatusBar(); } /* add the zoom list menu the the MasterMenu. * used in OnRightClick(wxMouseEvent& event) */ Loading
include/class_base_screen.h +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ public: int m_ScreenNumber; int m_NumberOfScreens; std::vector<double> m_ZoomList; ///< standard zoom (i.e. scale) coefficients. std::vector<int> m_ZoomList; ///< standard zoom (i.e. scale) coefficients. bool m_IsPrinting; public: Loading
include/draw_frame.h +13 −0 Original line number Diff line number Diff line Loading @@ -346,6 +346,12 @@ public: */ virtual const wxString GetZoomLevelIndicator() const; /** * Function GetZoomLevelCoeff * returns the coefficient to convert internal display scale factor to zoom level. */ inline double GetZoomLevelCoeff() const { return m_zoomLevelCoeff; } void EraseMsgBox(); void Process_PageSettings( wxCommandEvent& event ); Loading Loading @@ -505,6 +511,13 @@ public: */ void SetPrevZoom(); /** * Function SetPresetZoom() * changes zoom to one of the preset values. * @param aIndex is the zoom index from the list. */ void SetPresetZoom( int aIndex ); /** * Function RedrawScreen * redraws the entire screen area by updating the scroll bars and mouse pointer in Loading
pcbnew/tools/common_actions.cpp +10 −6 Original line number Diff line number Diff line Loading @@ -181,30 +181,34 @@ TOOL_ACTION COMMON_ACTIONS::arcPosture( "pcbnew.InteractiveDrawing.arcPosture", // View Controls TOOL_ACTION COMMON_ACTIONS::zoomIn( "pcbnew.Control.zoomIn", TOOL_ACTION COMMON_ACTIONS::zoomIn( "common.Control.zoomIn", AS_GLOBAL, WXK_F1, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomOut( "pcbnew.Control.zoomOut", TOOL_ACTION COMMON_ACTIONS::zoomOut( "common.Control.zoomOut", AS_GLOBAL, WXK_F2, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomInCenter( "pcbnew.Control.zoomInCenter", TOOL_ACTION COMMON_ACTIONS::zoomInCenter( "common.Control.zoomInCenter", AS_GLOBAL, 0, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomOutCenter( "pcbnew.Control.zoomOutCenter", TOOL_ACTION COMMON_ACTIONS::zoomOutCenter( "common.Control.zoomOutCenter", AS_GLOBAL, 0, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomCenter( "pcbnew.Control.zoomCenter", TOOL_ACTION COMMON_ACTIONS::zoomCenter( "common.Control.zoomCenter", AS_GLOBAL, WXK_F4, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "pcbnew.Control.zoomFitScreen", TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen", AS_GLOBAL, WXK_HOME, "", "" ); TOOL_ACTION COMMON_ACTIONS::zoomPreset( "common.Control.zoomPreset", AS_GLOBAL, 0, "", "" ); // Display modes TOOL_ACTION COMMON_ACTIONS::trackDisplayMode( "pcbnew.Control.trackDisplayMode", Loading