26#include <dialogs/dialog_bom_cfg_lexer.h>
40using namespace T_BOMCFG_T;
49 {
"name",
"bom_csv_grouped_extra" },
50 {
"path",
"bom_csv_grouped_extra.py" }
53 {
"name",
"bom_csv_grouped_by_value" },
54 {
"path",
"bom_csv_grouped_by_value.py" }
57 {
"name",
"bom_csv_grouped_by_value_with_fp" },
58 {
"path",
"bom_csv_grouped_by_value_with_fp.py" }
80 m_RescueNeverShow( false )
146 new PARAM<bool>(
"appearance.show_sheet_filename_case_sensitivity_dialog",
286 if( !aObj.is_array() )
299 if( !aObj.is_array() )
495 if( std::optional<int> optval = Get<int>(
"lib_tree.column_width" ) )
498 Set(
"lib_tree.column_width", 300 );
520 std::string gridSizePtr =
"window.grid.last_size";
522 if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
524 Set( gridSizePtr, *currentSize - 4 );
529 Set( gridSizePtr, 1 );
532 ret &= fromLegacy<bool>( aCfg,
"FootprintPreview",
"appearance.footprint_preview" );
533 ret &= fromLegacy<bool>( aCfg,
"NavigatorStaysOpen",
"appearance.navigator_stays_open" );
534 ret &= fromLegacy<bool>( aCfg,
"PrintSheetReferenceAndTitleBlock",
535 "appearance.print_sheet_reference" );
536 ret &= fromLegacy<bool>( aCfg,
"ShowHiddenPins",
"appearance.show_hidden_pins" );
537 ret &= fromLegacy<bool>( aCfg,
"ShowIllegalSymbolLibDialog",
538 "appearance.show_illegal_symbol_lib_dialog" );
539 ret &= fromLegacy<bool>( aCfg,
"ShowPageLimits",
"appearance.show_page_limits" );
540 ret &= fromLegacy<bool>( aCfg,
"ShowSheetFileNameCaseSensitivityDlg",
541 "appearance.show_sheet_filename_case_sensitivity_dialog" );
543 ret &= fromLegacy<bool>( aCfg,
"AutoplaceFields",
"autoplace_fields.enable" );
544 ret &= fromLegacy<bool>( aCfg,
"AutoplaceJustify",
"autoplace_fields.allow_rejustify" );
545 ret &= fromLegacy<bool>( aCfg,
"AutoplaceAlign",
"autoplace_fields.align_to_grid" );
547 ret &= fromLegacy<int>( aCfg,
"DefaultBusWidth",
"drawing.default_bus_thickness" );
548 ret &= fromLegacy<int>( aCfg,
"DefaultJunctionSize",
"drawing.default_junction_size" );
549 ret &= fromLegacy<int>( aCfg,
"DefaultDrawLineWidth",
"drawing.default_line_thickness" );
550 ret &= fromLegacy<int>( aCfg,
"RepeatStepX",
"drawing.default_repeat_offset_x" );
551 ret &= fromLegacy<int>( aCfg,
"RepeatStepY",
"drawing.default_repeat_offset_y" );
552 ret &= fromLegacy<int>( aCfg,
"DefaultWireWidth",
"drawing.default_wire_thickness" );
554 ret &= fromLegacy<bool>( aCfg,
"HorizVertLinesOnly",
"drawing.line_mode" );
555 ret &= fromLegacy<int>( aCfg,
"RepeatLabelIncrement",
"drawing.repeat_label_increment" );
557 ret &= fromLegacy<bool>( aCfg,
"DragActionIsMove",
"input.drag_is_move" );
559 ret &= fromLegacy<int>( aCfg,
"SelectionThickness",
"selection.thickness" );
560 ret &= fromLegacy<bool>( aCfg,
"SelectionDrawChildItems",
"selection.draw_selected_children" );
561 ret &= fromLegacy<bool>( aCfg,
"SelectionFillShapes",
"selection.fill_shapes" );
562 ret &= fromLegacy<bool>( aCfg,
"SelectPinSelectSymbolOpt",
563 "selection.select_pin_selects_symbol" );
565 ret &= fromLegacy<int>( aCfg,
"AnnotateAlgoOption",
"annotation.method" );
566 ret &= fromLegacy<int>( aCfg,
"AnnotateFilterMsg",
"annotation.messages_filter" );
567 ret &= fromLegacy<int>( aCfg,
"AnnotateSortOption",
"annotation.sort_order" );
569 ret &=
fromLegacyString( aCfg,
"bom_plugin_selected",
"bom.selected_plugin" );
575 "edit_sch_component.visible_columns" );
577 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportRevision",
"page_settings.export_revision" );
578 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportDate",
"page_settings.export_date" );
579 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportTitle",
"page_settings.export_title" );
580 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportCompany",
"page_settings.export_company" );
581 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment1",
"page_settings.export_comment1" );
582 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment2",
"page_settings.export_comment2" );
583 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment3",
"page_settings.export_comment3" );
584 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment4",
"page_settings.export_comment4" );
585 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment5",
"page_settings.export_comment5" );
586 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment6",
"page_settings.export_comment6" );
587 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment7",
"page_settings.export_comment7" );
588 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment8",
"page_settings.export_comment8" );
589 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment9",
"page_settings.export_comment9" );
593 constexpr int max_custom_commands = 8;
596 wxString cmd_key, title_key, cmd, title;
598 for(
int i = 1; i <= max_custom_commands; ++i )
601 cmd_key.Printf(
"CustomNetlistCommand%d", i );
602 title_key.Printf(
"CustomNetlistTitle%d", i );
604 if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
605 && !cmd.IsEmpty() && !title.IsEmpty() )
607 js_cmd.push_back( cmd.ToUTF8() );
608 js_title.push_back( title.ToUTF8() );
612 Set(
"netlist.custom_command_titles", js_title );
613 Set(
"netlist.custom_command_paths", js_cmd );
622 aCfg->SetPath(
"SymbolFieldEditor/Show/" );
629 while( aCfg->GetNextEntry( key, index ) )
631 if( aCfg->Read( key, &value ) )
633 std::string key_utf( key.ToUTF8() );
646 Set(
"field_editor.fields_show", js );
648 aCfg->SetPath(
"../GroupBy" );
650 while( aCfg->GetNextEntry( key, index ) )
652 if( aCfg->Read( key, &value ) )
654 std::string key_utf( key.ToUTF8() );
667 Set(
"field_editor.fields_group_by", js );
669 aCfg->SetPath(
"../.." );
672 ret &= fromLegacy<bool>( aCfg,
"PlotModeColor",
"plot.color" );
673 ret &= fromLegacy<int>( aCfg,
"PlotFormat",
"plot.format" );
674 ret &= fromLegacy<bool>( aCfg,
"PlotFrameRef",
"plot.frame_reference" );
675 ret &= fromLegacy<bool>( aCfg,
"PlotHPGLOrg",
"plot.hpgl_origin" );
676 ret &= fromLegacy<int>( aCfg,
"PlotHPGLPaperSize",
"plot.hpgl_paper_size" );
677 ret &= fromLegacy<double>( aCfg,
"PlotHPGLPenSize",
"plot.hpgl_pen_size" );
679 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMEPos_x",
"simulator.window.pos_x" );
680 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMEPos_y",
"simulator.window.pos_y" );
681 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMESize_x",
"simulator.window.size_x" );
682 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMESize_y",
"simulator.window.size_y" );
683 ret &= fromLegacy<bool>( aCfg,
"SIM_PLOT_FRAMEMaximized",
"simulator.window.maximized" );
684 ret &=
fromLegacyString( aCfg,
"SIM_PLOT_FRAMEPerspective",
"simulator.window.perspective" );
685 ret &=
fromLegacyString( aCfg,
"SIM_PLOT_FRAMEMostRecentlyUsedPath",
"simulator.mru_path" );
686 ret &= fromLegacy<int>( aCfg,
"SimPlotPanelWidth",
"simulator.plot_panel_width" );
687 ret &= fromLegacy<int>( aCfg,
"SimPlotPanelHeight",
"simulator.plot_panel_height" );
688 ret &= fromLegacy<int>( aCfg,
"SimSignalPanelHeight",
"simulator.signal_panel_height" );
689 ret &= fromLegacy<int>( aCfg,
"SimCursorsPanelHeight",
"simulator.cursors_panel_height" );
690 ret &= fromLegacy<bool>( aCfg,
"SimPlotWhiteBg",
"simulator.white_background" );
692 ret &= fromLegacy<int>( aCfg,
"SymbolChooserHSashPosition",
"symbol_chooser.sash_pos_h" );
693 ret &= fromLegacy<int>( aCfg,
"SymbolChooserVSashPosition",
"symbol_chooser.sash_pos_v" );
694 ret &= fromLegacy<int>( aCfg,
"SymbolChooserWidth",
"symbol_chooser.width" );
695 ret &= fromLegacy<int>( aCfg,
"SymbolChooserHeight",
"symbol_chooser.height" );
696 ret &= fromLegacy<bool>( aCfg,
"SymbolChooserKeepSymbol",
"symbol_chooser.keep_symbol" );
697 ret &= fromLegacy<bool>( aCfg,
"SymbolChooserUseUnits",
"symbol_chooser.place_all_units" );
699 const std::string vlf =
"ViewlibFrame";
700 ret &= fromLegacy<bool>( aCfg, vlf +
"Maximized",
"lib_view.window.maximized" );
701 ret &=
fromLegacyString( aCfg, vlf +
"MostRecentlyUsedPath",
"lib_view.window.mru_path" );
702 ret &= fromLegacy<int>( aCfg, vlf +
"Size_x",
"lib_view.window.size_x" );
703 ret &= fromLegacy<int>( aCfg, vlf +
"Size_y",
"lib_view.window.size_y" );
704 ret &=
fromLegacyString( aCfg, vlf +
"Perspective",
"lib_view.window.perspective" );
705 ret &= fromLegacy<int>( aCfg, vlf +
"Pos_x",
"lib_view.window.pos_x" );
706 ret &= fromLegacy<int>( aCfg, vlf +
"Pos_y",
"lib_view.window.pos_y" );
707 ret &= fromLegacy<int>( aCfg,
"ViewLiblistWidth",
"lib_view.lib_list_width" );
708 ret &= fromLegacy<int>( aCfg,
"ViewCmplistWidth",
"lib_view.cmp_list_width" );
709 ret &= fromLegacy<bool>( aCfg,
710 "ViewCmpShowPinElectricalType",
"lib_view.show_pin_electrical_type" );
711 ret &= fromLegacy<bool>( aCfg, vlf +
"ShowGrid",
"lib_view.grid.show" );
712 ret &= fromLegacy<int>( aCfg, vlf +
"_LastGridSize",
"lib_view.grid.last_size" );
714 ret &= fromLegacy<bool>( aCfg,
"RescueNeverShow",
"system.never_show_rescue_dialog" );
719 if( aCfg->Read(
"MoveWarpsCursor", &tmp ) )
720 Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move = tmp;
724 auto migrateLegacyColor = [&] (
const std::string& aKey,
int aLayerId ) {
727 if( aCfg->Read( aKey, &str ) )
735 migrateLegacyColor(
"Color4DBusEx",
LAYER_BUS );
747 migrateLegacyColor(
"Color4DNoteEx",
LAYER_NOTES );
748 migrateLegacyColor(
"Color4DPinEx",
LAYER_PIN );
753 migrateLegacyColor(
"Color4DSheetEx",
LAYER_SHEET );
758 migrateLegacyColor(
"Color4DWireEx",
LAYER_WIRE );
761 Pgm().GetSettingsManager().SaveColorSettings( cs,
"schematic" );
769 libedit->MigrateFromLegacy( aCfg );
785 BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
786 const char* aData,
const wxString& aSource );
806 wxString list = *Get<wxString>(
"bom.plugins" );
834 pluginJson[
"name"] = plugin.
name.ToUTF8();
835 pluginJson[
"path"] = plugin.
path.ToUTF8();
836 pluginJson[
"command"] = plugin.
command.ToUTF8();
838 js.push_back( pluginJson );
848 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> ret;
850 wxASSERT( aObj.is_array() );
854 if( entry.empty() || !entry.is_object() )
857 if( !entry.contains(
"name" ) || !entry.contains(
"path" ) )
861 entry.at(
"path" ).get<wxString>() );
863 if( entry.contains(
"command" ) )
864 plugin.
command = entry.at(
"command" ).get<wxString>();
866 ret.emplace_back( plugin );
881 pluginJson[
"name"] = plugin.
name.ToUTF8();
882 pluginJson[
"path"] = plugin.
path.ToUTF8();
883 pluginJson[
"command"] = plugin.
command.ToUTF8();
885 js.push_back( pluginJson );
895 std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> ret;
897 wxASSERT( aObj.is_array() );
901 if( entry.empty() || !entry.is_object() )
904 if( !entry.contains(
"name" ) || !entry.contains(
"path" ) )
908 entry.at(
"path" ).get<wxString>() );
910 if( entry.contains(
"command" ) )
911 plugin.
command = entry.at(
"command" ).get<wxString>();
913 ret.emplace_back( plugin );
921 const char* aLine,
const wxString& aSource ) :
922 DIALOG_BOM_CFG_LEXER( aLine, aSource )
924 wxASSERT( aPluginList );
933 while( ( token = NextTok() ) != T_RIGHT )
938 if( token == T_LEFT )
941 if( token == T_plugins )
963 NeedSYMBOLorNUMBER();
964 settings.
path = FromUTF8();
968 while( ( token = NextTok() ) != T_RIGHT )
979 NeedSYMBOLorNUMBER();
988 NeedSYMBOLorNUMBER();
990 wxString option = FromUTF8();
992 if( option.StartsWith( wxS(
"nickname=" ), &str ) )
1000 Unexpected( CurText() );
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
virtual bool MigrateFromLegacy(wxConfigBase *aCfg) override
Migrates from wxConfig to JSON-based configuration.
bool migrateLibTreeWidth()
Migrates the library tree width setting from a single column (Item) to multi-column.
Used for parsing legacy-format bom plugin configurations.
BOM_CFG_PARSER(std::vector< EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS > *aPluginList, const char *aData, const wxString &aSource)
std::vector< EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS > * m_pluginList
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
PANEL_ANNOTATE m_AnnotatePanel
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
bool migrateBomSettings()
PANEL_NETLIST m_NetlistPanel
nlohmann::json bomSettingsToJson() const
virtual bool MigrateFromLegacy(wxConfigBase *aLegacyConfig) override
Migrates from wxConfig to JSON-based configuration.
nlohmann::json netlistSettingsToJson() const
PANEL_SYM_CHOOSER m_SymChooserPanel
PAGE_SETTINGS m_PageSettings
static std::vector< BOM_PLUGIN_SETTINGS > bomSettingsFromJson(const nlohmann::json &aObj)
FIND_REPLACE_EXTRA m_FindReplaceExtra
wxString m_lastSymbolLibDir
PANEL_LIB_VIEW m_LibViewPanel
AUTOPLACE_FIELDS m_AutoplaceFields
static std::vector< NETLIST_PLUGIN_SETTINGS > netlistSettingsFromJson(const nlohmann::json &aObj)
PANEL_FIELD_EDITOR m_FieldEditorPanel
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
bool fromLegacyString(wxConfigBase *aConfig, const std::string &aKey, const std::string &aDest)
Translates a legacy wxConfig string value to a given JSON pointer value.
bool Contains(const std::string &aPath) const
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
void registerMigration(int aOldSchemaVersion, int aNewSchemaVersion, std::function< bool(void)> aMigrator)
Registers a migration from one schema version to another.
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...
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...
wxString GetFilename() const
A color representation with 4 components: red, green, blue, alpha.
Represents a map of <std::string, Value>.
#define DEFAULT_BUS_WIDTH_MILS
The default noconnect size in mils.
#define DEFAULT_JUNCTION_DIAM
The default bus and wire entry size in mils.
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
const nlohmann::json defaultBomPlugins
Default value for bom.plugins.
const int eeschemaSchemaVersion
! Update the schema version whenever a migration is required
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SELECTION_SHADOWS
@ LAYER_SCHEMATIC_BACKGROUND
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
bool show_sexpr_file_convert_warning
bool show_illegal_symbol_lib_dialog
wxString edit_sheet_visible_columns
wxString edit_symbol_visible_columns
bool print_sheet_reference
wxString edit_label_visible_columns
bool show_sheet_filename_case_sensitivity_dialog
int hierarchy_panel_docked_width
int hierarchy_panel_float_width
int hierarchy_panel_float_height
bool schematic_hierarchy_float
bool show_schematic_hierarchy
COLOR4D default_sheet_border_color
int default_repeat_offset_x
int default_repeat_offset_y
COLOR4D default_sheet_background_color
int default_wire_thickness
int default_junction_size
std::vector< double > junction_size_mult_list
int default_bus_thickness
int repeat_label_increment
int default_line_thickness
std::vector< BOM_PLUGIN_SETTINGS > plugins
std::map< std::string, bool > fields_show
std::map< std::string, int > column_widths
std::map< std::string, bool > fields_group_by
bool show_pin_electrical_type
std::vector< NETLIST_PLUGIN_SETTINGS > plugins
bool open_file_after_plot
bool select_pin_selects_symbol
bool draw_selected_children
Functions to provide common constants and other functions to assist in making a consistent UI.