2012-08-21 12:45:54 +02:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-14 14:24:58 +01:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2015-02-02 17:43:34 +01:00
|
|
|
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
|
2017-12-27 12:43:26 -05:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2012-08-21 12:45:54 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2025-01-26 16:51:47 -08:00
|
|
|
#include <3d_rendering/opengl/3d_model.h>
|
2021-08-05 13:03:59 +01:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2017-02-20 20:20:39 +08:00
|
|
|
#include <bitmaps.h>
|
2025-01-26 16:51:47 -08:00
|
|
|
#include <board_commit.h>
|
|
|
|
#include <board_design_settings.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <dialog_footprint_properties_fp_editor.h>
|
|
|
|
#include <dialogs/dialog_text_entry.h>
|
|
|
|
#include <dialogs/panel_preview_3d_model.h>
|
|
|
|
#include <embedded_files.h>
|
|
|
|
#include <filename_resolver.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2018-01-29 21:58:58 +01:00
|
|
|
#include <footprint_edit_frame.h>
|
2020-01-12 20:44:19 -05:00
|
|
|
#include <footprint_editor_settings.h>
|
2025-01-26 16:51:47 -08:00
|
|
|
#include <grid_layer_box_helpers.h>
|
|
|
|
#include <kiplatform/ui.h>
|
|
|
|
#include <panel_embedded_files.h>
|
2021-07-28 20:22:57 +01:00
|
|
|
#include <panel_fp_properties_3d_model.h>
|
2016-04-17 18:35:32 -04:00
|
|
|
#include <pgm_base.h>
|
2020-09-01 02:00:38 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-11-17 20:47:50 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2025-02-08 13:45:57 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2025-01-26 16:51:47 -08:00
|
|
|
#include <validators.h>
|
|
|
|
#include <widgets/grid_text_button_helpers.h>
|
|
|
|
#include <widgets/std_bitmap_button.h>
|
|
|
|
#include <widgets/text_ctrl_eval.h>
|
|
|
|
#include <widgets/wx_grid.h>
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
#include <fp_lib_table.h>
|
2025-02-16 12:41:31 +00:00
|
|
|
#include <project_pcb.h>
|
|
|
|
#include <kidialog.h>
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
PRIVATE_LAYERS_GRID_TABLE::PRIVATE_LAYERS_GRID_TABLE( PCB_BASE_FRAME* aFrame ) :
|
|
|
|
m_frame( aFrame )
|
|
|
|
{
|
|
|
|
m_layerColAttr = new wxGridCellAttr;
|
|
|
|
m_layerColAttr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) );
|
|
|
|
|
|
|
|
LSET forbiddenLayers = LSET::AllCuMask() | LSET::AllTechMask();
|
2022-04-27 17:13:50 +01:00
|
|
|
forbiddenLayers.set( Edge_Cuts );
|
|
|
|
forbiddenLayers.set( Margin );
|
2025-03-05 16:39:04 +00:00
|
|
|
m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, forbiddenLayers, true ) );
|
2021-12-05 21:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRIVATE_LAYERS_GRID_TABLE::~PRIVATE_LAYERS_GRID_TABLE()
|
|
|
|
{
|
|
|
|
m_layerColAttr->DecRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PRIVATE_LAYERS_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
|
|
|
|
{
|
|
|
|
return aTypeName == wxGRID_VALUE_NUMBER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PRIVATE_LAYERS_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
|
|
|
|
{
|
|
|
|
return aTypeName == wxGRID_VALUE_NUMBER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxGridCellAttr* PRIVATE_LAYERS_GRID_TABLE::GetAttr( int aRow, int aCol,
|
2024-05-16 15:50:57 +01:00
|
|
|
wxGridCellAttr::wxAttrKind aKind )
|
2021-12-05 21:56:55 +00:00
|
|
|
{
|
|
|
|
m_layerColAttr->IncRef();
|
2024-05-16 15:50:57 +01:00
|
|
|
return enhanceAttr( m_layerColAttr, aRow, aCol, aKind );
|
2021-12-05 21:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString PRIVATE_LAYERS_GRID_TABLE::GetValue( int aRow, int aCol )
|
|
|
|
{
|
|
|
|
return m_frame->GetBoard()->GetLayerName( this->at( (size_t) aRow ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long PRIVATE_LAYERS_GRID_TABLE::GetValueAsLong( int aRow, int aCol )
|
|
|
|
{
|
|
|
|
return this->at( (size_t) aRow );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PRIVATE_LAYERS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PRIVATE_LAYERS_GRID_TABLE::SetValueAsLong( int aRow, int aCol, long aValue )
|
|
|
|
{
|
|
|
|
this->at( (size_t) aRow ) = ToLAYER_ID( (int) aValue );
|
|
|
|
}
|
|
|
|
|
2018-01-14 14:24:58 +01:00
|
|
|
|
2021-07-19 19:56:05 -04:00
|
|
|
// Remember the last open page during session.
|
2015-02-02 17:43:34 +01:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
NOTEBOOK_PAGES DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::m_page = NOTEBOOK_PAGES::PAGE_GENERAL;
|
|
|
|
|
2011-03-14 11:17:18 -04:00
|
|
|
|
2021-07-19 19:56:05 -04:00
|
|
|
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(
|
2024-07-20 23:16:32 +01:00
|
|
|
FOOTPRINT_EDIT_FRAME* aParent,
|
|
|
|
FOOTPRINT* aFootprint ) :
|
|
|
|
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
|
|
|
m_footprint( aFootprint ),
|
2024-08-08 10:24:17 +01:00
|
|
|
m_initialized( false ),
|
2024-07-20 23:16:32 +01:00
|
|
|
m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ),
|
|
|
|
m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl,
|
|
|
|
m_SolderMaskMarginUnits ),
|
|
|
|
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl,
|
|
|
|
m_SolderPasteMarginUnits ),
|
|
|
|
m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl,
|
|
|
|
m_PasteMarginRatioUnits ),
|
|
|
|
m_gridSize( 0, 0 ),
|
|
|
|
m_lastRequestedSize( 0, 0 )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2022-11-29 19:35:59 -08:00
|
|
|
SetEvtHandlerEnabled( false );
|
2025-01-26 16:51:47 -08:00
|
|
|
|
|
|
|
// Create the extra panels.
|
|
|
|
m_embeddedFiles = new PANEL_EMBEDDED_FILES( m_NoteBook, m_footprint );
|
|
|
|
m_3dPanel = new PANEL_FP_PROPERTIES_3D_MODEL( m_frame, m_footprint, this, m_embeddedFiles, m_NoteBook );
|
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
m_NoteBook->AddPage( m_3dPanel, _("3D Models"), false );
|
2025-01-26 16:51:47 -08:00
|
|
|
m_NoteBook->AddPage( m_embeddedFiles, _( "Embedded Files" ) );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2025-04-23 15:11:13 +01:00
|
|
|
m_fields = new PCB_FIELDS_GRID_TABLE( m_frame, this, { m_embeddedFiles->GetLocalFiles() } );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayers = new PRIVATE_LAYERS_GRID_TABLE( m_frame );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
|
|
|
m_delayedErrorMessage = wxEmptyString;
|
2018-09-13 16:39:14 +01:00
|
|
|
m_delayedFocusCtrl = nullptr;
|
2018-03-28 18:14:04 +01:00
|
|
|
m_delayedFocusGrid = nullptr;
|
|
|
|
m_delayedFocusRow = -1;
|
|
|
|
m_delayedFocusColumn = -1;
|
2021-07-28 20:22:57 +01:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_UNKNOWN;
|
2011-09-11 13:38:01 +02:00
|
|
|
|
|
|
|
// Give an icon
|
2021-07-28 20:54:20 +01:00
|
|
|
wxIcon icon;
|
2021-03-07 21:59:07 -05:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
|
2011-09-11 13:38:01 +02:00
|
|
|
SetIcon( icon );
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Give a bit more room for combobox editors
|
|
|
|
m_itemsGrid->SetDefaultRowSize( m_itemsGrid->GetDefaultRowSize() + 4 );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->SetDefaultRowSize( m_privateLayersGrid->GetDefaultRowSize() + 4 );
|
2016-08-05 21:30:23 +02:00
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
m_itemsGrid->SetTable( m_fields );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->SetTable( m_privateLayers );
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) );
|
2022-09-09 12:18:05 +01:00
|
|
|
m_privateLayersGrid->PushEventHandler( new GRID_TRICKS( m_privateLayersGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddLayer( aEvent );
|
|
|
|
} ) );
|
2025-05-30 17:14:15 +01:00
|
|
|
m_nettieGroupsGrid->PushEventHandler( new GRID_TRICKS( m_nettieGroupsGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddNettieGroup( aEvent );
|
|
|
|
} ) );
|
|
|
|
m_jumperGroupsGrid->PushEventHandler( new GRID_TRICKS( m_jumperGroupsGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddJumperGroup( aEvent );
|
|
|
|
} ) );
|
2021-12-05 21:56:55 +00:00
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
m_itemsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
2025-05-30 17:14:15 +01:00
|
|
|
m_nettieGroupsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
|
|
|
m_jumperGroupsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
2021-07-28 16:40:35 +01:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Show/hide columns according to the user's preference
|
2020-01-12 20:44:19 -05:00
|
|
|
m_itemsGrid->ShowHideColumns( m_frame->GetSettings()->m_FootprintTextShownColumns );
|
2015-02-02 17:43:34 +01:00
|
|
|
|
2020-11-10 21:20:03 +00:00
|
|
|
m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2018-07-17 22:14:02 +01:00
|
|
|
// Set font sizes
|
2025-04-27 17:33:06 +01:00
|
|
|
wxFont infoFont = KIUI::GetInfoFont( this ).Italic();
|
2021-09-10 18:35:45 +01:00
|
|
|
m_staticTextInfoCopper->SetFont( infoFont );
|
|
|
|
m_staticTextInfoPaste->SetFont( infoFont );
|
2018-07-17 22:14:02 +01:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
if( static_cast<int>( m_page ) >= 0 )
|
2018-09-13 16:39:14 +01:00
|
|
|
m_NoteBook->SetSelection( (unsigned) m_page );
|
2015-02-02 17:43:34 +01:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
if( m_page == NOTEBOOK_PAGES::PAGE_GENERAL )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedFocusRow = 0;
|
|
|
|
m_delayedFocusColumn = 0;
|
2021-07-28 20:22:57 +01:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_GENERAL;
|
2018-03-28 18:14:04 +01:00
|
|
|
}
|
2021-07-28 20:22:57 +01:00
|
|
|
else if( m_page == NOTEBOOK_PAGES::PAGE_CLEARANCES )
|
|
|
|
{
|
2018-03-28 18:14:04 +01:00
|
|
|
SetInitialFocus( m_NetClearanceCtrl );
|
2021-07-28 20:22:57 +01:00
|
|
|
}
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2021-08-06 15:26:08 +01:00
|
|
|
m_solderPaste.SetNegativeZero();
|
|
|
|
|
|
|
|
m_solderPasteRatio.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_solderPasteRatio.SetNegativeZero();
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Configure button logos
|
2023-10-21 14:56:19 -04:00
|
|
|
m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
|
|
|
m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
|
|
|
m_bpAddLayer->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
|
|
|
m_bpDeleteLayer->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
2025-05-30 17:14:15 +01:00
|
|
|
m_bpAddNettieGroup->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
|
|
|
m_bpRemoveNettieGroup->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
|
|
|
m_bpAddJumperGroup->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
|
|
|
m_bpRemoveJumperGroup->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
|
2025-03-22 22:26:07 -04:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2022-11-29 19:35:59 -08:00
|
|
|
SetEvtHandlerEnabled( true );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::~DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2024-07-20 23:24:37 +01:00
|
|
|
m_frame->GetSettings()->m_FootprintTextShownColumns = m_itemsGrid->GetShownColumnsAsString();
|
2023-10-16 17:04:01 -04:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Prevents crash bug in wxGrid's d'tor
|
2023-05-24 08:39:25 -04:00
|
|
|
m_itemsGrid->DestroyTable( m_fields );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->DestroyTable( m_privateLayers );
|
2018-09-13 16:39:14 +01:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Delete the GRID_TRICKS.
|
|
|
|
m_itemsGrid->PopEventHandler( true );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->PopEventHandler( true );
|
2025-05-30 17:14:15 +01:00
|
|
|
m_nettieGroupsGrid->PopEventHandler( true );
|
|
|
|
m_jumperGroupsGrid->PopEventHandler( true );
|
2016-02-21 11:54:34 +11:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
m_page = static_cast<NOTEBOOK_PAGES>( m_NoteBook->GetSelection() );
|
2016-06-14 12:08:35 +02:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
// the GL canvas on the 3D models page has to be visible before it is destroyed
|
|
|
|
m_NoteBook->SetSelection( static_cast<int>( NOTEBOOK_PAGES::PAGE_3D_MODELS ) );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 18:14:04 +01:00
|
|
|
LIB_ID fpID = m_footprint->GetFPID();
|
|
|
|
wxString footprintName = fpID.GetLibItemName();
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-09-13 16:39:14 +01:00
|
|
|
m_FootprintNameCtrl->ChangeValue( footprintName );
|
2014-02-10 10:30:08 +01:00
|
|
|
|
2023-10-15 01:00:02 +03:00
|
|
|
m_DocCtrl->SetValue( EscapeString( m_footprint->GetLibDescription(), CTX_LINE ) );
|
2018-03-28 18:14:04 +01:00
|
|
|
m_KeywordCtrl->SetValue( m_footprint->GetKeywords() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
2016-07-19 13:35:25 -04:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
if( !m_PanelGeneral->TransferDataToWindow() )
|
|
|
|
return false;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2021-07-28 20:54:20 +01:00
|
|
|
// Add the models to the panel
|
2021-07-28 20:22:57 +01:00
|
|
|
if( !m_3dPanel->TransferDataToWindow() )
|
2018-03-28 18:14:04 +01:00
|
|
|
return false;
|
2016-01-16 17:49:28 +11:00
|
|
|
|
2025-01-26 16:51:47 -08:00
|
|
|
if( !m_embeddedFiles->TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
// Footprint Fields
|
|
|
|
for( PCB_FIELD* field : m_footprint->GetFields() )
|
2023-12-11 09:37:23 -05:00
|
|
|
m_fields->push_back( *field );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2021-07-28 20:54:20 +01:00
|
|
|
// Notify the grid
|
2023-05-24 08:39:25 -04:00
|
|
|
wxGridTableMessage tmsg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
|
|
|
|
m_fields->GetNumberRows() );
|
2018-03-28 18:14:04 +01:00
|
|
|
m_itemsGrid->ProcessTableMessage( tmsg );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2020-11-13 02:09:34 +00:00
|
|
|
if( m_footprint->GetAttributes() & FP_THROUGH_HOLE )
|
2020-08-26 22:43:38 +01:00
|
|
|
m_componentType->SetSelection( 0 );
|
2020-11-13 02:09:34 +00:00
|
|
|
else if( m_footprint->GetAttributes() & FP_SMD )
|
2020-08-26 22:43:38 +01:00
|
|
|
m_componentType->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_componentType->SetSelection( 2 );
|
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
// Private layers
|
|
|
|
for( PCB_LAYER_ID privateLayer : m_footprint->GetPrivateLayers().UIOrder() )
|
|
|
|
m_privateLayers->push_back( privateLayer );
|
|
|
|
|
|
|
|
// Notify the grid
|
|
|
|
wxGridTableMessage gridTableMessagesg( m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_APPENDED,
|
|
|
|
m_privateLayers->GetNumberRows() );
|
|
|
|
m_privateLayersGrid->ProcessTableMessage( gridTableMessagesg );
|
|
|
|
|
2020-11-13 02:09:34 +00:00
|
|
|
m_boardOnly->SetValue( m_footprint->GetAttributes() & FP_BOARD_ONLY );
|
|
|
|
m_excludeFromPosFiles->SetValue( m_footprint->GetAttributes() & FP_EXCLUDE_FROM_POS_FILES );
|
|
|
|
m_excludeFromBOM->SetValue( m_footprint->GetAttributes() & FP_EXCLUDE_FROM_BOM );
|
2023-04-10 13:10:42 -04:00
|
|
|
m_cbDNP->SetValue( m_footprint->GetAttributes() & FP_DNP );
|
2018-05-04 17:20:41 +01:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Local Clearances
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2024-01-10 11:28:29 +00:00
|
|
|
if( m_footprint->GetLocalClearance().has_value() )
|
|
|
|
m_netClearance.SetValue( m_footprint->GetLocalClearance().value() );
|
|
|
|
else
|
|
|
|
m_netClearance.SetValue( wxEmptyString );
|
|
|
|
|
|
|
|
if( m_footprint->GetLocalSolderMaskMargin().has_value() )
|
|
|
|
m_solderMask.SetValue( m_footprint->GetLocalSolderMaskMargin().value() );
|
|
|
|
else
|
|
|
|
m_solderMask.SetValue( wxEmptyString );
|
|
|
|
|
|
|
|
if( m_footprint->GetLocalSolderPasteMargin().has_value() )
|
|
|
|
m_solderPaste.SetValue( m_footprint->GetLocalSolderPasteMargin().value() );
|
|
|
|
else
|
|
|
|
m_solderPaste.SetValue( wxEmptyString );
|
|
|
|
|
|
|
|
if( m_footprint->GetLocalSolderPasteMarginRatio().has_value() )
|
|
|
|
m_solderPasteRatio.SetDoubleValue( m_footprint->GetLocalSolderPasteMarginRatio().value() * 100.0 );
|
|
|
|
else
|
|
|
|
m_solderPasteRatio.SetValue( wxEmptyString );
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
m_noCourtyards->SetValue( m_footprint->AllowMissingCourtyard() );
|
|
|
|
m_allowBridges->SetValue( m_footprint->AllowSolderMaskBridges() );
|
2012-05-18 10:33:57 +02:00
|
|
|
|
2024-01-10 11:28:29 +00:00
|
|
|
switch( m_footprint->GetLocalZoneConnection() )
|
2019-06-28 12:23:37 +01:00
|
|
|
{
|
|
|
|
default:
|
2021-07-28 20:54:20 +01:00
|
|
|
case ZONE_CONNECTION::INHERITED: m_ZoneConnectionChoice->SetSelection( 0 ); break;
|
|
|
|
case ZONE_CONNECTION::FULL: m_ZoneConnectionChoice->SetSelection( 1 ); break;
|
|
|
|
case ZONE_CONNECTION::THERMAL: m_ZoneConnectionChoice->SetSelection( 2 ); break;
|
|
|
|
case ZONE_CONNECTION::NONE: m_ZoneConnectionChoice->SetSelection( 3 ); break;
|
2019-06-28 12:23:37 +01:00
|
|
|
}
|
|
|
|
|
2022-08-19 18:34:53 +01:00
|
|
|
for( const wxString& group : m_footprint->GetNetTiePadGroups() )
|
|
|
|
{
|
|
|
|
if( !group.IsEmpty() )
|
|
|
|
{
|
2025-05-30 17:14:15 +01:00
|
|
|
m_nettieGroupsGrid->AppendRows( 1 );
|
|
|
|
m_nettieGroupsGrid->SetCellValue( m_nettieGroupsGrid->GetNumberRows() - 1, 0, group );
|
2022-08-19 18:34:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-03-22 22:26:07 -04:00
|
|
|
m_cbDuplicatePadsAreJumpers->SetValue( m_footprint->GetDuplicatePadNumbersAreJumpers() );
|
|
|
|
|
|
|
|
for( const std::set<wxString>& group : m_footprint->JumperPadGroups() )
|
|
|
|
{
|
|
|
|
wxString groupTxt;
|
|
|
|
|
|
|
|
for( const wxString& pinNumber : group )
|
|
|
|
{
|
2025-05-30 17:14:15 +01:00
|
|
|
if( !groupTxt.IsEmpty() )
|
2025-03-22 22:26:07 -04:00
|
|
|
groupTxt << ", ";
|
2025-05-30 17:14:15 +01:00
|
|
|
|
|
|
|
groupTxt << pinNumber;
|
2025-03-22 22:26:07 -04:00
|
|
|
}
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
m_jumperGroupsGrid->AppendRows( 1 );
|
|
|
|
m_jumperGroupsGrid->SetCellValue( m_jumperGroupsGrid->GetNumberRows() - 1, 0, groupTxt );
|
2025-03-22 22:26:07 -04:00
|
|
|
}
|
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
// Items grid
|
2019-02-10 07:59:27 +01:00
|
|
|
for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
|
2019-02-10 09:49:42 +01:00
|
|
|
{
|
|
|
|
// Adjust min size to the column label size
|
2022-08-19 18:34:53 +01:00
|
|
|
m_itemsGrid->SetColMinimalWidth( col, m_itemsGrid->GetVisibleWidth( col, true, false ) );
|
2021-02-23 17:24:26 +00:00
|
|
|
// Adjust the column size.
|
2022-08-19 18:34:53 +01:00
|
|
|
int col_size = m_itemsGrid->GetVisibleWidth( col );
|
2019-02-10 09:49:42 +01:00
|
|
|
|
2024-05-06 15:59:44 +01:00
|
|
|
if( col == PFC_LAYER ) // This one's a drop-down. Check all possible values.
|
2021-02-23 17:24:26 +00:00
|
|
|
{
|
|
|
|
BOARD* board = m_footprint->GetBoard();
|
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
|
|
|
|
col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x );
|
|
|
|
|
2024-05-21 04:11:56 +03:00
|
|
|
// Swatch and gaps:
|
2024-05-23 05:07:31 +03:00
|
|
|
col_size += KiROUND( 14 * GetDPIScaleFactor() ) + 12;
|
2021-02-23 17:24:26 +00:00
|
|
|
}
|
2019-02-10 09:49:42 +01:00
|
|
|
|
2019-02-17 14:09:35 +00:00
|
|
|
if( m_itemsGrid->IsColShown( col ) )
|
|
|
|
m_itemsGrid->SetColSize( col, col_size );
|
2019-02-10 09:49:42 +01:00
|
|
|
}
|
2019-02-09 15:31:31 -08:00
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
m_itemsGrid->SetRowLabelSize( 0 );
|
2019-02-09 15:31:31 -08:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
Layout();
|
2021-12-16 17:39:58 +03:00
|
|
|
adjustGridColumns();
|
2024-08-08 10:24:17 +01:00
|
|
|
m_initialized = true;
|
2013-11-29 13:29:41 -05:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
return true;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-02-16 12:41:31 +00:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::checkFootprintName( const wxString& aFootprintName,
|
|
|
|
LIB_ID* doOverwrite )
|
2018-09-13 16:39:14 +01:00
|
|
|
{
|
2019-07-02 17:00:00 +01:00
|
|
|
if( aFootprintName.IsEmpty() )
|
2018-09-13 16:39:14 +01:00
|
|
|
{
|
2019-07-02 17:00:00 +01:00
|
|
|
m_delayedErrorMessage = _( "Footprint must have a name." );
|
|
|
|
return false;
|
|
|
|
}
|
2020-11-13 15:15:52 +00:00
|
|
|
else if( !FOOTPRINT::IsLibNameValid( aFootprintName ) )
|
2019-07-02 17:00:00 +01:00
|
|
|
{
|
2021-06-16 23:35:00 +01:00
|
|
|
m_delayedErrorMessage.Printf( _( "Footprint name may not contain '%s'." ),
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT::StringLibNameInvalidChars( true ) );
|
2018-09-13 16:39:14 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2025-02-16 12:41:31 +00:00
|
|
|
LIB_ID fpID = m_footprint->GetFPID();
|
|
|
|
wxString libraryName = fpID.GetLibNickname();
|
|
|
|
wxString originalFPName = fpID.GetLibItemName();
|
|
|
|
FP_LIB_TABLE* tbl = PROJECT_PCB::PcbFootprintLibs( &m_frame->Prj() );
|
|
|
|
|
|
|
|
if( aFootprintName != originalFPName && tbl->FootprintExists( libraryName, aFootprintName ) )
|
|
|
|
{
|
|
|
|
wxString msg = wxString::Format( _( "Footprint '%s' already exists in library '%s'." ),
|
|
|
|
aFootprintName, libraryName );
|
|
|
|
|
|
|
|
KIDIALOG errorDlg( m_frame, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
|
|
|
|
errorDlg.SetOKLabel( _( "Overwrite" ) );
|
|
|
|
|
|
|
|
if( errorDlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
doOverwrite->SetLibNickname( libraryName );
|
|
|
|
doOverwrite->SetLibItemName( aFootprintName );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:39:14 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-19 17:10:14 +01:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
return false;
|
2018-03-28 18:14:04 +01:00
|
|
|
|
|
|
|
if( !DIALOG_SHIM::Validate() )
|
|
|
|
return false;
|
|
|
|
|
2020-11-13 11:17:15 +00:00
|
|
|
// First, test for invalid chars in footprint name
|
2012-12-10 12:18:42 +01:00
|
|
|
wxString footprintName = m_FootprintNameCtrl->GetValue();
|
2025-02-16 12:41:31 +00:00
|
|
|
LIB_ID overwrite;
|
2013-11-29 13:29:41 -05:00
|
|
|
|
2025-02-16 12:41:31 +00:00
|
|
|
if( !checkFootprintName( footprintName, &overwrite ) )
|
2012-12-10 12:18:42 +01:00
|
|
|
{
|
2018-09-13 16:39:14 +01:00
|
|
|
if( m_NoteBook->GetSelection() != 0 )
|
|
|
|
m_NoteBook->SetSelection( 0 );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2018-09-13 16:39:14 +01:00
|
|
|
m_delayedFocusCtrl = m_FootprintNameCtrl;
|
2021-07-28 20:22:57 +01:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_GENERAL;
|
2018-03-28 18:14:04 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
// Check for valid field text properties
|
2025-02-16 12:41:31 +00:00
|
|
|
for( int i = 0; i < (int) m_fields->size(); ++i )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2023-12-11 09:37:23 -05:00
|
|
|
PCB_FIELD& field = m_fields->at( i );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
// Check for missing field names.
|
2023-12-11 09:37:23 -05:00
|
|
|
if( field.GetName( false ).IsEmpty() )
|
2012-12-10 12:18:42 +01:00
|
|
|
{
|
2018-11-12 17:07:22 +00:00
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
2023-05-24 08:39:25 -04:00
|
|
|
m_delayedErrorMessage = wxString::Format( _( "Fields must have a name." ) );
|
2024-05-06 15:59:44 +01:00
|
|
|
m_delayedFocusColumn = PFC_NAME;
|
2018-03-28 18:14:04 +01:00
|
|
|
m_delayedFocusRow = i;
|
2016-08-05 21:30:23 +02:00
|
|
|
|
2022-10-05 17:42:03 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-03-23 13:15:31 +00:00
|
|
|
int minSize = pcbIUScale.mmToIU( TEXT_MIN_SIZE_MM );
|
|
|
|
int maxSize = pcbIUScale.mmToIU( TEXT_MAX_SIZE_MM );
|
2023-06-03 16:59:00 +01:00
|
|
|
|
2023-12-11 09:37:23 -05:00
|
|
|
if( field.GetTextWidth() < minSize || field.GetTextWidth() > maxSize )
|
2022-10-05 17:42:03 +01:00
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedErrorMessage = wxString::Format( _( "The text width must be between %s and %s." ),
|
2023-06-03 16:59:00 +01:00
|
|
|
m_frame->StringFromValue( minSize, true ),
|
|
|
|
m_frame->StringFromValue( maxSize, true ) );
|
2024-05-06 15:59:44 +01:00
|
|
|
m_delayedFocusColumn = PFC_WIDTH;
|
2022-10-05 17:42:03 +01:00
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-12-11 09:37:23 -05:00
|
|
|
if( field.GetTextHeight() < minSize || field.GetTextHeight() > maxSize )
|
2022-10-05 17:42:03 +01:00
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedErrorMessage = wxString::Format( _( "The text height must be between %s and %s." ),
|
2023-06-03 16:59:00 +01:00
|
|
|
m_frame->StringFromValue( minSize, true ),
|
|
|
|
m_frame->StringFromValue( maxSize, true ) );
|
2024-05-06 15:59:44 +01:00
|
|
|
m_delayedFocusColumn = PFC_HEIGHT;
|
2022-10-05 17:42:03 +01:00
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test for acceptable values for thickness and size and clamp if fails
|
2025-01-12 11:27:18 -05:00
|
|
|
int maxPenWidth = ClampTextPenSize( field.GetTextThickness(), field.GetTextSize() );
|
2022-10-05 17:42:03 +01:00
|
|
|
|
2023-12-11 09:37:23 -05:00
|
|
|
if( field.GetTextThickness() > maxPenWidth )
|
2022-10-05 17:42:03 +01:00
|
|
|
{
|
2024-05-06 15:59:44 +01:00
|
|
|
m_itemsGrid->SetCellValue( i, PFC_THICKNESS,
|
2022-10-05 17:42:03 +01:00
|
|
|
m_frame->StringFromValue( maxPenWidth, true ) );
|
|
|
|
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedErrorMessage = _( "The text thickness is too large for the text size.\n"
|
|
|
|
"It will be clamped." );
|
2024-05-06 15:59:44 +01:00
|
|
|
m_delayedFocusColumn = PFC_THICKNESS;
|
2022-10-05 17:42:03 +01:00
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
2017-04-16 13:53:56 +02:00
|
|
|
return false;
|
2012-12-10 12:18:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_netClearance.Validate( 0, INT_MAX ) )
|
2018-03-28 18:14:04 +01:00
|
|
|
return false;
|
2018-02-14 17:46:35 +01:00
|
|
|
|
2025-02-16 12:41:31 +00:00
|
|
|
if( overwrite.IsValid() )
|
|
|
|
{
|
|
|
|
if( m_frame->DeleteFootprintFromLibrary( overwrite, false /* already confirmed */ ) )
|
|
|
|
m_frame->SyncLibraryTree( true );
|
|
|
|
}
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2022-08-19 18:34:53 +01:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges()
|
|
|
|
|| !m_privateLayersGrid->CommitPendingChanges()
|
2025-05-30 17:14:15 +01:00
|
|
|
|| !m_nettieGroupsGrid->CommitPendingChanges()
|
|
|
|
|| !m_jumperGroupsGrid->CommitPendingChanges() )
|
2022-08-19 18:34:53 +01:00
|
|
|
{
|
2018-03-28 18:14:04 +01:00
|
|
|
return false;
|
2022-08-19 18:34:53 +01:00
|
|
|
}
|
2016-06-20 15:46:58 +02:00
|
|
|
|
2025-03-09 11:47:15 +00:00
|
|
|
KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView();
|
|
|
|
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
2018-03-28 18:14:04 +01:00
|
|
|
commit.Modify( m_footprint );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2025-01-26 16:51:47 -08:00
|
|
|
// Must be done inside the commit to capture the undo state
|
|
|
|
// This will call TransferDataToWindow() on the 3D panel and
|
|
|
|
// the embedded files panel.
|
|
|
|
if( !DIALOG_SHIM::TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Clear out embedded files that are no longer in use
|
|
|
|
std::set<wxString> files;
|
|
|
|
std::set<wxString> files_to_delete;
|
|
|
|
|
|
|
|
// Get the new files from the footprint fields
|
2025-02-08 13:45:57 +00:00
|
|
|
for( const PCB_FIELD& field : *m_fields )
|
2025-01-26 16:51:47 -08:00
|
|
|
{
|
2025-02-08 13:45:57 +00:00
|
|
|
if( field.GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
|
|
|
|
files.insert( field.GetText() );
|
2025-01-26 16:51:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find any files referenced in the old fields that are not in the new fields
|
|
|
|
for( PCB_FIELD* field : m_footprint->GetFields() )
|
|
|
|
{
|
|
|
|
if( field->GetText().StartsWith( FILEEXT::KiCadUriPrefix ) )
|
|
|
|
{
|
|
|
|
if( files.find( field->GetText() ) == files.end() )
|
|
|
|
files_to_delete.insert( field->GetText() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( const wxString& file : files_to_delete )
|
|
|
|
{
|
|
|
|
wxString name = file.Mid( FILEEXT::KiCadUriPrefix.size() + 3 ); // Skip "kicad-embed://"
|
|
|
|
m_footprint->RemoveFile( name );
|
|
|
|
}
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
LIB_ID fpID = m_footprint->GetFPID();
|
2021-06-30 12:00:06 +01:00
|
|
|
fpID.SetLibItemName( m_FootprintNameCtrl->GetValue() );
|
2018-03-28 18:14:04 +01:00
|
|
|
m_footprint->SetFPID( fpID );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2023-10-15 01:00:02 +03:00
|
|
|
m_footprint->SetLibDescription( UnescapeString( m_DocCtrl->GetValue() ) );
|
2018-03-28 18:14:04 +01:00
|
|
|
m_footprint->SetKeywords( m_KeywordCtrl->GetValue() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
// Update fields
|
2025-04-02 11:01:22 -04:00
|
|
|
m_frame->GetToolManager()->RunAction( ACTIONS::selectionClear );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2025-03-08 22:18:27 +01:00
|
|
|
while( !m_footprint->GetFields().empty() )
|
2017-04-16 13:53:56 +02:00
|
|
|
{
|
2025-03-08 22:18:27 +01:00
|
|
|
PCB_FIELD* existing = m_footprint->GetFields().front();
|
2025-02-08 13:45:57 +00:00
|
|
|
view->Remove( existing );
|
2025-03-08 22:18:27 +01:00
|
|
|
m_footprint->Remove( existing );
|
2025-02-08 13:45:57 +00:00
|
|
|
delete existing;
|
2018-03-28 18:14:04 +01:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2025-02-08 13:45:57 +00:00
|
|
|
for( PCB_FIELD& field : *m_fields )
|
2020-11-17 20:47:50 +00:00
|
|
|
{
|
2025-02-08 13:45:57 +00:00
|
|
|
PCB_FIELD* newField = field.CloneField();
|
|
|
|
m_footprint->Add( newField );
|
|
|
|
view->Add( newField );
|
2025-03-09 11:47:15 +00:00
|
|
|
|
|
|
|
if( newField->IsSelected() )
|
|
|
|
{
|
|
|
|
// The old copy was in the selection list, but this one is not. Remove the
|
|
|
|
// out-of-sync selection flag so we can re-add the field to the selection.
|
|
|
|
newField->ClearSelected();
|
|
|
|
selectionTool->AddItemToSel( newField, true );
|
|
|
|
}
|
2020-11-17 20:47:50 +00:00
|
|
|
}
|
2020-05-13 11:51:56 +02:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
LSET privateLayers;
|
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : *m_privateLayers )
|
|
|
|
privateLayers.set( layer );
|
|
|
|
|
|
|
|
m_footprint->SetPrivateLayers( privateLayers );
|
|
|
|
|
2020-08-26 22:43:38 +01:00
|
|
|
int attributes = 0;
|
|
|
|
|
|
|
|
switch( m_componentType->GetSelection() )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2020-11-13 02:09:34 +00:00
|
|
|
case 0: attributes |= FP_THROUGH_HOLE; break;
|
|
|
|
case 1: attributes |= FP_SMD; break;
|
|
|
|
default: break;
|
2018-05-04 17:20:41 +01:00
|
|
|
}
|
|
|
|
|
2020-08-26 22:43:38 +01:00
|
|
|
if( m_boardOnly->GetValue() )
|
2020-11-13 02:09:34 +00:00
|
|
|
attributes |= FP_BOARD_ONLY;
|
2020-08-26 22:43:38 +01:00
|
|
|
|
|
|
|
if( m_excludeFromPosFiles->GetValue() )
|
2020-11-13 02:09:34 +00:00
|
|
|
attributes |= FP_EXCLUDE_FROM_POS_FILES;
|
2020-08-26 22:43:38 +01:00
|
|
|
|
|
|
|
if( m_excludeFromBOM->GetValue() )
|
2020-11-13 02:09:34 +00:00
|
|
|
attributes |= FP_EXCLUDE_FROM_BOM;
|
2020-08-26 22:43:38 +01:00
|
|
|
|
2023-04-10 13:10:42 -04:00
|
|
|
if( m_cbDNP->GetValue() )
|
|
|
|
attributes |= FP_DNP;
|
|
|
|
|
2020-08-26 22:43:38 +01:00
|
|
|
m_footprint->SetAttributes( attributes );
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
m_footprint->SetAllowMissingCourtyard( m_noCourtyards->GetValue() );
|
|
|
|
m_footprint->SetAllowSolderMaskBridges( m_allowBridges->GetValue() );
|
|
|
|
|
2024-01-10 11:28:29 +00:00
|
|
|
// Initialize mask clearances
|
|
|
|
if( m_netClearance.IsNull() )
|
|
|
|
m_footprint->SetLocalClearance( {} );
|
|
|
|
else
|
|
|
|
m_footprint->SetLocalClearance( m_netClearance.GetValue() );
|
|
|
|
|
|
|
|
if( m_solderMask.IsNull() )
|
|
|
|
m_footprint->SetLocalSolderMaskMargin( {} );
|
|
|
|
else
|
|
|
|
m_footprint->SetLocalSolderMaskMargin( m_solderMask.GetValue() );
|
|
|
|
|
|
|
|
if( m_solderPaste.IsNull() )
|
|
|
|
m_footprint->SetLocalSolderPasteMargin( {} );
|
|
|
|
else
|
|
|
|
m_footprint->SetLocalSolderPasteMargin( m_solderPaste.GetValue() );
|
|
|
|
|
|
|
|
if( m_solderPasteRatio.IsNull() )
|
|
|
|
m_footprint->SetLocalSolderPasteMarginRatio( {} );
|
|
|
|
else
|
|
|
|
m_footprint->SetLocalSolderPasteMarginRatio( m_solderPasteRatio.GetDoubleValue() / 100.0 );
|
2012-02-18 22:02:19 -06:00
|
|
|
|
2019-06-28 12:23:37 +01:00
|
|
|
switch( m_ZoneConnectionChoice->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
2024-01-10 11:28:29 +00:00
|
|
|
case 0: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::INHERITED ); break;
|
|
|
|
case 1: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::FULL ); break;
|
|
|
|
case 2: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::THERMAL ); break;
|
|
|
|
case 3: m_footprint->SetLocalZoneConnection( ZONE_CONNECTION::NONE ); break;
|
2019-06-28 12:23:37 +01:00
|
|
|
}
|
|
|
|
|
2022-08-19 18:34:53 +01:00
|
|
|
m_footprint->ClearNetTiePadGroups();
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
for( int ii = 0; ii < m_nettieGroupsGrid->GetNumberRows(); ++ii )
|
2022-08-19 18:34:53 +01:00
|
|
|
{
|
2025-05-30 17:14:15 +01:00
|
|
|
wxString group = m_nettieGroupsGrid->GetCellValue( ii, 0 );
|
2022-08-19 18:34:53 +01:00
|
|
|
|
|
|
|
if( !group.IsEmpty() )
|
|
|
|
m_footprint->AddNetTiePadGroup( group );
|
|
|
|
}
|
|
|
|
|
2025-03-22 22:26:07 -04:00
|
|
|
m_footprint->SetDuplicatePadNumbersAreJumpers( m_cbDuplicatePadsAreJumpers->GetValue() );
|
|
|
|
|
|
|
|
std::vector<std::set<wxString>>& jumpers = m_footprint->JumperPadGroups();
|
|
|
|
jumpers.clear();
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
for( int ii = 0; ii < m_jumperGroupsGrid->GetNumberRows(); ++ii )
|
2025-03-22 22:26:07 -04:00
|
|
|
{
|
2025-05-30 17:14:15 +01:00
|
|
|
wxStringTokenizer tokenizer( m_jumperGroupsGrid->GetCellValue( ii, 0 ), ", " );
|
2025-03-22 22:26:07 -04:00
|
|
|
std::set<wxString>& group = jumpers.emplace_back();
|
|
|
|
|
|
|
|
while( tokenizer.HasMoreTokens() )
|
|
|
|
{
|
|
|
|
if( wxString token = tokenizer.GetNextToken(); !token.IsEmpty() )
|
|
|
|
group.insert( token );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
// Copy the models from the panel to the footprint
|
|
|
|
std::vector<FP_3DMODEL>& panelList = m_3dPanel->GetModelList();
|
2021-07-11 12:49:36 +01:00
|
|
|
std::vector<FP_3DMODEL>* fpList = &m_footprint->Models();
|
2021-07-28 20:22:57 +01:00
|
|
|
fpList->clear();
|
|
|
|
fpList->insert( fpList->end(), panelList.begin(), panelList.end() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2024-02-03 13:43:41 +00:00
|
|
|
commit.Push( _( "Edit Footprint Properties" ) );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2017-04-16 13:53:56 +02:00
|
|
|
return true;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField( wxCommandEvent& event )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-19 17:10:14 +01:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
2024-07-20 23:16:32 +01:00
|
|
|
|
2025-02-08 13:45:57 +00:00
|
|
|
PCB_FIELD newField( m_footprint, FIELD_T::USER,
|
2025-01-22 14:26:57 +00:00
|
|
|
GetUserFieldName( m_fields->GetNumberRows(), DO_TRANSLATE ) );
|
2018-01-14 14:24:58 +01:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
// Set active layer if legal; otherwise copy layer from previous text item
|
|
|
|
if( LSET::AllTechMask().test( m_frame->GetActiveLayer() ) )
|
2023-12-11 09:37:23 -05:00
|
|
|
newField.SetLayer( m_frame->GetActiveLayer() );
|
2018-03-28 18:14:04 +01:00
|
|
|
else
|
2023-12-11 09:37:23 -05:00
|
|
|
newField.SetLayer( m_fields->at( m_fields->size() - 1 ).GetLayer() );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2023-12-11 09:37:23 -05:00
|
|
|
newField.SetTextSize( dsnSettings.GetTextSize( newField.GetLayer() ) );
|
|
|
|
newField.SetTextThickness( dsnSettings.GetTextThickness( newField.GetLayer() ) );
|
|
|
|
newField.SetItalic( dsnSettings.GetTextItalic( newField.GetLayer() ) );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
m_fields->push_back( newField );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
|
|
|
// notify the grid
|
2023-05-24 08:39:25 -04:00
|
|
|
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
|
2018-03-28 18:14:04 +01:00
|
|
|
m_itemsGrid->ProcessTableMessage( msg );
|
2018-01-14 14:24:58 +01:00
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
m_itemsGrid->SetFocus();
|
2025-02-16 12:41:31 +00:00
|
|
|
m_itemsGrid->MakeCellVisible( (int) m_fields->size() - 1, 0 );
|
|
|
|
m_itemsGrid->SetGridCursor( (int) m_fields->size() - 1, 0 );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
|
|
|
m_itemsGrid->EnableCellEditControl( true );
|
|
|
|
m_itemsGrid->ShowCellEditControl();
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
OnModify();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 00:15:23 -05:00
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteField( wxCommandEvent& event )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-19 17:10:14 +01:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
2018-03-28 18:14:04 +01:00
|
|
|
return;
|
2018-01-14 14:24:58 +01:00
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
wxArrayInt selectedRows = m_itemsGrid->GetSelectedRows();
|
2018-08-19 17:10:14 +01:00
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
if( selectedRows.empty() && m_itemsGrid->GetGridCursorRow() >= 0 )
|
|
|
|
selectedRows.push_back( m_itemsGrid->GetGridCursorRow() );
|
|
|
|
|
|
|
|
if( selectedRows.empty() )
|
2018-08-19 17:10:14 +01:00
|
|
|
return;
|
2021-12-12 17:27:40 +00:00
|
|
|
|
|
|
|
for( int row : selectedRows )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2025-01-21 23:38:55 +00:00
|
|
|
if( row < m_fields->GetMandatoryRowCount() )
|
2021-12-12 17:27:40 +00:00
|
|
|
{
|
2023-05-24 08:39:25 -04:00
|
|
|
DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
|
2025-01-21 23:38:55 +00:00
|
|
|
m_fields->GetMandatoryRowCount() ) );
|
2021-12-12 17:27:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-03-28 18:14:04 +01:00
|
|
|
}
|
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
m_itemsGrid->CommitPendingChanges( true /* quiet mode */ );
|
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
// Reverse sort so deleting a row doesn't change the indexes of the other rows.
|
2024-07-20 23:16:32 +01:00
|
|
|
selectedRows.Sort( []( int* first, int* second )
|
|
|
|
{
|
|
|
|
return *second - *first;
|
|
|
|
} );
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
for( int row : selectedRows )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2025-05-29 17:53:36 +01:00
|
|
|
m_itemsGrid->ClearSelection();
|
2023-05-24 08:39:25 -04:00
|
|
|
m_fields->erase( m_fields->begin() + row );
|
2021-12-12 17:27:40 +00:00
|
|
|
|
|
|
|
// notify the grid
|
2023-05-24 08:39:25 -04:00
|
|
|
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
|
2021-12-12 17:27:40 +00:00
|
|
|
m_itemsGrid->ProcessTableMessage( msg );
|
|
|
|
|
|
|
|
if( m_itemsGrid->GetNumberRows() > 0 )
|
|
|
|
{
|
|
|
|
m_itemsGrid->MakeCellVisible( std::max( 0, row-1 ), m_itemsGrid->GetGridCursorCol() );
|
|
|
|
m_itemsGrid->SetGridCursor( std::max( 0, row-1 ), m_itemsGrid->GetGridCursorCol() );
|
|
|
|
}
|
2018-03-28 18:14:04 +01:00
|
|
|
}
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
OnModify();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
2016-02-28 10:17:58 +11:00
|
|
|
|
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddLayer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !m_privateLayersGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
PCB_LAYER_ID nextLayer = User_1;
|
|
|
|
|
2024-11-03 10:26:10 -08:00
|
|
|
while( alg::contains( *m_privateLayers, nextLayer ) && nextLayer < User_45 )
|
2021-12-05 21:56:55 +00:00
|
|
|
nextLayer = ToLAYER_ID( nextLayer + 1 );
|
|
|
|
|
|
|
|
m_privateLayers->push_back( nextLayer );
|
|
|
|
|
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage msg( m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
|
|
|
|
m_privateLayersGrid->ProcessTableMessage( msg );
|
|
|
|
|
|
|
|
m_privateLayersGrid->SetFocus();
|
2025-02-16 12:41:31 +00:00
|
|
|
m_privateLayersGrid->MakeCellVisible( (int) m_privateLayers->size() - 1, 0 );
|
|
|
|
m_privateLayersGrid->SetGridCursor( (int) m_privateLayers->size() - 1, 0 );
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
OnModify();
|
2021-12-05 21:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteLayer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !m_privateLayersGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int curRow = m_privateLayersGrid->GetGridCursorRow();
|
|
|
|
|
|
|
|
if( curRow < 0 )
|
|
|
|
return;
|
|
|
|
|
2025-05-29 17:53:36 +01:00
|
|
|
m_privateLayersGrid->ClearSelection();
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayers->erase( m_privateLayers->begin() + curRow );
|
|
|
|
|
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage msg( m_privateLayers, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
|
|
|
|
m_privateLayersGrid->ProcessTableMessage( msg );
|
|
|
|
|
|
|
|
if( m_privateLayersGrid->GetNumberRows() > 0 )
|
|
|
|
{
|
|
|
|
m_privateLayersGrid->MakeCellVisible( std::max( 0, curRow-1 ),
|
2024-07-20 23:16:32 +01:00
|
|
|
m_privateLayersGrid->GetGridCursorCol() );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->SetGridCursor( std::max( 0, curRow-1 ),
|
2024-07-20 23:16:32 +01:00
|
|
|
m_privateLayersGrid->GetGridCursorCol() );
|
2021-12-05 21:56:55 +00:00
|
|
|
}
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
OnModify();
|
2021-12-05 21:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddNettieGroup( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
onAddGroup( m_nettieGroupsGrid );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnRemoveNettieGroup( wxCommandEvent& event )
|
2022-08-19 18:34:53 +01:00
|
|
|
{
|
2025-05-30 17:14:15 +01:00
|
|
|
onRemoveGroup( m_nettieGroupsGrid );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddJumperGroup( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
onAddGroup( m_jumperGroupsGrid );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnRemoveJumperGroup( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
onRemoveGroup( m_jumperGroupsGrid );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::onAddGroup( WX_GRID* aGrid )
|
|
|
|
{
|
|
|
|
if( !aGrid->CommitPendingChanges() )
|
2022-08-19 18:34:53 +01:00
|
|
|
return;
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
aGrid->AppendRows( 1 );
|
2022-08-19 18:34:53 +01:00
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
aGrid->SetFocus();
|
|
|
|
aGrid->MakeCellVisible( aGrid->GetNumberRows() - 1, 0 );
|
|
|
|
aGrid->SetGridCursor( aGrid->GetNumberRows() - 1, 0 );
|
2022-08-19 18:34:53 +01:00
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
aGrid->EnableCellEditControl( true );
|
|
|
|
aGrid->ShowCellEditControl();
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
OnModify();
|
2022-08-19 18:34:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::onRemoveGroup( WX_GRID* aGrid )
|
2022-08-19 18:34:53 +01:00
|
|
|
{
|
2025-05-30 17:14:15 +01:00
|
|
|
if( !aGrid->CommitPendingChanges() )
|
2022-08-19 18:34:53 +01:00
|
|
|
return;
|
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
wxArrayInt selectedRows = aGrid->GetSelectedRows();
|
|
|
|
int curRow = aGrid->GetGridCursorRow();
|
2022-08-19 18:34:53 +01:00
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
if( selectedRows.empty() && curRow >= 0 && curRow < aGrid->GetNumberRows() )
|
2022-08-19 18:34:53 +01:00
|
|
|
selectedRows.Add( curRow );
|
|
|
|
|
2025-02-16 12:41:31 +00:00
|
|
|
for( int ii = (int) selectedRows.Count() - 1; ii >= 0; --ii )
|
2022-08-19 18:34:53 +01:00
|
|
|
{
|
|
|
|
int row = selectedRows.Item( ii );
|
2025-05-30 17:14:15 +01:00
|
|
|
aGrid->DeleteRows( row, 1 );
|
2022-08-19 18:34:53 +01:00
|
|
|
curRow = std::min( curRow, row );
|
|
|
|
}
|
|
|
|
|
|
|
|
curRow = std::max( 0, curRow - 1 );
|
2025-05-30 17:14:15 +01:00
|
|
|
aGrid->MakeCellVisible( curRow, aGrid->GetGridCursorCol() );
|
|
|
|
aGrid->SetGridCursor( curRow, aGrid->GetGridCursorCol() );
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
OnModify();
|
2022-08-19 18:34:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-16 17:39:58 +03:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::adjustGridColumns()
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
|
|
|
// Account for scroll bars
|
2021-12-16 17:39:58 +03:00
|
|
|
int itemsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_itemsGrid ).x;
|
2018-03-28 18:14:04 +01:00
|
|
|
|
|
|
|
itemsWidth -= m_itemsGrid->GetRowLabelSize();
|
|
|
|
|
2023-05-24 08:39:25 -04:00
|
|
|
for( int i = 0; i < m_itemsGrid->GetNumberCols(); i++ )
|
|
|
|
{
|
|
|
|
if( i == 1 )
|
|
|
|
continue;
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
itemsWidth -= m_itemsGrid->GetColSize( i );
|
2023-05-24 08:39:25 -04:00
|
|
|
}
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
m_itemsGrid->SetColSize( 1, std::max( itemsWidth, m_itemsGrid->GetVisibleWidth( 0, true, false ) ) );
|
2022-08-19 18:34:53 +01:00
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
auto updateSingleColumnGrid =
|
|
|
|
[]( WX_GRID* aGrid )
|
|
|
|
{
|
|
|
|
aGrid->SetColSize( 0, std::max( aGrid->GetClientSize().x, aGrid->GetVisibleWidth( 0 ) ) );
|
|
|
|
};
|
2022-08-19 18:34:53 +01:00
|
|
|
|
2025-05-30 17:14:15 +01:00
|
|
|
updateSingleColumnGrid( m_privateLayersGrid );
|
|
|
|
updateSingleColumnGrid( m_nettieGroupsGrid );
|
|
|
|
updateSingleColumnGrid( m_jumperGroupsGrid );
|
2021-07-28 16:40:35 +01:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
// Update the width of the 3D panel
|
2021-12-16 17:39:58 +03:00
|
|
|
m_3dPanel->AdjustGridColumnWidths();
|
2018-03-28 18:14:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 10:41:48 +01:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2018-09-13 16:39:14 +01:00
|
|
|
// Handle a delayed focus. The delay allows us to:
|
|
|
|
// a) change focus when the error was triggered from within a killFocus handler
|
|
|
|
// b) show the correct notebook page in the background before the error dialog comes up
|
|
|
|
// when triggered from an OK or a notebook page change
|
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
if( static_cast<int>( m_delayedFocusPage ) >= 0 )
|
2018-09-13 16:39:14 +01:00
|
|
|
{
|
2021-07-28 20:22:57 +01:00
|
|
|
if( m_NoteBook->GetSelection() != static_cast<int>( m_delayedFocusPage ) )
|
2021-12-13 15:46:13 -05:00
|
|
|
m_NoteBook->ChangeSelection( static_cast<int>( m_delayedFocusPage ) );
|
2018-11-20 22:58:40 +00:00
|
|
|
|
2021-07-28 20:22:57 +01:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_UNKNOWN;
|
2018-09-13 16:39:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !m_delayedErrorMessage.IsEmpty() )
|
|
|
|
{
|
|
|
|
// We will re-enter this routine when the error dialog is displayed, so make
|
|
|
|
// sure we don't keep putting up more dialogs.
|
|
|
|
wxString msg = m_delayedErrorMessage;
|
|
|
|
m_delayedErrorMessage = wxEmptyString;
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2018-09-13 16:39:14 +01:00
|
|
|
// Do not use DisplayErrorMessage(); it screws up window order on Mac
|
|
|
|
DisplayError( nullptr, msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_delayedFocusCtrl )
|
|
|
|
{
|
|
|
|
m_delayedFocusCtrl->SetFocus();
|
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
if( wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( m_delayedFocusCtrl ) )
|
2020-01-13 01:39:08 +00:00
|
|
|
textEntry->SelectAll();
|
2018-09-13 16:39:14 +01:00
|
|
|
|
|
|
|
m_delayedFocusCtrl = nullptr;
|
|
|
|
}
|
|
|
|
else if( m_delayedFocusGrid )
|
|
|
|
{
|
2018-03-28 18:14:04 +01:00
|
|
|
m_delayedFocusGrid->SetFocus();
|
|
|
|
m_delayedFocusGrid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
|
|
|
|
m_delayedFocusGrid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn );
|
|
|
|
|
2025-01-21 23:38:55 +00:00
|
|
|
if( !( m_delayedFocusColumn == 0 && m_delayedFocusRow < m_fields->GetMandatoryRowCount() ) )
|
2023-05-24 08:39:25 -04:00
|
|
|
m_delayedFocusGrid->EnableCellEditControl( true );
|
|
|
|
|
2018-03-28 18:14:04 +01:00
|
|
|
m_delayedFocusGrid->ShowCellEditControl();
|
|
|
|
|
2018-09-13 16:39:14 +01:00
|
|
|
m_delayedFocusGrid = nullptr;
|
2018-03-28 18:14:04 +01:00
|
|
|
m_delayedFocusRow = -1;
|
|
|
|
m_delayedFocusColumn = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-12 00:38:01 +01:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridSize( wxSizeEvent& aEvent )
|
2018-03-28 18:14:04 +01:00
|
|
|
{
|
2022-10-12 00:38:01 +01:00
|
|
|
wxSize new_size = aEvent.GetSize();
|
|
|
|
|
|
|
|
if( ( !m_itemsGrid->IsCellEditControlShown() || m_lastRequestedSize != new_size )
|
|
|
|
&& m_gridSize != new_size )
|
|
|
|
{
|
|
|
|
m_gridSize = new_size;
|
|
|
|
|
|
|
|
// A trick to fix a cosmetic issue: when, in m_itemsGrid, a layer selector widget has
|
|
|
|
// the focus (is activated in column 6) when resizing the grid, the widget is not moved.
|
|
|
|
// So just change the widget having the focus in this case
|
|
|
|
if( m_NoteBook->GetSelection() == 0 && !m_itemsGrid->HasFocus() )
|
|
|
|
{
|
|
|
|
int col = m_itemsGrid->GetGridCursorCol();
|
|
|
|
|
|
|
|
if( col == 6 ) // a layer selector widget can be activated
|
|
|
|
m_itemsGrid->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
adjustGridColumns();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We store this value to check whether the dialog is changing size. This might indicate
|
|
|
|
// that the user is scaling the dialog with an editor shown. Some editors do not close
|
|
|
|
// (at least on GTK) when the user drags a dialog corner
|
|
|
|
m_lastRequestedSize = new_size;
|
2018-03-28 18:14:04 +01:00
|
|
|
|
2022-10-12 00:38:01 +01:00
|
|
|
// Always propagate for a grid repaint (needed if the height changes, as well as width)
|
|
|
|
aEvent.Skip();
|
2016-02-28 10:17:58 +11:00
|
|
|
}
|
2024-08-08 10:24:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnPageChanging( wxNotebookEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
aEvent.Veto();
|
|
|
|
|
|
|
|
if( !m_privateLayersGrid->CommitPendingChanges() )
|
|
|
|
aEvent.Veto();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnCheckBox( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized )
|
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnText( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized )
|
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnChoice( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_initialized )
|
|
|
|
OnModify();
|
|
|
|
}
|
2025-03-22 22:26:07 -04:00
|
|
|
|
|
|
|
|