Implement a new settings framework across all of KiCad

CHANGED: Settings are now stored in versioned sub-directories
ADDED: First-run dialog for migrating settings from a previous version
CHANGED: Settings are now stored as JSON files instead of wxConfig-style INI files
CHANGED: Color settings are now all stored in a separate settings file
CHANGED: The symbol editor and footprint editor now have their own settings files
CHANGED: Color settings are no longer exposed through BOARD object
CHANGED: Page layout editor now uses Eeschema's color scheme

Settings are now managed through a central SETTINGS_MANAGER held by PGM_BASE.
Existing settings will be migrated from the wxConfig format on first run of each application.
Per-application settings are now stored in one class for each application.
This commit is contained in:
Jon Evans 2020-01-12 20:44:19 -05:00
parent 1449af40ed
commit e59a3d981e
334 changed files with 10703 additions and 4196 deletions

View File

@ -57,6 +57,7 @@
#include <filename_resolver.h> #include <filename_resolver.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <project.h> #include <project.h>
#include <settings/settings_manager.h>
#define MASK_3D_CACHE "3D_CACHE" #define MASK_3D_CACHE "3D_CACHE"
@ -793,7 +794,7 @@ S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir )
cache = new S3D_CACHE(); cache = new S3D_CACHE();
wxFileName cfgpath; wxFileName cfgpath;
cfgpath.AssignDir( GetKicadConfigPath() ); cfgpath.AssignDir( SETTINGS_MANAGER::GetUserSettingsPath() );
cfgpath.AppendDir( wxT( "3d" ) ); cfgpath.AppendDir( wxT( "3d" ) );
cache->SetProgramBase( &Pgm() ); cache->SetProgramBase( &Pgm() );

View File

@ -26,7 +26,6 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <wx/config.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/dynlib.h> #include <wx/dynlib.h>
#include <wx/filename.h> #include <wx/filename.h>

View File

@ -26,13 +26,14 @@
#include "panel_prev_model.h" #include "panel_prev_model.h"
#include <3d_canvas/eda_3d_canvas.h> #include <3d_canvas/eda_3d_canvas.h>
#include <common_ogl/cogl_att_list.h>
#include <class_board.h>
#include <base_units.h> #include <base_units.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <class_board.h>
#include <common_ogl/cogl_att_list.h>
#include <dpi_scaling.h> #include <dpi_scaling.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <project.h> #include <project.h>
#include <settings/common_settings.h>
PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule, PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* aModule,
@ -43,9 +44,6 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE*
initPanel(); initPanel();
// Initialize the color settings to draw the board and the footprint
m_dummyBoard->SetGeneralSettings( &aFrame->Settings() );
m_parentModelList = aParentModelList; m_parentModelList = aParentModelList;
m_dummyModule = new MODULE( *aModule ); m_dummyModule = new MODULE( *aModule );
@ -109,18 +107,12 @@ void PANEL_PREV_3D::loadCommonSettings()
{ {
wxCHECK_RET( m_previewPane, "Cannot load settings to null canvas" ); wxCHECK_RET( m_previewPane, "Cannot load settings to null canvas" );
wxConfigBase& cmnCfg = *Pgm().CommonSettings(); COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
{ const DPI_SCALING dpi{ settings, this };
const DPI_SCALING dpi{ &cmnCfg, this };
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() ); m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
}
{ m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan );
bool option;
cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, option );
}
} }

View File

@ -35,6 +35,8 @@
#include "3d_fastmath.h" #include "3d_fastmath.h"
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <math/util.h> // for KiROUND #include <math/util.h> // for KiROUND
#include <pgm_base.h>
#include <settings/settings_manager.h>
/** /**
* Trace mask used to enable or disable the trace output of this class. * Trace mask used to enable or disable the trace output of this class.
@ -59,6 +61,9 @@ CINFO3D_VISU::CINFO3D_VISU() :
m_3D_grid_type = GRID3D_TYPE::NONE; m_3D_grid_type = GRID3D_TYPE::NONE;
m_drawFlags.resize( FL_LAST, false ); m_drawFlags.resize( FL_LAST, false );
if( PgmOrNull() )
m_colors = Pgm().GetSettingsManager().GetColorSettings();
m_render_engine = RENDER_ENGINE::OPENGL_LEGACY; m_render_engine = RENDER_ENGINE::OPENGL_LEGACY;
m_material_mode = MATERIAL_MODE::NORMAL; m_material_mode = MATERIAL_MODE::NORMAL;
@ -504,7 +509,7 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( PCB_LAYER_ID aLayerId ) const
{ {
wxASSERT( aLayerId < PCB_LAYER_ID_COUNT ); wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId ); const COLOR4D color = m_colors->GetColor( aLayerId );
return SFVEC3F( color.r, color.g, color.b ); return SFVEC3F( color.r, color.g, color.b );
} }
@ -512,7 +517,7 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( PCB_LAYER_ID aLayerId ) const
SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const
{ {
return GetColor( m_board->Colors().GetItemColor( aItemId ) ); return GetColor( m_colors->GetColor( aItemId ) );
} }

View File

@ -51,6 +51,9 @@
#include <class_module.h> #include <class_module.h>
#include <reporter.h> #include <reporter.h>
class COLOR_SETTINGS;
/// A type that stores a container of 2d objects for each layer id /// A type that stores a container of 2d objects for each layer id
typedef std::map< PCB_LAYER_ID, CBVHCONTAINER2D *> MAP_CONTAINER_2D; typedef std::map< PCB_LAYER_ID, CBVHCONTAINER2D *> MAP_CONTAINER_2D;
@ -127,6 +130,8 @@ class CINFO3D_VISU
*/ */
const BOARD *GetBoard() const { return m_board; } const BOARD *GetBoard() const { return m_board; }
void SetColorSettings( COLOR_SETTINGS* aSettings ) { m_colors = aSettings; }
/** /**
* @brief InitSettings - Function to be called by the render when it need to * @brief InitSettings - Function to be called by the render when it need to
* reload the settings for the board. * reload the settings for the board.
@ -519,6 +524,8 @@ private:
/// pointer to the 3d model manager /// pointer to the 3d model manager
S3D_CACHE *m_3d_model_manager; S3D_CACHE *m_3d_model_manager;
/// pointer to current color settings
COLOR_SETTINGS* m_colors;
// Render options // Render options

View File

@ -44,6 +44,8 @@
#include <bitmaps.h> #include <bitmaps.h>
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
#include <widgets/wx_busy_indicator.h> #include <widgets/wx_busy_indicator.h>
@ -153,6 +155,8 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
wxASSERT( aBoard != NULL ); wxASSERT( aBoard != NULL );
m_settings.SetBoard( aBoard ); m_settings.SetBoard( aBoard );
m_settings.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
wxASSERT( a3DCachePointer != NULL ); wxASSERT( a3DCachePointer != NULL );
m_settings.Set3DCacheManager( a3DCachePointer ); m_settings.Set3DCacheManager( a3DCachePointer );
} }
@ -285,6 +289,8 @@ void EDA_3D_CANVAS::ReloadRequest( BOARD *aBoard , S3D_CACHE *aCachePointer )
if( aBoard != NULL ) if( aBoard != NULL )
m_settings.SetBoard( aBoard ); m_settings.SetBoard( aBoard );
m_settings.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
if( m_3d_render ) if( m_3d_render )
m_3d_render->ReloadRequest(); m_3d_render->ReloadRequest();
} }

View File

@ -0,0 +1,157 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <3d_enums.h>
#include <settings/common_settings.h>
#include <settings/parameters.h>
#include <settings/settings_manager.h>
#include <wx/config.h>
#include "3d_viewer_settings.h"
///! Update the schema version whenever a migration is required
const int viewer3dSchemaVersion = 0;
EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
APP_SETTINGS_BASE( "3d_viewer", viewer3dSchemaVersion ), m_Render()
{
m_params.emplace_back( new PARAM<int>( "render.engine", &m_Render.engine,
static_cast<int>( RENDER_ENGINE::OPENGL_LEGACY ),
static_cast<int>( RENDER_ENGINE::OPENGL_LEGACY ),
static_cast<int>( RENDER_ENGINE::RAYTRACING ) ) );
m_params.emplace_back( new PARAM<int>( "render.grid_type", &m_Render.grid_type,
static_cast<int>( GRID3D_TYPE::NONE ),
static_cast<int>( GRID3D_TYPE::NONE ),
static_cast<int>( GRID3D_TYPE::GRID_10MM ) ) );
m_params.emplace_back( new PARAM<int>( "render.material_mode", &m_Render.material_mode,
static_cast<int>( MATERIAL_MODE::NORMAL ),
static_cast<int>( MATERIAL_MODE::NORMAL ),
static_cast<int>( MATERIAL_MODE::CAD_MODE ) ) );
m_params.emplace_back( new PARAM<bool>(
"render.opengl_copper_thickness", &m_Render.opengl_copper_thickness, true ) );
m_params.emplace_back( new PARAM<bool>(
"render.opengl_show_model_bbox", &m_Render.opengl_show_model_bbox, false ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_anti_aliasing",
&m_Render.raytrace_anti_aliasing, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_backfloor",
&m_Render.raytrace_backfloor, false ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_post_processing",
&m_Render.raytrace_post_processing, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_procedural_textures",
&m_Render.raytrace_procedural_textures, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_reflections",
&m_Render.raytrace_reflections, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_refractions",
&m_Render.raytrace_refractions, true ) );
m_params.emplace_back( new PARAM<bool>( "render.raytrace_shadows",
&m_Render.raytrace_shadows, true ) );
m_params.emplace_back( new PARAM<bool>( "render.realistic", &m_Render.realistic, true ) );
m_params.emplace_back(
new PARAM<bool>( "render.show_adhesive", &m_Render.show_adhesive, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_axis", &m_Render.show_axis, true ) );
m_params.emplace_back(
new PARAM<bool>( "render.show_board_body", &m_Render.show_board_body, true ) );
m_params.emplace_back(
new PARAM<bool>( "render.show_comments", &m_Render.show_comments, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_eco", &m_Render.show_eco, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_insert",
&m_Render.show_footprints_insert, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_normal",
&m_Render.show_footprints_normal, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_footprints_virtual",
&m_Render.show_footprints_virtual, true ) );
m_params.emplace_back(
new PARAM<bool>( "render.show_silkscreen", &m_Render.show_silkscreen, true ) );
m_params.emplace_back(
new PARAM<bool>( "render.show_soldermask", &m_Render.show_soldermask, true ) );
m_params.emplace_back(
new PARAM<bool>( "render.show_solderpaste", &m_Render.show_solderpaste, true ) );
m_params.emplace_back( new PARAM<bool>( "render.show_zones", &m_Render.show_zones, true ) );
m_params.emplace_back( new PARAM<bool>( "render.subtract_mask_from_silk",
&m_Render.subtract_mask_from_silk, false ) );
}
bool EDA_3D_VIEWER_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
ret &= fromLegacy<int>( aCfg, "RenderEngine", "render.engine" );
ret &= fromLegacy<int>( aCfg, "ShowGrid3D", "render.grid_type" );
ret &= fromLegacy<int>( aCfg, "Render_Material", "render.material_mode" );
ret &= fromLegacy<bool>(
aCfg, "Render_OGL_ShowCopperThickness", "render.opengl_copper_thickness" );
ret &= fromLegacy<bool>(
aCfg, "Render_OGL_ShowModelBoudingBoxes", "render.opengl_show_model_bbox" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_AntiAliasing", "render.raytrace_anti_aliasing" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Backfloor", "render.raytrace_backfloor" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_PostProcess", "render.raytrace_post_processing" );
ret &= fromLegacy<bool>(
aCfg, "Render_RAY_ProceduralTextures", "render.raytrace_procedural_textures" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Reflections", "render.raytrace_reflections" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Refractions", "render.raytrace_refractions" );
ret &= fromLegacy<bool>( aCfg, "Render_RAY_Shadows", "render.raytrace_shadows" );
ret &= fromLegacy<bool>( aCfg, "ShowRealisticMode", "render.realistic" );
ret &= fromLegacy<bool>( aCfg, "ShowAdhesiveLayers", "render.show_adhesive" );
ret &= fromLegacy<bool>( aCfg, "ShowAxis", "render.show_axis" );
ret &= fromLegacy<bool>( aCfg, "ShowBoardBody", "render.show_board_body" );
ret &= fromLegacy<bool>( aCfg, "ShowCommentsLayers", "render.show_comments" );
ret &= fromLegacy<bool>( aCfg, "ShowEcoLayers", "render.show_eco" );
ret &= fromLegacy<bool>( aCfg, "ShowFootprints_Insert", "render.show_footprints_insert" );
ret &= fromLegacy<bool>( aCfg, "ShowFootprints_Normal", "render.show_footprints_normal" );
ret &= fromLegacy<bool>( aCfg, "ShowFootprints_Virtual", "render.show_footprints_virtual" );
ret &= fromLegacy<bool>( aCfg, "ShowSilkScreenLayers", "render.show_silkscreen" );
ret &= fromLegacy<bool>( aCfg, "ShowSolderMasLayers", "render.show_soldermask" );
ret &= fromLegacy<bool>( aCfg, "ShowSolderPasteLayers", "render.show_solderpaste" );
ret &= fromLegacy<bool>( aCfg, "ShowZones", "render.show_zones" );
ret &= fromLegacy<bool>( aCfg, "SubtractMaskFromSilk", "render.subtract_mask_from_silk" );
auto migrate_color =
[&] ( const std::string& k_r, const std::string& k_g,
const std::string &k_b, std::string dest )
{
COLOR4D color( 1, 1, 1, 1 );
if( aCfg->Read( k_r, &color.r ) &&
aCfg->Read( k_g, &color.g ) && aCfg->Read( k_b, &color.b ) )
{
( *this )[PointerFromString( dest )] = color;
}
};
migrate_color( "BgColor_Red", "BgColor_Green", "BgColor_Blue", "colors.background_bottom" );
migrate_color(
"BgColor_Red_Top", "BgColor_Green_Top", "BgColor_Blue_Top", "colors.background_top" );
migrate_color(
"BoardBodyColor_Red", "BoardBodyColor_Green", "BoardBodyColor_Blue", "colors.board" );
migrate_color( "CopperColor_Red", "CopperColor_Green", "CopperColor_Blue", "colors.copper" );
migrate_color(
"SilkColor_Red", "SilkColor_Green", "SilkColor_Blue", "colors.silkscreen_bottom" );
migrate_color( "SilkColor_Red", "SilkColor_Green", "SilkColor_Blue", "colors.silkscreen_top" );
migrate_color( "SMaskColor_Red", "SMaskColor_Green", "SMaskColor_Blue", "colors.soldermask" );
migrate_color(
"SPasteColor_Red", "SPasteColor_Green", "SPasteColor_Blue", "colors.solderpaste" );
return ret;
}

View File

@ -0,0 +1,122 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EDA_3D_VIEWER_SETTINGS_H_
#define EDA_3D_VIEWER_SETTINGS_H_
#include <settings/app_settings.h>
#include <settings/parameters.h>
class EDA_3D_VIEWER_SETTINGS : public APP_SETTINGS_BASE
{
public:
struct RENDER_SETTINGS
{
int engine;
int grid_type;
int material_mode;
bool opengl_copper_thickness;
bool opengl_show_model_bbox;
bool raytrace_anti_aliasing;
bool raytrace_backfloor;
bool raytrace_post_processing;
bool raytrace_procedural_textures;
bool raytrace_reflections;
bool raytrace_refractions;
bool raytrace_shadows;
bool realistic;
bool show_adhesive;
bool show_axis;
bool show_board_body;
bool show_comments;
bool show_eco;
bool show_footprints_insert;
bool show_footprints_normal;
bool show_footprints_virtual;
bool show_silkscreen;
bool show_soldermask;
bool show_solderpaste;
bool show_zones;
bool subtract_mask_from_silk;
};
EDA_3D_VIEWER_SETTINGS();
virtual ~EDA_3D_VIEWER_SETTINGS() {}
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
RENDER_SETTINGS m_Render;
protected:
virtual std::string getLegacyFrameName() const override { return "Viewer3DFrameName"; }
};
// Individual color param: not necessary once 3D viewer is migrated to color theme system
// TODO(JE) remove once irrelevant
class PARAM_COLOR : public PARAM_BASE
{
public:
PARAM_COLOR( const std::string& aJsonPath, COLOR4D* aPtr, COLOR4D aDefault,
bool aReadOnly = false ) :
PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault )
{}
void Load( JSON_SETTINGS* aSettings ) const override
{
if( m_readOnly )
return;
COLOR4D val = m_default;
try
{
val = aSettings->Get<COLOR4D>( m_path );
}
catch( ... )
{}
*m_ptr = val;
}
void Store( JSON_SETTINGS* aSettings) const override
{
aSettings->Set<COLOR4D>( m_path, *m_ptr );
}
COLOR4D GetDefault() const
{
return m_default;
}
virtual void SetDefault() override
{
*m_ptr = m_default;
}
private:
COLOR4D* m_ptr;
COLOR4D m_default;
};
#endif

View File

@ -23,7 +23,7 @@
*/ */
#include "eda_3d_viewer.h" #include "eda_3d_viewer.h"
#include "3d_viewer_settings.h"
#include "../3d_viewer_id.h" #include "../3d_viewer_id.h"
#include "../common_ogl/cogl_att_list.h" #include "../common_ogl/cogl_att_list.h"
@ -35,8 +35,11 @@
#include <dpi_scaling.h> #include <dpi_scaling.h>
#include <gestfich.h> #include <gestfich.h>
#include <hotkeys_basic.h> #include <hotkeys_basic.h>
#include <layers_id_colors_and_visibility.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <project.h> #include <project.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
@ -56,67 +59,6 @@
const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" ); const wxChar * EDA_3D_VIEWER::m_logTrace = wxT( "KI_TRACE_EDA_3D_VIEWER" );
// Key to store 3D Viewer config
static const wxChar keyBgColor_Red[] = wxT( "BgColor_Red" );
static const wxChar keyBgColor_Green[] = wxT( "BgColor_Green" );
static const wxChar keyBgColor_Blue[] = wxT( "BgColor_Blue" );
static const wxChar keyBgColor_Red_Top[] = wxT( "BgColor_Red_Top" );
static const wxChar keyBgColor_Green_Top[] = wxT( "BgColor_Green_Top" );
static const wxChar keyBgColor_Blue_Top[] = wxT( "BgColor_Blue_Top" );
static const wxChar keySMaskColor_Red[] = wxT( "SMaskColor_Red" );
static const wxChar keySMaskColor_Green[] = wxT( "SMaskColor_Green" );
static const wxChar keySMaskColor_Blue[] = wxT( "SMaskColor_Blue" );
static const wxChar keySPasteColor_Red[] = wxT( "SPasteColor_Red" );
static const wxChar keySPasteColor_Green[] = wxT( "SPasteColor_Green" );
static const wxChar keySPasteColor_Blue[] = wxT( "SPasteColor_Blue" );
static const wxChar keySilkColor_Red[] = wxT( "SilkColor_Red" );
static const wxChar keySilkColor_Green[] = wxT( "SilkColor_Green" );
static const wxChar keySilkColor_Blue[] = wxT( "SilkColor_Blue" );
static const wxChar keyCopperColor_Red[] = wxT( "CopperColor_Red" );
static const wxChar keyCopperColor_Green[] = wxT( "CopperColor_Green" );
static const wxChar keyCopperColor_Blue[] = wxT( "CopperColor_Blue" );
static const wxChar keyBoardBodyColor_Red[] = wxT( "BoardBodyColor_Red" );
static const wxChar keyBoardBodyColor_Green[] = wxT( "BoardBodyColor_Green" );
static const wxChar keyBoardBodyColor_Blue[] = wxT( "BoardBodyColor_Blue" );
static const wxChar keyShowRealisticMode[] = wxT( "ShowRealisticMode" );
static const wxChar keySubtractMaskFromSilk[] = wxT( "SubtractMaskFromSilk" );
static const wxChar keyRenderEngine[] = wxT( "RenderEngine" );
static const wxChar keyRenderMaterial[] = wxT( "Render_Material" );
static const wxChar keyRenderOGL_ShowCopperTck[]= wxT( "Render_OGL_ShowCopperThickness" );
static const wxChar keyRenderOGL_ShowModelBBox[]= wxT( "Render_OGL_ShowModelBoudingBoxes" );
static const wxChar keyRenderRAY_Shadows[] = wxT( "Render_RAY_Shadows" );
static const wxChar keyRenderRAY_Backfloor[] = wxT( "Render_RAY_Backfloor" );
static const wxChar keyRenderRAY_Refractions[] = wxT( "Render_RAY_Refractions" );
static const wxChar keyRenderRAY_Reflections[] = wxT( "Render_RAY_Reflections" );
static const wxChar keyRenderRAY_PostProcess[] = wxT( "Render_RAY_PostProcess" );
static const wxChar keyRenderRAY_AAliasing[] = wxT( "Render_RAY_AntiAliasing" );
static const wxChar keyRenderRAY_ProceduralT[] = wxT( "Render_RAY_ProceduralTextures" );
static const wxChar keyShowAxis[] = wxT( "ShowAxis" );
static const wxChar keyShowGrid[] = wxT( "ShowGrid3D" );
static const wxChar keyShowZones[] = wxT( "ShowZones" );
static const wxChar keyShowFootprints_Normal[] = wxT( "ShowFootprints_Normal" );
static const wxChar keyShowFootprints_Insert[] = wxT( "ShowFootprints_Insert" );
static const wxChar keyShowFootprints_Virtual[] = wxT( "ShowFootprints_Virtual" );
static const wxChar keyShowAdhesiveLayers[] = wxT( "ShowAdhesiveLayers" );
static const wxChar keyShowSilkScreenLayers[] = wxT( "ShowSilkScreenLayers" );
static const wxChar keyShowSolderMaskLayers[] = wxT( "ShowSolderMasLayers" );
static const wxChar keyShowSolderPasteLayers[] = wxT( "ShowSolderPasteLayers" );
static const wxChar keyShowCommentsLayer[] = wxT( "ShowCommentsLayers" );
static const wxChar keyShowBoardBody[] = wxT( "ShowBoardBody" );
static const wxChar keyShowEcoLayers[] = wxT( "ShowEcoLayers" );
BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME ) BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME )
EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate ) EVT_ACTIVATE( EDA_3D_VIEWER::OnActivate )
@ -163,7 +105,8 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent,
icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) );
SetIcon( icon ); SetIcon( icon );
LoadSettings( config() ); auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
LoadSettings( config );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
// Create the status line // Create the status line
@ -265,6 +208,9 @@ void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
//delete m_canvas; //delete m_canvas;
//m_canvas = nullptr; //m_canvas = nullptr;
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
Destroy(); Destroy();
event.Skip( true ); event.Skip( true );
} }
@ -553,10 +499,9 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
case ID_MENU3D_RESET_DEFAULTS: case ID_MENU3D_RESET_DEFAULTS:
{ {
// Reload settings with a dummy config, so it will load the defaults auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
wxConfig *fooconfig = new wxConfig( "FooBarApp" ); cfg->ResetToDefaults();
LoadSettings( fooconfig ); LoadSettings( cfg );
delete fooconfig;
// Tell canvas that we (may have) changed the render engine // Tell canvas that we (may have) changed the render engine
RenderEngineChanged(); RenderEngineChanged();
@ -703,228 +648,152 @@ void EDA_3D_VIEWER::OnSetFocus(wxFocusEvent &event)
} }
void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg ) void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
{ {
EDA_BASE_FRAME::LoadSettings( aCfg ); EDA_BASE_FRAME::LoadSettings( aCfg );
auto cfg = dynamic_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
wxASSERT( cfg );
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 ); COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 ); auto set_color = [] ( const COLOR4D& aColor, SFVEC3D& aTarget )
aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 ); {
aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 ); aTarget.r = aColor.r;
aTarget.g = aColor.g;
aTarget.b = aColor.b;
};
// m_SolderMaskColorTop default value = dark grey-green set_color( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_settings.m_BgColorBot );
aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColorTop.r, 100.0 * 0.2 / 255.0 ); set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_settings.m_BgColorTop );
aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColorTop.g, 255.0 * 0.2 / 255.0 ); set_color( colors->GetColor( LAYER_3D_BOARD ), m_settings.m_BoardBodyColor );
aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColorTop.b, 180.0 * 0.2 / 255.0 ); set_color( colors->GetColor( LAYER_3D_COPPER ), m_settings.m_CopperColor );
set_color( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), m_settings.m_SilkScreenColorBot );
set_color( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), m_settings.m_SilkScreenColorTop );
set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_settings.m_SolderMaskColorBot );
set_color( colors->GetColor( LAYER_3D_SOLDERMASK ), m_settings.m_SolderMaskColorTop );
set_color( colors->GetColor( LAYER_3D_SOLDERPASTE ), m_settings.m_SolderPasteColor );
// m_SolderMaskColorBot default value = dark grey-green m_settings.SetFlag( FL_USE_REALISTIC_MODE, cfg->m_Render.realistic );
aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColorBot.r, 100.0 * 0.2 / 255.0 );
aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColorBot.g, 255.0 * 0.2 / 255.0 );
aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColorBot.b, 180.0 * 0.2 / 255.0 );
// m_SolderPasteColor default value = light grey m_settings.SetFlag( FL_SUBTRACT_MASK_FROM_SILK, cfg->m_Render.subtract_mask_from_silk );
aCfg->Read( keySPasteColor_Red, &m_settings.m_SolderPasteColor.r, 128.0 / 255.0 );
aCfg->Read( keySPasteColor_Green, &m_settings.m_SolderPasteColor.g, 128.0 / 255.0 );
aCfg->Read( keySPasteColor_Blue, &m_settings.m_SolderPasteColor.b, 128.0 / 255.0 );
// m_SilkScreenColorTop default value = white
aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColorTop.r, 0.9 );
aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColorTop.g, 0.9 );
aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColorTop.b, 0.9 );
// m_SilkScreenColorBot default value = white
aCfg->Read( keySilkColor_Red, &m_settings.m_SilkScreenColorBot.r, 0.9 );
aCfg->Read( keySilkColor_Green, &m_settings.m_SilkScreenColorBot.g, 0.9 );
aCfg->Read( keySilkColor_Blue, &m_settings.m_SilkScreenColorBot.b, 0.9 );
// m_CopperColor default value = gold
aCfg->Read( keyCopperColor_Red, &m_settings.m_CopperColor.r, 255.0 * 0.7 / 255.0 );
aCfg->Read( keyCopperColor_Green, &m_settings.m_CopperColor.g, 223.0 * 0.7 / 255.0 );
aCfg->Read( keyCopperColor_Blue, &m_settings.m_CopperColor.b, 0.0 );
// m_BoardBodyColor default value = FR4, in realistic mode
aCfg->Read( keyBoardBodyColor_Red, &m_settings.m_BoardBodyColor.r, 51.0 / 255.0 );
aCfg->Read( keyBoardBodyColor_Green, &m_settings.m_BoardBodyColor.g, 43.0 / 255.0 );
aCfg->Read( keyBoardBodyColor_Blue, &m_settings.m_BoardBodyColor.b, 22.0 / 255.0 );
bool tmp;
aCfg->Read( keyShowRealisticMode, &tmp, true );
m_settings.SetFlag( FL_USE_REALISTIC_MODE, tmp );
aCfg->Read( keySubtractMaskFromSilk, &tmp, false );
m_settings.SetFlag( FL_SUBTRACT_MASK_FROM_SILK, tmp );
// OpenGL options // OpenGL options
aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true ); m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, cfg->m_Render.opengl_copper_thickness );
m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, tmp );
aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false ); m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, cfg->m_Render.opengl_show_model_bbox );
m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, tmp );
// Raytracing options // Raytracing options
aCfg->Read( keyRenderRAY_Shadows, &tmp, true ); m_settings.SetFlag( FL_RENDER_RAYTRACING_SHADOWS, cfg->m_Render.raytrace_shadows );
m_settings.SetFlag( FL_RENDER_RAYTRACING_SHADOWS, tmp );
aCfg->Read( keyRenderRAY_Backfloor, &tmp, false ); m_settings.SetFlag( FL_RENDER_RAYTRACING_BACKFLOOR, cfg->m_Render.raytrace_backfloor );
m_settings.SetFlag( FL_RENDER_RAYTRACING_BACKFLOOR, tmp );
aCfg->Read( keyRenderRAY_Refractions, &tmp, true ); m_settings.SetFlag( FL_RENDER_RAYTRACING_REFRACTIONS, cfg->m_Render.raytrace_refractions );
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFRACTIONS, tmp );
aCfg->Read( keyRenderRAY_Reflections, &tmp, true ); m_settings.SetFlag( FL_RENDER_RAYTRACING_REFLECTIONS, cfg->m_Render.raytrace_reflections );
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFLECTIONS, tmp );
aCfg->Read( keyRenderRAY_PostProcess, &tmp, true ); m_settings.SetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING,
m_settings.SetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING, tmp ); cfg->m_Render.raytrace_post_processing );
aCfg->Read( keyRenderRAY_AAliasing, &tmp, true ); m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, cfg->m_Render.raytrace_anti_aliasing );
m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, tmp );
aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true ); m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES,
m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, tmp ); cfg->m_Render.raytrace_procedural_textures );
aCfg->Read( keyShowAxis, &tmp, true ); m_settings.SetFlag( FL_AXIS, cfg->m_Render.show_axis );
m_settings.SetFlag( FL_AXIS, tmp );
aCfg->Read( keyShowFootprints_Normal, &tmp, true ); m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL, cfg->m_Render.show_footprints_normal );
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL, tmp );
aCfg->Read( keyShowFootprints_Insert, &tmp, true ); m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT, cfg->m_Render.show_footprints_insert );
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT, tmp );
aCfg->Read( keyShowFootprints_Virtual, &tmp, true ); m_settings.SetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL, cfg->m_Render.show_footprints_virtual );
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL, tmp );
aCfg->Read( keyShowZones, &tmp, true ); m_settings.SetFlag( FL_ZONE, cfg->m_Render.show_zones );
m_settings.SetFlag( FL_ZONE, tmp );
aCfg->Read( keyShowAdhesiveLayers, &tmp, true ); m_settings.SetFlag( FL_ADHESIVE, cfg->m_Render.show_adhesive );
m_settings.SetFlag( FL_ADHESIVE, tmp );
aCfg->Read( keyShowSilkScreenLayers, &tmp, true ); m_settings.SetFlag( FL_SILKSCREEN, cfg->m_Render.show_silkscreen );
m_settings.SetFlag( FL_SILKSCREEN, tmp );
aCfg->Read( keyShowSolderMaskLayers, &tmp, true ); m_settings.SetFlag( FL_SOLDERMASK, cfg->m_Render.show_soldermask );
m_settings.SetFlag( FL_SOLDERMASK, tmp );
aCfg->Read( keyShowSolderPasteLayers, &tmp, true ); m_settings.SetFlag( FL_SOLDERPASTE, cfg->m_Render.show_solderpaste );
m_settings.SetFlag( FL_SOLDERPASTE, tmp );
aCfg->Read( keyShowCommentsLayer, &tmp, true ); m_settings.SetFlag( FL_COMMENTS, cfg->m_Render.show_comments );
m_settings.SetFlag( FL_COMMENTS, tmp );
aCfg->Read( keyShowEcoLayers, &tmp, true ); m_settings.SetFlag( FL_ECO, cfg->m_Render.show_eco );
m_settings.SetFlag( FL_ECO, tmp );
aCfg->Read( keyShowBoardBody, &tmp, true ); m_settings.SetFlag( FL_SHOW_BOARD_BODY, cfg->m_Render.show_board_body );
m_settings.SetFlag( FL_SHOW_BOARD_BODY, tmp );
int tmpi; m_settings.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
aCfg->Read( keyShowGrid, &tmpi, static_cast<int>( GRID3D_TYPE::NONE ) );
m_settings.GridSet( static_cast<GRID3D_TYPE>( tmpi ) );
aCfg->Read( keyRenderEngine, &tmpi, static_cast<int>( RENDER_ENGINE::OPENGL_LEGACY ) ); RENDER_ENGINE engine = static_cast<RENDER_ENGINE>( cfg->m_Render.engine );
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings render setting %s", wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings render setting %s",
( static_cast<RENDER_ENGINE>( tmpi ) == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : ( engine == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : "OpenGL" );
"OpenGL" ); m_settings.RenderEngineSet( engine );
m_settings.RenderEngineSet( static_cast<RENDER_ENGINE>( tmpi ) );
aCfg->Read( keyRenderMaterial, &tmpi, static_cast<int>( MATERIAL_MODE::NORMAL ) ); m_settings.MaterialModeSet( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
m_settings.MaterialModeSet( static_cast<MATERIAL_MODE>( tmpi ) );
} }
void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg ) void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
{ {
EDA_BASE_FRAME::SaveSettings( aCfg ); auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
EDA_BASE_FRAME::SaveSettings( cfg );
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings" );
aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r ); COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r ); auto save_color = [colors] ( SFVEC3D& aSource, LAYER_3D_ID aTarget )
aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g ); {
aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b ); colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 ) );
};
aCfg->Write( keySMaskColor_Red, m_settings.m_SolderMaskColorTop.r ); save_color( m_settings.m_BgColorBot, LAYER_3D_BACKGROUND_BOTTOM );
aCfg->Write( keySMaskColor_Green, m_settings.m_SolderMaskColorTop.g ); save_color( m_settings.m_BgColorTop, LAYER_3D_BACKGROUND_TOP );
aCfg->Write( keySMaskColor_Blue, m_settings.m_SolderMaskColorTop.b ); save_color( m_settings.m_BoardBodyColor, LAYER_3D_BOARD );
save_color( m_settings.m_CopperColor, LAYER_3D_COPPER );
save_color( m_settings.m_SilkScreenColorBot, LAYER_3D_SILKSCREEN_BOTTOM );
save_color( m_settings.m_SilkScreenColorTop, LAYER_3D_SILKSCREEN_TOP );
save_color( m_settings.m_SolderMaskColorTop, LAYER_3D_SOLDERMASK );
save_color( m_settings.m_SolderPasteColor, LAYER_3D_SOLDERPASTE );
aCfg->Write( keySMaskColor_Red, m_settings.m_SolderMaskColorBot.r );
aCfg->Write( keySMaskColor_Green, m_settings.m_SolderMaskColorBot.g );
aCfg->Write( keySMaskColor_Blue, m_settings.m_SolderMaskColorBot.b );
aCfg->Write( keySPasteColor_Red, m_settings.m_SolderPasteColor.r );
aCfg->Write( keySPasteColor_Green, m_settings.m_SolderPasteColor.g );
aCfg->Write( keySPasteColor_Blue, m_settings.m_SolderPasteColor.b );
aCfg->Write( keySilkColor_Red, m_settings.m_SilkScreenColorTop.r );
aCfg->Write( keySilkColor_Green, m_settings.m_SilkScreenColorTop.g );
aCfg->Write( keySilkColor_Blue, m_settings.m_SilkScreenColorTop.b );
aCfg->Write( keySilkColor_Red, m_settings.m_SilkScreenColorBot.r );
aCfg->Write( keySilkColor_Green, m_settings.m_SilkScreenColorBot.g );
aCfg->Write( keySilkColor_Blue, m_settings.m_SilkScreenColorBot.b );
aCfg->Write( keyCopperColor_Red, m_settings.m_CopperColor.r );
aCfg->Write( keyCopperColor_Green, m_settings.m_CopperColor.g );
aCfg->Write( keyCopperColor_Blue, m_settings.m_CopperColor.b );
aCfg->Write( keyBoardBodyColor_Red, m_settings.m_BoardBodyColor.r );
aCfg->Write( keyBoardBodyColor_Green, m_settings.m_BoardBodyColor.g );
aCfg->Write( keyBoardBodyColor_Blue, m_settings.m_BoardBodyColor.b );
aCfg->Write( keyShowRealisticMode, m_settings.GetFlag( FL_USE_REALISTIC_MODE ) );
aCfg->Write( keySubtractMaskFromSilk, m_settings.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) );
aCfg->Write( keyRenderEngine, static_cast<int>( m_settings.RenderEngineGet() ) );
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings render setting %s", wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings render setting %s",
( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : ( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
"OpenGL" ); "OpenGL" );
aCfg->Write( keyRenderMaterial, (int) m_settings.MaterialModeGet() ); cfg->m_Render.engine = static_cast<int>( m_settings.RenderEngineGet() );
cfg->m_Render.grid_type = static_cast<int>( m_settings.GridGet() );
cfg->m_Render.material_mode = static_cast<int>( m_settings.MaterialModeGet() );
// OpenGL options cfg->m_Render.opengl_copper_thickness = m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS );
aCfg->Write( keyRenderOGL_ShowCopperTck, cfg->m_Render.opengl_show_model_bbox = m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) ); cfg->m_Render.raytrace_anti_aliasing = m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING );
aCfg->Write( keyRenderOGL_ShowModelBBox, cfg->m_Render.raytrace_backfloor = m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR );
m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) ); cfg->m_Render.raytrace_post_processing =
m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING );
// Raytracing options cfg->m_Render.raytrace_procedural_textures =
aCfg->Write( keyRenderRAY_Shadows, m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) ); m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
aCfg->Write( keyRenderRAY_Backfloor, m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) ); cfg->m_Render.raytrace_reflections = m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS );
aCfg->Write( keyRenderRAY_Refractions, m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) ); cfg->m_Render.raytrace_refractions = m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS );
aCfg->Write( keyRenderRAY_Reflections, m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) ); cfg->m_Render.raytrace_shadows = m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS );
aCfg->Write( cfg->m_Render.realistic = m_settings.GetFlag( FL_USE_REALISTIC_MODE );
keyRenderRAY_PostProcess, m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ); cfg->m_Render.show_adhesive = m_settings.GetFlag( FL_ADHESIVE );
aCfg->Write( keyRenderRAY_AAliasing, m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) ); cfg->m_Render.show_axis = m_settings.GetFlag( FL_AXIS );
aCfg->Write( keyRenderRAY_ProceduralT, cfg->m_Render.show_board_body = m_settings.GetFlag( FL_SHOW_BOARD_BODY );
m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ); cfg->m_Render.show_comments = m_settings.GetFlag( FL_COMMENTS );
cfg->m_Render.show_eco = m_settings.GetFlag( FL_ECO );
aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) ); cfg->m_Render.show_footprints_insert = m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT );
aCfg->Write( keyShowGrid, (int) m_settings.GridGet() ); cfg->m_Render.show_footprints_normal = m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL );
cfg->m_Render.show_footprints_virtual = m_settings.GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL );
aCfg->Write( keyShowFootprints_Normal, m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL ) ); cfg->m_Render.show_silkscreen = m_settings.GetFlag( FL_SILKSCREEN );
aCfg->Write( cfg->m_Render.show_soldermask = m_settings.GetFlag( FL_SOLDERMASK );
keyShowFootprints_Insert, m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT ) ); cfg->m_Render.show_solderpaste = m_settings.GetFlag( FL_SOLDERPASTE );
aCfg->Write( keyShowFootprints_Virtual, m_settings.GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL ) ); cfg->m_Render.show_zones = m_settings.GetFlag( FL_ZONE );
cfg->m_Render.subtract_mask_from_silk = m_settings.GetFlag( FL_SUBTRACT_MASK_FROM_SILK );
aCfg->Write( keyShowZones, m_settings.GetFlag( FL_ZONE ) );
aCfg->Write( keyShowAdhesiveLayers, m_settings.GetFlag( FL_ADHESIVE ) );
aCfg->Write( keyShowSilkScreenLayers, m_settings.GetFlag( FL_SILKSCREEN ) );
aCfg->Write( keyShowSolderMaskLayers, m_settings.GetFlag( FL_SOLDERMASK ) );
aCfg->Write( keyShowSolderPasteLayers, m_settings.GetFlag( FL_SOLDERPASTE ) );
aCfg->Write( keyShowCommentsLayer, m_settings.GetFlag( FL_COMMENTS ) );
aCfg->Write( keyShowEcoLayers, m_settings.GetFlag( FL_ECO ) );
aCfg->Write( keyShowBoardBody, m_settings.GetFlag( FL_SHOW_BOARD_BODY ) );
} }
@ -1269,16 +1138,9 @@ void EDA_3D_VIEWER::loadCommonSettings()
{ {
wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" ); wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
wxConfigBase& cmnCfg = *Pgm().CommonSettings(); COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
{ const DPI_SCALING dpi{ settings, this };
const DPI_SCALING dpi{ &cmnCfg, this };
m_canvas->SetScaleFactor( dpi.GetScaleFactor() ); m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
} m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan );
{
bool option;
cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, option );
}
} }

View File

@ -194,9 +194,9 @@ private:
*/ */
void ReCreateMainToolbar(); void ReCreateMainToolbar();
void SaveSettings( wxConfigBase *aCfg ) override; void SaveSettings( APP_SETTINGS_BASE *aCfg ) override;
void LoadSettings( wxConfigBase *aCfg ) override; void LoadSettings( APP_SETTINGS_BASE *aCfg ) override;
void OnKeyEvent( wxKeyEvent& event ); void OnKeyEvent( wxKeyEvent& event );

View File

@ -94,6 +94,7 @@ set(3D-VIEWER_SRCS
3d_viewer/dialogs/dialog_3D_view_option.cpp 3d_viewer/dialogs/dialog_3D_view_option.cpp
3d_viewer/dialogs/dialog_3D_view_option_base.cpp 3d_viewer/dialogs/dialog_3D_view_option_base.cpp
3d_viewer/eda_3d_viewer.cpp 3d_viewer/eda_3d_viewer.cpp
3d_viewer/3d_viewer_settings.cpp
common_ogl/cogl_att_list.cpp common_ogl/cogl_att_list.cpp
common_ogl/ogl_utils.cpp common_ogl/ogl_utils.cpp
3d_fastmath.cpp 3d_fastmath.cpp
@ -111,4 +112,8 @@ target_link_libraries( 3d-viewer
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
kicad_3dsg ) kicad_3dsg )
target_include_directories( 3d-viewer PRIVATE
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
)
add_subdirectory( 3d_cache ) add_subdirectory( 3d_cache )

View File

@ -12,6 +12,7 @@ set( BITMAP2COMPONENT_SRCS
${CMAKE_SOURCE_DIR}/common/single_top.cpp ${CMAKE_SOURCE_DIR}/common/single_top.cpp
bitmap2cmp_main.cpp bitmap2cmp_main.cpp
bitmap2cmp_settings.cpp
bitmap2component.cpp bitmap2component.cpp
bitmap2cmp_gui_base.cpp bitmap2cmp_gui_base.cpp
bitmap2cmp_gui.cpp bitmap2cmp_gui.cpp

View File

@ -24,6 +24,7 @@
#include "bitmap2cmp_gui.h" #include "bitmap2cmp_gui.h"
#include "bitmap2component.h" #include "bitmap2component.h"
#include <bitmap2cmp_settings.h>
#include <bitmap_io.h> #include <bitmap_io.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <kiface_i.h> #include <kiface_i.h>
@ -38,18 +39,6 @@
#include "bitmap2cmp_gui_base.h" #include "bitmap2cmp_gui_base.h"
#define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )
#define KEYWORD_FRAME_SIZEX wxT( "Bmconverter_Size_x" )
#define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" )
#define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" )
#define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" )
#define KEYWORD_LAST_FORMAT wxT( "Last_format" )
#define KEYWORD_LAST_MODLAYER wxT( "Last_modlayer" )
#define KEYWORD_BINARY_THRESHOLD wxT( "Threshold" )
#define KEYWORD_BW_NEGATIVE wxT( "Negative_choice" )
#define KEYWORD_UNIT_SELECTION wxT( "Unit_selection" )
#define DEFAULT_DPI 300 // the image DPI used in formats that do not define a DPI #define DEFAULT_DPI 300 // the image DPI used in formats that do not define a DPI
IMAGE_SIZE::IMAGE_SIZE() IMAGE_SIZE::IMAGE_SIZE()
@ -161,7 +150,6 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
BM2CMP_FRAME_BASE( aParent ) BM2CMP_FRAME_BASE( aParent )
{ {
SetKiway( this, aKiway ); SetKiway( this, aKiway );
m_config = GetNewConfig( Pgm().App().GetAppName() );
wxString unitList[] = wxString unitList[] =
{ {
@ -171,7 +159,7 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
for( int ii = 0; ii < 3; ii++ ) for( int ii = 0; ii < 3; ii++ )
m_PixelUnit->Append( unitList[ii] ); m_PixelUnit->Append( unitList[ii] );
LoadSettings( m_config.get() ); LoadSettings( config() );
m_outputSizeX.SetUnit( getUnitFromSelection() ); m_outputSizeX.SetUnit( getUnitFromSelection() );
m_outputSizeY.SetUnit( getUnitFromSelection() ); m_outputSizeY.SetUnit( getUnitFromSelection() );
@ -193,20 +181,19 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
m_buttonExportFile->Enable( false ); m_buttonExportFile->Enable( false );
m_buttonExportClipboard->Enable( false ); m_buttonExportClipboard->Enable( false );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if ( m_framePos == wxDefaultPosition ) if ( m_FramePos == wxDefaultPosition )
Centre(); Centre();
} }
BM2CMP_FRAME::~BM2CMP_FRAME() BM2CMP_FRAME::~BM2CMP_FRAME()
{ {
SaveSettings( m_config.get() ); SaveSettings( config() );
/* /*
* This needed for OSX: avoids further OnDraw processing after this * This needed for OSX: avoids further OnDraw processing after this
* destructor and before the native window is destroyed * destructor and before the native window is destroyed
@ -215,79 +202,63 @@ BM2CMP_FRAME::~BM2CMP_FRAME()
} }
void BM2CMP_FRAME::LoadSettings( wxConfigBase* aCfg ) void BM2CMP_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{ {
int tmp; EDA_BASE_FRAME::LoadSettings( aCfg );
aCfg->Read( KEYWORD_FRAME_POSX, & m_framePos.x, -1 );
aCfg->Read( KEYWORD_FRAME_POSY, & m_framePos.y, -1 );
aCfg->Read( KEYWORD_FRAME_SIZEX, & m_frameSize.x, -1 );
aCfg->Read( KEYWORD_FRAME_SIZEY, & m_frameSize.y, -1 );
aCfg->Read( KEYWORD_LAST_INPUT_FILE, &m_BitmapFileName );
aCfg->Read( KEYWORD_LAST_OUTPUT_FILE, &m_ConvertedFileName );
int u_select = 0; auto cfg = static_cast<BITMAP2CMP_SETTINGS*>( aCfg );
aCfg->Read( KEYWORD_UNIT_SELECTION, &u_select, 0 );
m_BitmapFileName = cfg->m_BitmapFileName;
m_ConvertedFileName = cfg->m_ConvertedFileName;
int u_select = cfg->m_Units;
if( u_select < 0 || u_select > 2 ) // Validity control if( u_select < 0 || u_select > 2 ) // Validity control
u_select = 0; u_select = 0;
m_PixelUnit->SetSelection( u_select ); m_PixelUnit->SetSelection( u_select );
if( aCfg->Read( KEYWORD_BINARY_THRESHOLD, &tmp ) ) m_sliderThreshold->SetValue( cfg->m_Threshold );
m_sliderThreshold->SetValue( tmp );
aCfg->Read( KEYWORD_BW_NEGATIVE, &tmp, 0 ); m_Negative = cfg->m_Negative;
m_Negative = tmp != 0; m_checkNegative->SetValue( cfg->m_Negative );
m_checkNegative->SetValue( m_Negative );
m_exportToClipboard = false; m_exportToClipboard = false;
m_AspectRatioLocked = false; m_AspectRatioLocked = false;
if( aCfg->Read( KEYWORD_LAST_FORMAT, &tmp ) ) int format = cfg->m_LastFormat;
{
if( tmp < 0 || tmp > FINAL_FMT )
tmp = PCBNEW_KICAD_MOD;
m_rbOutputFormat->SetSelection( tmp ); if( format < 0 || format > FINAL_FMT )
} format = PCBNEW_KICAD_MOD;
if( tmp == PCBNEW_KICAD_MOD ) m_rbOutputFormat->SetSelection( format );
if( format == PCBNEW_KICAD_MOD )
m_rbPCBLayer->Enable( true ); m_rbPCBLayer->Enable( true );
else else
m_rbPCBLayer->Enable( false ); m_rbPCBLayer->Enable( false );
if( aCfg->Read( KEYWORD_LAST_MODLAYER, &tmp ) ) int last_layer = cfg->m_LastModLayer;
{
if( (unsigned) tmp > MOD_LYR_FINAL ) // Out of range if( last_layer > static_cast<int>( MOD_LYR_FINAL ) ) // Out of range
m_rbPCBLayer->SetSelection( MOD_LYR_FSILKS ); m_rbPCBLayer->SetSelection( MOD_LYR_FSILKS );
else else
m_rbPCBLayer->SetSelection( tmp ); m_rbPCBLayer->SetSelection( last_layer );
}
} }
void BM2CMP_FRAME::SaveSettings( wxConfigBase* aCfg ) void BM2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{ {
if( !aCfg ) EDA_BASE_FRAME::SaveSettings( aCfg );
return;
m_frameSize = GetSize(); auto cfg = static_cast<BITMAP2CMP_SETTINGS*>( aCfg );
m_framePos = GetPosition();
if( !IsIconized() ) cfg->m_BitmapFileName = m_BitmapFileName;
{ cfg->m_ConvertedFileName = m_ConvertedFileName;
aCfg->Write( KEYWORD_FRAME_POSX, (long) m_framePos.x ); cfg->m_Threshold = m_sliderThreshold->GetValue();
aCfg->Write( KEYWORD_FRAME_POSY, (long) m_framePos.y ); cfg->m_Negative = m_checkNegative->IsChecked();
aCfg->Write( KEYWORD_FRAME_SIZEX, (long) m_frameSize.x ); cfg->m_LastFormat = m_rbOutputFormat->GetSelection();
aCfg->Write( KEYWORD_FRAME_SIZEY, (long) m_frameSize.y ); cfg->m_LastModLayer = m_rbPCBLayer->GetSelection();
} cfg->m_Units = m_PixelUnit->GetSelection();
aCfg->Write( KEYWORD_LAST_INPUT_FILE, m_BitmapFileName );
aCfg->Write( KEYWORD_LAST_OUTPUT_FILE, m_ConvertedFileName );
aCfg->Write( KEYWORD_BINARY_THRESHOLD, m_sliderThreshold->GetValue() );
aCfg->Write( KEYWORD_BW_NEGATIVE, m_checkNegative->IsChecked() ? 1 : 0 );
aCfg->Write( KEYWORD_LAST_FORMAT, m_rbOutputFormat->GetSelection() );
aCfg->Write( KEYWORD_LAST_MODLAYER, m_rbPCBLayer->GetSelection() );
aCfg->Write( KEYWORD_UNIT_SELECTION, m_PixelUnit->GetSelection() );
} }

View File

@ -152,8 +152,8 @@ private:
void OnFormatChange( wxCommandEvent& event ) override; void OnFormatChange( wxCommandEvent& event ) override;
void exportBitmap( OUTPUT_FMT_ID aFormat ); void exportBitmap( OUTPUT_FMT_ID aFormat );
void LoadSettings( wxConfigBase* aCfg ) override; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
private: private:
wxImage m_Pict_Image; wxImage m_Pict_Image;
@ -167,9 +167,6 @@ private:
bool m_Negative; bool m_Negative;
wxString m_BitmapFileName; wxString m_BitmapFileName;
wxString m_ConvertedFileName; wxString m_ConvertedFileName;
wxSize m_frameSize;
wxPoint m_framePos;
std::unique_ptr<wxConfigBase> m_config;
bool m_exportToClipboard; bool m_exportToClipboard;
bool m_AspectRatioLocked; bool m_AspectRatioLocked;
double m_AspectRatio; double m_AspectRatio;

View File

@ -22,10 +22,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "bitmap2cmp_gui.h" #include <bitmap2cmp_gui.h>
#include <bitmap2cmp_settings.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <kiway.h> #include <kiway.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/settings_manager.h>
//-----<KIFACE>----------------------------------------------------------------- //-----<KIFACE>-----------------------------------------------------------------
@ -38,6 +40,8 @@ static struct IFACE : public KIFACE_I
wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
{ {
InitSettings( new BITMAP2CMP_SETTINGS );
Pgm().GetSettingsManager().RegisterSettings( KifaceSettings() );
return new BM2CMP_FRAME( aKiway, aParent ); return new BM2CMP_FRAME( aKiway, aParent );
} }

View File

@ -0,0 +1,68 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <bitmap2cmp_settings.h>
#include <settings/parameters.h>
#include <wx/config.h>
///! Update the schema version whenever a migration is required
const int bitmap2cmpSchemaVersion = 0;
BITMAP2CMP_SETTINGS::BITMAP2CMP_SETTINGS() :
APP_SETTINGS_BASE( "bitmap2component", bitmap2cmpSchemaVersion ),
m_BitmapFileName(), m_ConvertedFileName(), m_Units(), m_Threshold(), m_Negative(),
m_LastFormat(), m_LastModLayer()
{
m_params.emplace_back( new PARAM<wxString>( "bitmap_file_name", &m_BitmapFileName, "" ) );
m_params.emplace_back(
new PARAM<wxString>( "converted_file_name", &m_ConvertedFileName, "" ) );
m_params.emplace_back( new PARAM<int>( "units", &m_Units, 0 ) );
m_params.emplace_back( new PARAM<int>( "threshold", &m_Threshold, 50 ) );
m_params.emplace_back( new PARAM<bool>( "negative", &m_Negative, false ) );
m_params.emplace_back( new PARAM<int>( "last_format", &m_LastFormat, 0 ) );
m_params.emplace_back( new PARAM<int>( "last_mod_layer", &m_LastModLayer, 0 ) );
}
bool BITMAP2CMP_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
ret &= fromLegacyString( aCfg, "Last_input", "bitmap_file_name" );
ret &= fromLegacyString( aCfg, "Last_output", "converted_file_name" );
ret &= fromLegacy<int>( aCfg, "Last_format", "last_format" );
ret &= fromLegacy<int>( aCfg, "Last_modlayer", "last_mod_layer" );
ret &= fromLegacy<int>( aCfg, "Threshold", "threshold" );
ret &= fromLegacy<bool>( aCfg, "Negative_choice", "negative" );
ret &= fromLegacy<int>( aCfg, "Unit_selection", "units" );
return ret;
}

View File

@ -0,0 +1,58 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _BITMAP2CMP_SETTINGS_H
#define _BITMAP2CMP_SETTINGS_H
#include <settings/app_settings.h>
class BITMAP2CMP_SETTINGS : public APP_SETTINGS_BASE
{
public:
BITMAP2CMP_SETTINGS();
virtual ~BITMAP2CMP_SETTINGS() {}
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
wxString m_BitmapFileName;
wxString m_ConvertedFileName;
int m_Units;
int m_Threshold;
bool m_Negative;
int m_LastFormat;
int m_LastModLayer;
protected:
virtual std::string getLegacyFrameName() const override { return "Bmconverter_"; }
};
#endif

View File

@ -82,6 +82,10 @@ target_link_libraries( gal
${GDI_PLUS_LIBRARIES} ${GDI_PLUS_LIBRARIES}
) )
target_include_directories( gal PRIVATE
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
)
# Only for win32 cross compilation using MXE # Only for win32 cross compilation using MXE
if( WIN32 AND MSYS ) if( WIN32 AND MSYS )
@ -168,6 +172,8 @@ set( COMMON_DLG_SRCS
dialogs/dialog_image_editor.cpp dialogs/dialog_image_editor.cpp
dialogs/dialog_image_editor_base.cpp dialogs/dialog_image_editor_base.cpp
dialogs/dialog_list_selector_base.cpp dialogs/dialog_list_selector_base.cpp
dialogs/dialog_migrate_settings.cpp
dialogs/dialog_migrate_settings_base.cpp
dialogs/dialog_page_settings_base.cpp dialogs/dialog_page_settings_base.cpp
dialogs/dialog_text_entry_base.cpp dialogs/dialog_text_entry_base.cpp
dialogs/dialog_print_generic.cpp dialogs/dialog_print_generic.cpp
@ -262,7 +268,6 @@ set( COMMON_SRCS
bitmap_base.cpp bitmap_base.cpp
board_printout.cpp board_printout.cpp
build_version.cpp build_version.cpp
colors_design_settings.cpp
colors.cpp colors.cpp
commit.cpp commit.cpp
common.cpp common.cpp
@ -322,7 +327,6 @@ set( COMMON_SRCS
richio.cpp richio.cpp
search_stack.cpp search_stack.cpp
searchhelpfilefullpath.cpp searchhelpfilefullpath.cpp
settings.cpp
status_popup.cpp status_popup.cpp
systemdirsappend.cpp systemdirsappend.cpp
trace_helpers.cpp trace_helpers.cpp
@ -382,6 +386,13 @@ set( COMMON_SRCS
tool/zoom_menu.cpp tool/zoom_menu.cpp
tool/zoom_tool.cpp tool/zoom_tool.cpp
settings/app_settings.cpp
settings/color_settings.cpp
settings/common_settings.cpp
settings/json_settings.cpp
settings/nested_settings.cpp
settings/settings_manager.cpp
libeval/numeric_evaluator.cpp libeval/numeric_evaluator.cpp
) )
@ -407,6 +418,10 @@ target_link_libraries( common
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
target_include_directories( common PUBLIC
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
)
set( PCB_COMMON_SRCS set( PCB_COMMON_SRCS
base_screen.cpp base_screen.cpp
@ -445,6 +460,7 @@ set( PCB_COMMON_SRCS
${CMAKE_SOURCE_DIR}/pcbnew/convert_drawsegment_list_to_polygon.cpp ${CMAKE_SOURCE_DIR}/pcbnew/convert_drawsegment_list_to_polygon.cpp
${CMAKE_SOURCE_DIR}/pcbnew/drc/drc_item.cpp ${CMAKE_SOURCE_DIR}/pcbnew/drc/drc_item.cpp
${CMAKE_SOURCE_DIR}/pcbnew/eagle_plugin.cpp ${CMAKE_SOURCE_DIR}/pcbnew/eagle_plugin.cpp
${CMAKE_SOURCE_DIR}/pcbnew/footprint_editor_settings.cpp
${CMAKE_SOURCE_DIR}/pcbnew/gpcb_plugin.cpp ${CMAKE_SOURCE_DIR}/pcbnew/gpcb_plugin.cpp
${CMAKE_SOURCE_DIR}/pcbnew/io_mgr.cpp ${CMAKE_SOURCE_DIR}/pcbnew/io_mgr.cpp
${CMAKE_SOURCE_DIR}/pcbnew/kicad_clipboard.cpp ${CMAKE_SOURCE_DIR}/pcbnew/kicad_clipboard.cpp
@ -452,18 +468,18 @@ set( PCB_COMMON_SRCS
${CMAKE_SOURCE_DIR}/pcbnew/kicad_plugin.cpp ${CMAKE_SOURCE_DIR}/pcbnew/kicad_plugin.cpp
${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/legacy_netlist_reader.cpp ${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/legacy_netlist_reader.cpp
${CMAKE_SOURCE_DIR}/pcbnew/legacy_plugin.cpp ${CMAKE_SOURCE_DIR}/pcbnew/legacy_plugin.cpp
${CMAKE_SOURCE_DIR}/pcbnew//netlist_reader/netlist_reader.cpp ${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/netlist_reader.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pad_custom_shape_functions.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pad_custom_shape_functions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pad_print_functions.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pad_print_functions.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_display_options.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_display_options.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_draw_panel_gal.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_draw_panel_gal.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_general_settings.cpp
${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/pcb_netlist.cpp ${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/pcb_netlist.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_painter.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_painter.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_parser.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_parser.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_plot_params.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_plot_params.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_screen.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_screen.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_view.cpp ${CMAKE_SOURCE_DIR}/pcbnew/pcb_view.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcbnew_settings.cpp
${CMAKE_SOURCE_DIR}/pcbnew/plugin.cpp ${CMAKE_SOURCE_DIR}/pcbnew/plugin.cpp
${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_data.cpp ${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_data.cpp
${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_viewitem.cpp ${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_viewitem.cpp

View File

@ -25,6 +25,7 @@
#include <common.h> #include <common.h>
#include <config_params.h> #include <config_params.h>
#include <settings/settings_manager.h>
#include <wx/config.h> #include <wx/config.h>
#include <wx/filename.h> #include <wx/filename.h>
@ -153,7 +154,7 @@ static void dumpCfg( const std::vector<PARAM_CFG*>& aArray )
static wxFileName getAdvancedCfgFilename() static wxFileName getAdvancedCfgFilename()
{ {
const static wxString cfg_filename{ "kicad_advanced" }; const static wxString cfg_filename{ "kicad_advanced" };
return wxFileName( GetKicadConfigPath(), cfg_filename ); return wxFileName( SETTINGS_MANAGER::GetUserSettingsPath(), cfg_filename );
} }

View File

@ -27,29 +27,26 @@
#include <filehistory.h> #include <filehistory.h>
#include <id.h> // for ID_FILE1 and FILE_HISTORY_SIZE #include <id.h> // for ID_FILE1 and FILE_HISTORY_SIZE
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/app_settings.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
BIN_MOD::BIN_MOD( const char* aName ) : BIN_MOD::BIN_MOD( const char* aName ) :
m_name( aName ), m_name( aName ),
m_history( 0 ) m_config( nullptr ),
m_history( nullptr )
{ {
} }
void BIN_MOD::Init() void BIN_MOD::Init()
{ {
// do an OS specific wxConfig instantiation, using the bin_mod (EXE/DLL/DSO) name.
m_config = GetNewConfig( wxString::FromUTF8( m_name ) );
// wxWidgets' implementation of this is *very* expensive, and we don't use them anyway.
m_config->SetExpandEnvVars( false );
// get file history size from common settings // get file history size from common settings
int fileHistorySize; int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE );
m_history = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ), ID_FILE1 ); m_history = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ), ID_FILE1 );
m_history->Load( *m_config.get() ); m_history->Load( *m_config );
// Prepare On Line Help. Use only lower case for help file names, in order to // Prepare On Line Help. Use only lower case for help file names, in order to
// avoid problems with upper/lower case file names under windows and unix. // avoid problems with upper/lower case file names under windows and unix.
@ -65,17 +62,22 @@ void BIN_MOD::End()
{ {
if( m_config ) if( m_config )
{ {
m_history->Save( *m_config.get() ); if( m_history )
{
m_history->Save( *m_config );
delete m_history; delete m_history;
m_history = nullptr;
}
// Deleting a wxConfigBase writes its contents to disk if changed. // The settings manager will outlive this module so we need to clean up the module level
m_config.reset(); // settings here instead of leaving it up to the manager
Pgm().GetSettingsManager().FlushAndRelease( m_config );
m_config = nullptr;
} }
} }
BIN_MOD::~BIN_MOD() BIN_MOD::~BIN_MOD()
{ {
End();
} }

View File

@ -39,6 +39,7 @@
#include <pgm_base.h> #include <pgm_base.h>
#include <eda_base_frame.h> #include <eda_base_frame.h>
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <settings/common_settings.h>
struct SCALED_BITMAP_ID { struct SCALED_BITMAP_ID {
@ -103,8 +104,7 @@ int KiIconScale( wxWindow* aWindow )
static int get_scale_factor( EDA_BASE_FRAME* aWindow ) static int get_scale_factor( EDA_BASE_FRAME* aWindow )
{ {
int requested_scale; int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
Pgm().CommonSettings()->Read( ICON_SCALE_KEY, &requested_scale, 0 );
if( requested_scale > 0 ) if( requested_scale > 0 )
return requested_scale; return requested_scale;
@ -223,8 +223,7 @@ bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage ) void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage )
{ {
// Retrieve the global applicaton show icon option: // Retrieve the global applicaton show icon option:
bool useImagesInMenus; bool useImagesInMenus = Pgm().GetCommonSettings()->m_Appearance.use_icons_in_menus;
Pgm().CommonSettings()->Read( USE_ICONS_IN_MENUS_KEY, &useImagesInMenus );
wxItemKind menu_type = aMenu->GetKind(); wxItemKind menu_type = aMenu->GetKind();

View File

@ -30,6 +30,7 @@
#include <gal/gal_print.h> #include <gal/gal_print.h>
#include <painter.h> #include <painter.h>
#include <pcbplot.h> #include <pcbplot.h>
#include <settings/app_settings.h>
BOARD_PRINTOUT_SETTINGS::BOARD_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo ) BOARD_PRINTOUT_SETTINGS::BOARD_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo )
@ -40,29 +41,26 @@ BOARD_PRINTOUT_SETTINGS::BOARD_PRINTOUT_SETTINGS( const PAGE_INFO& aPageInfo )
} }
void BOARD_PRINTOUT_SETTINGS::Load( wxConfigBase* aConfig ) void BOARD_PRINTOUT_SETTINGS::Load( APP_SETTINGS_BASE* aConfig )
{ {
PRINTOUT_SETTINGS::Load( aConfig ); PRINTOUT_SETTINGS::Load( aConfig );
for( unsigned layer = 0; layer < m_layerSet.size(); ++layer ) m_layerSet.reset();
{
int tmp; for( int layer : aConfig->m_Printing.layers )
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer ); m_layerSet.set( layer, true );
aConfig->Read( key, &tmp, 1 );
m_layerSet.set( layer, tmp );
}
} }
void BOARD_PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig ) void BOARD_PRINTOUT_SETTINGS::Save( APP_SETTINGS_BASE* aConfig )
{ {
PRINTOUT_SETTINGS::Save( aConfig ); PRINTOUT_SETTINGS::Save( aConfig );
aConfig->m_Printing.layers.clear();
for( unsigned layer = 0; layer < m_layerSet.size(); ++layer ) for( unsigned layer = 0; layer < m_layerSet.size(); ++layer )
{ if( m_layerSet.test( layer ) )
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer ); aConfig->m_Printing.layers.push_back( layer );
aConfig->Write( key, m_layerSet.test( layer ) );
}
} }

View File

@ -35,6 +35,7 @@
#include <base_units.h> #include <base_units.h>
#include <reporter.h> #include <reporter.h>
#include <mutex> #include <mutex>
#include <settings/settings_manager.h>
#include <wx/process.h> #include <wx/process.h>
#include <wx/config.h> #include <wx/config.h>
@ -246,60 +247,6 @@ timestamp_t GetNewTimeStamp()
} }
std::unique_ptr<wxConfigBase> GetNewConfig( const wxString& aProgName )
{
wxFileName configname;
configname.AssignDir( GetKicadConfigPath() );
configname.SetFullName( aProgName );
// explicitly use wxFileConfig to prevent storing any settings in the system registry on Windows
return std::make_unique<wxFileConfig>( wxT( "" ), wxT( "" ), configname.GetFullPath() );
}
wxString GetKicadConfigPath()
{
wxFileName cfgpath;
// http://docs.wxwidgets.org/3.0/classwx_standard_paths.html#a7c7cf595d94d29147360d031647476b0
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
// GetUserConfigDir() does not default to ~/.config which is the current standard
// configuration file location on Linux. This has been fixed in later versions of wxWidgets.
#if !defined( __WXMSW__ ) && !defined( __WXMAC__ )
wxArrayString dirs = cfgpath.GetDirs();
if( dirs.Last() != ".config" )
cfgpath.AppendDir( ".config" );
#endif
wxString envstr;
// This shouldn't cause any issues on Windows or MacOS.
if( wxGetEnv( wxT( "XDG_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
{
// Override the assignment above with XDG_CONFIG_HOME
cfgpath.AssignDir( envstr );
}
cfgpath.AppendDir( TO_STR( KICAD_CONFIG_DIR ) );
// Use KICAD_CONFIG_HOME to allow the user to force a specific configuration path.
if( wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
{
// Override the assignment above with KICAD_CONFIG_HOME
cfgpath.AssignDir( envstr );
}
if( !cfgpath.DirExists() )
{
cfgpath.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
}
return cfgpath.GetPath();
}
enum Bracket enum Bracket
{ {
Bracket_None, Bracket_None,

View File

@ -0,0 +1,150 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bitmaps.h>
#include <dialogs/dialog_migrate_settings.h>
#include <settings/settings_manager.h>
DIALOG_MIGRATE_SETTINGS::DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager ) :
DIALOG_MIGRATE_SETTINGS_BASE( nullptr ), m_manager( aManager )
{
m_standardButtonsCancel->SetLabel( _( "Quit KiCad" ) );
m_btnCustomPath->SetBitmap( KiBitmap( folder_xpm ) );
GetSizer()->SetSizeHints( this );
Centre();
}
DIALOG_MIGRATE_SETTINGS::~DIALOG_MIGRATE_SETTINGS()
{
}
bool DIALOG_MIGRATE_SETTINGS::TransferDataToWindow()
{
if( !wxDialog::TransferDataToWindow() )
return false;
wxString str;
str.Printf( _( "Welcome to KiCad %s!" ), SETTINGS_MANAGER::GetSettingsVersion() );
m_lblWelcome->SetLabelText( str );
std::vector<wxString> paths;
if( !m_manager->GetPreviousVersionPaths( &paths ) )
{
m_btnPrevVer->SetLabelText( _( "Import settings from a previous version (none found)" ) );
m_btnUseDefaults->SetValue( true );
}
else
{
m_cbPath->Clear();
for( const auto& path : paths )
m_cbPath->Append( path );
m_cbPath->SetSelection( 0 );
m_btnPrevVer->SetValue( true );
}
Fit();
return true;
}
bool DIALOG_MIGRATE_SETTINGS::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
if( m_btnPrevVer->GetValue() )
m_manager->SetMigrationSource( m_cbPath->GetValue() );
else
m_manager->SetMigrationSource( wxEmptyString );
return true;
}
void DIALOG_MIGRATE_SETTINGS::OnPrevVerSelected( wxCommandEvent& event )
{
m_standardButtons->GetAffirmativeButton()->Enable();
m_cbPath->Enable();
m_btnCustomPath->Enable();
validatePath();
}
void DIALOG_MIGRATE_SETTINGS::OnPathChanged( wxCommandEvent& event )
{
validatePath();
}
void DIALOG_MIGRATE_SETTINGS::OnPathDefocused( wxFocusEvent& event )
{
validatePath();
}
void DIALOG_MIGRATE_SETTINGS::OnChoosePath( wxCommandEvent& event )
{
wxDirDialog dlg( nullptr, _( "Select Settings Path" ), m_cbPath->GetValue(),
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
if( dlg.ShowModal() == wxID_OK )
{
m_cbPath->SetValue( dlg.GetPath() );
validatePath();
}
}
void DIALOG_MIGRATE_SETTINGS::OnDefaultSelected( wxCommandEvent& event )
{
m_standardButtons->GetAffirmativeButton()->Enable();
m_cbPath->Disable();
m_btnCustomPath->Disable();
showPathError( false );
}
bool DIALOG_MIGRATE_SETTINGS::validatePath()
{
wxString path = m_cbPath->GetValue();
bool valid = m_manager->IsSettingsPathValid( path );
showPathError( !valid );
m_standardButtons->GetAffirmativeButton()->Enable( valid && !path.IsEmpty() );
return valid;
}
void DIALOG_MIGRATE_SETTINGS::showPathError( bool aShow )
{
m_lblPathError->Show( aShow );
Layout();
Fit();
}

View File

@ -0,0 +1,62 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DIALOG_MIGRATE_SETTINGS_H
#define _DIALOG_MIGRATE_SETTINGS_H
#include "dialog_migrate_settings_base.h"
class SETTINGS_MANAGER;
class DIALOG_MIGRATE_SETTINGS : public DIALOG_MIGRATE_SETTINGS_BASE
{
public:
DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager );
~DIALOG_MIGRATE_SETTINGS() override;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
protected:
void OnPrevVerSelected( wxCommandEvent& event ) override;
void OnPathChanged( wxCommandEvent& event ) override;
void OnPathDefocused( wxFocusEvent& event ) override;
void OnChoosePath( wxCommandEvent& event ) override;
void OnDefaultSelected( wxCommandEvent& event ) override;
private:
bool validatePath();
void showPathError( bool aShow = true );
SETTINGS_MANAGER* m_manager;
};
#endif

View File

@ -0,0 +1,102 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_migrate_settings_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_MIGRATE_SETTINGS_BASE::DIALOG_MIGRATE_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
m_sizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
m_lblWelcome = new wxStaticText( this, wxID_ANY, wxT("Welcome to KiCad %s!"), wxDefaultPosition, wxDefaultSize, 0 );
m_lblWelcome->Wrap( -1 );
m_lblWelcome->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) );
bSizer6->Add( m_lblWelcome, 0, wxALL, 5 );
m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("How would you like to configure KiCad?"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizer6->Add( m_staticText2, 0, wxALL, 5 );
m_btnPrevVer = new wxRadioButton( this, wxID_ANY, wxT("Import settings from a previous version at:"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_btnPrevVer, 0, wxALL, 5 );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
m_cbPath = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_cbPath->SetMinSize( wxSize( 480,-1 ) );
bSizer5->Add( m_cbPath, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_btnCustomPath = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_btnCustomPath->SetToolTip( wxT("Choose a different path") );
bSizer5->Add( m_btnCustomPath, 0, wxALL, 5 );
bSizer6->Add( bSizer5, 1, wxEXPAND, 5 );
m_lblPathError = new wxStaticText( this, wxID_ANY, wxT("The selected path does not contain valid KiCad settings!"), wxDefaultPosition, wxDefaultSize, 0 );
m_lblPathError->Wrap( -1 );
m_lblPathError->SetForegroundColour( wxColour( 255, 43, 0 ) );
m_lblPathError->Hide();
bSizer6->Add( m_lblPathError, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
m_btnUseDefaults = new wxRadioButton( this, wxID_ANY, wxT("Start with default settings"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_btnUseDefaults, 0, wxALL, 5 );
m_sizer->Add( bSizer6, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
m_sizer->Add( 0, 0, 1, wxEXPAND, 5 );
m_standardButtons = new wxStdDialogButtonSizer();
m_standardButtonsOK = new wxButton( this, wxID_OK );
m_standardButtons->AddButton( m_standardButtonsOK );
m_standardButtonsCancel = new wxButton( this, wxID_CANCEL );
m_standardButtons->AddButton( m_standardButtonsCancel );
m_standardButtons->Realize();
m_standardButtons->SetMinSize( wxSize( -1,50 ) );
m_sizer->Add( m_standardButtons, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 10 );
this->SetSizer( m_sizer );
this->Layout();
m_sizer->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_btnPrevVer->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPrevVerSelected ), NULL, this );
m_cbPath->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this );
m_cbPath->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathDefocused ), NULL, this );
m_cbPath->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this );
m_btnCustomPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnChoosePath ), NULL, this );
m_btnUseDefaults->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnDefaultSelected ), NULL, this );
}
DIALOG_MIGRATE_SETTINGS_BASE::~DIALOG_MIGRATE_SETTINGS_BASE()
{
// Disconnect Events
m_btnPrevVer->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPrevVerSelected ), NULL, this );
m_cbPath->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this );
m_cbPath->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathDefocused ), NULL, this );
m_cbPath->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnPathChanged ), NULL, this );
m_btnCustomPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnChoosePath ), NULL, this );
m_btnUseDefaults->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_MIGRATE_SETTINGS_BASE::OnDefaultSelected ), NULL, this );
}

View File

@ -0,0 +1,568 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration">; </property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_migrate_settings_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">0</property>
<property name="name">DIALOG_MIGRATE_SETTINGS</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_MIGRATE_SETTINGS_BASE</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxCAPTION</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Configure KiCad Settings Path</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size">-1,-1</property>
<property name="name">m_sizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer6</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font">,90,92,-1,70,0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Welcome to KiCad %s!</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_lblWelcome</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">How would you like to configure KiCad?</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText2</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxRadioButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Import settings from a previous version at:</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btnPrevVer</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnRadioButton">OnPrevVerSelected</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer5</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxComboBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices"></property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">480,-1</property>
<property name="moveable">1</property>
<property name="name">m_cbPath</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">-1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCombobox">OnPathChanged</event>
<event name="OnKillFocus">OnPathDefocused</event>
<event name="OnTextEnter">OnPathChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxBitmapButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Choose Path</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btnCustomPath</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Choose a different path</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnChoosePath</event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">255,43,0</property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">1</property>
<property name="id">wxID_ANY</property>
<property name="label">The selected path does not contain valid KiCad settings!</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_lblPathError</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxRadioButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Start with default settings</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_btnUseDefaults</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnRadioButton">OnDefaultSelected</event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size">-1,50</property>
<property name="name">m_standardButtons</property>
<property name="permission">protected</property>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/radiobut.h>
#include <wx/combobox.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_MIGRATE_SETTINGS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_MIGRATE_SETTINGS_BASE : public DIALOG_SHIM
{
private:
protected:
wxBoxSizer* m_sizer;
wxStaticText* m_lblWelcome;
wxStaticText* m_staticText2;
wxRadioButton* m_btnPrevVer;
wxComboBox* m_cbPath;
wxBitmapButton* m_btnCustomPath;
wxStaticText* m_lblPathError;
wxRadioButton* m_btnUseDefaults;
wxStdDialogButtonSizer* m_standardButtons;
wxButton* m_standardButtonsOK;
wxButton* m_standardButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnPrevVerSelected( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPathChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPathDefocused( wxFocusEvent& event ) { event.Skip(); }
virtual void OnChoosePath( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDefaultSelected( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_MIGRATE_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Configure KiCad Settings Path"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION );
~DIALOG_MIGRATE_SETTINGS_BASE();
};

View File

@ -44,26 +44,12 @@
#ifdef EESCHEMA #ifdef EESCHEMA
#include <general.h> #include <general.h>
#include <sch_screen.h> #include <sch_screen.h>
#include <eeschema_settings.h>
#endif #endif
#define MAX_PAGE_EXAMPLE_SIZE 200 #define MAX_PAGE_EXAMPLE_SIZE 200
#define KEY_EXPORT_REVISION wxT( "PageSettingsExportRevision" )
#define KEY_EXPORT_DATE wxT( "PageSettingsExportDate" )
#define KEY_EXPORT_TITLE wxT( "PageSettingsExportTitle" )
#define KEY_EXPORT_COMPANY wxT( "PageSettingsExportCompany" )
#define KEY_EXPORT_COMMENT1 wxT( "PageSettingsExportComment1" )
#define KEY_EXPORT_COMMENT2 wxT( "PageSettingsExportComment2" )
#define KEY_EXPORT_COMMENT3 wxT( "PageSettingsExportComment3" )
#define KEY_EXPORT_COMMENT4 wxT( "PageSettingsExportComment4" )
#define KEY_EXPORT_COMMENT5 wxT( "PageSettingsExportComment5" )
#define KEY_EXPORT_COMMENT6 wxT( "PageSettingsExportComment6" )
#define KEY_EXPORT_COMMENT7 wxT( "PageSettingsExportComment7" )
#define KEY_EXPORT_COMMENT8 wxT( "PageSettingsExportComment8" )
#define KEY_EXPORT_COMMENT9 wxT( "PageSettingsExportComment9" )
// List of page formats. // List of page formats.
// they are prefixed by "_HKI" (already in use for hotkeys) instead of "_", // they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
// because we need both the translated and the not translated version. // because we need both the translated and the not translated version.
@ -135,20 +121,22 @@ DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMa
DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS() DIALOG_PAGES_SETTINGS::~DIALOG_PAGES_SETTINGS()
{ {
#ifdef EESCHEMA #ifdef EESCHEMA
wxConfigBase* config = Kiface().KifaceSettings(); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
config->Write( KEY_EXPORT_REVISION, m_RevisionExport->GetValue() ); wxASSERT( cfg );
config->Write( KEY_EXPORT_DATE, m_DateExport->GetValue() );
config->Write( KEY_EXPORT_TITLE, m_TitleExport->GetValue() ); cfg->m_PageSettings.export_revision = m_RevisionExport->GetValue();
config->Write( KEY_EXPORT_COMPANY, m_CompanyExport->GetValue() ); cfg->m_PageSettings.export_date = m_DateExport->GetValue();
config->Write( KEY_EXPORT_COMMENT1, m_Comment1Export->GetValue() ); cfg->m_PageSettings.export_title = m_TitleExport->GetValue();
config->Write( KEY_EXPORT_COMMENT2, m_Comment2Export->GetValue() ); cfg->m_PageSettings.export_company = m_CompanyExport->GetValue();
config->Write( KEY_EXPORT_COMMENT3, m_Comment3Export->GetValue() ); cfg->m_PageSettings.export_comment1 = m_Comment1Export->GetValue();
config->Write( KEY_EXPORT_COMMENT4, m_Comment4Export->GetValue() ); cfg->m_PageSettings.export_comment2 = m_Comment2Export->GetValue();
config->Write( KEY_EXPORT_COMMENT5, m_Comment5Export->GetValue() ); cfg->m_PageSettings.export_comment3 = m_Comment3Export->GetValue();
config->Write( KEY_EXPORT_COMMENT6, m_Comment6Export->GetValue() ); cfg->m_PageSettings.export_comment4 = m_Comment4Export->GetValue();
config->Write( KEY_EXPORT_COMMENT7, m_Comment7Export->GetValue() ); cfg->m_PageSettings.export_comment5 = m_Comment5Export->GetValue();
config->Write( KEY_EXPORT_COMMENT8, m_Comment8Export->GetValue() ); cfg->m_PageSettings.export_comment6 = m_Comment6Export->GetValue();
config->Write( KEY_EXPORT_COMMENT9, m_Comment9Export->GetValue() ); cfg->m_PageSettings.export_comment7 = m_Comment7Export->GetValue();
cfg->m_PageSettings.export_comment8 = m_Comment8Export->GetValue();
cfg->m_PageSettings.export_comment9 = m_Comment9Export->GetValue();
#endif #endif
delete m_page_bitmap; delete m_page_bitmap;
@ -221,20 +209,22 @@ void DIALOG_PAGES_SETTINGS::initDialog()
m_TextComment9->SetValue( m_tb.GetComment( 8 ) ); m_TextComment9->SetValue( m_tb.GetComment( 8 ) );
#ifdef EESCHEMA #ifdef EESCHEMA
wxConfigBase* config = Kiface().KifaceSettings(); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_RevisionExport->SetValue( config->ReadBool( KEY_EXPORT_REVISION, false ) ); wxASSERT( cfg );
m_DateExport->SetValue( config->ReadBool( KEY_EXPORT_DATE, false ) );
m_TitleExport->SetValue( config->ReadBool( KEY_EXPORT_TITLE, false ) ); m_RevisionExport->SetValue( cfg->m_PageSettings.export_revision );
m_CompanyExport->SetValue( config->ReadBool( KEY_EXPORT_COMPANY, false ) ); m_DateExport->SetValue( cfg->m_PageSettings.export_date );
m_Comment1Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT1, false ) ); m_TitleExport->SetValue( cfg->m_PageSettings.export_title );
m_Comment2Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT2, false ) ); m_CompanyExport->SetValue( cfg->m_PageSettings.export_company );
m_Comment3Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT3, false ) ); m_Comment1Export->SetValue( cfg->m_PageSettings.export_comment1 );
m_Comment4Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT4, false ) ); m_Comment2Export->SetValue( cfg->m_PageSettings.export_comment2 );
m_Comment5Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT5, false ) ); m_Comment3Export->SetValue( cfg->m_PageSettings.export_comment3 );
m_Comment6Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT6, false ) ); m_Comment4Export->SetValue( cfg->m_PageSettings.export_comment4 );
m_Comment7Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT7, false ) ); m_Comment5Export->SetValue( cfg->m_PageSettings.export_comment5 );
m_Comment8Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT8, false ) ); m_Comment6Export->SetValue( cfg->m_PageSettings.export_comment6 );
m_Comment9Export->SetValue( config->ReadBool( KEY_EXPORT_COMMENT9, false ) ); m_Comment7Export->SetValue( cfg->m_PageSettings.export_comment7 );
m_Comment8Export->SetValue( cfg->m_PageSettings.export_comment8 );
m_Comment9Export->SetValue( cfg->m_PageSettings.export_comment9 );
#else #else
m_RevisionExport->Show( false ); m_RevisionExport->Show( false );
m_DateExport->Show( false ); m_DateExport->Show( false );

View File

@ -23,7 +23,6 @@
#include <wx/valnum.h> #include <wx/valnum.h>
#include <widgets/unit_binder.h> #include <widgets/unit_binder.h>
class wxConfigBase;
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
struct PRINTOUT_SETTINGS; struct PRINTOUT_SETTINGS;
@ -78,7 +77,7 @@ protected:
// even if the dialog is closed without printing // even if the dialog is closed without printing
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
wxConfigBase* m_config; APP_SETTINGS_BASE* m_config;
PRINTOUT_SETTINGS* m_settings; PRINTOUT_SETTINGS* m_settings;

View File

@ -30,6 +30,8 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <id.h> #include <id.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
static constexpr int dpi_scaling_precision = 1; static constexpr int dpi_scaling_precision = 1;
static constexpr double dpi_scaling_increment = 0.5; static constexpr double dpi_scaling_increment = 0.5;
@ -79,28 +81,20 @@ PANEL_COMMON_SETTINGS::~PANEL_COMMON_SETTINGS()
bool PANEL_COMMON_SETTINGS::TransferDataToWindow() bool PANEL_COMMON_SETTINGS::TransferDataToWindow()
{ {
wxConfigBase* commonSettings = Pgm().CommonSettings(); COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
int timevalue; int timevalue = commonSettings->m_System.autosave_interval;
wxString msg; wxString msg;
commonSettings->Read( AUTOSAVE_INTERVAL_KEY, &timevalue );
msg << timevalue / 60; msg << timevalue / 60;
m_SaveTime->SetValue( msg ); m_SaveTime->SetValue( msg );
int fileHistorySize; m_fileHistorySize->SetValue( commonSettings->m_System.file_history_size );
commonSettings->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE );
m_fileHistorySize->SetValue( fileHistorySize );
int antialiasingMode; m_antialiasing->SetSelection( commonSettings->m_Graphics.opengl_aa_mode );
commonSettings->Read( GAL_ANTIALIASING_MODE_KEY, &antialiasingMode, 0 ); m_antialiasingFallback->SetSelection( commonSettings->m_Graphics.cairo_aa_mode );
m_antialiasing->SetSelection( antialiasingMode );
commonSettings->Read( CAIRO_ANTIALIASING_MODE_KEY, &antialiasingMode, 0 ); int icon_scale_fourths = commonSettings->m_Appearance.icon_scale;
m_antialiasingFallback->SetSelection( antialiasingMode );
int icon_scale_fourths;
commonSettings->Read( ICON_SCALE_KEY, &icon_scale_fourths );
if( icon_scale_fourths <= 0 ) if( icon_scale_fourths <= 0 )
{ {
@ -119,33 +113,16 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow()
m_canvasScaleAuto->SetValue( dpi.GetCanvasIsAutoScaled() ); m_canvasScaleAuto->SetValue( dpi.GetCanvasIsAutoScaled() );
} }
bool option; m_checkBoxIconsInMenus->SetValue( commonSettings->m_Appearance.use_icons_in_menus );
commonSettings->Read( USE_ICONS_IN_MENUS_KEY, &option ); m_ZoomCenterOpt->SetValue( commonSettings->m_Input.center_on_zoom );
m_checkBoxIconsInMenus->SetValue( option ); m_MousewheelPANOpt->SetValue( commonSettings->m_Input.mousewheel_pan );
m_AutoPANOpt->SetValue( commonSettings->m_Input.auto_pan );
commonSettings->Read( ENBL_ZOOM_NO_CENTER_KEY, &option ); m_PreferSelectToDrag->SetValue( commonSettings->m_Input.prefer_select_to_drag );
m_ZoomCenterOpt->SetValue( !option ); m_warpMouseOnMove->SetValue( commonSettings->m_Input.warp_mouse_on_move );
m_NonImmediateActions->SetValue( !commonSettings->m_Input.immediate_actions );
commonSettings->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
m_MousewheelPANOpt->SetValue( option );
commonSettings->Read( ENBL_AUTO_PAN_KEY, &option );
m_AutoPANOpt->SetValue( option );
if( !commonSettings->Read( PREFER_SELECT_TO_DRAG_KEY, &option ) )
{
// Legacy versions stored the property only for PCBNew, so see if we have it there
std::unique_ptr<wxConfigBase> pcbSettings = GetNewConfig( wxT( "pcbnew" ) );
pcbSettings->Read( "DragSelects", &option, true );
}
m_PreferSelectToDrag->SetValue( option );
commonSettings->Read( WARP_MOUSE_ON_MOVE_KEY, &option );
m_warpMouseOnMove->SetValue( option );
commonSettings->Read( IMMEDIATE_ACTIONS_KEY, &option );
m_NonImmediateActions->SetValue( !option );
// TODO(JE) Move these into COMMON_SETTINGS probably
m_textEditorPath->SetValue( Pgm().GetEditorName( false ) ); m_textEditorPath->SetValue( Pgm().GetEditorName( false ) );
m_defaultPDFViewer->SetValue( Pgm().UseSystemPdfBrowser() ); m_defaultPDFViewer->SetValue( Pgm().UseSystemPdfBrowser() );
m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() ); m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() );
@ -157,31 +134,30 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow()
bool PANEL_COMMON_SETTINGS::TransferDataFromWindow() bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
{ {
wxConfigBase* commonSettings = Pgm().CommonSettings(); COMMON_SETTINGS* commonSettings = Pgm().GetCommonSettings();
commonSettings->Write( AUTOSAVE_INTERVAL_KEY, m_SaveTime->GetValue() * 60 ); commonSettings->m_System.autosave_interval = m_SaveTime->GetValue() * 60;
commonSettings->m_System.file_history_size = m_fileHistorySize->GetValue();
commonSettings->Write( FILE_HISTORY_SIZE_KEY, m_fileHistorySize->GetValue() ); commonSettings->m_Graphics.opengl_aa_mode = m_antialiasing->GetSelection();
commonSettings->m_Graphics.cairo_aa_mode = m_antialiasingFallback->GetSelection();
commonSettings->Write( GAL_ANTIALIASING_MODE_KEY, m_antialiasing->GetSelection() );
commonSettings->Write( CAIRO_ANTIALIASING_MODE_KEY, m_antialiasingFallback->GetSelection() );
const int scale_fourths = m_iconScaleAuto->GetValue() ? -1 : m_iconScaleSlider->GetValue() / 25; const int scale_fourths = m_iconScaleAuto->GetValue() ? -1 : m_iconScaleSlider->GetValue() / 25;
commonSettings->Write( ICON_SCALE_KEY, scale_fourths ); commonSettings->m_Appearance.icon_scale = scale_fourths;
{ {
DPI_SCALING dpi( commonSettings, this ); DPI_SCALING dpi( commonSettings, this );
dpi.SetDpiConfig( m_canvasScaleAuto->GetValue(), m_canvasScaleCtrl->GetValue() ); dpi.SetDpiConfig( m_canvasScaleAuto->GetValue(), m_canvasScaleCtrl->GetValue() );
} }
commonSettings->Write( USE_ICONS_IN_MENUS_KEY, m_checkBoxIconsInMenus->GetValue() ); commonSettings->m_Appearance.use_icons_in_menus = m_checkBoxIconsInMenus->GetValue();
commonSettings->Write( ENBL_ZOOM_NO_CENTER_KEY, !m_ZoomCenterOpt->GetValue() );
commonSettings->Write( ENBL_MOUSEWHEEL_PAN_KEY, m_MousewheelPANOpt->GetValue() ); commonSettings->m_Input.auto_pan = m_AutoPANOpt->GetValue();
commonSettings->Write( ENBL_AUTO_PAN_KEY, m_AutoPANOpt->GetValue() ); commonSettings->m_Input.center_on_zoom = m_ZoomCenterOpt->GetValue();
commonSettings->Write( PREFER_SELECT_TO_DRAG_KEY, m_PreferSelectToDrag->GetValue() ); commonSettings->m_Input.immediate_actions = !m_NonImmediateActions->GetValue();
commonSettings->Write( WARP_MOUSE_ON_MOVE_KEY, m_warpMouseOnMove->GetValue() ); commonSettings->m_Input.mousewheel_pan = m_MousewheelPANOpt->GetValue();
commonSettings->Write( IMMEDIATE_ACTIONS_KEY, !m_NonImmediateActions->GetValue() ); commonSettings->m_Input.prefer_select_to_drag = m_PreferSelectToDrag->GetValue();
commonSettings->m_Input.warp_mouse_on_move = m_warpMouseOnMove->GetValue();
Pgm().SetEditorName( m_textEditorPath->GetValue() ); Pgm().SetEditorName( m_textEditorPath->GetValue() );
@ -189,6 +165,8 @@ bool PANEL_COMMON_SETTINGS::TransferDataFromWindow()
Pgm().ForceSystemPdfBrowser( m_defaultPDFViewer->GetValue() ); Pgm().ForceSystemPdfBrowser( m_defaultPDFViewer->GetValue() );
Pgm().WritePdfBrowserInfos(); Pgm().WritePdfBrowserInfos();
Pgm().GetSettingsManager().Save( commonSettings );
return true; return true;
} }

View File

@ -27,8 +27,8 @@
#include <env_vars.h> #include <env_vars.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/common_settings.h>
#include <wx/config.h>
#include <wx/log.h> #include <wx/log.h>
@ -47,11 +47,10 @@ const wxChar* const traceHiDpi = wxT( "KICAD_TRACE_HIGH_DPI" );
* *
* @return the scale factor, if set * @return the scale factor, if set
*/ */
static OPT<double> getKiCadConfiguredScale( const wxConfigBase& aConfig ) static OPT<double> getKiCadConfiguredScale( const COMMON_SETTINGS& aConfig )
{ {
OPT<double> scale; OPT<double> scale;
double canvas_scale = 0.0; double canvas_scale = aConfig.m_Appearance.canvas_scale;
aConfig.Read( CANVAS_SCALE_KEY, &canvas_scale, 0.0 );
if( canvas_scale > 0.0 ) if( canvas_scale > 0.0 )
{ {
@ -93,7 +92,7 @@ static OPT<double> getEnviromentScale()
} }
DPI_SCALING::DPI_SCALING( wxConfigBase* aConfig, const wxWindow* aWindow ) DPI_SCALING::DPI_SCALING( COMMON_SETTINGS* aConfig, const wxWindow* aWindow )
: m_config( aConfig ), m_window( aWindow ) : m_config( aConfig ), m_window( aWindow )
{ {
} }
@ -153,7 +152,7 @@ void DPI_SCALING::SetDpiConfig( bool aAuto, double aValue )
const double value = aAuto ? 0.0 : aValue; const double value = aAuto ? 0.0 : aValue;
m_config->Write( CANVAS_SCALE_KEY, value ); m_config->m_Appearance.canvas_scale = value;
} }

View File

@ -24,9 +24,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <confirm.h>
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <confirm.h> #include <settings/app_settings.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <view/view.h> #include <view/view.h>

View File

@ -23,48 +23,28 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <wx/stdpaths.h> #include <bitmaps.h>
#include <wx/string.h>
#include <wx/display.h>
#include <dialog_shim.h> #include <dialog_shim.h>
#include <dialogs/panel_common_settings.h>
#include <filehistory.h>
#include <id.h> #include <id.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <pgm_base.h> #include <menus_helpers.h>
#include <trace_helpers.h>
#include <panel_hotkeys_editor.h> #include <panel_hotkeys_editor.h>
#include <dialogs/panel_common_settings.h> #include <pgm_base.h>
#include <widgets/paged_dialog.h> #include <settings/app_settings.h>
#include <bitmaps.h> #include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <tool/action_manager.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <tool/actions.h>
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/action_manager.h> #include <trace_helpers.h>
#include <menus_helpers.h> #include <widgets/paged_dialog.h>
#include <tool/actions.h> #include <wx/display.h>
#include <filehistory.h> #include <wx/stdpaths.h>
#include <wx/string.h>
/// The default auto save interval is 10 minutes.
#define DEFAULT_AUTO_SAVE_INTERVAL 600
///@{
/// \ingroup config
/// Configuration file entry name for auto save interval.
static const wxString entryAutoSaveInterval = "AutoSaveInterval";
/// Configuration file entry for wxAuiManger perspective.
static const wxString entryPerspective = "Perspective";
/// Configuration file entry for most recently used path.
static const wxString entryMruPath = "MostRecentlyUsedPath";
static const wxString entryPosY = "Pos_y"; ///< Y position of frame, in pixels (suffix)
static const wxString entryPosX = "Pos_x"; ///< X position of frame, in pixels (suffix)
static const wxString entrySizeY = "Size_y"; ///< Height of frame, in pixels (suffix)
static const wxString entrySizeX = "Size_x"; ///< Width of frame, in pixels (suffix)
static const wxString entryMaximized = "Maximized"; ///< Nonzero iff frame is maximized (suffix)
///@}
BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame ) BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame )
@ -95,6 +75,7 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER ); m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
m_mruPath = wxStandardPaths::Get().GetDocumentsDir(); m_mruPath = wxStandardPaths::Get().GetDocumentsDir();
m_toolManager = nullptr; m_toolManager = nullptr;
m_settingsManager = nullptr;
// Gives a reasonable minimal size to the frame: // Gives a reasonable minimal size to the frame:
const int minsize_x = 500; const int minsize_x = 500;
@ -151,7 +132,7 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
return; return;
} }
wxConfigBase* cfg = config(); APP_SETTINGS_BASE* cfg = config();
if( cfg ) if( cfg )
SaveSettings( cfg ); // virtual, wxFrame specific SaveSettings( cfg ); // virtual, wxFrame specific
@ -450,40 +431,30 @@ void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
GetMenuBar()->Refresh(); GetMenuBar()->Refresh();
} }
wxConfigBase* settings = Pgm().CommonSettings(); COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
settings->Read( WARP_MOUSE_ON_MOVE_KEY, &m_moveWarpsCursor ); m_moveWarpsCursor = settings->m_Input.warp_mouse_on_move;
settings->Read( PREFER_SELECT_TO_DRAG_KEY, &m_dragSelects ); m_dragSelects = settings->m_Input.prefer_select_to_drag;
settings->Read( IMMEDIATE_ACTIONS_KEY, &m_immediateActions ); m_immediateActions = settings->m_Input.immediate_actions;
} }
void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) void EDA_BASE_FRAME::LoadWindowSettings( WINDOW_SETTINGS* aCfg )
{ {
int maximized = 0; m_FramePos.x = aCfg->pos_x;
m_FramePos.y = aCfg->pos_y;
m_FrameSize.x = aCfg->size_x;
m_FrameSize.y = aCfg->size_y;
wxString baseCfgName = ConfigBaseName(); // Ensure minimum size is set if the stored config was zero-initialized
if( m_FrameSize.x < GetMinWidth() || m_FrameSize.y < GetMinHeight() )
wxString text = baseCfgName + entryPosX; {
aCfg->Read( text, &m_FramePos.x, m_FramePos.x ); m_FrameSize.x = GetMinWidth();
m_FrameSize.y = GetMinHeight();
text = baseCfgName + entryPosY; }
aCfg->Read( text, &m_FramePos.y, m_FramePos.y );
text = baseCfgName + entrySizeX;
aCfg->Read( text, &m_FrameSize.x, m_FrameSize.x );
text = baseCfgName + entrySizeY;
aCfg->Read( text, &m_FrameSize.y, m_FrameSize.y );
text = baseCfgName + entryMaximized;
aCfg->Read( text, &maximized, 0 );
if( m_hasAutoSave ) if( m_hasAutoSave )
{ m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
text = baseCfgName + entryAutoSaveInterval;
aCfg->Read( text, &m_autoSaveInterval, DEFAULT_AUTO_SAVE_INTERVAL );
}
// Ensure the window is on a connected display, and is visible. // Ensure the window is on a connected display, and is visible.
// (at least a corner of the frame must be visible on screen) // (at least a corner of the frame must be visible on screen)
@ -510,33 +481,21 @@ void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
if( m_FramePos.y < Ypos_min ) if( m_FramePos.y < Ypos_min )
m_FramePos.y = Ypos_min; m_FramePos.y = Ypos_min;
if( maximized ) if( aCfg->maximized )
Maximize(); Maximize();
aCfg->Read( baseCfgName + entryPerspective, &m_perspective ); m_perspective = aCfg->perspective;
aCfg->Read( baseCfgName + entryMruPath, &m_mruPath ); m_mruPath = aCfg->mru_path;
wxConfigBase* settings = Pgm().CommonSettings(); COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
if( !settings->Read( WARP_MOUSE_ON_MOVE_KEY, &m_moveWarpsCursor ) ) m_moveWarpsCursor = settings->m_Input.warp_mouse_on_move;
{ m_dragSelects = settings->m_Input.prefer_select_to_drag;
// Legacy versions stored the property only for Eeschema, so see if we have it there m_immediateActions = settings->m_Input.immediate_actions;
std::unique_ptr<wxConfigBase> pcbSettings = GetNewConfig( wxT( "eeschema" ) );
pcbSettings->Read( "MoveWarpsCursor", &m_moveWarpsCursor, true );
}
if( !settings->Read( PREFER_SELECT_TO_DRAG_KEY, &m_dragSelects ) )
{
// Legacy versions stored the property only for PCBNew, so see if we have it there
std::unique_ptr<wxConfigBase> pcbSettings = GetNewConfig( wxT( "pcbnew" ) );
pcbSettings->Read( "DragSelects", &m_dragSelects, true );
}
settings->Read( IMMEDIATE_ACTIONS_KEY, &m_immediateActions, false );
} }
void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg )
{ {
wxString text; wxString text;
@ -548,43 +507,47 @@ void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
m_FrameSize = GetSize(); m_FrameSize = GetSize();
m_FramePos = GetPosition(); m_FramePos = GetPosition();
text = baseCfgName + wxT( "Pos_x" ); aCfg->pos_x = m_FramePos.x;
aCfg->Write( text, (long) m_FramePos.x ); aCfg->pos_y = m_FramePos.y;
aCfg->size_x = m_FrameSize.x;
text = baseCfgName + wxT( "Pos_y" ); aCfg->size_y = m_FrameSize.y;
aCfg->Write( text, (long) m_FramePos.y ); aCfg->maximized = IsMaximized();
text = baseCfgName + wxT( "Size_x" );
aCfg->Write( text, (long) m_FrameSize.x );
text = baseCfgName + wxT( "Size_y" );
aCfg->Write( text, (long) m_FrameSize.y );
text = baseCfgName + wxT( "Maximized" );
aCfg->Write( text, IsMaximized() );
// TODO(JE) should auto-save in common settings be overwritten by every app?
if( m_hasAutoSave ) if( m_hasAutoSave )
{ Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
text = baseCfgName + entryAutoSaveInterval;
aCfg->Write( text, m_autoSaveInterval );
}
// Once this is fully implemented, wxAuiManager will be used to maintain // Once this is fully implemented, wxAuiManager will be used to maintain
// the persistance of the main frame and all it's managed windows and // the persistance of the main frame and all it's managed windows and
// all of the legacy frame persistence position code can be removed. // all of the legacy frame persistence position code can be removed.
wxString perspective = m_auimgr.SavePerspective(); aCfg->perspective = m_auimgr.SavePerspective().ToStdString();
// printf( "perspective(%s): %s\n", aCfg->mru_path = m_mruPath;
// TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) );
aCfg->Write( baseCfgName + entryPerspective, perspective );
aCfg->Write( baseCfgName + entryMruPath, m_mruPath );
} }
wxConfigBase* EDA_BASE_FRAME::config() void EDA_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
LoadWindowSettings( GetWindowSettings( aCfg ) );
}
void EDA_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
SaveWindowSettings( GetWindowSettings( aCfg ) );
}
WINDOW_SETTINGS* EDA_BASE_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
return &aCfg->m_Window;
}
APP_SETTINGS_BASE* EDA_BASE_FRAME::config()
{ {
// KICAD_MANAGER_FRAME overrides this // KICAD_MANAGER_FRAME overrides this
wxConfigBase* ret = Kiface().KifaceSettings(); APP_SETTINGS_BASE* ret = Kiface().KifaceSettings();
//wxASSERT( ret ); //wxASSERT( ret );
return ret; return ret;
} }

View File

@ -31,6 +31,7 @@
#include <common.h> #include <common.h>
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <settings/common_settings.h>
#include <wx/mimetype.h> #include <wx/mimetype.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
@ -41,23 +42,15 @@
void PGM_BASE::ReadPdfBrowserInfos() void PGM_BASE::ReadPdfBrowserInfos()
{ {
wxASSERT( m_common_settings ); SetPdfBrowserName( GetCommonSettings()->m_System.pdf_viewer_name );
m_use_system_pdf_browser = GetCommonSettings()->m_System.use_system_pdf_viewer;
wxString browser = m_common_settings->Read( wxT( "PdfBrowserName" ), wxEmptyString );
SetPdfBrowserName( browser );
int tmp;
m_common_settings->Read( wxT( "UseSystemBrowser" ), &tmp, 0 );
m_use_system_pdf_browser = bool( tmp );
} }
void PGM_BASE::WritePdfBrowserInfos() void PGM_BASE::WritePdfBrowserInfos()
{ {
wxASSERT( m_common_settings ); GetCommonSettings()->m_System.pdf_viewer_name = GetPdfBrowserName();
GetCommonSettings()->m_System.use_system_pdf_viewer = m_use_system_pdf_browser;
m_common_settings->Write( wxT( "PdfBrowserName" ), GetPdfBrowserName() );
m_common_settings->Write( wxT( "UseSystemBrowser" ), m_use_system_pdf_browser );
} }

View File

@ -23,64 +23,43 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <bitmaps.h>
#include <macros.h>
#include <id.h>
#include <base_screen.h> #include <base_screen.h>
#include <msgpanel.h> #include <bitmaps.h>
#include <eda_draw_frame.h>
#include <confirm.h> #include <confirm.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <lockfile.h>
#include <trace_helpers.h>
#include <wx/snglinst.h>
#include <view/view.h>
#include <tool/tool_manager.h>
#include <tool/action_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/actions.h>
#include <ws_draw_item.h>
#include <page_info.h>
#include <title_block.h>
#include <tool/tool_menu.h>
#include <tool/selection_conditions.h>
#include <tool/zoom_menu.h>
#include <tool/grid_menu.h>
#include <tool/common_tools.h>
#include <dialog_shim.h> #include <dialog_shim.h>
#include <eda_draw_frame.h>
#include <fctsys.h>
#include <filehistory.h> #include <filehistory.h>
#include <id.h>
#include <kiface_i.h>
#include <lockfile.h>
#include <macros.h>
#include <msgpanel.h>
#include <page_info.h>
#include <pgm_base.h>
#include <settings/app_settings.h>
#include <settings/color_settings.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <title_block.h>
#include <tool/action_manager.h>
#include <tool/actions.h>
#include <tool/common_tools.h>
#include <tool/grid_menu.h>
#include <tool/selection_conditions.h>
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <tool/tool_menu.h>
#include <tool/zoom_menu.h>
#include <trace_helpers.h>
#include <view/view.h>
#include <ws_draw_item.h>
#include <wx/snglinst.h>
///@{
/// \ingroup config
static const wxChar FirstRunShownKeyword[] = wxT( "FirstRunShown" );
static const wxChar FindReplaceFlagsEntry[] = wxT( "LastFindReplaceFlags" );
static const wxChar FindStringEntry[] = wxT( "LastFindString" );
static const wxChar ReplaceStringEntry[] = wxT( "LastReplaceString" );
static const wxChar FindStringHistoryEntry[] = wxT( "FindStringHistoryList%d" );
static const wxChar ReplaceStringHistoryEntry[] = wxT( "ReplaceStringHistoryList%d" );
///@}
#define FR_HISTORY_LIST_CNT 10 ///< Maximum size of the find/replace history stacks. #define FR_HISTORY_LIST_CNT 10 ///< Maximum size of the find/replace history stacks.
/**
* Integer to set the maximum number of undo items on the stack. If zero,
* undo items are unlimited.
*
* Present as:
*
* - SchematicFrameDevelMaxUndoItems (file: eeschema)
* - LibeditFrameDevelMaxUndoItems (file: eeschema)
* - PcbFrameDevelMaxUndoItems (file: pcbnew)
* - ModEditFrameDevelMaxUndoItems (file: pcbnew)
*
* \ingroup develconfig
*/
static const wxString MaxUndoItemsEntry(wxT( "DevelMaxUndoItems" ) );
EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
@ -217,26 +196,17 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
{ {
EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged ); EDA_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
wxConfigBase* settings = Pgm().CommonSettings(); COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls(); KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls();
int autosaveInterval; SetAutoSaveInterval( settings->m_System.autosave_interval );
settings->Read( AUTOSAVE_INTERVAL_KEY, &autosaveInterval );
SetAutoSaveInterval( autosaveInterval );
int historySize; int historySize = settings->m_System.file_history_size;
settings->Read( FILE_HISTORY_SIZE_KEY, &historySize, DEFAULT_FILE_HISTORY_SIZE );
Kiface().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) ); Kiface().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) );
bool option; viewControls->EnableMousewheelPan( settings->m_Input.mousewheel_pan );
settings->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option ); viewControls->EnableCursorWarping( settings->m_Input.center_on_zoom );
viewControls->EnableMousewheelPan( option ); viewControls->EnableAutoPan( settings->m_Input.auto_pan );
settings->Read( ENBL_ZOOM_NO_CENTER_KEY, &option );
viewControls->EnableCursorWarping( !option );
settings->Read( ENBL_AUTO_PAN_KEY, &option );
viewControls->EnableAutoPan( option );
m_galDisplayOptions.ReadCommonConfig( *settings, this ); m_galDisplayOptions.ReadCommonConfig( *settings, this );
} }
@ -457,102 +427,73 @@ const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
} }
void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg ) void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{ {
EDA_BASE_FRAME::LoadSettings( aCfg ); EDA_BASE_FRAME::LoadSettings( aCfg );
wxString baseCfgName = ConfigBaseName(); wxString baseCfgName = ConfigBaseName();
wxConfigBase* cmnCfg = Pgm().CommonSettings(); COMMON_SETTINGS* cmnCfg = Pgm().GetCommonSettings();
WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
// Read units used in dialogs and toolbars // Read units used in dialogs and toolbars
EDA_UNITS unitsTmp; SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
if( aCfg->Read( baseCfgName + UserUnitsEntryKeyword, (int*) &unitsTmp ) )
SetUserUnits( unitsTmp );
else
SetUserUnits( EDA_UNITS::MILLIMETRES );
// Read show/hide grid entry // Read show/hide grid entry
bool btmp; SetGridVisibility( window->grid.show );
if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )
SetGridVisibility( btmp );
aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, m_LastGridSizeId ); m_LastGridSizeId = window->grid.last_size;
// m_LastGridSizeId is an offset, expected to be >= 0 // m_LastGridSizeId is an offset, expected to be >= 0
if( m_LastGridSizeId < 0 ) if( m_LastGridSizeId < 0 )
m_LastGridSizeId = 0; m_LastGridSizeId = 0;
m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry, m_UndoRedoCountMax = aCfg->m_System.max_undo_items;
long( DEFAULT_MAX_UNDO_ITEMS ) ); m_firstRunDialogSetting = aCfg->m_System.first_run_shown;
aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L ); m_galDisplayOptions.ReadConfig( *cmnCfg, *window, this );
m_galDisplayOptions.ReadConfig( *cmnCfg, *aCfg, baseCfgName, this ); m_findReplaceData->SetFlags( aCfg->m_FindReplace.flags );
m_findReplaceData->SetFindString( aCfg->m_FindReplace.find_string );
m_findReplaceData->SetReplaceString( aCfg->m_FindReplace.replace_string );
long tmp; for( auto& s : aCfg->m_FindReplace.find_history )
aCfg->Read( FindReplaceFlagsEntry, &tmp, (long) wxFR_DOWN ); m_findStringHistoryList.Add( s );
m_findReplaceData->SetFlags( (wxUint32) tmp & ~FR_REPLACE_ITEM_FOUND );
m_findReplaceData->SetFindString( aCfg->Read( FindStringEntry, wxEmptyString ) );
m_findReplaceData->SetReplaceString( aCfg->Read( ReplaceStringEntry, wxEmptyString ) );
// Load the find and replace string history list. for( auto& s : aCfg->m_FindReplace.replace_history )
for( int i = 0; i < FR_HISTORY_LIST_CNT; ++i ) m_replaceStringHistoryList.Add( s );
{
wxString tmpHistory;
wxString entry;
entry.Printf( FindStringHistoryEntry, i );
tmpHistory = aCfg->Read( entry, wxEmptyString );
if( !tmpHistory.IsEmpty() )
m_findStringHistoryList.Add( tmpHistory );
entry.Printf( ReplaceStringHistoryEntry, i );
tmpHistory = aCfg->Read( entry, wxEmptyString );
if( !tmpHistory.IsEmpty() )
m_replaceStringHistoryList.Add( tmpHistory );
}
} }
void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg ) void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{ {
EDA_BASE_FRAME::SaveSettings( aCfg ); EDA_BASE_FRAME::SaveSettings( aCfg );
wxString baseCfgName = ConfigBaseName(); WINDOW_SETTINGS* window = GetWindowSettings( aCfg );
aCfg->Write( baseCfgName + UserUnitsEntryKeyword, (int) m_userUnits ); aCfg->m_System.units = static_cast<int>( m_userUnits );
aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() ); aCfg->m_System.first_run_shown = m_firstRunDialogSetting;
aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting ); window->grid.show = IsGridVisible();
window->grid.last_size = m_LastGridSizeId;
if( GetScreen() ) if( GetScreen() )
aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) ); aCfg->m_System.max_undo_items = GetScreen()->GetMaxUndoItems();
m_galDisplayOptions.WriteConfig( *aCfg, baseCfgName ); m_galDisplayOptions.WriteConfig( *window );
// Save find dialog session setting. aCfg->m_FindReplace.flags = m_findReplaceData->GetFlags();
aCfg->Write( FindReplaceFlagsEntry, (long) m_findReplaceData->GetFlags() ); aCfg->m_FindReplace.find_string = m_findReplaceData->GetFindString();
aCfg->Write( FindStringEntry, m_findReplaceData->GetFindString() ); aCfg->m_FindReplace.replace_string = m_findReplaceData->GetReplaceString();
aCfg->Write( ReplaceStringEntry, m_findReplaceData->GetReplaceString() );
// Save the find and replace string history list. aCfg->m_FindReplace.find_history.clear();
unsigned i; aCfg->m_FindReplace.replace_history.clear();
wxString tmpHistory;
wxString entry; // invoke constructor outside of any loops
for( i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ ) for( size_t i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
{ aCfg->m_FindReplace.find_history.push_back( m_findStringHistoryList[ i ].ToStdString() );
entry.Printf( FindStringHistoryEntry, i );
aCfg->Write( entry, m_findStringHistoryList[ i ] );
}
for( i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ ) for( size_t i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
{ aCfg->m_FindReplace.replace_history.push_back(
entry.Printf( ReplaceStringHistoryEntry, i ); m_replaceStringHistoryList[ i ].ToStdString() );
aCfg->Write( entry, m_replaceStringHistoryList[ i ] );
}
} }
@ -618,13 +559,10 @@ void EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting() EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting()
{ {
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
wxConfigBase* cfg = Kiface().KifaceSettings(); APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
if( cfg ) if( cfg )
{ canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( cfg->m_Graphics.canvas_type );
canvasType = (EDA_DRAW_PANEL_GAL::GAL_TYPE)
cfg->ReadLong( GetCanvasTypeKey(), EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
}
if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
|| canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST ) || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
@ -682,10 +620,12 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
return false; return false;
} }
wxConfigBase* cfg = Kiface().KifaceSettings(); APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
if( cfg ) if( cfg )
return cfg->Write( GetCanvasTypeKey(), (long) aCanvasType ); cfg->m_Graphics.canvas_type = static_cast<int>( aCanvasType );
Pgm().GetSettingsManager().Save( cfg );
return false; return false;
} }
@ -862,3 +802,9 @@ void EDA_DRAW_FRAME::RecreateToolbars()
// Update the checked state of tools // Update the checked state of tools
SyncToolbars(); SyncToolbars();
} }
COLOR4D EDA_DRAW_FRAME::GetLayerColor( SCH_LAYER_ID aLayer )
{
return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
}

View File

@ -24,6 +24,7 @@
#include <filehistory.h> #include <filehistory.h>
#include <id.h> #include <id.h>
#include <settings/app_settings.h>
#include <tool/action_menu.h> #include <tool/action_menu.h>
#include <tool/selection_conditions.h> #include <tool/selection_conditions.h>
#include <wx/menu.h> #include <wx/menu.h>
@ -39,6 +40,45 @@ FILE_HISTORY::FILE_HISTORY( size_t aMaxFiles, int aBaseFileId ) :
} }
void FILE_HISTORY::Load( const APP_SETTINGS_BASE& aSettings )
{
m_fileHistory.clear();
// file_history stores the most recent file first
for( auto it = aSettings.m_System.file_history.rbegin();
it != aSettings.m_System.file_history.rend(); ++it )
AddFileToHistory( *it );
}
void FILE_HISTORY::Load( const std::vector<wxString>& aList )
{
m_fileHistory.clear();
for( const auto& file : aList )
AddFileToHistory( file );
}
void FILE_HISTORY::Save( APP_SETTINGS_BASE& aSettings )
{
aSettings.m_System.file_history.clear();
for( const auto& file : m_fileHistory )
aSettings.m_System.file_history.insert( aSettings.m_System.file_history.begin(),
file.ToStdString() );
}
void FILE_HISTORY::Save( std::vector<wxString>* aList )
{
aList->clear();
for( const auto& file : m_fileHistory )
aList->push_back( file );
}
void FILE_HISTORY::SetMaxFiles( size_t aMaxFiles ) void FILE_HISTORY::SetMaxFiles( size_t aMaxFiles )
{ {
m_fileMaxFiles = std::min( aMaxFiles, (size_t) MAX_FILE_HISTORY_SIZE ); m_fileMaxFiles = std::min( aMaxFiles, (size_t) MAX_FILE_HISTORY_SIZE );

View File

@ -25,13 +25,13 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <footprint_info.h> #include <footprint_info.h>
#include <lib_id.h> #include <lib_id.h>
#include <lib_table_lexer.h> #include <lib_table_lexer.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <search_stack.h> #include <search_stack.h>
#include <settings/settings_manager.h>
#include <systemdirsappend.h> #include <systemdirsappend.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <class_module.h> #include <class_module.h>
@ -513,7 +513,7 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName()
{ {
wxFileName fn; wxFileName fn;
fn.SetPath( GetKicadConfigPath() ); fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
fn.SetName( global_tbl_name ); fn.SetName( global_tbl_name );
return fn.GetFullPath(); return fn.GetFullPath();

View File

@ -24,7 +24,7 @@
*/ */
#include <map> #include <map>
#include <nlohmann/json.hpp>
#include <gal/color4d.h> #include <gal/color4d.h>
using namespace KIGFX; using namespace KIGFX;
@ -146,6 +146,17 @@ std::ostream &operator<<( std::ostream &aStream, COLOR4D const &aColor )
return aStream << aColor.ToWxString( wxC2S_CSS_SYNTAX ); return aStream << aColor.ToWxString( wxC2S_CSS_SYNTAX );
} }
void to_json( nlohmann::json& aJson, const COLOR4D& aColor )
{
aJson = nlohmann::json( aColor.ToWxString( wxC2S_CSS_SYNTAX ).ToStdString() );
}
void from_json( const nlohmann::json& aJson, COLOR4D& aColor )
{
aColor.SetFromWxString( aJson.get<std::string>() );
}
} }

View File

@ -22,27 +22,16 @@
*/ */
#include <gal/gal_display_options.h> #include <gal/gal_display_options.h>
#include <settings/app_settings.h>
#include <settings/common_settings.h>
#include <wx/config.h>
#include <wx/log.h> #include <wx/log.h>
#include <config_map.h> #include <config_map.h>
#include <dpi_scaling.h> #include <dpi_scaling.h>
#include <pgm_base.h>
using namespace KIGFX; using namespace KIGFX;
/*
* Config option strings
*/
static const wxString GalGridStyleConfig( "GridStyle" );
static const wxString GalGridLineWidthConfig( "GridLineWidth" );
static const wxString GalGridMaxDensityConfig( "GridMaxDensity" );
static const wxString GalGridAxesEnabledConfig( "GridAxesEnabled" );
static const wxString GalFullscreenCursorConfig( "CursorFullscreen" );
static const wxString GalForceDisplayCursorConfig( "ForceDisplayCursor" );
static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleConfigVals = static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleConfigVals =
{ {
{ KIGFX::GRID_STYLE::DOTS, 0 }, { KIGFX::GRID_STYLE::DOTS, 0 },
@ -74,43 +63,34 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
{} {}
void GAL_DISPLAY_OPTIONS::ReadAppConfig( wxConfigBase& aCfg, const wxString& aBaseName ) void GAL_DISPLAY_OPTIONS::ReadWindowSettings( WINDOW_SETTINGS& aCfg )
{ {
const wxString baseName = aBaseName + GAL_DISPLAY_OPTIONS_KEY; wxLogTrace( traceGalDispOpts, "Reading app-specific options" );
wxLogTrace( traceGalDispOpts, "Reading options with base name '%s'", baseName ); m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, aCfg.grid.style );
m_gridLineWidth = aCfg.grid.line_width;
m_gridMinSpacing = aCfg.grid.min_spacing;
m_axesEnabled = aCfg.grid.axes_enabled;
long readLong; // Temp value buffer m_fullscreenCursor = aCfg.cursor.fullscreen_cursor;
m_forceDisplayCursor = aCfg.cursor.always_show_cursor;
aCfg.Read( baseName + GalGridStyleConfig, &readLong,
static_cast<long>( KIGFX::GRID_STYLE::DOTS ) );
m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, readLong );
aCfg.Read( baseName + GalGridLineWidthConfig, &m_gridLineWidth, 1.0 );
aCfg.Read( baseName + GalGridMaxDensityConfig, &m_gridMinSpacing, 10 );
aCfg.Read( baseName + GalGridAxesEnabledConfig, &m_axesEnabled, false );
aCfg.Read( baseName + GalFullscreenCursorConfig, &m_fullscreenCursor, false );
aCfg.Read( baseName + GalForceDisplayCursorConfig, &m_forceDisplayCursor, true );
NotifyChanged(); NotifyChanged();
} }
void GAL_DISPLAY_OPTIONS::ReadCommonConfig( wxConfigBase& aCommonConfig, wxWindow* aWindow ) void GAL_DISPLAY_OPTIONS::ReadCommonConfig( COMMON_SETTINGS& aSettings, wxWindow* aWindow )
{ {
wxLogTrace( traceGalDispOpts, "Reading common config" ); wxLogTrace( traceGalDispOpts, "Reading common config" );
int temp; gl_antialiasing_mode = static_cast<KIGFX::OPENGL_ANTIALIASING_MODE>(
aCommonConfig.Read( aSettings.m_Graphics.opengl_aa_mode );
GAL_ANTIALIASING_MODE_KEY, &temp, (int) KIGFX::OPENGL_ANTIALIASING_MODE::NONE );
gl_antialiasing_mode = (KIGFX::OPENGL_ANTIALIASING_MODE) temp;
aCommonConfig.Read( cairo_antialiasing_mode = static_cast<KIGFX::CAIRO_ANTIALIASING_MODE>(
CAIRO_ANTIALIASING_MODE_KEY, &temp, (int) KIGFX::CAIRO_ANTIALIASING_MODE::NONE ); aSettings.m_Graphics.cairo_aa_mode );
cairo_antialiasing_mode = (KIGFX::CAIRO_ANTIALIASING_MODE) temp;
{ {
const DPI_SCALING dpi{ &aCommonConfig, aWindow }; const DPI_SCALING dpi{ &aSettings, aWindow };
m_scaleFactor = dpi.GetScaleFactor(); m_scaleFactor = dpi.GetScaleFactor();
} }
@ -118,31 +98,27 @@ void GAL_DISPLAY_OPTIONS::ReadCommonConfig( wxConfigBase& aCommonConfig, wxWindo
} }
void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase& aCommonConfig, wxConfigBase& aAppConfig, void GAL_DISPLAY_OPTIONS::ReadConfig( COMMON_SETTINGS& aCommonConfig,
const wxString& aBaseCfgName, wxWindow* aWindow ) WINDOW_SETTINGS& aWindowConfig, wxWindow* aWindow )
{ {
wxLogTrace( traceGalDispOpts, "Reading common and app config (%s)", aBaseCfgName ); wxLogTrace( traceGalDispOpts, "Reading common and app config" );
ReadAppConfig( aAppConfig, aBaseCfgName ); ReadWindowSettings( aWindowConfig );
ReadCommonConfig( aCommonConfig, aWindow ); ReadCommonConfig( aCommonConfig, aWindow );
} }
void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase& aCfg, const wxString& aBaseName ) void GAL_DISPLAY_OPTIONS::WriteConfig( WINDOW_SETTINGS& aCfg )
{ {
const wxString baseName = aBaseName + GAL_DISPLAY_OPTIONS_KEY; wxLogTrace( traceGalDispOpts, "Writing window settings" );
wxLogTrace( traceGalDispOpts, "Writing app config (%s)", baseName ); aCfg.grid.style = UTIL::GetConfigForVal( gridStyleConfigVals, m_gridStyle );
aCfg.grid.line_width = m_gridLineWidth;
aCfg.Write( baseName + GalGridStyleConfig, aCfg.grid.min_spacing = m_gridMinSpacing;
UTIL::GetConfigForVal( gridStyleConfigVals, m_gridStyle ) ); aCfg.grid.axes_enabled = m_axesEnabled;
aCfg.cursor.fullscreen_cursor = m_fullscreenCursor;
aCfg.Write( baseName + GalGridLineWidthConfig, m_gridLineWidth ); aCfg.cursor.always_show_cursor = m_forceDisplayCursor;
aCfg.Write( baseName + GalGridMaxDensityConfig, m_gridMinSpacing );
aCfg.Write( baseName + GalGridAxesEnabledConfig, m_axesEnabled );
aCfg.Write( baseName + GalFullscreenCursorConfig, m_fullscreenCursor );
aCfg.Write( baseName + GalForceDisplayCursorConfig, m_forceDisplayCursor );
} }

View File

@ -34,6 +34,7 @@
#include <macros.h> #include <macros.h>
#include <menus_helpers.h> #include <menus_helpers.h>
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include "dialogs/dialog_hotkey_list.h" #include "dialogs/dialog_hotkey_list.h"
@ -314,7 +315,7 @@ void ReadHotKeyConfig( wxString fileName, std::map<std::string, int>& aHotKeys )
{ {
wxFileName fn( "user" ); wxFileName fn( "user" );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() ); fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
fileName = fn.GetFullPath(); fileName = fn.GetFullPath();
} }
@ -350,7 +351,7 @@ int WriteHotKeyConfig( const std::map<std::string, TOOL_ACTION*>& aActionMap )
wxFileName fn( "user" ); wxFileName fn( "user" );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() ); fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
// Read the existing config (all hotkeys) // Read the existing config (all hotkeys)
// //
@ -394,7 +395,7 @@ int ReadLegacyHotkeyConfigFile( const wxString& aFilename, std::map<std::string,
wxFileName fn( aFilename ); wxFileName fn( aFilename );
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT ); fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
fn.SetPath( GetKicadConfigPath() ); fn.SetPath( SETTINGS_MANAGER::GetUserSettingsPath() );
if( !wxFile::Exists( fn.GetFullPath() ) ) if( !wxFile::Exists( fn.GetFullPath() ) )
return 0; return 0;

View File

@ -24,7 +24,6 @@
*/ */
#include <macros.h> // FROM_UTF8() #include <macros.h> // FROM_UTF8()
#include <wx/config.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <kiface_i.h> #include <kiface_i.h>

View File

@ -29,12 +29,13 @@
#include <set> #include <set>
#include <fctsys.h>
#include <common.h> #include <common.h>
#include <macros.h> #include <fctsys.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <lib_table_lexer.h>
#include <lib_table_base.h> #include <lib_table_base.h>
#include <lib_table_lexer.h>
#include <macros.h>
#include <settings/app_settings.h>
#define OPT_SEP '|' ///< options separator character #define OPT_SEP '|' ///< options separator character

View File

@ -24,6 +24,7 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <config_params.h> #include <config_params.h>
#include <lib_tree_model_adapter.h> #include <lib_tree_model_adapter.h>
#include <settings/app_settings.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#include <wx/wupdlock.h> #include <wx/wupdlock.h>
@ -87,14 +88,8 @@ LIB_TREE_MODEL_ADAPTER::LIB_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent ) :
m_colWidths[PART_COL] = 360; m_colWidths[PART_COL] = 360;
m_colWidths[DESC_COL] = 2000; m_colWidths[DESC_COL] = 2000;
m_config = Kiface().KifaceSettings(); auto cfg = Kiface().KifaceSettings();
m_configPrefix = typeid( this ).name(); m_colWidths[PART_COL] = cfg->m_LibTree.column_width;
// Read the column width from the global config
int colWidth = 0;
if( m_config->Read( m_configPrefix + LIST_COLUMN_WIDTH_KEY, &colWidth ) )
m_colWidths[PART_COL] = colWidth;
// Read the pinned entries from the project config // Read the pinned entries from the project config
m_parent->Kiway().Prj().ConfigLoad( Kiface().KifaceSearch(), m_parent->GetName(), m_parent->Kiway().Prj().ConfigLoad( Kiface().KifaceSearch(), m_parent->GetName(),
@ -110,8 +105,8 @@ void LIB_TREE_MODEL_ADAPTER::SaveColWidths()
{ {
if( m_widget ) if( m_widget )
{ {
int colWidth = m_widget->GetColumn( PART_COL )->GetWidth(); auto cfg = Kiface().KifaceSettings();
m_config->Write( m_configPrefix + LIST_COLUMN_WIDTH_KEY, colWidth ); cfg->m_LibTree.column_width = m_widget->GetColumn( PART_COL )->GetWidth();
} }
else else
{ {

View File

@ -89,6 +89,7 @@
* - `HasDefaultCompare()` - whether sorted by default * - `HasDefaultCompare()` - whether sorted by default
*/ */
class APP_SETTINGS_BASE;
class TOOL_INTERACTIVE; class TOOL_INTERACTIVE;
class PARAM_CFG; class PARAM_CFG;
@ -359,8 +360,6 @@ private:
wxDataViewColumn* m_col_desc; wxDataViewColumn* m_col_desc;
wxDataViewCtrl* m_widget; wxDataViewCtrl* m_widget;
wxConfigBase* m_config;
wxString m_configPrefix;
std::vector<PARAM_CFG*> m_projectFileParams; std::vector<PARAM_CFG*> m_projectFileParams;
int m_colWidths[NUM_COLS]; int m_colWidths[NUM_COLS];

View File

@ -31,6 +31,7 @@
#include <eda_draw_frame.h> #include <eda_draw_frame.h>
#include <title_block.h> #include <title_block.h>
#include <build_version.h> #include <build_version.h>
#include <settings/color_settings.h>
#include <ws_draw_item.h> #include <ws_draw_item.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
@ -52,6 +53,18 @@ WS_RENDER_SETTINGS::WS_RENDER_SETTINGS()
} }
void WS_RENDER_SETTINGS::LoadColors( const COLOR_SETTINGS* aSettings )
{
for( int layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; layer ++)
m_layerColors[ layer ] = aSettings->GetColor( layer );
for( int layer = GAL_LAYER_ID_START; layer < GAL_LAYER_ID_END; layer ++)
m_layerColors[ layer ] = aSettings->GetColor( layer );
m_backgroundColor = aSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
}
const COLOR4D& WS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const const COLOR4D& WS_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) const
{ {
const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem ); const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );

View File

@ -41,7 +41,8 @@ WS_PROXY_VIEW_ITEM::WS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO
m_titleBlock( aTitleBlock ), m_titleBlock( aTitleBlock ),
m_pageInfo( aPageInfo ), m_pageInfo( aPageInfo ),
m_sheetNumber( 1 ), m_sheetNumber( 1 ),
m_sheetCount( 1 ) m_sheetCount( 1 ),
m_colorLayer( LAYER_WORKSHEET )
{ {
} }
@ -110,7 +111,7 @@ void WS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
WS_PAINTER ws_painter( gal ); WS_PAINTER ws_painter( gal );
WS_RENDER_SETTINGS* ws_settings =static_cast<WS_RENDER_SETTINGS*>( ws_painter.GetSettings() ); WS_RENDER_SETTINGS* ws_settings =static_cast<WS_RENDER_SETTINGS*>( ws_painter.GetSettings() );
ws_settings->SetNormalColor( settings->GetLayerColor( LAYER_WORKSHEET ) ); ws_settings->SetNormalColor( settings->GetLayerColor( m_colorLayer ) );
ws_settings->SetSelectedColor( settings->GetLayerColor( LAYER_SELECT_OVERLAY ) ); ws_settings->SetSelectedColor( settings->GetLayerColor( LAYER_SELECT_OVERLAY ) );
ws_settings->SetBrightenedColor( settings->GetLayerColor( LAYER_BRIGHTENED ) ); ws_settings->SetBrightenedColor( settings->GetLayerColor( LAYER_BRIGHTENED ) );

View File

@ -40,32 +40,26 @@
#include <wx/sysopt.h> #include <wx/sysopt.h>
#include <wx/richmsgdlg.h> #include <wx/richmsgdlg.h>
#include <pgm_base.h>
#include <eda_draw_frame.h>
#include <eda_base_frame.h>
#include <macros.h>
#include <config_params.h>
#include <id.h>
#include <build_version.h> #include <build_version.h>
#include <hotkeys_basic.h> #include <config_params.h>
#include <gestfich.h>
#include <menus_helpers.h>
#include <confirm.h> #include <confirm.h>
#include <dialog_configure_paths.h> #include <dialog_configure_paths.h>
#include <eda_base_frame.h>
#include <eda_draw_frame.h>
#include <gal/gal_display_options.h>
#include <gestfich.h>
#include <hotkeys_basic.h>
#include <id.h>
#include <lockfile.h> #include <lockfile.h>
#include <macros.h>
#include <menus_helpers.h>
#include <pgm_base.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <systemdirsappend.h> #include <systemdirsappend.h>
#include <trace_helpers.h> #include <trace_helpers.h>
#include <gal/gal_display_options.h>
#define KICAD_COMMON wxT( "kicad_common" )
// some key strings used to store parameters in KICAD_COMMON
const wxChar PGM_BASE::workingDirKey[] = wxT( "WorkingDir" ); // public
static const wxChar languageCfgKey[] = wxT( "LanguageID" );
static const wxChar pathEnvVariables[] = wxT( "EnvironmentVariables" );
static const wxChar showEnvVarWarningDialog[] = wxT( "ShowEnvVarWarningDialog" );
static const wxChar traceEnvVars[] = wxT( "KIENVVARS" ); static const wxChar traceEnvVars[] = wxT( "KIENVVARS" );
@ -133,8 +127,6 @@ PGM_BASE::~PGM_BASE()
void PGM_BASE::Destroy() void PGM_BASE::Destroy()
{ {
// unlike a normal destructor, this is designed to be called more than once safely: // unlike a normal destructor, this is designed to be called more than once safely:
m_common_settings.reset();
delete m_pgm_checker; delete m_pgm_checker;
m_pgm_checker = 0; m_pgm_checker = 0;
@ -153,8 +145,8 @@ wxApp& PGM_BASE::App()
void PGM_BASE::SetEditorName( const wxString& aFileName ) void PGM_BASE::SetEditorName( const wxString& aFileName )
{ {
m_editor_name = aFileName; m_editor_name = aFileName;
wxASSERT( m_common_settings ); wxASSERT( GetCommonSettings() );
m_common_settings->Write( "Editor", aFileName ); GetCommonSettings()->m_System.editor_name = aFileName;
} }
@ -222,8 +214,6 @@ bool PGM_BASE::InitPgm()
{ {
wxFileName pgm_name( App().argv[0] ); wxFileName pgm_name( App().argv[0] );
wxConfigBase::DontCreateOnDemand();
wxInitAllImageHandlers(); wxInitAllImageHandlers();
m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) + m_pgm_checker = new wxSingleInstanceChecker( pgm_name.GetName().Lower() + wxT( "-" ) +
@ -240,6 +230,12 @@ bool PGM_BASE::InitPgm()
return false; return false;
} }
m_settings_manager = std::unique_ptr<SETTINGS_MANAGER>( new SETTINGS_MANAGER );
// Something got in the way of settings load: can't continue
if( !m_settings_manager->IsOK() )
return false;
// Init KiCad environment // Init KiCad environment
// the environment variable KICAD (if exists) gives the kicad path: // the environment variable KICAD (if exists) gives the kicad path:
// something like set KICAD=d:\kicad // something like set KICAD=d:\kicad
@ -274,9 +270,6 @@ bool PGM_BASE::InitPgm()
SetLanguagePath(); SetLanguagePath();
// OS specific instantiation of wxConfigBase derivative:
m_common_settings = GetNewConfig( KICAD_COMMON );
wxString envVarName = wxT( "KIGITHUB" ); wxString envVarName = wxT( "KIGITHUB" );
ENV_VAR_ITEM envVarItem; ENV_VAR_ITEM envVarItem;
wxString envValue; wxString envValue;
@ -433,7 +426,7 @@ bool PGM_BASE::InitPgm()
envVarItem.SetValue( tmpFileName.GetPath() ); envVarItem.SetValue( tmpFileName.GetPath() );
m_local_env_vars[ envVarName ] = envVarItem; m_local_env_vars[ envVarName ] = envVarItem;
ReadPdfBrowserInfos(); // needs m_common_settings GetSettingsManager().Load( GetCommonSettings() );
// Init user language *before* calling loadCommonSettings, because // Init user language *before* calling loadCommonSettings, because
// env vars could be incorrectly initialized on Linux // env vars could be incorrectly initialized on Linux
@ -442,6 +435,8 @@ bool PGM_BASE::InitPgm()
loadCommonSettings(); loadCommonSettings();
ReadPdfBrowserInfos(); // needs GetCommonSettings()
#ifdef __WXMAC__ #ifdef __WXMAC__
// Always show filters on Open dialog to be able to choose plugin // Always show filters on Open dialog to be able to choose plugin
wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 ); wxSystemOptions::SetOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1 );
@ -495,138 +490,62 @@ bool PGM_BASE::setExecutablePath()
void PGM_BASE::loadCommonSettings() void PGM_BASE::loadCommonSettings()
{ {
wxASSERT( m_common_settings );
m_help_size.x = 500; m_help_size.x = 500;
m_help_size.y = 400; m_help_size.y = 400;
// This only effect the first time KiCad is run. The user's setting will be used for all m_show_env_var_dialog = GetCommonSettings()->m_Env.show_warning_dialog;
// subsequent runs. Menu icons are off by default on OSX and on for all other platforms. m_editor_name = GetCommonSettings()->m_System.editor_name;
#if defined( __WXMAC__ )
bool defaultUseIconsInMenus = false;
#else
bool defaultUseIconsInMenus = true;
#endif
m_common_settings->Read( showEnvVarWarningDialog, &m_show_env_var_dialog ); for( const auto& it : GetCommonSettings()->m_Env.vars )
if( !m_common_settings->HasEntry( USE_ICONS_IN_MENUS_KEY ) )
m_common_settings->Write( USE_ICONS_IN_MENUS_KEY, defaultUseIconsInMenus );
if( !m_common_settings->HasEntry( ICON_SCALE_KEY )
|| !m_common_settings->HasEntry( GAL_ANTIALIASING_MODE_KEY )
|| !m_common_settings->HasEntry( CAIRO_ANTIALIASING_MODE_KEY ) )
{ {
// 5.0 and earlier saved common settings in each app, and saved hardware antialiasing wxString key( it.first.c_str(), wxConvUTF8 );
// options only in pcbnew (which was the only canvas to support them). Since there's wxLogTrace( traceEnvVars, "Enumerating over entry %s = %s.", key, it.second );
// no single right answer to where to pull the common settings from, we might as well
// get them along with the hardware antialiasing option from pcbnew.
auto pcbnewConfig = GetNewConfig( wxString::FromUTF8( "pcbnew" ) );
wxString pcbFrameKey( PCB_EDIT_FRAME_NAME );
if( !m_common_settings->HasEntry( ICON_SCALE_KEY ) )
{
int temp;
wxString msg;
bool option;
pcbnewConfig->Read( "PcbIconScale", &temp, 0 );
m_common_settings->Write( ICON_SCALE_KEY, temp );
pcbnewConfig->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
m_common_settings->Write( ENBL_MOUSEWHEEL_PAN_KEY, option );
pcbnewConfig->Read( ENBL_ZOOM_NO_CENTER_KEY, &option, false );
m_common_settings->Write( ENBL_ZOOM_NO_CENTER_KEY, option );
pcbnewConfig->Read( ENBL_AUTO_PAN_KEY, &option, true );
m_common_settings->Write( ENBL_AUTO_PAN_KEY, option );
}
if( !m_common_settings->HasEntry( GAL_ANTIALIASING_MODE_KEY ) )
{
int temp;
pcbnewConfig->Read( pcbFrameKey + GAL_DISPLAY_OPTIONS_KEY + GAL_ANTIALIASING_MODE_KEY,
&temp, (int) KIGFX::OPENGL_ANTIALIASING_MODE::NONE );
m_common_settings->Write( GAL_ANTIALIASING_MODE_KEY, temp );
}
if( !m_common_settings->HasEntry( CAIRO_ANTIALIASING_MODE_KEY ) )
{
int temp;
pcbnewConfig->Read( pcbFrameKey + GAL_DISPLAY_OPTIONS_KEY + CAIRO_ANTIALIASING_MODE_KEY,
&temp, (int) KIGFX::CAIRO_ANTIALIASING_MODE::NONE );
m_common_settings->Write( CAIRO_ANTIALIASING_MODE_KEY, temp );
}
}
m_editor_name = m_common_settings->Read( "Editor" );
wxString entry, oldPath;
wxArrayString entries;
long index = 0L;
oldPath = m_common_settings->GetPath();
m_common_settings->SetPath( pathEnvVariables );
while( m_common_settings->GetNextEntry( entry, index ) )
{
wxLogTrace( traceEnvVars,
"Enumerating over entry %s, %ld.", GetChars( entry ), index );
// Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason
// it is found in config. (It is reserved and defined as project path) // it is found in config. (It is reserved and defined as project path)
if( entry == PROJECT_VAR_NAME ) if( key == PROJECT_VAR_NAME )
continue; continue;
entries.Add( entry ); if( m_local_env_vars[ key ].GetDefinedExternally() )
}
for( unsigned i = 0; i < entries.GetCount(); i++ )
{
wxString val = m_common_settings->Read( entries[i], wxEmptyString );
if( m_local_env_vars[ entries[i] ].GetDefinedExternally() )
continue; continue;
m_local_env_vars[ entries[i] ] = ENV_VAR_ITEM( val, wxGetEnv( entries[i], NULL ) ); m_local_env_vars[ key ] = ENV_VAR_ITEM( it.second, wxGetEnv( it.first, nullptr ) );
} }
for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it ) for( auto& m_local_env_var : m_local_env_vars )
{ SetLocalEnvVariable( m_local_env_var.first, m_local_env_var.second.GetValue() );
SetLocalEnvVariable( it->first, it->second.GetValue() );
}
m_common_settings->SetPath( oldPath );
} }
void PGM_BASE::SaveCommonSettings() void PGM_BASE::SaveCommonSettings()
{ {
// m_common_settings is not initialized until fairly late in the // GetCommonSettings() is not initialized until fairly late in the
// process startup: InitPgm(), so test before using: // process startup: InitPgm(), so test before using:
if( m_common_settings ) if( GetCommonSettings() )
{ {
wxString cur_dir = wxGetCwd(); GetCommonSettings()->m_System.working_dir = wxGetCwd().ToStdString();
GetCommonSettings()->m_Env.show_warning_dialog = m_show_env_var_dialog;
m_common_settings->Write( workingDirKey, cur_dir );
m_common_settings->Write( showEnvVarWarningDialog, m_show_env_var_dialog );
// Save the local environment variables. // Save the local environment variables.
m_common_settings->SetPath( pathEnvVariables ); for( auto& m_local_env_var : m_local_env_vars )
for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it )
{ {
if( it->second.GetDefinedExternally() ) if( m_local_env_var.second.GetDefinedExternally() )
continue; continue;
wxLogTrace( traceEnvVars, "Saving environment variable config entry %s as %s", wxLogTrace( traceEnvVars, "Saving environment variable config entry %s as %s",
GetChars( it->first ), GetChars( it->second.GetValue() ) ); GetChars( m_local_env_var.first ),
m_common_settings->Write( it->first, it->second.GetValue() ); GetChars( m_local_env_var.second.GetValue() ) );
}
m_common_settings->SetPath( ".." ); std::string key( m_local_env_var.first.ToUTF8() );
GetCommonSettings()->m_Env.vars[ key ] = m_local_env_var.second.GetValue();
} }
}
}
COMMON_SETTINGS* PGM_BASE::GetCommonSettings() const
{
return GetSettingsManager().GetCommonSettings();
} }
@ -638,10 +557,8 @@ bool PGM_BASE::SetLanguage( bool first_time )
{ {
setLanguageId( wxLANGUAGE_DEFAULT ); setLanguageId( wxLANGUAGE_DEFAULT );
// First time SetLanguage is called, the user selected language id is set // First time SetLanguage is called, the user selected language id is set
// from commun user config settings // from common user config settings
wxString languageSel; wxString languageSel = GetCommonSettings()->m_System.language;
m_common_settings->Read( languageCfgKey, &languageSel );
// Search for the current selection // Search for the current selection
for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ ) for( unsigned ii = 0; LanguagesList[ii].m_KI_Lang_Identifier != 0; ii++ )
@ -695,7 +612,7 @@ bool PGM_BASE::SetLanguage( bool first_time )
} }
} }
m_common_settings->Write( languageCfgKey, languageSel ); GetCommonSettings()->m_System.language = languageSel;
} }
// Test if floating point notation is working (bug encountered in cross compilation) // Test if floating point notation is working (bug encountered in cross compilation)
@ -797,17 +714,15 @@ void PGM_BASE::SetLocalEnvVariables( const ENV_VAR_MAP& aEnvVarMap )
m_local_env_vars.clear(); m_local_env_vars.clear();
m_local_env_vars = aEnvVarMap; m_local_env_vars = aEnvVarMap;
if( m_common_settings )
m_common_settings->DeleteGroup( pathEnvVariables );
SaveCommonSettings(); SaveCommonSettings();
// Overwrites externally defined environment variable until the next time the application // Overwrites externally defined environment variable until the next time the application
// is run. // is run.
for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it ) for( auto& m_local_env_var : m_local_env_vars )
{ {
wxLogTrace( traceEnvVars, "Setting local environment variable %s to %s.", wxLogTrace( traceEnvVars, "Setting local environment variable %s to %s.",
GetChars( it->first ), GetChars( it->second.GetValue() ) ); GetChars( m_local_env_var.first ),
wxSetEnv( it->first, it->second.GetValue() ); GetChars( m_local_env_var.second.GetValue() ) );
wxSetEnv( m_local_env_var.first, m_local_env_var.second.GetValue() );
} }
} }

View File

@ -16,21 +16,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <printout.h>
#include <pcbplot.h> #include <pcbplot.h>
#include <wx/config.h> #include <printout.h>
#include <settings/app_settings.h>
void PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig )
void PRINTOUT_SETTINGS::Save( APP_SETTINGS_BASE* aConfig )
{ {
aConfig->Write( OPTKEY_PRINT_SCALE, m_scale ); aConfig->m_Printing.monochrome = m_blackWhite;
aConfig->Write( OPTKEY_PRINT_PAGE_FRAME, m_titleBlock ); aConfig->m_Printing.title_block = m_titleBlock;
aConfig->Write( OPTKEY_PRINT_MONOCHROME_MODE, m_blackWhite ); aConfig->m_Printing.scale = m_scale;
} }
void PRINTOUT_SETTINGS::Load( wxConfigBase* aConfig ) void PRINTOUT_SETTINGS::Load( APP_SETTINGS_BASE* aConfig )
{ {
aConfig->Read( OPTKEY_PRINT_SCALE, &m_scale, 1.0 ); m_blackWhite = aConfig->m_Printing.monochrome;
aConfig->Read( OPTKEY_PRINT_PAGE_FRAME, &m_titleBlock, false ); m_titleBlock = aConfig->m_Printing.title_block;
aConfig->Read( OPTKEY_PRINT_MONOCHROME_MODE, &m_blackWhite, 1 ); m_scale = aConfig->m_Printing.scale;
} }

View File

@ -0,0 +1,254 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <class_draw_panel_gal.h>
#include <common.h>
#include <layers_id_colors_and_visibility.h>
#include <pgm_base.h>
#include <settings/app_settings.h>
#include <settings/common_settings.h>
#include <settings/parameters.h>
///! Update the schema version whenever a migration is required
const int appSettingsSchemaVersion = 0;
APP_SETTINGS_BASE::APP_SETTINGS_BASE( std::string aFilename, int aSchemaVersion ) :
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::USER, appSettingsSchemaVersion ),
m_Printing(), m_System(), m_Window(), m_appSettingsSchemaVersion( aSchemaVersion )
{
m_params.emplace_back( new PARAM<int>( "find_replace.flags", &m_FindReplace.flags, 1 ) );
m_params.emplace_back( new PARAM<wxString>( "find_replace.find_string",
&m_FindReplace.find_string, "" ) );
m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.find_history",
&m_FindReplace.find_history, {} ) );
m_params.emplace_back( new PARAM<wxString>( "find_replace.replace_string",
&m_FindReplace.replace_string, "" ) );
m_params.emplace_back( new PARAM_LIST<wxString>( "find_replace.replace_history",
&m_FindReplace.replace_history, {} ) );
#ifdef __WXMAC__
// Cairo renderer doesn't handle Retina displays so default to OpenGL
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type", &m_Graphics.canvas_type,
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
#else
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type", &m_Graphics.canvas_type,
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
#endif
m_params.emplace_back(
new PARAM<int>( "lib_tree.column_width", &m_LibTree.column_width, 360 ) );
m_params.emplace_back( new PARAM<bool>( "printing.monochrome", &m_Printing.monochrome, true ) );
m_params.emplace_back( new PARAM<double>( "printing.scale", &m_Printing.scale, 1.0 ) );
m_params.emplace_back( new PARAM<bool>( "printing.title_block",
&m_Printing.title_block, false ) );
m_params.emplace_back( new PARAM_LIST<int>( "printing.layers", &m_Printing.layers, {} ) );
m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
&m_System.first_run_shown, false ) );
m_params.emplace_back( new PARAM<int>( "system.max_undo_items", &m_System.max_undo_items, 0 ) );
m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history",
&m_System.file_history, {} ) );
m_params.emplace_back( new PARAM<int>( "system.units", &m_System.units,
static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
addParamsForWindow( &m_Window, "window" );
}
bool APP_SETTINGS_BASE::MigrateFromLegacy( wxConfigBase* aCfg )
{
bool ret = true;
const std::string f = getLegacyFrameName();
ret &= fromLegacyString( aCfg, "LastFindString", "find_replace.find_string" );
ret &= fromLegacyString( aCfg, "LastReplaceString", "find_replace.replace_string" );
migrateFindReplace( aCfg );
ret &= fromLegacy<int>( aCfg, "canvas_type", "graphics.canvas_type" );
ret &= fromLegacy<int>( aCfg, "P22LIB_TREE_MODEL_ADAPTERSelectorColumnWidth",
"lib_tree.column_width" );
ret &= fromLegacy<bool>( aCfg, "PrintMonochrome", "printing.monochrome" );
ret &= fromLegacy<double>( aCfg, "PrintScale", "printing.scale" );
ret &= fromLegacy<bool>( aCfg, "PrintPageFrame", "printing.title_block" );
{
nlohmann::json js = nlohmann::json::array();
wxString key;
bool val = false;
for( unsigned i = 0; i < PCB_LAYER_ID_COUNT; ++i )
{
key.Printf( wxT( "PlotLayer_%d" ), i );
if( aCfg->Read( key, &val ) && val )
js.push_back( i );
}
( *this )[PointerFromString( "printing.layers" ) ] = js;
}
ret &= fromLegacy<bool>( aCfg, f + "FirstRunShown", "system.first_run_shown" );
ret &= fromLegacy<int>( aCfg, f + "DevelMaxUndoItems", "system.max_undo_items" );
ret &= fromLegacy<int>( aCfg, f + "Units", "system.units" );
{
int max_history_size = Pgm().GetCommonSettings()->m_System.file_history_size;
wxString file, key;
nlohmann::json js = nlohmann::json::array();
for( int i = 1; i <= max_history_size; i++ )
{
key.Printf( "file%d", i );
file = aCfg->Read( key, wxEmptyString );
if( !file.IsEmpty() )
js.push_back( file.ToStdString() );
}
( *this )[PointerFromString( "system.file_history" )] = js;
}
ret &= migrateWindowConfig( aCfg, f, "window" );
return ret;
}
void APP_SETTINGS_BASE::migrateFindReplace( wxConfigBase* aCfg )
{
const int find_replace_history_size = 10;
nlohmann::json find_history = nlohmann::json::array();
nlohmann::json replace_history = nlohmann::json::array();
wxString tmp, find_key, replace_key;
for( int i = 0; i < find_replace_history_size; ++i )
{
find_key.Printf( "FindStringHistoryList%d", i );
replace_key.Printf( "ReplaceStringHistoryList%d", i );
if( aCfg->Read( find_key, &tmp ) )
find_history.push_back( tmp.ToStdString() );
if( aCfg->Read( replace_key, &tmp ) )
replace_history.push_back( tmp.ToStdString() );
}
( *this )[PointerFromString( "find_replace.find_history" )] = find_history;
( *this )[PointerFromString( "find_replace.replace_history" )] = replace_history;
}
bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::string& aFrame,
const std::string& aJsonPath )
{
bool ret = true;
const std::string gd = "GalDisplayOptions";
ret &= fromLegacy<bool>( aCfg, aFrame + "Maximized", aJsonPath + ".maximized" );
ret &= fromLegacyString( aCfg, aFrame + "MostRecentlyUsedPath", aJsonPath + ".mru_path" );
ret &= fromLegacy<int>( aCfg, aFrame + "Size_x", aJsonPath + ".size_x" );
ret &= fromLegacy<int>( aCfg, aFrame + "Size_y", aJsonPath + ".size_y" );
ret &= fromLegacyString( aCfg, aFrame + "Perspective", aJsonPath + ".perspective" );
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_x", aJsonPath + ".pos_x" );
ret &= fromLegacy<int>( aCfg, aFrame + "Pos_y", aJsonPath + ".pos_y" );
ret &= fromLegacy<bool>( aCfg,
aFrame + gd + "ForceDisplayCursor", aJsonPath + ".cursor.always_show_cursor" );
ret &= fromLegacy<bool>( aCfg,
aFrame + gd + "CursorFullscreen", aJsonPath + ".cursor.fullscreen_cursor" );
ret &= fromLegacy<int>( aCfg,
aFrame + "_LastGridSize", aJsonPath + ".grid.last_size" );
ret &= fromLegacy<bool>( aCfg,
aFrame + gd + "GridAxesEnabled", aJsonPath + ".grid.axes_enabled" );
ret &= fromLegacy<double>( aCfg,
aFrame + gd + "GridLineWidth", aJsonPath + ".grid.line_width" );
ret &= fromLegacy<double>( aCfg,
aFrame + gd + "GridMaxDensity", aJsonPath + ".grid.min_spacing" );
ret &= fromLegacy<bool>( aCfg, aFrame + gd + "ShowGrid", aJsonPath + ".grid.show" );
ret &= fromLegacy<int>( aCfg, aFrame + gd + "GridStyle", aJsonPath + ".grid.style" );
ret &= fromLegacyColor( aCfg, aFrame + gd + "GridColor", aJsonPath + ".grid.color" );
ret &= fromLegacy<bool>( aCfg, aFrame + "AutoZoom", aJsonPath + ".auto_zoom" );
ret &= fromLegacy<double>( aCfg, aFrame + "Zoom", aJsonPath + ".zoom" );
return ret;
}
void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath )
{
m_params.emplace_back(
new PARAM<bool>( aJsonPath + ".maximized", &aWindow->maximized, false ) );
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path", &aWindow->mru_path, "" ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->size_x, 0 ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->size_y, 0 ) );
m_params.emplace_back(
new PARAM<wxString>( aJsonPath + ".perspective", &aWindow->perspective, "" ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->pos_x, 0 ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_y", &aWindow->pos_y, 0 ) );
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
&aWindow->grid.axes_enabled, false ) );
m_params.emplace_back(
new PARAM<int>( aJsonPath + ".grid.last_size", &aWindow->grid.last_size, 0 ) );
m_params.emplace_back(
new PARAM<double>( aJsonPath + ".grid.line_width", &aWindow->grid.line_width, 1.0 ) );
m_params.emplace_back(
new PARAM<double>( aJsonPath + ".grid.min_spacing", &aWindow->grid.min_spacing, 10 ) );
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show", &aWindow->grid.show, true ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style", &aWindow->grid.style, 0 ) );
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
&aWindow->cursor.always_show_cursor, true ) );
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.fullscreen_cursor",
&aWindow->cursor.fullscreen_cursor, false ) );
}

View File

@ -0,0 +1,345 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <layers_id_colors_and_visibility.h>
#include <settings/color_settings.h>
#include <settings/parameters.h>
///! Update the schema version whenever a migration is required
const int colorsSchemaVersion = 0;
COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::COLORS, colorsSchemaVersion ),
m_Palette(), m_colors(), m_color_context( COLOR_CONTEXT::PCB )
{
m_params.emplace_back( new PARAM<wxString>( "meta.name", &m_displayName, "KiCad Default" ) );
std::vector<COLOR4D> default_palette = {
COLOR4D( RED ),
COLOR4D( YELLOW ),
COLOR4D( LIGHTMAGENTA ),
COLOR4D( LIGHTRED ),
COLOR4D( CYAN ),
COLOR4D( GREEN ),
COLOR4D( BLUE ),
COLOR4D( DARKGRAY ),
COLOR4D( MAGENTA ),
COLOR4D( LIGHTGRAY ),
COLOR4D( MAGENTA ),
COLOR4D( RED ),
COLOR4D( BROWN ),
COLOR4D( LIGHTGRAY ),
COLOR4D( BLUE ),
COLOR4D( GREEN )
};
// TODO(JE) in actual usage, how long does the default palette need to be?
m_params.emplace_back( new PARAM_LIST<COLOR4D>( "palette", &m_Palette, default_palette ) );
#define CLR( x, y, z ) m_params.emplace_back( new COLOR_MAP_PARAM( x, y, z, &m_colors ) );
CLR( "schematic.background", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) );
CLR( "schematic.brightened", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) );
CLR( "schematic.bus", LAYER_BUS, COLOR4D( BLUE ) );
CLR( "schematic.component_body", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) );
CLR( "schematic.component_outline", LAYER_DEVICE, COLOR4D( RED ) );
CLR( "schematic.cursor", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) );
CLR( "schematic.erc_error", LAYER_ERC_ERR, COLOR4D( RED ).WithAlpha( 0.8 ) );
CLR( "schematic.erc_warning", LAYER_ERC_WARN, COLOR4D( GREEN ).WithAlpha( 0.8 ) );
CLR( "schematic.fields", LAYER_FIELDS, COLOR4D( MAGENTA ) );
CLR( "schematic.grid", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) );
CLR( "schematic.hidden", LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) );
CLR( "schematic.junction", LAYER_JUNCTION, COLOR4D( GREEN ) );
CLR( "schematic.label_global", LAYER_GLOBLABEL, COLOR4D( RED ) );
CLR( "schematic.label_hier", LAYER_HIERLABEL, COLOR4D( BROWN ) );
CLR( "schematic.label_local", LAYER_LOCLABEL, COLOR4D( BLACK ) );
CLR( "schematic.net_name", LAYER_NETNAM, COLOR4D( DARKGRAY ) );
CLR( "schematic.no_connect", LAYER_NOCONNECT, COLOR4D( BLUE ) );
CLR( "schematic.note", LAYER_NOTES, COLOR4D( LIGHTBLUE ) );
CLR( "schematic.pin", LAYER_PIN, COLOR4D( RED ) );
CLR( "schematic.pin_name", LAYER_PINNAM, COLOR4D( CYAN ) );
CLR( "schematic.pin_number", LAYER_PINNUM, COLOR4D( RED ) );
CLR( "schematic.reference", LAYER_REFERENCEPART, COLOR4D( CYAN ) );
// Macs look better with a lighter shadow
#ifdef __WXMAC__
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS, COLOR4D( .78, .92, 1.0, 0.8 ) );
#else
CLR( "schematic.shadow", LAYER_SELECTION_SHADOWS, COLOR4D( .4, .7, 1.0, 0.8 ) );
#endif
CLR( "schematic.sheet", LAYER_SHEET, COLOR4D( MAGENTA ) );
CLR( "schematic.sheet_filename", LAYER_SHEETFILENAME, COLOR4D( BROWN ) );
CLR( "schematic.sheet_label", LAYER_SHEETLABEL, COLOR4D( CYAN ) );
CLR( "schematic.sheet_name", LAYER_SHEETNAME, COLOR4D( CYAN ) );
CLR( "schematic.value", LAYER_VALUEPART, COLOR4D( CYAN ) );
CLR( "schematic.wire", LAYER_WIRE, COLOR4D( GREEN ) );
CLR( "schematic.worksheet", LAYER_SCHEMATIC_WORKSHEET, COLOR4D( BLACK ) );
CLR( "gerbview.axes", LAYER_GERBVIEW_AXES, COLOR4D( BLUE ) );
CLR( "gerbview.background", LAYER_GERBVIEW_BACKGROUND, COLOR4D( BLACK ) );
CLR( "gerbview.dcodes", LAYER_DCODES, COLOR4D( WHITE ) );
CLR( "gerbview.grid", LAYER_GERBVIEW_GRID, COLOR4D( MAGENTA ) );
CLR( "gerbview.negative_objects", LAYER_NEGATIVE_OBJECTS, COLOR4D( DARKGRAY ) );
CLR( "gerbview.worksheet", LAYER_GERBVIEW_WORKSHEET, COLOR4D( BLUE ) );
// TODO(JE) New default scheme for GerbView
for( int i = 0, id = GERBVIEW_LAYER_ID_START;
id < GERBER_DRAWLAYERS_COUNT + GERBVIEW_LAYER_ID_START; ++i, ++id )
{
CLR( "gerbview.layers." + std::to_string( i ), id,
default_palette[ i % default_palette.size() ] );
}
CLR( "board.anchor", LAYER_ANCHOR, COLOR4D( BLUE ) );
CLR( "board.aux_items", LAYER_AUX_ITEMS, COLOR4D( WHITE ) );
CLR( "board.background", LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) );
CLR( "board.cursor", LAYER_CURSOR, COLOR4D( WHITE ) );
CLR( "board.drc", LAYER_DRC, COLOR4D( LIGHTGRAY ) );
CLR( "board.footprint_text_back", LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) );
CLR( "board.footprint_text_front", LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) );
CLR( "board.footprint_text_invisible", LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) );
CLR( "board.grid", LAYER_GRID, COLOR4D( DARKGRAY ) );
CLR( "board.grid_axes", LAYER_GRID_AXES, COLOR4D( LIGHTGRAY ) );
CLR( "board.microvia", LAYER_VIA_MICROVIA, COLOR4D( LIGHTGRAY ) );
CLR( "board.no_connect", LAYER_NO_CONNECTS, COLOR4D( BLUE ) );
CLR( "board.pad_back", LAYER_PAD_BK, COLOR4D( GREEN ) );
CLR( "board.pad_front", LAYER_PAD_FR, COLOR4D( RED ) );
CLR( "board.pad_plated_hole", LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) );
CLR( "board.pad_through_hole", LAYER_PADS_TH, COLOR4D( YELLOW ) );
CLR( "board.plated_hole", LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) );
CLR( "board.ratsnest", LAYER_RATSNEST, COLOR4D( WHITE ) );
CLR( "board.select_overlay", LAYER_SELECT_OVERLAY, COLOR4D( DARKRED ) );
CLR( "board.through_via", LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
CLR( "board.via", LAYER_VIAS, COLOR4D( BLACK ) );
CLR( "board.via_blind_buried", LAYER_VIA_BBLIND, COLOR4D( BROWN ) );
CLR( "board.via_hole", LAYER_VIAS_HOLES, COLOR4D( WHITE ) );
CLR( "board.via_micro", LAYER_VIA_MICROVIA, COLOR4D( CYAN ) );
CLR( "board.via_through", LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
CLR( "board.worksheet", LAYER_WORKSHEET, COLOR4D( DARKRED ) );
CLR( "board.copper.f", F_Cu, COLOR4D( RED ) );
CLR( "board.copper.in1", In1_Cu, COLOR4D( YELLOW ) );
CLR( "board.copper.in2", In2_Cu, COLOR4D( LIGHTMAGENTA ) );
CLR( "board.copper.in3", In3_Cu, COLOR4D( LIGHTRED ) );
CLR( "board.copper.in4", In4_Cu, COLOR4D( CYAN ) );
CLR( "board.copper.in5", In5_Cu, COLOR4D( GREEN ) );
CLR( "board.copper.in6", In6_Cu, COLOR4D( BLUE ) );
CLR( "board.copper.in7", In7_Cu, COLOR4D( DARKGRAY ) );
CLR( "board.copper.in8", In8_Cu, COLOR4D( MAGENTA ) );
CLR( "board.copper.in9", In9_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "board.copper.in10", In10_Cu, COLOR4D( MAGENTA ) );
CLR( "board.copper.in11", In11_Cu, COLOR4D( RED ) );
CLR( "board.copper.in12", In12_Cu, COLOR4D( BROWN ) );
CLR( "board.copper.in13", In13_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "board.copper.in14", In14_Cu, COLOR4D( BLUE ) );
CLR( "board.copper.in15", In15_Cu, COLOR4D( GREEN ) );
CLR( "board.copper.in16", In16_Cu, COLOR4D( RED ) );
CLR( "board.copper.in17", In17_Cu, COLOR4D( YELLOW ) );
CLR( "board.copper.in18", In18_Cu, COLOR4D( LIGHTMAGENTA ) );
CLR( "board.copper.in19", In19_Cu, COLOR4D( LIGHTRED ) );
CLR( "board.copper.in20", In20_Cu, COLOR4D( CYAN ) );
CLR( "board.copper.in21", In21_Cu, COLOR4D( GREEN ) );
CLR( "board.copper.in22", In22_Cu, COLOR4D( BLUE ) );
CLR( "board.copper.in23", In23_Cu, COLOR4D( DARKGRAY ) );
CLR( "board.copper.in24", In24_Cu, COLOR4D( MAGENTA ) );
CLR( "board.copper.in25", In25_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "board.copper.in26", In26_Cu, COLOR4D( MAGENTA ) );
CLR( "board.copper.in27", In27_Cu, COLOR4D( RED ) );
CLR( "board.copper.in28", In28_Cu, COLOR4D( BROWN ) );
CLR( "board.copper.in29", In29_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "board.copper.in30", In30_Cu, COLOR4D( BLUE ) );
CLR( "board.copper.b", B_Cu, COLOR4D( GREEN ) );
CLR( "board.b_adhes", B_Adhes, COLOR4D( BLUE ) );
CLR( "board.f_adhes", F_Adhes, COLOR4D( MAGENTA ) );
CLR( "board.b_paste", B_Paste, COLOR4D( LIGHTCYAN ) );
CLR( "board.f_paste", F_Paste, COLOR4D( RED ) );
CLR( "board.b_silks", B_SilkS, COLOR4D( MAGENTA ) );
CLR( "board.f_silks", F_SilkS, COLOR4D( CYAN ) );
CLR( "board.b_mask", B_Mask, COLOR4D( BROWN ) );
CLR( "board.f_mask", F_Mask, COLOR4D( MAGENTA ) );
CLR( "board.dwgs_user", Dwgs_User, COLOR4D( LIGHTGRAY ) );
CLR( "board.cmts_user", Cmts_User, COLOR4D( BLUE ) );
CLR( "board.eco1_user", Eco1_User, COLOR4D( GREEN ) );
CLR( "board.eco2_user", Eco2_User, COLOR4D( YELLOW ) );
CLR( "board.edge_cuts", Edge_Cuts, COLOR4D( YELLOW ) );
CLR( "board.margin", Margin, COLOR4D( LIGHTMAGENTA ) );
CLR( "board.b_crtyd", B_CrtYd, COLOR4D( DARKGRAY ) );
CLR( "board.f_crtyd", F_CrtYd, COLOR4D( LIGHTGRAY ) );
CLR( "board.b_fab", B_Fab, COLOR4D( BLUE ) );
CLR( "board.f_fab", F_Fab, COLOR4D( DARKGRAY ) );
// TODO(JE) Storing fpedit colors here is a temporary hack to preserve user settings.
// Ultimately, if a user wants to have different colors for pcbnew and the footprint editor,
// they should simply choose a different named color theme for each.
// While we only have a single color theme, we need to store two mappings of all the
// pcb-related colors, one for pcbnew and one for footprint editor.
// Once color themes are supported, we should bump the schema version of COLOR_SETTINGS
// and in the migration split out the "User" theme to "User.FpEdit" or something, then set
// the User.FpEdit scheme as active for the footprint editor.
#define FL FPEDIT_LAYER_ID_START
CLR( "fpedit.anchor", FL + LAYER_ANCHOR, COLOR4D( BLUE ) );
CLR( "fpedit.aux_items", FL + LAYER_AUX_ITEMS, COLOR4D( WHITE ) );
CLR( "fpedit.background", FL + LAYER_PCB_BACKGROUND, COLOR4D( BLACK ) );
CLR( "fpedit.cursor", FL + LAYER_CURSOR, COLOR4D( WHITE ) );
CLR( "fpedit.drc", FL + LAYER_DRC, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.footprint_text_back", FL + LAYER_MOD_TEXT_BK, COLOR4D( BLUE ) );
CLR( "fpedit.footprint_text_front", FL + LAYER_MOD_TEXT_FR, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.footprint_text_invisible", FL + LAYER_MOD_TEXT_INVISIBLE, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.grid", FL + LAYER_GRID, COLOR4D( DARKGRAY ) );
CLR( "fpedit.grid_axes", FL + LAYER_GRID_AXES, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.microvia", FL + LAYER_VIA_MICROVIA, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.no_connect", FL + LAYER_NO_CONNECTS, COLOR4D( BLUE ) );
CLR( "fpedit.pad_back", FL + LAYER_PAD_BK, COLOR4D( GREEN ) );
CLR( "fpedit.pad_front", FL + LAYER_PAD_FR, COLOR4D( RED ) );
CLR( "fpedit.pad_plated_hole", FL + LAYER_PADS_PLATEDHOLES, COLOR4D( YELLOW ) );
CLR( "fpedit.pad_through_hole", FL + LAYER_PADS_TH, COLOR4D( YELLOW ) );
CLR( "fpedit.plated_hole", FL + LAYER_NON_PLATEDHOLES, COLOR4D( YELLOW ) );
CLR( "fpedit.ratsnest", FL + LAYER_RATSNEST, COLOR4D( WHITE ) );
CLR( "fpedit.select_overlay", FL + LAYER_SELECT_OVERLAY, COLOR4D( DARKRED ) );
CLR( "fpedit.through_via", FL + LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.via", FL + LAYER_VIAS, COLOR4D( BLACK ) );
CLR( "fpedit.via_blind_buried", FL + LAYER_VIA_BBLIND, COLOR4D( BROWN ) );
CLR( "fpedit.via_hole", FL + LAYER_VIAS_HOLES, COLOR4D( WHITE ) );
CLR( "fpedit.via_micro", FL + LAYER_VIA_MICROVIA, COLOR4D( CYAN ) );
CLR( "fpedit.via_through", FL + LAYER_VIA_THROUGH, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.worksheet", FL + LAYER_WORKSHEET, COLOR4D( DARKRED ) );
CLR( "fpedit.copper.f", FL + F_Cu, COLOR4D( RED ) );
CLR( "fpedit.copper.in1", FL + In1_Cu, COLOR4D( YELLOW ) );
CLR( "fpedit.copper.in2", FL + In2_Cu, COLOR4D( LIGHTMAGENTA ) );
CLR( "fpedit.copper.in3", FL + In3_Cu, COLOR4D( LIGHTRED ) );
CLR( "fpedit.copper.in4", FL + In4_Cu, COLOR4D( CYAN ) );
CLR( "fpedit.copper.in5", FL + In5_Cu, COLOR4D( GREEN ) );
CLR( "fpedit.copper.in6", FL + In6_Cu, COLOR4D( BLUE ) );
CLR( "fpedit.copper.in7", FL + In7_Cu, COLOR4D( DARKGRAY ) );
CLR( "fpedit.copper.in8", FL + In8_Cu, COLOR4D( MAGENTA ) );
CLR( "fpedit.copper.in9", FL + In9_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.copper.in10", FL + In10_Cu, COLOR4D( MAGENTA ) );
CLR( "fpedit.copper.in11", FL + In11_Cu, COLOR4D( RED ) );
CLR( "fpedit.copper.in12", FL + In12_Cu, COLOR4D( BROWN ) );
CLR( "fpedit.copper.in13", FL + In13_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.copper.in14", FL + In14_Cu, COLOR4D( BLUE ) );
CLR( "fpedit.copper.in15", FL + In15_Cu, COLOR4D( GREEN ) );
CLR( "fpedit.copper.in16", FL + In16_Cu, COLOR4D( RED ) );
CLR( "fpedit.copper.in17", FL + In17_Cu, COLOR4D( YELLOW ) );
CLR( "fpedit.copper.in18", FL + In18_Cu, COLOR4D( LIGHTMAGENTA ) );
CLR( "fpedit.copper.in19", FL + In19_Cu, COLOR4D( LIGHTRED ) );
CLR( "fpedit.copper.in20", FL + In20_Cu, COLOR4D( CYAN ) );
CLR( "fpedit.copper.in21", FL + In21_Cu, COLOR4D( GREEN ) );
CLR( "fpedit.copper.in22", FL + In22_Cu, COLOR4D( BLUE ) );
CLR( "fpedit.copper.in23", FL + In23_Cu, COLOR4D( DARKGRAY ) );
CLR( "fpedit.copper.in24", FL + In24_Cu, COLOR4D( MAGENTA ) );
CLR( "fpedit.copper.in25", FL + In25_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.copper.in26", FL + In26_Cu, COLOR4D( MAGENTA ) );
CLR( "fpedit.copper.in27", FL + In27_Cu, COLOR4D( RED ) );
CLR( "fpedit.copper.in28", FL + In28_Cu, COLOR4D( BROWN ) );
CLR( "fpedit.copper.in29", FL + In29_Cu, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.copper.in30", FL + In30_Cu, COLOR4D( BLUE ) );
CLR( "fpedit.copper.b", FL + B_Cu, COLOR4D( GREEN ) );
CLR( "fpedit.b_adhes", FL + B_Adhes, COLOR4D( BLUE ) );
CLR( "fpedit.f_adhes", FL + F_Adhes, COLOR4D( MAGENTA ) );
CLR( "fpedit.b_paste", FL + B_Paste, COLOR4D( LIGHTCYAN ) );
CLR( "fpedit.f_paste", FL + F_Paste, COLOR4D( RED ) );
CLR( "fpedit.b_silks", FL + B_SilkS, COLOR4D( MAGENTA ) );
CLR( "fpedit.f_silks", FL + F_SilkS, COLOR4D( CYAN ) );
CLR( "fpedit.b_mask", FL + B_Mask, COLOR4D( BROWN ) );
CLR( "fpedit.f_mask", FL + F_Mask, COLOR4D( MAGENTA ) );
CLR( "fpedit.dwgs_user", FL + Dwgs_User, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.cmts_user", FL + Cmts_User, COLOR4D( BLUE ) );
CLR( "fpedit.eco1_user", FL + Eco1_User, COLOR4D( GREEN ) );
CLR( "fpedit.eco2_user", FL + Eco2_User, COLOR4D( YELLOW ) );
CLR( "fpedit.edge_cuts", FL + Edge_Cuts, COLOR4D( YELLOW ) );
CLR( "fpedit.margin", FL + Margin, COLOR4D( LIGHTMAGENTA ) );
CLR( "fpedit.b_crtyd", FL + B_CrtYd, COLOR4D( DARKGRAY ) );
CLR( "fpedit.f_crtyd", FL + F_CrtYd, COLOR4D( LIGHTGRAY ) );
CLR( "fpedit.b_fab", FL + B_Fab, COLOR4D( BLUE ) );
CLR( "fpedit.f_fab", FL + F_Fab, COLOR4D( DARKGRAY ) );
// Colors for 3D viewer, which are used as defaults unless overridden by the board
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) );
CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 1.0 ) );
CLR( "3d_viewer.copper", LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) );
CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 1.0 ) );
CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
}
bool COLOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
return false;
}
COLOR4D COLOR_SETTINGS::GetColor( int aLayer ) const
{
try
{
if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START
&& aLayer <= GAL_LAYER_ID_END )
aLayer += FPEDIT_LAYER_ID_START;
return m_colors.at( aLayer );
}
catch( std::out_of_range& )
{
return COLOR4D::UNSPECIFIED;
}
}
COLOR4D COLOR_SETTINGS::GetDefaultColor( int aLayer )
{
if( !m_defaultColors.count( aLayer ) )
{
if( m_color_context == COLOR_CONTEXT::FOOTPRINT && aLayer >= PCBNEW_LAYER_ID_START
&& aLayer <= GAL_LAYER_ID_END )
aLayer += FPEDIT_LAYER_ID_START;
COLOR_MAP_PARAM* p = nullptr;
for( auto param : m_params )
if( auto cmp = dynamic_cast<COLOR_MAP_PARAM*>( param ) )
if( cmp->GetKey() == aLayer )
p = cmp;
wxASSERT( p );
m_defaultColors[aLayer] = p->GetDefault();
}
return m_defaultColors.at( aLayer );;
}
void COLOR_SETTINGS::SetColor( int aLayer, COLOR4D aColor )
{
if( m_color_context == COLOR_CONTEXT::FOOTPRINT )
aLayer += FPEDIT_LAYER_ID_START;
m_colors[ aLayer ] = aColor;
}

View File

@ -0,0 +1,169 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <settings/common_settings.h>
#include <settings/parameters.h>
#include <wx/config.h>
#include <wx/log.h>
extern const char* traceSettings;
///! Update the schema version whenever a migration is required
const int commonSchemaVersion = 0;
COMMON_SETTINGS::COMMON_SETTINGS() :
JSON_SETTINGS( "kicad_common", SETTINGS_LOC::USER, commonSchemaVersion ),
m_Appearance(), m_Env(), m_Input(), m_Graphics(), m_System()
{
// This only effect the first time KiCad is run. The user's setting will be used for all
// subsequent runs. Menu icons are off by default on OSX and on for all other platforms.
#if defined( __WXMAC__ )
bool defaultUseIconsInMenus = false;
#else
bool defaultUseIconsInMenus = true;
#endif
m_params.emplace_back( new PARAM<double>( "appearance.canvas_scale",
&m_Appearance.canvas_scale, 1.0 ) );
m_params.emplace_back( new PARAM<int>( "appearance.icon_scale",
&m_Appearance.icon_scale, 0 ) );
m_params.emplace_back( new PARAM<bool>( "appearance.use_icons_in_menus",
&m_Appearance.use_icons_in_menus, defaultUseIconsInMenus ) );
m_params.emplace_back( new PARAM<bool>( "environment.show_warning_dialog",
&m_Env.show_warning_dialog, false ) );
m_params.emplace_back( new PARAM_MAP<wxString>( "environment.vars", &m_Env.vars, {} ) );
m_params.emplace_back( new PARAM<bool>( "input.auto_pan", &m_Input.auto_pan, false ) );
m_params.emplace_back(
new PARAM<bool>( "input.center_on_zoom", &m_Input.center_on_zoom, true ) );
m_params.emplace_back( new PARAM<bool>( "input.immediate_actions",
&m_Input.immediate_actions, true ) );
m_params.emplace_back(
new PARAM<bool>( "input.mousewheel_pan", &m_Input.mousewheel_pan, false ) );
m_params.emplace_back( new PARAM<bool>( "input.prefer_select_to_drag",
&m_Input.prefer_select_to_drag, true ) );
m_params.emplace_back( new PARAM<bool>( "input.warp_mouse_on_move",
&m_Input.warp_mouse_on_move, true ) );
m_params.emplace_back( new PARAM<int>( "graphics.opengl_antialiasing_mode",
&m_Graphics.opengl_aa_mode, 0, 0, 4 ) );
m_params.emplace_back( new PARAM<int>( "graphics.cairo_antialiasing_mode",
&m_Graphics.cairo_aa_mode, 0, 0, 3 ) );
m_params.emplace_back( new PARAM<int>( "system.autosave_interval",
&m_System.autosave_interval, 600 ) );
m_params.emplace_back( new PARAM<wxString>( "system.editor_name",
&m_System.editor_name, "" ) );
m_params.emplace_back( new PARAM<int>( "system.file_history_size",
&m_System.file_history_size, 9 ) );
m_params.emplace_back( new PARAM<wxString>( "system.language",
&m_System.language, "Default" ) );
m_params.emplace_back( new PARAM<wxString>( "system.pdf_viewer_name",
&m_System.pdf_viewer_name, "" ) );
m_params.emplace_back( new PARAM<bool>( "system.use_system_pdf_viewer",
&m_System.use_system_pdf_viewer, true ) );
m_params.emplace_back( new PARAM<wxString>( "system.working_dir",
&m_System.working_dir, "" ) );
}
bool COMMON_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
bool ret = true;
ret &= fromLegacy<double>( aCfg, "CanvasScale", "appearance.canvas_scale" );
ret &= fromLegacy<int>( aCfg, "IconScale", "appearance.icon_scale" );
ret &= fromLegacy<bool>( aCfg, "UseIconsInMenus", "appearance.use_icons_in_menus" );
ret &= fromLegacy<bool>( aCfg, "ShowEnvVarWarningDialog", "environment.show_warning_dialog" );
auto load_env_vars = [&] () {
wxString key, value;
long index = 0;
nlohmann::json::json_pointer ptr = PointerFromString( "environment.vars" );
aCfg->SetPath( "EnvironmentVariables" );
( *this )[ptr] = nlohmann::json( {} );
while( aCfg->GetNextEntry( key, index ) )
{
value = aCfg->Read( key, wxEmptyString );
if( !value.IsEmpty() )
{
ptr.push_back( key.ToStdString() );
wxLogTrace( traceSettings, "Migrate Env: %s=%s", ptr.to_string(), value );
( *this )[ptr] = value.ToUTF8();
ptr.pop_back();
}
}
aCfg->SetPath( ".." );
};
load_env_vars();
ret &= fromLegacy<bool>( aCfg, "AutoPAN", "input.auto_pan" );
ret &= fromLegacy<bool>( aCfg, "ImmediateActions", "input.immediate_actions" );
ret &= fromLegacy<bool>( aCfg, "MousewheelPAN", "input.mousewheel_pan" );
ret &= fromLegacy<bool>( aCfg, "PreferSelectionToDragging", "input.prefer_select_to_drag" );
ret &= fromLegacy<bool>( aCfg, "MoveWarpsCursor", "input.warp_mouse_on_move" );
ret &= fromLegacy<bool>( aCfg, "ZoomNoCenter", "input.center_on_zoom" );
// This was stored inverted in legacy config
if( ret )
{
auto p = PointerFromString( "input.center_on_zoom" );
( *this )[p] = !( *this )[p];
}
ret &= fromLegacy<int>( aCfg, "OpenGLAntialiasingMode", "graphics.opengl_antialiasing_mode" );
ret &= fromLegacy<int>( aCfg, "CairoAntialiasingMode", "graphics.cairo_antialiasing_mode" );
ret &= fromLegacy<int>( aCfg, "AutoSaveInterval", "system.autosave_interval" );
ret &= fromLegacyString( aCfg, "Editor", "system.editor_name" );
ret &= fromLegacy<int>( aCfg, "FileHistorySize", "system.file_history_size" );
ret &= fromLegacyString( aCfg, "LanguageID", "system.language" );
ret &= fromLegacyString( aCfg, "PdfBrowserName", "system.pdf_viewer_name" );
ret &= fromLegacy<bool>( aCfg, "UseSystemBrowser", "system.use_system_pdf_viewer" );
ret &= fromLegacyString( aCfg, "WorkingDir", "system.working_dir" );
return ret;
}

View File

@ -0,0 +1,412 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <fstream>
#include <iomanip>
#include <utility>
#include <common.h>
#include <gal/color4d.h>
#include <settings/json_settings.h>
#include <settings/nested_settings.h>
#include <settings/parameters.h>
#include <wx/config.h>
#include <wx/debug.h>
#include <wx/filename.h>
extern const char* traceSettings;
JSON_SETTINGS::JSON_SETTINGS( const std::string& aFilename, SETTINGS_LOC aLocation,
int aSchemaVersion, bool aCreateIfMissing, bool aWriteFile,
nlohmann::json aDefault ) :
nlohmann::json( std::move( aDefault ) ), m_filename( aFilename ), m_legacy_filename( "" ),
m_location( aLocation ), m_createIfMissing( aCreateIfMissing ), m_writeFile( aWriteFile ),
m_schemaVersion( aSchemaVersion )
{
m_params.emplace_back(
new PARAM<std::string>( "meta.filename", &m_filename, m_filename, true ) );
m_params.emplace_back(
new PARAM<int>( "meta.version", &m_schemaVersion, m_schemaVersion, true ) );
}
JSON_SETTINGS::~JSON_SETTINGS()
{
for( auto param: m_params )
delete param;
m_params.clear();
}
void JSON_SETTINGS::Load()
{
for( auto param : m_params )
param->Load( this );
}
void JSON_SETTINGS::LoadFromFile( const std::string& aDirectory )
{
// First, load all params to default values
clear();
Load();
bool migrated = false;
LOCALE_IO locale;
auto migrateFromLegacy = [&] ( wxFileName& aPath ) {
wxConfigBase::DontCreateOnDemand();
auto cfg = std::make_unique<wxFileConfig>( wxT( "" ), wxT( "" ), aPath.GetFullPath() );
// If migrate fails or is not implemented, fall back to built-in defaults that were
// already loaded above
if( !MigrateFromLegacy( cfg.get() ) )
{
wxLogTrace( traceSettings,
"%s: migrated; not all settings were found in legacy file", m_filename );
}
else
{
wxLogTrace( traceSettings, "%s: migrated from legacy format", m_filename );
}
// Either way, we want to clean up the old file afterwards
migrated = true;
};
wxFileName path( aDirectory, m_filename, "json" );
if( !path.Exists() )
{
// Case 1: legacy migration, no .json extension yet
path.ClearExt();
if( path.Exists() )
{
migrateFromLegacy( path );
}
// Case 2: legacy filename is different from new one
else if( !m_legacy_filename.empty() )
{
path.SetName( m_legacy_filename );
if( path.Exists() )
migrateFromLegacy( path );
}
}
else
{
try
{
std::ifstream in( path.GetFullPath().ToStdString() );
in >> *this;
// If parse succeeds, check if schema migration is required
try
{
int filever = at( PointerFromString( "meta.version" ) ).get<int>();
if( filever < m_schemaVersion )
{
wxLogTrace( traceSettings, "%s: attempting migration from version %d to %d",
m_filename, filever, m_schemaVersion );
if( !Migrate() )
{
wxLogTrace( traceSettings, "%s: migration failed!", m_filename );
}
}
else if( filever > m_schemaVersion )
{
wxLogTrace( traceSettings,
"%s: warning: file version %d is newer than latest (%d)", m_filename,
filever, m_schemaVersion );
}
}
catch( ... )
{
wxLogTrace( traceSettings, "%s: file version could not be read!", m_filename );
}
}
catch( nlohmann::json::parse_error& error )
{
wxLogTrace(
traceSettings, "Parse error reading %s: %s", path.GetFullPath(), error.what() );
wxLogTrace( traceSettings, "Attempting migration in case file is in legacy format" );
migrateFromLegacy( path );
}
}
// Now that we have new data in the JSON structure, load the params again
Load();
// And finally load any nested settings
for( auto settings : m_nested_settings )
settings->LoadFromFile();
wxLogTrace( traceSettings, "Loaded %s with schema %d", GetFilename(), m_schemaVersion );
// If we migrated, clean up the legacy file (with no extension)
if( migrated )
{
if( !wxRemoveFile( path.GetFullPath() ) )
{
wxLogTrace(
traceSettings, "Warning: could not remove legacy file %s", path.GetFullPath() );
}
// And write-out immediately so that we don't lose data if the program later crashes.
SaveToFile( aDirectory );
}
}
void JSON_SETTINGS::Store()
{
for( auto param : m_params )
param->Store( this );
}
void JSON_SETTINGS::ResetToDefaults()
{
for( auto param : m_params )
param->SetDefault();
}
void JSON_SETTINGS::SaveToFile( const std::string& aDirectory )
{
if( !m_writeFile )
return;
wxLogTrace( traceSettings, "Saving %s", m_filename );
wxFileName path( aDirectory, m_filename, "json" );
if( !m_createIfMissing && !path.FileExists() )
return;
if( !path.DirExists() && !path.Mkdir() )
{
wxLogTrace( traceSettings, "Warning: could not create path %s, can't save %s",
path.GetPath(), m_filename );
return;
}
for( auto settings : m_nested_settings )
settings->SaveToFile();
Store();
LOCALE_IO dummy;
try
{
std::ofstream file( path.GetFullPath().ToStdString() );
file << std::setw( 2 ) << *this << std::endl;
}
catch( const std::exception& e )
{
wxLogTrace( traceSettings, "Warning: could not save %s: %s", m_filename, e.what() );
}
catch( ... )
{
}
}
nlohmann::json JSON_SETTINGS::GetJson( std::string aPath ) const
{
nlohmann::json ret( {} );
// Will throw an exception if the path is not found
try
{
ret = this->at( PointerFromString( std::move( aPath ) ) );
}
catch( ... )
{
}
return ret;
}
bool JSON_SETTINGS::Migrate()
{
wxLogTrace( traceSettings, "Migrate() not implemented for %s", typeid( *this ).name() );
return false;
}
bool JSON_SETTINGS::MigrateFromLegacy( wxConfigBase* aLegacyConfig )
{
wxLogTrace( traceSettings,
"MigrateFromLegacy() not implemented for %s", typeid( *this ).name() );
return false;
}
nlohmann::json::json_pointer JSON_SETTINGS::PointerFromString( std::string aPath )
{
boost::replace_all( aPath, ".", "/" );
aPath.insert( 0, "/" );
nlohmann::json::json_pointer p;
try
{
p = nlohmann::json::json_pointer( aPath );
}
catch( ... )
{
wxASSERT_MSG( false, wxT( "Invalid pointer path in PointerFromString!" ) );
}
return p;
}
template<typename ValueType>
bool JSON_SETTINGS::fromLegacy( wxConfigBase* aConfig, const std::string& aKey,
const std::string& aDest )
{
ValueType val;
if( aConfig->Read( aKey, &val ) )
{
try
{
( *this )[PointerFromString( aDest )] = val;
}
catch( ... )
{
wxASSERT_MSG( false, wxT( "Could not write value in fromLegacy!" ) );
return false;
}
return true;
}
return false;
}
// Explicitly declare these because we only support a few types anyway, and it means we can keep
// wxConfig detail out of the header file
template bool JSON_SETTINGS::fromLegacy<int>( wxConfigBase*, const std::string&,
const std::string& );
template bool JSON_SETTINGS::fromLegacy<double>( wxConfigBase*, const std::string&,
const std::string& );
template bool JSON_SETTINGS::fromLegacy<bool>( wxConfigBase*, const std::string&,
const std::string& );
bool JSON_SETTINGS::fromLegacyString( wxConfigBase* aConfig, const std::string& aKey,
const std::string& aDest )
{
wxString str;
if( aConfig->Read( aKey, &str ) )
{
try
{
( *this )[PointerFromString( aDest )] = str.ToUTF8();
}
catch( ... )
{
wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyString!" ) );
return false;
}
return true;
}
return false;
}
bool JSON_SETTINGS::fromLegacyColor( wxConfigBase* aConfig, const std::string& aKey,
const std::string& aDest )
{
wxString str;
if( aConfig->Read( aKey, &str ) )
{
KIGFX::COLOR4D color;
color.SetFromWxString( str );
try
{
nlohmann::json js = nlohmann::json::array( { color.r, color.g, color.b, color.a } );
( *this )[PointerFromString( aDest )] = js;
}
catch( ... )
{
wxASSERT_MSG( false, wxT( "Could not write value in fromLegacyColor!" ) );
return false;
}
return true;
}
return false;
}
void JSON_SETTINGS::AddNestedSettings( NESTED_SETTINGS* aSettings )
{
m_nested_settings.push_back( aSettings );
}
// Specializations to allow conversion between wxString and std::string via JSON_SETTINGS API
template<> wxString JSON_SETTINGS::Get( std::string aPath ) const
{
return wxString( GetJson( std::move( aPath ) ).get<std::string>().c_str(), wxConvUTF8 );
}
template<> void JSON_SETTINGS::Set<wxString>( std::string aPath, wxString aVal )
{
( *this )[PointerFromString( std::move( aPath ) ) ] = aVal.ToUTF8();
}
// Specializations to allow directly reading/writing wxStrings from JSON
void to_json( nlohmann::json& aJson, const wxString& aString )
{
aJson = aString.ToUTF8();
}
void from_json( const nlohmann::json& aJson, wxString& aString )
{
aString = wxString( aJson.get<std::string>().c_str(), wxConvUTF8 );
}

View File

@ -0,0 +1,78 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <wx/log.h>
#include <settings/nested_settings.h>
extern const char* traceSettings;
NESTED_SETTINGS::NESTED_SETTINGS( const std::string& aName, int aVersion, JSON_SETTINGS* aParent,
const std::string& aPath, nlohmann::json aDefault ) :
JSON_SETTINGS( aName, SETTINGS_LOC::NESTED, aVersion, std::move( aDefault ) ),
m_parent( aParent ), m_path( aPath )
{
wxASSERT( m_parent );
m_parent->AddNestedSettings( this );
// In case we were created after the parent's ctor
LoadFromFile();
}
void NESTED_SETTINGS::LoadFromFile( const std::string& aDirectory )
{
clear();
try
{
update( ( *m_parent )[PointerFromString( m_path ) ] );
wxLogTrace( traceSettings, "Loaded NESTED_SETTINGS %s with schema %d",
GetFilename(), m_schemaVersion );
}
catch( ... )
{
wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not load from %s at %s",
m_filename, m_parent->GetFilename(), m_path );
}
Load();
}
void NESTED_SETTINGS::SaveToFile( const std::string& aDirectory )
{
Store();
try
{
( *m_parent )[PointerFromString( m_path ) ].update( *this );
wxLogTrace( traceSettings, "Stored NESTED_SETTINGS %s with schema %d",
GetFilename(), m_schemaVersion );
}
catch( ... )
{
wxLogTrace( traceSettings, "NESTED_SETTINGS %s: Could not store to %s at %s",
m_filename, m_parent->GetFilename(), m_path );
}
}

View File

@ -0,0 +1,545 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020 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 as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <regex>
#include <wx/debug.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include <wx/utils.h>
#include <build_version.h>
#include <confirm.h>
#include <dialogs/dialog_migrate_settings.h>
#include <gestfich.h>
#include <macros.h>
#include <settings/app_settings.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <settings/color_settings.h>
/**
* Flag to enable settings tracing
* @ingroup trace_env_vars
*/
const char* traceSettings = "SETTINGS";
SETTINGS_MANAGER::SETTINGS_MANAGER() :
m_common_settings( nullptr ), m_migration_source()
{
// Check if the settings directory already exists, and if not, perform a migration if possible
if( !MigrateIfNeeded() )
{
m_ok = false;
return;
}
m_ok = true;
// create the common settings shared by all applications. Not loaded immediately
m_common_settings =
static_cast<COMMON_SETTINGS*>( RegisterSettings( new COMMON_SETTINGS, false ) );
// create the default color settings
m_color_settings["default"] =
static_cast<COLOR_SETTINGS*>( RegisterSettings( new COLOR_SETTINGS ) );
}
SETTINGS_MANAGER::~SETTINGS_MANAGER()
{
m_settings.clear();
m_color_settings.clear();
}
JSON_SETTINGS* SETTINGS_MANAGER::RegisterSettings( JSON_SETTINGS* aSettings, bool aLoadNow )
{
std::unique_ptr<JSON_SETTINGS> ptr( aSettings );
wxLogTrace( traceSettings, "Registered new settings object %s", ptr->GetFilename() );
if( aLoadNow )
ptr->LoadFromFile( GetPathForSettingsFile( ptr.get() ) );
m_settings.push_back( std::move( ptr ) );
return m_settings.back().get();
}
void SETTINGS_MANAGER::Load()
{
// TODO(JE) We should check for dirty settings here and write them if so, because
// Load() could be called late in the application lifecycle
for( auto&& settings : m_settings )
settings->LoadFromFile( GetPathForSettingsFile( settings.get() ) );
}
void SETTINGS_MANAGER::Load( JSON_SETTINGS* aSettings )
{
auto it = std::find_if( m_settings.begin(), m_settings.end(),
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) {
return aPtr.get() == aSettings;
} );
if( it != m_settings.end() )
( *it )->LoadFromFile( GetPathForSettingsFile( it->get() ) );
}
void SETTINGS_MANAGER::Save()
{
for( auto&& settings : m_settings )
{
// Never automatically save color settings, caller should use SaveColorSettings
if( dynamic_cast<COLOR_SETTINGS*>( settings.get() ) )
continue;
settings->SaveToFile( GetPathForSettingsFile( settings.get() ) );
}
}
void SETTINGS_MANAGER::Save( JSON_SETTINGS* aSettings )
{
auto it = std::find_if( m_settings.begin(), m_settings.end(),
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) {
return aPtr.get() == aSettings;
} );
if( it != m_settings.end() )
{
wxLogTrace( traceSettings, "Saving %s", ( *it )->GetFilename() );
( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) );
}
}
void SETTINGS_MANAGER::FlushAndRelease( JSON_SETTINGS* aSettings )
{
auto it = std::find_if( m_settings.begin(), m_settings.end(),
[&aSettings]( const std::unique_ptr<JSON_SETTINGS>& aPtr ) {
return aPtr.get() == aSettings;
} );
if( it != m_settings.end() )
{
wxLogTrace( traceSettings, "Flush and release %s", ( *it )->GetFilename() );
( *it )->SaveToFile( GetPathForSettingsFile( it->get() ) );
m_settings.erase( it );
}
}
COLOR_SETTINGS* SETTINGS_MANAGER::GetColorSettings( std::string aName )
{
COLOR_SETTINGS* ret = nullptr;
try
{
ret = m_color_settings.at( aName );
}
catch( std::out_of_range& )
{
// This had better work
ret = m_color_settings.at( "default" );
}
return ret;
}
void SETTINGS_MANAGER::SaveColorSettings( COLOR_SETTINGS* aSettings, const std::string& aNamespace )
{
// The passed settings should already be managed
wxASSERT( std::find_if( m_color_settings.begin(), m_color_settings.end(),
[aSettings] ( const auto& el ) {
return el.second == aSettings;
} ) != m_color_settings.end() );
nlohmann::json::json_pointer ptr = JSON_SETTINGS::PointerFromString( aNamespace );
aSettings->Store();
wxASSERT( aSettings->contains( ptr ) );
wxLogTrace( traceSettings, "Saving color scheme %s, preserving &s",
aSettings->GetFilename(), aNamespace );
nlohmann::json backup = aSettings->at( ptr );
std::string path = GetColorSettingsPath();
aSettings->LoadFromFile( path );
( *aSettings )[ptr].update( backup );
aSettings->Load();
aSettings->SaveToFile( path );
}
std::string SETTINGS_MANAGER::GetPathForSettingsFile( JSON_SETTINGS* aSettings )
{
wxASSERT( aSettings );
switch( aSettings->GetLocation() )
{
case SETTINGS_LOC::USER:
return GetUserSettingsPath();
case SETTINGS_LOC::PROJECT:
// TODO(JE)
return "";
case SETTINGS_LOC::COLORS:
return GetColorSettingsPath();
default:
wxASSERT_MSG( false, "Unknown settings location!" );
}
return "";
}
class MIGRATION_TRAVERSER : public wxDirTraverser
{
private:
wxString m_src;
wxString m_dest;
wxString m_errors;
public:
MIGRATION_TRAVERSER( const wxString& aSrcDir, const wxString& aDestDir ) :
m_src( aSrcDir ), m_dest( aDestDir )
{
}
wxString GetErrors() { return m_errors; }
virtual wxDirTraverseResult OnFile( const wxString& aSrcFilePath ) override
{
wxFileName file( aSrcFilePath );
wxString path = file.GetPath();
path.Replace( m_src, m_dest, false );
file.SetPath( path );
wxLogTrace( traceSettings, "Copying %s to %s", aSrcFilePath, file.GetFullPath() );
// For now, just copy everything
CopyFile( aSrcFilePath, file.GetFullPath(), m_errors );
return wxDIR_CONTINUE;
}
virtual wxDirTraverseResult OnDir( const wxString& dirPath ) override
{
wxFileName dir( dirPath );
// Whitelist of directories to migrate
if( dir.GetName() == "colors" ||
dir.GetName() == "3d" )
{
wxString path = dir.GetPath();
path.Replace( m_src, m_dest, false );
dir.SetPath( path );
wxMkdir( dir.GetFullPath() );
return wxDIR_CONTINUE;
}
else
{
return wxDIR_IGNORE;
}
}
};
bool SETTINGS_MANAGER::MigrateIfNeeded()
{
wxFileName path( GetUserSettingsPath(), "" );
wxLogTrace( traceSettings, "Using settings path %s", path.GetFullPath() );
if( path.DirExists() )
{
wxFileName common = path;
common.SetName( "kicad_common" );
common.SetExt( "json" );
if( common.Exists() )
{
wxLogTrace( traceSettings, "Path exists and has a kicad_common, continuing!" );
return true;
}
}
// Now we have an empty path, let's figure out what to put in it
DIALOG_MIGRATE_SETTINGS dlg( this );
if( dlg.ShowModal() != wxID_OK )
{
wxLogTrace( traceSettings, "Migration dialog canceled; exiting" );
return false;
}
if( !path.DirExists() )
{
wxLogTrace( traceSettings, "Path didn't exist; creating it" );
path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
}
if( m_migration_source.IsEmpty() )
{
wxLogTrace( traceSettings, "No migration source given; starting with defaults" );
return true;
}
MIGRATION_TRAVERSER traverser( m_migration_source, path.GetFullPath() );
wxDir source_dir( m_migration_source );
source_dir.Traverse( traverser );
if( !traverser.GetErrors().empty() )
DisplayErrorMessage( nullptr, traverser.GetErrors() );
return true;
}
bool SETTINGS_MANAGER::GetPreviousVersionPaths( std::vector<wxString>* aPaths )
{
wxASSERT( aPaths );
aPaths->clear();
wxDir dir;
std::vector<wxFileName> base_paths;
base_paths.emplace_back( wxFileName( calculateUserSettingsPath( false ), "" ) );
// If the env override is set, also check the default paths
if( wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), nullptr ) )
base_paths.emplace_back( wxFileName( calculateUserSettingsPath( false, false ), "" ) );
wxString subdir;
std::string mine = GetSettingsVersion();
auto check_dir = [&] ( const wxString& aSubDir )
{
// Only older versions are valid for migration
if( compareVersions( aSubDir.ToStdString(), mine ) <= 0 )
{
wxString sub_path = dir.GetNameWithSep() + aSubDir;
if( IsSettingsPathValid( sub_path ) )
{
aPaths->push_back( sub_path );
wxLogTrace( traceSettings, "GetPreviousVersionName: %s is valid", sub_path );
}
}
};
for( auto base_path : base_paths )
{
if( !dir.Open( base_path.GetFullPath() ) )
{
wxLogTrace( traceSettings, "GetPreviousVersionName: could not open base path %s",
base_path.GetFullPath() );
continue;
}
wxLogTrace( traceSettings, "GetPreviousVersionName: checking base path %s",
base_path.GetFullPath() );
if( dir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS ) )
{
if( subdir != mine )
check_dir( subdir );
while( dir.GetNext( &subdir ) )
{
if( subdir != mine )
check_dir( subdir );
}
}
// If we didn't find one yet, check for legacy settings without a version directory
if( IsSettingsPathValid( dir.GetNameWithSep() ) )
{
wxLogTrace( traceSettings,
"GetPreviousVersionName: root path %s is valid", dir.GetName() );
aPaths->push_back( dir.GetName() );
}
}
return aPaths->size() > 0;
}
bool SETTINGS_MANAGER::IsSettingsPathValid( const wxString& aPath )
{
wxFileName test( aPath, "kicad_common" );
return test.Exists();
}
std::string SETTINGS_MANAGER::GetColorSettingsPath()
{
wxFileName path;
path.AssignDir( GetUserSettingsPath() );
path.AppendDir( "colors" );
return path.GetPath().ToStdString();
}
std::string SETTINGS_MANAGER::GetUserSettingsPath()
{
static std::string user_settings_path;
if( user_settings_path.empty() )
user_settings_path = calculateUserSettingsPath();
return user_settings_path;
}
std::string SETTINGS_MANAGER::calculateUserSettingsPath( bool aIncludeVer, bool aUseEnv )
{
wxFileName cfgpath;
// http://docs.wxwidgets.org/3.0/classwx_standard_paths.html#a7c7cf595d94d29147360d031647476b0
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
// GetUserConfigDir() does not default to ~/.config which is the current standard
// configuration file location on Linux. This has been fixed in later versions of wxWidgets.
#if !defined( __WXMSW__ ) && !defined( __WXMAC__ )
wxArrayString dirs = cfgpath.GetDirs();
if( dirs.Last() != ".config" )
cfgpath.AppendDir( ".config" );
#endif
wxString envstr;
// This shouldn't cause any issues on Windows or MacOS.
if( wxGetEnv( wxT( "XDG_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
{
// Override the assignment above with XDG_CONFIG_HOME
cfgpath.AssignDir( envstr );
}
cfgpath.AppendDir( TO_STR( KICAD_CONFIG_DIR ) );
// Use KICAD_CONFIG_HOME to allow the user to force a specific configuration path.
if( aUseEnv && wxGetEnv( wxT( "KICAD_CONFIG_HOME" ), &envstr ) && !envstr.IsEmpty() )
{
// Override the assignment above with KICAD_CONFIG_HOME
cfgpath.AssignDir( envstr );
}
if( aIncludeVer )
cfgpath.AppendDir( GetSettingsVersion() );
return cfgpath.GetPath().ToStdString();
}
std::string SETTINGS_MANAGER::GetSettingsVersion()
{
wxString version = GetBuildVersion().BeforeLast( '.' );
// A full build version looks like (x.y.z-nnn-g1234567) or x.y.z-xxx
// We want to extract the x.y portion here
if( version.StartsWith( '(' ) )
version = version.Mid( 1 );
return version.ToStdString();
}
int SETTINGS_MANAGER::compareVersions( const std::string& aFirst, const std::string& aSecond )
{
int a_maj = 0;
int a_min = 0;
int b_maj = 0;
int b_min = 0;
if( !extractVersion( aFirst, &a_maj, &a_min ) || !extractVersion( aSecond, &b_maj, &b_min ) )
{
wxLogTrace( traceSettings, "compareSettingsVersions: bad input (%s, %s)", aFirst, aSecond );
return -1;
}
if( a_maj < b_maj )
{
return -1;
}
else if( a_maj > b_maj )
{
return 1;
}
else
{
if( a_min < b_min )
{
return -1;
}
else if( a_min > b_min )
{
return 1;
}
else
{
return 0;
}
}
}
bool SETTINGS_MANAGER::extractVersion( const std::string& aVersionString, int* aMajor, int* aMinor )
{
std::regex re_version( "(\\d+)\\.(\\d+)" );
std::smatch match;
if( std::regex_match( aVersionString, match, re_version ) )
{
try
{
*aMajor = std::stoi( match[1].str() );
*aMinor = std::stoi( match[2].str() );
}
catch( ... )
{
return false;
}
return true;
}
return false;
}

View File

@ -46,6 +46,7 @@
#include <pgm_base.h> #include <pgm_base.h>
#include <kiway_player.h> #include <kiway_player.h>
#include <confirm.h> #include <confirm.h>
#include <settings/settings_manager.h>
// Only a single KIWAY is supported in this single_top top level component, // Only a single KIWAY is supported in this single_top top level component,
@ -67,7 +68,11 @@ static struct PGM_SINGLE_TOP : public PGM_BASE
{ {
Kiway.OnKiwayEnd(); Kiway.OnKiwayEnd();
if( m_settings_manager && m_settings_manager->IsOK() )
{
SaveCommonSettings(); SaveCommonSettings();
m_settings_manager->Save();
}
// Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
// earlier than wxApp and earlier than static destruction would. // earlier than wxApp and earlier than static destruction would.
@ -157,7 +162,13 @@ struct APP_SINGLE_TOP : public wxApp
try try
{ {
return program.OnPgmInit(); if( !program.OnPgmInit() )
{
program.OnPgmExit();
return false;
}
return true;
} }
catch( const std::exception& e ) catch( const std::exception& e )
{ {

View File

@ -91,12 +91,13 @@ principle should be easily implemented by adapting the current STL containers.
#include <bitset> #include <bitset>
#include <title_block.h> #include <title_block.h>
#include <colors_design_settings.h>
#include <marker_base.h> #include <marker_base.h>
#include <eda_text.h> #include <eda_text.h>
#include <convert_to_biu.h> #include <convert_to_biu.h>
#include <id.h> #include <id.h>
#include <build_version.h> #include <build_version.h>
#include <layers_id_colors_and_visibility.h>
#include <settings/settings_manager.h>
%} %}
// all the wx wrappers for wxString, wxPoint, wxRect, wxChar .. // all the wx wrappers for wxString, wxPoint, wxRect, wxChar ..
@ -113,11 +114,10 @@ principle should be easily implemented by adapting the current STL containers.
%include common.h %include common.h
%include title_block.h %include title_block.h
%include gal/color4d.h %include gal/color4d.h
%include core/settings.h
%include colors_design_settings.h
%include marker_base.h %include marker_base.h
%include eda_text.h %include eda_text.h
%include build_version.h %include build_version.h
%include settings/settings_manager.h
// Cast time_t to known type for Python // Cast time_t to known type for Python
typedef long time_t; typedef long time_t;

View File

@ -60,43 +60,4 @@ EDA_ITEM* TOOL_BASE::getModelInt() const
void TOOL_BASE::attachManager( TOOL_MANAGER* aManager ) void TOOL_BASE::attachManager( TOOL_MANAGER* aManager )
{ {
m_toolMgr = aManager; m_toolMgr = aManager;
m_toolSettings = TOOL_SETTINGS( this );
}
TOOL_SETTINGS::TOOL_SETTINGS( TOOL_BASE* aTool ) :
m_tool( aTool )
{
}
TOOL_SETTINGS::~TOOL_SETTINGS()
{
}
TOOL_SETTINGS& TOOL_BASE::GetSettings()
{
return m_toolSettings;
}
wxString TOOL_SETTINGS::getKeyName( const wxString& aEntryName ) const
{
wxString key( m_tool->GetName() );
key += wxT( "." );
key += aEntryName;
return key;
}
wxConfigBase* TOOL_SETTINGS::getConfigBase() const
{
if( !m_tool )
return NULL;
if( EDA_BASE_FRAME* frame = m_tool->getEditFrame<EDA_BASE_FRAME>() )
return frame->config();
return NULL;
} }

View File

@ -32,6 +32,7 @@
#include <view/zoom_controller.h> #include <view/zoom_controller.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
#include <settings/common_settings.h>
#include <math/util.h> // for KiROUND #include <math/util.h> // for KiROUND
@ -67,13 +68,9 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
m_cursorPos( 0, 0 ), m_cursorPos( 0, 0 ),
m_updateCursor( true ) m_updateCursor( true )
{ {
bool enableMousewheelPan = false; bool enableMousewheelPan = Pgm().GetCommonSettings()->m_Input.mousewheel_pan;
bool enableZoomNoCenter = false; bool enableZoomNoCenter = !Pgm().GetCommonSettings()->m_Input.center_on_zoom;
bool enableAutoPan = true; bool enableAutoPan = Pgm().GetCommonSettings()->m_Input.auto_pan;
Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &enableMousewheelPan, false );
Pgm().CommonSettings()->Read( ENBL_ZOOM_NO_CENTER_KEY, &enableZoomNoCenter, false );
Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &enableAutoPan, true );
m_settings.m_enableMousewheelPan = enableMousewheelPan; m_settings.m_enableMousewheelPan = enableMousewheelPan;
m_settings.m_warpCursor = !enableZoomNoCenter; m_settings.m_warpCursor = !enableZoomNoCenter;
@ -136,13 +133,13 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxScrolledCanvas* aParentPanel
WX_VIEW_CONTROLS::~WX_VIEW_CONTROLS() WX_VIEW_CONTROLS::~WX_VIEW_CONTROLS()
{ {
wxConfigBase* cfg = Pgm().CommonSettings(); COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
if( cfg ) if( cfg )
{ {
cfg->Write( ENBL_MOUSEWHEEL_PAN_KEY, m_settings.m_enableMousewheelPan ); cfg->m_Input.mousewheel_pan = m_settings.m_enableMousewheelPan;
cfg->Write( ENBL_ZOOM_NO_CENTER_KEY, !m_settings.m_warpCursor ); cfg->m_Input.center_on_zoom = m_settings.m_warpCursor;
cfg->Write( ENBL_AUTO_PAN_KEY, m_settings.m_autoPanSettingEnabled ); cfg->m_Input.auto_pan = m_settings.m_autoPanSettingEnabled;
} }
} }

View File

@ -37,6 +37,7 @@ set( CVPCB_SRCS
footprints_listbox.cpp footprints_listbox.cpp
library_listbox.cpp library_listbox.cpp
cvpcb_mainframe.cpp cvpcb_mainframe.cpp
cvpcb_settings.cpp
listbox_base.cpp listbox_base.cpp
menubar.cpp menubar.cpp
readwrite_dlgs.cpp readwrite_dlgs.cpp

View File

@ -31,8 +31,10 @@
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/settings_manager.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
#include <cvpcb_settings.h>
#include <display_footprints_frame.h> #include <display_footprints_frame.h>
@ -128,6 +130,9 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
// Do nothing in here pertinent to a project! // Do nothing in here pertinent to a project!
InitSettings( new CVPCB_SETTINGS );
aProgram->GetSettingsManager().RegisterSettings( KifaceSettings() );
start_common( aCtlBits ); start_common( aCtlBits );
/* Now that there are no *.mod files in the standard library, this function /* Now that there are no *.mod files in the standard library, this function

View File

@ -42,6 +42,7 @@
#include <cvpcb_association.h> #include <cvpcb_association.h>
#include <cvpcb_id.h> #include <cvpcb_id.h>
#include <cvpcb_mainframe.h> #include <cvpcb_mainframe.h>
#include <cvpcb_settings.h>
#include <display_footprints_frame.h> #include <display_footprints_frame.h>
#include <listboxes.h> #include <listboxes.h>
#include <tools/cvpcb_actions.h> #include <tools/cvpcb_actions.h>
@ -51,12 +52,6 @@
wxSize const FRAME_MIN_SIZE_DU( 400, 300 ); wxSize const FRAME_MIN_SIZE_DU( 400, 300 );
wxSize const FRAME_DEFAULT_SIZE_DU( 500, 400 ); wxSize const FRAME_DEFAULT_SIZE_DU( 500, 400 );
///@{
/// \ingroup config
static const wxString FilterFootprintEntry = "FilterFootprint";
///@}
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" ) #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
@ -376,7 +371,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
} }
void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg ) void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{ {
EDA_BASE_FRAME::LoadSettings( aCfg ); EDA_BASE_FRAME::LoadSettings( aCfg );
@ -385,15 +380,18 @@ void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg )
if( m_FrameSize == wxDefaultSize ) if( m_FrameSize == wxDefaultSize )
m_FrameSize = frame_default; m_FrameSize = frame_default;
aCfg->Read( FilterFootprintEntry, &m_filteringOptions, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST ); auto cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
m_filteringOptions = cfg->m_FilterFootprint;
} }
void CVPCB_MAINFRAME::SaveSettings( wxConfigBase* aCfg ) void CVPCB_MAINFRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{ {
EDA_BASE_FRAME::SaveSettings( aCfg ); EDA_BASE_FRAME::SaveSettings( aCfg );
aCfg->Write( FilterFootprintEntry, m_filteringOptions ); auto cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
cfg->m_FilterFootprint = m_filteringOptions;
} }

View File

@ -293,9 +293,9 @@ public:
*/ */
void SaveProjectFile(); void SaveProjectFile();
void LoadSettings( wxConfigBase* aCfg ) override; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
/** /**
* Function DisplayStatus * Function DisplayStatus

68
cvpcb/cvpcb_settings.cpp Normal file
View File

@ -0,0 +1,68 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <cvpcb_settings.h>
#include <settings/parameters.h>
#include <wx/config.h>
///! Update the schema version whenever a migration is required
const int cvpcbSchemaVersion = 0;
CVPCB_SETTINGS::CVPCB_SETTINGS() :
APP_SETTINGS_BASE( "cvpcb", cvpcbSchemaVersion )
{
m_params.emplace_back( new PARAM<int>( "filter_footprint", &m_FilterFootprint, 0 ) );
addParamsForWindow( &m_FootprintViewer, "footprint_viewer" );
m_params.emplace_back(
new PARAM<bool>( "footprint_viewer.pad_fill",
&m_FootprintViewerDisplayOptions.m_DisplayPadFill, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.pad_numbers",
&m_FootprintViewerDisplayOptions.m_DisplayPadNum, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.footprint_text_fill",
&m_FootprintViewerDisplayOptions.m_DisplayModTextFill, true ) );
m_params.emplace_back( new PARAM<bool>( "footprint_viewer.graphic_items_fill",
&m_FootprintViewerDisplayOptions.m_DisplayDrawItemsFill, true ) );
}
bool CVPCB_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
ret &= fromLegacy<int>( aCfg, "FilterFootprint", "filter_footprint" );
ret &= migrateWindowConfig( aCfg, "FootprintViewerFrame", "footprint_viewer" );
ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadFi", "footprint_viewer.pad_fill" );
ret &= fromLegacy<bool>( aCfg, "FootprintViewerFrameDiPadNu", "footprint_viewer.pad_numbers" );
ret &= fromLegacy<bool>(
aCfg, "FootprintViewerFrameDiModTx", "footprint_viewer.footprint_text_fill" );
return ret;
}

51
cvpcb/cvpcb_settings.h Normal file
View File

@ -0,0 +1,51 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _CVPCB_SETTINGS_H
#define _CVPCB_SETTINGS_H
#include <pcb_display_options.h>
#include <settings/app_settings.h>
class CVPCB_SETTINGS : public APP_SETTINGS_BASE
{
public:
CVPCB_SETTINGS();
virtual ~CVPCB_SETTINGS() {}
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
WINDOW_SETTINGS m_FootprintViewer;
PCB_DISPLAY_OPTIONS m_FootprintViewerDisplayOptions;
int m_FilterFootprint;
protected:
virtual std::string getLegacyFrameName() const override { return "CvpcbFrame"; }
};
#endif

View File

@ -42,7 +42,6 @@ DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
DIALOG_CONFIG_EQUFILES_BASE( aParent ) DIALOG_CONFIG_EQUFILES_BASE( aParent )
{ {
m_Parent = aParent; m_Parent = aParent;
m_Config = Pgm().CommonSettings();
PROJECT& prj = Prj(); PROJECT& prj = Prj();
SetTitle( wxString::Format( _( "Project file: \"%s\"" ), SetTitle( wxString::Format( _( "Project file: \"%s\"" ),

View File

@ -35,7 +35,6 @@ class DIALOG_CONFIG_EQUFILES : public DIALOG_CONFIG_EQUFILES_BASE
{ {
private: private:
CVPCB_MAINFRAME* m_Parent; CVPCB_MAINFRAME* m_Parent;
wxConfigBase* m_Config;
wxString m_UserLibDirBufferImg; wxString m_UserLibDirBufferImg;
bool m_ListChanged; bool m_ListChanged;

View File

@ -28,6 +28,7 @@
#include <class_module.h> #include <class_module.h>
#include <common.h> #include <common.h>
#include <confirm.h> #include <confirm.h>
#include <cvpcb_settings.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <id.h> #include <id.h>
#include <lib_id.h> #include <lib_id.h>
@ -46,9 +47,6 @@
#include <tools/cvpcb_fpviewer_control.h> #include <tools/cvpcb_fpviewer_control.h>
#include <tools/cvpcb_fpviewer_selection_tool.h> #include <tools/cvpcb_fpviewer_selection_tool.h>
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY );
BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME ) BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow ) EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow )
@ -262,23 +260,39 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
} }
void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( wxConfigBase* aCfg ) void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{ {
PCB_BASE_FRAME::LoadSettings( aCfg ); auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxASSERT( cfg );
m_configSettings.Load( aCfg ); // mainly, load the color config EDA_DRAW_FRAME::LoadSettings( cfg );
aCfg->Read( ConfigBaseName() + AUTO_ZOOM_KEY, &m_autoZoom, true ); SetDisplayOptions( cfg->m_FootprintViewerDisplayOptions );
aCfg->Read( ConfigBaseName() + ZOOM_KEY, &m_lastZoom, 10.0 );
m_autoZoom = cfg->m_FootprintViewer.auto_zoom;
m_lastZoom = cfg->m_FootprintViewer.zoom;
} }
void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( wxConfigBase* aCfg ) void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{ {
PCB_BASE_FRAME::SaveSettings( aCfg ); auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxASSERT( cfg );
aCfg->Write( ConfigBaseName() + AUTO_ZOOM_KEY, m_autoZoom ); EDA_DRAW_FRAME::SaveSettings( cfg );
aCfg->Write( ConfigBaseName() + ZOOM_KEY, GetCanvas()->GetView()->GetScale() );
cfg->m_FootprintViewerDisplayOptions = GetDisplayOptions();
cfg->m_FootprintViewer.auto_zoom = m_autoZoom;
cfg->m_FootprintViewer.zoom = GetCanvas()->GetView()->GetScale();
}
WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
wxASSERT( cfg );
return &cfg->m_FootprintViewer;
} }
@ -401,7 +415,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
void DISPLAY_FOOTPRINTS_FRAME::updateView() void DISPLAY_FOOTPRINTS_FRAME::updateView()
{ {
PCB_DRAW_PANEL_GAL* dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetCanvas() ); PCB_DRAW_PANEL_GAL* dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetCanvas() );
dp->UseColorScheme( &Settings().Colors() ); dp->UpdateColors();
dp->DisplayBoard( GetBoard() ); dp->DisplayBoard( GetBoard() );
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );

View File

@ -66,8 +66,10 @@ public:
*/ */
void updateView(); void updateView();
void LoadSettings( wxConfigBase* aCfg ) override; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override;
/// Updates the GAL with display settings changes /// Updates the GAL with display settings changes
void ApplyDisplaySettingsToGAL(); void ApplyDisplaySettingsToGAL();

View File

@ -118,6 +118,7 @@ set( EESCHEMA_WIDGETS
set ( EESCHEMA_LIBEDIT_SRCS set ( EESCHEMA_LIBEDIT_SRCS
libedit/libedit.cpp libedit/libedit.cpp
libedit/libedit_plot_component.cpp libedit/libedit_plot_component.cpp
libedit/libedit_settings.cpp
libedit/libedit_undo_redo.cpp libedit/libedit_undo_redo.cpp
libedit/lib_edit_frame.cpp libedit/lib_edit_frame.cpp
libedit/menubar_libedit.cpp libedit/menubar_libedit.cpp
@ -147,6 +148,7 @@ set( EESCHEMA_SRCS
drc_erc_item.cpp drc_erc_item.cpp
edit_label.cpp edit_label.cpp
eeschema_config.cpp eeschema_config.cpp
eeschema_settings.cpp
erc.cpp erc.cpp
fields_grid_table.cpp fields_grid_table.cpp
files-io.cpp files-io.cpp

View File

@ -65,6 +65,7 @@
#include <algorithm> #include <algorithm>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/ee_selection_tool.h> #include <tools/ee_selection_tool.h>
#include <eeschema_settings.h>
#define FIELD_PADDING Mils2iu( 10 ) // arbitrarily chosen for aesthetics #define FIELD_PADDING Mils2iu( 10 ) // arbitrarily chosen for aesthetics
#define FIELD_PADDING_ALIGNED Mils2iu( 18 ) // aligns 50 mil text to a 100 mil grid #define FIELD_PADDING_ALIGNED Mils2iu( 18 ) // aligns 50 mil text to a 100 mil grid
@ -126,8 +127,10 @@ public:
:m_screen( aScreen ), m_component( aComponent ) :m_screen( aScreen ), m_component( aComponent )
{ {
m_component->GetFields( m_fields, /* aVisibleOnly */ true ); m_component->GetFields( m_fields, /* aVisibleOnly */ true );
Kiface().KifaceSettings()->Read( AutoplaceJustifyEntry, &m_allow_rejustify, true );
Kiface().KifaceSettings()->Read( AutoplaceAlignEntry, &m_align_to_grid, false ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_allow_rejustify = cfg->m_AutoplaceFields.allow_rejustify;
m_align_to_grid = cfg->m_AutoplaceFields.align_to_grid;
m_comp_bbox = m_component->GetBodyBoundingBox(); m_comp_bbox = m_component->GetBodyBoundingBox();
m_fbox_size = ComputeFBoxSize( /* aDynamic */ true ); m_fbox_size = ComputeFBoxSize( /* aDynamic */ true );

View File

@ -26,7 +26,6 @@
#include <unordered_map> #include <unordered_map>
#include <profile.h> #include <profile.h>
#include <advanced_config.h>
#include <common.h> #include <common.h>
#include <erc.h> #include <erc.h>
#include <sch_bus_entry.h> #include <sch_bus_entry.h>
@ -39,6 +38,7 @@
#include <sch_sheet.h> #include <sch_sheet.h>
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <sch_text.h> #include <sch_text.h>
#include <advanced_config.h>
#include <connection_graph.h> #include <connection_graph.h>

View File

@ -36,19 +36,14 @@
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <dialog_annotate_base.h> #include <dialog_annotate_base.h>
#include <eeschema_settings.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <wx_html_report_panel.h> #include <wx_html_report_panel.h>
#define KEY_ANNOTATE_SORT_OPTION wxT( "AnnotateSortOption" )
#define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" )
#define KEY_ANNOTATE_MESSAGES_FILTER wxT( "AnnotateFilterMsg" )
// A window name for the annotate dialog to retrieve is if not destroyed // A window name for the annotate dialog to retrieve is if not destroyed
#define DLG_WINDOW_NAME "DialogAnnotateWindowName" #define DLG_WINDOW_NAME "DialogAnnotateWindowName"
class wxConfigBase;
/** /**
* DIALOG_ANNOTATE: a dialog to set/clear reference designators, * DIALOG_ANNOTATE: a dialog to set/clear reference designators,
* of a schematic hierarchy, with different options * of a schematic hierarchy, with different options
@ -61,7 +56,6 @@ public:
private: private:
SCH_EDIT_FRAME* m_Parent; SCH_EDIT_FRAME* m_Parent;
wxConfigBase* m_Config;
/// Initialises member variables /// Initialises member variables
void InitValues(); void InitValues();
@ -128,24 +122,24 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& messag
DIALOG_ANNOTATE::~DIALOG_ANNOTATE() DIALOG_ANNOTATE::~DIALOG_ANNOTATE()
{ {
m_Config->Write( KEY_ANNOTATE_SORT_OPTION, GetSortOrder() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_Config->Write( KEY_ANNOTATE_ALGO_OPTION, GetAnnotateAlgo() );
m_Config->Write( KEY_ANNOTATE_MESSAGES_FILTER, cfg->m_AnnotatePanel.sort_order = GetSortOrder();
(long) m_MessageWindow->GetVisibleSeverities() ); cfg->m_AnnotatePanel.method = GetAnnotateAlgo();
cfg->m_AnnotatePanel.messages_filter = m_MessageWindow->GetVisibleSeverities();
} }
void DIALOG_ANNOTATE::InitValues() void DIALOG_ANNOTATE::InitValues()
{ {
m_Config = Kiface().KifaceSettings(); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
long option; int option;
// These are always reset to attempt to keep the user out of trouble... // These are always reset to attempt to keep the user out of trouble...
m_rbScope->SetSelection( 0 ); m_rbScope->SetSelection( 0 );
m_rbOptions->SetSelection( 0 ); m_rbOptions->SetSelection( 0 );
m_Config->Read( KEY_ANNOTATE_SORT_OPTION, &option, 0L ); option = cfg->m_AnnotatePanel.sort_order;
switch( option ) switch( option )
{ {
@ -158,7 +152,7 @@ void DIALOG_ANNOTATE::InitValues()
break; break;
} }
m_Config->Read( KEY_ANNOTATE_ALGO_OPTION, &option, 0L ); option = cfg->m_AnnotatePanel.method;
switch( option ) switch( option )
{ {
@ -179,8 +173,7 @@ void DIALOG_ANNOTATE::InitValues()
annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) ); annotate_down_right_bitmap->SetBitmap( KiBitmap( annotate_down_right_xpm ) );
annotate_right_down_bitmap->SetBitmap( KiBitmap( annotate_right_down_xpm ) ); annotate_right_down_bitmap->SetBitmap( KiBitmap( annotate_right_down_xpm ) );
int severities = m_Config->Read( KEY_ANNOTATE_MESSAGES_FILTER, -1l ); m_MessageWindow->SetVisibleSeverities( cfg->m_AnnotatePanel.messages_filter );
m_MessageWindow->SetVisibleSeverities( severities );
m_MessageWindow->MsgPanelSetMinSize( wxSize( -1, 160 ) ); m_MessageWindow->MsgPanelSetMinSize( wxSize( -1, 160 ) );
} }

View File

@ -28,29 +28,27 @@
*/ */
#include <fctsys.h> #include <bom_plugins.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <confirm.h> #include <confirm.h>
#include <dialog_bom_base.h>
#include <dialog_helpers.h>
#include <eeschema_settings.h>
#include <fctsys.h>
#include <gestfich.h> #include <gestfich.h>
#include <sch_edit_frame.h> #include <html_messagebox.h>
#include <i18n_utility.h> // for _HKI definition used in dialog_bom_help_md.h
#include <invoke_sch_dialog.h>
#include <kiface_i.h>
#include <netlist.h> #include <netlist.h>
#include <netlist_exporter_generic.h> #include <netlist_exporter_generic.h>
#include <invoke_sch_dialog.h> #include <pgm_base.h>
#include <dialog_helpers.h>
#include <dialog_bom_base.h>
#include <html_messagebox.h>
#include <reporter.h> #include <reporter.h>
#include <bom_plugins.h> #include <sch_edit_frame.h>
#include <i18n_utility.h> // for _HKI definition used in dialog_bom_help_md.h
#include <dialogs/dialog_bom_cfg_lexer.h> #include <dialogs/dialog_bom_cfg_lexer.h>
static constexpr wxChar BOM_TRACE[] = wxT( "BOM_GENERATORS" ); static constexpr wxChar BOM_TRACE[] = wxT( "BOM_GENERATORS" );
static constexpr wxChar BOM_GENERATORS_KEY[] = wxT( "bom_plugins" );
static constexpr wxChar BOM_GENERATOR_SELECTED_KEY[] = wxT( "bom_plugin_selected" );
wxString s_bomHelpInfo = wxString s_bomHelpInfo =
#include <dialog_bom_help_md.h> #include <dialog_bom_help_md.h>
; ;
@ -175,7 +173,6 @@ class DIALOG_BOM : public DIALOG_BOM_BASE
private: private:
SCH_EDIT_FRAME* m_parent; SCH_EDIT_FRAME* m_parent;
BOM_GENERATOR_ARRAY m_generators; BOM_GENERATOR_ARRAY m_generators;
wxConfigBase* m_config; // to store the "plugins"
bool m_initialized; bool m_initialized;
public: public:
@ -225,7 +222,6 @@ DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) :
DIALOG_BOM_BASE( parent ) DIALOG_BOM_BASE( parent )
{ {
m_parent = parent; m_parent = parent;
m_config = Kiface().KifaceSettings();
m_initialized = false; m_initialized = false;
m_buttonAddGenerator->SetBitmap( KiBitmap( small_plus_xpm ) ); m_buttonAddGenerator->SetBitmap( KiBitmap( small_plus_xpm ) );
@ -251,6 +247,8 @@ DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) :
DIALOG_BOM::~DIALOG_BOM() DIALOG_BOM::~DIALOG_BOM()
{ {
// TODO(JE) maybe unpack this into JSON instead of sexpr
// Save the plugin descriptions in config. // Save the plugin descriptions in config.
// The config stores only one string, so we save the plugins inside a S-expr: // The config stores only one string, so we save the plugins inside a S-expr:
// ( plugins // ( plugins
@ -289,19 +287,20 @@ DIALOG_BOM::~DIALOG_BOM()
wxString list( FROM_UTF8( writer.GetString().c_str() ) ); wxString list( FROM_UTF8( writer.GetString().c_str() ) );
m_config->Write( BOM_GENERATORS_KEY, list ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxString active_plugin_name = m_lbGenerators->GetStringSelection( ); cfg->m_BomPanel.plugins = list.ToStdString();
m_config->Write( BOM_GENERATOR_SELECTED_KEY, active_plugin_name ); cfg->m_BomPanel.selected_plugin = m_lbGenerators->GetStringSelection().ToStdString();
} }
// Read the initialized plugins in config and fill the list of names // Read the initialized plugins in config and fill the list of names
void DIALOG_BOM::installGeneratorsList() void DIALOG_BOM::installGeneratorsList()
{ {
wxString list, active_plugin_name; auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_config->Read( BOM_GENERATORS_KEY, &list );
m_config->Read( BOM_GENERATOR_SELECTED_KEY, &active_plugin_name ); wxString list = cfg->m_BomPanel.plugins;
wxString active_plugin_name = cfg->m_BomPanel.selected_plugin;
if( !list.IsEmpty() ) if( !list.IsEmpty() )
{ {

View File

@ -22,26 +22,27 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <dialog_choose_component.h>
#include <algorithm> #include <algorithm>
#include <wx/utils.h> #include <class_libentry.h>
#include <class_library.h>
#include <dialog_choose_component.h>
#include <eeschema_settings.h>
#include <kiface_i.h>
#include <sch_base_frame.h>
#include <symbol_lib_table.h>
#include <template_fieldnames.h>
#include <widgets/footprint_preview_widget.h>
#include <widgets/footprint_select_widget.h>
#include <widgets/lib_tree.h>
#include <widgets/symbol_preview_widget.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/clipbrd.h>
#include <wx/dataview.h> #include <wx/dataview.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/splitter.h> #include <wx/splitter.h>
#include <wx/timer.h> #include <wx/timer.h>
#include <class_library.h> #include <wx/utils.h>
#include <sch_base_frame.h>
#include <template_fieldnames.h>
#include <symbol_lib_table.h>
#include <widgets/lib_tree.h>
#include <widgets/footprint_preview_widget.h>
#include <widgets/footprint_select_widget.h>
#include <widgets/symbol_preview_widget.h>
#include <wx/clipbrd.h>
#include <kiface_i.h>
#include <class_libentry.h>
#define SYM_CHOOSER_HSASH wxT( "SymbolChooserHSashPosition" ) #define SYM_CHOOSER_HSASH wxT( "SymbolChooserHSashPosition" )
#define SYM_CHOOSER_VSASH wxT( "SymbolChooserVSashPosition" ) #define SYM_CHOOSER_VSASH wxT( "SymbolChooserVSashPosition" )
@ -73,8 +74,6 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
m_show_footprints( aShowFootprints ), m_show_footprints( aShowFootprints ),
m_external_browser_requested( false ) m_external_browser_requested( false )
{ {
m_config = Kiface().KifaceSettings();
auto sizer = new wxBoxSizer( wxVERTICAL ); auto sizer = new wxBoxSizer( wxVERTICAL );
// Use a slightly different layout, with a details pane spanning the entire window, // Use a slightly different layout, with a details pane spanning the entire window,
@ -148,16 +147,21 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
Layout(); Layout();
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
// We specify the width of the right window (m_symbol_view_panel), because specify // We specify the width of the right window (m_symbol_view_panel), because specify
// the width of the left window does not work as expected when SetSashGravity() is called // the width of the left window does not work as expected when SetSashGravity() is called
m_hsplitter->SetSashPosition( m_config->Read( SYM_CHOOSER_HSASH, HorizPixelsFromDU( 220 ) ) ); m_hsplitter->SetSashPosition( cfg->m_SymChooserPanel.sash_pos_h > 0 ?
cfg->m_SymChooserPanel.sash_pos_h : HorizPixelsFromDU( 220 ) );
if( m_vsplitter ) if( m_vsplitter )
m_vsplitter->SetSashPosition( m_config->Read( SYM_CHOOSER_VSASH, m_vsplitter->SetSashPosition( cfg->m_SymChooserPanel.sash_pos_v > 0 ?
VertPixelsFromDU( 230 ) ) ); cfg->m_SymChooserPanel.sash_pos_v : VertPixelsFromDU( 230 ) );
wxSize dlgSize( m_config->Read( SYM_CHOOSER_WIDTH_KEY, HorizPixelsFromDU( 390 ) ), wxSize dlgSize( cfg->m_SymChooserPanel.width > 0 ?
m_config->Read( SYM_CHOOSER_HEIGHT_KEY, VertPixelsFromDU( 300 ) ) ); cfg->m_SymChooserPanel.width : HorizPixelsFromDU( 390 ),
cfg->m_SymChooserPanel.height > 0 ?
cfg->m_SymChooserPanel.height : VertPixelsFromDU( 300 ) );
SetSize( dlgSize ); SetSize( dlgSize );
SetInitialFocus( m_tree ); SetInitialFocus( m_tree );
@ -207,16 +211,18 @@ DIALOG_CHOOSE_COMPONENT::~DIALOG_CHOOSE_COMPONENT()
m_dbl_click_timer->Stop(); m_dbl_click_timer->Stop();
delete m_dbl_click_timer; delete m_dbl_click_timer;
m_config->Write( SYM_CHOOSER_WIDTH_KEY, GetSize().x ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_config->Write( SYM_CHOOSER_HEIGHT_KEY, GetSize().y );
m_config->Write( SYM_CHOOSER_KEEP_SYM_KEY, m_keepSymbol->GetValue() ); cfg->m_SymChooserPanel.width = GetSize().x;
m_config->Write( SYM_CHOOSER_USE_UNITS_KEY, m_useUnits->GetValue() ); cfg->m_SymChooserPanel.height = GetSize().y;
m_config->Write( SYM_CHOOSER_HSASH, m_hsplitter->GetSashPosition() ); cfg->m_SymChooserPanel.keep_symbol = m_keepSymbol->GetValue();
cfg->m_SymChooserPanel.place_all_units = m_useUnits->GetValue();
cfg->m_SymChooserPanel.sash_pos_h = m_hsplitter->GetSashPosition();
if( m_vsplitter ) if( m_vsplitter )
m_config->Write( SYM_CHOOSER_VSASH, m_vsplitter->GetSashPosition() ); cfg->m_SymChooserPanel.sash_pos_v = m_vsplitter->GetSashPosition();
} }
@ -254,14 +260,16 @@ wxPanel* DIALOG_CHOOSE_COMPONENT::ConstructRightPanel( wxWindow* aParent )
sizer->Add( m_symbol_preview, 1, wxEXPAND | wxTOP | wxRIGHT, 5 ); sizer->Add( m_symbol_preview, 1, wxEXPAND | wxTOP | wxRIGHT, 5 );
} }
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_keepSymbol = new wxCheckBox( panel, 1000, _("Multi-Symbol Placement"), wxDefaultPosition, m_keepSymbol = new wxCheckBox( panel, 1000, _("Multi-Symbol Placement"), wxDefaultPosition,
wxDefaultSize, wxALIGN_RIGHT ); wxDefaultSize, wxALIGN_RIGHT );
m_keepSymbol->SetValue( m_config->ReadBool( SYM_CHOOSER_KEEP_SYM_KEY, false ) ); m_keepSymbol->SetValue( cfg->m_SymChooserPanel.keep_symbol );
m_keepSymbol->SetToolTip( _( "Place multiple copies of the symbol." ) ); m_keepSymbol->SetToolTip( _( "Place multiple copies of the symbol." ) );
m_useUnits = new wxCheckBox( panel, 1000, _("Place all units"), wxDefaultPosition, m_useUnits = new wxCheckBox( panel, 1000, _("Place all units"), wxDefaultPosition,
wxDefaultSize, wxALIGN_RIGHT ); wxDefaultSize, wxALIGN_RIGHT );
m_useUnits->SetValue( m_config->ReadBool( SYM_CHOOSER_USE_UNITS_KEY, true ) ); m_useUnits->SetValue( cfg->m_SymChooserPanel.place_all_units );
m_useUnits->SetToolTip( _( "Sequentially place all units of the symbol." ) ); m_useUnits->SetToolTip( _( "Sequentially place all units of the symbol." ) );
auto fgSizer = new wxFlexGridSizer( 0, 2, 0, 1 ); auto fgSizer = new wxFlexGridSizer( 0, 2, 0, 1 );

View File

@ -200,8 +200,6 @@ protected:
*/ */
void PopulateFootprintSelector( LIB_ID const& aLibId ); void PopulateFootprintSelector( LIB_ID const& aLibId );
wxConfigBase* m_config;
wxTimer* m_dbl_click_timer; wxTimer* m_dbl_click_timer;
SYMBOL_PREVIEW_WIDGET* m_symbol_preview; SYMBOL_PREVIEW_WIDGET* m_symbol_preview;
wxButton* m_browser_button; wxButton* m_browser_button;

View File

@ -21,26 +21,26 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <fctsys.h> #include <bitmaps.h>
#include <kiway.h> #include <class_libentry.h>
#include <common.h> #include <common.h>
#include <confirm.h> #include <confirm.h>
#include <pgm_base.h> #include <dialog_helpers.h>
#include <kiface_i.h>
#include <dialog_text_entry.h> #include <dialog_text_entry.h>
#include <math/util.h> // for KiROUND #include <eeschema_settings.h>
#include <fctsys.h>
#include <general.h> #include <general.h>
#include <widgets/wx_grid.h> #include <kiface_i.h>
#include <widgets/grid_text_button_helpers.h> #include <kiway.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <lib_manager.h> #include <lib_manager.h>
#include <class_libentry.h> #include <math/util.h> // for KiROUND
#include <symbol_lib_table.h> #include <pgm_base.h>
#include <sch_item.h>
#include <sch_component.h> #include <sch_component.h>
#include <dialog_helpers.h> #include <sch_item.h>
#include <bitmaps.h> #include <symbol_lib_table.h>
#include <widgets/grid_text_button_helpers.h>
#include <widgets/wx_grid.h>
#ifdef KICAD_SPICE #ifdef KICAD_SPICE
#include <dialog_spice_model.h> #include <dialog_spice_model.h>
@ -48,10 +48,10 @@
#endif /* KICAD_SPICE */ #endif /* KICAD_SPICE */
#include <dialog_edit_component_in_lib.h> #include <dialog_edit_component_in_lib.h>
#include <settings/settings_manager.h>
#include <libedit_settings.h>
#define LibEditFieldsShownColumnsKey wxT( "LibEditFieldsShownColumns" )
int DIALOG_EDIT_COMPONENT_IN_LIBRARY::m_lastOpenedPage = 0; int DIALOG_EDIT_COMPONENT_IN_LIBRARY::m_lastOpenedPage = 0;
DIALOG_EDIT_COMPONENT_IN_LIBRARY::LAST_LAYOUT DIALOG_EDIT_COMPONENT_IN_LIBRARY::LAST_LAYOUT
DIALOG_EDIT_COMPONENT_IN_LIBRARY::m_lastLayout = DIALOG_EDIT_COMPONENT_IN_LIBRARY::NONE; DIALOG_EDIT_COMPONENT_IN_LIBRARY::m_lastLayout = DIALOG_EDIT_COMPONENT_IN_LIBRARY::NONE;
@ -70,8 +70,6 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( LIB_EDIT_FRA
m_delayedFocusPage( -1 ), m_delayedFocusPage( -1 ),
m_width( 0 ) m_width( 0 )
{ {
m_config = Kiface().KifaceSettings();
// Give a bit more room for combobox editors // Give a bit more room for combobox editors
m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_libEntry ); m_fields = new FIELDS_GRID_TABLE<LIB_FIELD>( this, aParent, m_libEntry );
@ -79,8 +77,8 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( LIB_EDIT_FRA
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
// Show/hide columns according to the user's preference // Show/hide columns according to the user's preference
m_config->Read( LibEditFieldsShownColumnsKey, &m_shownColumns, wxT( "0 1 2 3 4 5 6 7" ) ); auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
m_grid->ShowHideColumns( m_shownColumns ); m_grid->ShowHideColumns( cfg->m_EditComponentVisibleColumns );
wxGridCellAttr* attr = new wxGridCellAttr; wxGridCellAttr* attr = new wxGridCellAttr;
attr->SetEditor( new GRID_CELL_URL_EDITOR( this ) ); attr->SetEditor( new GRID_CELL_URL_EDITOR( this ) );
@ -132,7 +130,8 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY()
{ {
m_lastOpenedPage = m_NoteBook->GetSelection( ); m_lastOpenedPage = m_NoteBook->GetSelection( );
m_config->Write( LibEditFieldsShownColumnsKey, m_grid->GetShownColumns() ); auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
cfg->m_EditComponentVisibleColumns = m_grid->GetShownColumns();
// Prevents crash bug in wxGrid's d'tor // Prevents crash bug in wxGrid's d'tor
m_grid->DestroyTable( m_fields ); m_grid->DestroyTable( m_fields );

View File

@ -48,8 +48,6 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY: public DIALOG_EDIT_COMPONENT_IN_LIBRARY_
static LAST_LAYOUT m_lastLayout; static LAST_LAYOUT m_lastLayout;
public: public:
wxConfigBase* m_config;
LIB_EDIT_FRAME* m_Parent; LIB_EDIT_FRAME* m_Parent;
LIB_PART* m_libEntry; LIB_PART* m_libEntry;

View File

@ -34,6 +34,7 @@
#include <widgets/wx_grid.h> #include <widgets/wx_grid.h>
#include <class_library.h> #include <class_library.h>
#include <eeschema_settings.h>
#include <fields_grid_table.h> #include <fields_grid_table.h>
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <sch_draw_panel.h> #include <sch_draw_panel.h>
@ -48,15 +49,10 @@
#endif /* KICAD_SPICE */ #endif /* KICAD_SPICE */
#define SymbolFieldsShownColumnsKey wxT( "SymbolFieldsShownColumns" )
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT_FRAME* aParent, DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT_FRAME* aParent,
SCH_COMPONENT* aComponent ) : SCH_COMPONENT* aComponent ) :
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( aParent ) DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( aParent )
{ {
m_config = Kiface().KifaceSettings();
m_cmp = aComponent; m_cmp = aComponent;
m_part = m_cmp->GetPartRef().get(); m_part = m_cmp->GetPartRef().get();
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_part ); m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_part );
@ -84,7 +80,8 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) ); m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
// Show/hide columns according to user's preference // Show/hide columns according to user's preference
m_config->Read( SymbolFieldsShownColumnsKey, &m_shownColumns, wxT( "0 1 2 3 4 5 6 7" ) ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_shownColumns = cfg->m_Appearance.edit_component_visible_columns;
m_grid->ShowHideColumns( m_shownColumns ); m_grid->ShowHideColumns( m_shownColumns );
wxToolTip::Enable( true ); wxToolTip::Enable( true );
@ -108,7 +105,8 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC() DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC()
{ {
m_config->Write( SymbolFieldsShownColumnsKey, m_grid->GetShownColumns() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_Appearance.edit_component_visible_columns = m_grid->GetShownColumns();
// Prevents crash bug in wxGrid's d'tor // Prevents crash bug in wxGrid's d'tor
m_grid->DestroyTable( m_fields ); m_grid->DestroyTable( m_fields );

View File

@ -49,8 +49,6 @@ public:
SCH_EDIT_FRAME* GetParent(); SCH_EDIT_FRAME* GetParent();
private: private:
wxConfigBase* m_config;
SCH_COMPONENT* m_cmp; SCH_COMPONENT* m_cmp;
LIB_PART* m_part; LIB_PART* m_part;

View File

@ -23,23 +23,24 @@
*/ */
#include <wx/msgdlg.h>
#include <wx/grid.h>
#include <widgets/wx_grid.h>
#include <base_units.h> #include <base_units.h>
#include <confirm.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <class_library.h>
#include <confirm.h>
#include <eda_doc.h>
#include <eeschema_settings.h>
#include <general.h>
#include <grid_tricks.h> #include <grid_tricks.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <kiface_i.h>
#include <refdes_utils.h> #include <refdes_utils.h>
#include <general.h>
#include <class_library.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <sch_reference_list.h> #include <sch_reference_list.h>
#include <tools/sch_editor_control.h> #include <tools/sch_editor_control.h>
#include <kiface_i.h>
#include <eda_doc.h>
#include <widgets/grid_text_button_helpers.h> #include <widgets/grid_text_button_helpers.h>
#include <widgets/wx_grid.h>
#include <wx/grid.h>
#include <wx/msgdlg.h>
#include "dialog_fields_editor_global.h" #include "dialog_fields_editor_global.h"
@ -666,7 +667,6 @@ public:
DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent ) : DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent ) :
DIALOG_FIELDS_EDITOR_GLOBAL_BASE( parent ), DIALOG_FIELDS_EDITOR_GLOBAL_BASE( parent ),
m_config( Kiface().KifaceSettings() ),
m_parent( parent ) m_parent( parent )
{ {
wxSize defaultDlgSize = ConvertDialogToPixels( wxSize( 600, 300 ) ); wxSize defaultDlgSize = ConvertDialogToPixels( wxSize( 600, 300 ) );
@ -884,12 +884,31 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::AddField( const wxString& aName,
wxVector<wxVariant> fieldsCtrlRow; wxVector<wxVariant> fieldsCtrlRow;
m_config->Read( "SymbolFieldEditor/Show/" + aName, &defaultShow ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_config->Read( "SymbolFieldEditor/GroupBy/" + aName, &defaultSortBy ); bool show = defaultShow;
bool sort_by = defaultSortBy;
std::string key( aName.ToUTF8() );
try
{
show = cfg->m_FieldEditorPanel.fields_show.at( key );
}
catch( std::out_of_range& )
{
}
try
{
show = cfg->m_FieldEditorPanel.fields_group_by.at( key );
}
catch( std::out_of_range& )
{
}
fieldsCtrlRow.push_back( wxVariant( aName ) ); fieldsCtrlRow.push_back( wxVariant( aName ) );
fieldsCtrlRow.push_back( wxVariant( defaultShow ) ); fieldsCtrlRow.push_back( wxVariant( show ) );
fieldsCtrlRow.push_back( wxVariant( defaultSortBy ) ); fieldsCtrlRow.push_back( wxVariant( sort_by ) );
m_fieldsCtrl->AppendItem( fieldsCtrlRow ); m_fieldsCtrl->AppendItem( fieldsCtrlRow );
} }
@ -912,7 +931,8 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames()
} }
// Force References to always be shown // Force References to always be shown
m_config->Write( "SymbolFieldEditor/Show/Reference", true ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_FieldEditorPanel.fields_show["Reference"] = true;
// *DO NOT* use translated mandatory field names: // *DO NOT* use translated mandatory field names:
// They are also used as keyword to find fields in component list. // They are also used as keyword to find fields in component list.
@ -964,7 +984,10 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnAddField( wxCommandEvent& event )
} }
} }
m_config->Write( "SymbolFieldEditor/Show/" + fieldName, true ); std::string key( fieldName.ToUTF8() );
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_FieldEditorPanel.fields_show[key] = true;
AddField( fieldName, true, false ); AddField( fieldName, true, false );
@ -983,6 +1006,7 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnAddField( wxCommandEvent& event )
void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event ) void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event )
{ {
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxDataViewItem item = event.GetItem(); wxDataViewItem item = event.GetItem();
int row = m_fieldsCtrl->ItemToRow( item ); int row = m_fieldsCtrl->ItemToRow( item );
@ -1005,8 +1029,8 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event )
m_fieldsCtrl->SetToggleValue( value, row, col ); m_fieldsCtrl->SetToggleValue( value, row, col );
} }
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN ); std::string fieldName( m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN ).ToUTF8() );
m_config->Write( "SymbolFieldEditor/Show/" + fieldName, value ); cfg->m_FieldEditorPanel.fields_show[fieldName] = value;
if( value ) if( value )
m_grid->ShowCol( row ); m_grid->ShowCol( row );
@ -1018,8 +1042,9 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event )
case GROUP_BY_COLUMN: case GROUP_BY_COLUMN:
{ {
bool value = m_fieldsCtrl->GetToggleValue( row, col ); bool value = m_fieldsCtrl->GetToggleValue( row, col );
wxString fieldName = m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN ); std::string fieldName( m_fieldsCtrl->GetTextValue( row, FIELD_NAME_COLUMN ).ToUTF8() );
m_config->Write( "SymbolFieldEditor/GroupBy/" + fieldName, value ); cfg->m_FieldEditorPanel.fields_group_by[fieldName] = value;
m_dataModel->RebuildRows( m_groupComponentsBox, m_fieldsCtrl ); m_dataModel->RebuildRows( m_groupComponentsBox, m_fieldsCtrl );
m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() ); m_dataModel->Sort( m_grid->GetSortingColumn(), m_grid->IsSortOrderAscending() );
m_grid->ForceRefresh(); m_grid->ForceRefresh();

View File

@ -44,7 +44,6 @@ public:
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
private: private:
wxConfigBase* m_config;
SCH_EDIT_FRAME* m_parent; SCH_EDIT_FRAME* m_parent;
int m_showColWidth; int m_showColWidth;
int m_groupByColWidth; int m_groupByColWidth;

View File

@ -21,20 +21,20 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <connection_graph.h>
#include <dialog_global_edit_text_and_graphics_base.h>
#include <fctsys.h> #include <fctsys.h>
#include <kicad_string.h> #include <kicad_string.h>
#include <widgets/unit_binder.h> #include <sch_component.h>
#include <sch_connection.h>
#include <sch_edit_frame.h>
#include <sch_line.h>
#include <sch_sheet.h>
#include <advanced_config.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/ee_selection_tool.h> #include <tools/ee_selection_tool.h>
#include <tools/sch_edit_tool.h> #include <tools/sch_edit_tool.h>
#include <sch_edit_frame.h> #include <widgets/unit_binder.h>
#include <sch_component.h>
#include <sch_line.h>
#include <sch_connection.h>
#include <sch_sheet.h>
#include <connection_graph.h>
#include <dialog_global_edit_text_and_graphics_base.h>
#include <advanced_config.h>
static bool g_modifyReferences; static bool g_modifyReferences;
static bool g_modifyValues; static bool g_modifyValues;

View File

@ -22,21 +22,20 @@
*/ */
#include "dialog_lib_edit_pin_table.h" #include "dialog_lib_edit_pin_table.h"
#include "grid_tricks.h"
#include "lib_pin.h" #include "lib_pin.h"
#include "pin_number.h" #include "pin_number.h"
#include "grid_tricks.h"
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h>
#include <queue>
#include <base_units.h> #include <base_units.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <wx/bmpcbox.h>
#include <kiface_i.h>
#include <kicad_string.h>
#include <confirm.h> #include <confirm.h>
#include <kicad_string.h>
#include <kiface_i.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <libedit_settings.h>
#define PinTableShownColumnsKey wxT( "PinTableShownColumns" ) #include <queue>
#include <widgets/grid_icon_text_helpers.h>
#include <widgets/wx_grid.h>
#include <wx/bmpcbox.h>
static std::vector<BITMAP_DEF> g_typeIcons; static std::vector<BITMAP_DEF> g_typeIcons;
@ -393,8 +392,6 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( LIB_EDIT_FRAME* parent, LI
m_editFrame( parent ), m_editFrame( parent ),
m_part( aPart ) m_part( aPart )
{ {
m_config = Kiface().KifaceSettings();
if( g_typeNames.empty()) if( g_typeNames.empty())
{ {
for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i ) for( unsigned i = 0; i < ELECTRICAL_PINTYPES_TOTAL; ++i )
@ -428,7 +425,9 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( LIB_EDIT_FRAME* parent, LI
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
// Show/hide columns according to the user's preference // Show/hide columns according to the user's preference
m_config->Read( PinTableShownColumnsKey, &m_columnsShown, wxT( "0 1 2 3 4 8 9" ) ); auto cfg = parent->GetSettings();
m_columnsShown = cfg->m_PinTableVisibleColumns;
m_grid->ShowHideColumns( m_columnsShown ); m_grid->ShowHideColumns( m_columnsShown );
// Set special attributes // Set special attributes
@ -480,7 +479,8 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( LIB_EDIT_FRAME* parent, LI
DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE() DIALOG_LIB_EDIT_PIN_TABLE::~DIALOG_LIB_EDIT_PIN_TABLE()
{ {
m_config->Write( PinTableShownColumnsKey, m_grid->GetShownColumns() ); auto cfg = m_editFrame->GetSettings();
cfg->m_PinTableVisibleColumns = m_grid->GetShownColumns().ToStdString();
// Disconnect Events // Disconnect Events
m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this ); m_grid->Disconnect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this );

View File

@ -72,7 +72,6 @@ protected:
void adjustGridColumns( int aWidth ); void adjustGridColumns( int aWidth );
LIB_EDIT_FRAME* m_editFrame; LIB_EDIT_FRAME* m_editFrame;
wxConfigBase* m_config;
bool m_initialized = false; bool m_initialized = false;
int m_originalColWidths[ COL_COUNT ]; int m_originalColWidths[ COL_COUNT ];
wxString m_columnsShown; wxString m_columnsShown;

View File

@ -44,6 +44,7 @@
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <invoke_sch_dialog.h> #include <invoke_sch_dialog.h>
#include <netlist_exporters/netlist_exporter_pspice.h> #include <netlist_exporters/netlist_exporter_pspice.h>
#include <eeschema_settings.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <wx/regex.h> #include <wx/regex.h>
@ -113,7 +114,6 @@ public:
protected: protected:
bool m_asFormatSelected; bool m_asFormatSelected;
wxConfigBase* m_config;
public: public:
// Constructor and destructor // Constructor and destructor
@ -153,16 +153,6 @@ private:
*/ */
void WriteCurrentNetlistSetup(); void WriteCurrentNetlistSetup();
/**
* Function UserNetlistTypeName
* to retrieve user netlist type names
* @param first_item = true: return first name of the list, false = return next
* @return a wxString : name of the type netlist or empty string
* this function must be called first with "first_item" = true
* and after with "first_item" = false to get all the other existing netlist names
*/
const wxString UserNetlistTypeName( bool first_item );
/** /**
* Function FilenamePrms * Function FilenamePrms
* returns the filename extension and the wildcard string for this curr * returns the filename extension and the wildcard string for this curr
@ -213,13 +203,6 @@ enum id_netlist {
}; };
// keywords for configuration:
#define CUSTOM_NETLIST_TITLE wxT( "CustomNetlistTitle" )
#define CUSTOM_NETLIST_COMMAND wxT( "CustomNetlistCommand" )
#define NETLIST_USE_DEFAULT_NETNAME wxT( "NetlistUseDefaultNetname" )
#define NETLIST_PSPICE_USE_NETNAME wxT( "SpiceUseNetNames" )
BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE ) BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE )
EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT, NETLIST_DIALOG::SelectDefaultNetlistType ) EVT_CHECKBOX( ID_CURRENT_FORMAT_IS_DEFAULT, NETLIST_DIALOG::SelectDefaultNetlistType )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -275,10 +258,7 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
NETLIST_DIALOG_BASE( parent ) NETLIST_DIALOG_BASE( parent )
{ {
m_Parent = parent; m_Parent = parent;
m_config = Kiface().KifaceSettings();
long tmp;
m_config->Read( NETLIST_USE_DEFAULT_NETNAME, &tmp, 0l );
m_DefaultNetFmtName = m_Parent->GetNetListFormatName(); m_DefaultNetFmtName = m_Parent->GetNetListFormatName();
for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType) for( NETLIST_PAGE_DIALOG*& page : m_PanelNetType)
@ -323,22 +303,6 @@ NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) :
} }
const wxString NETLIST_DIALOG::UserNetlistTypeName( bool first_item )
{
static int index;
if( first_item )
index = 0;
else
index++;
wxString msg = CUSTOM_NETLIST_TITLE;
msg << index + 1;
return m_config->Read( msg );
}
void NETLIST_DIALOG::InstallPageSpice() void NETLIST_DIALOG::InstallPageSpice()
{ {
NETLIST_PAGE_DIALOG* page = m_PanelNetType[PANELSPICE] = NETLIST_PAGE_DIALOG* page = m_PanelNetType[PANELSPICE] =
@ -354,24 +318,25 @@ void NETLIST_DIALOG::InstallPageSpice()
void NETLIST_DIALOG::InstallCustomPages() void NETLIST_DIALOG::InstallCustomPages()
{ {
int ii;
wxString title;
NETLIST_PAGE_DIALOG* currPage; NETLIST_PAGE_DIALOG* currPage;
for( ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
{
title = UserNetlistTypeName( ii == 0 ? true : false );
if( title.IsEmpty() ) for( size_t i = 0;
i < CUSTOMPANEL_COUNTMAX && i < cfg->m_NetlistPanel.custom_command_titles.size(); i++ )
{
// pairs of (title, command) are stored
wxString title = cfg->m_NetlistPanel.custom_command_titles[i];
if( i >= cfg->m_NetlistPanel.custom_command_paths.size() )
break; // No more panel to install break; // No more panel to install
// Install a plugin panel wxString command = cfg->m_NetlistPanel.custom_command_paths[i];
wxString msg = CUSTOM_NETLIST_COMMAND;
msg << ii + 1;
wxString command = m_config->Read( msg );
currPage = AddOneCustomPage( title, command, (NETLIST_TYPE_ID)(NET_TYPE_CUSTOM1 + ii) ); currPage = AddOneCustomPage( title, command,
m_PanelNetType[PANELCUSTOMBASE + ii] = currPage; static_cast<NETLIST_TYPE_ID>( NET_TYPE_CUSTOM1 + i ) );
m_PanelNetType[PANELCUSTOMBASE + i] = currPage;
} }
} }
@ -585,8 +550,12 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup()
NetlistUpdateOpt(); NetlistUpdateOpt();
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_NetlistPanel.custom_command_titles.clear();
cfg->m_NetlistPanel.custom_command_paths.clear();
// Update existing custom pages // Update existing custom pages
int jj = 0;
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
{ {
NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE]; NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
@ -599,27 +568,9 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup()
if( title.IsEmpty() ) if( title.IsEmpty() )
continue; continue;
msg = CUSTOM_NETLIST_TITLE; cfg->m_NetlistPanel.custom_command_titles.push_back( title.ToStdString() );
msg << jj + 1; cfg->m_NetlistPanel.custom_command_paths.push_back(
m_config->Write( msg, title ); currPage->m_CommandStringCtrl->GetValue().ToStdString() );
wxString Command = currPage->m_CommandStringCtrl->GetValue();
msg = CUSTOM_NETLIST_COMMAND;
msg << jj + 1;
m_config->Write( msg, Command );
jj++;
}
// Ensure all other pages are void
for( ; jj < CUSTOMPANEL_COUNTMAX; jj++ )
{
msg = CUSTOM_NETLIST_TITLE;
msg << jj + 1;
m_config->Write( msg, wxEmptyString );
msg = CUSTOM_NETLIST_COMMAND;
msg << jj + 1;
m_config->Write( msg, wxEmptyString );
} }
} }

View File

@ -28,21 +28,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <pgm_base.h>
#include <kiface_i.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <ws_painter.h>
#include <sch_sheet.h>
#include <dialog_plot_schematic.h> #include <dialog_plot_schematic.h>
#include <eeschema_settings.h>
#include <kiface_i.h>
// Keys for configuration #include <pgm_base.h>
#define PLOT_FORMAT_KEY wxT( "PlotFormat" ) #include <sch_sheet.h>
#define PLOT_MODECOLOR_KEY wxT( "PlotModeColor" ) #include <ws_painter.h>
#define PLOT_FRAME_REFERENCE_KEY wxT( "PlotFrameRef" )
#define PLOT_HPGL_ORIGIN_KEY wxT( "PlotHPGLOrg" )
#define PLOT_HPGL_PAPERSIZE_KEY wxT( "PlotHPGLPaperSize" )
#define PLOT_HPGL_PEN_SIZE_KEY wxT( "PlotHPGLPenSize" )
// static members (static to remember last state): // static members (static to remember last state):
@ -69,7 +61,6 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent )
m_defaultLineWidth( parent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ), m_defaultLineWidth( parent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ),
m_penWidth( parent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true ) m_penWidth( parent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true )
{ {
m_config = Kiface().KifaceSettings();
m_configChanged = false; m_configChanged = false;
m_browseButton->SetBitmap( KiBitmap( folder_xpm ) ); m_browseButton->SetBitmap( KiBitmap( folder_xpm ) );
@ -92,30 +83,24 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent )
// Initialize the dialog options: // Initialize the dialog options:
void DIALOG_PLOT_SCHEMATIC::initDlg() void DIALOG_PLOT_SCHEMATIC::initDlg()
{ {
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
// Set color or B&W plot option // Set color or B&W plot option
bool tmp; setModeColor( cfg->m_PlotPanel.color );
m_config->Read( PLOT_MODECOLOR_KEY, &tmp, true );
setModeColor( tmp );
// Set plot or not frame reference option // Set plot or not frame reference option
m_config->Read( PLOT_FRAME_REFERENCE_KEY, &tmp, true ); setPlotFrameRef( cfg->m_PlotPanel.frame_reference );
setPlotFrameRef( tmp );
// Set HPGL plot origin to center of paper of left bottom corner // Set HPGL plot origin to center of paper of left bottom corner
m_config->Read( PLOT_HPGL_ORIGIN_KEY, &tmp, false ); SetPlotOriginCenter( cfg->m_PlotPanel.hpgl_origin );
SetPlotOriginCenter( tmp );
m_config->Read( PLOT_HPGL_PAPERSIZE_KEY, &m_HPGLPaperSizeSelect, 0 ); m_HPGLPaperSizeSelect = cfg->m_PlotPanel.hpgl_paper_size;
// HPGL Pen Size is stored in mm in config // HPGL Pen Size is stored in mm in config
m_config->Read( PLOT_HPGL_PEN_SIZE_KEY, &m_HPGLPenSize, 0.5 ); m_HPGLPenSize = cfg->m_PlotPanel.hpgl_pen_size * IU_PER_MM;
m_HPGLPenSize *= IU_PER_MM;
// Switch to the last save plot format // Switch to the last save plot format
int plotfmt; switch( static_cast<PLOT_FORMAT>( cfg->m_PlotPanel.format ) )
m_config->Read( PLOT_FORMAT_KEY, &plotfmt, 0 );
switch( static_cast<PLOT_FORMAT>( plotfmt ) )
{ {
default: default:
case PLOT_FORMAT::POST: case PLOT_FORMAT::POST:
@ -270,14 +255,16 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions()
{ {
m_HPGLPenSize = m_penWidth.GetValue(); m_HPGLPenSize = m_penWidth.GetValue();
m_config->Write( PLOT_MODECOLOR_KEY, getModeColor() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
m_config->Write( PLOT_FRAME_REFERENCE_KEY, getPlotFrameRef() );
m_config->Write( PLOT_FORMAT_KEY, (long) GetPlotFileFormat() ); cfg->m_PlotPanel.color = getModeColor();
m_config->Write( PLOT_HPGL_ORIGIN_KEY, GetPlotOriginCenter() ); cfg->m_PlotPanel.frame_reference = getPlotFrameRef();
m_config->Write( PLOT_HPGL_PAPERSIZE_KEY, m_HPGLPaperSizeSelect ); cfg->m_PlotPanel.format = static_cast<int>( GetPlotFileFormat() );
cfg->m_PlotPanel.hpgl_origin = GetPlotOriginCenter();
cfg->m_PlotPanel.hpgl_paper_size = m_HPGLPaperSizeSelect;
// HPGL Pen Size is stored in mm in config // HPGL Pen Size is stored in mm in config
m_config->Write( PLOT_HPGL_PEN_SIZE_KEY, m_HPGLPenSize/IU_PER_MM ); cfg->m_PlotPanel.hpgl_pen_size = m_HPGLPenSize / IU_PER_MM;
SetDefaultLineThickness( m_defaultLineWidth.GetValue() ); SetDefaultLineThickness( m_defaultLineWidth.GetValue() );

View File

@ -47,7 +47,6 @@ class DIALOG_PLOT_SCHEMATIC : public DIALOG_PLOT_SCHEMATIC_BASE
{ {
private: private:
SCH_EDIT_FRAME* m_parent; SCH_EDIT_FRAME* m_parent;
wxConfigBase* m_config;
bool m_configChanged; // true if a project config param has changed bool m_configChanged; // true if a project config param has changed
PLOT_FORMAT m_plotFormat; PLOT_FORMAT m_plotFormat;
static int m_pageSizeSelect; // Static to keep last option for some format static int m_pageSizeSelect; // Static to keep last option for some format

View File

@ -443,7 +443,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
{ {
m_parent->PrintWorkSheet( dc, aScreen, GetDefaultLineThickness(), IU_PER_MILS, m_parent->PrintWorkSheet( dc, aScreen, GetDefaultLineThickness(), IU_PER_MILS,
aScreen->GetFileName(), wxEmptyString, aScreen->GetFileName(), wxEmptyString,
GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) ); m_parent->GetLayerColor( LAYER_SCHEMATIC_WORKSHEET ) );
} }
aScreen->Print( dc ); aScreen->Print( dc );

View File

@ -21,19 +21,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <sch_edit_frame.h>
#include <sch_component.h>
#include <invoke_sch_dialog.h>
#include <dialog_rescue_each_base.h>
#include <kiface_i.h>
#include <class_library.h>
#include <class_libentry.h>
#include <set>
#include <vector>
#include <project_rescue.h>
#include <eeschema_config.h>
#include <symbol_preview_widget.h>
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <class_libentry.h>
#include <class_library.h>
#include <dialog_rescue_each_base.h>
#include <eeschema_settings.h>
#include <invoke_sch_dialog.h>
#include <kiface_i.h>
#include <project_rescue.h>
#include <sch_component.h>
#include <sch_edit_frame.h>
#include <set>
#include <symbol_preview_widget.h>
#include <vector>
class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE class DIALOG_RESCUE_EACH: public DIALOG_RESCUE_EACH_BASE
@ -58,7 +58,6 @@ public:
private: private:
SYMBOL_PREVIEW_WIDGET* m_previewNewWidget; SYMBOL_PREVIEW_WIDGET* m_previewNewWidget;
SYMBOL_PREVIEW_WIDGET* m_previewOldWidget; SYMBOL_PREVIEW_WIDGET* m_previewOldWidget;
wxConfigBase* m_Config;
RESCUER* m_Rescuer; RESCUER* m_Rescuer;
SCH_SHEET_PATH* m_currentSheet; SCH_SHEET_PATH* m_currentSheet;
bool m_AskShowAgain; bool m_AskShowAgain;
@ -95,7 +94,6 @@ DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH( wxWindow* aParent,
m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, Kiway(), aGalBackEndType ); m_previewNewWidget = new SYMBOL_PREVIEW_WIDGET( m_previewNewPanel, Kiway(), aGalBackEndType );
m_SizerNewPanel->Add( m_previewNewWidget, 1, wxEXPAND | wxALL, 5 ); m_SizerNewPanel->Add( m_previewNewWidget, 1, wxEXPAND | wxALL, 5 );
m_Config = Kiface().KifaceSettings();
m_stdButtonsOK->SetDefault(); m_stdButtonsOK->SetDefault();
// Set the info message, customized to include the proper suffix. // Set the info message, customized to include the proper suffix.
@ -294,7 +292,8 @@ void DIALOG_RESCUE_EACH::OnNeverShowClick( wxCommandEvent& aEvent )
if( resp == wxID_YES ) if( resp == wxID_YES )
{ {
m_Config->Write( RescueNeverShowEntry, true ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_RescueNeverShow = true;
m_Rescuer->m_chosen_candidates.clear(); m_Rescuer->m_chosen_candidates.clear();
Close(); Close();
} }

View File

@ -29,6 +29,7 @@
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <eda_dde.h> #include <eda_dde.h>
#include <eeschema_settings.h>
#include <sch_edit_frame.h> #include <sch_edit_frame.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <lib_view_frame.h> #include <lib_view_frame.h>
@ -40,6 +41,7 @@
#include <dialogs/panel_sym_lib_table.h> #include <dialogs/panel_sym_lib_table.h>
#include <kiway.h> #include <kiway.h>
#include <sim/sim_plot_frame.h> #include <sim/sim_plot_frame.h>
#include <settings/settings_manager.h>
#include <sexpr/sexpr.h> #include <sexpr/sexpr.h>
#include <sexpr/sexpr_parser.h> #include <sexpr/sexpr_parser.h>
@ -162,6 +164,7 @@ PGM_BASE& Pgm()
} }
// TODO(JE) Get rid of this on a second pass through eeschema
static COLOR4D s_layerColor[LAYER_ID_COUNT]; static COLOR4D s_layerColor[LAYER_ID_COUNT];
COLOR4D GetLayerColor( SCH_LAYER_ID aLayer ) COLOR4D GetLayerColor( SCH_LAYER_ID aLayer )
@ -171,70 +174,13 @@ COLOR4D GetLayerColor( SCH_LAYER_ID aLayer )
return s_layerColor[layer]; return s_layerColor[layer];
} }
void SetLayerColor( COLOR4D aColor, SCH_LAYER_ID aLayer )
void OnColorsChanged()
{ {
// Do not allow non-background layers to be completely white. COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
// This ensures the BW printing recognizes that the colors should be printed black.
if( aColor == COLOR4D::WHITE && aLayer != LAYER_SCHEMATIC_BACKGROUND )
aColor.Darken( 0.01 );
unsigned layer = aLayer; for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
wxASSERT( layer < arrayDim( s_layerColor ) ); s_layerColor[layer] = cs->GetColor( layer );
s_layerColor[layer] = aColor;
}
static std::vector<PARAM_CFG*>& cfg_params()
{
static std::vector<PARAM_CFG*> ca;
if( !ca.size() )
{
// These are KIFACE specific, they need to be loaded once when the
// eeschema KIFACE comes in.
#define CLR(x, y, z)\
ca.push_back( new PARAM_CFG_SETCOLOR( true, wxT( x ),\
&s_layerColor[( y )], z ) );
CLR( "Color4DWireEx", LAYER_WIRE, COLOR4D( GREEN ) )
CLR( "Color4DBusEx", LAYER_BUS, COLOR4D( BLUE ) )
CLR( "Color4DConnEx", LAYER_JUNCTION, COLOR4D( GREEN ) )
CLR( "Color4DLLabelEx", LAYER_LOCLABEL, COLOR4D( BLACK ) )
CLR( "Color4DHLabelEx", LAYER_HIERLABEL, COLOR4D( BROWN ) )
CLR( "Color4DGLabelEx", LAYER_GLOBLABEL, COLOR4D( RED ) )
CLR( "Color4DPinNumEx", LAYER_PINNUM, COLOR4D( RED ) )
CLR( "Color4DPinNameEx", LAYER_PINNAM, COLOR4D( CYAN ) )
CLR( "Color4DFieldEx", LAYER_FIELDS, COLOR4D( MAGENTA ) )
CLR( "Color4DReferenceEx", LAYER_REFERENCEPART, COLOR4D( CYAN ) )
CLR( "Color4DValueEx", LAYER_VALUEPART, COLOR4D( CYAN ) )
CLR( "Color4DNoteEx", LAYER_NOTES, COLOR4D( LIGHTBLUE ) )
CLR( "Color4DBodyEx", LAYER_DEVICE, COLOR4D( RED ) )
CLR( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND, COLOR4D( LIGHTYELLOW ) )
CLR( "Color4DNetNameEx", LAYER_NETNAM, COLOR4D( DARKGRAY ) )
CLR( "Color4DPinEx", LAYER_PIN, COLOR4D( RED ) )
CLR( "Color4DSheetEx", LAYER_SHEET, COLOR4D( MAGENTA ) )
CLR( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME, COLOR4D( BROWN ) )
CLR( "Color4DSheetNameEx", LAYER_SHEETNAME, COLOR4D( CYAN ) )
CLR( "Color4DSheetLabelEx", LAYER_SHEETLABEL, COLOR4D( BROWN ) )
CLR( "Color4DNoConnectEx", LAYER_NOCONNECT, COLOR4D( BLUE ) )
CLR( "Color4DErcWEx", LAYER_ERC_WARN, COLOR4D( GREEN ).WithAlpha(0.8 ) )
CLR( "Color4DErcEEx", LAYER_ERC_ERR, COLOR4D( RED ).WithAlpha(0.8 ) )
CLR( "Color4DGridEx", LAYER_SCHEMATIC_GRID, COLOR4D( DARKGRAY ) )
CLR( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND, COLOR4D( WHITE ) )
CLR( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR, COLOR4D( BLACK ) )
CLR( "Color4DBrightenedEx", LAYER_BRIGHTENED, COLOR4D( PUREMAGENTA ) )
CLR( "Color4DHiddenEx", LAYER_HIDDEN, COLOR4D( LIGHTGRAY ) )
CLR( "Color4DWorksheetEx", LAYER_WORKSHEET, COLOR4D( RED ) )
// Macs look better with a lighter shadow
#ifdef __WXMAC__
CLR( "Color4DShadowEx", LAYER_SELECTION_SHADOWS, COLOR4D( .78, .92, 1.0, 0.8 ) )
#else
CLR( "Color4DShadowEx", LAYER_SELECTION_SHADOWS, COLOR4D( .4, .7, 1.0, 0.8 ) )
#endif
}
return ca;
} }
@ -242,17 +188,12 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
{ {
// This is process-level-initialization, not project-level-initialization of the DSO. // This is process-level-initialization, not project-level-initialization of the DSO.
// Do nothing in here pertinent to a project! // Do nothing in here pertinent to a project!
InitSettings( new EESCHEMA_SETTINGS );
aProgram->GetSettingsManager().RegisterSettings( KifaceSettings() );
start_common( aCtlBits ); start_common( aCtlBits );
// Give a default colour for all layers (actual color will be initialized by config) OnColorsChanged();
for( SCH_LAYER_ID ii = SCH_LAYER_ID_START; ii < SCH_LAYER_ID_END; ++ii )
SetLayerColor( COLOR4D( DARKGRAY ), ii );
SetLayerColor( COLOR4D::WHITE, LAYER_SCHEMATIC_BACKGROUND );
SetLayerColor( COLOR4D::BLACK, LAYER_SCHEMATIC_CURSOR );
wxConfigLoadSetups( KifaceSettings(), cfg_params() );
wxFileName fn = SYMBOL_LIB_TABLE::GetGlobalTableFileName(); wxFileName fn = SYMBOL_LIB_TABLE::GetGlobalTableFileName();
@ -292,7 +233,13 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
void IFACE::OnKifaceEnd() void IFACE::OnKifaceEnd()
{ {
wxConfigSaveSetups( KifaceSettings(), cfg_params() ); COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
{
cs->SetColor( layer, GetLayerColor( layer ) );
}
end_common(); end_common();
} }

View File

@ -21,31 +21,33 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <confirm.h>
#include <gestfich.h>
#include <sch_edit_frame.h>
#include <sch_sheet.h>
#include <lib_edit_frame.h>
#include <eeschema_config.h>
#include <ws_data_model.h>
#include <class_library.h> #include <class_library.h>
#include <symbol_lib_table.h> #include <confirm.h>
#include <wildcards_and_files_ext.h>
#include <widgets/paged_dialog.h>
#include <dialogs/panel_eeschema_template_fieldnames.h>
#include <dialogs/panel_eeschema_settings.h>
#include <dialogs/panel_eeschema_display_options.h> #include <dialogs/panel_eeschema_display_options.h>
#include <dialogs/panel_eeschema_settings.h>
#include <dialogs/panel_eeschema_template_fieldnames.h>
#include <dialogs/panel_libedit_settings.h>
#include <eeschema_config.h>
#include <eeschema_settings.h>
#include <fctsys.h>
#include <gestfich.h>
#include <gr_text.h>
#include <kiface_i.h>
#include <lib_edit_frame.h>
#include <panel_display_options.h> #include <panel_display_options.h>
#include <panel_hotkeys_editor.h> #include <panel_hotkeys_editor.h>
#include <widgets/widget_eeschema_color_config.h> #include <pgm_base.h>
#include <widgets/symbol_tree_pane.h> #include <sch_edit_frame.h>
#include <dialogs/panel_libedit_settings.h> #include <sch_junction.h>
#include <sch_painter.h> #include <sch_painter.h>
#include <gr_text.h> #include <sch_sheet.h>
#include "sch_junction.h" #include <settings/app_settings.h>
#include <symbol_lib_table.h>
#include <widgets/paged_dialog.h>
#include <widgets/symbol_tree_pane.h>
#include <widgets/widget_eeschema_color_config.h>
#include <wildcards_and_files_ext.h>
#include <ws_data_model.h>
static int s_defaultBusThickness = Mils2iu( DEFAULTBUSTHICKNESS ); static int s_defaultBusThickness = Mils2iu( DEFAULTBUSTHICKNESS );
static int s_defaultWireThickness = Mils2iu( DEFAULTDRAWLINETHICKNESS ); static int s_defaultWireThickness = Mils2iu( DEFAULTDRAWLINETHICKNESS );
@ -293,134 +295,46 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
SetDefaultTextSize( Mils2iu( GetDefaultTextSize() ) ); SetDefaultTextSize( Mils2iu( GetDefaultTextSize() ) );
} }
///@{
/// \ingroup config
const wxChar RescueNeverShowEntry[] = wxT( "RescueNeverShow" ); void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
const wxChar AutoplaceFieldsEntry[] = wxT( "AutoplaceFields" );
const wxChar AutoplaceJustifyEntry[] = wxT( "AutoplaceJustify" );
const wxChar AutoplaceAlignEntry[] = wxT( "AutoplaceAlign" );
static const wxChar DragActionIsMoveEntry[] = wxT( "DragActionIsMove" );
static const wxChar FootprintPreviewEntry[] = wxT( "FootprintPreview" );
static const wxChar NavigatorStaysOpenEntry[] = wxT( "NavigatorStaysOpen" );
static const wxChar DefaultBusWidthEntry[] = wxT( "DefaultBusWidth" );
static const wxChar DefaultWireWidthEntry[] = wxT( "DefaultWireWidth" );
static const wxChar DefaultDrawLineWidthEntry[] = wxT( "DefaultDrawLineWidth" );
static const wxChar DefaultJctSizeEntry[] = wxT( "DefaultJunctionSize" );
static const wxChar ShowHiddenPinsEntry[] = wxT( "ShowHiddenPins" );
static const wxChar HorzVertLinesOnlyEntry[] = wxT( "HorizVertLinesOnly" );
static const wxChar FieldNamesEntry[] = wxT( "FieldNames" );
static const wxString TextMarkupFlagsEntry = "TextMarkupFlags";
static const wxString ShowPageLimitsEntry = "ShowPageLimits";
static const wxString UnitsEntry = "Units";
static const wxString PrintMonochromeEntry = "PrintMonochrome";
static const wxString PrintSheetRefEntry = "PrintSheetReferenceAndTitleBlock";
static const wxString RepeatStepXEntry = "RepeatStepX";
static const wxString RepeatStepYEntry = "RepeatStepY";
static const wxString RepeatLabelIncrementEntry = "RepeatLabelIncrement";
static const wxString ShowIllegalSymboLibDialog = "ShowIllegalSymbolLibDialog";
static const wxString showSheetFileNameCaseSensitivityDlg = "ShowSheetFileNameCaseSensitivityDlg";
static const wxString SelectPinSelectSymbolEntry = "SelectPinSelectSymbolOpt";
// Library editor wxConfig entry names.
static const wxChar defaultLibWidthEntry[] = wxT( "LibeditLibWidth" );
static const wxChar defaultPinNumSizeEntry[] = wxT( "LibeditPinNumSize" );
static const wxChar defaultPinNameSizeEntry[] = wxT( "LibeditPinNameSize" );
static const wxChar DefaultPinLengthEntry[] = wxT( "DefaultPinLength" );
static const wxChar repeatLibLabelIncEntry[] = wxT( "LibeditRepeatLabelInc" );
static const wxChar pinRepeatStepEntry[] = wxT( "LibeditPinRepeatStep" );
static const wxChar repeatLibStepXEntry[] = wxT( "LibeditRepeatStepX" );
static const wxChar repeatLibStepYEntry[] = wxT( "LibeditRepeatStepY" );
static const wxChar showPinElectricalType[] = wxT( "LibeditShowPinElectricalType" );
static const wxChar boxedSelectedText[] = wxT( "SelectionTextAsBox" );
static const wxChar drawSelectedChildren[] = wxT( "SelectionDrawChildItems" );
static const wxChar selectionFillShapes[] = wxT( "SelectionFillShapes" );
static const wxChar selectionThickness[] = wxT( "SelectionThickness" );
///@}
std::vector<PARAM_CFG*>& SCH_EDIT_FRAME::GetConfigurationSettings()
{
if( !m_configSettings.empty() )
return m_configSettings;
m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowPageLimitsEntry,
&m_showPageLimits, true ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, UnitsEntry,
(int*) &m_userUnits,
(int) EDA_UNITS::MILLIMETRES ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintMonochromeEntry,
&m_printMonochrome, true ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, PrintSheetRefEntry,
&m_printSheetReference, true ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, RepeatLabelIncrementEntry,
&m_repeatDeltaLabel, DEFAULT_REPEAT_LABEL_INC,
-10, +10 ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, ShowIllegalSymboLibDialog,
&m_showIllegalSymbolLibDialog, true ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, showSheetFileNameCaseSensitivityDlg,
&m_showSheetFileNameCaseSensitivityDlg,
true ) );
return m_configSettings;
}
void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
{ {
EDA_DRAW_FRAME::LoadSettings( aCfg ); EDA_DRAW_FRAME::LoadSettings( aCfg );
long tmp; auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); m_repeatStep.x = Mils2iu( cfg->m_Drawing.default_repeat_offset_x );
m_repeatStep.y = Mils2iu( cfg->m_Drawing.default_repeat_offset_y );
aCfg->Read( RepeatStepXEntry, &tmp, DEFAULT_REPEAT_OFFSET_X );
m_repeatStep.x = Mils2iu( static_cast< int >( tmp ) );
aCfg->Read( RepeatStepYEntry, &tmp, DEFAULT_REPEAT_OFFSET_Y );
m_repeatStep.y = Mils2iu( static_cast< int >( tmp ) );
// LibEdit owns this one, but we must read it in if LibEdit hasn't set it yet // LibEdit owns this one, but we must read it in if LibEdit hasn't set it yet
if( GetDefaultLineThickness() < 0 ) if( GetDefaultLineThickness() < 0 )
{ SetDefaultLineThickness( Mils2iu( cfg->m_Drawing.default_line_thickness ) );
SetDefaultLineThickness( Mils2iu( (int) aCfg->Read( DefaultDrawLineWidthEntry,
DEFAULTDRAWLINETHICKNESS ) ) );
}
SetDefaultBusThickness( Mils2iu( (int) aCfg->Read( DefaultBusWidthEntry, SetDefaultBusThickness( Mils2iu( cfg->m_Drawing.default_bus_thickness ) );
DEFAULTBUSTHICKNESS ) ) );
// Property introduced in 6.0; use DefaultLineWidth for earlier projects // Property introduced in 6.0; use DefaultLineWidth for earlier projects
if( !aCfg->Read( DefaultWireWidthEntry, &tmp ) ) SetDefaultWireThickness( Mils2iu( cfg->m_Drawing.default_wire_thickness) );
aCfg->Read( DefaultDrawLineWidthEntry, &tmp, DEFAULTDRAWLINETHICKNESS );
SetDefaultWireThickness( Mils2iu( (int) tmp ) ); SetSelectionTextAsBox( cfg->m_Selection.text_as_box );
SetSelectionDrawChildItems( cfg->m_Selection.draw_selected_children );
SetSelectionFillShapes( cfg->m_Selection.fill_shapes );
SetSelectionThickness( Mils2iu( cfg->m_Selection.thickness ) );
SetSelectionTextAsBox( aCfg->ReadBool( boxedSelectedText, false ) ); SetTextMarkupFlags( cfg->m_Drawing.text_markup_flags );
SetSelectionDrawChildItems( aCfg->ReadBool( drawSelectedChildren, true ) );
SetSelectionFillShapes( aCfg->ReadBool( selectionFillShapes, false ) );
SetSelectionThickness(
Mils2iu( static_cast<int>( aCfg->Read( selectionThickness,
DEFAULTSELECTIONTHICKNESS ) ) ) );
SetTextMarkupFlags( (int) aCfg->Read( TextMarkupFlagsEntry, 0L ) ); SCH_JUNCTION::SetSymbolSize( Mils2iu( cfg->m_Drawing.default_junction_size ) );
if( aCfg->Read( DefaultJctSizeEntry, &tmp ) ) m_footprintPreview = cfg->m_Appearance.footprint_preview;
SCH_JUNCTION::SetSymbolSize( Mils2iu( (int) tmp ) ); m_navigatorStaysOpen = cfg->m_Appearance.navigator_stays_open;
m_showAllPins = cfg->m_Appearance.show_hidden_pins;
m_autoplaceFields = cfg->m_AutoplaceFields.enable;
m_autoplaceAlign = cfg->m_AutoplaceFields.align_to_grid;
m_autoplaceJustify = cfg->m_AutoplaceFields.allow_rejustify;
m_forceHVLines = cfg->m_Drawing.hv_lines_only;
m_dragActionIsMove = cfg->m_Input.drag_is_move;
m_selectPinSelectSymbol = cfg->m_Selection.select_pin_selects_symbol;
m_repeatDeltaLabel = cfg->m_Drawing.repeat_label_increment;
aCfg->Read( DragActionIsMoveEntry, &m_dragActionIsMove, true ); wxString templateFieldNames = cfg->m_Drawing.field_names;
aCfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false );
aCfg->Read( SelectPinSelectSymbolEntry, &m_selectPinSelectSymbol, true );
aCfg->Read( HorzVertLinesOnlyEntry, &m_forceHVLines, true );
aCfg->Read( AutoplaceFieldsEntry, &m_autoplaceFields, true );
aCfg->Read( AutoplaceJustifyEntry, &m_autoplaceJustify, true );
aCfg->Read( AutoplaceAlignEntry, &m_autoplaceAlign, false );
aCfg->Read( FootprintPreviewEntry, &m_footprintPreview, false );
aCfg->Read( NavigatorStaysOpenEntry, &m_navigatorStaysOpen, false );
wxString templateFieldNames = aCfg->Read( FieldNamesEntry, wxEmptyString );
if( !templateFieldNames.IsEmpty() ) if( !templateFieldNames.IsEmpty() )
{ {
@ -446,30 +360,49 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
} }
void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{ {
EDA_DRAW_FRAME::SaveSettings( aCfg ); EDA_DRAW_FRAME::SaveSettings( aCfg );
wxConfigSaveSetups( aCfg, GetConfigurationSettings() ); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
aCfg->Write( RepeatStepXEntry, static_cast< long >( Iu2Mils( m_repeatStep.x ) ) ); // TODO(JE) do most of these need to live as class members here, or can the sites that need
aCfg->Write( RepeatStepYEntry, static_cast< long >( Iu2Mils( m_repeatStep.y ) ) ); // the setting just grab a pointer to the EESCHEMA_SETTINGS and look them up directly?
aCfg->Write( DragActionIsMoveEntry, m_dragActionIsMove );
aCfg->Write( DefaultBusWidthEntry, (long) Iu2Mils( GetDefaultBusThickness() ) ); cfg->m_Appearance.footprint_preview = m_footprintPreview;
aCfg->Write( DefaultWireWidthEntry, (long) Iu2Mils( GetDefaultWireThickness() ) ); cfg->m_Appearance.navigator_stays_open = m_navigatorStaysOpen;
aCfg->Write( DefaultJctSizeEntry, (long) Iu2Mils( SCH_JUNCTION::GetSymbolSize() ) ); cfg->m_Appearance.print_sheet_reference = m_printSheetReference;
aCfg->Write( ShowHiddenPinsEntry, m_showAllPins ); cfg->m_Appearance.show_hidden_pins = m_showAllPins;
aCfg->Write( SelectPinSelectSymbolEntry, GetSelectPinSelectSymbol() ); cfg->m_Appearance.show_illegal_symbol_lib_dialog = m_showIllegalSymbolLibDialog;
aCfg->Write( HorzVertLinesOnlyEntry, GetForceHVLines() ); cfg->m_Appearance.show_page_limits = m_showPageLimits;
aCfg->Write( AutoplaceFieldsEntry, m_autoplaceFields ); cfg->m_Appearance.show_sheet_filename_case_sensitivity_dialog =
aCfg->Write( AutoplaceJustifyEntry, m_autoplaceJustify ); m_showSheetFileNameCaseSensitivityDlg;
aCfg->Write( AutoplaceAlignEntry, m_autoplaceAlign );
aCfg->Write( FootprintPreviewEntry, m_footprintPreview ); cfg->m_AutoplaceFields.enable = m_autoplaceFields;
aCfg->Write( boxedSelectedText, GetSelectionTextAsBox() ); cfg->m_AutoplaceFields.allow_rejustify = m_autoplaceJustify;
aCfg->Write( drawSelectedChildren, GetSelectionDrawChildItems() ); cfg->m_AutoplaceFields.align_to_grid = m_autoplaceAlign;
aCfg->Write( selectionFillShapes, GetSelectionFillShapes() );
aCfg->Write( selectionThickness, Iu2Mils( GetSelectionThickness() ) ); cfg->m_Drawing.default_bus_thickness = Iu2Mils( GetDefaultBusThickness() );
aCfg->Write( NavigatorStaysOpenEntry, m_navigatorStaysOpen ); cfg->m_Drawing.default_line_thickness = Iu2Mils( GetDefaultLineThickness() );
cfg->m_Drawing.default_junction_size = Iu2Mils( SCH_JUNCTION::GetSymbolSize() );
cfg->m_Drawing.default_repeat_offset_x = Iu2Mils( m_repeatStep.x );
cfg->m_Drawing.default_repeat_offset_y = Iu2Mils( m_repeatStep.y );
cfg->m_Drawing.default_wire_thickness = Iu2Mils( GetDefaultWireThickness() );
cfg->m_Drawing.hv_lines_only = GetForceHVLines();
cfg->m_Drawing.repeat_label_increment = m_repeatDeltaLabel;
cfg->m_Drawing.text_markup_flags = GetTextMarkupFlags();
cfg->m_Input.drag_is_move = m_dragActionIsMove;
cfg->m_Printing.monochrome = m_printMonochrome;
cfg->m_Selection.thickness = Iu2Mils( GetSelectionThickness() );
cfg->m_Selection.draw_selected_children = GetSelectionDrawChildItems();
cfg->m_Selection.fill_shapes = GetSelectionFillShapes();
cfg->m_Selection.select_pin_selects_symbol = GetSelectPinSelectSymbol();
cfg->m_Selection.text_as_box = GetSelectionTextAsBox();
cfg->m_System.units = static_cast<int>( m_userUnits );
// Save template fieldnames // Save template fieldnames
STRING_FORMATTER sf; STRING_FORMATTER sf;
@ -479,80 +412,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
record.Replace( wxT(" "), wxT(" "), true ); // double space to single record.Replace( wxT(" "), wxT(" "), true ); // double space to single
aCfg->Write( FieldNamesEntry, record ); cfg->m_Drawing.field_names = record.ToStdString();
aCfg->Write( TextMarkupFlagsEntry, GetTextMarkupFlags() );
aCfg->Write( showSheetFileNameCaseSensitivityDlg, m_showSheetFileNameCaseSensitivityDlg );
}
void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
SetDefaultLineThickness( Mils2iu( (int) aCfg->Read( DefaultDrawLineWidthEntry,
DEFAULTDRAWLINETHICKNESS ) ) );
SetDefaultPinLength( Mils2iu( (int) aCfg->Read( DefaultPinLengthEntry, DEFAULTPINLENGTH ) ) );
m_textPinNumDefaultSize = Mils2iu( (int) aCfg->Read( defaultPinNumSizeEntry,
DEFAULTPINNUMSIZE ) );
m_textPinNameDefaultSize = Mils2iu( (int) aCfg->Read( defaultPinNameSizeEntry,
DEFAULTPINNAMESIZE ) );
SetRepeatDeltaLabel( (int) aCfg->Read( repeatLibLabelIncEntry, DEFAULT_REPEAT_LABEL_INC ) );
SetRepeatPinStep( Mils2iu( (int) aCfg->Read( pinRepeatStepEntry,
DEFAULT_REPEAT_OFFSET_PIN ) ) );
wxPoint step;
step.x = Mils2iu( static_cast< int >( aCfg->Read( repeatLibStepXEntry,
static_cast< long >( DEFAULT_REPEAT_OFFSET_X ) ) ) );
step.y = Mils2iu( static_cast< int >( aCfg->Read( repeatLibStepYEntry,
static_cast< long >( DEFAULT_REPEAT_OFFSET_Y ) ) ) );
SetRepeatStep( step );
m_showPinElectricalTypeName = aCfg->ReadBool( showPinElectricalType, true );
aCfg->Read( defaultLibWidthEntry, &m_defaultLibWidth, DEFAULTLIBWIDTH );
wxString templateFieldNames = aCfg->Read( FieldNamesEntry, wxEmptyString );
if( !templateFieldNames.IsEmpty() )
{
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
try
{
m_templateFieldNames.Parse( &lexer );
}
catch( const IO_ERROR& DBG( e ) )
{
// @todo show error msg
DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); )
}
}
auto painter = static_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
KIGFX::SCH_RENDER_SETTINGS* settings = painter->GetSettings();
settings->m_ShowPinsElectricalType = m_showPinElectricalTypeName;
// Hidden elements must be editable
settings->m_ShowHiddenText = true;
settings->m_ShowHiddenPins = true;
settings->m_ShowUmbilicals = false;
}
void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
{
EDA_DRAW_FRAME::SaveSettings( aCfg );
aCfg->Write( DefaultDrawLineWidthEntry, Iu2Mils( GetDefaultLineThickness() ) );
aCfg->Write( DefaultPinLengthEntry, Iu2Mils( GetDefaultPinLength() ) );
aCfg->Write( defaultPinNumSizeEntry, Iu2Mils( GetPinNumDefaultSize() ) );
aCfg->Write( defaultPinNameSizeEntry, Iu2Mils( GetPinNameDefaultSize() ) );
aCfg->Write( repeatLibLabelIncEntry, GetRepeatDeltaLabel() );
aCfg->Write( pinRepeatStepEntry, Iu2Mils( GetRepeatPinStep() ) );
aCfg->Write( repeatLibStepXEntry, Iu2Mils( GetRepeatStep().x ) );
aCfg->Write( repeatLibStepYEntry, Iu2Mils( GetRepeatStep().y ) );
aCfg->Write( showPinElectricalType, GetShowElectricalType() );
aCfg->Write( defaultLibWidthEntry, m_treePane->GetSize().x );
} }

View File

@ -0,0 +1,500 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <eeschema_settings.h>
#include <layers_id_colors_and_visibility.h>
#include <libedit_settings.h>
#include <pgm_base.h>
#include <settings/common_settings.h>
#include <settings/parameters.h>
#include <settings/settings_manager.h>
#include <wx/config.h>
///! Update the schema version whenever a migration is required
const int eeschemaSchemaVersion = 0;
EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : APP_SETTINGS_BASE( "eeschema", eeschemaSchemaVersion )
{
m_params.emplace_back( new PARAM<wxString>( "appearance.edit_component_visible_columns",
&m_Appearance.edit_component_visible_columns, "0 1 2 3 4 5 6 7" ) );
m_params.emplace_back( new PARAM<bool>( "appearance.footprint_preview",
&m_Appearance.footprint_preview, true ) );
m_params.emplace_back( new PARAM<bool>( "appearance.navigator_stays_open",
&m_Appearance.navigator_stays_open, false ) );
m_params.emplace_back( new PARAM<bool>( "appearance.print_sheet_reference",
&m_Appearance.print_sheet_reference, true ) );
m_params.emplace_back( new PARAM<bool>( "appearance.show_hidden_pins",
&m_Appearance.show_hidden_pins, false ) );
m_params.emplace_back( new PARAM<bool>( "appearance.show_illegal_symbol_lib_dialog",
&m_Appearance.show_illegal_symbol_lib_dialog, true ) );
m_params.emplace_back( new PARAM<bool>( "appearance.show_page_limits",
&m_Appearance.show_page_limits, true ) );
m_params.emplace_back(
new PARAM<bool>( "appearance.show_sheet_filename_case_sensitivity_dialog",
&m_Appearance.show_sheet_filename_case_sensitivity_dialog, true ) );
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.enable",
&m_AutoplaceFields.enable, true ) );
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.allow_rejustify",
&m_AutoplaceFields.allow_rejustify, true ) );
m_params.emplace_back( new PARAM<bool>( "autoplace_fields.align_to_grid",
&m_AutoplaceFields.align_to_grid, true ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_bus_thickness",
&m_Drawing.default_bus_thickness, 12 ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_junction_size",
&m_Drawing.default_junction_size, 40 ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_line_thickness",
&m_Drawing.default_line_thickness, 6 ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_x",
&m_Drawing.default_repeat_offset_x, 0 ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_repeat_offset_y",
&m_Drawing.default_repeat_offset_y, 100 ) );
m_params.emplace_back( new PARAM<int>( "drawing.default_wire_thickness",
&m_Drawing.default_wire_thickness, 6 ) );
m_params.emplace_back(
new PARAM<wxString>( "drawing.field_names", &m_Drawing.field_names, "" ) );
m_params.emplace_back(
new PARAM<bool>( "drawing.hv_lines_only", &m_Drawing.hv_lines_only, true ) );
m_params.emplace_back( new PARAM<int>( "drawing.repeat_label_increment",
&m_Drawing.repeat_label_increment, 1, -10, 10 ) );
m_params.emplace_back(
new PARAM<int>( "drawing.text_markup_flags", &m_Drawing.text_markup_flags, 0 ) );
m_params.emplace_back( new PARAM<bool>( "input.drag_is_move", &m_Input.drag_is_move, true ) );
m_params.emplace_back(
new PARAM<int>( "selection.thickness", &m_Selection.thickness, 3 ) );
m_params.emplace_back( new PARAM<bool>( "selection.draw_selected_children",
&m_Selection.draw_selected_children, true ) );
m_params.emplace_back( new PARAM<bool>( "selection.fill_shapes",
&m_Selection.fill_shapes, false ) );
m_params.emplace_back( new PARAM<bool>( "selection.select_pin_selects_symbol",
&m_Selection.select_pin_selects_symbol, true ) );
m_params.emplace_back( new PARAM<bool>( "selection.text_as_box",
&m_Selection.text_as_box, false ) );
m_params.emplace_back(
new PARAM<int>( "annotation.method", &m_AnnotatePanel.method, 0, 0, 2 ) );
m_params.emplace_back( new PARAM<int>( "annotation.messages_filter",
&m_AnnotatePanel.messages_filter, -1 ) );
m_params.emplace_back( new PARAM<int>( "annotation.sort_order",
&m_AnnotatePanel.sort_order, 0, 0, 1 ) );
m_params.emplace_back(
new PARAM<wxString>( "bom.selected_plugin", &m_BomPanel.selected_plugin, "" ) );
m_params.emplace_back( new PARAM<wxString>( "bom.plugins", &m_BomPanel.plugins, "" ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_revision",
&m_PageSettings.export_revision, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_date",
&m_PageSettings.export_date, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_title",
&m_PageSettings.export_title, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_company",
&m_PageSettings.export_company, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment1",
&m_PageSettings.export_comment1, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment2",
&m_PageSettings.export_comment2, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment3",
&m_PageSettings.export_comment3, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment4",
&m_PageSettings.export_comment4, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment5",
&m_PageSettings.export_comment5, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment6",
&m_PageSettings.export_comment6, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment7",
&m_PageSettings.export_comment7, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment8",
&m_PageSettings.export_comment8, false ) );
m_params.emplace_back( new PARAM<bool>( "page_settings.export_comment9",
&m_PageSettings.export_comment9, false ) );
m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_show",
&m_FieldEditorPanel.fields_show, {} ) );
m_params.emplace_back( new PARAM_MAP<bool>( "field_editor.fields_group_by",
&m_FieldEditorPanel.fields_group_by, {} ) );
m_params.emplace_back( new PARAM<bool>( "plot.color", &m_PlotPanel.color, true ) );
m_params.emplace_back( new PARAM<int>( "plot.format", &m_PlotPanel.format, 0 ) );
m_params.emplace_back( new PARAM<bool>( "plot.frame_reference",
&m_PlotPanel.frame_reference, true ) );
m_params.emplace_back( new PARAM<int>( "plot.hpgl_paper_size",
&m_PlotPanel.hpgl_paper_size, 0 ) );
m_params.emplace_back( new PARAM<double>( "plot.hpgl_pen_size",
&m_PlotPanel.hpgl_pen_size, 0.5 ) );
m_params.emplace_back(
new PARAM<bool>( "plot.hpgl_origin", &m_PlotPanel.hpgl_origin, false ) );
m_params.emplace_back(
new PARAM<int>( "simulator.window.pos_x", &m_Simulator.window.pos_x, 0 ) );
m_params.emplace_back(
new PARAM<int>( "simulator.window.pos_y", &m_Simulator.window.pos_y, 0 ) );
m_params.emplace_back( new PARAM<int>( "simulator.window.size_x",
&m_Simulator.window.size_x, 500 ) );
m_params.emplace_back( new PARAM<int>( "simulator.window.size_y",
&m_Simulator.window.size_y, 400 ) );
m_params.emplace_back( new PARAM<bool>( "simulator.window.maximized",
&m_Simulator.window.maximized, false ) );
m_params.emplace_back( new PARAM<wxString>( "simulator.window.perspective",
&m_Simulator.window.perspective, "" ) );
m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_width",
&m_Simulator.plot_panel_width, 0 ) );
m_params.emplace_back( new PARAM<int>( "simulator.plot_panel_height",
&m_Simulator.plot_panel_height, 0 ) );
m_params.emplace_back( new PARAM<int>( "simulator.signal_panel_height",
&m_Simulator.signal_panel_height, 0 ) );
m_params.emplace_back( new PARAM<int>( "simulator.cursors_panel_height",
&m_Simulator.cursors_panel_height, 0 ) );
m_params.emplace_back( new PARAM<bool>( "simulator.white_background",
&m_Simulator.white_background, false ) );
m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_h",
&m_SymChooserPanel.sash_pos_h, -1 ) );
m_params.emplace_back( new PARAM<int>( "symbol_chooser.sash_pos_v",
&m_SymChooserPanel.sash_pos_v, -1 ) );
m_params.emplace_back( new PARAM<int>( "symbol_chooser.width",
&m_SymChooserPanel.width, -1 ) );
m_params.emplace_back( new PARAM<int>( "symbol_chooser.height",
&m_SymChooserPanel.height, -1 ) );
m_params.emplace_back( new PARAM<bool>( "symbol_chooser.keep_symbol",
&m_SymChooserPanel.keep_symbol, false ) );
m_params.emplace_back( new PARAM<bool>( "symbol_chooser.place_all_units",
&m_SymChooserPanel.place_all_units, true ) );
m_params.emplace_back( new PARAM<bool>( "system.never_show_rescue_dialog",
&m_RescueNeverShow, false ) );
m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_x",
&m_LibViewPanel.window.pos_x, 0 ) );
m_params.emplace_back( new PARAM<int>( "lib_view.window.pos_y",
&m_LibViewPanel.window.pos_y, 0 ) );
m_params.emplace_back( new PARAM<int>( "lib_view.window.size_x",
&m_LibViewPanel.window.size_x, 500 ) );
m_params.emplace_back( new PARAM<int>( "lib_view.window.size_y",
&m_LibViewPanel.window.size_y, 400 ) );
m_params.emplace_back( new PARAM<bool>( "lib_view.window.maximized",
&m_LibViewPanel.window.maximized, false ) );
m_params.emplace_back( new PARAM<wxString>( "lib_view.window.perspective",
&m_LibViewPanel.window.perspective, "" ) );
m_params.emplace_back( new PARAM<int>( "lib_view.lib_list_width",
&m_LibViewPanel.lib_list_width, 150 ) );
m_params.emplace_back( new PARAM<int>( "lib_view.cmp_list_width",
&m_LibViewPanel.cmp_list_width, 150 ) );
m_params.emplace_back( new PARAM<bool>( "lib_view.show_pin_electrical_type",
&m_LibViewPanel.show_pin_electrical_type, true ) );
}
bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg );
ret &= fromLegacy<bool>( aCfg, "FootprintPreview", "appearance.footprint_preview" );
ret &= fromLegacy<bool>( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" );
ret &= fromLegacy<bool>( aCfg, "PrintSheetReferenceAndTitleBlock",
"appearance.print_sheet_reference" );
ret &= fromLegacy<bool>( aCfg, "ShowHiddenPins", "appearance.show_hidden_pins" );
ret &= fromLegacy<bool>( aCfg, "ShowIllegalSymbolLibDialog",
"appearance.show_illegal_symbol_lib_dialog" );
ret &= fromLegacy<bool>( aCfg, "ShowPageLimits", "appearance.show_page_limits" );
ret &= fromLegacy<bool>( aCfg, "ShowSheetFileNameCaseSensitivityDlg",
"appearance.show_sheet_filename_case_sensitivity_dialog" );
ret &= fromLegacy<bool>( aCfg, "AutoplaceFields", "autoplace_fields.enable" );
ret &= fromLegacy<bool>( aCfg, "AutoplaceJustify", "autoplace_fields.allow_rejustify" );
ret &= fromLegacy<bool>( aCfg, "AutoplaceAlign", "autoplace_fields.align_to_grid" );
ret &= fromLegacy<int>( aCfg, "DefaultBusWidth", "drawing.default_bus_thickness" );
ret &= fromLegacy<int>( aCfg, "DefaultJunctionSize", "drawing.default_junction_size" );
ret &= fromLegacy<int>( aCfg, "DefaultDrawLineWidth", "drawing.default_line_thickness" );
ret &= fromLegacy<int>( aCfg, "RepeatStepX", "drawing.default_repeat_offset_x" );
ret &= fromLegacy<int>( aCfg, "RepeatStepY", "drawing.default_repeat_offset_y" );
ret &= fromLegacy<int>( aCfg, "DefaultWireWidth", "drawing.default_wire_thickness" );
ret &= fromLegacyString( aCfg, "FieldNames", "drawing.field_names" );
ret &= fromLegacy<bool>( aCfg, "HorizVertLinesOnly", "drawing.hv_lines_only" );
ret &= fromLegacy<int>( aCfg, "RepeatLabelIncrement", "drawing.repeat_label_increment" );
ret &= fromLegacy<int>( aCfg, "TextMarkupFlags", "drawing.text_markup_flags" );
ret &= fromLegacy<bool>( aCfg, "DragActionIsMove", "input.drag_is_move" );
ret &= fromLegacy<int>( aCfg, "SelectionThickness", "selection.thickness" );
ret &= fromLegacy<bool>( aCfg, "SelectionDrawChildItems", "selection.draw_selected_children" );
ret &= fromLegacy<bool>( aCfg, "SelectionFillShapes", "selection.fill_shapes" );
ret &= fromLegacy<bool>( aCfg, "SelectPinSelectSymbolOpt",
"selection.select_pin_selects_symbol" );
ret &= fromLegacy<bool>( aCfg, "SelectionTextAsBox", "selection.text_as_box" );
ret &= fromLegacy<int>( aCfg, "AnnotateAlgoOption", "annotation.method" );
ret &= fromLegacy<int>( aCfg, "AnnotateFilterMsg", "annotation.messages_filter" );
ret &= fromLegacy<int>( aCfg, "AnnotateSortOption", "annotation.sort_order" );
ret &= fromLegacyString( aCfg, "bom_plugin_selected", "bom.selected_plugin" );
ret &= fromLegacyString( aCfg, "bom_plugins", "bom.plugins" );
ret &= fromLegacyString( aCfg, "SymbolFieldsShownColumns",
"edit_sch_component.visible_columns" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportRevision", "page_settings.export_revision" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportDate", "page_settings.export_date" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportTitle", "page_settings.export_title" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportCompany", "page_settings.export_company" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment1", "page_settings.export_comment1" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment2", "page_settings.export_comment2" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment3", "page_settings.export_comment3" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment4", "page_settings.export_comment4" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment5", "page_settings.export_comment5" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment6", "page_settings.export_comment6" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment7", "page_settings.export_comment7" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment8", "page_settings.export_comment8" );
ret &= fromLegacy<bool>( aCfg, "PageSettingsExportComment9", "page_settings.export_comment9" );
{
constexpr int max_custom_commands = 8; // from DIALOG_NETLIST
nlohmann::json js_cmd = nlohmann::json::array();
nlohmann::json js_title = nlohmann::json::array();
wxString cmd_key, title_key, cmd, title;
for( int i = 1; i <= max_custom_commands; ++i )
{
// Only migrate if both title and command are specified
cmd_key.Printf( "CustomNetlistCommand%d", i );
title_key.Printf( "CustomNetlistTitle%d", i );
if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
&& !cmd.IsEmpty() && !title.IsEmpty() )
{
js_cmd.push_back( cmd.ToUTF8() );
js_title.push_back( title.ToUTF8() );
}
}
( *this )[PointerFromString( "netlist.custom_command_titles" )] = js_title;
( *this )[PointerFromString( "netlist.custom_command_paths" )] = js_cmd;
}
{
// NOTE(JE) These parameters should move to project-local storage before V6, but we are
// migrating them here in order to preserve data. There is a bug here that is preserved:
// keys are taken directly from the (translated) UI and stored in the config, so if the user
// changes languages the keys will no longer work.
aCfg->SetPath( "SymbolFieldEditor/Show/" );
nlohmann::json js = nlohmann::json( {} );
wxString key;
bool value = false;
long index = 0;
while( aCfg->GetNextEntry( key, index ) )
{
if( aCfg->Read( key, &value ) )
{
std::string key_utf( key.ToUTF8() );
js[PointerFromString( key_utf )] = value;
}
}
( *this )[PointerFromString( "field_editor.fields_show" ) ] = js;
aCfg->SetPath( "../GroupBy" );
while( aCfg->GetNextEntry( key, index ) )
{
if( aCfg->Read( key, &value ) )
{
std::string key_utf( key.ToUTF8() );
js[PointerFromString( key_utf )] = value;
}
}
( *this )[PointerFromString( "field_editor.fields_group_by" ) ] = js;
aCfg->SetPath( "../.." );
}
ret &= fromLegacy<bool>( aCfg, "PlotModeColor", "plot.color" );
ret &= fromLegacy<int>( aCfg, "PlotFormat", "plot.format" );
ret &= fromLegacy<bool>( aCfg, "PlotFrameRef", "plot.frame_reference" );
ret &= fromLegacy<bool>( aCfg, "PlotHPGLOrg", "plot.hpgl_origin" );
ret &= fromLegacy<int>( aCfg, "PlotHPGLPaperSize", "plot.hpgl_paper_size" );
ret &= fromLegacy<double>( aCfg, "PlotHPGLPenSize", "plot.hpgl_pen_size" );
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_x", "simulator.window.pos_x" );
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMEPos_y", "simulator.window.pos_y" );
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_x", "simulator.window.size_x" );
ret &= fromLegacy<int>( aCfg, "SIM_PLOT_FRAMESize_y", "simulator.window.size_y" );
ret &= fromLegacy<bool>( aCfg, "SIM_PLOT_FRAMEMaximized", "simulator.window.maximized" );
ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEPerspective", "simulator.window.perspective" );
ret &= fromLegacyString( aCfg, "SIM_PLOT_FRAMEMostRecentlyUsedPath", "simulator.mru_path" );
ret &= fromLegacy<int>( aCfg, "SimPlotPanelWidth", "simulator.plot_panel_width" );
ret &= fromLegacy<int>( aCfg, "SimPlotPanelHeight", "simulator.plot_panel_height" );
ret &= fromLegacy<int>( aCfg, "SimSignalPanelHeight", "simulator.signal_panel_height" );
ret &= fromLegacy<int>( aCfg, "SimCursorsPanelHeight", "simulator.cursors_panel_height" );
ret &= fromLegacy<bool>( aCfg, "SimPlotWhiteBg", "simulator.white_background" );
ret &= fromLegacy<int>( aCfg, "SymbolChooserHSashPosition", "symbol_chooser.sash_pos_h" );
ret &= fromLegacy<int>( aCfg, "SymbolChooserVSashPosition", "symbol_chooser.sash_pos_v" );
ret &= fromLegacy<int>( aCfg, "SymbolChooserWidth", "symbol_chooser.width" );
ret &= fromLegacy<int>( aCfg, "SymbolChooserHeight", "symbol_chooser.height" );
ret &= fromLegacy<bool>( aCfg, "SymbolChooserKeepSymbol", "symbol_chooser.keep_symbol" );
ret &= fromLegacy<bool>( aCfg, "SymbolChooserUseUnits", "symbol_chooser.place_all_units" );
const std::string vlf = "ViewlibFrame";
ret &= fromLegacy<bool>( aCfg, vlf + "Maximized", "lib_view.window.maximized" );
ret &= fromLegacyString( aCfg, vlf + "MostRecentlyUsedPath", "lib_view.window.mru_path" );
ret &= fromLegacy<int>( aCfg, vlf + "Size_x", "lib_view.window.size_x" );
ret &= fromLegacy<int>( aCfg, vlf + "Size_y", "lib_view.window.size_y" );
ret &= fromLegacyString( aCfg, vlf + "Perspective", "lib_view.window.perspective" );
ret &= fromLegacy<int>( aCfg, vlf + "Pos_x", "lib_view.window.pos_x" );
ret &= fromLegacy<int>( aCfg, vlf + "Pos_y", "lib_view.window.pos_y" );
ret &= fromLegacy<int>( aCfg, "ViewLiblistWidth", "lib_view.lib_list_width" );
ret &= fromLegacy<int>( aCfg, "ViewCmplistWidth", "lib_view.cmp_list_width" );
ret &= fromLegacy<bool>( aCfg,
"ViewCmpShowPinElectricalType", "lib_view.show_pin_electrical_type" );
ret &= fromLegacy<bool>( aCfg, vlf + "ShowGrid", "lib_view.grid.show" );
ret &= fromLegacy<int>( aCfg, vlf + "_LastGridSize", "lib_view.grid.last_size" );
ret &= fromLegacy<bool>( aCfg, "RescueNeverShow", "system.never_show_rescue_dialog" );
// Legacy version stored this setting in eeschema, so move it to common if it exists
aCfg->Read( "MoveWarpsCursor", &Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move );
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) {
wxString str;
if( aCfg->Read( aKey, &str ) )
cs->SetColor( aLayerId, COLOR4D( str ) );
};
migrateLegacyColor( "Color4DBgCanvasEx", LAYER_SCHEMATIC_BACKGROUND );
migrateLegacyColor( "Color4DBodyBgEx", LAYER_DEVICE_BACKGROUND );
migrateLegacyColor( "Color4DBodyEx", LAYER_DEVICE );
migrateLegacyColor( "Color4DBrightenedEx", LAYER_BRIGHTENED );
migrateLegacyColor( "Color4DBusEx", LAYER_BUS );
migrateLegacyColor( "Color4DConnEx", LAYER_JUNCTION );
migrateLegacyColor( "Color4DCursorEx", LAYER_SCHEMATIC_CURSOR );
migrateLegacyColor( "Color4DErcEEx", LAYER_ERC_ERR );
migrateLegacyColor( "Color4DErcWEx", LAYER_ERC_WARN );
migrateLegacyColor( "Color4DFieldEx", LAYER_FIELDS );
migrateLegacyColor( "Color4DGLabelEx", LAYER_GLOBLABEL );
migrateLegacyColor( "Color4DGridEx", LAYER_SCHEMATIC_GRID );
migrateLegacyColor( "Color4DHLabelEx", LAYER_HIERLABEL );
migrateLegacyColor( "Color4DHiddenEx", LAYER_HIDDEN );
migrateLegacyColor( "Color4DLLabelEx", LAYER_LOCLABEL );
migrateLegacyColor( "Color4DNetNameEx", LAYER_NETNAM );
migrateLegacyColor( "Color4DNoConnectEx", LAYER_NOCONNECT );
migrateLegacyColor( "Color4DNoteEx", LAYER_NOTES );
migrateLegacyColor( "Color4DPinEx", LAYER_PIN );
migrateLegacyColor( "Color4DPinNameEx", LAYER_PINNAM );
migrateLegacyColor( "Color4DPinNumEx", LAYER_PINNUM );
migrateLegacyColor( "Color4DReferenceEx", LAYER_REFERENCEPART );
migrateLegacyColor( "Color4DShadowEx", LAYER_SELECTION_SHADOWS );
migrateLegacyColor( "Color4DSheetEx", LAYER_SHEET );
migrateLegacyColor( "Color4DSheetFileNameEx", LAYER_SHEETFILENAME );
migrateLegacyColor( "Color4DSheetLabelEx", LAYER_SHEETLABEL );
migrateLegacyColor( "Color4DSheetNameEx", LAYER_SHEETNAME );
migrateLegacyColor( "Color4DValueEx", LAYER_VALUEPART );
migrateLegacyColor( "Color4DWireEx", LAYER_WIRE );
migrateLegacyColor( "Color4DWorksheetEx", LAYER_SCHEMATIC_WORKSHEET );
// LibEdit settings were stored with eeschema. If eeschema is the first app to run,
// we need to migrate the LibEdit settings here
auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>( false );
libedit->MigrateFromLegacy( aCfg );
libedit->Load();
return ret;
}

View File

@ -0,0 +1,203 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _EESCHEMA_SETTINGS_H
#define _EESCHEMA_SETTINGS_H
#include <settings/app_settings.h>
class EESCHEMA_SETTINGS : public APP_SETTINGS_BASE
{
public:
struct APPEARANCE
{
wxString edit_component_visible_columns;
bool footprint_preview;
bool navigator_stays_open;
bool print_sheet_reference;
bool show_hidden_pins;
bool show_illegal_symbol_lib_dialog;
bool show_page_limits;
bool show_sheet_filename_case_sensitivity_dialog;
};
struct AUTOPLACE_FIELDS
{
bool enable;
bool allow_rejustify;
bool align_to_grid;
};
struct DRAWING
{
int default_bus_thickness;
int default_junction_size;
int default_line_thickness;
int default_repeat_offset_x;
int default_repeat_offset_y;
int default_wire_thickness;
wxString field_names;
bool hv_lines_only;
int repeat_label_increment;
int text_markup_flags;
};
struct INPUT
{
bool drag_is_move;
};
struct SELECTION
{
int thickness;
bool draw_selected_children;
bool fill_shapes;
bool select_pin_selects_symbol;
bool text_as_box;
};
struct PAGE_SETTINGS
{
bool export_revision;
bool export_date;
bool export_title;
bool export_company;
bool export_comment1;
bool export_comment2;
bool export_comment3;
bool export_comment4;
bool export_comment5;
bool export_comment6;
bool export_comment7;
bool export_comment8;
bool export_comment9;
};
struct PANEL_ANNOTATE
{
int method;
int messages_filter;
int sort_order;
};
struct PANEL_BOM
{
wxString selected_plugin;
wxString plugins;
};
struct PANEL_FIELD_EDITOR
{
std::map<std::string, bool> fields_show;
std::map<std::string, bool> fields_group_by;
};
struct PANEL_LIB_VIEW
{
int lib_list_width;
int cmp_list_width;
bool show_pin_electrical_type;
WINDOW_SETTINGS window;
};
struct PANEL_NETLIST
{
std::vector<wxString> custom_command_titles;
std::vector<wxString> custom_command_paths;
};
struct PANEL_PLOT
{
bool color;
int format;
bool frame_reference;
int hpgl_paper_size;
double hpgl_pen_size;
bool hpgl_origin;
};
struct PANEL_SYM_CHOOSER
{
int sash_pos_h;
int sash_pos_v;
int width;
int height;
bool keep_symbol;
bool place_all_units;
};
struct SIMULATOR
{
int plot_panel_width;
int plot_panel_height;
int signal_panel_height;
int cursors_panel_height;
bool white_background;
WINDOW_SETTINGS window;
};
EESCHEMA_SETTINGS();
virtual ~EESCHEMA_SETTINGS() {}
virtual bool MigrateFromLegacy( wxConfigBase* aLegacyConfig ) override;
APPEARANCE m_Appearance;
AUTOPLACE_FIELDS m_AutoplaceFields;
DRAWING m_Drawing;
INPUT m_Input;
PAGE_SETTINGS m_PageSettings;
PANEL_ANNOTATE m_AnnotatePanel;
PANEL_BOM m_BomPanel;
PANEL_FIELD_EDITOR m_FieldEditorPanel;
PANEL_LIB_VIEW m_LibViewPanel;
PANEL_NETLIST m_NetlistPanel;
PANEL_PLOT m_PlotPanel;
PANEL_SYM_CHOOSER m_SymChooserPanel;
SELECTION m_Selection;
SIMULATOR m_Simulator;
bool m_RescueNeverShow;
protected:
virtual std::string getLegacyFrameName() const override { return "SchematicFrame"; }
};
#endif

View File

@ -43,6 +43,7 @@
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <project_rescue.h> #include <project_rescue.h>
#include <eeschema_config.h> #include <eeschema_config.h>
#include <eeschema_settings.h>
#include <sch_legacy_plugin.h> #include <sch_legacy_plugin.h>
#include <sch_eagle_plugin.h> #include <sch_eagle_plugin.h>
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
@ -382,11 +383,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// Check to see whether some old library parts need to be rescued // Check to see whether some old library parts need to be rescued
// Only do this if RescueNeverShow was not set. // Only do this if RescueNeverShow was not set.
wxConfigBase *config = Kiface().KifaceSettings(); auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
bool rescueNeverShow = false;
config->Read( RescueNeverShowEntry, &rescueNeverShow, false );
if( !rescueNeverShow ) if( !cfg->m_RescueNeverShow )
RescueSymbolLibTableProject( false ); RescueSymbolLibTableProject( false );
} }

View File

@ -148,7 +148,12 @@ int GetSelectionThickness();
void SetSelectionThickness( int aThickness ); void SetSelectionThickness( int aThickness );
COLOR4D GetLayerColor( SCH_LAYER_ID aLayer ); COLOR4D GetLayerColor( SCH_LAYER_ID aLayer );
void SetLayerColor( COLOR4D aColor, SCH_LAYER_ID aLayer );
/**
* Update the static layer color cache used by GetLayerColor()
* TODO(JE) Remove this once eeschema is refactored to not need s_layerColor[]
*/
void OnColorsChanged();
// Color to draw selected items // Color to draw selected items
COLOR4D GetItemSelectedColor(); COLOR4D GetItemSelectedColor();

View File

@ -31,6 +31,7 @@
#include <dialog_choose_component.h> #include <dialog_choose_component.h>
#include <eda_doc.h> #include <eda_doc.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <eeschema_settings.h>
#include <fctsys.h> #include <fctsys.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <kiway.h> #include <kiway.h>
@ -42,6 +43,7 @@
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
#include <symbol_tree_model_adapter.h> #include <symbol_tree_model_adapter.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/tool_dispatcher.h> #include <tool/tool_dispatcher.h>
@ -601,33 +603,18 @@ void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
} }
#define LIBLIST_WIDTH_KEY "ViewLiblistWidth" void LIB_VIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
#define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
#define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType"
void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
{ {
EDA_DRAW_FRAME::LoadSettings( aCfg ); auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
// Fetch display settings from Symbol Editor as the Symbol Viewer EDA_DRAW_FRAME::LoadSettings( cfg );
// doesn't have its own config
wxString symbolEditor = LIB_EDIT_FRAME_NAME;
bool btmp;
COLOR4D wtmp;
if( aCfg->Read( symbolEditor + ShowGridEntryKeyword, &btmp ) )
SetGridVisibility( btmp );
if( wtmp.SetFromWxString( aCfg->Read( symbolEditor + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
SetGridColor( wtmp );
// Grid shape, etc. // Grid shape, etc.
GetGalDisplayOptions().ReadAppConfig( *aCfg, symbolEditor ); GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 ); m_libListWidth = cfg->m_LibViewPanel.lib_list_width;
aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 ); m_cmpListWidth = cfg->m_LibViewPanel.cmp_list_width;
m_showPinElectricalTypeName = aCfg->Read( CMPVIEW_SHOW_PINELECTRICALTYPE_KEY, true ); m_showPinElectricalTypeName = cfg->m_LibViewPanel.show_pin_electrical_type;
// Set parameters to a reasonable value. // Set parameters to a reasonable value.
if( m_libListWidth > m_FrameSize.x/2 ) if( m_libListWidth > m_FrameSize.x/2 )
@ -638,20 +625,28 @@ void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
} }
void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg ) void LIB_VIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
{ {
EDA_DRAW_FRAME::SaveSettings( aCfg ); auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
EDA_DRAW_FRAME::SaveSettings( cfg );
if( m_libListWidth && m_libList ) if( m_libListWidth && m_libList )
{
m_libListWidth = m_libList->GetSize().x; m_libListWidth = m_libList->GetSize().x;
aCfg->Write( LIBLIST_WIDTH_KEY, m_libListWidth );
}
m_cmpListWidth = m_cmpList->GetSize().x; m_cmpListWidth = m_cmpList->GetSize().x;
aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
aCfg->Write( CMPVIEW_SHOW_PINELECTRICALTYPE_KEY, m_showPinElectricalTypeName ); cfg->m_LibViewPanel.lib_list_width = m_libListWidth;
cfg->m_LibViewPanel.cmp_list_width = m_cmpListWidth;
cfg->m_LibViewPanel.show_pin_electrical_type = m_showPinElectricalTypeName;
}
WINDOW_SETTINGS* LIB_VIEW_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
wxASSERT( cfg );
return &cfg->m_LibViewPanel.window;
} }

View File

@ -99,8 +99,11 @@ public:
void ClickOnCmpList( wxCommandEvent& event ); void ClickOnCmpList( wxCommandEvent& event );
void OnSelectSymbol( wxCommandEvent& aEvent ); void OnSelectSymbol( wxCommandEvent& aEvent );
void LoadSettings( wxConfigBase* aCfg ) override; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override;
void CommonSettingsChanged( bool aEnvVarsChanged ) override; void CommonSettingsChanged( bool aEnvVarsChanged ) override;
/** /**

View File

@ -23,41 +23,44 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <base_screen.h>
#include <class_library.h>
#include <confirm.h>
#include <eeschema_id.h>
#include <eeschema_settings.h>
#include <fctsys.h> #include <fctsys.h>
#include <pgm_base.h> #include <general.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <kiway_express.h> #include <kiway_express.h>
#include <sch_draw_panel.h>
#include <base_screen.h>
#include <confirm.h>
#include <general.h>
#include <eeschema_id.h>
#include <lib_edit_frame.h> #include <lib_edit_frame.h>
#include <class_library.h>
#include <lib_manager.h> #include <lib_manager.h>
#include <widgets/symbol_tree_pane.h> #include <libedit_settings.h>
#include <widgets/lib_tree.h> #include <pgm_base.h>
#include <sch_draw_panel.h>
#include <sch_painter.h>
#include <sch_view.h>
#include <settings/settings_manager.h>
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
#include <wildcards_and_files_ext.h>
#include <wx/progdlg.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h> #include <tool/action_toolbar.h>
#include <tool/common_control.h> #include <tool/common_control.h>
#include <tool/picker_tool.h>
#include <tool/common_tools.h> #include <tool/common_tools.h>
#include <tool/picker_tool.h>
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <tool/zoom_tool.h> #include <tool/zoom_tool.h>
#include <tools/ee_actions.h> #include <tools/ee_actions.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_inspection_tool.h> #include <tools/ee_inspection_tool.h>
#include <tools/lib_pin_tool.h> #include <tools/ee_point_editor.h>
#include <tools/ee_selection_tool.h>
#include <tools/lib_control.h>
#include <tools/lib_drawing_tools.h>
#include <tools/lib_edit_tool.h> #include <tools/lib_edit_tool.h>
#include <tools/lib_move_tool.h> #include <tools/lib_move_tool.h>
#include <tools/lib_drawing_tools.h> #include <tools/lib_pin_tool.h>
#include <tools/lib_control.h> #include <widgets/lib_tree.h>
#include <tools/ee_point_editor.h> #include <widgets/symbol_tree_pane.h>
#include <sch_view.h> #include <wildcards_and_files_ext.h>
#include <sch_painter.h> #include <wx/progdlg.h>
bool LIB_EDIT_FRAME:: m_showDeMorgan = false; bool LIB_EDIT_FRAME:: m_showDeMorgan = false;
@ -123,7 +126,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) );
SetIcon( icon ); SetIcon( icon );
LoadSettings( config() ); m_settings = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
LoadSettings( m_settings );
// Ensure axis are always drawn // Ensure axis are always drawn
KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions(); KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
@ -203,10 +207,82 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
// current screen is destroyed in EDA_DRAW_FRAME // current screen is destroyed in EDA_DRAW_FRAME
SetScreen( m_dummyScreen ); SetScreen( m_dummyScreen );
auto libedit = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
Pgm().GetSettingsManager().Save( libedit );
delete m_libMgr; delete m_libMgr;
} }
void LIB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
EDA_DRAW_FRAME::LoadSettings( aCfg );
auto cfg = dynamic_cast<LIBEDIT_SETTINGS*>( aCfg );
wxASSERT( cfg );
SetDefaultLineThickness( Mils2iu( cfg->m_Defaults.line_width ) );
SetDefaultPinLength( Mils2iu( cfg->m_Defaults.pin_length ) );
m_textPinNameDefaultSize = Mils2iu( cfg->m_Defaults.pin_name_size );
m_textPinNumDefaultSize = Mils2iu( cfg->m_Defaults.pin_num_size );
SetRepeatDeltaLabel( cfg->m_Repeat.label_delta );
SetRepeatPinStep( Mils2iu( cfg->m_Repeat.pin_step ) );
SetRepeatStep( wxPoint( cfg->m_Repeat.x_step, cfg->m_Repeat.y_step ) );
m_showPinElectricalTypeName = cfg->m_ShowPinElectricalType;
m_defaultLibWidth = cfg->m_LibWidth;
// TODO(JE) does libedit need its own TemplateFieldNames?
auto ee_settings = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
wxASSERT( ee_settings );
wxString templateFieldNames = ee_settings->m_Drawing.field_names;
if( !templateFieldNames.IsEmpty() )
{
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
try
{
m_templateFieldNames.Parse( &lexer );
}
catch( const IO_ERROR& DBG( e ) )
{
// @todo show error msg
DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); )
}
}
auto painter = static_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
KIGFX::SCH_RENDER_SETTINGS* settings = painter->GetSettings();
settings->m_ShowPinsElectricalType = m_showPinElectricalTypeName;
// Hidden elements must be editable
settings->m_ShowHiddenText = true;
settings->m_ShowHiddenPins = true;
settings->m_ShowUmbilicals = false;
}
void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
{
// aCfg will be EESCHEMA_SETTINGS because that's the parent FACE
// so we throw it away here and get our own settings
auto cfg = Pgm().GetSettingsManager().GetAppSettings<LIBEDIT_SETTINGS>();
EDA_DRAW_FRAME::SaveSettings( cfg );
cfg->m_Defaults.line_width = Iu2Mils( GetDefaultLineThickness() );
cfg->m_Defaults.pin_length = Iu2Mils( GetDefaultPinLength() );
cfg->m_Defaults.pin_name_size = Iu2Mils( GetPinNameDefaultSize() );
cfg->m_Defaults.pin_num_size = Iu2Mils( GetPinNumDefaultSize() );
cfg->m_Repeat.label_delta = GetRepeatDeltaLabel();
cfg->m_Repeat.pin_step = Iu2Mils( GetRepeatPinStep() );
cfg->m_Repeat.x_step = Iu2Mils( GetRepeatStep().x );
cfg->m_Repeat.y_step = Iu2Mils( GetRepeatStep().y );
cfg->m_ShowPinElectricalType = GetShowElectricalType();
cfg->m_LibWidth = m_treePane->GetSize().x;
}
void LIB_EDIT_FRAME::setupTools() void LIB_EDIT_FRAME::setupTools()
{ {
// Create the manager and dispatcher & route draw panel events to the dispatcher // Create the manager and dispatcher & route draw panel events to the dispatcher

View File

@ -43,6 +43,7 @@ class SYMBOL_TREE_PANE;
class LIB_TREE_NODE; class LIB_TREE_NODE;
class LIB_ID; class LIB_ID;
class LIB_MANAGER; class LIB_MANAGER;
class LIBEDIT_SETTINGS;
/** /**
@ -56,6 +57,7 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME
// has multiple units) // has multiple units)
SYMBOL_TREE_PANE* m_treePane; // component search tree widget SYMBOL_TREE_PANE* m_treePane; // component search tree widget
LIB_MANAGER* m_libMgr; // manager taking care of temporary modifications LIB_MANAGER* m_libMgr; // manager taking care of temporary modifications
LIBEDIT_SETTINGS* m_settings; // Handle to the settings
// The unit number to edit and show // The unit number to edit and show
int m_unit; int m_unit;
@ -255,8 +257,13 @@ public:
void ReCreateVToolbar() override; void ReCreateVToolbar() override;
void ReCreateOptToolbar() override; void ReCreateOptToolbar() override;
void LoadSettings( wxConfigBase* aCfg ) override; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
LIBEDIT_SETTINGS* GetSettings()
{
return m_settings;
}
/** /**
* Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro: * Trigger the wxCloseEvent, which is handled by the function given to EVT_CLOSE() macro:

Some files were not shown because too many files have changed in this diff Show More