From 73b52f2e23f6583693a7d6cf98d02b5bee1794af Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 20 Nov 2018 10:22:45 +0100 Subject: [PATCH] Gerbview: fix incorrect initialization of WorldUnitLength. Fix incorrect min zoom level to show D Code texts. --- common/gal/graphics_abstraction_layer.cpp | 2 ++ gerbview/gerber_draw_item.cpp | 2 +- gerbview/gerbview_draw_panel_gal.cpp | 4 ++++ gerbview/gerbview_painter.cpp | 2 +- gerbview/gerbview_printout.cpp | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 5104f8fd6f..74074dcd36 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -46,6 +46,8 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : SetLookAtPoint( VECTOR2D( 0, 0 ) ); SetZoomFactor( 1.0 ); SetRotation( 0.0 ); + // this value for SetWorldUnitLength is only suitable for Pcbnew. + // Other editors/viewer must call SetWorldUnitLength with their internal units SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ ); // wxDC::GetPPI() reports 96 DPI, but somehow this value // is the closest match to the legacy renderer diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index b110b0943f..a8e98c1773 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -958,7 +958,7 @@ unsigned int GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) cons // the level of details is chosen experimentally, to show // only a readable text: - const int level = Millimeter2iu( 500 ); + const int level = Millimeter2iu( 4 ); return ( level / ( size + 1 ) ); } diff --git a/gerbview/gerbview_draw_panel_gal.cpp b/gerbview/gerbview_draw_panel_gal.cpp index def79ca5c2..6206b12c21 100644 --- a/gerbview/gerbview_draw_panel_gal.cpp +++ b/gerbview/gerbview_draw_panel_gal.cpp @@ -39,6 +39,7 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy { m_view = new KIGFX::VIEW( true ); m_view->SetGAL( m_gal ); + GetGAL()->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ ); m_painter.reset( new KIGFX::GERBVIEW_PAINTER( m_gal ) ); m_view->SetPainter( m_painter.get() ); @@ -116,6 +117,9 @@ bool GERBVIEW_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType ) { bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType ); setDefaultLayerDeps(); + + GetGAL()->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ ); + return rv; } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index e0a27981d5..20dbd6c57f 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -214,7 +214,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetStrokeColor( color ); m_gal->SetFillColor( COLOR4D( 0, 0, 0, 0 ) ); - m_gal->SetLineWidth( 2 ); + m_gal->SetLineWidth( textSize/10 ); m_gal->SetFontBold( false ); m_gal->SetFontItalic( false ); m_gal->SetTextMirrored( false ); diff --git a/gerbview/gerbview_printout.cpp b/gerbview/gerbview_printout.cpp index 4e410880f7..45bb017f7f 100644 --- a/gerbview/gerbview_printout.cpp +++ b/gerbview/gerbview_printout.cpp @@ -107,7 +107,7 @@ void GERBVIEW_PRINTOUT::setupViewLayers( const std::unique_ptr& aVi void GERBVIEW_PRINTOUT::setupGal( KIGFX::GAL* aGal ) { BOARD_PRINTOUT::setupGal( aGal ); - aGal->SetWorldUnitLength( 10e-9 /* 10 nm */ / 0.0254 /* 1 inch in meters */ ); + aGal->SetWorldUnitLength( 1.0/IU_PER_MM /* 10 nm */ / 25.4 /* 1 inch in mm */ ); }