From 3c3984a6fc54fe54ada4af3c5713ad309b1a6859 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 8 May 2020 19:10:47 +0100 Subject: [PATCH] Generalize default footprint fields. Fixes https://gitlab.com/kicad/code/kicad/issues/2289 --- common/settings/json_settings.cpp | 11 +- .../panel_eeschema_template_fieldnames.cpp | 6 +- include/board_design_settings.h | 35 +- include/lib_table_grid.h | 11 +- include/settings/parameters.h | 79 +- pcbnew/board_design_settings.cpp | 16 +- pcbnew/dialogs/panel_modedit_defaults.cpp | 272 ++++++- pcbnew/dialogs/panel_modedit_defaults.h | 6 + .../dialogs/panel_modedit_defaults_base.cpp | 183 ++--- .../dialogs/panel_modedit_defaults_base.fbp | 700 ++++++------------ pcbnew/dialogs/panel_modedit_defaults_base.h | 32 +- .../panel_setup_feature_constraints.cpp | 31 +- pcbnew/footprint_edit_frame.cpp | 58 +- pcbnew/footprint_editor_settings.cpp | 195 ++--- pcbnew/footprint_libraries_utils.cpp | 151 ++-- pcbnew/pcbnew_settings.cpp | 90 +-- pcbnew/router/pns_routing_settings.cpp | 21 +- pcbnew/text_mod_grid_table.cpp | 6 +- 18 files changed, 959 insertions(+), 944 deletions(-) diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp index 7c15fa2cd0..5980e79ddd 100644 --- a/common/settings/json_settings.cpp +++ b/common/settings/json_settings.cpp @@ -38,9 +38,14 @@ extern const char* traceSettings; JSON_SETTINGS::JSON_SETTINGS( const std::string& aFilename, SETTINGS_LOC aLocation, int aSchemaVersion, bool aCreateIfMissing, bool aWriteFile, nlohmann::json aDefault ) : - nlohmann::json( std::move( aDefault ) ), m_filename( aFilename ), m_legacy_filename( "" ), - m_location( aLocation ), m_createIfMissing( aCreateIfMissing ), m_writeFile( aWriteFile ), - m_schemaVersion( aSchemaVersion ), m_manager( nullptr ) + nlohmann::json( std::move( aDefault ) ), + m_filename( aFilename ), + m_legacy_filename( "" ), + m_location( aLocation ), + m_createIfMissing( aCreateIfMissing ), + m_writeFile( aWriteFile ), + m_schemaVersion( aSchemaVersion ), + m_manager( nullptr ) { m_params.emplace_back( new PARAM( "meta.filename", &m_filename, m_filename, true ) ); diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp b/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp index 6bc7c50027..a6934147e0 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp +++ b/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp @@ -150,9 +150,9 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid() for( int row = 0; row < m_grid->GetNumberRows(); ++row ) { - m_fields[row].m_Name = m_grid->GetCellValue( row, 0 ); - m_fields[row].m_Visible = ( m_grid->GetCellValue( row, 1 ) != wxEmptyString ); - m_fields[row].m_URL = ( m_grid->GetCellValue( row, 2 ) != wxEmptyString ); + m_fields[row].m_Name = m_grid->GetCellValue( row, 0 ); + m_fields[row].m_Visible = m_grid->GetCellValue( row, 1 ) != wxEmptyString; + m_fields[row].m_URL = m_grid->GetCellValue( row, 2 ) != wxEmptyString; } return true; diff --git a/include/board_design_settings.h b/include/board_design_settings.h index 4206aa0ca9..14acfe85a0 100644 --- a/include/board_design_settings.h +++ b/include/board_design_settings.h @@ -175,6 +175,22 @@ enum LAYER_CLASS_COUNT }; + +struct TEXT_ITEM_INFO +{ + wxString m_Text; + bool m_Visible; + int m_Layer; + + TEXT_ITEM_INFO( const wxString& aText, bool aVisible, int aLayer ) + { + m_Text = aText; + m_Visible = aVisible; + m_Layer = aLayer; + } +}; + + // forward declaration from class_track.h enum class VIATYPE : int; @@ -230,6 +246,9 @@ public: double m_SolderPasteMarginRatio; ///< Solder pask margin ratio value of pad size ///< The final margin is the sum of these 2 values + // Variables used in footprint editing (default value in item/footprint creation) + std::vector m_DefaultFPTextItems; + // Arrays of default values for the various layer classes. int m_LineThickness[ LAYER_CLASS_COUNT ]; wxSize m_TextSize[ LAYER_CLASS_COUNT ]; @@ -240,22 +259,6 @@ public: int m_DimensionUnits; int m_DimensionPrecision; - // Variables used in footprint editing (default value in item/footprint creation) - - wxString m_RefDefaultText; ///< Default ref text on fp creation - // if empty, use footprint name as default - bool m_RefDefaultVisibility; ///< Default ref text visibility on fp creation - int m_RefDefaultlayer; ///< Default ref text layer on fp creation - // should be a PCB_LAYER_ID, but use an int - // to save this param in config - - wxString m_ValueDefaultText; ///< Default value text on fp creation - // if empty, use footprint name as default - bool m_ValueDefaultVisibility; ///< Default value text visibility on fp creation - int m_ValueDefaultlayer; ///< Default value text layer on fp creation - // should be a PCB_LAYER_ID, but use an int - // to save this param in config - // Miscellaneous wxPoint m_AuxOrigin; ///< origin for plot exports wxPoint m_GridOrigin; ///< origin for grid offsets diff --git a/include/lib_table_grid.h b/include/lib_table_grid.h index 4be96adcb8..de582e466e 100644 --- a/include/lib_table_grid.h +++ b/include/lib_table_grid.h @@ -150,10 +150,7 @@ public: if( GetView() ) { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_ROWS_APPENDED, - aNumRows ); - + wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, aNumRows ); GetView()->ProcessTableMessage( msg ); } @@ -170,11 +167,7 @@ public: erase( start, start + aNumRows ); if( GetView() ) { - wxGridTableMessage msg( this, - wxGRIDTABLE_NOTIFY_ROWS_DELETED, - aPos, - aNumRows ); - + wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPos, aNumRows ); GetView()->ProcessTableMessage( msg ); } return true; diff --git a/include/settings/parameters.h b/include/settings/parameters.h index a8559e1648..d7ed902d94 100644 --- a/include/settings/parameters.h +++ b/include/settings/parameters.h @@ -33,7 +33,9 @@ class PARAM_BASE { public: PARAM_BASE( std::string aJsonPath, bool aReadOnly ) : - m_path( std::move( aJsonPath ) ), m_readOnly( aReadOnly ) {} + m_path( std::move( aJsonPath ) ), + m_readOnly( aReadOnly ) + {} virtual ~PARAM_BASE() = default; @@ -65,15 +67,23 @@ class PARAM : public PARAM_BASE public: PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ), - m_min(), m_max(), m_use_minmax( false ) - {} + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ), + m_min(), + m_max(), + m_use_minmax( false ) + { } PARAM( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, ValueType aMin, - ValueType aMax, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ), - m_min( aMin ), m_max( aMax ), m_use_minmax( true ) - {} + ValueType aMax, bool aReadOnly = false ) : + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ), + m_min( aMin ), + m_max( aMax ), + m_use_minmax( true ) + { } void Load( JSON_SETTINGS* aSettings ) const override { @@ -119,6 +129,7 @@ private: bool m_use_minmax; }; + /** * Like a normal param, but with custom getter and setter functions * @tparam ValueType is the value to store @@ -128,10 +139,13 @@ class PARAM_LAMBDA : public PARAM_BASE { public: PARAM_LAMBDA( const std::string& aJsonPath, std::function aGetter, - std::function aSetter, ValueType aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_default( aDefault ), m_getter( aGetter ), + std::function aSetter, ValueType aDefault, + bool aReadOnly = false ) : + PARAM_BASE( aJsonPath, aReadOnly ), + m_default( aDefault ), + m_getter( aGetter ), m_setter( aSetter ) - {} + { } void Load( JSON_SETTINGS* aSettings ) const override { @@ -183,6 +197,7 @@ private: std::function m_setter; }; + /** * Represents a parameter that has a scaling factor between the value in the file and the * value used internally (i.e. the value pointer). This basically only makes sense to use @@ -195,15 +210,25 @@ class PARAM_SCALED: public PARAM_BASE public: PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, double aScale = 1.0, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ), - m_min(), m_max(), m_use_minmax( false ), m_scale( aScale ) - {} + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ), + m_min(), + m_max(), + m_use_minmax( false ), + m_scale( aScale ) + { } - PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, ValueType aMin, - ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ), - m_min( aMin ), m_max( aMax ), m_use_minmax( true ), m_scale( aScale ) - {} + PARAM_SCALED( const std::string& aJsonPath, ValueType* aPtr, ValueType aDefault, + ValueType aMin, ValueType aMax, double aScale = 1.0, bool aReadOnly = false ) : + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ), + m_min( aMin ), + m_max( aMax ), + m_use_minmax( true ), + m_scale( aScale ) + { } void Load( JSON_SETTINGS* aSettings ) const override { @@ -256,11 +281,17 @@ class PARAM_LIST : public PARAM_BASE public: PARAM_LIST( const std::string& aJsonPath, std::vector* aPtr, std::initializer_list aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ) {} + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ) + { } PARAM_LIST( const std::string& aJsonPath, std::vector* aPtr, std::vector aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ) {} + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ) + { } void Load( JSON_SETTINGS* aSettings ) const override { @@ -304,6 +335,7 @@ private: std::vector m_default; }; + /** * Represents a map of . The key parameter has to be a string in JSON. * @@ -323,7 +355,10 @@ public: PARAM_MAP( const std::string& aJsonPath, std::map* aPtr, std::initializer_list> aDefault, bool aReadOnly = false ) : - PARAM_BASE( aJsonPath, aReadOnly ), m_ptr( aPtr ), m_default( aDefault ) {} + PARAM_BASE( aJsonPath, aReadOnly ), + m_ptr( aPtr ), + m_default( aDefault ) + { } void Load( JSON_SETTINGS* aSettings ) const override { diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 6fa3d4a6e1..91485be8ca 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -551,6 +551,13 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : m_BlindBuriedViaAllowed = false; m_MicroViasAllowed = false; + // First is always the reference designator + m_DefaultFPTextItems.emplace_back( wxT( "REF**" ), true, F_SilkS ); + // Second is always the value + m_DefaultFPTextItems.emplace_back( wxT( "" ), true, F_Fab ); + // Any following ones are freebies + m_DefaultFPTextItems.emplace_back( wxT( "${REF}" ), true, F_Fab ); + m_LineThickness[ LAYER_CLASS_SILK ] = Millimeter2iu( DEFAULT_SILK_LINE_WIDTH ); m_TextSize[ LAYER_CLASS_SILK ] = wxSize( Millimeter2iu( DEFAULT_SILK_TEXT_SIZE ), Millimeter2iu( DEFAULT_SILK_TEXT_SIZE ) ); @@ -642,15 +649,6 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : m_viaSizeIndex = 0; m_trackWidthIndex = 0; m_diffPairIndex = 0; - - // Default ref text on fp creation. If empty, use footprint name as default - m_RefDefaultText = "REF**"; - m_RefDefaultVisibility = true; - m_RefDefaultlayer = int( F_SilkS ); - // Default value text on fp creation. If empty, use footprint name as default - m_ValueDefaultText = ""; - m_ValueDefaultVisibility = true; - m_ValueDefaultlayer = int( F_Fab ); } // Add parameters to save in project config. diff --git a/pcbnew/dialogs/panel_modedit_defaults.cpp b/pcbnew/dialogs/panel_modedit_defaults.cpp index 97dc2b8fac..4ef83af4e8 100644 --- a/pcbnew/dialogs/panel_modedit_defaults.cpp +++ b/pcbnew/dialogs/panel_modedit_defaults.cpp @@ -29,6 +29,120 @@ #include #include +#include +#include + +class TEXT_ITEMS_GRID_TABLE : public wxGridTableBase +{ + std::vector m_items; + +public: + TEXT_ITEMS_GRID_TABLE() + { } + + int GetNumberRows() override { return m_items.size(); } + int GetNumberCols() override { return 3; } + + wxString GetColLabelValue( int aCol ) override + { + switch( aCol ) + { + case 0: return _( "Text Items" ); + case 1: return _( "Show" ); + case 2: return _( "Layer" ); + default: return wxEmptyString; + } + } + + wxString GetRowLabelValue( int aRow ) + { + switch( aRow ) + { + case 0: return _( "Reference designator" ); + case 1: return _( "Value" ); + default: return wxEmptyString; + } + } + + bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) + { + switch( aCol ) + { + case 0: return aTypeName == wxGRID_VALUE_STRING; + case 1: return aTypeName == wxGRID_VALUE_BOOL; + case 2: return aTypeName == wxGRID_VALUE_NUMBER; + default: wxFAIL; return false; + } + } + + bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) + { + return CanGetValueAs( aRow, aCol, aTypeName ); + } + + wxString GetValue( int row, int col ) override + { + return m_items[row].m_Text; + } + void SetValue( int row, int col, const wxString& value ) override + { + if( col == 0 ) + m_items[row].m_Text = value; + } + + bool GetValueAsBool( int row, int col ) override + { + return m_items[row].m_Visible; + } + void SetValueAsBool( int row, int col, bool value ) override + { + if( col == 1 ) + m_items[row].m_Visible = value; + } + + long GetValueAsLong( int row, int col ) override + { + return m_items[row].m_Layer; + } + void SetValueAsLong( int row, int col, long value ) override + { + if( col == 2 ) + m_items[row].m_Layer = value; + } + + bool AppendRows( size_t aNumRows = 1 ) override + { + for( int i = 0; i < aNumRows; ++i ) + m_items.emplace_back( wxT( "" ), true, F_SilkS ); + + if( GetView() ) + { + wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, aNumRows ); + GetView()->ProcessTableMessage( msg ); + } + + return true; + } + + bool DeleteRows( size_t aPos, size_t aNumRows ) override + { + // aPos may be a large positive, e.g. size_t(-1), and the sum of + // aPos+aNumRows may wrap here, so both ends of the range are tested. + if( aPos < m_items.size() && aPos + aNumRows <= m_items.size() ) + { + m_items.erase( m_items.begin() + aPos, m_items.begin() + aPos + aNumRows ); + + if( GetView() ) + { + wxGridTableMessage msg( this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, aPos, aNumRows ); + GetView()->ProcessTableMessage( msg ); + } + return true; + } + + return false; + } +}; // Columns of layer classes grid @@ -60,14 +174,27 @@ PANEL_MODEDIT_DEFAULTS::PANEL_MODEDIT_DEFAULTS( FOOTPRINT_EDIT_FRAME* aFrame, PA m_frame( aFrame ), m_Parent( aParent ) { - m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); + m_textItemsGrid->SetDefaultRowSize( m_textItemsGrid->GetDefaultRowSize() + 4 ); + m_layerClassesGrid->SetDefaultRowSize( m_layerClassesGrid->GetDefaultRowSize() + 4 ); + + m_textItemsGrid->SetTable( new TEXT_ITEMS_GRID_TABLE(), true ); + + wxGridCellAttr* attr = new wxGridCellAttr; + attr->SetRenderer( new wxGridCellBoolRenderer() ); + attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS + m_textItemsGrid->SetColAttr( 1, attr ); + + attr = new wxGridCellAttr; + attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) ); + attr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, LSET::ForbiddenTextLayers() ) ); + m_textItemsGrid->SetColAttr( 2, attr ); // Work around a bug in wxWidgets where it fails to recalculate the grid height // after changing the default row size - m_grid->AppendRows( 1 ); - m_grid->DeleteRows( m_grid->GetNumberRows() - 1, 1 ); + m_layerClassesGrid->AppendRows( 1 ); + m_layerClassesGrid->DeleteRows( m_layerClassesGrid->GetNumberRows() - 1, 1 ); - m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); + m_layerClassesGrid->PushEventHandler( new GRID_TRICKS( m_layerClassesGrid ) ); wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); infoFont.SetSymbolicSize( wxFONTSIZE_SMALL ); @@ -77,8 +204,8 @@ PANEL_MODEDIT_DEFAULTS::PANEL_MODEDIT_DEFAULTS( FOOTPRINT_EDIT_FRAME* aFrame, PA PANEL_MODEDIT_DEFAULTS::~PANEL_MODEDIT_DEFAULTS() { - // destroy GRID_TRICKS before m_grid. - m_grid->PopEventHandler( true ); + // destroy GRID_TRICKS before m_layerClassesGrid. + m_layerClassesGrid->PopEventHandler( true ); } @@ -87,10 +214,10 @@ bool PANEL_MODEDIT_DEFAULTS::TransferDataToWindow() wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ); #define SET_MILS_CELL( row, col, val ) \ - m_grid->SetCellValue( row, col, StringFromValue( m_frame->GetUserUnits(), val, true, true ) ) + m_layerClassesGrid->SetCellValue( row, col, StringFromValue( m_frame->GetUserUnits(), val, true, true ) ) #define DISABLE_CELL( row, col ) \ - m_grid->SetReadOnly( row, col ); m_grid->SetCellBackgroundColour( row, col, disabledColour ); + m_layerClassesGrid->SetReadOnly( row, col ); m_layerClassesGrid->SetCellBackgroundColour( row, col, disabledColour ); for( int i = 0; i < ROW_COUNT; ++i ) { @@ -108,36 +235,39 @@ bool PANEL_MODEDIT_DEFAULTS::TransferDataToWindow() SET_MILS_CELL( i, COL_TEXT_WIDTH, m_brdSettings.m_TextSize[ i ].x ); SET_MILS_CELL( i, COL_TEXT_HEIGHT, m_brdSettings.m_TextSize[ i ].y ); SET_MILS_CELL( i, COL_TEXT_THICKNESS, m_brdSettings.m_TextThickness[ i ] ); - m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_brdSettings.m_TextItalic[ i ] ? "1" : "" ); + m_layerClassesGrid->SetCellValue( i, COL_TEXT_ITALIC, m_brdSettings.m_TextItalic[ i ] ? "1" : "" ); auto attr = new wxGridCellAttr; attr->SetRenderer( new wxGridCellBoolRenderer() ); attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM ); - m_grid->SetAttr( i, COL_TEXT_ITALIC, attr ); + m_layerClassesGrid->SetAttr( i, COL_TEXT_ITALIC, attr ); } } // Footprint defaults - m_textCtrlRefText->SetValue( m_brdSettings.m_RefDefaultText ); - m_choiceLayerReference->SetSelection( m_brdSettings.m_RefDefaultlayer == F_SilkS ? 0 : 1 ); - m_choiceVisibleReference->SetSelection( m_brdSettings.m_RefDefaultVisibility ? 0 : 1 ); + m_textItemsGrid->GetTable()->AppendRows( m_brdSettings.m_DefaultFPTextItems.size() ); - m_textCtrlValueText->SetValue( m_brdSettings.m_ValueDefaultText ); - m_choiceLayerValue->SetSelection( m_brdSettings.m_ValueDefaultlayer == F_SilkS ? 0 : 1 ); - m_choiceVisibleValue->SetSelection( m_brdSettings.m_ValueDefaultVisibility ? 0 : 1 ); - - for( int col = 0; col < m_grid->GetNumberCols(); col++ ) + for( int i = 0; i < m_brdSettings.m_DefaultFPTextItems.size(); ++i ) { - // Set the minimal width to the column label size. - m_grid->SetColMinimalWidth( col, m_grid->GetVisibleWidth( col, true, false, false ) ); + TEXT_ITEM_INFO item = m_brdSettings.m_DefaultFPTextItems[i]; - // Set the width to see the full contents - if( m_grid->IsColShown( col ) ) - m_grid->SetColSize( col, m_grid->GetVisibleWidth( col, true, true, true ) ); + m_textItemsGrid->GetTable()->SetValue( i, 0, item.m_Text ); + m_textItemsGrid->GetTable()->SetValueAsBool( i, 1, item.m_Visible ); + m_textItemsGrid->GetTable()->SetValueAsLong( i, 2, item.m_Layer ); } - m_grid->SetRowLabelSize( m_grid->GetVisibleWidth( -1, true, true, true ) ); + for( int col = 0; col < m_layerClassesGrid->GetNumberCols(); col++ ) + { + // Set the minimal width to the column label size. + m_layerClassesGrid->SetColMinimalWidth( col, m_layerClassesGrid->GetVisibleWidth( col, true, false, false ) ); + + // Set the width to see the full contents + if( m_layerClassesGrid->IsColShown( col ) ) + m_layerClassesGrid->SetColSize( col, m_layerClassesGrid->GetVisibleWidth( col, true, true, true ) ); + } + + m_layerClassesGrid->SetRowLabelSize( m_layerClassesGrid->GetVisibleWidth( -1, true, true, true ) ); Layout(); @@ -145,15 +275,39 @@ bool PANEL_MODEDIT_DEFAULTS::TransferDataToWindow() } +bool PANEL_MODEDIT_DEFAULTS::Show( bool aShow ) +{ + bool retVal = wxPanel::Show( aShow ); + + if( aShow ) + { + // These *should* work in the constructor, and indeed they do if this panel is the + // first displayed. However, on OSX 3.0.5 (at least), if another panel is displayed + // first then the icons will be blank unless they're set here. + m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) ); + m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) ); + } + + if( aShow && m_firstShow ) + { + m_layerClassesGrid->SetColumnWidth( 0, m_layerClassesGrid->GetColumnWidth( 0 ) + 1 ); + m_firstShow = false; + } + + return retVal; +} + + int PANEL_MODEDIT_DEFAULTS::getGridValue( int aRow, int aCol ) { - return ValueFromString( m_frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ), true ); + return ValueFromString( m_frame->GetUserUnits(), + m_layerClassesGrid->GetCellValue( aRow, aCol ), true ); } bool PANEL_MODEDIT_DEFAULTS::validateData() { - if( !m_grid->CommitPendingChanges() ) + if( !m_textItemsGrid->CommitPendingChanges() || !m_layerClassesGrid->CommitPendingChanges() ) return false; // Test text parameters. @@ -166,7 +320,7 @@ bool PANEL_MODEDIT_DEFAULTS::validateData() { wxString msg = _( "Text will not be readable with a thickness greater than\n" "1/4 its width or height." ); - m_Parent->SetError( msg, this, m_grid, row, COL_TEXT_THICKNESS ); + m_Parent->SetError( msg, this, m_layerClassesGrid, row, COL_TEXT_THICKNESS ); return false; } } @@ -187,24 +341,68 @@ bool PANEL_MODEDIT_DEFAULTS::TransferDataFromWindow() if( i == ROW_EDGES || i == ROW_COURTYARD ) continue; - m_brdSettings.m_TextSize[ i ] = - wxSize( getGridValue( i, COL_TEXT_WIDTH ), getGridValue( i, COL_TEXT_HEIGHT ) ); + m_brdSettings.m_TextSize[ i ] = wxSize( getGridValue( i, COL_TEXT_WIDTH ), + getGridValue( i, COL_TEXT_HEIGHT ) ); m_brdSettings.m_TextThickness[ i ] = getGridValue( i, COL_TEXT_THICKNESS ); - m_brdSettings.m_TextItalic[ i ] = - wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_ITALIC ) ); + + wxString msg = m_layerClassesGrid->GetCellValue( i, COL_TEXT_ITALIC ); + m_brdSettings.m_TextItalic[ i ] = wxGridCellBoolEditor::IsTrueValue( msg ); } // Footprint defaults - m_brdSettings.m_RefDefaultText = m_textCtrlRefText->GetValue(); - m_brdSettings.m_RefDefaultlayer = (m_choiceLayerReference->GetSelection() == 0) ? F_SilkS : F_Fab; - m_brdSettings.m_RefDefaultVisibility = m_choiceVisibleReference->GetSelection() == 0; + wxGridTableBase* table = m_textItemsGrid->GetTable(); + m_brdSettings.m_DefaultFPTextItems.clear(); + for( int i = 0; i < m_textItemsGrid->GetNumberRows(); ++i ) + { + wxString text = table->GetValue( i, 0 ); + bool visible = table->GetValueAsBool( i, 1 ); + int layer = (int) table->GetValueAsLong( i, 2 ); - m_brdSettings.m_ValueDefaultText = m_textCtrlValueText->GetValue(); - m_brdSettings.m_ValueDefaultlayer = (m_choiceLayerValue->GetSelection() == 0) ? F_SilkS : F_Fab; - m_brdSettings.m_ValueDefaultVisibility = m_choiceVisibleValue->GetSelection() == 0; + m_brdSettings.m_DefaultFPTextItems.emplace_back( text, visible, layer ); + } m_frame->SetDesignSettings( m_brdSettings ); return true; } + + +void PANEL_MODEDIT_DEFAULTS::OnAddTextItem( wxCommandEvent& event ) +{ + if( !m_textItemsGrid->CommitPendingChanges() || !m_layerClassesGrid->CommitPendingChanges() ) + return; + + wxGridTableBase* table = m_textItemsGrid->GetTable(); + + int newRow = m_textItemsGrid->GetNumberRows(); + table->AppendRows( 1 ); + table->SetValueAsBool( newRow, 1, table->GetValueAsBool( newRow - 1, 1 ) ); + table->SetValueAsLong( newRow, 2, table->GetValueAsLong( newRow - 1, 2 ) ); + + m_textItemsGrid->MakeCellVisible( newRow, 0 ); + m_textItemsGrid->SetGridCursor( newRow, 0 ); + + m_textItemsGrid->EnableCellEditControl( true ); + m_textItemsGrid->ShowCellEditControl(); +} + + +void PANEL_MODEDIT_DEFAULTS::OnDeleteTextItem( wxCommandEvent& event ) +{ + if( !m_textItemsGrid->CommitPendingChanges() || !m_layerClassesGrid->CommitPendingChanges() ) + return; + + int curRow = m_textItemsGrid->GetGridCursorRow(); + + if( curRow < 2 ) // First two rows are required + return; + + m_textItemsGrid->GetTable()->DeleteRows( curRow, 1 ); + + curRow = std::max( 0, curRow - 1 ); + m_textItemsGrid->MakeCellVisible( curRow, m_textItemsGrid->GetGridCursorCol() ); + m_textItemsGrid->SetGridCursor( curRow, m_textItemsGrid->GetGridCursorCol() ); +} + + diff --git a/pcbnew/dialogs/panel_modedit_defaults.h b/pcbnew/dialogs/panel_modedit_defaults.h index ff25f31009..be5392fd99 100644 --- a/pcbnew/dialogs/panel_modedit_defaults.h +++ b/pcbnew/dialogs/panel_modedit_defaults.h @@ -32,12 +32,18 @@ class PANEL_MODEDIT_DEFAULTS : public PANEL_MODEDIT_DEFAULTS_BASE BOARD_DESIGN_SETTINGS m_brdSettings; FOOTPRINT_EDIT_FRAME* m_frame; PAGED_DIALOG* m_Parent; + bool m_firstShow = true; public: PANEL_MODEDIT_DEFAULTS( FOOTPRINT_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ); ~PANEL_MODEDIT_DEFAULTS() override; private: + virtual void OnAddTextItem( wxCommandEvent& event ) override; + virtual void OnDeleteTextItem( wxCommandEvent& event ) override; + + bool Show( bool aShow ) override; + int getGridValue( int aRow, int aCol ); bool validateData(); diff --git a/pcbnew/dialogs/panel_modedit_defaults_base.cpp b/pcbnew/dialogs/panel_modedit_defaults_base.cpp index b7abbe8cc3..e342f3bf29 100644 --- a/pcbnew/dialogs/panel_modedit_defaults_base.cpp +++ b/pcbnew/dialogs/panel_modedit_defaults_base.cpp @@ -19,127 +19,134 @@ PANEL_MODEDIT_DEFAULTS_BASE::PANEL_MODEDIT_DEFAULTS_BASE( wxWindow* parent, wxWi wxBoxSizer* bSizerMargins; bSizerMargins = new wxBoxSizer( wxVERTICAL ); - m_staticText13 = new wxStaticText( this, wxID_ANY, _("Default values for new footprints:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText13->Wrap( -1 ); - bSizerMargins->Add( m_staticText13, 0, wxTOP|wxLEFT, 5 ); + defaultTextItemsLabel = new wxStaticText( this, wxID_ANY, _("Default text items for new footprints:"), wxDefaultPosition, wxDefaultSize, 0 ); + defaultTextItemsLabel->Wrap( -1 ); + bSizerMargins->Add( defaultTextItemsLabel, 0, wxTOP|wxLEFT, 5 ); - wxFlexGridSizer* defaultValuesSizer; - defaultValuesSizer = new wxFlexGridSizer( 0, 4, 5, 5 ); - defaultValuesSizer->AddGrowableCol( 1 ); - defaultValuesSizer->SetFlexibleDirection( wxBOTH ); - defaultValuesSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + wxStaticBoxSizer* sbSizerTexts; + sbSizerTexts = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); - m_staticTextRef = new wxStaticText( this, wxID_ANY, _("&Reference designator:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextRef->Wrap( -1 ); - defaultValuesSizer->Add( m_staticTextRef, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); + m_textItemsGrid = new WX_GRID( sbSizerTexts->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - m_textCtrlRefText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textCtrlRefText->SetToolTip( _("Default text for reference\nLeave blank to use the footprint name") ); + // Grid + m_textItemsGrid->CreateGrid( 2, 3 ); + m_textItemsGrid->EnableEditing( true ); + m_textItemsGrid->EnableGridLines( true ); + m_textItemsGrid->EnableDragGridSize( false ); + m_textItemsGrid->SetMargins( 0, 0 ); - defaultValuesSizer->Add( m_textCtrlRefText, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxRIGHT, 5 ); + // Columns + m_textItemsGrid->SetColSize( 0, 233 ); + m_textItemsGrid->SetColSize( 1, 60 ); + m_textItemsGrid->SetColSize( 2, 120 ); + m_textItemsGrid->EnableDragColMove( false ); + m_textItemsGrid->EnableDragColSize( true ); + m_textItemsGrid->SetColLabelSize( 24 ); + m_textItemsGrid->SetColLabelValue( 0, _("Text Items") ); + m_textItemsGrid->SetColLabelValue( 1, _("Show") ); + m_textItemsGrid->SetColLabelValue( 2, _("Layer") ); + m_textItemsGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); - wxString m_choiceLayerReferenceChoices[] = { _("SilkScreen"), _("Fab. Layer") }; - int m_choiceLayerReferenceNChoices = sizeof( m_choiceLayerReferenceChoices ) / sizeof( wxString ); - m_choiceLayerReference = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceLayerReferenceNChoices, m_choiceLayerReferenceChoices, 0 ); - m_choiceLayerReference->SetSelection( 0 ); - defaultValuesSizer->Add( m_choiceLayerReference, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); + // Rows + m_textItemsGrid->EnableDragRowSize( false ); + m_textItemsGrid->SetRowLabelSize( 160 ); + m_textItemsGrid->SetRowLabelValue( 0, _("Reference designator") ); + m_textItemsGrid->SetRowLabelValue( 1, _("Value") ); + m_textItemsGrid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER ); - wxString m_choiceVisibleReferenceChoices[] = { _("Visible"), _("Invisible") }; - int m_choiceVisibleReferenceNChoices = sizeof( m_choiceVisibleReferenceChoices ) / sizeof( wxString ); - m_choiceVisibleReference = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceVisibleReferenceNChoices, m_choiceVisibleReferenceChoices, 0 ); - m_choiceVisibleReference->SetSelection( 0 ); - defaultValuesSizer->Add( m_choiceVisibleReference, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); + // Label Appearance - m_staticTextValue = new wxStaticText( this, wxID_ANY, _("V&alue:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextValue->Wrap( -1 ); - defaultValuesSizer->Add( m_staticTextValue, 0, wxALIGN_CENTER_VERTICAL, 5 ); + // Cell Defaults + m_textItemsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_textItemsGrid->SetMinSize( wxSize( -1,140 ) ); - m_textCtrlValueText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textCtrlValueText->SetToolTip( _("Default text for value\nLeave blank to use the footprint name") ); - m_textCtrlValueText->SetMinSize( wxSize( 160,-1 ) ); + sbSizerTexts->Add( m_textItemsGrid, 1, wxALL|wxBOTTOM|wxEXPAND, 5 ); - defaultValuesSizer->Add( m_textCtrlValueText, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 5 ); + wxBoxSizer* bButtonSize; + bButtonSize = new wxBoxSizer( wxHORIZONTAL ); - wxString m_choiceLayerValueChoices[] = { _("SilkScreen"), _("Fab. Layer") }; - int m_choiceLayerValueNChoices = sizeof( m_choiceLayerValueChoices ) / sizeof( wxString ); - m_choiceLayerValue = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceLayerValueNChoices, m_choiceLayerValueChoices, 0 ); - m_choiceLayerValue->SetSelection( 1 ); - defaultValuesSizer->Add( m_choiceLayerValue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + m_bpAdd = new wxBitmapButton( sbSizerTexts->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpAdd->SetMinSize( wxSize( 30,29 ) ); - wxString m_choiceVisibleValueChoices[] = { _("Visible"), _("Invisible") }; - int m_choiceVisibleValueNChoices = sizeof( m_choiceVisibleValueChoices ) / sizeof( wxString ); - m_choiceVisibleValue = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceVisibleValueNChoices, m_choiceVisibleValueChoices, 0 ); - m_choiceVisibleValue->SetSelection( 0 ); - defaultValuesSizer->Add( m_choiceVisibleValue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bButtonSize->Add( m_bpAdd, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - bSizerMargins->Add( defaultValuesSizer, 0, wxEXPAND|wxLEFT, 25 ); + bButtonSize->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + m_bpDelete = new wxBitmapButton( sbSizerTexts->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + m_bpDelete->SetMinSize( wxSize( 30,29 ) ); + + bButtonSize->Add( m_bpDelete, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - bSizerMargins->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + sbSizerTexts->Add( bButtonSize, 0, wxEXPAND, 5 ); - m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("A blank reference designator or value will use the footprint name."), wxDefaultPosition, wxDefaultSize, 0 ); + + bSizerMargins->Add( sbSizerTexts, 1, wxEXPAND|wxLEFT, 20 ); + + m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("Note: a blank reference designator or value will use the footprint name."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextInfo->Wrap( -1 ); - m_staticTextInfo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + m_staticTextInfo->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); bSizerMargins->Add( m_staticTextInfo, 0, wxBOTTOM|wxLEFT, 25 ); bSizerMargins->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); - wxBoxSizer* defaultSizesSizer1; - defaultSizesSizer1 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* defaultPropertiesSizer; + defaultPropertiesSizer = new wxBoxSizer( wxVERTICAL ); - m_staticText1 = new wxStaticText( this, wxID_ANY, _("Default properties for new graphic items:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - defaultSizesSizer1->Add( m_staticText1, 0, wxBOTTOM|wxRIGHT, 5 ); + wxStaticText* defaultPropertiesLabel; + defaultPropertiesLabel = new wxStaticText( this, wxID_ANY, _("Default properties for new graphic items:"), wxDefaultPosition, wxDefaultSize, 0 ); + defaultPropertiesLabel->Wrap( -1 ); + defaultPropertiesSizer->Add( defaultPropertiesLabel, 0, wxBOTTOM|wxRIGHT, 5 ); - m_grid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_layerClassesGrid = new WX_GRID( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); // Grid - m_grid->CreateGrid( 6, 5 ); - m_grid->EnableEditing( true ); - m_grid->EnableGridLines( true ); - m_grid->EnableDragGridSize( false ); - m_grid->SetMargins( 0, 0 ); + m_layerClassesGrid->CreateGrid( 6, 5 ); + m_layerClassesGrid->EnableEditing( true ); + m_layerClassesGrid->EnableGridLines( true ); + m_layerClassesGrid->EnableDragGridSize( false ); + m_layerClassesGrid->SetMargins( 0, 0 ); // Columns - m_grid->SetColSize( 0, 110 ); - m_grid->SetColSize( 1, 100 ); - m_grid->SetColSize( 2, 100 ); - m_grid->SetColSize( 3, 100 ); - m_grid->SetColSize( 4, 60 ); - m_grid->EnableDragColMove( false ); - m_grid->EnableDragColSize( true ); - m_grid->SetColLabelSize( 22 ); - m_grid->SetColLabelValue( 0, _("Line Thickness") ); - m_grid->SetColLabelValue( 1, _("Text Width") ); - m_grid->SetColLabelValue( 2, _("Text Height") ); - m_grid->SetColLabelValue( 3, _("Text Thickness") ); - m_grid->SetColLabelValue( 4, _("Italic") ); - m_grid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + m_layerClassesGrid->SetColSize( 0, 110 ); + m_layerClassesGrid->SetColSize( 1, 100 ); + m_layerClassesGrid->SetColSize( 2, 100 ); + m_layerClassesGrid->SetColSize( 3, 100 ); + m_layerClassesGrid->SetColSize( 4, 60 ); + m_layerClassesGrid->EnableDragColMove( false ); + m_layerClassesGrid->EnableDragColSize( true ); + m_layerClassesGrid->SetColLabelSize( 22 ); + m_layerClassesGrid->SetColLabelValue( 0, _("Line Thickness") ); + m_layerClassesGrid->SetColLabelValue( 1, _("Text Width") ); + m_layerClassesGrid->SetColLabelValue( 2, _("Text Height") ); + m_layerClassesGrid->SetColLabelValue( 3, _("Text Thickness") ); + m_layerClassesGrid->SetColLabelValue( 4, _("Italic") ); + m_layerClassesGrid->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); // Rows - m_grid->EnableDragRowSize( false ); - m_grid->SetRowLabelSize( 125 ); - m_grid->SetRowLabelValue( 0, _("Silk Layers") ); - m_grid->SetRowLabelValue( 1, _("Copper Layers") ); - m_grid->SetRowLabelValue( 2, _("Edge Cuts") ); - m_grid->SetRowLabelValue( 3, _("Courtyards") ); - m_grid->SetRowLabelValue( 4, _("Fab Layers") ); - m_grid->SetRowLabelValue( 5, _("Other Layers") ); - m_grid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER ); + m_layerClassesGrid->EnableDragRowSize( false ); + m_layerClassesGrid->SetRowLabelSize( 125 ); + m_layerClassesGrid->SetRowLabelValue( 0, _("Silk Layers") ); + m_layerClassesGrid->SetRowLabelValue( 1, _("Copper Layers") ); + m_layerClassesGrid->SetRowLabelValue( 2, _("Edge Cuts") ); + m_layerClassesGrid->SetRowLabelValue( 3, _("Courtyards") ); + m_layerClassesGrid->SetRowLabelValue( 4, _("Fab Layers") ); + m_layerClassesGrid->SetRowLabelValue( 5, _("Other Layers") ); + m_layerClassesGrid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTER ); // Label Appearance // Cell Defaults - m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - m_grid->SetToolTip( _("Net Class parameters") ); + m_layerClassesGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + m_layerClassesGrid->SetToolTip( _("Net Class parameters") ); - defaultSizesSizer1->Add( m_grid, 1, wxBOTTOM|wxLEFT, 20 ); + defaultPropertiesSizer->Add( m_layerClassesGrid, 1, wxBOTTOM|wxLEFT, 20 ); - bSizerMargins->Add( defaultSizesSizer1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizerMargins->Add( defaultPropertiesSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( bSizerMargins, 1, wxRIGHT|wxLEFT, 5 ); @@ -148,8 +155,18 @@ PANEL_MODEDIT_DEFAULTS_BASE::PANEL_MODEDIT_DEFAULTS_BASE( wxWindow* parent, wxWi this->SetSizer( bSizerMain ); this->Layout(); bSizerMain->Fit( this ); + + // Connect Events + m_textItemsGrid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_MODEDIT_DEFAULTS_BASE::OnGridSize ), NULL, this ); + m_bpAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_MODEDIT_DEFAULTS_BASE::OnAddTextItem ), NULL, this ); + m_bpDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_MODEDIT_DEFAULTS_BASE::OnDeleteTextItem ), NULL, this ); } PANEL_MODEDIT_DEFAULTS_BASE::~PANEL_MODEDIT_DEFAULTS_BASE() { + // Disconnect Events + m_textItemsGrid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_MODEDIT_DEFAULTS_BASE::OnGridSize ), NULL, this ); + m_bpAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_MODEDIT_DEFAULTS_BASE::OnAddTextItem ), NULL, this ); + m_bpDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_MODEDIT_DEFAULTS_BASE::OnDeleteTextItem ), NULL, this ); + } diff --git a/pcbnew/dialogs/panel_modedit_defaults_base.fbp b/pcbnew/dialogs/panel_modedit_defaults_base.fbp index 4186ae2f48..f93927cae3 100644 --- a/pcbnew/dialogs/panel_modedit_defaults_base.fbp +++ b/pcbnew/dialogs/panel_modedit_defaults_base.fbp @@ -95,7 +95,7 @@ 0 0 wxID_ANY - Default values for new footprints: + Default text items for new footprints: 0 0 @@ -104,7 +104,7 @@ 0 1 - m_staticText13 + defaultTextItemsLabel 1 @@ -125,26 +125,22 @@ - 25 + 20 wxEXPAND|wxLEFT - 0 - - 4 - wxBOTH - 1 - - 5 + 1 + + wxID_ANY + - defaultValuesSizer - wxFLEX_GROWMODE_SPECIFIED + sbSizerTexts + wxVERTICAL + 1 none - 0 - 5 - + 5 - wxALIGN_CENTER_VERTICAL|wxTOP - 0 - + wxALL|wxBOTTOM|wxEXPAND + 1 + 1 1 1 @@ -153,35 +149,58 @@ + 0 + 0 1 + + + wxALIGN_LEFT + + wxALIGN_TOP 0 1 + wxALIGN_CENTER + 24 + "Text Items" "Show" "Layer" + wxALIGN_CENTER + 3 + 233,60,120 1 0 Dock 0 Left + 0 + 1 + 0 + 0 + 1 1 1 + + 1 0 0 wxID_ANY - &Reference designator: - 0 + + + + 0 + 0 0 0 - + -1,140 1 - m_staticTextRef + m_textItemsGrid 1 @@ -189,473 +208,190 @@ 1 Resizable + wxALIGN_LEFT + 160 + "Reference designator" "Value" + wxALIGN_CENTER + + 2 1 - - - + -1,-1 + WX_GRID; widgets/wx_grid.h; forward_declare 0 - -1 + OnGridSize - + 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxRIGHT + wxEXPAND 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - -1,-1 - 1 - m_textCtrlRefText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Default text for reference Leave blank to use the footprint name - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "SilkScreen" "Fab. Layer" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 + - 1 - m_choiceLayerReference - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - + bButtonSize + wxHORIZONTAL + none + + 5 + wxBOTTOM|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Add Field + + 0 + + 0 + + + 0 + 30,29 + 1 + m_bpAdd + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnAddTextItem + + + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 0 + protected + 0 + + + + 5 + wxBOTTOM|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Delete Field + + 0 + + 0 + + + 0 + 30,29 + 1 + m_bpDelete + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnDeleteTextItem + + - - 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Visible" "Invisible" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_choiceVisibleReference - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - V&alue: - 0 - - 0 - - - 0 - - 1 - m_staticTextValue - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - 160,-1 - 1 - m_textCtrlValueText - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - Default text for value Leave blank to use the footprint name - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "SilkScreen" "Fab. Layer" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_choiceLayerValue - 1 - - - protected - 1 - - Resizable - 1 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Visible" "Invisible" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_choiceVisibleValue - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 0 - protected - 0 @@ -686,11 +422,11 @@ 1 1 - ,90,92,-1,70,0 + ,90,90,-1,70,0 0 0 wxID_ANY - A blank reference designator or value will use the footprint name. + Note: a blank reference designator or value will use the footprint name. 0 0 @@ -735,7 +471,7 @@ 0 - defaultSizesSizer1 + defaultPropertiesSizer wxVERTICAL none @@ -779,11 +515,11 @@ 0 1 - m_staticText1 + defaultPropertiesLabel 1 - protected + none 1 Resizable @@ -863,7 +599,7 @@ 0 -1,-1 1 - m_grid + m_layerClassesGrid 1 diff --git a/pcbnew/dialogs/panel_modedit_defaults_base.h b/pcbnew/dialogs/panel_modedit_defaults_base.h index 882a9f2292..ac4d54336a 100644 --- a/pcbnew/dialogs/panel_modedit_defaults_base.h +++ b/pcbnew/dialogs/panel_modedit_defaults_base.h @@ -18,10 +18,14 @@ class WX_GRID; #include #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -35,18 +39,18 @@ class PANEL_MODEDIT_DEFAULTS_BASE : public wxPanel private: protected: - wxStaticText* m_staticText13; - wxStaticText* m_staticTextRef; - wxTextCtrl* m_textCtrlRefText; - wxChoice* m_choiceLayerReference; - wxChoice* m_choiceVisibleReference; - wxStaticText* m_staticTextValue; - wxTextCtrl* m_textCtrlValueText; - wxChoice* m_choiceLayerValue; - wxChoice* m_choiceVisibleValue; + wxStaticText* defaultTextItemsLabel; + WX_GRID* m_textItemsGrid; + wxBitmapButton* m_bpAdd; + wxBitmapButton* m_bpDelete; wxStaticText* m_staticTextInfo; - wxStaticText* m_staticText1; - WX_GRID* m_grid; + WX_GRID* m_layerClassesGrid; + + // Virtual event handlers, overide them in your derived class + virtual void OnGridSize( wxSizeEvent& event ) { event.Skip(); } + virtual void OnAddTextItem( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDeleteTextItem( wxCommandEvent& event ) { event.Skip(); } + public: diff --git a/pcbnew/dialogs/panel_setup_feature_constraints.cpp b/pcbnew/dialogs/panel_setup_feature_constraints.cpp index 7a1d42e4e1..309fb564e3 100644 --- a/pcbnew/dialogs/panel_setup_feature_constraints.cpp +++ b/pcbnew/dialogs/panel_setup_feature_constraints.cpp @@ -123,20 +123,23 @@ bool PANEL_SETUP_FEATURE_CONSTRAINTS::Show( bool aShow ) { bool retVal = wxPanel::Show( aShow ); - // These *should* work in the constructor, and indeed they do if this panel is the - // first displayed. However, on OSX 3.0.5 (at least), if another panel is displayed - // first then the icons will be blank unless they're set here. - m_bitmapZoneFillOpt->SetBitmap( KiBitmap( show_zone_xpm ) ); - m_bitmapClearance->SetBitmap( KiBitmap( ps_diff_pair_gap_xpm ) ); - m_bitmapMinTrackWidth->SetBitmap( KiBitmap( width_track_xpm ) ); - m_bitmapMinViaDiameter->SetBitmap( KiBitmap( via_diameter_xpm ) ); - m_bitmapMinViaDrill->SetBitmap( KiBitmap( via_hole_diameter_xpm ) ); - m_bitmapMinuViaDiameter->SetBitmap( KiBitmap( via_diameter_xpm ) ); - m_bitmapMinuViaDrill->SetBitmap( KiBitmap( via_hole_diameter_xpm ) ); - m_bitmapMinHoleClearance->SetBitmap( KiBitmap( hole_to_hole_clearance_xpm ) ); - m_bitmapEdgeClearance->SetBitmap( KiBitmap( edge_to_copper_clearance_xpm ) ); - m_bitmapBlindBuried->SetBitmap( KiBitmap( via_buried_xpm ) ); - m_bitmap_uVia->SetBitmap( KiBitmap( via_microvia_xpm ) ); + if( aShow ) + { + // These *should* work in the constructor, and indeed they do if this panel is the + // first displayed. However, on OSX 3.0.5 (at least), if another panel is displayed + // first then the icons will be blank unless they're set here. + m_bitmapZoneFillOpt->SetBitmap( KiBitmap( show_zone_xpm ) ); + m_bitmapClearance->SetBitmap( KiBitmap( ps_diff_pair_gap_xpm ) ); + m_bitmapMinTrackWidth->SetBitmap( KiBitmap( width_track_xpm ) ); + m_bitmapMinViaDiameter->SetBitmap( KiBitmap( via_diameter_xpm ) ); + m_bitmapMinViaDrill->SetBitmap( KiBitmap( via_hole_diameter_xpm ) ); + m_bitmapMinuViaDiameter->SetBitmap( KiBitmap( via_diameter_xpm ) ); + m_bitmapMinuViaDrill->SetBitmap( KiBitmap( via_hole_diameter_xpm ) ); + m_bitmapMinHoleClearance->SetBitmap( KiBitmap( hole_to_hole_clearance_xpm ) ); + m_bitmapEdgeClearance->SetBitmap( KiBitmap( edge_to_copper_clearance_xpm ) ); + m_bitmapBlindBuried->SetBitmap( KiBitmap( via_buried_xpm ) ); + m_bitmap_uVia->SetBitmap( KiBitmap( via_microvia_xpm ) ); + } return retVal; } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 833e4e4fd2..225519c547 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -128,13 +128,18 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, GetGalDisplayOptions(), m_canvasType ); SetCanvas( drawPanel ); - SetBoard( new BOARD() ); - // In modedit, the default net clearance is not known. - // (it depends on the actual board) - // So we do not show the default clearance, by setting it to 0 - // The footprint or pad specific clearance will be shown + m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true ); + + // LoadSettings() *after* creating m_LayersManager, because LoadSettings() initialize + // parameters in m_LayersManager + // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew + LoadSettings( GetSettings() ); + + // In modedit, the default net clearance is not known (it depends on the actual board). + // So we do not show the default clearance, by setting it to 0. + // The footprint or pad specific clearance will be shown. GetBoard()->GetDesignSettings().GetDefault()->SetClearance( 0 ); // Don't show the default board solder mask clearance in the footprint editor. Only the @@ -145,27 +150,18 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, restoreLastFootprint(); // Ensure all layers and items are visible: - // In footprint editor, some layers have no meaning or - // cannot be used, but we show all of them, at least to be able - // to edit a bad layer + // In footprint editor, some layers have no meaning or cannot be used, but we show all of + // them, at least to be able to edit a bad layer GetBoard()->SetVisibleAlls(); - // However the "no net" mark on pads is useless, because there is - // no net in footprint editor: make it non visible + // However the "no net" mark on pads is useless, because there are no nets in footprint + // editor: make it non visible. GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false ); - m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), true ); - - // LoadSettings() *after* creating m_LayersManager, because LoadSettings() - // initialize parameters in m_LayersManager - // NOTE: KifaceSettings() will return PCBNEW_SETTINGS if we started from pcbnew - LoadSettings( GetSettings() ); - - // Must be set after calling LoadSettings() to be sure these parameters are - // non dependent on what is read in stored settings. - // Enable one internal layer, because footprints support keepout areas that - // can be on internal layers only (therefore on the first internal layer) - // This is needed to handle these keepout in internal layers only + // Must be set after calling LoadSettings() to be sure these parameters are not dependent + // on what is read in stored settings. Enable one internal layer, because footprints + // support keepout areas that can be on internal layers only (therefore on the first internal + // layer). This is needed to handle these keepout in internal layers only. GetBoard()->SetCopperLayerCount( 3 ); GetBoard()->SetEnabledLayers( GetBoard()->GetEnabledLayers().set( In1_Cu ) ); GetBoard()->SetVisibleLayers( GetBoard()->GetEnabledLayers() ); @@ -179,8 +175,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS::UNSCALED, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); - // In modedit, set the default paper size to A4: - // this should be OK for all footprint to plot/print + // In modedit, set the default paper size to A4 for plot/print SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) ); // Create the manager and dispatcher & route draw panel events to the dispatcher @@ -437,22 +432,11 @@ FOOTPRINT_EDITOR_SETTINGS* FOOTPRINT_EDIT_FRAME::GetSettings() void FOOTPRINT_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { // aCfg will be the PCBNEW_SETTINGS - auto cfg = GetSettings(); + FOOTPRINT_EDITOR_SETTINGS* cfg = GetSettings(); EDA_DRAW_FRAME::LoadSettings( cfg ); - // Ensure some params are valid - BOARD_DESIGN_SETTINGS& settings = GetDesignSettings(); - - settings = cfg->m_DesignSettings; - - // Usually, graphic items are drawn on F_SilkS or F_Fab layer - // Force these layers if not default - if( ( settings.m_RefDefaultlayer != F_SilkS ) && ( settings.m_RefDefaultlayer != F_Fab ) ) - settings.m_RefDefaultlayer = F_SilkS; - - if( ( settings.m_ValueDefaultlayer != F_SilkS ) && ( settings.m_ValueDefaultlayer != F_Fab ) ) - settings.m_ValueDefaultlayer = F_Fab; + GetDesignSettings() = cfg->m_DesignSettings; m_DisplayOptions = cfg->m_Display; m_defaultLibWidth = cfg->m_LibWidth; diff --git a/pcbnew/footprint_editor_settings.cpp b/pcbnew/footprint_editor_settings.cpp index 76c5cf82c8..5e6ad96e00 100644 --- a/pcbnew/footprint_editor_settings.cpp +++ b/pcbnew/footprint_editor_settings.cpp @@ -36,11 +36,19 @@ const int fpEditSchemaVersion = 1; FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() : - APP_SETTINGS_BASE( "fpedit", fpEditSchemaVersion ), m_DesignSettings(), m_MagneticPads(), - m_Display(), m_UserGrid(), m_PolarCoords( false ), m_Use45DegreeGraphicSegments( true ), - m_LibWidth( 250 ), m_LastImportExportPath(), m_FootprintTextShownColumns() + APP_SETTINGS_BASE( "fpedit", fpEditSchemaVersion ), + m_DesignSettings(), + m_MagneticPads(), + m_Display(), + m_UserGrid(), + m_PolarCoords( false ), + m_Use45DegreeGraphicSegments( true ), + m_LibWidth( 250 ), + m_LastImportExportPath(), + m_FootprintTextShownColumns() { - m_params.emplace_back( new PARAM( "window.lib_width", &m_LibWidth, 250 ) ); + m_params.emplace_back( new PARAM( "window.lib_width", + &m_LibWidth, 250 ) ); m_params.emplace_back( new PARAM( "system.last_import_export_path", &m_LastImportExportPath, "" ) ); @@ -57,14 +65,56 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() : m_params.emplace_back( new PARAM( "editing.use_45_degree_graphic_segments", &m_Use45DegreeGraphicSegments, false ) ); - m_params.emplace_back( new PARAM( - "pcb_display.footprint_text", &m_Display.m_DisplayModTextFill, true ) ); + m_params.emplace_back( new PARAM( "pcb_display.footprint_text", + &m_Display.m_DisplayModTextFill, true ) ); - m_params.emplace_back( new PARAM( - "pcb_display.graphic_items_fill", &m_Display.m_DisplayDrawItemsFill, true ) ); + m_params.emplace_back( new PARAM( "pcb_display.graphic_items_fill", + &m_Display.m_DisplayDrawItemsFill, true ) ); - m_params.emplace_back( - new PARAM( "pcb_display.pad_fill", &m_Display.m_DisplayPadFill, true ) ); + m_params.emplace_back( new PARAM( "pcb_display.pad_fill", + &m_Display.m_DisplayPadFill, true ) ); + + m_params.emplace_back( new PARAM_LAMBDA( + "design_settings.default_footprint_text_items", + [&] () -> nlohmann::json + { + nlohmann::json js = nlohmann::json::array(); + + for( const TEXT_ITEM_INFO& item : m_DesignSettings.m_DefaultFPTextItems ) + { + js.push_back( nlohmann::json( { item.m_Text.ToUTF8(), + item.m_Visible, + item.m_Layer } ) ); + } + + return js; + }, + [&] ( const nlohmann::json& aObj ) + { + m_DesignSettings.m_DefaultFPTextItems.clear(); + + if( !aObj.is_array() ) + return; + + for( const nlohmann::json& entry : aObj ) + { + if( entry.empty() || !entry.is_array() ) + continue; + + TEXT_ITEM_INFO textInfo( wxT( "" ), true, F_SilkS ); + + textInfo.m_Text = entry.at(0).get(); + textInfo.m_Visible = entry.at(1).get(); + textInfo.m_Layer = entry.at(2).get(); + + m_DesignSettings.m_DefaultFPTextItems.push_back( std::move( textInfo ) ); + } + }, + nlohmann::json::array( { + { "REF**", true, F_SilkS }, + { "", true, F_Fab }, + { "${REFERENCE}", true, F_Fab } + } ) ) ); m_params.emplace_back( new PARAM_SCALED( "design_settings.silk_line_width", &m_DesignSettings.m_LineThickness[ LAYER_CLASS_SILK ], @@ -158,24 +208,6 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() : m_params.emplace_back( new PARAM( "design_settings.others_text_italic", &m_DesignSettings.m_TextItalic[ LAYER_CLASS_OTHERS ], false ) ); - - m_params.emplace_back( new PARAM( "design_settings.default_ref_layer", - &m_DesignSettings.m_RefDefaultlayer, F_SilkS, F_SilkS, F_Fab ) ); - - m_params.emplace_back( new PARAM( "design_settings.default_ref_text", - &m_DesignSettings.m_RefDefaultText, "REF**" ) ); - - m_params.emplace_back( new PARAM( "design_settings.default_ref_visibility", - &m_DesignSettings.m_RefDefaultVisibility, true ) ); - - m_params.emplace_back( new PARAM( "design_settings.default_value_layer", - &m_DesignSettings.m_ValueDefaultlayer, F_SilkS, F_SilkS, F_Fab ) ); - - m_params.emplace_back( new PARAM( "design_settings.default_value_text", - &m_DesignSettings.m_ValueDefaultText, "" ) ); - - m_params.emplace_back( new PARAM( "design_settings.default_value_visibility", - &m_DesignSettings.m_ValueDefaultVisibility, true ) ); } @@ -183,61 +215,53 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) { bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); - ret &= fromLegacy( aCfg, "ModeditLibWidth", "window.lib_width" ); - ret &= fromLegacyString( aCfg, "import_last_path", "system.last_import_export_path" ); - ret &= fromLegacyString( - aCfg, "LibFootprintTextShownColumns", "window.footprint_text_shown_columns" ); + // + // NOTE: there's no value in line-wrapping these; it just makes the table unreadable. + // + ret &= fromLegacy( aCfg, "ModeditLibWidth", "window.lib_width" ); + ret &= fromLegacyString( aCfg, "import_last_path", "system.last_import_export_path" ); + ret &= fromLegacyString( aCfg, "LibFootprintTextShownColumns", "window.footprint_text_shown_columns" ); - ret &= fromLegacy( aCfg, "FpEditorMagneticPads", "editing.magnetic_pads" ); - ret &= fromLegacy( aCfg, "FpEditorDisplayPolarCoords", "editing.polar_coords" ); - ret &= fromLegacy( aCfg, - "FpEditorUse45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" ); + ret &= fromLegacy( aCfg, "FpEditorMagneticPads", "editing.magnetic_pads" ); + ret &= fromLegacy( aCfg, "FpEditorDisplayPolarCoords", "editing.polar_coords" ); + ret &= fromLegacy( aCfg, "FpEditorUse45DegreeGraphicSegments", "editing.use_45_degree_graphic_segments" ); - ret &= fromLegacy( aCfg, - "FpEditorGraphicLinesDisplayMode", "pcb_display.graphic_items_fill" ); - ret &= fromLegacy( aCfg, "FpEditorPadDisplayMode", "pcb_display.pad_fill" ); - ret &= fromLegacy( aCfg, "FpEditorTextsDisplayMode", "pcb_display.footprint_text" ); + ret &= fromLegacy( aCfg, "FpEditorGraphicLinesDisplayMode", "pcb_display.graphic_items_fill" ); + ret &= fromLegacy( aCfg, "FpEditorPadDisplayMode", "pcb_display.pad_fill" ); + ret &= fromLegacy( aCfg, "FpEditorTextsDisplayMode", "pcb_display.footprint_text" ); + + ret &= fromLegacy( aCfg, "FpEditorSilkLineWidth", "design_settings.silk_line_width" ); + ret &= fromLegacy( aCfg, "FpEditorSilkTextSizeH", "design_settings.silk_text_size_h" ); + ret &= fromLegacy( aCfg, "FpEditorSilkTextSizeV", "design_settings.silk_text_size_v" ); + ret &= fromLegacy( aCfg, "FpEditorSilkTextThickness", "design_settings.silk_text_thickness" ); + ret &= fromLegacy( aCfg, "FpEditorSilkTextItalic", "design_settings.silk_text_italic" ); + ret &= fromLegacy( aCfg, "FpEditorCopperLineWidth", "design_settings.copper_line_width" ); + ret &= fromLegacy( aCfg, "FpEditorCopperTextSizeH", "design_settings.copper_text_size_h" ); + ret &= fromLegacy( aCfg, "FpEditorCopperTextSizeV", "design_settings.copper_text_size_v" ); + ret &= fromLegacy( aCfg, "FpEditorCopperTextThickness", "design_settings.copper_text_thickness" ); + ret &= fromLegacy( aCfg, "FpEditorCopperTextItalic", "design_settings.copper_text_italic" ); + ret &= fromLegacy( aCfg, "FpEditorEdgeCutLineWidth", "design_settings.edge_line_width" ); + ret &= fromLegacy( aCfg, "FpEditorCourtyardLineWidth", "design_settings.courtyard_line_width" ); + ret &= fromLegacy( aCfg, "FpEditorOthersLineWidth", "design_settings.others_line_width" ); + ret &= fromLegacy( aCfg, "FpEditorOthersTextSizeH", "design_settings.others_text_size_h" ); + ret &= fromLegacy( aCfg, "FpEditorOthersTextSizeV", "design_settings.others_text_size_v" ); + ret &= fromLegacy( aCfg, "FpEditorOthersTextThickness", "design_settings.others_text_thickness" ); + ret &= fromLegacy( aCfg, "FpEditorOthersTextItalic", "design_settings.others_text_italic" ); + + nlohmann::json textItems = nlohmann::json::array( { + { "REF**", true, F_SilkS }, + { "", true, F_Fab } + } ); + + ( *this )[PointerFromString( "design_settings.default_footprint_text_items" )] = textItems; + + ret &= fromLegacyString( aCfg, "FpEditorRefDefaultText", "design_settings.default_footprint_text_items.0.0" ); + ret &= fromLegacy( aCfg, "FpEditorRefDefaultVisibility", "design_settings.default_footprint_text_items.0.1" ); + ret &= fromLegacy( aCfg, "FpEditorRefDefaultLayer", "design_settings.default_footprint_text_items.0.2" ); + ret &= fromLegacyString( aCfg, "FpEditorValueDefaultText", "design_settings.default_footprint_text_items.1.0" ); + ret &= fromLegacy( aCfg, "FpEditorValueDefaultVisibility", "design_settings.default_footprint_text_items.1.1" ); + ret &= fromLegacy( aCfg, "FpEditorValueDefaultLayer", "design_settings.default_footprint_text_items.1.2" ); - ret &= fromLegacy( aCfg, "FpEditorSilkLineWidth", "design_settings.silk_line_width" ); - ret &= fromLegacy( aCfg, "FpEditorSilkTextSizeH", "design_settings.silk_text_size_h" ); - ret &= fromLegacy( aCfg, "FpEditorSilkTextSizeV", "design_settings.silk_text_size_v" ); - ret &= fromLegacy( aCfg, - "FpEditorSilkTextThickness", "design_settings.silk_text_thickness" ); - ret &= fromLegacy( aCfg, "FpEditorSilkTextItalic", "design_settings.silk_text_italic" ); - ret &= fromLegacy( aCfg, - "FpEditorCopperLineWidth", "design_settings.copper_line_width" ); - ret &= fromLegacy( aCfg, - "FpEditorCopperTextSizeH", "design_settings.copper_text_size_h" ); - ret &= fromLegacy( aCfg, - "FpEditorCopperTextSizeV", "design_settings.copper_text_size_v" ); - ret &= fromLegacy( aCfg, - "FpEditorCopperTextThickness", "design_settings.copper_text_thickness" ); - ret &= fromLegacy( aCfg, - "FpEditorCopperTextItalic", "design_settings.copper_text_italic" ); - ret &= fromLegacy( aCfg, - "FpEditorEdgeCutLineWidth", "design_settings.edge_line_width" ); - ret &= fromLegacy( aCfg, - "FpEditorCourtyardLineWidth", "design_settings.courtyard_line_width" ); - ret &= fromLegacy( aCfg, - "FpEditorOthersLineWidth", "design_settings.others_line_width" ); - ret &= fromLegacy( aCfg, - "FpEditorOthersTextSizeH", "design_settings.others_text_size_h" ); - ret &= fromLegacy( aCfg, - "FpEditorOthersTextSizeV", "design_settings.others_text_size_v" ); - ret &= fromLegacy( aCfg, - "FpEditorOthersTextSizeThickness", "design_settings.others_text_thickness" ); - ret &= fromLegacy( aCfg, - "FpEditorOthersTextItalic", "design_settings.others_text_italic" ); - ret &= fromLegacy( aCfg, "FpEditorRefDefaultLayer", "design_settings.default_ref_layer" ); - ret &= fromLegacyString( aCfg, "FpEditorRefDefaultText", "design_settings.default_ref_text" ); - ret &= fromLegacy( aCfg, - "FpEditorRefDefaultVisibility", "design_settings.default_ref_visibility" ); - ret &= fromLegacy( aCfg, - "FpEditorValueDefaultLayer", "design_settings.default_value_layer" ); - ret &= fromLegacyString( aCfg, - "FpEditorValueDefaultText", "design_settings.default_value_text" ); - ret &= fromLegacy( aCfg, - "FpEditorValueDefaultVisibility", "design_settings.default_value_visibility" ); const std::string f = "ModEdit"; @@ -250,12 +274,13 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) cs->SetName( wxT( "KiCad Default (Footprints)" ) ); manager.Save( cs ); - auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) { - wxString str; + auto migrateLegacyColor = [&] ( const std::string& aKey, int aLayerId ) + { + wxString str; - if( aCfg->Read( aKey, &str ) ) - cs->SetColor( aLayerId, COLOR4D( str ) ); - }; + if( aCfg->Read( aKey, &str ) ) + cs->SetColor( aLayerId, COLOR4D( str ) ); + }; for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i ) { diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index aa17452dce..aa55c7dc4c 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -51,22 +51,6 @@ // unique, "file local" translations: -#define FMT_OK_DELETE _( "OK to delete footprint \"%s\" in library \"%s\"" ) -#define FMT_IMPORT_MODULE _( "Import Footprint" ) -#define FMT_FILE_NOT_FOUND _( "File \"%s\" not found" ) -#define FMT_NOT_MODULE _( "Not a footprint file" ) -#define FMT_MOD_NOT_FOUND _( "Unable to find or load footprint \"%s\" from lib path \"%s\"" ) -#define FMT_LIB_READ_ONLY _( "Library \"%s\" is read only, not writable" ) - -#define FMT_EXPORT_MODULE _( "Export Footprint" ) -#define FMT_SAVE_MODULE _( "Save Footprint" ) -#define FMT_MOD_REF _( "Enter footprint name:" ) -#define FMT_EXPORTED _( "Footprint exported to file \"%s\"" ) -#define FMT_MOD_DELETED _( "Footprint \"%s\" deleted from library \"%s\"" ) -#define FMT_MOD_CREATE _( "New Footprint" ) - -#define FMT_NO_REF_ABORTED _( "No footprint name defined." ) -#define FMT_SELECT_LIB _( "Select Library" ) static const wxString INFO_LEGACY_LIB_WARN_EDIT( _( "Writing/modifying legacy libraries (.mod files) is not allowed\n"\ @@ -96,7 +80,7 @@ static wxFileName getFootprintFilenameFromUser( wxWindow* aParent, const wxStrin << GedaPcbFootprintLibFileWildcard() << wxChar( '|' ) << AllFilesWildcard(); - wxFileDialog dlg( aParent, FMT_IMPORT_MODULE, aLastPath, wxEmptyString, wildCard, + wxFileDialog dlg( aParent, _( "Import Footprint" ), aLastPath, wxEmptyString, wildCard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); dlg.SetFilterIndex( lastFilterIndex ); @@ -262,23 +246,23 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module( const wxString& aName ) if( !fp ) { - wxString msg = wxString::Format( FMT_FILE_NOT_FOUND, GetChars( fn.GetFullPath() ) ); + wxString msg = wxString::Format( _( "File \"%s\" not found" ), fn.GetFullPath() ); DisplayError( this, msg ); return NULL; } cfg->m_LastImportExportPath = lastOpenedPathForLoading; - wxString moduleName; + wxString moduleName; IO_MGR::PCB_FILE_T fileType = detect_file_type( fp, fn.GetFullPath(), &moduleName ); if( fileType == IO_MGR::FILE_TYPE_NONE ) { - DisplayError( this, FMT_NOT_MODULE ); + DisplayError( this, _( "Not a footprint file" ) ); return NULL; } - MODULE* module = NULL; + MODULE* module = NULL; try { @@ -286,8 +270,9 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module( const wxString& aName ) if( !module ) { - wxString msg = wxString::Format( - FMT_MOD_NOT_FOUND, GetChars( moduleName ), GetChars( fn.GetFullPath() ) ); + wxString msg = wxString::Format( _( "Unable to load footprint '%s' from '%s'" ), + moduleName, + fn.GetFullPath() ); DisplayError( this, msg ); return NULL; } @@ -342,7 +327,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) else fn.SetPath( m_mruPath ); - wxFileDialog dlg( this, FMT_EXPORT_MODULE, fn.GetPath(), fn.GetFullName(), + wxFileDialog dlg( this, _( "Export Footprint" ), fn.GetPath(), fn.GetFullName(), wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) @@ -385,7 +370,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) return; } - wxString msg = wxString::Format( FMT_EXPORTED, GetChars( dlg.GetPath() ) ); + wxString msg = wxString::Format( _( "Footprint exported to file \"%s\"" ), dlg.GetPath() ); DisplayInfoMessage( this, msg ); } @@ -449,7 +434,8 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName ) { if( !writable ) { - wxString msg = wxString::Format( FMT_LIB_READ_ONLY, libPath ); + wxString msg = wxString::Format( _( "Library \"%s\" is read only, not writable" ), + libPath ); DisplayError( this, msg ); return wxEmptyString; } @@ -585,13 +571,15 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aC if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) ) { - wxString msg = wxString::Format( _( "Library \"%s\" is read only" ), nickname ); + wxString msg = wxString::Format( _( "Library '%s' is read only" ), nickname ); DisplayError( this, msg ); return false; } // Confirmation - wxString msg = wxString::Format( FMT_OK_DELETE, fpname.GetData(), nickname.GetData() ); + wxString msg = wxString::Format( _( "Delete footprint '%s' from library '%s'?" ), + fpname.GetData(), + nickname.GetData() ); if( aConfirm && !IsOK( this, msg ) ) return false; @@ -606,7 +594,9 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aC return false; } - msg.Printf( FMT_MOD_DELETED, fpname.GetData(), nickname.GetData() ); + msg.Printf( _( "Footprint '%s' deleted from library '%s'" ), + fpname.GetData(), + nickname.GetData() ); SetStatusText( msg ); @@ -880,7 +870,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aModule ) itemsToDisplay.push_back( item ); } - EDA_LIST_DIALOG dlg( this, FMT_SAVE_MODULE, headers, itemsToDisplay, libraryName ); + EDA_LIST_DIALOG dlg( this, _( "Save Footprint" ), headers, itemsToDisplay, libraryName ); dlg.SetListLabel( _( "Save in library:" ) ); dlg.SetOKLabel( _( "Save" ) ); @@ -1011,19 +1001,13 @@ bool FOOTPRINT_EDIT_FRAME::RevertFootprint() MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) { - // Creates a new footprint at position 0,0 which contains the minimal items: - // the reference and the value. - // Value : initialized to the footprint name. - // put on fab layer (front side) - // Reference : initialized to a default value (REF**). - // put on silkscreen layer (front side) - wxString moduleName = aModuleName; // Ask for the new module name if( moduleName.IsEmpty() ) { - WX_TEXT_ENTRY_DIALOG dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName ); + WX_TEXT_ENTRY_DIALOG dlg( this, _( "Enter footprint name:" ), _( "New Footprint" ), + moduleName ); dlg.SetTextValidator( MODULE_NAME_CHAR_VALIDATOR( &moduleName ) ); if( dlg.ShowModal() != wxID_OK ) @@ -1035,7 +1019,7 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) if( moduleName.IsEmpty() ) { - DisplayInfoMessage( this, FMT_NO_REF_ABORTED ); + DisplayInfoMessage( this, _( "No footprint name defined." ) ); return NULL; } @@ -1048,40 +1032,59 @@ MODULE* PCB_BASE_FRAME::CreateNewModule( const wxString& aModuleName ) // Update its name in lib module->SetFPID( LIB_ID( wxEmptyString, moduleName ) ); + PCB_LAYER_ID layer; wxPoint default_pos; BOARD_DESIGN_SETTINGS& settings = GetDesignSettings(); - // Update reference: - if( settings.m_RefDefaultText.empty() ) - module->SetReference( moduleName ); - else - module->SetReference( settings.m_RefDefaultText ); - - PCB_LAYER_ID layer = ToLAYER_ID( settings.m_RefDefaultlayer ); - module->Reference().SetTextThickness( settings.GetTextThickness( layer )); - module->Reference().SetTextSize( settings.GetTextSize( layer ) ); - module->Reference().SetItalic( settings.GetTextItalic( layer ) ); - module->Reference().SetKeepUpright( settings.GetTextUpright( layer ) ); - default_pos.y = GetDesignSettings().GetTextSize( layer ).y / 2; - module->Reference().SetPosition( default_pos ); + module->Reference().SetText( settings.m_DefaultFPTextItems[0].m_Text ); + module->Reference().SetVisible( settings.m_DefaultFPTextItems[0].m_Visible ); + layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[0].m_Layer; module->Reference().SetLayer( layer ); - module->Reference().SetVisible( settings.m_RefDefaultVisibility ); + default_pos.y -= settings.GetTextSize( layer ).y / 2; + module->Reference().SetPosition( default_pos ); + default_pos.y += settings.GetTextSize( layer ).y; - // Set the value field to a default value - if( settings.m_ValueDefaultText.empty() ) - module->SetValue( moduleName ); - else - module->SetValue( settings.m_ValueDefaultText ); - - layer = ToLAYER_ID( settings.m_ValueDefaultlayer ); - module->Value().SetTextThickness( settings.GetTextThickness( layer )); - module->Value().SetTextSize( settings.GetTextSize( layer ) ); - module->Value().SetItalic( settings.GetTextItalic( layer ) ); - module->Value().SetKeepUpright( settings.GetTextUpright( layer ) ); - default_pos.y = -default_pos.y; - module->Value().SetPosition( default_pos ); + module->Value().SetText( settings.m_DefaultFPTextItems[1].m_Text ); + module->Value().SetVisible( settings.m_DefaultFPTextItems[1].m_Visible ); + layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[1].m_Layer; module->Value().SetLayer( layer ); - module->Value().SetVisible( settings.m_ValueDefaultVisibility ); + default_pos.y += settings.GetTextSize( layer ).y / 2; + module->Value().SetPosition( default_pos ); + default_pos.y += settings.GetTextSize( layer ).y; + + for( int i = 2; i < settings.m_DefaultFPTextItems.size(); ++i ) + { + TEXTE_MODULE* textItem = new TEXTE_MODULE( module ); + textItem->SetText( settings.m_DefaultFPTextItems[i].m_Text ); + textItem->SetVisible( settings.m_DefaultFPTextItems[i].m_Visible ); + layer = (PCB_LAYER_ID) settings.m_DefaultFPTextItems[i].m_Layer; + textItem->SetLayer( layer ); + default_pos.y += settings.GetTextSize( layer ).y / 2; + textItem->SetPosition( default_pos ); + default_pos.y += settings.GetTextSize( layer ).y; + module->GraphicalItems().push_back( textItem ); + } + + if( module->GetReference().IsEmpty() ) + module->SetReference( moduleName ); + + if( module->GetValue().IsEmpty() ) + module->SetValue( moduleName ); + + module->RunOnChildren( + [&] ( BOARD_ITEM* aChild ) + { + if( aChild->Type() == PCB_MODULE_TEXT_T ) + { + TEXTE_MODULE* textItem = static_cast( aChild ); + PCB_LAYER_ID layer = textItem->GetLayer(); + + textItem->SetTextThickness( settings.GetTextThickness( layer ) ); + textItem->SetTextSize( settings.GetTextSize( layer ) ); + textItem->SetItalic( settings.GetTextItalic( layer ) ); + textItem->SetKeepUpright( settings.GetTextUpright( layer ) ); + } + } ); SetMsgPanel( module ); return module; @@ -1100,24 +1103,20 @@ wxString PCB_BASE_FRAME::SelectLibrary( const wxString& aNicknameExisting ) std::vector< wxArrayString > itemsToDisplay; std::vector< wxString > nicknames = fptbl->GetLogicalLibs(); - for( unsigned i = 0; i < nicknames.size(); i++ ) + for( const wxString& nickname : nicknames ) { wxArrayString item; - item.Add( nicknames[i] ); - item.Add( fptbl->GetDescription( nicknames[i] ) ); + item.Add( nickname ); + item.Add( fptbl->GetDescription( nickname ) ); itemsToDisplay.push_back( item ); } - EDA_LIST_DIALOG dlg( this, FMT_SELECT_LIB, headers, itemsToDisplay, aNicknameExisting ); + EDA_LIST_DIALOG dlg( this, _( "Select Library" ), headers, itemsToDisplay, aNicknameExisting ); if( dlg.ShowModal() != wxID_OK ) return wxEmptyString; - wxString nickname = dlg.GetTextSelection(); - - wxLogDebug( wxT( "Chose footprint library \"%s\"." ), GetChars( nickname ) ); - - return nickname; + return dlg.GetTextSelection(); } diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index 651c36bd03..0786fc8b5f 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -352,22 +352,25 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() : APP_SETTINGS_BASE( "pcbnew", pcbnewSchemaVe m_params.emplace_back( new PARAM( "window.footprint_text_shown_columns", &m_FootprintTextShownColumns, "0 1 2 3 4 5 6" ) ); - m_params.emplace_back( - new PARAM( "footprint_wizard_list.width", &m_FootprintWizardList.width, -1 ) ); + m_params.emplace_back( new PARAM( "footprint_wizard_list.width", + &m_FootprintWizardList.width, -1 ) ); - m_params.emplace_back( - new PARAM( "footprint_wizard_list.height", &m_FootprintWizardList.height, -1 ) ); + m_params.emplace_back( new PARAM( "footprint_wizard_list.height", + &m_FootprintWizardList.height, -1 ) ); #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) - m_params.emplace_back( - new PARAM_LAMBDA( "action_plugins", [&]() -> nlohmann::json { + m_params.emplace_back( new PARAM_LAMBDA( "action_plugins", + [&]() -> nlohmann::json + { nlohmann::json js = nlohmann::json::array(); for( const auto& pair : m_VisibleActionPlugins ) js.push_back( nlohmann::json( { { pair.first.ToUTF8(), pair.second } } ) ); return js; - }, [&]( const nlohmann::json& aObj ) { + }, + [&]( const nlohmann::json& aObj ) + { m_VisibleActionPlugins.clear(); if( !aObj.is_array() ) @@ -386,7 +389,8 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() : APP_SETTINGS_BASE( "pcbnew", pcbnewSchemaVe wxString( pair.key().c_str(), wxConvUTF8 ), pair.value() ) ); } } - }, nlohmann::json::array() ) ); + }, + nlohmann::json::array() ) ); #endif addParamsForWindow( &m_FootprintViewer, "footprint_viewer" ); @@ -404,6 +408,9 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) const std::string f = getLegacyFrameName(); + // + // NOTE: there's no value in line-wrapping these; it just makes the table unreadable. + // ret &= fromLegacy( aCfg, "ShowLayerManagerTools", "aui.show_layer_manager" ); ret &= fromLegacy( aCfg, "ShowMicrowaveTools", "aui.show_microwave_tools" ); @@ -447,11 +454,11 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ret &= fromLegacy( aCfg, "PlotLineWidth_mm", "plot.line_width" ); aCfg->SetPath( "/dialogs/cleanup_tracks" ); - ret &= fromLegacy( aCfg, "DialogCleanupVias", "cleanup.cleanup_vias" ); + ret &= fromLegacy( aCfg, "DialogCleanupVias", "cleanup.cleanup_vias" ); ret &= fromLegacy( aCfg, "DialogCleanupMergeSegments", "cleanup.merge_segments" ); - ret &= fromLegacy( aCfg, "DialogCleanupUnconnected", "cleanup.cleanup_unconnected" ); - ret &= fromLegacy( aCfg, "DialogCleanupShortCircuit", "cleanup.cleanup_short_circuits" ); - ret &= fromLegacy( aCfg, "DialogCleanupTracksInPads", "cleanup.cleanup_tracks_in_pad" ); + ret &= fromLegacy( aCfg, "DialogCleanupUnconnected", "cleanup.cleanup_unconnected" ); + ret &= fromLegacy( aCfg, "DialogCleanupShortCircuit", "cleanup.cleanup_short_circuits" ); + ret &= fromLegacy( aCfg, "DialogCleanupTracksInPads", "cleanup.cleanup_tracks_in_pad" ); aCfg->SetPath( "../.." ); ret &= fromLegacy( aCfg, "RefillZonesBeforeDrc", "drc_dialog.refill_zones" ); @@ -533,6 +540,9 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ( *this )[PointerFromString( "action_plugins" ) ] = js; } + // + // NOTE: there's no value in line-wrapping these; it just makes the table unreadable. + // ret &= fromLegacy( aCfg, "VrmlExportUnit", "export_vrml.units" ); ret &= fromLegacy( aCfg, "VrmlExportCopyFiles", "export_vrml.copy_3d_models" ); ret &= fromLegacy( aCfg, "VrmlUseRelativePaths", "export_vrml.use_relative_paths" ); @@ -550,42 +560,38 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) ret &= fromLegacy( aCfg, "Zone_TH_Copper_Width", "zones.thermal_relief_copper_width" ); aCfg->SetPath( "ImportGraphics" ); - ret &= fromLegacy( aCfg, "BoardLayer", "import_graphics.layer" ); - ret &= fromLegacy( - aCfg, "InteractivePlacement", "import_graphics.interactive_placement" ); - ret &= fromLegacyString( aCfg, "LastFile", "import_graphics.last_file" ); - ret &= fromLegacy( aCfg, "LineWidth", "import_graphics.line_width" ); - ret &= fromLegacy( aCfg, "LineWidthUnits", "import_graphics.line_width_units" ); - ret &= fromLegacy( aCfg, "PositionUnits", "import_graphics.origin_units" ); - ret &= fromLegacy( aCfg, "PositionX", "import_graphics.origin_x" ); - ret &= fromLegacy( aCfg, "PositionY", "import_graphics.origin_y" ); + ret &= fromLegacy( aCfg, "BoardLayer", "import_graphics.layer" ); + ret &= fromLegacy( aCfg, "InteractivePlacement", "import_graphics.interactive_placement" ); + ret &= fromLegacyString( aCfg, "LastFile", "import_graphics.last_file" ); + ret &= fromLegacy( aCfg, "LineWidth", "import_graphics.line_width" ); + ret &= fromLegacy( aCfg, "LineWidthUnits", "import_graphics.line_width_units" ); + ret &= fromLegacy( aCfg, "PositionUnits", "import_graphics.origin_units" ); + ret &= fromLegacy( aCfg, "PositionX", "import_graphics.origin_x" ); + ret &= fromLegacy( aCfg, "PositionY", "import_graphics.origin_y" ); aCfg->SetPath( ".." ); - ret &= fromLegacy( aCfg, "NetlistReportFilterMsg", "netlist.report_filter" ); - ret &= fromLegacy( aCfg, "NetlistUpdateFootprints", "netlist.update_footprints" ); - ret &= fromLegacy( aCfg, - "NetlistDeleteShortingTracks", "netlist.delete_shorting_tracks" ); - ret &= fromLegacy( aCfg, - "NetlistDeleteExtraFootprints", "netlist.delete_extra_footprints" ); - ret &= fromLegacy( aCfg, "NetlistDeleteSinglePadNets", "netlist.delete_single_pad_nets" ); + ret &= fromLegacy( aCfg, "NetlistReportFilterMsg", "netlist.report_filter" ); + ret &= fromLegacy( aCfg, "NetlistUpdateFootprints", "netlist.update_footprints" ); + ret &= fromLegacy( aCfg, "NetlistDeleteShortingTracks", "netlist.delete_shorting_tracks" ); + ret &= fromLegacy( aCfg, "NetlistDeleteExtraFootprints", "netlist.delete_extra_footprints" ); + ret &= fromLegacy( aCfg, "NetlistDeleteSinglePadNets", "netlist.delete_single_pad_nets" ); ret &= fromLegacy( aCfg, "PlaceFileUnits", "place_file.units" ); ret &= fromLegacy( aCfg, "PlaceFileOpts", "place_file.file_options" ); ret &= fromLegacy( aCfg, "PlaceFileFormat", "place_file.file_format" ); ret &= fromLegacy( aCfg, "PlaceFileIncludeBrdEdge", "place_file.include_board_edge" ); - ret &= fromLegacy( aCfg, "PrintSinglePage", "plot.one_page_per_layer" ); - ret &= fromLegacy( aCfg, "PrintPadsDrillOpt", "plot.pads_drill_mode" ); - ret &= fromLegacy( aCfg, "PlotXFineScaleAdj", "plot.fine_scale_x" ); - ret &= fromLegacy( aCfg, "PlotYFineScaleAdj", "plot.fine_scale_y" ); - ret &= fromLegacy( aCfg, "PSPlotFineWidthAdj", "plot.ps_fine_width_adjust" ); - ret &= fromLegacy( aCfg, "CheckZonesBeforePlotting", "plot.check_zones_before_plotting" ); + ret &= fromLegacy( aCfg, "PrintSinglePage", "plot.one_page_per_layer" ); + ret &= fromLegacy( aCfg, "PrintPadsDrillOpt", "plot.pads_drill_mode" ); + ret &= fromLegacy( aCfg, "PlotXFineScaleAdj", "plot.fine_scale_x" ); + ret &= fromLegacy( aCfg, "PlotYFineScaleAdj", "plot.fine_scale_y" ); + ret &= fromLegacy( aCfg, "PSPlotFineWidthAdj", "plot.ps_fine_width_adjust" ); + ret &= fromLegacy( aCfg, "CheckZonesBeforePlotting", "plot.check_zones_before_plotting" ); - ret &= fromLegacyString( aCfg, - "FootprintTextShownColumns", "window.footprint_text_shown_columns" ); + ret &= fromLegacyString( aCfg, "FootprintTextShownColumns", "window.footprint_text_shown_columns" ); - ret &= fromLegacy( aCfg, "FpWizardListWidth", "footprint_wizard_list.width" ); - ret &= fromLegacy( aCfg, "FpWizardListHeight", "footprint_wizard_list.height" ); + ret &= fromLegacy( aCfg, "FpWizardListWidth", "footprint_wizard_list.width" ); + ret &= fromLegacy( aCfg, "FpWizardListHeight", "footprint_wizard_list.height" ); migrateWindowConfig( aCfg, "ModViewFrame", "footprint_viewer" ); @@ -595,10 +601,10 @@ bool PCBNEW_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) const std::string p = "pcbnew.InteractiveRouter."; - ( *this )[PointerFromString( "tools.pns.meta" ) ] = nlohmann::json( { - { "filename", "pns" }, - { "version", 0 } - } ); + ( *this )[PointerFromString( "tools.pns.meta" )] = nlohmann::json( { + { "filename", "pns" }, + { "version", 0 } + } ); ret &= fromLegacy( aCfg, p + "Mode", "tools.pns.mode" ); ret &= fromLegacy( aCfg, p + "OptimizerEffort", "tools.pns.effort" ); diff --git a/pcbnew/router/pns_routing_settings.cpp b/pcbnew/router/pns_routing_settings.cpp index fc041ca437..dcf2b15bce 100644 --- a/pcbnew/router/pns_routing_settings.cpp +++ b/pcbnew/router/pns_routing_settings.cpp @@ -69,25 +69,28 @@ ROUTING_SETTINGS::ROUTING_SETTINGS( JSON_SETTINGS* aParent, const std::string& a m_params.emplace_back( new PARAM( "start_diagonal", &m_startDiagonal, false ) ); m_params.emplace_back( new PARAM( "shove_iteration_limit", &m_shoveIterationLimit, 250 ) ); - m_params.emplace_back( new PARAM_LAMBDA( "shove_time_limit", [this] () -> int { + m_params.emplace_back( new PARAM_LAMBDA( "shove_time_limit", + [this] () -> int + { return m_shoveTimeLimit.Get(); - }, [this] ( int aVal ) { + }, + [this] ( int aVal ) + { m_shoveTimeLimit.Set( aVal ); - }, 1000 ) ); + }, + 1000 ) ); - m_params.emplace_back( - new PARAM( "walkaround_iteration_limit", &m_walkaroundIterationLimit, 40 ) ); - m_params.emplace_back( new PARAM( "jump_over_obstacles", &m_jumpOverObstacles, false ) ); + m_params.emplace_back( new PARAM( "walkaround_iteration_limit", &m_walkaroundIterationLimit, 40 ) ); + m_params.emplace_back( new PARAM( "jump_over_obstacles", &m_jumpOverObstacles, false ) ); - m_params.emplace_back( - new PARAM( "smooth_dragged_segments", &m_smoothDraggedSegments, true ) ); + m_params.emplace_back( new PARAM( "smooth_dragged_segments", &m_smoothDraggedSegments, true ) ); m_params.emplace_back( new PARAM( "can_violate_drc", &m_canViolateDRC, false ) ); m_params.emplace_back( new PARAM( "free_angle_mode", &m_freeAngleMode, false ) ); m_params.emplace_back( new PARAM( "inline_drag", &m_inlineDragEnabled, false ) ); m_params.emplace_back( new PARAM( "snap_to_tracks", &m_snapToTracks, false ) ); m_params.emplace_back( new PARAM( "snap_to_pads", &m_snapToPads, false ) ); - m_params.emplace_back( new PARAM( "optimize_dragged_track", &m_optimizeDraggedTrack, true ) ); + m_params.emplace_back( new PARAM( "optimize_dragged_track", &m_optimizeDraggedTrack, true ) ); m_params.emplace_back( new PARAM( "min_radius", &m_minRadius, 0 ) ); m_params.emplace_back( new PARAM( "max_radius", &m_maxRadius, 1000000 ) ); diff --git a/pcbnew/text_mod_grid_table.cpp b/pcbnew/text_mod_grid_table.cpp index 5c0c7db777..bd644a6308 100644 --- a/pcbnew/text_mod_grid_table.cpp +++ b/pcbnew/text_mod_grid_table.cpp @@ -105,7 +105,7 @@ wxString TEXT_MOD_GRID_TABLE::GetRowLabelValue( int aRow ) { switch( aRow ) { - case 0: return _( "Reference" ); + case 0: return _( "Reference designator" ); case 1: return _( "Value" ); default: return wxEmptyString; } @@ -201,8 +201,8 @@ wxString TEXT_MOD_GRID_TABLE::GetValue( int aRow, int aCol ) return text.GetLayerName(); case TMC_ORIENTATION: - return StringFromValue( - EDA_UNITS::DEGREES, (int) NormalizeAnglePos( text.GetTextAngle() ), true ); + return StringFromValue( EDA_UNITS::DEGREES, (int) NormalizeAnglePos( text.GetTextAngle() ), + true ); case TMC_XOFFSET: return StringFromValue( m_userUnits, text.GetPos0().x, true );