diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index c7fea04927..f12fedc871 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -78,16 +78,6 @@ static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) ); ///@{ /// \ingroup config -/// User units -static const wxString UserUnitsEntryKeyword( wxT( "Units" ) ); -static const wxString FpEditorUserUnitsEntryKeyword( wxT( "FpEditorUnits" ) ); -/// Nonzero to show grid (suffix) -static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) ); -/// Grid color ID (suffix) -static const wxString GridColorEntryKeyword( wxT( "GridColor" ) ); -/// Most recently used grid size (suffix) -static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) ); - const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" ); static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) ); diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp index b94504550b..0c44f754fe 100644 --- a/common/legacy_wx/eda_draw_frame.cpp +++ b/common/legacy_wx/eda_draw_frame.cpp @@ -81,16 +81,6 @@ static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) ); ///@{ /// \ingroup config -/// User units -static const wxString UserUnitsEntryKeyword( wxT( "Units" ) ); -static const wxString FpEditorUserUnitsEntryKeyword( wxT( "FpEditorUnits" ) ); -/// Nonzero to show grid (suffix) -static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) ); -/// Grid color ID (suffix) -static const wxString GridColorEntryKeyword( wxT( "GridColor" ) ); -/// Most recently used grid size (suffix) -static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) ); - const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" ); static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) ); diff --git a/include/draw_frame.h b/include/draw_frame.h index ae54b260cb..4e2f9f0a7c 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -55,6 +55,22 @@ namespace KIGFX #define FOOTPRINT_VIEWER_FRAME_NAME_MODAL wxT( "ModViewFrameModal" ) #define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" ) + +///@{ +/// \ingroup config + +/// User units +static const wxString UserUnitsEntryKeyword( wxT( "Units" ) ); +/// Nonzero to show grid (suffix) +static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) ); +/// Grid color ID (suffix) +static const wxString GridColorEntryKeyword( wxT( "GridColor" ) ); +/// Most recently used grid size (suffix) +static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) ); + +///@} + + /** * Class EDA_DRAW_FRAME * is the base class for create windows for drawing purpose. The Eeschema, Pcbnew and diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 9b924101db..d09d4d6073 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -30,14 +30,15 @@ #include #include #include - +#include #include #include #include #include - +#include #include - +#include +#include /** * Threadsafe interface class between loader thread and panel class. @@ -367,7 +368,29 @@ wxWindow* FOOTPRINT_PREVIEW_PANEL::GetWindow() FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* aParent ) { + PCB_EDIT_FRAME* pcbnew = static_cast( aKiway->Player( FRAME_PCB, false ) ); KIGFX::GAL_DISPLAY_OPTIONS gal_opts; + wxConfigBase* cfg = Kiface().KifaceSettings(); + wxConfigBase* commonCfg = Pgm().CommonSettings(); + bool btemp; + int itemp; + wxString msg; + COLOR4D ctemp; + + // Fetch grid & display settings from PCBNew if it's running; otherwise fetch them + // from PCBNew's config settings. + + if( pcbnew ) + { + gal_opts = pcbnew->GetGalDisplayOptions(); + } + else + { + gal_opts.ReadConfig( cfg, wxString( PCB_EDIT_FRAME_NAME ) + GAL_DISPLAY_OPTIONS_KEY ); + + commonCfg->Read( GAL_ANTIALIASING_MODE_KEY, &itemp, (int) KIGFX::OPENGL_ANTIALIASING_MODE::NONE ); + gal_opts.gl_antialiasing_mode = (KIGFX::OPENGL_ANTIALIASING_MODE) itemp; + } #ifdef __WXMAC__ // Cairo renderer doesn't handle Retina displays @@ -375,5 +398,34 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* #else EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; #endif - return new FOOTPRINT_PREVIEW_PANEL( aKiway, aParent, gal_opts, backend ); + + auto panel = new FOOTPRINT_PREVIEW_PANEL( aKiway, aParent, gal_opts, backend ); + + if( pcbnew ) + { + panel->GetGAL()->SetGridVisibility( pcbnew->IsGridVisible() ); + panel->GetGAL()->SetGridSize( VECTOR2D( pcbnew->GetScreen()->GetGridSize() ) ); + + // Grid color (among other things): + KIGFX::PAINTER* pcbnew_painter = pcbnew->GetGalCanvas()->GetView()->GetPainter(); + panel->GetView()->GetPainter()->ApplySettings( pcbnew_painter->GetSettings() ); + } + else + { + btemp = cfg->ReadBool( wxString( PCB_EDIT_FRAME_NAME ) + ShowGridEntryKeyword, true ); + panel->GetGAL()->SetGridVisibility( btemp ); + + // Read grid size: + std::unique_ptr temp_screen = std::make_unique( wxSize() ); + cfg->Read( wxString( PCB_EDIT_FRAME_NAME ) + LastGridSizeIdKeyword, &itemp, 0L ); + temp_screen->SetGrid( itemp + ID_POPUP_GRID_LEVEL_1000 ); + panel->GetGAL()->SetGridSize( VECTOR2D( temp_screen->GetGridSize() ) ); + + // Read grid color: + msg = cfg->Read( wxString( PCB_EDIT_FRAME_NAME ) + GridColorEntryKeyword, wxT( "NONE" ) ); + ctemp.SetFromWxString( msg ); + panel->GetGAL()->SetGridColor( ctemp ); + } + + return panel; }