From ade51289a7a883076f495b04efcf0b2abed3371a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 25 Oct 2015 17:58:04 +0100 Subject: [PATCH] All: use solid lines instead of dashed lines to draw X and Y axis in legacy canvas (like in Gal canvas). The main reason: on OSX axis using dashed lines are very very slow to draw (looks like a wxWidget issue when the wxDC scale factor is very small) --- common/draw_panel.cpp | 38 ++++++++++---------------------------- common/draw_panel_gal.cpp | 7 +------ common/gr_basic.cpp | 30 ++++-------------------------- include/gr_basic.h | 10 ++++++---- pcbnew/xchgmod.cpp | 4 ++-- 5 files changed, 23 insertions(+), 66 deletions(-) diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index 7d66608ec0..c40fb462e8 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -667,12 +667,10 @@ void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC ) wxSize pageSize = GetParent()->GetPageSizeIU(); // Draw the Y axis - GRDashedLine( &m_ClipBox, DC, 0, -pageSize.y, - 0, pageSize.y, 0, axis_color ); + GRLine( &m_ClipBox, DC, 0, -pageSize.y, 0, pageSize.y, 0, axis_color ); // Draw the X axis - GRDashedLine( &m_ClipBox, DC, -pageSize.x, 0, - pageSize.x, 0, 0, axis_color ); + GRLine( &m_ClipBox, DC, -pageSize.x, 0, pageSize.x, 0, 0, axis_color ); } if( GetParent()->m_showOriginAxis ) @@ -821,20 +819,12 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) GRSetDrawMode( aDC, aDrawMode ); // Draw the Y axis - GRDashedLine( &m_ClipBox, aDC, - origin.x, - -pageSize.y, - origin.x, - pageSize.y, - 0, color ); + GRLine( &m_ClipBox, aDC, origin.x, -pageSize.y, + origin.x, pageSize.y, 0, color ); // Draw the X axis - GRDashedLine( &m_ClipBox, aDC, - -pageSize.x, - origin.y, - pageSize.x, - origin.y, - 0, color ); + GRLine( &m_ClipBox, aDC, -pageSize.x, origin.y, + pageSize.x, origin.y, 0, color ); } @@ -849,20 +839,12 @@ void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoi GRSetDrawMode( aDC, aDrawMode ); // Draw the Y axis - GRDashedLine( &m_ClipBox, aDC, - aGridOrigin.x, - -pageSize.y, - aGridOrigin.x, - pageSize.y, - 0, color ); + GRLine( &m_ClipBox, aDC, aGridOrigin.x, -pageSize.y, + aGridOrigin.x, pageSize.y, 0, color ); // Draw the X axis - GRDashedLine( &m_ClipBox, aDC, - -pageSize.x, - aGridOrigin.y, - pageSize.x, - aGridOrigin.y, - 0, color ); + GRLine( &m_ClipBox, aDC, -pageSize.x, aGridOrigin.y, + pageSize.x, aGridOrigin.y, 0, color ); } diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index bd22c9799b..cd51a5a4f2 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -206,12 +206,7 @@ void EDA_DRAW_PANEL_GAL::ForceRefresh() void EDA_DRAW_PANEL_GAL::SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher ) { m_eventDispatcher = aEventDispatcher; - -#if wxCHECK_VERSION( 3, 0, 0 ) const wxEventType eventTypes[] = { wxEVT_TOOL }; -#else - const wxEventType eventTypes[] = { wxEVT_COMMAND_MENU_SELECTED, wxEVT_COMMAND_TOOL_CLICKED }; -#endif if( m_eventDispatcher ) { @@ -310,7 +305,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) // warn about unhandled GAL canvas type, but continue with the fallback option case GAL_TYPE_NONE: - // KIGFX::GAL is a stub - it actually does cannot display anything, + // KIGFX::GAL is a stub - it actually does cannot display anything, // but prevents code relying on GAL canvas existence from crashing new_gal = new KIGFX::GAL(); break; diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 002b242585..91694bd37e 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -375,26 +375,9 @@ void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aW } -void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, EDA_COLOR_T Color ) -{ - s_DC_lastcolor = UNSPECIFIED_COLOR; - GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH ); - WinClipAndDrawLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x2, y2, width ); - s_DC_lastcolor = UNSPECIFIED_COLOR; - GRSetColorPen( DC, Color, width ); - GRLastMoveToX = x2; - GRLastMoveToY = y2; -} - - -void GRDashedLine( EDA_RECT* ClipBox, - wxDC* DC, - int x1, - int y1, - int x2, - int y2, - int width, - EDA_COLOR_T Color ) +void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, + int x1, int y1, int x2, int y2, + int width, EDA_COLOR_T Color ) { GRLastMoveToX = x2; GRLastMoveToY = y2; @@ -421,12 +404,7 @@ void GRMoveTo( int x, int y ) */ void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color ) { - int GRLineToX, GRLineToY; - - GRLineToX = x; - GRLineToY = y; - - GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, GRLineToX, GRLineToY, width, Color ); + GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color ); } diff --git a/include/gr_basic.h b/include/gr_basic.h index 2db80a7641..c68ea5a71a 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -109,15 +109,17 @@ void GRForceBlackPen( bool flagforce ); */ bool GetGRForceBlackPenState( void ); -void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor ); -void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ); +void GRLine( EDA_RECT* aClipBox, wxDC* aDC, + wxPoint aStart, wxPoint aEnd, int aWidth, EDA_COLOR_T aColor ); +void GRLine( EDA_RECT* ClipBox, wxDC* DC, + int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ); void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ); void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, EDA_COLOR_T Color ); -void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, EDA_COLOR_T Color ); void GRMoveTo( int x, int y ); -void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, EDA_COLOR_T Color ); +void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, + int x, int y, int width, EDA_COLOR_T Color ); void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill, int width, EDA_COLOR_T Color, EDA_COLOR_T BgColor ); diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 8905a6b869..838c7aa39c 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -5,10 +5,10 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License