Inherit grid settings from PCBNew.

Fixes: lp:1801428
* https://bugs.launchpad.net/kicad/+bug/1801428
This commit is contained in:
Jeff Young 2018-11-03 12:35:17 +00:00
parent 8c1ebc4314
commit 3bfd32cdc5
4 changed files with 72 additions and 24 deletions

View File

@ -78,16 +78,6 @@ static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
///@{ ///@{
/// \ingroup config /// \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" ); const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) ); static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) );

View File

@ -81,16 +81,6 @@ static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
///@{ ///@{
/// \ingroup config /// \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" ); const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) ); static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) );

View File

@ -55,6 +55,22 @@ namespace KIGFX
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL wxT( "ModViewFrameModal" ) #define FOOTPRINT_VIEWER_FRAME_NAME_MODAL wxT( "ModViewFrameModal" )
#define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" ) #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 * Class EDA_DRAW_FRAME
* is the base class for create windows for drawing purpose. The Eeschema, Pcbnew and * is the base class for create windows for drawing purpose. The Eeschema, Pcbnew and

View File

@ -30,14 +30,15 @@
#include <class_module.h> #include <class_module.h>
#include <class_board.h> #include <class_board.h>
#include <ki_mutex.h> #include <ki_mutex.h>
#include <draw_frame.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <utility> #include <utility>
#include <make_unique.h> #include <make_unique.h>
#include <colors_design_settings.h> #include <colors_design_settings.h>
#include <pcb_edit_frame.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <pgm_base.h>
#include <painter.h>
/** /**
* Threadsafe interface class between loader thread and panel class. * 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 ) FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* aParent )
{ {
PCB_EDIT_FRAME* pcbnew = static_cast<PCB_EDIT_FRAME*>( aKiway->Player( FRAME_PCB, false ) );
KIGFX::GAL_DISPLAY_OPTIONS gal_opts; 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__ #ifdef __WXMAC__
// Cairo renderer doesn't handle Retina displays // Cairo renderer doesn't handle Retina displays
@ -375,5 +398,34 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow*
#else #else
EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
#endif #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<PCB_SCREEN> temp_screen = std::make_unique<PCB_SCREEN>( 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;
} }