Eradicate globals for PCB_GENERAL_SETTINGS.
Fixes: lp:1832896 * https://bugs.launchpad.net/kicad/+bug/1832896
This commit is contained in:
parent
7903cfa1da
commit
e785c140b9
|
@ -372,21 +372,18 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
|
|||
}
|
||||
|
||||
|
||||
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
|
||||
int default_val, const wxChar* group ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
|
||||
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxString& ident, bool* ptparam, int default_val,
|
||||
const wxChar* group, const wxString& legacy ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_BOOL, group, legacy )
|
||||
{
|
||||
m_Pt_param = ptparam;
|
||||
m_Default = default_val ? true : false;
|
||||
}
|
||||
|
||||
|
||||
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
|
||||
const wxString& ident,
|
||||
bool* ptparam,
|
||||
int default_val,
|
||||
const wxChar* group ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
|
||||
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
|
||||
int default_val, const wxChar* group, const wxString& legacy ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_BOOL, group, legacy )
|
||||
{
|
||||
m_Pt_param = ptparam;
|
||||
m_Default = default_val ? true : false;
|
||||
|
@ -399,7 +396,10 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) const
|
|||
if( !m_Pt_param || !aConfig )
|
||||
return;
|
||||
|
||||
int itmp = aConfig->Read( m_Ident, (int) m_Default );
|
||||
int itmp = (int) m_Default;
|
||||
|
||||
if( !aConfig->Read( m_Ident, &itmp ) && m_Ident_legacy != wxEmptyString )
|
||||
aConfig->Read( m_Ident_legacy, &itmp );
|
||||
|
||||
*m_Pt_param = itmp ? true : false;
|
||||
}
|
||||
|
@ -414,8 +414,7 @@ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const
|
|||
}
|
||||
|
||||
|
||||
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident,
|
||||
wxString* ptparam,
|
||||
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident, wxString* ptparam,
|
||||
const wxChar* group ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
|
||||
{
|
||||
|
@ -423,10 +422,8 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxString& ident,
|
|||
}
|
||||
|
||||
|
||||
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxString& ident,
|
||||
wxString* ptparam,
|
||||
const wxString& default_val,
|
||||
const wxChar* group ) :
|
||||
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxString& ident, wxString* ptparam,
|
||||
const wxString& default_val, const wxChar* group ) :
|
||||
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
|
||||
{
|
||||
m_Pt_param = ptparam;
|
||||
|
|
|
@ -243,9 +243,11 @@ public:
|
|||
|
||||
public:
|
||||
PARAM_CFG_BOOL( const wxString& ident, bool* ptparam,
|
||||
int default_val = false, const wxChar* group = NULL );
|
||||
int default_val = false, const wxChar* group = NULL,
|
||||
const wxString& legacy_ident = wxEmptyString );
|
||||
PARAM_CFG_BOOL( bool Insetup, const wxString& ident, bool* ptparam,
|
||||
int default_val = false, const wxChar* group = NULL );
|
||||
int default_val = false, const wxChar* group = NULL,
|
||||
const wxString& legacy_ident = wxEmptyString );
|
||||
|
||||
virtual void ReadParam( wxConfigBase* aConfig ) const override;
|
||||
virtual void SaveParam( wxConfigBase* aConfig ) const override;
|
||||
|
|
|
@ -118,7 +118,6 @@ class SETTINGS
|
|||
return aEntryName;
|
||||
}
|
||||
|
||||
private:
|
||||
wxString m_prefix;
|
||||
PARAM_CFG_ARRAY m_params;
|
||||
};
|
||||
|
|
|
@ -45,9 +45,9 @@ bool PANEL_MODEDIT_SETTINGS::TransferDataToWindow()
|
|||
m_UnitsSelection->SetSelection( m_frame->GetUserUnits() == INCHES ? 0 : 1 );
|
||||
|
||||
// Editing options
|
||||
m_Segments_45_Only_Ctrl->SetValue( PCB_GENERAL_SETTINGS::g_Use45DegreeGraphicSegments );
|
||||
m_MagneticPads->SetValue( PCB_GENERAL_SETTINGS::g_MagneticPads == CAPTURE_ALWAYS );
|
||||
m_dragSelects->SetValue( PCB_GENERAL_SETTINGS::g_DragSelects );
|
||||
m_Segments_45_Only_Ctrl->SetValue( m_frame->Settings().m_Use45DegreeGraphicSegments );
|
||||
m_MagneticPads->SetValue( m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS );
|
||||
m_dragSelects->SetValue( m_frame->Settings().m_DragSelects );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -60,9 +60,9 @@ bool PANEL_MODEDIT_SETTINGS::TransferDataFromWindow()
|
|||
m_frame->SetUserUnits( m_UnitsSelection->GetSelection() == 0 ? INCHES : MILLIMETRES );
|
||||
|
||||
// Editing options
|
||||
PCB_GENERAL_SETTINGS::g_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
||||
PCB_GENERAL_SETTINGS::g_MagneticPads = m_MagneticPads->GetValue() ? CAPTURE_ALWAYS : NO_EFFECT;
|
||||
PCB_GENERAL_SETTINGS::g_DragSelects = m_dragSelects->GetValue();
|
||||
m_frame->Settings().m_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
||||
m_frame->Settings().m_MagneticPads = m_MagneticPads->GetValue() ? CAPTURE_ALWAYS : NO_EFFECT;
|
||||
m_frame->Settings().m_DragSelects = m_dragSelects->GetValue();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ PANEL_PCBNEW_SETTINGS::PANEL_PCBNEW_SETTINGS( PCB_EDIT_FRAME* aFrame, PAGED_DIAL
|
|||
|
||||
bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow()
|
||||
{
|
||||
const PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_Frame->GetDisplayOptions();
|
||||
const PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) m_Frame->GetDisplayOptions();
|
||||
const PCB_GENERAL_SETTINGS& general_opts = m_Frame->Settings();
|
||||
|
||||
/* Set display options */
|
||||
m_PolarDisplay->SetSelection( m_Frame->GetShowPolarCoords() ? 1 : 0 );
|
||||
|
@ -55,12 +56,12 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow()
|
|||
rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
|
||||
m_RotationAngle->SetValue( rotationAngle );
|
||||
|
||||
m_Segments_45_Only_Ctrl->SetValue( PCB_GENERAL_SETTINGS::g_Use45DegreeGraphicSegments );
|
||||
m_magneticPadChoice->SetSelection( PCB_GENERAL_SETTINGS::g_MagneticPads );
|
||||
m_magneticTrackChoice->SetSelection( PCB_GENERAL_SETTINGS::g_MagneticTracks );
|
||||
m_magneticGraphicsChoice->SetSelection( !PCB_GENERAL_SETTINGS::g_MagneticGraphics );
|
||||
m_UseEditKeyForWidth->SetValue( PCB_GENERAL_SETTINGS::g_EditHotkeyChangesTrackWidth );
|
||||
m_dragSelects->SetValue( PCB_GENERAL_SETTINGS::g_DragSelects );
|
||||
m_Segments_45_Only_Ctrl->SetValue( general_opts.m_Use45DegreeGraphicSegments );
|
||||
m_magneticPadChoice->SetSelection( general_opts.m_MagneticPads );
|
||||
m_magneticTrackChoice->SetSelection( general_opts.m_MagneticTracks );
|
||||
m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticGraphics );
|
||||
m_UseEditKeyForWidth->SetValue( general_opts.m_EditHotkeyChangesTrackWidth );
|
||||
m_dragSelects->SetValue( general_opts.m_DragSelects );
|
||||
|
||||
m_Show_Page_Limits->SetValue( m_Frame->ShowPageLimits() );
|
||||
|
||||
|
@ -77,12 +78,12 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow()
|
|||
|
||||
/* Updating the combobox to display the active layer. */
|
||||
|
||||
PCB_GENERAL_SETTINGS::g_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
||||
PCB_GENERAL_SETTINGS::g_MagneticPads = (MAGNETIC_OPTIONS) m_magneticPadChoice->GetSelection();
|
||||
PCB_GENERAL_SETTINGS::g_MagneticTracks = (MAGNETIC_OPTIONS) m_magneticTrackChoice->GetSelection();
|
||||
PCB_GENERAL_SETTINGS::g_MagneticGraphics = !m_magneticGraphicsChoice->GetSelection();
|
||||
PCB_GENERAL_SETTINGS::g_EditHotkeyChangesTrackWidth = m_UseEditKeyForWidth->GetValue();
|
||||
PCB_GENERAL_SETTINGS::g_DragSelects = m_dragSelects->GetValue();
|
||||
m_Frame->Settings().m_Use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();
|
||||
m_Frame->Settings().m_MagneticPads = (MAGNETIC_OPTIONS) m_magneticPadChoice->GetSelection();
|
||||
m_Frame->Settings().m_MagneticTracks = (MAGNETIC_OPTIONS) m_magneticTrackChoice->GetSelection();
|
||||
m_Frame->Settings().m_MagneticGraphics = !m_magneticGraphicsChoice->GetSelection();
|
||||
m_Frame->Settings().m_EditHotkeyChangesTrackWidth = m_UseEditKeyForWidth->GetValue();
|
||||
m_Frame->Settings().m_DragSelects = m_dragSelects->GetValue();
|
||||
|
||||
m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() );
|
||||
|
||||
|
|
|
@ -24,32 +24,38 @@
|
|||
#include <pcb_general_settings.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
bool PCB_GENERAL_SETTINGS::g_Use45DegreeGraphicSegments = false;
|
||||
bool PCB_GENERAL_SETTINGS::g_EditHotkeyChangesTrackWidth = false;
|
||||
bool PCB_GENERAL_SETTINGS::g_DragSelects = true;
|
||||
|
||||
MAGNETIC_OPTIONS PCB_GENERAL_SETTINGS::g_MagneticPads = CAPTURE_CURSOR_IN_TRACK_TOOL;
|
||||
MAGNETIC_OPTIONS PCB_GENERAL_SETTINGS::g_MagneticTracks = CAPTURE_CURSOR_IN_TRACK_TOOL;
|
||||
bool PCB_GENERAL_SETTINGS::g_MagneticGraphics = true;
|
||||
|
||||
|
||||
PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType )
|
||||
: m_frameType( aFrameType ), m_colorsSettings( aFrameType )
|
||||
PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) :
|
||||
m_Use45DegreeGraphicSegments( false ),
|
||||
m_EditHotkeyChangesTrackWidth( false ),
|
||||
m_DragSelects( true ),
|
||||
m_MagneticPads( CAPTURE_CURSOR_IN_TRACK_TOOL ),
|
||||
m_MagneticTracks( CAPTURE_CURSOR_IN_TRACK_TOOL ),
|
||||
m_MagneticGraphics( true ),
|
||||
m_frameType( aFrameType ),
|
||||
m_colorsSettings( aFrameType )
|
||||
{
|
||||
switch( m_frameType )
|
||||
{
|
||||
case FRAME_PCB:
|
||||
Add( "Use45DegreeGraphicSegments", &g_Use45DegreeGraphicSegments, false);
|
||||
Add( "MagneticPads", reinterpret_cast<int*>( &g_MagneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
|
||||
Add( "MagneticTracks", reinterpret_cast<int*>( &g_MagneticTracks ), CAPTURE_CURSOR_IN_TRACK_TOOL );
|
||||
Add( "MagneticGraphics", &g_MagneticGraphics, true );
|
||||
Add( "EditActionChangesTrackWidth", &g_EditHotkeyChangesTrackWidth, false );
|
||||
Add( "DragSelects", &g_DragSelects, true );
|
||||
Add( "Use45DegreeGraphicSegments", &m_Use45DegreeGraphicSegments, false);
|
||||
Add( "MagneticPads", reinterpret_cast<int*>( &m_MagneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
|
||||
Add( "MagneticTracks", reinterpret_cast<int*>( &m_MagneticTracks ), CAPTURE_CURSOR_IN_TRACK_TOOL );
|
||||
Add( "MagneticGraphics", &m_MagneticGraphics, true );
|
||||
Add( "EditActionChangesTrackWidth", &m_EditHotkeyChangesTrackWidth, false );
|
||||
Add( "DragSelects", &m_DragSelects, true );
|
||||
break;
|
||||
|
||||
case FRAME_PCB_MODULE_EDITOR:
|
||||
Add( "Use45DegreeGraphicSegments", &g_Use45DegreeGraphicSegments, false);
|
||||
Add( "MagneticPads", reinterpret_cast<int*>( &g_MagneticPads ), CAPTURE_CURSOR_IN_TRACK_TOOL );
|
||||
m_params.push_back( new PARAM_CFG_BOOL( "FpEditorUse45DegreeGraphicSegments",
|
||||
&m_Use45DegreeGraphicSegments, false,
|
||||
nullptr, "Use45DegreeGraphicSegments" ) ); // legacy location
|
||||
m_params.push_back( new PARAM_CFG_INT( "FpEditorMagneticPads",
|
||||
reinterpret_cast<int*>( &m_MagneticPads ),
|
||||
CAPTURE_CURSOR_IN_TRACK_TOOL, // default
|
||||
NO_EFFECT, // min
|
||||
CAPTURE_ALWAYS, // max
|
||||
nullptr, "MagneticPads" ) ); // legacy location
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -47,15 +47,15 @@ public:
|
|||
|
||||
COLORS_DESIGN_SETTINGS& Colors() { return m_colorsSettings; }
|
||||
|
||||
static bool g_Use45DegreeGraphicSegments; // True to constraint graphic lines to horizontal,
|
||||
// vertical and 45º
|
||||
static bool g_EditHotkeyChangesTrackWidth;
|
||||
static bool g_DragSelects; // True: Drag gesture always draws a selection box,
|
||||
// False: Drag will select an item and move it
|
||||
bool m_Use45DegreeGraphicSegments; // True to constraint graphic lines to horizontal,
|
||||
// vertical and 45º
|
||||
bool m_EditHotkeyChangesTrackWidth;
|
||||
bool m_DragSelects; // True: Drag gesture always draws a selection box,
|
||||
// False: Drag will select an item and move it
|
||||
|
||||
static MAGNETIC_OPTIONS g_MagneticPads;
|
||||
static MAGNETIC_OPTIONS g_MagneticTracks;
|
||||
static bool g_MagneticGraphics;
|
||||
MAGNETIC_OPTIONS m_MagneticPads;
|
||||
MAGNETIC_OPTIONS m_MagneticTracks;
|
||||
bool m_MagneticGraphics;
|
||||
|
||||
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
|
||||
std::vector< std::pair<wxString, wxString> > m_pluginSettings; // Settings for action plugins
|
||||
|
|
|
@ -237,11 +237,11 @@ bool TOOL_BASE::checkSnap( ITEM *aItem )
|
|||
// Sync PNS engine settings with the general PCB editor options.
|
||||
auto& pnss = m_router->Settings();
|
||||
|
||||
pnss.SetSnapToPads( PCB_GENERAL_SETTINGS::g_MagneticPads == CAPTURE_CURSOR_IN_TRACK_TOOL
|
||||
|| PCB_GENERAL_SETTINGS::g_MagneticPads == CAPTURE_ALWAYS );
|
||||
pnss.SetSnapToPads( frame()->Settings().m_MagneticPads == CAPTURE_CURSOR_IN_TRACK_TOOL
|
||||
|| frame()->Settings().m_MagneticPads == CAPTURE_ALWAYS );
|
||||
|
||||
pnss.SetSnapToTracks( PCB_GENERAL_SETTINGS::g_MagneticTracks == CAPTURE_CURSOR_IN_TRACK_TOOL
|
||||
|| PCB_GENERAL_SETTINGS::g_MagneticTracks == CAPTURE_ALWAYS );
|
||||
pnss.SetSnapToTracks( frame()->Settings().m_MagneticTracks == CAPTURE_CURSOR_IN_TRACK_TOOL
|
||||
|| frame()->Settings().m_MagneticTracks == CAPTURE_ALWAYS );
|
||||
|
||||
if( aItem )
|
||||
{
|
||||
|
|
|
@ -877,7 +877,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
|
|||
m_controls->ForceCursorPosition( true, cursorPos );
|
||||
|
||||
// 45 degree angle constraint enabled with an option and toggled with Ctrl
|
||||
const bool limit45 = ( frame()->Settings().g_Use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
|
||||
const bool limit45 = ( frame()->Settings().m_Use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
|
||||
|
||||
if( direction45 != limit45 && started && aShape == S_SEGMENT )
|
||||
{
|
||||
|
|
|
@ -503,7 +503,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
bool EDIT_TOOL::changeTrackWidthOnClick( const PCBNEW_SELECTION& selection )
|
||||
{
|
||||
if ( selection.Size() == 1 && frame()->Settings().g_EditHotkeyChangesTrackWidth )
|
||||
if ( selection.Size() == 1 && frame()->Settings().m_EditHotkeyChangesTrackWidth )
|
||||
{
|
||||
auto item = static_cast<BOARD_ITEM *>( selection[0] );
|
||||
|
||||
|
|
|
@ -332,7 +332,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, co
|
|||
|
||||
for( auto pad : mod->Pads() )
|
||||
{
|
||||
if(( aFrom || PCB_GENERAL_SETTINGS::g_MagneticPads == CAPTURE_ALWAYS ) &&
|
||||
if(( aFrom || m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS ) &&
|
||||
pad->GetBoundingBox().Contains( wxPoint( aRefPos.x, aRefPos.y ) ) )
|
||||
{
|
||||
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
||||
|
@ -347,7 +347,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, co
|
|||
|
||||
case PCB_PAD_T:
|
||||
{
|
||||
if( aFrom || PCB_GENERAL_SETTINGS::g_MagneticPads == CAPTURE_ALWAYS )
|
||||
if( aFrom || m_frame->Settings().m_MagneticPads == CAPTURE_ALWAYS )
|
||||
{
|
||||
D_PAD* pad = static_cast<D_PAD*>( aItem );
|
||||
addAnchor( pad->GetPosition(), CORNER | SNAPPABLE, pad );
|
||||
|
@ -359,7 +359,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, co
|
|||
case PCB_MODULE_EDGE_T:
|
||||
case PCB_LINE_T:
|
||||
{
|
||||
if( !PCB_GENERAL_SETTINGS::g_MagneticGraphics )
|
||||
if( !m_frame->Settings().m_MagneticGraphics )
|
||||
break;
|
||||
|
||||
DRAWSEGMENT* dseg = static_cast<DRAWSEGMENT*>( aItem );
|
||||
|
@ -422,7 +422,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, co
|
|||
|
||||
case PCB_TRACE_T:
|
||||
{
|
||||
if( aFrom || PCB_GENERAL_SETTINGS::g_MagneticTracks == CAPTURE_ALWAYS )
|
||||
if( aFrom || m_frame->Settings().m_MagneticTracks == CAPTURE_ALWAYS )
|
||||
{
|
||||
TRACK* track = static_cast<TRACK*>( aItem );
|
||||
VECTOR2I start = track->GetStart();
|
||||
|
@ -444,7 +444,7 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, co
|
|||
|
||||
case PCB_VIA_T:
|
||||
{
|
||||
if( aFrom ||PCB_GENERAL_SETTINGS::g_MagneticTracks == CAPTURE_ALWAYS )
|
||||
if( aFrom || m_frame->Settings().m_MagneticTracks == CAPTURE_ALWAYS )
|
||||
addAnchor( aItem->GetPosition(), ORIGIN | CORNER | SNAPPABLE, aItem );
|
||||
|
||||
break;
|
||||
|
|
|
@ -262,7 +262,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
else if( m_selection.Empty() )
|
||||
{
|
||||
// There is nothing selected, so try to select something
|
||||
if( getEditFrame<PCB_BASE_FRAME>()->Settings().g_DragSelects || !selectCursor() )
|
||||
if( getEditFrame<PCB_BASE_FRAME>()->Settings().m_DragSelects || !selectCursor() )
|
||||
{
|
||||
// If nothings has been selected, user wants to select more or selection
|
||||
// box is preferred to dragging - draw selection box
|
||||
|
|
Loading…
Reference in New Issue