mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-03-30 06:06:55 +00:00
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:
parent
1449af40ed
commit
e59a3d981e
3d-viewer
bitmap2component
CMakeLists.txtbitmap2cmp_gui.cppbitmap2cmp_gui.hbitmap2cmp_main.cppbitmap2cmp_settings.cppbitmap2cmp_settings.h
common
CMakeLists.txtadvanced_config.cppbin_mod.cppbitmap.cppboard_printout.cppcommon.cpp
dialogs
dialog_migrate_settings.cppdialog_migrate_settings.hdialog_migrate_settings_base.cppdialog_migrate_settings_base.fbpdialog_migrate_settings_base.hdialog_page_settings.cppdialog_print_generic.hpanel_common_settings.cpp
dpi_scaling.cppdraw_panel_gal.cppeda_base_frame.cppeda_doc.cppeda_draw_frame.cppfilehistory.cppfp_lib_table.cppgal
hotkeys_basic.cppkiface_i.cpplib_table_base.cpplib_tree_model_adapter.cpplib_tree_model_adapter.hpage_layout
pgm_base.cppprintout.cppsettings
app_settings.cppcolor_settings.cppcommon_settings.cppjson_settings.cppnested_settings.cppsettings_manager.cpp
single_top.cppswig
tool
view
cvpcb
CMakeLists.txtcvpcb.cppcvpcb_mainframe.cppcvpcb_mainframe.hcvpcb_settings.cppcvpcb_settings.h
dialogs
display_footprints_frame.cppdisplay_footprints_frame.heeschema
CMakeLists.txtautoplace_fields.cppconnection_graph.cpp
dialogs
dialog_annotate.cppdialog_bom.cppdialog_choose_component.cppdialog_choose_component.hdialog_edit_component_in_lib.cppdialog_edit_component_in_lib.hdialog_edit_component_in_schematic.cppdialog_edit_component_in_schematic.hdialog_fields_editor_global.cppdialog_fields_editor_global.hdialog_global_edit_text_and_graphics.cppdialog_lib_edit_pin_table.cppdialog_lib_edit_pin_table.hdialog_netlist.cppdialog_plot_schematic.cppdialog_plot_schematic.hdialog_print_using_printer.cppdialog_rescue_each.cpp
eeschema.cppeeschema_config.cppeeschema_settings.cppeeschema_settings.hfiles-io.cppgeneral.hlib_view_frame.cpplib_view_frame.hlibedit
sch_base_frame.cppsch_connection.cppsch_draw_panel.cppsch_edit_frame.cppsch_edit_frame.hsch_painter.cppsch_painter.hsch_preview_panel.cppsch_preview_panel.hsch_view.cppsim
symbol_lib_table.cpptools
widgets
gerbview
CMakeLists.txt
dialogs
gbr_layout.hgerbview.cppgerbview_config.cppgerbview_draw_panel_gal.cppgerbview_draw_panel_gal.hgerbview_frame.cppgerbview_frame.hgerbview_layer_widget.cppgerbview_painter.cppgerbview_painter.hgerbview_settings.cppgerbview_settings.hmenubar.cppselect_layers_to_pcb.cppinclude
advanced_config.hbin_mod.hboard_design_settings.hboard_printout.hcommon.hdpi_scaling.heda_base_frame.heda_draw_frame.hfilehistory.h
gal
kiface_i.hkiway.hlayers_id_colors_and_visibility.hpainter.hpcb_base_frame.hpgm_base.hplotter.hprintout.hsettings
app_settings.hcolor_settings.hcommon_settings.hjson_settings.hnested_settings.hparameters.hsettings_manager.h
tool
ws_painter.hws_proxy_view_item.hkicad
CMakeLists.txtkicad.cppkicad_manager_frame.cppkicad_manager_frame.hkicad_settings.cppkicad_settings.hpgm_kicad.h
pagelayout_editor
CMakeLists.txtpl_draw_panel_gal.cpppl_editor.cpppl_editor_frame.cpppl_editor_frame.hpl_editor_settings.cpppl_editor_settings.h
pcb_calculator
CMakeLists.txt
attenuators
board_classes_values.cppcolorcode.cppelectrical_spacing_values.cppparams_read_write.cpppcb_calculator.cpppcb_calculator.hpcb_calculator_frame.cpppcb_calculator_settings.cpppcb_calculator_settings.hregulators_funct.cpptracks_width_versus_current.cpptransline_dlg_funct.cpptransline_ident.cpptransline_ident.hvia.cpppcbnew
CMakeLists.txtboard_design_settings.cppclass_board.cppclass_board.hclass_dimension.cppclass_drawsegment.cppclass_edge_mod.cppclass_pcb_target.cppclass_pcb_text.cppclass_text_mod.cppclass_track.cppclass_zone.cpp
dialogs
dialog_choose_footprint.cppdialog_choose_footprint.hdialog_cleanup_tracks_and_vias.cppdialog_cleanup_tracks_and_vias.hdialog_copper_zones.cppdialog_drc.cppdialog_drc.hdialog_edit_footprint_for_BoardEditor.cppdialog_edit_footprint_for_BoardEditor.hdialog_edit_footprint_for_fp_editor.cppdialog_edit_footprint_for_fp_editor.hdialog_exchange_footprints.cppdialog_export_idf.cppdialog_export_step.cppdialog_export_svg.cppdialog_export_vrml.cppdialog_footprint_wizard_list.cppdialog_footprint_wizard_list.hdialog_gendrill.cppdialog_gendrill.hdialog_get_footprint_by_name.hdialog_keepout_area_properties.cppdialog_netlist.cppdialog_netlist.hdialog_non_copper_zones_properties.cppdialog_pad_properties.cppdialog_plot.cppdialog_plot.hdialog_update_pcb.cppdialog_update_pcb.hpanel_modedit_settings.cpppanel_pcbnew_action_plugins.cpppanel_pcbnew_settings.cppwizard_3DShape_Libs_downloader.cpp
exporters
footprint_edit_frame.cppfootprint_edit_frame.hfootprint_editor_options.cppfootprint_editor_settings.cppfootprint_editor_settings.hfootprint_editor_utils.cppfootprint_libraries_utils.cppfootprint_preview_panel.cppfootprint_preview_panel.hfootprint_viewer_frame.cppfootprint_viewer_frame.hfootprint_wizard_frame.cppfootprint_wizard_frame.hgrid_layer_box_helpers.cppimport_gfx
invoke_pcb_dialog.hkicad_plugin.cppload_select_footprint.cppmenubar_footprint_editor.cppmenubar_pcb_editor.cpppad_print_functions.cpppcad2kicadpcb_plugin
pcad2kicad_common.cpppcb.cpppcb_arc.cpppcb_component.cpppcb_copper_pour.cpppcb_cutout.cpppcb_keepout.cpppcb_line.cpppcb_module.cpppcb_net.cpppcb_pad.cpppcb_pad_shape.cpppcb_plane.cpppcb_polygon.cpppcb_text.cpppcb_via.cpppcb_via_shape.cpp
pcb_base_edit_frame.cpppcb_base_frame.cpppcb_draw_panel_gal.cpppcb_draw_panel_gal.hpcb_edit_frame.cpppcb_edit_frame.hpcb_general_settings.hpcb_layer_box_selector.cpppcb_layer_widget.cpppcb_painter.cpppcb_painter.hpcb_plot_params.cpppcb_plot_params.hpcbnew.cpppcbnew_config.cpppcbnew_printout.cpppcbnew_printout.hpcbnew_settings.cpppcbnew_settings.hpcbplot.hplot_board_layers.cppplot_brditems_plotter.cpppython/kicad_pyshell
router
length_tuner_tool.cpppns_router.cpppns_router.hpns_routing_settings.cpppns_routing_settings.hpns_tool_base.cpppns_tool_base.hrouter_tool.cpp
sel_layer.cppspecctra_import_export
swig
toolbars_pcb_editor.cpptools
drawing_tool.cppedit_tool.cppgrid_helper.cpppcb_editor_control.cpppcb_tool_base.cpppcbnew_control.cpp
undo_redo.cppzone_settings.cppzones.hqa
scripting
@ -57,6 +57,7 @@
|
||||
#include <filename_resolver.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
|
||||
#define MASK_3D_CACHE "3D_CACHE"
|
||||
@ -793,7 +794,7 @@ S3D_CACHE* PROJECT::Get3DCacheManager( bool aUpdateProjDir )
|
||||
cache = new S3D_CACHE();
|
||||
|
||||
wxFileName cfgpath;
|
||||
cfgpath.AssignDir( GetKicadConfigPath() );
|
||||
cfgpath.AssignDir( SETTINGS_MANAGER::GetUserSettingsPath() );
|
||||
cfgpath.AppendDir( wxT( "3d" ) );
|
||||
|
||||
cache->SetProgramBase( &Pgm() );
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/dir.h>
|
||||
#include <wx/dynlib.h>
|
||||
#include <wx/filename.h>
|
||||
|
@ -26,13 +26,14 @@
|
||||
|
||||
#include "panel_prev_model.h"
|
||||
#include <3d_canvas/eda_3d_canvas.h>
|
||||
#include <common_ogl/cogl_att_list.h>
|
||||
#include <class_board.h>
|
||||
#include <base_units.h>
|
||||
#include <bitmaps.h>
|
||||
#include <class_board.h>
|
||||
#include <common_ogl/cogl_att_list.h>
|
||||
#include <dpi_scaling.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
#include <settings/common_settings.h>
|
||||
|
||||
|
||||
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();
|
||||
|
||||
// Initialize the color settings to draw the board and the footprint
|
||||
m_dummyBoard->SetGeneralSettings( &aFrame->Settings() );
|
||||
|
||||
m_parentModelList = aParentModelList;
|
||||
|
||||
m_dummyModule = new MODULE( *aModule );
|
||||
@ -109,18 +107,12 @@ void PANEL_PREV_3D::loadCommonSettings()
|
||||
{
|
||||
wxCHECK_RET( m_previewPane, "Cannot load settings to null canvas" );
|
||||
|
||||
wxConfigBase& cmnCfg = *Pgm().CommonSettings();
|
||||
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
||||
|
||||
{
|
||||
const DPI_SCALING dpi{ &cmnCfg, this };
|
||||
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
}
|
||||
const DPI_SCALING dpi{ settings, this };
|
||||
m_previewPane->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
|
||||
{
|
||||
bool option;
|
||||
cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
|
||||
m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
}
|
||||
m_settings3Dviewer->SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan );
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "3d_fastmath.h"
|
||||
#include <geometry/geometry_utils.h>
|
||||
#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.
|
||||
@ -59,6 +61,9 @@ CINFO3D_VISU::CINFO3D_VISU() :
|
||||
m_3D_grid_type = GRID3D_TYPE::NONE;
|
||||
m_drawFlags.resize( FL_LAST, false );
|
||||
|
||||
if( PgmOrNull() )
|
||||
m_colors = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
m_render_engine = RENDER_ENGINE::OPENGL_LEGACY;
|
||||
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 );
|
||||
|
||||
const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId );
|
||||
const COLOR4D color = m_colors->GetColor( aLayerId );
|
||||
|
||||
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
|
||||
{
|
||||
return GetColor( m_board->Colors().GetItemColor( aItemId ) );
|
||||
return GetColor( m_colors->GetColor( aItemId ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +51,9 @@
|
||||
#include <class_module.h>
|
||||
#include <reporter.h>
|
||||
|
||||
|
||||
class COLOR_SETTINGS;
|
||||
|
||||
/// A type that stores a container of 2d objects for each layer id
|
||||
typedef std::map< PCB_LAYER_ID, CBVHCONTAINER2D *> MAP_CONTAINER_2D;
|
||||
|
||||
@ -127,6 +130,8 @@ class CINFO3D_VISU
|
||||
*/
|
||||
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
|
||||
* reload the settings for the board.
|
||||
@ -519,6 +524,8 @@ private:
|
||||
/// pointer to the 3d model manager
|
||||
S3D_CACHE *m_3d_model_manager;
|
||||
|
||||
/// pointer to current color settings
|
||||
COLOR_SETTINGS* m_colors;
|
||||
|
||||
// Render options
|
||||
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include <bitmaps.h>
|
||||
#include <hotkeys_basic.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
#include <widgets/wx_busy_indicator.h>
|
||||
|
||||
@ -153,6 +155,8 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow *aParent,
|
||||
wxASSERT( aBoard != NULL );
|
||||
m_settings.SetBoard( aBoard );
|
||||
|
||||
m_settings.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
|
||||
|
||||
wxASSERT( a3DCachePointer != NULL );
|
||||
m_settings.Set3DCacheManager( a3DCachePointer );
|
||||
}
|
||||
@ -285,6 +289,8 @@ void EDA_3D_CANVAS::ReloadRequest( BOARD *aBoard , S3D_CACHE *aCachePointer )
|
||||
if( aBoard != NULL )
|
||||
m_settings.SetBoard( aBoard );
|
||||
|
||||
m_settings.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
|
||||
|
||||
if( m_3d_render )
|
||||
m_3d_render->ReloadRequest();
|
||||
}
|
||||
|
157
3d-viewer/3d_viewer/3d_viewer_settings.cpp
Normal file
157
3d-viewer/3d_viewer/3d_viewer_settings.cpp
Normal 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;
|
||||
}
|
122
3d-viewer/3d_viewer/3d_viewer_settings.h
Normal file
122
3d-viewer/3d_viewer/3d_viewer_settings.h
Normal 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
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "eda_3d_viewer.h"
|
||||
|
||||
#include "3d_viewer_settings.h"
|
||||
|
||||
#include "../3d_viewer_id.h"
|
||||
#include "../common_ogl/cogl_att_list.h"
|
||||
@ -35,8 +35,11 @@
|
||||
#include <dpi_scaling.h>
|
||||
#include <gestfich.h>
|
||||
#include <hotkeys_basic.h>
|
||||
#include <layers_id_colors_and_visibility.h>
|
||||
#include <pgm_base.h>
|
||||
#include <project.h>
|
||||
#include <settings/common_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <tool/common_control.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
@ -56,67 +59,6 @@
|
||||
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 )
|
||||
|
||||
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 ) );
|
||||
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 );
|
||||
|
||||
// Create the status line
|
||||
@ -265,6 +208,9 @@ void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
|
||||
//delete m_canvas;
|
||||
//m_canvas = nullptr;
|
||||
|
||||
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
||||
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
|
||||
|
||||
Destroy();
|
||||
event.Skip( true );
|
||||
}
|
||||
@ -553,10 +499,9 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
||||
|
||||
case ID_MENU3D_RESET_DEFAULTS:
|
||||
{
|
||||
// Reload settings with a dummy config, so it will load the defaults
|
||||
wxConfig *fooconfig = new wxConfig( "FooBarApp" );
|
||||
LoadSettings( fooconfig );
|
||||
delete fooconfig;
|
||||
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
|
||||
cfg->ResetToDefaults();
|
||||
LoadSettings( cfg );
|
||||
|
||||
// Tell canvas that we (may have) changed the render engine
|
||||
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 );
|
||||
|
||||
auto cfg = dynamic_cast<EDA_3D_VIEWER_SETTINGS*>( aCfg );
|
||||
wxASSERT( cfg );
|
||||
|
||||
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings" );
|
||||
|
||||
aCfg->Read( keyBgColor_Red, &m_settings.m_BgColorBot.r, 0.4 );
|
||||
aCfg->Read( keyBgColor_Green, &m_settings.m_BgColorBot.g, 0.4 );
|
||||
aCfg->Read( keyBgColor_Blue, &m_settings.m_BgColorBot.b, 0.5 );
|
||||
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
aCfg->Read( keyBgColor_Red_Top, &m_settings.m_BgColorTop.r, 0.8 );
|
||||
aCfg->Read( keyBgColor_Green_Top, &m_settings.m_BgColorTop.g, 0.8 );
|
||||
aCfg->Read( keyBgColor_Blue_Top, &m_settings.m_BgColorTop.b, 0.9 );
|
||||
auto set_color = [] ( const COLOR4D& aColor, SFVEC3D& aTarget )
|
||||
{
|
||||
aTarget.r = aColor.r;
|
||||
aTarget.g = aColor.g;
|
||||
aTarget.b = aColor.b;
|
||||
};
|
||||
|
||||
// m_SolderMaskColorTop default value = dark grey-green
|
||||
aCfg->Read( keySMaskColor_Red, &m_settings.m_SolderMaskColorTop.r, 100.0 * 0.2 / 255.0 );
|
||||
aCfg->Read( keySMaskColor_Green, &m_settings.m_SolderMaskColorTop.g, 255.0 * 0.2 / 255.0 );
|
||||
aCfg->Read( keySMaskColor_Blue, &m_settings.m_SolderMaskColorTop.b, 180.0 * 0.2 / 255.0 );
|
||||
set_color( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_settings.m_BgColorBot );
|
||||
set_color( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_settings.m_BgColorTop );
|
||||
set_color( colors->GetColor( LAYER_3D_BOARD ), m_settings.m_BoardBodyColor );
|
||||
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
|
||||
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_settings.SetFlag( FL_USE_REALISTIC_MODE, cfg->m_Render.realistic );
|
||||
|
||||
// m_SolderPasteColor default value = light grey
|
||||
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 );
|
||||
m_settings.SetFlag( FL_SUBTRACT_MASK_FROM_SILK, cfg->m_Render.subtract_mask_from_silk );
|
||||
|
||||
// OpenGL options
|
||||
aCfg->Read( keyRenderOGL_ShowCopperTck, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, cfg->m_Render.opengl_copper_thickness );
|
||||
|
||||
aCfg->Read( keyRenderOGL_ShowModelBBox, &tmp, false );
|
||||
m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, cfg->m_Render.opengl_show_model_bbox );
|
||||
|
||||
// Raytracing options
|
||||
aCfg->Read( keyRenderRAY_Shadows, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_SHADOWS, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_SHADOWS, cfg->m_Render.raytrace_shadows );
|
||||
|
||||
aCfg->Read( keyRenderRAY_Backfloor, &tmp, false );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_BACKFLOOR, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_BACKFLOOR, cfg->m_Render.raytrace_backfloor );
|
||||
|
||||
aCfg->Read( keyRenderRAY_Refractions, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFRACTIONS, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFRACTIONS, cfg->m_Render.raytrace_refractions );
|
||||
|
||||
aCfg->Read( keyRenderRAY_Reflections, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFLECTIONS, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_REFLECTIONS, cfg->m_Render.raytrace_reflections );
|
||||
|
||||
aCfg->Read( keyRenderRAY_PostProcess, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING,
|
||||
cfg->m_Render.raytrace_post_processing );
|
||||
|
||||
aCfg->Read( keyRenderRAY_AAliasing, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, cfg->m_Render.raytrace_anti_aliasing );
|
||||
|
||||
aCfg->Read( keyRenderRAY_ProceduralT, &tmp, true );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, tmp );
|
||||
m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES,
|
||||
cfg->m_Render.raytrace_procedural_textures );
|
||||
|
||||
aCfg->Read( keyShowAxis, &tmp, true );
|
||||
m_settings.SetFlag( FL_AXIS, tmp );
|
||||
m_settings.SetFlag( FL_AXIS, cfg->m_Render.show_axis );
|
||||
|
||||
aCfg->Read( keyShowFootprints_Normal, &tmp, true );
|
||||
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL, tmp );
|
||||
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL, cfg->m_Render.show_footprints_normal );
|
||||
|
||||
aCfg->Read( keyShowFootprints_Insert, &tmp, true );
|
||||
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT, tmp );
|
||||
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT, cfg->m_Render.show_footprints_insert );
|
||||
|
||||
aCfg->Read( keyShowFootprints_Virtual, &tmp, true );
|
||||
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL, tmp );
|
||||
m_settings.SetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL, cfg->m_Render.show_footprints_virtual );
|
||||
|
||||
aCfg->Read( keyShowZones, &tmp, true );
|
||||
m_settings.SetFlag( FL_ZONE, tmp );
|
||||
m_settings.SetFlag( FL_ZONE, cfg->m_Render.show_zones );
|
||||
|
||||
aCfg->Read( keyShowAdhesiveLayers, &tmp, true );
|
||||
m_settings.SetFlag( FL_ADHESIVE, tmp );
|
||||
m_settings.SetFlag( FL_ADHESIVE, cfg->m_Render.show_adhesive );
|
||||
|
||||
aCfg->Read( keyShowSilkScreenLayers, &tmp, true );
|
||||
m_settings.SetFlag( FL_SILKSCREEN, tmp );
|
||||
m_settings.SetFlag( FL_SILKSCREEN, cfg->m_Render.show_silkscreen );
|
||||
|
||||
aCfg->Read( keyShowSolderMaskLayers, &tmp, true );
|
||||
m_settings.SetFlag( FL_SOLDERMASK, tmp );
|
||||
m_settings.SetFlag( FL_SOLDERMASK, cfg->m_Render.show_soldermask );
|
||||
|
||||
aCfg->Read( keyShowSolderPasteLayers, &tmp, true );
|
||||
m_settings.SetFlag( FL_SOLDERPASTE, tmp );
|
||||
m_settings.SetFlag( FL_SOLDERPASTE, cfg->m_Render.show_solderpaste );
|
||||
|
||||
aCfg->Read( keyShowCommentsLayer, &tmp, true );
|
||||
m_settings.SetFlag( FL_COMMENTS, tmp );
|
||||
m_settings.SetFlag( FL_COMMENTS, cfg->m_Render.show_comments );
|
||||
|
||||
aCfg->Read( keyShowEcoLayers, &tmp, true );
|
||||
m_settings.SetFlag( FL_ECO, tmp );
|
||||
m_settings.SetFlag( FL_ECO, cfg->m_Render.show_eco );
|
||||
|
||||
aCfg->Read( keyShowBoardBody, &tmp, true );
|
||||
m_settings.SetFlag( FL_SHOW_BOARD_BODY, tmp );
|
||||
m_settings.SetFlag( FL_SHOW_BOARD_BODY, cfg->m_Render.show_board_body );
|
||||
|
||||
int tmpi;
|
||||
aCfg->Read( keyShowGrid, &tmpi, static_cast<int>( GRID3D_TYPE::NONE ) );
|
||||
m_settings.GridSet( static_cast<GRID3D_TYPE>( tmpi ) );
|
||||
m_settings.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
|
||||
|
||||
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",
|
||||
( static_cast<RENDER_ENGINE>( tmpi ) == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
|
||||
"OpenGL" );
|
||||
m_settings.RenderEngineSet( static_cast<RENDER_ENGINE>( tmpi ) );
|
||||
( engine == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : "OpenGL" );
|
||||
m_settings.RenderEngineSet( engine );
|
||||
|
||||
aCfg->Read( keyRenderMaterial, &tmpi, static_cast<int>( MATERIAL_MODE::NORMAL ) );
|
||||
m_settings.MaterialModeSet( static_cast<MATERIAL_MODE>( tmpi ) );
|
||||
m_settings.MaterialModeSet( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
|
||||
}
|
||||
|
||||
|
||||
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" );
|
||||
|
||||
aCfg->Write( keyBgColor_Red, m_settings.m_BgColorBot.r );
|
||||
aCfg->Write( keyBgColor_Green, m_settings.m_BgColorBot.g );
|
||||
aCfg->Write( keyBgColor_Blue, m_settings.m_BgColorBot.b );
|
||||
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
aCfg->Write( keyBgColor_Red_Top, m_settings.m_BgColorTop.r );
|
||||
aCfg->Write( keyBgColor_Green_Top, m_settings.m_BgColorTop.g );
|
||||
aCfg->Write( keyBgColor_Blue_Top, m_settings.m_BgColorTop.b );
|
||||
auto save_color = [colors] ( SFVEC3D& aSource, LAYER_3D_ID aTarget )
|
||||
{
|
||||
colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 ) );
|
||||
};
|
||||
|
||||
aCfg->Write( keySMaskColor_Red, m_settings.m_SolderMaskColorTop.r );
|
||||
aCfg->Write( keySMaskColor_Green, m_settings.m_SolderMaskColorTop.g );
|
||||
aCfg->Write( keySMaskColor_Blue, m_settings.m_SolderMaskColorTop.b );
|
||||
save_color( m_settings.m_BgColorBot, LAYER_3D_BACKGROUND_BOTTOM );
|
||||
save_color( m_settings.m_BgColorTop, LAYER_3D_BACKGROUND_TOP );
|
||||
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",
|
||||
( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
|
||||
"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
|
||||
aCfg->Write( keyRenderOGL_ShowCopperTck,
|
||||
m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) );
|
||||
aCfg->Write( keyRenderOGL_ShowModelBBox,
|
||||
m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) );
|
||||
|
||||
// Raytracing options
|
||||
aCfg->Write( keyRenderRAY_Shadows, m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) );
|
||||
aCfg->Write( keyRenderRAY_Backfloor, m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) );
|
||||
aCfg->Write( keyRenderRAY_Refractions, m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) );
|
||||
aCfg->Write( keyRenderRAY_Reflections, m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) );
|
||||
aCfg->Write(
|
||||
keyRenderRAY_PostProcess, m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) );
|
||||
aCfg->Write( keyRenderRAY_AAliasing, m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) );
|
||||
aCfg->Write( keyRenderRAY_ProceduralT,
|
||||
m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
|
||||
|
||||
aCfg->Write( keyShowAxis, m_settings.GetFlag( FL_AXIS ) );
|
||||
aCfg->Write( keyShowGrid, (int) m_settings.GridGet() );
|
||||
|
||||
aCfg->Write( keyShowFootprints_Normal, m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL ) );
|
||||
aCfg->Write(
|
||||
keyShowFootprints_Insert, m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT ) );
|
||||
aCfg->Write( keyShowFootprints_Virtual, m_settings.GetFlag( FL_MODULE_ATTRIBUTES_VIRTUAL ) );
|
||||
|
||||
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 ) );
|
||||
cfg->m_Render.opengl_copper_thickness = m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS );
|
||||
cfg->m_Render.opengl_show_model_bbox = m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX );
|
||||
cfg->m_Render.raytrace_anti_aliasing = m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING );
|
||||
cfg->m_Render.raytrace_backfloor = m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR );
|
||||
cfg->m_Render.raytrace_post_processing =
|
||||
m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING );
|
||||
cfg->m_Render.raytrace_procedural_textures =
|
||||
m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES );
|
||||
cfg->m_Render.raytrace_reflections = m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS );
|
||||
cfg->m_Render.raytrace_refractions = m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS );
|
||||
cfg->m_Render.raytrace_shadows = m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS );
|
||||
cfg->m_Render.realistic = m_settings.GetFlag( FL_USE_REALISTIC_MODE );
|
||||
cfg->m_Render.show_adhesive = m_settings.GetFlag( FL_ADHESIVE );
|
||||
cfg->m_Render.show_axis = m_settings.GetFlag( FL_AXIS );
|
||||
cfg->m_Render.show_board_body = m_settings.GetFlag( FL_SHOW_BOARD_BODY );
|
||||
cfg->m_Render.show_comments = m_settings.GetFlag( FL_COMMENTS );
|
||||
cfg->m_Render.show_eco = m_settings.GetFlag( FL_ECO );
|
||||
cfg->m_Render.show_footprints_insert = m_settings.GetFlag( FL_MODULE_ATTRIBUTES_NORMAL_INSERT );
|
||||
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 );
|
||||
cfg->m_Render.show_silkscreen = m_settings.GetFlag( FL_SILKSCREEN );
|
||||
cfg->m_Render.show_soldermask = m_settings.GetFlag( FL_SOLDERMASK );
|
||||
cfg->m_Render.show_solderpaste = m_settings.GetFlag( FL_SOLDERPASTE );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
@ -1269,16 +1138,9 @@ void EDA_3D_VIEWER::loadCommonSettings()
|
||||
{
|
||||
wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" );
|
||||
|
||||
wxConfigBase& cmnCfg = *Pgm().CommonSettings();
|
||||
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
||||
|
||||
{
|
||||
const DPI_SCALING dpi{ &cmnCfg, this };
|
||||
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
}
|
||||
|
||||
{
|
||||
bool option;
|
||||
cmnCfg.Read( ENBL_MOUSEWHEEL_PAN_KEY, &option, false );
|
||||
m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, option );
|
||||
}
|
||||
const DPI_SCALING dpi{ settings, this };
|
||||
m_canvas->SetScaleFactor( dpi.GetScaleFactor() );
|
||||
m_settings.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.mousewheel_pan );
|
||||
}
|
||||
|
@ -194,9 +194,9 @@ private:
|
||||
*/
|
||||
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 );
|
||||
|
||||
|
@ -94,6 +94,7 @@ set(3D-VIEWER_SRCS
|
||||
3d_viewer/dialogs/dialog_3D_view_option.cpp
|
||||
3d_viewer/dialogs/dialog_3D_view_option_base.cpp
|
||||
3d_viewer/eda_3d_viewer.cpp
|
||||
3d_viewer/3d_viewer_settings.cpp
|
||||
common_ogl/cogl_att_list.cpp
|
||||
common_ogl/ogl_utils.cpp
|
||||
3d_fastmath.cpp
|
||||
@ -111,4 +112,8 @@ target_link_libraries( 3d-viewer
|
||||
${OPENGL_LIBRARIES}
|
||||
kicad_3dsg )
|
||||
|
||||
target_include_directories( 3d-viewer PRIVATE
|
||||
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
)
|
||||
|
||||
add_subdirectory( 3d_cache )
|
||||
|
@ -12,6 +12,7 @@ set( BITMAP2COMPONENT_SRCS
|
||||
${CMAKE_SOURCE_DIR}/common/single_top.cpp
|
||||
|
||||
bitmap2cmp_main.cpp
|
||||
bitmap2cmp_settings.cpp
|
||||
bitmap2component.cpp
|
||||
bitmap2cmp_gui_base.cpp
|
||||
bitmap2cmp_gui.cpp
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "bitmap2cmp_gui.h"
|
||||
#include "bitmap2component.h"
|
||||
#include <bitmap2cmp_settings.h>
|
||||
#include <bitmap_io.h>
|
||||
#include <bitmaps.h>
|
||||
#include <kiface_i.h>
|
||||
@ -38,18 +39,6 @@
|
||||
#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
|
||||
|
||||
IMAGE_SIZE::IMAGE_SIZE()
|
||||
@ -161,7 +150,6 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
BM2CMP_FRAME_BASE( aParent )
|
||||
{
|
||||
SetKiway( this, aKiway );
|
||||
m_config = GetNewConfig( Pgm().App().GetAppName() );
|
||||
|
||||
wxString unitList[] =
|
||||
{
|
||||
@ -171,7 +159,7 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
for( int ii = 0; ii < 3; ii++ )
|
||||
m_PixelUnit->Append( unitList[ii] );
|
||||
|
||||
LoadSettings( m_config.get() );
|
||||
LoadSettings( config() );
|
||||
|
||||
m_outputSizeX.SetUnit( getUnitFromSelection() );
|
||||
m_outputSizeY.SetUnit( getUnitFromSelection() );
|
||||
@ -193,20 +181,19 @@ BM2CMP_FRAME::BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
|
||||
GetSizer()->SetSizeHints( this );
|
||||
|
||||
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
||||
|
||||
m_buttonExportFile->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();
|
||||
}
|
||||
|
||||
|
||||
BM2CMP_FRAME::~BM2CMP_FRAME()
|
||||
{
|
||||
SaveSettings( m_config.get() );
|
||||
SaveSettings( config() );
|
||||
/*
|
||||
* This needed for OSX: avoids further OnDraw processing after this
|
||||
* 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;
|
||||
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 );
|
||||
EDA_BASE_FRAME::LoadSettings( aCfg );
|
||||
|
||||
int u_select = 0;
|
||||
aCfg->Read( KEYWORD_UNIT_SELECTION, &u_select, 0 );
|
||||
auto cfg = static_cast<BITMAP2CMP_SETTINGS*>( aCfg );
|
||||
|
||||
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
|
||||
u_select = 0;
|
||||
|
||||
m_PixelUnit->SetSelection( u_select );
|
||||
|
||||
if( aCfg->Read( KEYWORD_BINARY_THRESHOLD, &tmp ) )
|
||||
m_sliderThreshold->SetValue( tmp );
|
||||
m_sliderThreshold->SetValue( cfg->m_Threshold );
|
||||
|
||||
aCfg->Read( KEYWORD_BW_NEGATIVE, &tmp, 0 );
|
||||
m_Negative = tmp != 0;
|
||||
m_checkNegative->SetValue( m_Negative );
|
||||
m_Negative = cfg->m_Negative;
|
||||
m_checkNegative->SetValue( cfg->m_Negative );
|
||||
m_exportToClipboard = false;
|
||||
m_AspectRatioLocked = false;
|
||||
|
||||
if( aCfg->Read( KEYWORD_LAST_FORMAT, &tmp ) )
|
||||
{
|
||||
if( tmp < 0 || tmp > FINAL_FMT )
|
||||
tmp = PCBNEW_KICAD_MOD;
|
||||
int format = cfg->m_LastFormat;
|
||||
|
||||
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 );
|
||||
else
|
||||
m_rbPCBLayer->Enable( false );
|
||||
|
||||
if( aCfg->Read( KEYWORD_LAST_MODLAYER, &tmp ) )
|
||||
{
|
||||
if( (unsigned) tmp > MOD_LYR_FINAL ) // Out of range
|
||||
m_rbPCBLayer->SetSelection( MOD_LYR_FSILKS );
|
||||
else
|
||||
m_rbPCBLayer->SetSelection( tmp );
|
||||
}
|
||||
int last_layer = cfg->m_LastModLayer;
|
||||
|
||||
if( last_layer > static_cast<int>( MOD_LYR_FINAL ) ) // Out of range
|
||||
m_rbPCBLayer->SetSelection( MOD_LYR_FSILKS );
|
||||
else
|
||||
m_rbPCBLayer->SetSelection( last_layer );
|
||||
}
|
||||
|
||||
|
||||
void BM2CMP_FRAME::SaveSettings( wxConfigBase* aCfg )
|
||||
void BM2CMP_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
{
|
||||
if( !aCfg )
|
||||
return;
|
||||
EDA_BASE_FRAME::SaveSettings( aCfg );
|
||||
|
||||
m_frameSize = GetSize();
|
||||
m_framePos = GetPosition();
|
||||
auto cfg = static_cast<BITMAP2CMP_SETTINGS*>( aCfg );
|
||||
|
||||
if( !IsIconized() )
|
||||
{
|
||||
aCfg->Write( KEYWORD_FRAME_POSX, (long) m_framePos.x );
|
||||
aCfg->Write( KEYWORD_FRAME_POSY, (long) m_framePos.y );
|
||||
aCfg->Write( KEYWORD_FRAME_SIZEX, (long) m_frameSize.x );
|
||||
aCfg->Write( KEYWORD_FRAME_SIZEY, (long) m_frameSize.y );
|
||||
}
|
||||
|
||||
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() );
|
||||
cfg->m_BitmapFileName = m_BitmapFileName;
|
||||
cfg->m_ConvertedFileName = m_ConvertedFileName;
|
||||
cfg->m_Threshold = m_sliderThreshold->GetValue();
|
||||
cfg->m_Negative = m_checkNegative->IsChecked();
|
||||
cfg->m_LastFormat = m_rbOutputFormat->GetSelection();
|
||||
cfg->m_LastModLayer = m_rbPCBLayer->GetSelection();
|
||||
cfg->m_Units = m_PixelUnit->GetSelection();
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,8 +152,8 @@ private:
|
||||
void OnFormatChange( wxCommandEvent& event ) override;
|
||||
void exportBitmap( OUTPUT_FMT_ID aFormat );
|
||||
|
||||
void LoadSettings( wxConfigBase* aCfg ) override;
|
||||
void SaveSettings( wxConfigBase* aCfg ) override;
|
||||
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||
|
||||
private:
|
||||
wxImage m_Pict_Image;
|
||||
@ -167,9 +167,6 @@ private:
|
||||
bool m_Negative;
|
||||
wxString m_BitmapFileName;
|
||||
wxString m_ConvertedFileName;
|
||||
wxSize m_frameSize;
|
||||
wxPoint m_framePos;
|
||||
std::unique_ptr<wxConfigBase> m_config;
|
||||
bool m_exportToClipboard;
|
||||
bool m_AspectRatioLocked;
|
||||
double m_AspectRatio;
|
||||
|
@ -22,10 +22,12 @@
|
||||
* 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 <kiway.h>
|
||||
#include <pgm_base.h>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
|
||||
//-----<KIFACE>-----------------------------------------------------------------
|
||||
@ -38,6 +40,8 @@ static struct IFACE : public KIFACE_I
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
68
bitmap2component/bitmap2cmp_settings.cpp
Normal file
68
bitmap2component/bitmap2cmp_settings.cpp
Normal 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;
|
||||
}
|
58
bitmap2component/bitmap2cmp_settings.h
Normal file
58
bitmap2component/bitmap2cmp_settings.h
Normal 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
|
@ -82,6 +82,10 @@ target_link_libraries( gal
|
||||
${GDI_PLUS_LIBRARIES}
|
||||
)
|
||||
|
||||
target_include_directories( gal PRIVATE
|
||||
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
)
|
||||
|
||||
|
||||
# Only for win32 cross compilation using MXE
|
||||
if( WIN32 AND MSYS )
|
||||
@ -168,6 +172,8 @@ set( COMMON_DLG_SRCS
|
||||
dialogs/dialog_image_editor.cpp
|
||||
dialogs/dialog_image_editor_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_text_entry_base.cpp
|
||||
dialogs/dialog_print_generic.cpp
|
||||
@ -262,7 +268,6 @@ set( COMMON_SRCS
|
||||
bitmap_base.cpp
|
||||
board_printout.cpp
|
||||
build_version.cpp
|
||||
colors_design_settings.cpp
|
||||
colors.cpp
|
||||
commit.cpp
|
||||
common.cpp
|
||||
@ -322,7 +327,6 @@ set( COMMON_SRCS
|
||||
richio.cpp
|
||||
search_stack.cpp
|
||||
searchhelpfilefullpath.cpp
|
||||
settings.cpp
|
||||
status_popup.cpp
|
||||
systemdirsappend.cpp
|
||||
trace_helpers.cpp
|
||||
@ -382,6 +386,13 @@ set( COMMON_SRCS
|
||||
tool/zoom_menu.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
|
||||
)
|
||||
|
||||
@ -407,6 +418,10 @@ target_link_libraries( common
|
||||
${wxWidgets_LIBRARIES}
|
||||
)
|
||||
|
||||
target_include_directories( common PUBLIC
|
||||
$<TARGET_PROPERTY:nlohmann_json,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
)
|
||||
|
||||
|
||||
set( PCB_COMMON_SRCS
|
||||
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/drc/drc_item.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/io_mgr.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/netlist_reader/legacy_netlist_reader.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_print_functions.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcb_display_options.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/pcb_painter.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcb_parser.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcb_plot_params.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcb_screen.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/ratsnest_data.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_viewitem.cpp
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <config_params.h>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/filename.h>
|
||||
@ -153,7 +154,7 @@ static void dumpCfg( const std::vector<PARAM_CFG*>& aArray )
|
||||
static wxFileName getAdvancedCfgFilename()
|
||||
{
|
||||
const static wxString cfg_filename{ "kicad_advanced" };
|
||||
return wxFileName( GetKicadConfigPath(), cfg_filename );
|
||||
return wxFileName( SETTINGS_MANAGER::GetUserSettingsPath(), cfg_filename );
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,29 +27,26 @@
|
||||
#include <filehistory.h>
|
||||
#include <id.h> // for ID_FILE1 and FILE_HISTORY_SIZE
|
||||
#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 ) :
|
||||
m_name( aName ),
|
||||
m_history( 0 )
|
||||
m_config( nullptr ),
|
||||
m_history( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
int fileHistorySize;
|
||||
Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE );
|
||||
int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
|
||||
|
||||
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
|
||||
// avoid problems with upper/lower case file names under windows and unix.
|
||||
@ -65,17 +62,22 @@ void BIN_MOD::End()
|
||||
{
|
||||
if( m_config )
|
||||
{
|
||||
m_history->Save( *m_config.get() );
|
||||
delete m_history;
|
||||
if( m_history )
|
||||
{
|
||||
m_history->Save( *m_config );
|
||||
delete m_history;
|
||||
m_history = nullptr;
|
||||
}
|
||||
|
||||
// Deleting a wxConfigBase writes its contents to disk if changed.
|
||||
m_config.reset();
|
||||
// The settings manager will outlive this module so we need to clean up the module level
|
||||
// settings here instead of leaving it up to the manager
|
||||
Pgm().GetSettingsManager().FlushAndRelease( m_config );
|
||||
m_config = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN_MOD::~BIN_MOD()
|
||||
{
|
||||
End();
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <pgm_base.h>
|
||||
#include <eda_base_frame.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <settings/common_settings.h>
|
||||
|
||||
|
||||
struct SCALED_BITMAP_ID {
|
||||
@ -103,8 +104,7 @@ int KiIconScale( wxWindow* aWindow )
|
||||
|
||||
static int get_scale_factor( EDA_BASE_FRAME* aWindow )
|
||||
{
|
||||
int requested_scale;
|
||||
Pgm().CommonSettings()->Read( ICON_SCALE_KEY, &requested_scale, 0 );
|
||||
int requested_scale = Pgm().GetCommonSettings()->m_Appearance.icon_scale;
|
||||
|
||||
if( requested_scale > 0 )
|
||||
return requested_scale;
|
||||
@ -223,8 +223,7 @@ bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
|
||||
void AddBitmapToMenuItem( wxMenuItem* aMenu, const wxBitmap& aImage )
|
||||
{
|
||||
// Retrieve the global applicaton show icon option:
|
||||
bool useImagesInMenus;
|
||||
Pgm().CommonSettings()->Read( USE_ICONS_IN_MENUS_KEY, &useImagesInMenus );
|
||||
bool useImagesInMenus = Pgm().GetCommonSettings()->m_Appearance.use_icons_in_menus;
|
||||
|
||||
wxItemKind menu_type = aMenu->GetKind();
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <gal/gal_print.h>
|
||||
#include <painter.h>
|
||||
#include <pcbplot.h>
|
||||
#include <settings/app_settings.h>
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
for( unsigned layer = 0; layer < m_layerSet.size(); ++layer )
|
||||
{
|
||||
int tmp;
|
||||
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer );
|
||||
aConfig->Read( key, &tmp, 1 );
|
||||
m_layerSet.set( layer, tmp );
|
||||
}
|
||||
m_layerSet.reset();
|
||||
|
||||
for( int layer : aConfig->m_Printing.layers )
|
||||
m_layerSet.set( layer, true );
|
||||
}
|
||||
|
||||
|
||||
void BOARD_PRINTOUT_SETTINGS::Save( wxConfigBase* aConfig )
|
||||
void BOARD_PRINTOUT_SETTINGS::Save( APP_SETTINGS_BASE* aConfig )
|
||||
{
|
||||
PRINTOUT_SETTINGS::Save( aConfig );
|
||||
|
||||
aConfig->m_Printing.layers.clear();
|
||||
|
||||
for( unsigned layer = 0; layer < m_layerSet.size(); ++layer )
|
||||
{
|
||||
wxString key = wxString::Format( OPTKEY_LAYERBASE, layer );
|
||||
aConfig->Write( key, m_layerSet.test( layer ) );
|
||||
}
|
||||
if( m_layerSet.test( layer ) )
|
||||
aConfig->m_Printing.layers.push_back( layer );
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <base_units.h>
|
||||
#include <reporter.h>
|
||||
#include <mutex>
|
||||
#include <settings/settings_manager.h>
|
||||
|
||||
#include <wx/process.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
|
||||
{
|
||||
Bracket_None,
|
||||
|
150
common/dialogs/dialog_migrate_settings.cpp
Normal file
150
common/dialogs/dialog_migrate_settings.cpp
Normal 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();
|
||||
}
|
62
common/dialogs/dialog_migrate_settings.h
Normal file
62
common/dialogs/dialog_migrate_settings.h
Normal 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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user