2012-08-21 10:45:54 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-14 13:24:58 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2015-02-02 16:43:34 +00:00
|
|
|
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
|
2017-12-27 17:43:26 +00:00
|
|
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
2022-10-05 16:42:03 +00:00
|
|
|
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-08-21 10:45:54 +00: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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-12-17 13:12:18 +00:00
|
|
|
#include <dialogs/dialog_text_entry.h>
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h>
|
2013-11-29 18:29:41 +00:00
|
|
|
#include <validators.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <board_design_settings.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2021-12-16 14:39:58 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2020-09-01 02:00:38 +00:00
|
|
|
#include <widgets/grid_text_button_helpers.h>
|
2018-05-30 10:52:19 +00:00
|
|
|
#include <widgets/wx_grid.h>
|
2022-12-13 20:47:28 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
2021-04-04 09:41:48 +00:00
|
|
|
#include <dialog_footprint_properties_fp_editor.h>
|
2021-07-28 19:22:57 +00:00
|
|
|
#include <panel_fp_properties_3d_model.h>
|
2021-10-21 13:29:19 +00:00
|
|
|
#include "3d_rendering/opengl/3d_model.h"
|
2018-03-07 13:05:12 +00:00
|
|
|
#include "filename_resolver.h"
|
2016-04-17 22:35:32 +00:00
|
|
|
#include <pgm_base.h>
|
2022-10-05 16:42:03 +00:00
|
|
|
#include <pcbnew.h>
|
2021-10-21 11:43:50 +00:00
|
|
|
#include "dialogs/panel_preview_3d_model.h"
|
|
|
|
#include "dialogs/3d_cache_dialogs.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>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2021-12-05 21:56:55 +00:00
|
|
|
#include <grid_layer_box_helpers.h>
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <fp_lib_table.h>
|
|
|
|
|
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 16:13:50 +00:00
|
|
|
forbiddenLayers.set( Edge_Cuts );
|
|
|
|
forbiddenLayers.set( Margin );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, forbiddenLayers ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
wxGridCellAttr::wxAttrKind )
|
|
|
|
{
|
|
|
|
m_layerColAttr->IncRef();
|
|
|
|
return m_layerColAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 13:24:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Remember the last open page during session.
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
NOTEBOOK_PAGES DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::m_page = NOTEBOOK_PAGES::PAGE_GENERAL;
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(
|
|
|
|
FOOTPRINT_EDIT_FRAME* aParent,
|
|
|
|
FOOTPRINT* aFootprint ) :
|
2021-04-04 09:41:48 +00:00
|
|
|
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR_BASE( aParent ),
|
2021-07-28 19:22:57 +00:00
|
|
|
m_frame( aParent ),
|
|
|
|
m_footprint( aFootprint ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits ),
|
2021-07-19 23:56:05 +00:00
|
|
|
m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl,
|
|
|
|
m_SolderMaskMarginUnits ),
|
|
|
|
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl,
|
2021-08-06 14:26:08 +00:00
|
|
|
m_SolderPasteMarginUnits ),
|
|
|
|
m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl,
|
2022-10-11 23:38:01 +00:00
|
|
|
m_PasteMarginRatioUnits ),
|
|
|
|
m_gridSize( 0, 0 ),
|
|
|
|
m_lastRequestedSize( 0, 0 )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2022-11-30 03:35:59 +00:00
|
|
|
SetEvtHandlerEnabled( false );
|
2021-07-28 19:22:57 +00:00
|
|
|
// Create the 3D models page
|
|
|
|
m_3dPanel = new PANEL_FP_PROPERTIES_3D_MODEL( m_frame, m_footprint, this, m_NoteBook );
|
|
|
|
m_NoteBook->AddPage( m_3dPanel, _("3D Models"), false );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-12-22 21:43:41 +00:00
|
|
|
m_texts = new FP_TEXT_GRID_TABLE( m_frame );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayers = new PRIVATE_LAYERS_GRID_TABLE( m_frame );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
m_delayedErrorMessage = wxEmptyString;
|
2018-09-13 15:39:14 +00:00
|
|
|
m_delayedFocusCtrl = nullptr;
|
2018-03-28 17:14:04 +00:00
|
|
|
m_delayedFocusGrid = nullptr;
|
|
|
|
m_delayedFocusRow = -1;
|
|
|
|
m_delayedFocusColumn = -1;
|
2021-07-28 19:22:57 +00:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_UNKNOWN;
|
2011-09-11 11:38:01 +00:00
|
|
|
|
|
|
|
// Give an icon
|
2021-07-28 19:54:20 +00:00
|
|
|
wxIcon icon;
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_modedit ) );
|
2011-09-11 11:38:01 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
|
2018-03-28 17:14:04 +00: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 19:30:23 +00:00
|
|
|
|
2018-05-30 10:52:19 +00:00
|
|
|
m_itemsGrid->SetTable( m_texts );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->SetTable( m_privateLayers );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_itemsGrid->PushEventHandler( new GRID_TRICKS( m_itemsGrid ) );
|
2022-09-09 11:18:05 +00:00
|
|
|
m_privateLayersGrid->PushEventHandler( new GRID_TRICKS( m_privateLayersGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddLayer( aEvent );
|
|
|
|
} ) );
|
|
|
|
m_padGroupsGrid->PushEventHandler( new GRID_TRICKS( m_padGroupsGrid,
|
|
|
|
[this]( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
OnAddPadGroup( 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 );
|
2022-08-19 17:34:53 +00:00
|
|
|
m_padGroupsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
|
2021-07-28 15:40:35 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Show/hide columns according to the user's preference
|
2020-01-13 01:44:19 +00:00
|
|
|
m_itemsGrid->ShowHideColumns( m_frame->GetSettings()->m_FootprintTextShownColumns );
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2020-11-10 21:20:03 +00:00
|
|
|
m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2018-07-17 21:14:02 +00:00
|
|
|
// Set font sizes
|
2021-09-11 19:07:33 +00:00
|
|
|
wxFont infoFont = KIUI::GetInfoFont( this );
|
2019-08-21 14:31:52 +00:00
|
|
|
infoFont.SetStyle( wxFONTSTYLE_ITALIC );
|
2021-09-10 17:35:45 +00:00
|
|
|
m_staticTextInfoCopper->SetFont( infoFont );
|
|
|
|
m_staticTextInfoPaste->SetFont( infoFont );
|
2018-07-17 21:14:02 +00:00
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
if( static_cast<int>( m_page ) >= 0 )
|
2018-09-13 15:39:14 +00:00
|
|
|
m_NoteBook->SetSelection( (unsigned) m_page );
|
2015-02-02 16:43:34 +00:00
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
if( m_page == NOTEBOOK_PAGES::PAGE_GENERAL )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedFocusRow = 0;
|
|
|
|
m_delayedFocusColumn = 0;
|
2021-07-28 19:22:57 +00:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_GENERAL;
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2021-07-28 19:22:57 +00:00
|
|
|
else if( m_page == NOTEBOOK_PAGES::PAGE_CLEARANCES )
|
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
SetInitialFocus( m_NetClearanceCtrl );
|
2021-07-28 19:22:57 +00:00
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
m_solderPaste.SetNegativeZero();
|
|
|
|
|
|
|
|
m_solderPasteRatio.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_solderPasteRatio.SetNegativeZero();
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Configure button logos
|
2021-03-08 02:59:07 +00:00
|
|
|
m_bpAdd->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
|
|
|
m_bpDelete->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_bpAddLayer->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
|
|
|
m_bpDeleteLayer->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
|
2022-08-19 17:34:53 +00:00
|
|
|
m_bpAddPadGroup->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
|
|
|
|
m_bpRemovePadGroup->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
|
2016-07-18 15:54:41 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2022-11-30 03:35:59 +00:00
|
|
|
SetEvtHandlerEnabled( true );
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::~DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2023-04-13 12:45:22 +00:00
|
|
|
if( FOOTPRINT_EDITOR_SETTINGS* cfg = m_frame->GetSettings() )
|
|
|
|
cfg->m_FootprintTextShownColumns = m_itemsGrid->GetShownColumnsAsString();
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
// Prevents crash bug in wxGrid's d'tor
|
2018-05-30 10:52:19 +00:00
|
|
|
m_itemsGrid->DestroyTable( m_texts );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->DestroyTable( m_privateLayers );
|
2018-09-13 15:39:14 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Delete the GRID_TRICKS.
|
|
|
|
m_itemsGrid->PopEventHandler( true );
|
2021-12-05 21:56:55 +00:00
|
|
|
m_privateLayersGrid->PopEventHandler( true );
|
2022-09-09 11:18:05 +00:00
|
|
|
m_padGroupsGrid->PopEventHandler( true );
|
2016-02-21 00:54:34 +00:00
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
m_page = static_cast<NOTEBOOK_PAGES>( m_NoteBook->GetSelection() );
|
2016-06-14 10:08:35 +00:00
|
|
|
|
2021-07-28 19:22:57 +00: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 09:41:48 +00:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
LIB_ID fpID = m_footprint->GetFPID();
|
|
|
|
wxString footprintName = fpID.GetLibItemName();
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-09-13 15:39:14 +00:00
|
|
|
m_FootprintNameCtrl->ChangeValue( footprintName );
|
2014-02-10 09:30:08 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_DocCtrl->SetValue( m_footprint->GetDescription() );
|
|
|
|
m_KeywordCtrl->SetValue( m_footprint->GetKeywords() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !m_PanelGeneral->TransferDataToWindow() )
|
|
|
|
return false;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2021-07-28 19:54:20 +00:00
|
|
|
// Add the models to the panel
|
2021-07-28 19:22:57 +00:00
|
|
|
if( !m_3dPanel->TransferDataToWindow() )
|
2018-03-28 17:14:04 +00:00
|
|
|
return false;
|
2016-01-16 06:49:28 +00:00
|
|
|
|
2021-07-28 19:54:20 +00:00
|
|
|
// Footprint Texts
|
2018-03-28 17:14:04 +00:00
|
|
|
m_texts->push_back( m_footprint->Reference() );
|
|
|
|
m_texts->push_back( m_footprint->Value() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
for( BOARD_ITEM* item : m_footprint->GraphicalItems() )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item) )
|
2020-10-04 23:34:59 +00:00
|
|
|
m_texts->push_back( *textItem );
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2021-07-28 19:54:20 +00:00
|
|
|
// Notify the grid
|
2018-03-28 17:14:04 +00:00
|
|
|
wxGridTableMessage tmsg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_texts->GetNumberRows() );
|
|
|
|
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 21:43:38 +00:00
|
|
|
m_componentType->SetSelection( 0 );
|
2020-11-13 02:09:34 +00:00
|
|
|
else if( m_footprint->GetAttributes() & FP_SMD )
|
2020-08-26 21:43:38 +00: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 );
|
2021-12-07 19:24:26 +00:00
|
|
|
m_noCourtyards->SetValue( m_footprint->GetAttributes() & FP_ALLOW_MISSING_COURTYARD );
|
2023-04-10 17:10:42 +00:00
|
|
|
m_cbDNP->SetValue( m_footprint->GetAttributes() & FP_DNP );
|
2018-05-04 16:20:41 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Local Clearances
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_netClearance.SetValue( m_footprint->GetLocalClearance() );
|
|
|
|
m_solderMask.SetValue( m_footprint->GetLocalSolderMaskMargin() );
|
|
|
|
m_solderPaste.SetValue( m_footprint->GetLocalSolderPasteMargin() );
|
2021-08-06 14:26:08 +00:00
|
|
|
m_solderPasteRatio.SetDoubleValue( m_footprint->GetLocalSolderPasteMarginRatio() * 100.0 );
|
2021-08-12 16:58:30 +00:00
|
|
|
m_allowBridges->SetValue( m_footprint->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES );
|
2012-05-18 08:33:57 +00:00
|
|
|
|
2019-06-28 11:23:37 +00:00
|
|
|
switch( m_footprint->GetZoneConnection() )
|
|
|
|
{
|
|
|
|
default:
|
2021-07-28 19:54:20 +00: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 11:23:37 +00:00
|
|
|
}
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
for( const wxString& group : m_footprint->GetNetTiePadGroups() )
|
|
|
|
{
|
|
|
|
if( !group.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_padGroupsGrid->AppendRows( 1 );
|
|
|
|
m_padGroupsGrid->SetCellValue( m_padGroupsGrid->GetNumberRows() - 1, 0, group );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
// Items grid
|
2019-02-10 06:59:27 +00:00
|
|
|
for( int col = 0; col < m_itemsGrid->GetNumberCols(); col++ )
|
2019-02-10 08:49:42 +00:00
|
|
|
{
|
|
|
|
// Adjust min size to the column label size
|
2022-08-19 17:34:53 +00: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 17:34:53 +00:00
|
|
|
int col_size = m_itemsGrid->GetVisibleWidth( col );
|
2019-02-10 08:49:42 +00:00
|
|
|
|
2021-02-23 17:24:26 +00:00
|
|
|
if( col == FPT_LAYER ) // This one's a drop-down. Check all possible values.
|
|
|
|
{
|
|
|
|
BOARD* board = m_footprint->GetBoard();
|
|
|
|
|
|
|
|
for( PCB_LAYER_ID layer : board->GetEnabledLayers().Seq() )
|
|
|
|
col_size = std::max( col_size, GetTextExtent( board->GetLayerName( layer ) ).x );
|
|
|
|
|
|
|
|
// And the swatch:
|
2019-02-10 08:49:42 +00:00
|
|
|
col_size += 20;
|
2021-02-23 17:24:26 +00:00
|
|
|
}
|
2019-02-10 08:49:42 +00:00
|
|
|
|
2019-02-17 14:09:35 +00:00
|
|
|
if( m_itemsGrid->IsColShown( col ) )
|
|
|
|
m_itemsGrid->SetColSize( col, col_size );
|
2019-02-10 08:49:42 +00:00
|
|
|
}
|
2019-02-09 23:31:31 +00:00
|
|
|
|
|
|
|
m_itemsGrid->SetRowLabelSize( m_itemsGrid->GetVisibleWidth( -1, true, true, true ) );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
Layout();
|
2021-12-16 14:39:58 +00:00
|
|
|
adjustGridColumns();
|
2013-11-29 18:29:41 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
return true;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::checkFootprintName( const wxString& aFootprintName )
|
2018-09-13 15:39:14 +00:00
|
|
|
{
|
2019-07-02 16:00:00 +00:00
|
|
|
if( aFootprintName.IsEmpty() )
|
2018-09-13 15:39:14 +00:00
|
|
|
{
|
2019-07-02 16:00:00 +00: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 16:00:00 +00:00
|
|
|
{
|
2021-06-16 22:35:00 +00:00
|
|
|
m_delayedErrorMessage.Printf( _( "Footprint name may not contain '%s'." ),
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT::StringLibNameInvalidChars( true ) );
|
2018-09-13 15:39:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate()
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-19 16:10:14 +00:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
return false;
|
2018-03-28 17:14:04 +00: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 11:18:42 +00:00
|
|
|
wxString footprintName = m_FootprintNameCtrl->GetValue();
|
2013-11-29 18:29:41 +00:00
|
|
|
|
2018-09-13 15:39:14 +00:00
|
|
|
if( !checkFootprintName( footprintName ) )
|
2012-12-10 11:18:42 +00:00
|
|
|
{
|
2018-09-13 15:39:14 +00:00
|
|
|
if( m_NoteBook->GetSelection() != 0 )
|
|
|
|
m_NoteBook->SetSelection( 0 );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2018-09-13 15:39:14 +00:00
|
|
|
m_delayedFocusCtrl = m_FootprintNameCtrl;
|
2021-07-28 19:22:57 +00:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_GENERAL;
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for empty texts.
|
|
|
|
for( size_t i = 2; i < m_texts->size(); ++i )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT& text = m_texts->at( i );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
if( text.GetText().IsEmpty() )
|
2012-12-10 11:18:42 +00:00
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
if( m_NoteBook->GetSelection() != 0 )
|
|
|
|
m_NoteBook->SetSelection( 0 );
|
2012-12-10 11:18:42 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_delayedErrorMessage = _( "Text items must have some content." );
|
2018-11-12 17:07:22 +00:00
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
2021-02-02 23:16:37 +00:00
|
|
|
m_delayedFocusColumn = FPT_TEXT;
|
2018-03-28 17:14:04 +00:00
|
|
|
m_delayedFocusRow = i;
|
2016-08-05 19:30:23 +00:00
|
|
|
|
2022-10-05 16:42:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( text.GetTextWidth() < TEXTS_MIN_SIZE || text.GetTextWidth() > TEXTS_MAX_SIZE )
|
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedErrorMessage = wxString::Format( _( "The text width must be between %s and %s." ),
|
|
|
|
m_frame->StringFromValue( TEXTS_MIN_SIZE, true ),
|
|
|
|
m_frame->StringFromValue( TEXTS_MAX_SIZE, true ) );
|
|
|
|
m_delayedFocusColumn = FPT_WIDTH;
|
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( text.GetTextHeight() < TEXTS_MIN_SIZE || text.GetTextHeight() > TEXTS_MAX_SIZE )
|
|
|
|
{
|
|
|
|
m_delayedFocusGrid = m_itemsGrid;
|
|
|
|
m_delayedErrorMessage = wxString::Format( _( "The text height must be between %s and %s." ),
|
|
|
|
m_frame->StringFromValue( TEXTS_MIN_SIZE, true ),
|
|
|
|
m_frame->StringFromValue( TEXTS_MAX_SIZE, true ) );
|
|
|
|
m_delayedFocusColumn = FPT_HEIGHT;
|
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test for acceptable values for thickness and size and clamp if fails
|
|
|
|
int maxPenWidth = Clamp_Text_PenSize( text.GetTextThickness(), text.GetTextSize() );
|
|
|
|
|
|
|
|
if( text.GetTextThickness() > maxPenWidth )
|
|
|
|
{
|
|
|
|
m_itemsGrid->SetCellValue( i, FPT_THICKNESS,
|
|
|
|
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." );
|
|
|
|
m_delayedFocusColumn = FPT_THICKNESS;
|
|
|
|
m_delayedFocusRow = i;
|
|
|
|
|
2017-04-16 11:53:56 +00:00
|
|
|
return false;
|
2012-12-10 11:18:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_netClearance.Validate( 0, INT_MAX ) )
|
2018-03-28 17:14:04 +00:00
|
|
|
return false;
|
2018-02-14 16:46:35 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
if( !Validate() )
|
2018-02-14 16:46:35 +00:00
|
|
|
return false;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
if( !DIALOG_SHIM::TransferDataFromWindow() )
|
2017-04-16 11:53:56 +00:00
|
|
|
return false;
|
2016-08-05 19:30:23 +00:00
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges()
|
|
|
|
|| !m_privateLayersGrid->CommitPendingChanges()
|
|
|
|
|| !m_padGroupsGrid->CommitPendingChanges() )
|
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
return false;
|
2022-08-19 17:34:53 +00:00
|
|
|
}
|
2016-06-20 13:46:58 +00:00
|
|
|
|
2021-07-28 19:54:20 +00:00
|
|
|
// This only commits the editor, model updating is done below so it is inside
|
|
|
|
// the commit
|
2021-07-28 19:22:57 +00:00
|
|
|
if( !m_3dPanel->TransferDataFromWindow() )
|
2018-03-28 17:14:04 +00:00
|
|
|
return false;
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2021-12-05 21:56:55 +00:00
|
|
|
KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView();
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
2018-03-28 17:14:04 +00:00
|
|
|
commit.Modify( m_footprint );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
LIB_ID fpID = m_footprint->GetFPID();
|
2021-06-30 11:00:06 +00:00
|
|
|
fpID.SetLibItemName( m_FootprintNameCtrl->GetValue() );
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->SetFPID( fpID );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_footprint->SetDescription( m_DocCtrl->GetValue() );
|
|
|
|
m_footprint->SetKeywords( m_KeywordCtrl->GetValue() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// copy reference and value
|
|
|
|
m_footprint->Reference() = m_texts->at( 0 );
|
|
|
|
m_footprint->Value() = m_texts->at( 1 );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
size_t i = 2;
|
2023-03-30 11:49:23 +00:00
|
|
|
std::vector<PCB_TEXT*> items_to_remove;
|
2020-05-13 09:51:56 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* item : m_footprint->GraphicalItems() )
|
2017-04-16 11:53:56 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item );
|
2010-05-16 14:05:04 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
if( textItem )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
// copy grid table entries till we run out, then delete any remaining texts
|
|
|
|
if( i < m_texts->size() )
|
2020-10-04 23:34:59 +00:00
|
|
|
*textItem = m_texts->at( i++ );
|
2020-05-13 09:51:56 +00:00
|
|
|
else // store this item to remove and delete it later,
|
|
|
|
// after the graphic list is explored:
|
2020-10-04 23:34:59 +00:00
|
|
|
items_to_remove.push_back( textItem );
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2020-11-17 20:47:50 +00:00
|
|
|
// Remove text items:
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
2020-11-17 20:47:50 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
for( PCB_TEXT* item: items_to_remove )
|
2020-11-17 20:47:50 +00:00
|
|
|
{
|
|
|
|
selTool->RemoveItemFromSel( item );
|
|
|
|
view->Remove( item );
|
2020-05-13 09:51:56 +00:00
|
|
|
item->DeleteStructure();
|
2020-11-17 20:47:50 +00:00
|
|
|
}
|
2020-05-13 09:51:56 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// if there are still grid table entries, create new texts for them
|
|
|
|
while( i < m_texts->size() )
|
2018-05-04 16:20:41 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT* newText = new PCB_TEXT( m_texts->at( i++ ) );
|
2019-12-28 00:55:11 +00:00
|
|
|
m_footprint->Add( newText, ADD_MODE::APPEND );
|
2018-03-28 17:14:04 +00:00
|
|
|
view->Add( newText );
|
|
|
|
}
|
2018-05-04 16:20:41 +00: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 21:43:38 +00:00
|
|
|
int attributes = 0;
|
|
|
|
|
|
|
|
switch( m_componentType->GetSelection() )
|
2018-03-28 17:14:04 +00: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 16:20:41 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 21:43:38 +00:00
|
|
|
if( m_boardOnly->GetValue() )
|
2020-11-13 02:09:34 +00:00
|
|
|
attributes |= FP_BOARD_ONLY;
|
2020-08-26 21:43:38 +00:00
|
|
|
|
|
|
|
if( m_excludeFromPosFiles->GetValue() )
|
2020-11-13 02:09:34 +00:00
|
|
|
attributes |= FP_EXCLUDE_FROM_POS_FILES;
|
2020-08-26 21:43:38 +00:00
|
|
|
|
|
|
|
if( m_excludeFromBOM->GetValue() )
|
2020-11-13 02:09:34 +00:00
|
|
|
attributes |= FP_EXCLUDE_FROM_BOM;
|
2020-08-26 21:43:38 +00:00
|
|
|
|
2021-12-07 19:24:26 +00:00
|
|
|
if( m_noCourtyards->GetValue() )
|
|
|
|
attributes |= FP_ALLOW_MISSING_COURTYARD;
|
|
|
|
|
2023-04-10 17:10:42 +00:00
|
|
|
if( m_cbDNP->GetValue() )
|
|
|
|
attributes |= FP_DNP;
|
|
|
|
|
2021-08-12 16:58:30 +00:00
|
|
|
if( m_allowBridges->GetValue() )
|
|
|
|
attributes |= FP_ALLOW_SOLDERMASK_BRIDGES;
|
|
|
|
|
2020-08-26 21:43:38 +00:00
|
|
|
m_footprint->SetAttributes( attributes );
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Initialize masks clearances
|
|
|
|
m_footprint->SetLocalClearance( m_netClearance.GetValue() );
|
|
|
|
m_footprint->SetLocalSolderMaskMargin( m_solderMask.GetValue() );
|
|
|
|
m_footprint->SetLocalSolderPasteMargin( m_solderPaste.GetValue() );
|
2021-08-06 14:26:08 +00:00
|
|
|
m_footprint->SetLocalSolderPasteMarginRatio( m_solderPasteRatio.GetDoubleValue() / 100.0 );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2019-06-28 11:23:37 +00:00
|
|
|
switch( m_ZoneConnectionChoice->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
2020-08-26 21:43:38 +00:00
|
|
|
case 0: m_footprint->SetZoneConnection( ZONE_CONNECTION::INHERITED ); break;
|
|
|
|
case 1: m_footprint->SetZoneConnection( ZONE_CONNECTION::FULL ); break;
|
|
|
|
case 2: m_footprint->SetZoneConnection( ZONE_CONNECTION::THERMAL ); break;
|
|
|
|
case 3: m_footprint->SetZoneConnection( ZONE_CONNECTION::NONE ); break;
|
2019-06-28 11:23:37 +00:00
|
|
|
}
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
m_footprint->ClearNetTiePadGroups();
|
|
|
|
|
|
|
|
for( int ii = 0; ii < m_padGroupsGrid->GetNumberRows(); ++ii )
|
|
|
|
{
|
|
|
|
wxString group = m_padGroupsGrid->GetCellValue( ii, 0 );
|
|
|
|
|
|
|
|
if( !group.IsEmpty() )
|
|
|
|
m_footprint->AddNetTiePadGroup( group );
|
|
|
|
}
|
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
// Copy the models from the panel to the footprint
|
|
|
|
std::vector<FP_3DMODEL>& panelList = m_3dPanel->GetModelList();
|
2021-07-11 11:49:36 +00:00
|
|
|
std::vector<FP_3DMODEL>* fpList = &m_footprint->Models();
|
2021-07-28 19:22:57 +00:00
|
|
|
fpList->clear();
|
|
|
|
fpList->insert( fpList->end(), panelList.begin(), panelList.end() );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2020-11-13 11:17:15 +00:00
|
|
|
commit.Push( _( "Modify footprint properties" ) );
|
2009-08-11 10:27:21 +00:00
|
|
|
|
2017-04-16 11:53:56 +00:00
|
|
|
return true;
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
static bool footprintIsFromBoard( FOOTPRINT* aFootprint )
|
2018-09-13 15:39:14 +00:00
|
|
|
{
|
2020-02-20 12:11:04 +00:00
|
|
|
return aFootprint->GetLink() != niluuid;
|
2018-09-13 15:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnFootprintNameText( wxCommandEvent& event )
|
2018-09-13 15:39:14 +00:00
|
|
|
{
|
|
|
|
if( !footprintIsFromBoard( m_footprint ) )
|
|
|
|
{
|
2019-10-09 16:53:41 +00:00
|
|
|
// Currently: nothing to do
|
2018-09-13 15:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField( wxCommandEvent& event )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-19 16:10:14 +00:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
2023-03-30 11:49:23 +00:00
|
|
|
PCB_TEXT textItem( m_footprint );
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
// Set active layer if legal; otherwise copy layer from previous text item
|
|
|
|
if( LSET::AllTechMask().test( m_frame->GetActiveLayer() ) )
|
2020-10-04 23:34:59 +00:00
|
|
|
textItem.SetLayer( m_frame->GetActiveLayer() );
|
2018-03-28 17:14:04 +00:00
|
|
|
else
|
2020-10-04 23:34:59 +00:00
|
|
|
textItem.SetLayer( m_texts->at( m_texts->size() - 1 ).GetLayer() );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
textItem.SetTextSize( dsnSettings.GetTextSize( textItem.GetLayer() ) );
|
|
|
|
textItem.SetTextThickness( dsnSettings.GetTextThickness( textItem.GetLayer() ) );
|
|
|
|
textItem.SetItalic( dsnSettings.GetTextItalic( textItem.GetLayer() ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
m_texts->push_back( textItem );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
|
|
|
|
m_itemsGrid->ProcessTableMessage( msg );
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
m_itemsGrid->SetFocus();
|
|
|
|
m_itemsGrid->MakeCellVisible( m_texts->size() - 1, 0 );
|
|
|
|
m_itemsGrid->SetGridCursor( m_texts->size() - 1, 0 );
|
|
|
|
|
|
|
|
m_itemsGrid->EnableCellEditControl( true );
|
|
|
|
m_itemsGrid->ShowCellEditControl();
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteField( wxCommandEvent& event )
|
2009-08-11 10:27:21 +00:00
|
|
|
{
|
2018-08-19 16:10:14 +00:00
|
|
|
if( !m_itemsGrid->CommitPendingChanges() )
|
2018-03-28 17:14:04 +00:00
|
|
|
return;
|
2018-01-14 13:24:58 +00:00
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
wxArrayInt selectedRows = m_itemsGrid->GetSelectedRows();
|
2018-08-19 16:10:14 +00: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 16:10:14 +00:00
|
|
|
return;
|
2021-12-12 17:27:40 +00:00
|
|
|
|
|
|
|
for( int row : selectedRows )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2021-12-12 17:27:40 +00:00
|
|
|
if( row < 2 )
|
|
|
|
{
|
|
|
|
DisplayError( nullptr, _( "Reference and value are mandatory." ) );
|
|
|
|
return;
|
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
// Reverse sort so deleting a row doesn't change the indexes of the other rows.
|
|
|
|
selectedRows.Sort( []( int* first, int* second ) { return *second - *first; } );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-12-12 17:27:40 +00:00
|
|
|
for( int row : selectedRows )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2021-12-12 17:27:40 +00:00
|
|
|
m_texts->erase( m_texts->begin() + row );
|
|
|
|
|
|
|
|
// notify the grid
|
|
|
|
wxGridTableMessage msg( m_texts, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
|
|
|
|
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 17:14:04 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
}
|
2016-02-27 23:17:58 +00: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;
|
|
|
|
|
|
|
|
while( alg::contains( *m_privateLayers, nextLayer ) && nextLayer < User_9 )
|
|
|
|
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();
|
|
|
|
m_privateLayersGrid->MakeCellVisible( m_privateLayers->size() - 1, 0 );
|
|
|
|
m_privateLayersGrid->SetGridCursor( m_privateLayers->size() - 1, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnDeleteLayer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !m_privateLayersGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int curRow = m_privateLayersGrid->GetGridCursorRow();
|
|
|
|
|
|
|
|
if( curRow < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
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 ),
|
|
|
|
m_privateLayersGrid->GetGridCursorCol() );
|
|
|
|
m_privateLayersGrid->SetGridCursor( std::max( 0, curRow-1 ),
|
|
|
|
m_privateLayersGrid->GetGridCursorCol() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddPadGroup( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !m_padGroupsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_padGroupsGrid->AppendRows( 1 );
|
|
|
|
|
|
|
|
m_padGroupsGrid->SetFocus();
|
|
|
|
m_padGroupsGrid->MakeCellVisible( m_padGroupsGrid->GetNumberRows() - 1, 0 );
|
|
|
|
m_padGroupsGrid->SetGridCursor( m_padGroupsGrid->GetNumberRows() - 1, 0 );
|
|
|
|
|
|
|
|
m_padGroupsGrid->EnableCellEditControl( true );
|
|
|
|
m_padGroupsGrid->ShowCellEditControl();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnRemovePadGroup( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !m_padGroupsGrid->CommitPendingChanges() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxArrayInt selectedRows = m_padGroupsGrid->GetSelectedRows();
|
|
|
|
int curRow = m_padGroupsGrid->GetGridCursorRow();
|
|
|
|
|
|
|
|
if( selectedRows.empty() && curRow >= 0 && curRow < m_padGroupsGrid->GetNumberRows() )
|
|
|
|
selectedRows.Add( curRow );
|
|
|
|
|
|
|
|
for( int ii = selectedRows.Count() - 1; ii >= 0; --ii )
|
|
|
|
{
|
|
|
|
int row = selectedRows.Item( ii );
|
|
|
|
m_padGroupsGrid->DeleteRows( row, 1 );
|
|
|
|
curRow = std::min( curRow, row );
|
|
|
|
}
|
|
|
|
|
|
|
|
curRow = std::max( 0, curRow - 1 );
|
|
|
|
m_padGroupsGrid->MakeCellVisible( curRow, m_padGroupsGrid->GetGridCursorCol() );
|
|
|
|
m_padGroupsGrid->SetGridCursor( curRow, m_padGroupsGrid->GetGridCursorCol() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-16 14:39:58 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::adjustGridColumns()
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
// Account for scroll bars
|
2021-12-16 14:39:58 +00:00
|
|
|
int itemsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_itemsGrid ).x;
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
itemsWidth -= m_itemsGrid->GetRowLabelSize();
|
|
|
|
|
|
|
|
for( int i = 1; i < m_itemsGrid->GetNumberCols(); i++ )
|
|
|
|
itemsWidth -= m_itemsGrid->GetColSize( i );
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
m_itemsGrid->SetColSize( 0, std::max( itemsWidth,
|
|
|
|
m_itemsGrid->GetVisibleWidth( 0, true, false ) ) );
|
|
|
|
|
|
|
|
// Update the width private layers grid
|
|
|
|
m_privateLayersGrid->SetColSize( 0, std::max( m_privateLayersGrid->GetClientSize().x,
|
|
|
|
m_privateLayersGrid->GetVisibleWidth( 0 ) ) );
|
|
|
|
|
|
|
|
// Update the width net tie pad groups grid
|
|
|
|
m_padGroupsGrid->SetColSize( 0, std::max( m_padGroupsGrid->GetClientSize().x,
|
|
|
|
m_padGroupsGrid->GetVisibleWidth( 0 ) ) );
|
2021-07-28 15:40:35 +00:00
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
// Update the width of the 3D panel
|
2021-12-16 14:39:58 +00:00
|
|
|
m_3dPanel->AdjustGridColumnWidths();
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-04 09:41:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2018-09-13 15:39:14 +00: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 19:22:57 +00:00
|
|
|
if( static_cast<int>( m_delayedFocusPage ) >= 0 )
|
2018-09-13 15:39:14 +00:00
|
|
|
{
|
2021-07-28 19:22:57 +00:00
|
|
|
if( m_NoteBook->GetSelection() != static_cast<int>( m_delayedFocusPage ) )
|
2021-12-13 20:46:13 +00:00
|
|
|
m_NoteBook->ChangeSelection( static_cast<int>( m_delayedFocusPage ) );
|
2018-11-20 22:58:40 +00:00
|
|
|
|
2021-07-28 19:22:57 +00:00
|
|
|
m_delayedFocusPage = NOTEBOOK_PAGES::PAGE_UNKNOWN;
|
2018-09-13 15:39:14 +00: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 17:14:04 +00:00
|
|
|
|
2018-09-13 15:39:14 +00: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 15:39:14 +00:00
|
|
|
|
|
|
|
m_delayedFocusCtrl = nullptr;
|
|
|
|
}
|
|
|
|
else if( m_delayedFocusGrid )
|
|
|
|
{
|
2018-03-28 17:14:04 +00:00
|
|
|
m_delayedFocusGrid->SetFocus();
|
|
|
|
m_delayedFocusGrid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
|
|
|
|
m_delayedFocusGrid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn );
|
|
|
|
|
|
|
|
m_delayedFocusGrid->EnableCellEditControl( true );
|
|
|
|
m_delayedFocusGrid->ShowCellEditControl();
|
|
|
|
|
2018-09-13 15:39:14 +00:00
|
|
|
m_delayedFocusGrid = nullptr;
|
2018-03-28 17:14:04 +00:00
|
|
|
m_delayedFocusRow = -1;
|
|
|
|
m_delayedFocusColumn = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-11 23:38:01 +00:00
|
|
|
void DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnGridSize( wxSizeEvent& aEvent )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2022-10-11 23:38:01 +00: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 17:14:04 +00:00
|
|
|
|
2022-10-11 23:38:01 +00:00
|
|
|
// Always propagate for a grid repaint (needed if the height changes, as well as width)
|
|
|
|
aEvent.Skip();
|
2016-02-27 23:17:58 +00:00
|
|
|
}
|