26#include <dialogs/dialog_bom_cfg_lexer.h>
42using namespace T_BOMCFG_T;
51 {
"name",
"bom_csv_grouped_extra" },
52 {
"path",
"bom_csv_grouped_extra.py" }
55 {
"name",
"bom_csv_grouped_by_value" },
56 {
"path",
"bom_csv_grouped_by_value.py" }
59 {
"name",
"bom_csv_grouped_by_value_with_fp" },
60 {
"path",
"bom_csv_grouped_by_value_with_fp.py" }
67 static wxAuiPaneInfo paneInfo;
69 paneInfo.Name( wxS(
"NetNavigator" ) )
70 .Caption(
_(
"Net Navigator" ) )
71 .CaptionVisible(
true )
75 .BottomDockable(
false )
79 .FloatingSize( 200, 200 )
80 .FloatingPosition( 50, 200 )
89 static wxAuiPaneInfo paneInfo;
92 .Caption(
_(
"Properties" ) )
93 .CaptionVisible(
true )
97 .BottomDockable(
false )
100 .BestSize( 200, 200 )
101 .FloatingSize( 200, 400 )
102 .FloatingPosition( 50, 200 )
114 m_FindReplaceExtra(),
119 m_FieldEditorPanel(),
126 m_RescueNeverShow( false )
201 new PARAM<bool>(
"appearance.show_sheet_filename_case_sensitivity_dialog",
301 LINE_MODE::LINE_MODE_90 ) );
318 m_params.emplace_back(
new PARAM <int>(
"drawing.junction_size_choice",
381 [&](
const nlohmann::json& aObj )
383 if( !aObj.is_array() )
394 [&](
const nlohmann::json& aObj )
396 if( !aObj.is_array() )
402 const nlohmann::json& list = aObj;
606 if( std::optional<int> optval = Get<int>(
"lib_tree.column_width" ) )
609 Set(
"lib_tree.column_width", 300 );
631 std::string gridSizePtr =
"window.grid.last_size";
633 if( std::optional<int> currentSize = Get<int>( gridSizePtr ) )
635 Set( gridSizePtr, *currentSize - 4 );
640 Set( gridSizePtr, 1 );
643 ret &= fromLegacy<bool>( aCfg,
"FootprintPreview",
"appearance.footprint_preview" );
644 ret &= fromLegacy<bool>( aCfg,
"NavigatorStaysOpen",
"appearance.navigator_stays_open" );
645 ret &= fromLegacy<bool>( aCfg,
"PrintSheetReferenceAndTitleBlock",
646 "appearance.print_sheet_reference" );
647 ret &= fromLegacy<bool>( aCfg,
"ShowHiddenPins",
"appearance.show_hidden_pins" );
648 ret &= fromLegacy<bool>( aCfg,
"ShowIllegalSymbolLibDialog",
649 "appearance.show_illegal_symbol_lib_dialog" );
650 ret &= fromLegacy<bool>( aCfg,
"ShowPageLimits",
"appearance.show_page_limits" );
651 ret &= fromLegacy<bool>( aCfg,
"ShowSheetFileNameCaseSensitivityDlg",
652 "appearance.show_sheet_filename_case_sensitivity_dialog" );
654 ret &= fromLegacy<bool>( aCfg,
"AutoplaceFields",
"autoplace_fields.enable" );
655 ret &= fromLegacy<bool>( aCfg,
"AutoplaceJustify",
"autoplace_fields.allow_rejustify" );
656 ret &= fromLegacy<bool>( aCfg,
"AutoplaceAlign",
"autoplace_fields.align_to_grid" );
658 ret &= fromLegacy<int>( aCfg,
"DefaultBusWidth",
"drawing.default_bus_thickness" );
659 ret &= fromLegacy<int>( aCfg,
"DefaultJunctionSize",
"drawing.default_junction_size" );
660 ret &= fromLegacy<int>( aCfg,
"DefaultDrawLineWidth",
"drawing.default_line_thickness" );
661 ret &= fromLegacy<int>( aCfg,
"RepeatStepX",
"drawing.default_repeat_offset_x" );
662 ret &= fromLegacy<int>( aCfg,
"RepeatStepY",
"drawing.default_repeat_offset_y" );
663 ret &= fromLegacy<int>( aCfg,
"DefaultWireWidth",
"drawing.default_wire_thickness" );
665 ret &= fromLegacy<bool>( aCfg,
"HorizVertLinesOnly",
"drawing.line_mode" );
666 ret &= fromLegacy<int>( aCfg,
"RepeatLabelIncrement",
"drawing.repeat_label_increment" );
668 ret &= fromLegacy<bool>( aCfg,
"DragActionIsMove",
"input.drag_is_move" );
670 ret &= fromLegacy<int>( aCfg,
"SelectionThickness",
"selection.thickness" );
671 ret &= fromLegacy<bool>( aCfg,
"SelectionDrawChildItems",
"selection.draw_selected_children" );
672 ret &= fromLegacy<bool>( aCfg,
"SelectionFillShapes",
"selection.fill_shapes" );
673 ret &= fromLegacy<bool>( aCfg,
"SelectPinSelectSymbolOpt",
674 "selection.select_pin_selects_symbol" );
676 ret &= fromLegacy<int>( aCfg,
"AnnotateAlgoOption",
"annotation.method" );
677 ret &= fromLegacy<int>( aCfg,
"AnnotateFilterMsg",
"annotation.messages_filter" );
678 ret &= fromLegacy<int>( aCfg,
"AnnotateSortOption",
"annotation.sort_order" );
680 ret &=
fromLegacyString( aCfg,
"bom_plugin_selected",
"bom.selected_plugin" );
686 "edit_sch_component.visible_columns" );
688 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportRevision",
"page_settings.export_revision" );
689 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportDate",
"page_settings.export_date" );
690 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportTitle",
"page_settings.export_title" );
691 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportCompany",
"page_settings.export_company" );
692 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment1",
"page_settings.export_comment1" );
693 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment2",
"page_settings.export_comment2" );
694 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment3",
"page_settings.export_comment3" );
695 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment4",
"page_settings.export_comment4" );
696 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment5",
"page_settings.export_comment5" );
697 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment6",
"page_settings.export_comment6" );
698 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment7",
"page_settings.export_comment7" );
699 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment8",
"page_settings.export_comment8" );
700 ret &= fromLegacy<bool>( aCfg,
"PageSettingsExportComment9",
"page_settings.export_comment9" );
704 constexpr int max_custom_commands = 8;
705 nlohmann::json js_cmd = nlohmann::json::array();
706 nlohmann::json js_title = nlohmann::json::array();
707 wxString cmd_key, title_key, cmd, title;
709 for(
int i = 1; i <= max_custom_commands; ++i )
712 cmd_key.Printf(
"CustomNetlistCommand%d", i );
713 title_key.Printf(
"CustomNetlistTitle%d", i );
715 if( aCfg->Read( cmd_key, &cmd ) && aCfg->Read( title_key, &title )
716 && !cmd.IsEmpty() && !title.IsEmpty() )
718 js_cmd.push_back( cmd.ToUTF8() );
719 js_title.push_back( title.ToUTF8() );
723 Set(
"netlist.custom_command_titles", js_title );
724 Set(
"netlist.custom_command_paths", js_cmd );
733 aCfg->SetPath(
"SymbolFieldEditor/Show/" );
735 nlohmann::json js = nlohmann::json( {} );
740 while( aCfg->GetNextEntry( key, index ) )
742 if( aCfg->Read( key, &value ) )
744 std::string key_utf( key.ToUTF8() );
757 Set(
"field_editor.fields_show", js );
759 aCfg->SetPath(
"../GroupBy" );
761 while( aCfg->GetNextEntry( key, index ) )
763 if( aCfg->Read( key, &value ) )
765 std::string key_utf( key.ToUTF8() );
778 Set(
"field_editor.fields_group_by", js );
780 aCfg->SetPath(
"../.." );
783 ret &= fromLegacy<bool>( aCfg,
"PlotModeColor",
"plot.color" );
784 ret &= fromLegacy<int>( aCfg,
"PlotFormat",
"plot.format" );
785 ret &= fromLegacy<bool>( aCfg,
"PlotFrameRef",
"plot.frame_reference" );
786 ret &= fromLegacy<bool>( aCfg,
"PlotHPGLOrg",
"plot.hpgl_origin" );
787 ret &= fromLegacy<int>( aCfg,
"PlotHPGLPaperSize",
"plot.hpgl_paper_size" );
788 ret &= fromLegacy<double>( aCfg,
"PlotHPGLPenSize",
"plot.hpgl_pen_size" );
790 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMEPos_x",
"simulator.window.pos_x" );
791 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMEPos_y",
"simulator.window.pos_y" );
792 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMESize_x",
"simulator.window.size_x" );
793 ret &= fromLegacy<int>( aCfg,
"SIM_PLOT_FRAMESize_y",
"simulator.window.size_y" );
794 ret &= fromLegacy<bool>( aCfg,
"SIM_PLOT_FRAMEMaximized",
"simulator.window.maximized" );
795 ret &=
fromLegacyString( aCfg,
"SIM_PLOT_FRAMEPerspective",
"simulator.window.perspective" );
796 ret &=
fromLegacyString( aCfg,
"SIM_PLOT_FRAMEMostRecentlyUsedPath",
"simulator.mru_path" );
797 ret &= fromLegacy<int>( aCfg,
"SimPlotPanelWidth",
"simulator.plot_panel_width" );
798 ret &= fromLegacy<int>( aCfg,
"SimPlotPanelHeight",
"simulator.plot_panel_height" );
799 ret &= fromLegacy<int>( aCfg,
"SimSignalPanelHeight",
"simulator.signal_panel_height" );
800 ret &= fromLegacy<int>( aCfg,
"SimCursorsPanelHeight",
"simulator.cursors_panel_height" );
801 ret &= fromLegacy<bool>( aCfg,
"SimPlotWhiteBg",
"simulator.white_background" );
803 ret &= fromLegacy<int>( aCfg,
"SymbolChooserHSashPosition",
"symbol_chooser.sash_pos_h" );
804 ret &= fromLegacy<int>( aCfg,
"SymbolChooserVSashPosition",
"symbol_chooser.sash_pos_v" );
805 ret &= fromLegacy<int>( aCfg,
"SymbolChooserWidth",
"symbol_chooser.width" );
806 ret &= fromLegacy<int>( aCfg,
"SymbolChooserHeight",
"symbol_chooser.height" );
807 ret &= fromLegacy<bool>( aCfg,
"SymbolChooserKeepSymbol",
"symbol_chooser.keep_symbol" );
808 ret &= fromLegacy<bool>( aCfg,
"SymbolChooserUseUnits",
"symbol_chooser.place_all_units" );
810 const std::string vlf =
"ViewlibFrame";
811 ret &= fromLegacy<bool>( aCfg, vlf +
"Maximized",
"lib_view.window.maximized" );
812 ret &=
fromLegacyString( aCfg, vlf +
"MostRecentlyUsedPath",
"lib_view.window.mru_path" );
813 ret &= fromLegacy<int>( aCfg, vlf +
"Size_x",
"lib_view.window.size_x" );
814 ret &= fromLegacy<int>( aCfg, vlf +
"Size_y",
"lib_view.window.size_y" );
815 ret &=
fromLegacyString( aCfg, vlf +
"Perspective",
"lib_view.window.perspective" );
816 ret &= fromLegacy<int>( aCfg, vlf +
"Pos_x",
"lib_view.window.pos_x" );
817 ret &= fromLegacy<int>( aCfg, vlf +
"Pos_y",
"lib_view.window.pos_y" );
818 ret &= fromLegacy<int>( aCfg,
"ViewLiblistWidth",
"lib_view.lib_list_width" );
819 ret &= fromLegacy<int>( aCfg,
"ViewCmplistWidth",
"lib_view.cmp_list_width" );
820 ret &= fromLegacy<bool>( aCfg,
821 "ViewCmpShowPinElectricalType",
"lib_view.show_pin_electrical_type" );
822 ret &= fromLegacy<bool>( aCfg, vlf +
"ShowGrid",
"lib_view.grid.show" );
823 ret &= fromLegacy<int>( aCfg, vlf +
"_LastGridSize",
"lib_view.grid.last_size" );
825 ret &= fromLegacy<bool>( aCfg,
"RescueNeverShow",
"system.never_show_rescue_dialog" );
830 if( aCfg->Read(
"MoveWarpsCursor", &tmp ) )
831 Pgm().GetCommonSettings()->m_Input.warp_mouse_on_move = tmp;
835 auto migrateLegacyColor = [&] (
const std::string& aKey,
int aLayerId ) {
838 if( aCfg->Read( aKey, &str ) )
846 migrateLegacyColor(
"Color4DBusEx",
LAYER_BUS );
858 migrateLegacyColor(
"Color4DNoteEx",
LAYER_NOTES );
859 migrateLegacyColor(
"Color4DPinEx",
LAYER_PIN );
864 migrateLegacyColor(
"Color4DSheetEx",
LAYER_SHEET );
869 migrateLegacyColor(
"Color4DWireEx",
LAYER_WIRE );
872 Pgm().GetSettingsManager().SaveColorSettings( cs,
"schematic" );
880 libedit->MigrateFromLegacy( aCfg );
896 BOM_CFG_PARSER( std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS>* aPluginList,
897 const char* aData,
const wxString& aSource );
917 wxString list = *Get<wxString>(
"bom.plugins" );
939 nlohmann::json js = nlohmann::json::array();
943 nlohmann::json pluginJson;
945 pluginJson[
"name"] = plugin.
name.ToUTF8();
946 pluginJson[
"path"] = plugin.
path.ToUTF8();
947 pluginJson[
"command"] = plugin.
command.ToUTF8();
949 js.push_back( pluginJson );
957 const nlohmann::json& aObj )
959 std::vector<EESCHEMA_SETTINGS::BOM_PLUGIN_SETTINGS> ret;
961 wxASSERT( aObj.is_array() );
963 for(
const nlohmann::json& entry : aObj )
965 if( entry.empty() || !entry.is_object() )
968 if( !entry.contains(
"name" ) || !entry.contains(
"path" ) )
972 entry.at(
"path" ).get<wxString>() );
974 if( entry.contains(
"command" ) )
975 plugin.
command = entry.at(
"command" ).get<wxString>();
977 ret.emplace_back( plugin );
986 nlohmann::json js = nlohmann::json::array();
990 nlohmann::json pluginJson;
992 pluginJson[
"name"] = plugin.
name.ToUTF8();
993 pluginJson[
"path"] = plugin.
path.ToUTF8();
994 pluginJson[
"command"] = plugin.
command.ToUTF8();
996 js.push_back( pluginJson );
1004 const nlohmann::json& aObj )
1006 std::vector<EESCHEMA_SETTINGS::NETLIST_PLUGIN_SETTINGS> ret;
1008 wxASSERT( aObj.is_array() );
1010 for(
const nlohmann::json& entry : aObj )
1012 if( entry.empty() || !entry.is_object() )
1015 if( !entry.contains(
"name" ) || !entry.contains(
"path" ) )
1019 entry.at(
"path" ).get<wxString>() );
1021 if( entry.contains(
"command" ) )
1022 plugin.
command = entry.at(
"command" ).get<wxString>();
1024 ret.emplace_back( plugin );
1032 const char* aLine,
const wxString& aSource ) :
1033 DIALOG_BOM_CFG_LEXER( aLine, aSource )
1035 wxASSERT( aPluginList );
1044 while( ( token = NextTok() ) != T_RIGHT )
1049 if( token == T_LEFT )
1052 if( token == T_plugins )
1074 NeedSYMBOLorNUMBER();
1075 settings.
path = FromUTF8();
1079 while( ( token = NextTok() ) != T_RIGHT )
1090 NeedSYMBOLorNUMBER();
1092 settings.
command = FromUTF8();
1099 NeedSYMBOLorNUMBER();
1101 wxString option = FromUTF8();
1103 if( option.StartsWith( wxS(
"nickname=" ), &str ) )
1104 settings.
name = str;
1111 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)
static const wxString PropertiesPaneName()
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.
Like a normal param, but with custom getter and setter functions.
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 wxAuiPaneInfo & defaultPropertiesPaneInfo()
const wxAuiPaneInfo & defaultNetNavigatorPaneInfo()
const int eeschemaSchemaVersion
! Update the schema version whenever a migration is required
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SELECTION_SHADOWS
@ LAYER_SCHEMATIC_BACKGROUND
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool show_sexpr_file_convert_warning
bool show_illegal_symbol_lib_dialog
wxString edit_sheet_visible_columns
bool show_directive_labels
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 search_panel_dock_direction
int hierarchy_panel_docked_height
int hierarchy_panel_float_height
wxSize net_nav_panel_float_size
float properties_splitter
bool schematic_hierarchy_float
int properties_panel_width
wxPoint net_nav_panel_float_pos
wxSize net_nav_panel_docked_size
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, int > field_widths
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
int measurements_panel_height
Functions to provide common constants and other functions to assist in making a consistent UI.