26 #include <dialogs/dialog_bom_cfg_lexer.h> 36 #include <wx/config.h> 40 using namespace T_BOMCFG_T;
48 {
"name",
"bom_csv_grouped_by_value" },
49 {
"path",
"bom_csv_grouped_by_value.py" }
52 {
"name",
"bom_csv_grouped_by_value_with_fp" },
53 {
"path",
"bom_csv_grouped_by_value_with_fp.py" }
74 m_RescueNeverShow( false )
110 new PARAM<bool>(
"appearance.show_sheet_filename_case_sensitivity_dialog",
213 if( !aObj.is_array() )
226 if( !aObj.is_array() )
422 std::string gridSizePtr =
"window.grid.last_size";
424 if(
OPT<int> currentSize = Get<int>( gridSizePtr ) )
426 Set( gridSizePtr, *currentSize - 4 );
431 Set( gridSizePtr, 1 );
434 ret &= fromLegacy<bool>( aCfg,
"FootprintPreview",
"appearance.footprint_preview" );
435 ret &= fromLegacy<bool>( aCfg,
"NavigatorStaysOpen",
"appearance.navigator_stays_open" );
436 ret &= fromLegacy<bool>( aCfg,
"PrintSheetReferenceAndTitleBlock",
437 "appearance.print_sheet_reference" );
438 ret &= fromLegacy<bool>( aCfg,
"ShowHiddenPins",
"appearance.show_hidden_pins" );
439 ret &= fromLegacy<bool>( aCfg,
"ShowIllegalSymbolLibDialog",
440 "appearance.show_illegal_symbol_lib_dialog" );
441 ret &= fromLegacy<bool>( aCfg,
"ShowPageLimits",
"appearance.show_page_limits" );
442 ret &= fromLegacy<bool>( aCfg,
"ShowSheetFileNameCaseSensitivityDlg",
443 "appearance.show_sheet_filename_case_sensitivity_dialog" );
445 ret &= fromLegacy<bool>( aCfg,
"AutoplaceFields",
"autoplace_fields.enable" );
446 ret &= fromLegacy<bool>( aCfg,
"AutoplaceJustify",
"autoplace_fields.allow_rejustify" );
447 ret &= fromLegacy<bool>( aCfg,
"AutoplaceAlign",
"autoplace_fields.align_to_grid" );
449 ret &= fromLegacy<int>( aCfg,
"DefaultBusWidth",
"drawing.default_bus_thickness" );
450 ret &= fromLegacy<int>( aCfg,
"DefaultJunctionSize",
"drawing.default_junction_size" );
451 ret &= fromLegacy<int>( aCfg,
"DefaultDrawLineWidth",
"drawing.default_line_thickness" );
452 ret &= fromLegacy<int>( aCfg,
"RepeatStepX",
"drawing.default_repeat_offset_x" );
453 ret &= fromLegacy<int>( aCfg,
"RepeatStepY",
"drawing.default_repeat_offset_y" );
454 ret &= fromLegacy<int>( aCfg,
"DefaultWireWidth",
"drawing.default_wire_thickness" );
456 ret &= fromLegacy<bool>( aCfg,
"HorizVertLinesOnly",
"drawing.hv_lines_only" );
457 ret &= fromLegacy<int>( aCfg,
"RepeatLabelIncrement",
"drawing.repeat_label_increment" );
459 ret &= fromLegacy<bool>( aCfg,
"DragActionIsMove",
"input.drag_is_move" );
461 ret &= fromLegacy<int>( aCfg,
"SelectionThickness",
"selection.thickness" );
462 ret &= fromLegacy<bool>( aCfg,
"SelectionDrawChildItems",
"selection.draw_selected_children" );
463 ret &= fromLegacy<bool>( aCfg,
"SelectionFillShapes",
"selection.fill_shapes" );
464 ret &= fromLegacy<bool>( aCfg,
"SelectPinSelectSymbolOpt",
465 "selection.select_pin_selects_symbol" );
466 ret &= fromLegacy<bool>( aCfg,
"SelectionTextAsBox",
"selection.text_as_box" );
468 ret &= fromLegacy<int>( aCfg,
"AnnotateAlgoOption",
"annotation.method" );
469 ret &= fromLegacy<int>( aCfg,
"AnnotateFilterMsg",
"annotation.messages_filter" );
470 ret &= fromLegacy<int>( aCfg,
"AnnotateSortOption",
"annotation.sort_order" );
472 ret &=
fromLegacyString( aCfg,
"bom_plugin_selected",
"bom.selected_plugin" );
478 "edit_sch_component.visible_columns" );
480 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportRevision",
"page_settings.export_revision" );
481 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportDate",
"page_settings.export_date" );
482 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportTitle",
"page_settings.export_title" );
483 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportCompany",
"page_settings.export_company" );
484 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment1",
"page_settings.export_comment1" );
485 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment2",
"page_settings.export_comment2" );
486 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment3",
"page_settings.export_comment3" );
487 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment4",
"page_settings.export_comment4" );
488 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment5",
"page_settings.export_comment5" );
489 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment6",
"page_settings.export_comment6" );
490 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment7",
"page_settings.export_comment7" );
491 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment8",
"page_settings.export_comment8" );
492 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment9",
"page_settings.export_comment9" );
494 #if 0 // To do: move this code to the new netlist plugin management in settings 496 constexpr
int max_custom_commands = 8;
499 wxString cmd_key, title_key, cmd, title;
501 for(
int i = 1; i <= max_custom_commands; ++i )
504 cmd_key.Printf(
"CustomNetlistCommand%d", i );
505 title_key.Printf(
"CustomNetlistTitle%d", i );
507 if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
508 && !cmd.IsEmpty() && !title.IsEmpty() )
510 js_cmd.push_back( cmd.ToUTF8() );
511 js_title.push_back( title.ToUTF8() );
515 Set(
"netlist.custom_command_titles", js_title );
516 Set(
"netlist.custom_command_paths", js_cmd );
525 aCfg->SetPath(
"SymbolFieldEditor/Show/" );
532 while( aCfg->GetNextEntry( key, index ) )
534 if( aCfg->Read( key, &value ) )
536 std::string key_utf( key.ToUTF8() );
549 Set(
"field_editor.fields_show", js );
551 aCfg->SetPath(
"../GroupBy" );
553 while( aCfg->GetNextEntry( key, index ) )
555 if( aCfg->Read( key, &value ) )
557 std::string key_utf( key.ToUTF8() );
570 Set(
"field_editor.fields_group_by", js );
572 aCfg->SetPath(
"../.." );
575 ret &= fromLegacy<bool>( aCfg,
"PlotModeColor",
"plot.color" );
576 ret &= fromLegacy<int>( aCfg,
"PlotFormat",
"plot.format" );
577 ret &= fromLegacy<bool>( aCfg,
"PlotFrameRef",
"plot.frame_reference" );
578 ret &= fromLegacy<bool>( aCfg,
"PlotHPGLOrg",
"plot.hpgl_origin" );
579 ret &= fromLegacy<int>( aCfg,
"PlotHPGLPaperSize",
"plot.hpgl_paper_size" );
580 ret &= fromLegacy<double>( aCfg,
"PlotHPGLPenSize",
"plot.hpgl_pen_size" );
582 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMEPos_x",
"simulator.window.pos_x" );
583 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMEPos_y",
"simulator.window.pos_y" );
584 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMESize_x",
"simulator.window.size_x" );
585 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMESize_y",
"simulator.window.size_y" );
586 ret &= fromLegacy<bool>( aCfg,
"SIM_PLOT_FRAMEMaximized",
"simulator.window.maximized" );
587 ret &=
fromLegacyString( aCfg,
"SIM_PLOT_FRAMEPerspective",
"simulator.window.perspective" );
588 ret &=
fromLegacyString( aCfg,
"SIM_PLOT_FRAMEMostRecentlyUsedPath",
"simulator.mru_path" );
589 ret &= fromLegacy<int>( aCfg,
"SimPlotPanelWidth",
"simulator.plot_panel_width" );
590 ret &= fromLegacy<int>( aCfg,
"SimPlotPanelHeight",
"simulator.plot_panel_height" );
591 ret &= fromLegacy<int>( aCfg,
"SimSignalPanelHeight",
"simulator.signal_panel_height" );
592 ret &= fromLegacy<int>( aCfg,
"SimCursorsPanelHeight",
"simulator.cursors_panel_height" );
593 ret &= fromLegacy<bool>( aCfg,
"SimPlotWhiteBg",
"simulator.white_background" );
595 ret &= fromLegacy<int>( aCfg,
"SymbolChooserHSashPosition",
"symbol_chooser.sash_pos_h" );
596 ret &= fromLegacy<int>( aCfg,
"SymbolChooserVSashPosition",
"symbol_chooser.sash_pos_v" );
597 ret &= fromLegacy<int>( aCfg,
"SymbolChooserWidth",
"symbol_chooser.width" );
598 ret &= fromLegacy<int>( aCfg,
"SymbolChooserHeight",
"symbol_chooser.height" );
599 ret &= fromLegacy<bool>( aCfg,
"SymbolChooserKeepSymbol",
"symbol_chooser.keep_symbol" );
600 ret &= fromLegacy<bool>( aCfg,
"SymbolChooserUseUnits",
"symbol_chooser.place_all_units" );
602 const std::string vlf =
"ViewlibFrame";
603 ret &= fromLegacy<bool>( aCfg, vlf +
"Maximized",
"lib_view.window.maximized" );
604 ret &=
fromLegacyString( aCfg, vlf +
"MostRecentlyUsedPath",
"lib_view.window.mru_path" );
605 ret &= fromLegacy<int>( aCfg, vlf +
"Size_x",
"lib_view.window.size_x" );
606 ret &= fromLegacy<int>( aCfg, vlf +
"Size_y",
"lib_view.window.size_y" );
607 ret &=
fromLegacyString( aCfg, vlf +
"Perspective",
"lib_view.window.perspective" );
608 ret &= fromLegacy<int>( aCfg, vlf +
"Pos_x",
"lib_view.window.pos_x" );
609 ret &= fromLegacy<int>( aCfg, vlf +
"Pos_y",
"lib_view.window.pos_y" );
610 ret &= fromLegacy<int>( aCfg,
"ViewLiblistWidth",
"lib_view.lib_list_width" );
611 ret &= fromLegacy<int>( aCfg,
"ViewCmplistWidth",
"lib_view.cmp_list_width" );
612 ret &= fromLegacy<bool>( aCfg,
613 "ViewCmpShowPinElectricalType",
"lib_view.show_pin_electrical_type" );
614 ret &= fromLegacy<bool>( aCfg, vlf +
"ShowGrid",
"lib_view.grid.show" );
615 ret &= fromLegacy<int>( aCfg, vlf +
"_LastGridSize",
"lib_view.grid.last_size" );
617 ret &= fromLegacy<bool>( aCfg,
"RescueNeverShow",
"system.never_show_rescue_dialog" );
622 if( aCfg->Read(
"MoveWarpsCursor", &tmp ) )
623 Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move = tmp;
627 auto migrateLegacyColor = [&] (
const std::string& aKey,
int aLayerId ) {
630 if( aCfg->Read( aKey, &str ) )
638 migrateLegacyColor(
"Color4DBusEx",
LAYER_BUS );
650 migrateLegacyColor(
"Color4DNoteEx",
LAYER_NOTES );
651 migrateLegacyColor(
"Color4DPinEx",
LAYER_PIN );
656 migrateLegacyColor(
"Color4DSheetEx",
LAYER_SHEET );
661 migrateLegacyColor(
"Color4DWireEx",
LAYER_WIRE );
664 Pgm().GetSettingsManager().SaveColorSettings( cs,
"schematic" );
672 libedit->MigrateFromLegacy( aCfg );
688 BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
689 const char* aData,
const wxString& aSource );
709 wxString list = Get<wxString>(
"bom.plugins" ).value();
737 pluginJson[
"name"] = plugin.
name.ToUTF8();
738 pluginJson[
"path"] = plugin.
path.ToUTF8();
739 pluginJson[
"command"] = plugin.
command.ToUTF8();
741 js.push_back( pluginJson );
751 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> ret;
753 wxASSERT( aObj.is_array() );
757 if( entry.empty() || !entry.is_object() )
760 if( !entry.contains(
"name" ) || !entry.contains(
"path" ) )
764 entry.at(
"path" ).get<wxString>() );
766 if( entry.contains(
"command" ) )
767 plugin.
command = entry.at(
"command" ).get<wxString>();
769 ret.emplace_back( plugin );
784 pluginJson[
"name"] = plugin.
name.ToUTF8();
785 pluginJson[
"path"] = plugin.
path.ToUTF8();
786 pluginJson[
"command"] = plugin.
command.ToUTF8();
788 js.push_back( pluginJson );
798 std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> ret;
800 wxASSERT( aObj.is_array() );
804 if( entry.empty() || !entry.is_object() )
807 if( !entry.contains(
"name" ) || !entry.contains(
"path" ) )
811 entry.at(
"path" ).get<wxString>() );
813 if( entry.contains(
"command" ) )
814 plugin.
command = entry.at(
"command" ).get<wxString>();
816 ret.emplace_back( plugin );
824 const char* aLine,
const wxString& aSource ) :
825 DIALOG_BOM_CFG_LEXER( aLine, aSource )
827 wxASSERT( aPluginList );
836 while( ( token = NextTok() ) != T_RIGHT )
841 if( token == T_LEFT )
844 if( token == T_plugins )
866 NeedSYMBOLorNUMBER();
867 settings.
path = FromUTF8();
871 while( ( token = NextTok() ) != T_RIGHT )
882 NeedSYMBOLorNUMBER();
891 NeedSYMBOLorNUMBER();
893 wxString option = FromUTF8();
895 if( option.StartsWith( wxT(
"nickname=" ), &str ) )
903 Unexpected( CurText() );
BOM_CFG_PARSER(std::vector< EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS > *aPluginList, const char *aData, const wxString &aSource)
void Set(const std::string &aPath, ValueType aVal)
Stores a value into the JSON document Will throw an exception if ValueType isn't something that the l...
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
COLOR4D default_sheet_background_color
wxString edit_sheet_visible_columns
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
bool show_sexpr_file_convert_warning
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
wxString edit_component_visible_columns
const nlohmann::json defaultBomPlugins
Default value for bom.plugins.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
Represents a map of <std::string, Value>.
wxString GetFilename() const
bool migrateBomSettings()
int repeat_label_increment
std::vector< BOM_PLUGIN_SETTINGS > plugins
PANEL_ANNOTATE m_AnnotatePanel
int default_repeat_offset_y
void SetColor(int aLayer, const COLOR4D &aColor)
bool draw_selected_children
#define DEFAULT_JUNCTION_DIAM
The default bus and wire entry size in mils.
bool navigator_stays_open
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
PANEL_SYM_CHOOSER m_SymChooserPanel
nlohmann::json & At(const std::string &aPath)
Wrappers for the underlying JSON API so that most consumers don't need json.hpp All of these function...
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
This file contains miscellaneous commonly used macros and functions.
PANEL_FIELD_EDITOR m_FieldEditorPanel
PAGE_SETTINGS m_PageSettings
static std::vector< BOM_PLUGIN_SETTINGS > bomSettingsFromJson(const nlohmann::json &aObj)
int default_line_thickness
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool select_pin_selects_symbol
AUTOPLACE_FIELDS m_AutoplaceFields
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
nlohmann::json netlistSettingsToJson() const
Functions to provide common constants and other functions to assist in making a consistent UI.
std::vector< EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS > * m_pluginList
Used for parsing legacy-format bom plugin configurations.
std::map< std::string, int > column_widths
nlohmann::json bomSettingsToJson() const
int default_bus_thickness
PANEL_LIB_VIEW m_LibViewPanel
wxString m_lastSymbolLibDir
int default_repeat_offset_x
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
int default_junction_size
#define DEFAULT_BUS_WIDTH_MILS
The default noconnect size in mils.
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
bool show_sheet_filename_case_sensitivity_dialog
bool show_pin_electrical_type
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
Color settings are a bit different than most of the settings objects in that there can be more than o...
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
bool Contains(const std::string &aPath) const
std::vector< double > junction_size_mult_list
int default_wire_thickness
const int eeschemaSchemaVersion
! Update the schema version whenever a migration is required
bool print_sheet_reference
std::map< std::string, bool > fields_group_by
std::map< std::string, bool > fields_show
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
PANEL_NETLIST m_NetlistPanel
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
static std::vector< NETLIST_PLUGIN_SETTINGS > netlistSettingsFromJson(const nlohmann::json &aObj)
bool show_illegal_symbol_lib_dialog
COLOR4D default_sheet_border_color
A color representation with 4 components: red, green, blue, alpha.