2012-03-20 20:22:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-02-23 11:31:00 +00:00
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-03-30 09:28:59 +00:00
|
|
|
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
|
2021-07-19 23:56:05 +00:00
|
|
|
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@gmail.com>
|
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-03-20 20:22:38 +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-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2018-02-03 23:22:45 +00:00
|
|
|
#include <bitmaps.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <board_commit.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <confirm.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h> // for enum RECT_CHAMFER_POSITIONS definition
|
2020-10-26 00:09:42 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
2016-04-06 18:15:49 +00:00
|
|
|
#include <dialog_pad_properties.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2021-09-14 18:26:03 +00:00
|
|
|
#include <dialogs/html_message_box.h>
|
2020-04-24 23:44:09 +00:00
|
|
|
#include <macros.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2021-01-12 16:27:08 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcb_painter.h>
|
|
|
|
#include <pcbnew_settings.h>
|
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <view/view_controls.h>
|
|
|
|
#include <widgets/net_selector.h>
|
2020-05-03 07:59:05 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2020-06-27 11:57:40 +00:00
|
|
|
#include <tools/pad_tool.h>
|
2020-01-06 17:11:01 +00:00
|
|
|
#include <advanced_config.h> // for pad property feature management
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/choicdlg.h>
|
2020-01-06 17:11:01 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
// list of pad shapes, ordered like the pad shape wxChoice in dialog.
|
2021-05-01 12:22:35 +00:00
|
|
|
static PAD_SHAPE code_shape[] =
|
2018-05-23 06:11:47 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
PAD_SHAPE::CIRCLE,
|
|
|
|
PAD_SHAPE::OVAL,
|
|
|
|
PAD_SHAPE::RECT,
|
|
|
|
PAD_SHAPE::TRAPEZOID,
|
|
|
|
PAD_SHAPE::ROUNDRECT,
|
|
|
|
PAD_SHAPE::CHAMFERED_RECT,
|
|
|
|
PAD_SHAPE::CHAMFERED_RECT, // choice = CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT
|
|
|
|
PAD_SHAPE::CUSTOM, // choice = CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR
|
|
|
|
PAD_SHAPE::CUSTOM // choice = PAD_SHAPE::CUSTOM_RECT_ANCHOR
|
2016-04-06 18:15:49 +00:00
|
|
|
};
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
// the ordered index of the pad shape wxChoice in dialog.
|
|
|
|
// keep it consistent with code_shape[] and dialog strings
|
2018-05-23 06:11:47 +00:00
|
|
|
enum CODE_CHOICE
|
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
CHOICE_SHAPE_CIRCLE = 0,
|
|
|
|
CHOICE_SHAPE_OVAL,
|
|
|
|
CHOICE_SHAPE_RECT,
|
|
|
|
CHOICE_SHAPE_TRAPEZOID,
|
|
|
|
CHOICE_SHAPE_ROUNDRECT,
|
2018-08-29 07:13:07 +00:00
|
|
|
CHOICE_SHAPE_CHAMFERED_RECT,
|
2020-06-04 15:07:23 +00:00
|
|
|
CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT,
|
2017-01-13 17:51:22 +00:00
|
|
|
CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR,
|
|
|
|
CHOICE_SHAPE_CUSTOM_RECT_ANCHOR
|
2008-11-22 11:10:40 +00:00
|
|
|
};
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
static PAD_ATTRIB code_type[] =
|
2018-05-23 06:11:47 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
PAD_ATTRIB::PTH,
|
|
|
|
PAD_ATTRIB::SMD,
|
|
|
|
PAD_ATTRIB::CONN,
|
|
|
|
PAD_ATTRIB::NPTH,
|
|
|
|
PAD_ATTRIB::SMD // Aperture pad :type SMD with no copper layers,
|
2019-11-17 17:20:19 +00:00
|
|
|
// only on tech layers (usually only on paste layer
|
2008-11-22 11:10:40 +00:00
|
|
|
};
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
// These define have the same value as the m_PadType wxChoice GetSelected() return value
|
2020-11-04 12:13:08 +00:00
|
|
|
#define PTH_DLG_TYPE 0
|
|
|
|
#define SMD_DLG_TYPE 1
|
|
|
|
#define CONN_DLG_TYPE 2
|
|
|
|
#define NPTH_DLG_TYPE 3
|
|
|
|
#define APERTURE_DLG_TYPE 4
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
void PCB_BASE_FRAME::ShowPadPropertiesDialog( PAD* aPad )
|
2014-04-24 18:54:49 +00:00
|
|
|
{
|
|
|
|
DIALOG_PAD_PROPERTIES dlg( this, aPad );
|
2020-05-03 07:59:05 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
dlg.ShowQuasiModal();
|
2014-04-24 18:54:49 +00:00
|
|
|
}
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad ) :
|
2021-08-06 14:26:08 +00:00
|
|
|
DIALOG_PAD_PROPERTIES_BASE( aParent ),
|
|
|
|
m_parent( aParent ),
|
|
|
|
m_canUpdate( false ),
|
|
|
|
m_posX( aParent, m_posXLabel, m_posXCtrl, m_posXUnits ),
|
|
|
|
m_posY( aParent, m_posYLabel, m_posYCtrl, m_posYUnits ),
|
|
|
|
m_sizeX( aParent, m_sizeXLabel, m_sizeXCtrl, m_sizeXUnits ),
|
|
|
|
m_sizeY( aParent, m_sizeYLabel, m_sizeYCtrl, m_sizeYUnits ),
|
|
|
|
m_offsetX( aParent, m_offsetXLabel, m_offsetXCtrl, m_offsetXUnits ),
|
|
|
|
m_offsetY( aParent, m_offsetYLabel, m_offsetYCtrl, m_offsetYUnits ),
|
|
|
|
m_padToDie( aParent, m_padToDieLabel, m_padToDieCtrl, m_padToDieUnits ),
|
|
|
|
m_trapDelta( aParent, m_trapDeltaLabel, m_trapDeltaCtrl, m_trapDeltaUnits ),
|
|
|
|
m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits ),
|
|
|
|
m_cornerRatio( aParent, m_cornerRatioLabel, m_cornerRatioCtrl, m_cornerRatioUnits ),
|
|
|
|
m_chamferRatio( aParent, m_chamferRatioLabel, m_chamferRatioCtrl, m_chamferRatioUnits ),
|
|
|
|
m_mixedCornerRatio( aParent, m_mixedCornerRatioLabel, m_mixedCornerRatioCtrl,
|
|
|
|
m_mixedCornerRatioUnits ),
|
|
|
|
m_mixedChamferRatio( aParent, m_mixedChamferRatioLabel, m_mixedChamferRatioCtrl,
|
|
|
|
m_mixedChamferRatioUnits ),
|
|
|
|
m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits ),
|
|
|
|
m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits ),
|
|
|
|
m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits ),
|
|
|
|
m_maskMargin( aParent, m_maskMarginLabel, m_maskMarginCtrl, m_maskMarginUnits ),
|
|
|
|
m_pasteMargin( aParent, m_pasteMarginLabel, m_pasteMarginCtrl, m_pasteMarginUnits ),
|
|
|
|
m_pasteMarginRatio( aParent, m_pasteMarginRatioLabel, m_pasteMarginRatioCtrl,
|
|
|
|
m_pasteMarginRatioUnits ),
|
|
|
|
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits ),
|
2021-10-30 09:56:24 +00:00
|
|
|
m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits ),
|
|
|
|
m_pad_orientation( aParent, m_PadOrientText, m_cb_padrotation, m_orientationUnits )
|
2012-02-19 04:02:19 +00:00
|
|
|
{
|
2020-12-31 09:53:14 +00:00
|
|
|
SetName( PAD_PROPERTIES_DLG_NAME );
|
2021-01-12 16:27:08 +00:00
|
|
|
m_isFpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( aParent ) != nullptr;
|
2020-12-31 09:53:14 +00:00
|
|
|
|
2014-03-14 07:37:04 +00:00
|
|
|
m_currentPad = aPad; // aPad can be NULL, if the dialog is called
|
2016-04-06 18:15:49 +00:00
|
|
|
// from the footprint editor to set default pad setup
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2013-03-30 09:28:59 +00:00
|
|
|
m_board = m_parent->GetBoard();
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2020-07-06 14:41:29 +00:00
|
|
|
// Configure display origin transforms
|
|
|
|
m_posX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
|
|
|
|
m_posY.SetCoordType( ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
m_padNetSelector->SetBoard( m_board );
|
|
|
|
m_padNetSelector->SetNetInfo( &m_board->GetNetInfo() );
|
2018-05-23 06:11:47 +00:00
|
|
|
|
|
|
|
m_cbShowPadOutline->SetValue( m_sketchPreview );
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
m_FlippedWarningIcon->SetBitmap( KiBitmap( BITMAPS::dialog_warning ) );
|
|
|
|
m_nonCopperWarningIcon->SetBitmap( KiBitmap( BITMAPS::dialog_warning ) );
|
2018-05-04 16:20:41 +00:00
|
|
|
|
2021-06-06 19:03:10 +00:00
|
|
|
m_padMaster = m_parent->GetDesignSettings().m_Pad_Master.get();
|
2021-07-19 23:56:05 +00:00
|
|
|
m_dummyPad = new PAD( (FOOTPRINT*) nullptr );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
if( aPad )
|
2018-09-27 16:46:51 +00:00
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
SetTitle( _( "Pad Properties" ) );
|
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
*m_dummyPad = *aPad;
|
2020-06-27 16:06:01 +00:00
|
|
|
m_dummyPad->ClearFlags( SELECTED|BRIGHTENED );
|
2018-09-27 16:46:51 +00:00
|
|
|
}
|
2021-04-25 13:47:46 +00:00
|
|
|
else
|
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
SetTitle( _( "Default Pad Properties for Add Pad Tool" ) );
|
|
|
|
|
2016-05-31 08:27:52 +00:00
|
|
|
*m_dummyPad = *m_padMaster;
|
2021-04-25 13:47:46 +00:00
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
if( m_isFpEditor )
|
|
|
|
{
|
|
|
|
m_padNetLabel->Show( false );
|
|
|
|
m_padNetSelector->Show( false );
|
|
|
|
}
|
|
|
|
|
2020-10-18 19:27:30 +00:00
|
|
|
// Pad needs to have a parent for painting; use the parent board for its design settings
|
|
|
|
if( !m_dummyPad->GetParent() )
|
|
|
|
m_dummyPad->SetParent( m_board );
|
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatio.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_chamferRatio.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_mixedCornerRatio.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_mixedChamferRatio.SetUnits( EDA_UNITS::PERCENT );
|
2021-10-30 09:56:24 +00:00
|
|
|
m_pad_orientation.SetUnits( EDA_UNITS::DEGREES );
|
|
|
|
m_pad_orientation.SetPrecision( 3 );
|
2021-08-06 14:26:08 +00:00
|
|
|
|
|
|
|
m_pasteMargin.SetNegativeZero();
|
|
|
|
|
|
|
|
m_pasteMarginRatio.SetUnits( EDA_UNITS::PERCENT );
|
|
|
|
m_pasteMarginRatio.SetNegativeZero();
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
initValues();
|
|
|
|
|
2021-09-11 19:07:33 +00:00
|
|
|
wxFont infoFont = KIUI::GetInfoFont( this );
|
2020-08-23 17:11:47 +00:00
|
|
|
m_copperLayersLabel->SetFont( infoFont );
|
2018-07-18 16:59:05 +00:00
|
|
|
m_techLayersLabel->SetFont( infoFont );
|
2020-09-08 23:39:33 +00:00
|
|
|
m_parentInfo->SetFont( infoFont );
|
2019-08-21 14:31:52 +00:00
|
|
|
|
|
|
|
infoFont.SetStyle( wxFONTSTYLE_ITALIC );
|
2019-12-11 10:36:45 +00:00
|
|
|
m_nonCopperNote->SetFont( infoFont );
|
|
|
|
m_staticTextInfoPaste->SetFont( infoFont );
|
2018-05-04 16:20:41 +00:00
|
|
|
m_staticTextInfoNegVal->SetFont( infoFont );
|
|
|
|
m_staticTextInfoPosValue->SetFont( infoFont );
|
2020-06-01 16:05:40 +00:00
|
|
|
m_staticTextPrimitiveListWarning->SetFont( infoFont );
|
2018-05-04 16:20:41 +00:00
|
|
|
|
2021-01-11 19:23:26 +00:00
|
|
|
// Do not allow locking items in the footprint editor
|
2021-01-12 16:27:08 +00:00
|
|
|
m_locked->Show( !m_isFpEditor );
|
2021-01-11 19:23:26 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
// Usually, TransferDataToWindow is called by OnInitDialog
|
2018-08-19 16:11:58 +00:00
|
|
|
// calling it here fixes all widget sizes so FinishDialogSettings can safely fix minsizes
|
2017-01-13 17:51:22 +00:00
|
|
|
TransferDataToWindow();
|
|
|
|
|
2017-09-28 07:57:46 +00:00
|
|
|
// Initialize canvas to be able to display the dummy pad:
|
|
|
|
prepareCanvas();
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
SetInitialFocus( m_padNumCtrl );
|
2017-01-13 17:51:22 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
|
|
|
m_canUpdate = true;
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
m_padNetSelector->Connect( NET_SELECTED,
|
2021-07-19 23:56:05 +00:00
|
|
|
wxCommandEventHandler( DIALOG_PAD_PROPERTIES::OnValuesChanged ),
|
|
|
|
nullptr, this );
|
2018-08-19 16:11:58 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2020-06-01 16:05:40 +00:00
|
|
|
|
2021-11-24 08:44:13 +00:00
|
|
|
// Update widgets
|
|
|
|
wxUpdateUIEvent dummyUI;
|
|
|
|
OnUpdateUI( dummyUI );
|
|
|
|
|
|
|
|
// Post a dummy size event to force the pad preview panel to update the
|
|
|
|
// view: actual size, best zoom ... after the frame is shown
|
|
|
|
PostSizeEvent();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 16:11:58 +00:00
|
|
|
|
|
|
|
DIALOG_PAD_PROPERTIES::~DIALOG_PAD_PROPERTIES()
|
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
m_padNetSelector->Disconnect( NET_SELECTED,
|
2021-07-19 23:56:05 +00:00
|
|
|
wxCommandEventHandler( DIALOG_PAD_PROPERTIES::OnValuesChanged ),
|
|
|
|
nullptr, this );
|
2018-08-19 16:11:58 +00:00
|
|
|
|
|
|
|
delete m_dummyPad;
|
|
|
|
delete m_axisOrigin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Store the pad draw option during a session.
|
|
|
|
bool DIALOG_PAD_PROPERTIES::m_sketchPreview = false;
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnInitDialog( wxInitDialogEvent& event )
|
|
|
|
{
|
2018-01-13 16:05:09 +00:00
|
|
|
m_selectedColor = COLOR4D( 1.0, 1.0, 1.0, 0.7 );
|
2017-12-26 19:46:52 +00:00
|
|
|
|
|
|
|
// Needed on some WM to be sure the pad is redrawn according to the final size
|
|
|
|
// of the canvas, with the right zoom factor
|
|
|
|
redraw();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 13:37:20 +00:00
|
|
|
|
2017-11-07 17:33:13 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnCancel( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Mandatory to avoid m_panelShowPadGal trying to draw something
|
|
|
|
// in a non valid context during closing process:
|
2020-06-05 18:07:23 +00:00
|
|
|
m_padPreviewGAL->StopDrawing();
|
2017-11-07 17:33:13 +00:00
|
|
|
|
|
|
|
// Now call default handler for wxID_CANCEL command event
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 13:37:20 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::enablePrimitivePage( bool aEnable )
|
|
|
|
{
|
|
|
|
// Enable or disable the widgets in page managing custom shape primitives
|
|
|
|
m_listCtrlPrimitives->Enable( aEnable );
|
|
|
|
m_buttonDel->Enable( aEnable );
|
|
|
|
m_buttonEditShape->Enable( aEnable );
|
|
|
|
m_buttonAddShape->Enable( aEnable );
|
|
|
|
m_buttonDup->Enable( aEnable );
|
|
|
|
m_buttonGeometry->Enable( aEnable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::prepareCanvas()
|
|
|
|
{
|
2019-05-30 09:16:05 +00:00
|
|
|
// Initialize the canvas to display the pad
|
2020-08-31 17:47:44 +00:00
|
|
|
m_padPreviewGAL = new PCB_DRAW_PANEL_GAL( m_boardViewPanel, -1, wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
m_parent->GetGalDisplayOptions(),
|
2020-11-04 20:58:40 +00:00
|
|
|
m_parent->GetCanvas()->GetBackend() );
|
2020-06-05 18:07:23 +00:00
|
|
|
|
|
|
|
m_padPreviewSizer->Add( m_padPreviewGAL, 12, wxEXPAND | wxALL, 5 );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Show the X and Y axis. It is useful because pad shape can have an offset
|
2016-07-19 09:16:16 +00:00
|
|
|
// or be a complex shape.
|
2017-01-13 17:51:22 +00:00
|
|
|
KIGFX::COLOR4D axis_color = LIGHTBLUE;
|
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
m_axisOrigin = new KIGFX::ORIGIN_VIEWITEM( axis_color, KIGFX::ORIGIN_VIEWITEM::CROSS,
|
2016-07-19 09:16:16 +00:00
|
|
|
Millimeter2iu( 0.2 ),
|
|
|
|
VECTOR2D( m_dummyPad->GetPosition() ) );
|
2016-02-13 15:34:52 +00:00
|
|
|
m_axisOrigin->SetDrawAtZero( true );
|
|
|
|
|
2020-06-05 18:07:23 +00:00
|
|
|
m_padPreviewGAL->UpdateColors();
|
|
|
|
m_padPreviewGAL->SetStealsFocus( false );
|
2020-08-23 17:11:47 +00:00
|
|
|
m_padPreviewGAL->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-08-23 17:11:47 +00:00
|
|
|
KIGFX::VIEW_CONTROLS* parentViewControls = m_parent->GetCanvas()->GetViewControls();
|
|
|
|
m_padPreviewGAL->GetViewControls()->ApplySettings( parentViewControls->GetSettings() );
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2020-06-05 18:07:23 +00:00
|
|
|
m_padPreviewGAL->Show();
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2020-06-05 18:07:23 +00:00
|
|
|
KIGFX::VIEW* view = m_padPreviewGAL->GetView();
|
2019-05-27 16:16:54 +00:00
|
|
|
|
|
|
|
// fix the pad render mode (filled/not filled)
|
|
|
|
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
|
|
|
bool sketchMode = m_cbShowPadOutline->IsChecked();
|
|
|
|
settings->SetSketchMode( LAYER_PADS_TH, sketchMode );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_FR, sketchMode );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_BK, sketchMode );
|
|
|
|
settings->SetSketchModeGraphicItems( sketchMode );
|
|
|
|
|
2020-08-23 17:11:47 +00:00
|
|
|
settings->SetHighContrast( false );
|
2020-09-02 20:56:31 +00:00
|
|
|
settings->SetContrastModeDisplay( HIGH_CONTRAST_MODE::NORMAL );
|
2020-08-23 17:11:47 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid:
|
|
|
|
double gridsize = 0.001 * IU_PER_MM;
|
|
|
|
view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// And do not show the grid:
|
|
|
|
view->GetGAL()->SetGridVisibility( false );
|
|
|
|
view->Add( m_dummyPad );
|
|
|
|
view->Add( m_axisOrigin );
|
|
|
|
|
2020-06-05 18:07:23 +00:00
|
|
|
m_padPreviewGAL->StartDrawing();
|
2019-05-27 16:16:54 +00:00
|
|
|
Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues()
|
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
// Note: use ChangeValue() to avoid generating a wxEVT_TEXT event
|
2021-11-24 08:44:13 +00:00
|
|
|
m_cornerRadius.ChangeValue( m_dummyPad->GetRoundRectCornerRadius() );
|
2018-05-23 06:11:47 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatio.ChangeDoubleValue( m_dummyPad->GetRoundRectRadiusRatio() * 100.0 );
|
|
|
|
m_mixedCornerRatio.ChangeDoubleValue( m_dummyPad->GetRoundRectRadiusRatio() * 100.0 );
|
2021-04-25 13:19:00 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
m_chamferRatio.ChangeDoubleValue( m_dummyPad->GetChamferRectRatio() * 100.0 );
|
|
|
|
m_mixedChamferRatio.ChangeDoubleValue( m_dummyPad->GetChamferRectRatio() * 100.0 );
|
2016-04-06 18:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-09 19:19:21 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onCornerRadiusChange( wxCommandEvent& event )
|
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_dummyPad->GetShape() != PAD_SHAPE::ROUNDRECT &&
|
|
|
|
m_dummyPad->GetShape() != PAD_SHAPE::CHAMFERED_RECT )
|
2018-09-09 19:19:21 +00:00
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
return;
|
2019-04-04 13:25:22 +00:00
|
|
|
}
|
2018-09-09 19:19:21 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
if( m_cornerRadius.GetValue() < 0 )
|
|
|
|
m_cornerRadiusCtrl->ChangeValue( "0" );
|
|
|
|
|
2019-04-04 13:25:22 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2021-08-06 14:26:08 +00:00
|
|
|
m_dummyPad->SetRoundRectCornerRadius( m_cornerRadius.GetValue() );
|
2018-09-09 19:19:21 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatio.ChangeDoubleValue( m_dummyPad->GetRoundRectRadiusRatio() * 100.0 );
|
|
|
|
m_mixedCornerRatio.ChangeDoubleValue( m_dummyPad->GetRoundRectRadiusRatio() * 100.0 );
|
2020-08-23 17:11:47 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2018-09-09 19:19:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event )
|
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_dummyPad->GetShape() != PAD_SHAPE::ROUNDRECT &&
|
|
|
|
m_dummyPad->GetShape() != PAD_SHAPE::CHAMFERED_RECT )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
return;
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
wxObject* ctrl = event.GetEventObject();
|
|
|
|
wxString value = event.GetString();
|
|
|
|
bool changed = false;
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
if( ctrl == m_cornerRatioCtrl || ctrl == m_mixedCornerRatioCtrl )
|
2016-04-06 18:15:49 +00:00
|
|
|
{
|
2020-06-04 15:07:23 +00:00
|
|
|
double ratioPercent;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
if( value.ToDouble( &ratioPercent ) )
|
2016-04-06 18:15:49 +00:00
|
|
|
{
|
2020-06-04 15:07:23 +00:00
|
|
|
// Clamp ratioPercent to acceptable value (0.0 to 50.0)
|
|
|
|
if( ratioPercent < 0.0 )
|
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatio.SetDoubleValue( 0.0 );
|
|
|
|
m_mixedCornerRatio.SetDoubleValue( 0.0 );
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2021-08-06 14:26:08 +00:00
|
|
|
else if( ratioPercent > 50.0 )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatio.SetDoubleValue( 50.0 );
|
|
|
|
m_mixedCornerRatio.SetDoubleValue( 50.0 );
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
if( ctrl == m_cornerRatioCtrl )
|
|
|
|
m_mixedCornerRatioCtrl->ChangeValue( value );
|
2020-06-04 15:07:23 +00:00
|
|
|
else
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatioCtrl->ChangeValue( value );
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
changed = true;
|
2018-08-29 07:13:07 +00:00
|
|
|
}
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2021-08-06 14:26:08 +00:00
|
|
|
else if( ctrl == m_chamferRatioCtrl || ctrl == m_mixedChamferRatioCtrl )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
|
|
|
double ratioPercent;
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
if( value.ToDouble( &ratioPercent ) )
|
2018-08-29 07:13:07 +00:00
|
|
|
{
|
2020-06-04 15:07:23 +00:00
|
|
|
// Clamp ratioPercent to acceptable value (0.0 to 50.0)
|
|
|
|
if( ratioPercent < 0.0 )
|
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
m_chamferRatio.SetDoubleValue( 0.0 );
|
|
|
|
m_mixedChamferRatio.SetDoubleValue( 0.0 );
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2021-08-06 14:26:08 +00:00
|
|
|
else if( ratioPercent > 50.0 )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
m_chamferRatio.SetDoubleValue( 50.0 );
|
|
|
|
m_mixedChamferRatio.SetDoubleValue( 50.0 );
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
if( ctrl == m_chamferRatioCtrl )
|
|
|
|
m_mixedChamferRatioCtrl->ChangeValue( value );
|
2020-06-04 15:07:23 +00:00
|
|
|
else
|
2021-08-06 14:26:08 +00:00
|
|
|
m_chamferRatioCtrl->ChangeValue( value );
|
2020-06-04 15:07:23 +00:00
|
|
|
|
|
|
|
changed = true;
|
|
|
|
}
|
2018-08-29 07:13:07 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
if( changed )
|
2018-08-29 07:13:07 +00:00
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2018-09-09 19:19:21 +00:00
|
|
|
m_cornerRadius.ChangeValue( m_dummyPad->GetRoundRectCornerRadius() );
|
2016-04-06 18:15:49 +00:00
|
|
|
}
|
2020-08-23 17:11:47 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2016-04-06 18:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::initValues()
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxString msg;
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
// Disable pad net name wxTextCtrl if the caller is the footprint editor
|
|
|
|
// because nets are living only in the board managed by the board editor
|
2019-09-05 22:00:47 +00:00
|
|
|
m_canEditNetName = m_parent->IsType( FRAME_PCB_EDITOR );
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerAdhCmp->SetLabel( m_board->GetLayerName( F_Adhes ) );
|
|
|
|
m_PadLayerAdhCu->SetLabel( m_board->GetLayerName( B_Adhes ) );
|
|
|
|
m_PadLayerPateCmp->SetLabel( m_board->GetLayerName( F_Paste ) );
|
|
|
|
m_PadLayerPateCu->SetLabel( m_board->GetLayerName( B_Paste ) );
|
|
|
|
m_PadLayerSilkCmp->SetLabel( m_board->GetLayerName( F_SilkS ) );
|
|
|
|
m_PadLayerSilkCu->SetLabel( m_board->GetLayerName( B_SilkS ) );
|
|
|
|
m_PadLayerMaskCmp->SetLabel( m_board->GetLayerName( F_Mask ) );
|
|
|
|
m_PadLayerMaskCu->SetLabel( m_board->GetLayerName( B_Mask ) );
|
|
|
|
m_PadLayerECO1->SetLabel( m_board->GetLayerName( Eco1_User ) );
|
|
|
|
m_PadLayerECO2->SetLabel( m_board->GetLayerName( Eco2_User ) );
|
|
|
|
m_PadLayerDraft->SetLabel( m_board->GetLayerName( Dwgs_User ) );
|
2012-03-10 13:00:31 +00:00
|
|
|
|
2013-03-30 09:28:59 +00:00
|
|
|
if( m_currentPad )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2021-01-08 16:32:28 +00:00
|
|
|
m_locked->SetValue( m_currentPad->IsLocked() );
|
2016-04-06 18:15:49 +00:00
|
|
|
m_isFlipped = m_currentPad->IsFlipped();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* footprint = m_currentPad->GetParent();
|
2017-02-12 07:09:21 +00:00
|
|
|
|
|
|
|
if( footprint )
|
2018-05-23 06:11:47 +00:00
|
|
|
{
|
2021-10-30 09:56:24 +00:00
|
|
|
double angle = m_dummyPad->GetOrientation();
|
2021-01-08 16:32:28 +00:00
|
|
|
angle -= footprint->GetOrientation();
|
|
|
|
m_dummyPad->SetOrientation( angle );
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Display parent footprint info
|
2020-10-29 17:33:28 +00:00
|
|
|
msg.Printf( _("Footprint %s (%s), %s, rotated %g deg"),
|
2020-08-22 22:51:54 +00:00
|
|
|
footprint->Reference().GetShownText(),
|
2020-09-08 23:39:33 +00:00
|
|
|
footprint->Value().GetShownText(),
|
2021-10-22 18:55:06 +00:00
|
|
|
footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
|
2020-10-29 17:33:28 +00:00
|
|
|
footprint->GetOrientationDegrees() );
|
2018-05-23 06:11:47 +00:00
|
|
|
}
|
2017-02-12 07:09:21 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
m_parentInfo->SetLabel( msg );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
2021-01-08 16:32:28 +00:00
|
|
|
else
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2021-01-08 16:32:28 +00:00
|
|
|
m_locked->Hide();
|
|
|
|
m_isFlipped = false;
|
2020-10-27 14:30:36 +00:00
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-10-27 14:30:36 +00:00
|
|
|
if( m_isFlipped )
|
|
|
|
{
|
|
|
|
// flip pad (up/down) around its position
|
|
|
|
m_dummyPad->Flip( m_dummyPad->GetPosition(), false );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
m_primitives = m_dummyPad->GetPrimitives();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2018-05-04 16:20:41 +00:00
|
|
|
m_FlippedWarningSizer->Show( m_isFlipped );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
if( m_currentPad )
|
|
|
|
{
|
|
|
|
m_padNumCtrl->SetValue( m_dummyPad->GetNumber() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PAD_TOOL* padTool = m_parent->GetToolManager()->GetTool<PAD_TOOL>();
|
|
|
|
m_padNumCtrl->SetValue( padTool->GetLastPadNumber() );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_padNetSelector->SetSelectedNetcode( m_dummyPad->GetNetCode() );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Display current pad parameters units:
|
2020-09-08 23:39:33 +00:00
|
|
|
m_posX.ChangeValue( m_dummyPad->GetPosition().x );
|
|
|
|
m_posY.ChangeValue( m_dummyPad->GetPosition().y );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
m_holeX.ChangeValue( m_dummyPad->GetDrillSize().x );
|
|
|
|
m_holeY.ChangeValue( m_dummyPad->GetDrillSize().y );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
m_sizeX.ChangeValue( m_dummyPad->GetSize().x );
|
|
|
|
m_sizeY.ChangeValue( m_dummyPad->GetSize().y );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
m_offsetShapeOpt->SetValue( m_dummyPad->GetOffset() != wxPoint() );
|
2020-09-08 23:39:33 +00:00
|
|
|
m_offsetX.ChangeValue( m_dummyPad->GetOffset().x );
|
|
|
|
m_offsetY.ChangeValue( m_dummyPad->GetOffset().y );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( m_dummyPad->GetDelta().x )
|
2010-09-15 14:53:33 +00:00
|
|
|
{
|
2020-09-08 23:39:33 +00:00
|
|
|
m_trapDelta.ChangeValue( m_dummyPad->GetDelta().x );
|
2018-05-23 06:11:47 +00:00
|
|
|
m_trapAxisCtrl->SetSelection( 0 );
|
2010-09-15 14:53:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-08 23:39:33 +00:00
|
|
|
m_trapDelta.ChangeValue( m_dummyPad->GetDelta().y );
|
2018-05-23 06:11:47 +00:00
|
|
|
m_trapAxisCtrl->SetSelection( 1 );
|
2010-09-15 14:53:33 +00:00
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
m_padToDieOpt->SetValue( m_dummyPad->GetPadToDieLength() != 0 );
|
2020-09-08 23:39:33 +00:00
|
|
|
m_padToDie.ChangeValue( m_dummyPad->GetPadToDieLength() );
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
m_clearance.ChangeValue( m_dummyPad->GetLocalClearance() );
|
2021-08-06 14:26:08 +00:00
|
|
|
m_maskMargin.ChangeValue( m_dummyPad->GetLocalSolderMaskMargin() );
|
2020-09-10 18:35:11 +00:00
|
|
|
m_spokeWidth.ChangeValue( m_dummyPad->GetThermalSpokeWidth() );
|
2020-09-08 23:39:33 +00:00
|
|
|
m_thermalGap.ChangeValue( m_dummyPad->GetThermalGap() );
|
2021-08-06 14:26:08 +00:00
|
|
|
m_pasteMargin.ChangeValue( m_dummyPad->GetLocalSolderPasteMargin() );
|
|
|
|
m_pasteMarginRatio.ChangeDoubleValue( m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
|
2021-10-30 09:56:24 +00:00
|
|
|
m_pad_orientation.ChangeDoubleValue( m_dummyPad->GetOrientation() );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
switch( m_dummyPad->GetZoneConnection() )
|
2012-02-24 23:23:46 +00:00
|
|
|
{
|
|
|
|
default:
|
2020-06-04 15:07:23 +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;
|
2012-02-24 23:23:46 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
if( m_dummyPad->GetCustomShapeInZoneOpt() == CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL )
|
|
|
|
m_ZoneCustomPadShape->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_ZoneCustomPadShape->SetSelection( 0 );
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( m_dummyPad->GetShape() )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
|
|
|
default:
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CIRCLE: m_PadShapeSelector->SetSelection( CHOICE_SHAPE_CIRCLE ); break;
|
|
|
|
case PAD_SHAPE::OVAL: m_PadShapeSelector->SetSelection( CHOICE_SHAPE_OVAL ); break;
|
|
|
|
case PAD_SHAPE::RECT: m_PadShapeSelector->SetSelection( CHOICE_SHAPE_RECT ); break;
|
|
|
|
case PAD_SHAPE::TRAPEZOID: m_PadShapeSelector->SetSelection( CHOICE_SHAPE_TRAPEZOID ); break;
|
|
|
|
case PAD_SHAPE::ROUNDRECT: m_PadShapeSelector->SetSelection( CHOICE_SHAPE_ROUNDRECT ); break;
|
2020-06-04 15:07:23 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CHAMFERED_RECT:
|
2020-06-04 15:07:23 +00:00
|
|
|
if( m_dummyPad->GetRoundRectRadiusRatio() > 0.0 )
|
2020-11-12 19:13:28 +00:00
|
|
|
m_PadShapeSelector->SetSelection( CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT );
|
2020-06-04 15:07:23 +00:00
|
|
|
else
|
2020-11-12 19:13:28 +00:00
|
|
|
m_PadShapeSelector->SetSelection( CHOICE_SHAPE_CHAMFERED_RECT );
|
2020-06-04 15:07:23 +00:00
|
|
|
break;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case PAD_SHAPE::CUSTOM:
|
|
|
|
if( m_dummyPad->GetAnchorPadShape() == PAD_SHAPE::RECT )
|
2020-11-12 19:13:28 +00:00
|
|
|
m_PadShapeSelector->SetSelection( CHOICE_SHAPE_CUSTOM_RECT_ANCHOR );
|
2017-01-13 17:51:22 +00:00
|
|
|
else
|
2020-11-12 19:13:28 +00:00
|
|
|
m_PadShapeSelector->SetSelection( CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-29 07:13:07 +00:00
|
|
|
m_cbTopLeft->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT) );
|
2020-06-04 15:07:23 +00:00
|
|
|
m_cbTopLeft1->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT) );
|
2018-08-29 07:13:07 +00:00
|
|
|
m_cbTopRight->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_TOP_RIGHT) );
|
2020-06-04 15:07:23 +00:00
|
|
|
m_cbTopRight1->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_TOP_RIGHT) );
|
2018-08-29 07:13:07 +00:00
|
|
|
m_cbBottomLeft->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_LEFT) );
|
2020-06-04 15:07:23 +00:00
|
|
|
m_cbBottomLeft1->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_LEFT) );
|
2018-08-29 07:13:07 +00:00
|
|
|
m_cbBottomRight->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_RIGHT) );
|
2020-06-04 15:07:23 +00:00
|
|
|
m_cbBottomRight1->SetValue( (m_dummyPad->GetChamferPositions() & RECT_CHAMFER_BOTTOM_RIGHT) );
|
|
|
|
|
|
|
|
updateRoundRectCornerValues();
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
enablePrimitivePage( PAD_SHAPE::CUSTOM == m_dummyPad->GetShape() );
|
2017-09-20 13:37:20 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
// Type of pad selection
|
2021-05-01 14:46:50 +00:00
|
|
|
bool aperture = m_dummyPad->GetAttribute() == PAD_ATTRIB::SMD && m_dummyPad->IsAperturePad();
|
2019-08-05 05:43:06 +00:00
|
|
|
|
|
|
|
if( aperture )
|
2018-07-24 13:56:20 +00:00
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
m_padType->SetSelection( APERTURE_DLG_TYPE );
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
else
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2018-07-24 13:56:20 +00:00
|
|
|
switch( m_dummyPad->GetAttribute() )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
case PAD_ATTRIB::PTH: m_padType->SetSelection( PTH_DLG_TYPE ); break;
|
|
|
|
case PAD_ATTRIB::SMD: m_padType->SetSelection( SMD_DLG_TYPE ); break;
|
|
|
|
case PAD_ATTRIB::CONN: m_padType->SetSelection( CONN_DLG_TYPE ); break;
|
|
|
|
case PAD_ATTRIB::NPTH: m_padType->SetSelection( NPTH_DLG_TYPE ); break;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-11 10:36:45 +00:00
|
|
|
switch( m_dummyPad->GetProperty() )
|
|
|
|
{
|
2021-05-01 14:58:30 +00:00
|
|
|
case PAD_PROP::NONE: m_choiceFabProperty->SetSelection( 0 ); break;
|
|
|
|
case PAD_PROP::BGA: m_choiceFabProperty->SetSelection( 1 ); break;
|
|
|
|
case PAD_PROP::FIDUCIAL_LOCAL: m_choiceFabProperty->SetSelection( 2 ); break;
|
|
|
|
case PAD_PROP::FIDUCIAL_GLBL: m_choiceFabProperty->SetSelection( 3 ); break;
|
|
|
|
case PAD_PROP::TESTPOINT: m_choiceFabProperty->SetSelection( 4 ); break;
|
|
|
|
case PAD_PROP::HEATSINK: m_choiceFabProperty->SetSelection( 5 ); break;
|
|
|
|
case PAD_PROP::CASTELLATED: m_choiceFabProperty->SetSelection( 6 ); break;
|
2019-12-11 10:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure the pad property is compatible with the pad type
|
2021-05-01 14:46:50 +00:00
|
|
|
if( m_dummyPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2019-12-11 10:36:45 +00:00
|
|
|
{
|
|
|
|
m_choiceFabProperty->SetSelection( 0 );
|
|
|
|
m_choiceFabProperty->Enable( false );
|
|
|
|
}
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( m_dummyPad->GetDrillShape() != PAD_DRILL_SHAPE_OBLONG )
|
2018-05-23 06:11:47 +00:00
|
|
|
m_holeShapeCtrl->SetSelection( 0 );
|
2008-11-22 11:10:40 +00:00
|
|
|
else
|
2018-05-23 06:11:47 +00:00
|
|
|
m_holeShapeCtrl->SetSelection( 1 );
|
2010-03-01 17:48:17 +00:00
|
|
|
|
2020-11-05 11:49:05 +00:00
|
|
|
updatePadLayersList( m_dummyPad->GetLayerSet(), m_dummyPad->GetRemoveUnconnected(),
|
|
|
|
m_dummyPad->GetKeepTopBottom() );
|
2020-09-08 22:34:10 +00:00
|
|
|
|
|
|
|
// Update some dialog widgets state (Enable/disable options):
|
|
|
|
wxCommandEvent cmd_event;
|
2012-06-25 20:59:19 +00:00
|
|
|
OnPadShapeSelection( cmd_event );
|
2020-06-05 16:42:20 +00:00
|
|
|
OnOffsetCheckbox( cmd_event );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
// Update basic shapes list
|
2017-09-20 08:28:52 +00:00
|
|
|
displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// A small helper function, to display coordinates:
|
2019-12-20 14:11:39 +00:00
|
|
|
static wxString formatCoord( EDA_UNITS aUnits, wxPoint aCoord )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2022-02-04 22:44:59 +00:00
|
|
|
return wxString::Format( wxT( "(X:%s Y:%s)" ),
|
2020-10-02 20:51:24 +00:00
|
|
|
MessageTextFromValue( aUnits, aCoord.x ),
|
|
|
|
MessageTextFromValue( aUnits, aCoord.y ) );
|
2016-04-06 18:15:49 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::displayPrimitivesList()
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
m_listCtrlPrimitives->ClearAll();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
wxListItem itemCol;
|
|
|
|
itemCol.SetImage(-1);
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 5; ++ii )
|
2017-09-20 08:28:52 +00:00
|
|
|
m_listCtrlPrimitives->InsertColumn(ii, itemCol);
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
wxString bs_info[5];
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < m_primitives.size(); ++ii )
|
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
const std::shared_ptr<PCB_SHAPE>& primitive = m_primitives[ii];
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-07-03 10:10:16 +00:00
|
|
|
for( wxString& s : bs_info )
|
|
|
|
s.Empty();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
bs_info[4] = _( "width" ) + wxS( " " )+ MessageTextFromValue( m_units,
|
|
|
|
primitive->GetWidth() );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
switch( primitive->GetShape() )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::SEGMENT:
|
2017-01-13 17:51:22 +00:00
|
|
|
bs_info[0] = _( "Segment" );
|
2020-10-20 19:05:04 +00:00
|
|
|
bs_info[1] = _( "from" ) + wxS( " " )+ formatCoord( m_units, primitive->GetStart() );
|
|
|
|
bs_info[2] = _( "to" ) + wxS( " " )+ formatCoord( m_units, primitive->GetEnd() );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::BEZIER:
|
2019-04-14 17:58:35 +00:00
|
|
|
bs_info[0] = _( "Bezier" );
|
2020-10-20 19:05:04 +00:00
|
|
|
bs_info[1] = _( "from" ) + wxS( " " )+ formatCoord( m_units, primitive->GetStart() );
|
|
|
|
bs_info[2] = _( "to" ) + wxS( " " )+ formatCoord( m_units, primitive->GetEnd() );
|
2019-04-14 17:58:35 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::ARC:
|
2017-01-13 17:51:22 +00:00
|
|
|
bs_info[0] = _( "Arc" );
|
2020-10-20 19:05:04 +00:00
|
|
|
bs_info[1] = _( "center" ) + wxS( " " )+ formatCoord( m_units, primitive->GetCenter() );
|
2021-07-17 19:56:18 +00:00
|
|
|
bs_info[2] = _( "start" ) + wxS( " " )+ formatCoord( m_units, primitive->GetStart() );
|
|
|
|
bs_info[3] = _( "angle" ) + wxS( " " )+ FormatAngle( primitive->GetArcAngle() );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::CIRCLE:
|
2020-06-24 11:12:39 +00:00
|
|
|
if( primitive->GetWidth() )
|
2017-01-13 17:51:22 +00:00
|
|
|
bs_info[0] = _( "ring" );
|
|
|
|
else
|
|
|
|
bs_info[0] = _( "circle" );
|
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
bs_info[1] = formatCoord( m_units, primitive->GetStart() );
|
2021-07-19 23:56:05 +00:00
|
|
|
bs_info[2] = _( "radius" ) + wxS( " " )+ MessageTextFromValue( m_units,
|
|
|
|
primitive->GetRadius() );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
case SHAPE_T::POLY:
|
2022-02-04 22:44:59 +00:00
|
|
|
bs_info[0] = _( "Polygon" );
|
2020-06-24 11:12:39 +00:00
|
|
|
bs_info[1] = wxString::Format( _( "corners count %d" ),
|
2022-02-02 21:35:01 +00:00
|
|
|
primitive->GetPolyShape().Outline( 0 ).PointCount() );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-02-04 22:44:59 +00:00
|
|
|
bs_info[0] = _( "Unknown primitive" );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-07-03 10:10:16 +00:00
|
|
|
long tmp = m_listCtrlPrimitives->InsertItem( ii, bs_info[0] );
|
|
|
|
m_listCtrlPrimitives->SetItemData( tmp, ii );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
for( int jj = 0, col = 0; jj < 5; ++jj )
|
2020-07-03 10:10:16 +00:00
|
|
|
m_listCtrlPrimitives->SetItem( tmp, col++, bs_info[jj] );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now columns are filled, ensure correct width of columns
|
|
|
|
for( unsigned ii = 0; ii < 5; ++ii )
|
2017-09-20 08:28:52 +00:00
|
|
|
m_listCtrlPrimitives->SetColumnWidth( ii, wxLIST_AUTOSIZE );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2014-07-15 14:02:08 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event )
|
|
|
|
{
|
|
|
|
redraw();
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-13 16:05:09 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onChangePadMode( wxCommandEvent& event )
|
|
|
|
{
|
2018-05-23 06:11:47 +00:00
|
|
|
m_sketchPreview = m_cbShowPadOutline->GetValue();
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2020-06-05 18:07:23 +00:00
|
|
|
KIGFX::VIEW* view = m_padPreviewGAL->GetView();
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// fix the pad render mode (filled/not filled)
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
settings->SetSketchMode( LAYER_PADS_TH, m_sketchPreview );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_FR, m_sketchPreview );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_BK, m_sketchPreview );
|
|
|
|
settings->SetSketchModeGraphicItems( m_sketchPreview );
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2020-08-23 17:11:47 +00:00
|
|
|
settings->SetHighContrast( false );
|
2020-09-02 20:56:31 +00:00
|
|
|
settings->SetContrastModeDisplay( HIGH_CONTRAST_MODE::NORMAL );
|
2020-08-23 17:11:47 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2018-01-13 16:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2020-11-12 19:13:28 +00:00
|
|
|
switch( m_PadShapeSelector->GetSelection() )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
case CHOICE_SHAPE_CIRCLE:
|
|
|
|
case CHOICE_SHAPE_OVAL:
|
|
|
|
case CHOICE_SHAPE_RECT:
|
2020-06-01 16:05:40 +00:00
|
|
|
m_shapePropsBook->SetSelection( 0 );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case CHOICE_SHAPE_TRAPEZOID:
|
2020-06-01 16:05:40 +00:00
|
|
|
m_shapePropsBook->SetSelection( 1 );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
case CHOICE_SHAPE_ROUNDRECT:
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
2020-06-01 16:05:40 +00:00
|
|
|
m_shapePropsBook->SetSelection( 2 );
|
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
// A reasonable default (from IPC-7351C)
|
|
|
|
if( m_dummyPad->GetRoundRectRadiusRatio() == 0.0 )
|
2021-08-06 14:26:08 +00:00
|
|
|
m_cornerRatio.ChangeValue( 25 );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-06-01 16:05:40 +00:00
|
|
|
|
|
|
|
case CHOICE_SHAPE_CHAMFERED_RECT:
|
|
|
|
m_shapePropsBook->SetSelection( 3 );
|
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
// Reasonable default
|
|
|
|
if( m_dummyPad->GetChamferRectRatio() == 0.0 )
|
|
|
|
m_dummyPad->SetChamferRectRatio( 0.2 );
|
|
|
|
|
|
|
|
// Ensure the displayed value is up to date:
|
2021-08-06 14:26:08 +00:00
|
|
|
m_chamferRatio.ChangeDoubleValue( m_dummyPad->GetChamferRectRatio() * 100.0 );
|
2020-11-12 19:13:28 +00:00
|
|
|
|
|
|
|
// A reasonable default is one corner chamfered (usual for some SMD pads).
|
2020-06-01 16:05:40 +00:00
|
|
|
if( !m_cbTopLeft->GetValue() && !m_cbTopRight->GetValue()
|
|
|
|
&& !m_cbBottomLeft->GetValue() && !m_cbBottomRight->GetValue() )
|
|
|
|
{
|
|
|
|
m_cbTopLeft->SetValue( true );
|
2020-11-12 19:13:28 +00:00
|
|
|
m_cbTopRight->SetValue( false );
|
|
|
|
m_cbBottomLeft->SetValue( false );
|
|
|
|
m_cbBottomRight->SetValue( false );
|
2020-06-01 16:05:40 +00:00
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2021-07-20 15:05:00 +00:00
|
|
|
break;
|
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
case CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT:
|
|
|
|
m_shapePropsBook->SetSelection( 4 );
|
|
|
|
|
|
|
|
// Reasonable defaults (corner radius from IPC-7351C)
|
2020-11-12 19:13:28 +00:00
|
|
|
if( m_dummyPad->GetRoundRectRadiusRatio() == 0.0
|
|
|
|
&& m_dummyPad->GetChamferRectRatio() == 0.0 )
|
|
|
|
{
|
|
|
|
if( m_dummyPad->GetRoundRectRadiusRatio() == 0.0 )
|
|
|
|
m_dummyPad->SetRoundRectRadiusRatio( 0.25 );
|
2020-06-04 15:07:23 +00:00
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
if( m_dummyPad->GetChamferRectRatio() == 0.0 )
|
|
|
|
m_dummyPad->SetChamferRectRatio( 0.2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure the displayed values are up to date:
|
2021-08-06 14:26:08 +00:00
|
|
|
m_mixedChamferRatio.ChangeDoubleValue( m_dummyPad->GetChamferRectRatio() * 100.0 );
|
|
|
|
m_mixedCornerRatio.ChangeDoubleValue( m_dummyPad->GetRoundRectRadiusRatio() * 100.0 );
|
2020-06-04 15:07:23 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
case CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR: // PAD_SHAPE::CUSTOM, circular anchor
|
|
|
|
case CHOICE_SHAPE_CUSTOM_RECT_ANCHOR: // PAD_SHAPE::CUSTOM, rect anchor
|
2020-06-01 16:05:40 +00:00
|
|
|
m_shapePropsBook->SetSelection( 0 );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2020-06-05 16:42:20 +00:00
|
|
|
// Readjust props book size
|
|
|
|
wxSize size = m_shapePropsBook->GetSize();
|
|
|
|
size.y = m_shapePropsBook->GetPage( m_shapePropsBook->GetSelection() )->GetBestSize().y;
|
|
|
|
m_shapePropsBook->SetMaxSize( size );
|
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
m_sizeY.Enable( m_PadShapeSelector->GetSelection() != CHOICE_SHAPE_CIRCLE
|
|
|
|
&& m_PadShapeSelector->GetSelection() != CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR );
|
2020-06-01 16:05:40 +00:00
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
m_offsetShapeOpt->Enable( m_PadShapeSelector->GetSelection() != CHOICE_SHAPE_CIRCLE
|
|
|
|
&& m_PadShapeSelector->GetSelection() != CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR
|
|
|
|
&& m_PadShapeSelector->GetSelection() != CHOICE_SHAPE_CUSTOM_RECT_ANCHOR );
|
2017-09-20 13:37:20 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
if( !m_offsetShapeOpt->IsEnabled() )
|
|
|
|
m_offsetShapeOpt->SetValue( false );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2020-06-11 10:52:05 +00:00
|
|
|
// Show/hide controls depending on m_offsetShapeOpt being enabled
|
|
|
|
m_offsetCtrls->Show( m_offsetShapeOpt->GetValue() );
|
|
|
|
m_offsetShapeOptLabel->Show( m_offsetShapeOpt->GetValue() );
|
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
bool is_custom = m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR
|
|
|
|
|| m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CUSTOM_RECT_ANCHOR;
|
2020-06-01 16:05:40 +00:00
|
|
|
|
|
|
|
enablePrimitivePage( is_custom );
|
2019-06-21 16:57:02 +00:00
|
|
|
m_staticTextcps->Enable( is_custom );
|
|
|
|
m_ZoneCustomPadShape->Enable( is_custom );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2012-04-11 23:30:06 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
updateRoundRectCornerValues();
|
2020-06-11 10:52:05 +00:00
|
|
|
|
|
|
|
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
|
|
|
|
m_notebook->GetPage( i )->Layout();
|
|
|
|
|
|
|
|
// Resize the dialog if its height is too small to show all widgets:
|
|
|
|
if( m_MainSizer->GetSize().y < m_MainSizer->GetMinSize().y )
|
|
|
|
m_MainSizer->SetSizeHints( this );
|
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnDrillShapeSelected( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2012-04-11 23:30:06 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::PadOrientEvent( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2012-04-11 23:30:06 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-23 17:11:47 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::UpdateLayersDropdown()
|
|
|
|
{
|
|
|
|
m_rbCopperLayersSel->Clear();
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
switch( m_padType->GetSelection() )
|
2020-08-23 17:11:47 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
case PTH_DLG_TYPE:
|
2020-08-23 17:11:47 +00:00
|
|
|
m_rbCopperLayersSel->Append( _( "All copper layers" ) );
|
|
|
|
m_rbCopperLayersSel->Append( wxString::Format( _( "%s, %s and connected layers" ),
|
|
|
|
m_board->GetLayerName( F_Cu ),
|
|
|
|
m_board->GetLayerName( B_Cu ) ) );
|
|
|
|
m_rbCopperLayersSel->Append( _( "Connected layers only" ) );
|
|
|
|
m_rbCopperLayersSel->Append( _( "None" ) );
|
2020-11-05 11:49:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NPTH_DLG_TYPE:
|
2020-09-08 23:39:33 +00:00
|
|
|
m_rbCopperLayersSel->Append( wxString::Format( _( "%s and %s" ),
|
|
|
|
m_board->GetLayerName( F_Cu ),
|
|
|
|
m_board->GetLayerName( B_Cu ) ) );
|
|
|
|
m_rbCopperLayersSel->Append( m_board->GetLayerName( F_Cu ) );
|
|
|
|
m_rbCopperLayersSel->Append( m_board->GetLayerName( B_Cu ) );
|
|
|
|
m_rbCopperLayersSel->Append( _( "None" ) );
|
2020-11-05 11:49:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SMD_DLG_TYPE:
|
|
|
|
case CONN_DLG_TYPE:
|
2020-08-23 17:11:47 +00:00
|
|
|
m_rbCopperLayersSel->Append( m_board->GetLayerName( F_Cu ) );
|
|
|
|
m_rbCopperLayersSel->Append( m_board->GetLayerName( B_Cu ) );
|
2020-11-05 11:49:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case APERTURE_DLG_TYPE:
|
|
|
|
m_rbCopperLayersSel->Append( _( "None" ) );
|
|
|
|
break;
|
2020-08-23 17:11:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
bool hasHole = true;
|
|
|
|
bool hasConnection = true;
|
|
|
|
bool hasProperty = true;
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
switch( m_padType->GetSelection() )
|
2018-07-24 13:56:20 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
case PTH_DLG_TYPE: hasHole = true; hasConnection = true; hasProperty = true; break;
|
|
|
|
case SMD_DLG_TYPE: hasHole = false; hasConnection = true; hasProperty = true; break;
|
|
|
|
case CONN_DLG_TYPE: hasHole = false; hasConnection = true; hasProperty = true; break;
|
|
|
|
case NPTH_DLG_TYPE: hasHole = true; hasConnection = false; hasProperty = false; break;
|
|
|
|
case APERTURE_DLG_TYPE: hasHole = false; hasConnection = false; hasProperty = true; break;
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 12:13:08 +00:00
|
|
|
// Update Layers dropdown list and selects the "best" layer set for the new pad type:
|
2020-11-05 11:49:05 +00:00
|
|
|
updatePadLayersList( {}, m_dummyPad->GetRemoveUnconnected(), m_dummyPad->GetKeepTopBottom() );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2018-07-24 13:56:20 +00:00
|
|
|
if( !hasHole )
|
|
|
|
{
|
2020-09-08 23:39:33 +00:00
|
|
|
m_holeX.ChangeValue( 0 );
|
|
|
|
m_holeY.ChangeValue( 0 );
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
else if ( m_holeX.GetValue() == 0 && m_currentPad )
|
|
|
|
{
|
2020-09-08 23:39:33 +00:00
|
|
|
m_holeX.ChangeValue( m_currentPad->GetDrillSize().x );
|
|
|
|
m_holeY.ChangeValue( m_currentPad->GetDrillSize().y );
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
2012-03-17 02:11:44 +00:00
|
|
|
|
2018-07-24 13:56:20 +00:00
|
|
|
if( !hasConnection )
|
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
m_padNumCtrl->ChangeValue( wxEmptyString );
|
|
|
|
m_padNetSelector->SetSelectedNetcode( 0 );
|
2020-06-01 16:05:40 +00:00
|
|
|
m_padToDieOpt->SetValue( false );
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
2021-10-22 18:55:06 +00:00
|
|
|
else if( m_padNumCtrl->GetValue().IsEmpty() && m_currentPad )
|
2018-07-24 13:56:20 +00:00
|
|
|
{
|
2021-10-22 18:55:06 +00:00
|
|
|
m_padNumCtrl->ChangeValue( m_currentPad->GetNumber() );
|
|
|
|
m_padNetSelector->SetSelectedNetcode( m_currentPad->GetNetCode() );
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2019-12-11 10:36:45 +00:00
|
|
|
if( !hasProperty )
|
|
|
|
m_choiceFabProperty->SetSelection( 0 );
|
|
|
|
|
|
|
|
m_choiceFabProperty->Enable( hasProperty );
|
|
|
|
|
2018-07-24 13:56:20 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2020-09-08 23:39:33 +00:00
|
|
|
|
2018-07-24 13:56:20 +00:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
2021-01-08 16:32:28 +00:00
|
|
|
// Enable/disable position
|
2021-01-12 16:27:08 +00:00
|
|
|
m_posX.Enable( !m_locked->GetValue() || m_isFpEditor );
|
|
|
|
m_posY.Enable( !m_locked->GetValue() || m_isFpEditor );
|
2021-01-08 16:32:28 +00:00
|
|
|
|
2020-11-05 11:49:05 +00:00
|
|
|
bool hasHole = true;
|
|
|
|
bool hasConnection = true;
|
2018-07-24 13:56:20 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
switch( m_padType->GetSelection() )
|
2018-07-24 13:56:20 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
case PTH_DLG_TYPE: /* PTH */ hasHole = true; hasConnection = true; break;
|
|
|
|
case SMD_DLG_TYPE: /* SMD */ hasHole = false; hasConnection = true; break;
|
|
|
|
case CONN_DLG_TYPE: /* CONN */ hasHole = false; hasConnection = true; break;
|
|
|
|
case NPTH_DLG_TYPE: /* NPTH */ hasHole = true; hasConnection = false; break;
|
2020-11-04 12:13:08 +00:00
|
|
|
case APERTURE_DLG_TYPE: /* Aperture */ hasHole = false; hasConnection = false; break;
|
2018-07-24 13:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Enable/disable hole controls
|
|
|
|
m_holeShapeLabel->Enable( hasHole );
|
|
|
|
m_holeShapeCtrl->Enable( hasHole );
|
|
|
|
m_holeX.Enable( hasHole );
|
|
|
|
m_holeY.Enable( hasHole && m_holeShapeCtrl->GetSelection() == 1 );
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
// Enable/disable number and net
|
|
|
|
m_padNumLabel->Enable( hasConnection );
|
|
|
|
m_padNumCtrl->Enable( hasConnection );
|
|
|
|
|
|
|
|
if( m_padNetLabel->IsShown() )
|
|
|
|
{
|
|
|
|
m_padNetLabel->Enable( hasConnection && m_canEditNetName && m_currentPad );
|
|
|
|
m_padNetSelector->Enable( hasConnection && m_canEditNetName && m_currentPad );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enable/disable pad length-to-die
|
2020-06-01 16:05:40 +00:00
|
|
|
m_padToDieOpt->Enable( hasConnection );
|
|
|
|
|
|
|
|
if( !m_padToDieOpt->IsEnabled() )
|
|
|
|
m_padToDieOpt->SetValue( false );
|
|
|
|
|
2020-06-05 16:42:20 +00:00
|
|
|
// We can show/hide this here because it doesn't require the layout to be refreshed.
|
|
|
|
// All the others have to be done in their event handlers because doing a layout here
|
|
|
|
// causes infinite looping on MSW.
|
2020-06-01 16:05:40 +00:00
|
|
|
m_padToDie.Show( m_padToDieOpt->GetValue() );
|
2018-07-24 13:56:20 +00:00
|
|
|
|
|
|
|
// Enable/disable Copper Layers control
|
2021-10-22 18:55:06 +00:00
|
|
|
m_rbCopperLayersSel->Enable( m_padType->GetSelection() != APERTURE_DLG_TYPE );
|
2020-09-08 22:34:10 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
LSET cu_set = m_dummyPad->GetLayerSet() & LSET::AllCuMask();
|
2020-09-08 22:34:10 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
switch( m_padType->GetSelection() )
|
2020-09-08 23:39:33 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
case PTH_DLG_TYPE:
|
2020-09-08 22:34:10 +00:00
|
|
|
if( !cu_set.any() )
|
|
|
|
m_stackupImagesBook->SetSelection( 3 );
|
|
|
|
else if( !m_dummyPad->GetRemoveUnconnected() )
|
|
|
|
m_stackupImagesBook->SetSelection( 0 );
|
|
|
|
else if( m_dummyPad->GetKeepTopBottom() )
|
|
|
|
m_stackupImagesBook->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_stackupImagesBook->SetSelection( 2 );
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPTH_DLG_TYPE:
|
2020-09-08 23:39:33 +00:00
|
|
|
if( cu_set.test( F_Cu ) && cu_set.test( B_Cu ) )
|
|
|
|
m_stackupImagesBook->SetSelection( 4 );
|
|
|
|
else if( cu_set.test( F_Cu ) )
|
|
|
|
m_stackupImagesBook->SetSelection( 5 );
|
|
|
|
else if( cu_set.test( B_Cu ) )
|
|
|
|
m_stackupImagesBook->SetSelection( 6 );
|
|
|
|
else
|
|
|
|
m_stackupImagesBook->SetSelection( 7 );
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SMD_DLG_TYPE:
|
|
|
|
case CONN_DLG_TYPE:
|
|
|
|
case APERTURE_DLG_TYPE:
|
2021-12-13 23:43:09 +00:00
|
|
|
m_stackupImagesBook->ChangeSelection( 3 );
|
2020-11-05 11:49:05 +00:00
|
|
|
break;
|
2020-09-08 22:34:10 +00:00
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-06 19:03:10 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnUpdateUINonCopperWarning( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
|
2021-12-13 20:46:13 +00:00
|
|
|
m_nonCopperWarningBook->ChangeSelection( isOnCopperLayer ? 0 : 1 );
|
2021-06-06 19:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-05 11:49:05 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::updatePadLayersList( LSET layer_mask, bool remove_unconnected,
|
|
|
|
bool keep_top_bottom )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2020-08-23 17:11:47 +00:00
|
|
|
UpdateLayersDropdown();
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
switch( m_padType->GetSelection() )
|
2020-08-23 17:11:47 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
case PTH_DLG_TYPE:
|
|
|
|
if( !layer_mask.any() )
|
2020-11-12 22:30:02 +00:00
|
|
|
layer_mask = PAD::PTHMask();
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
if( !( layer_mask & LSET::AllCuMask() ).any() )
|
2020-08-23 17:11:47 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 3 );
|
|
|
|
else if( !remove_unconnected )
|
|
|
|
m_rbCopperLayersSel->SetSelection( 0 );
|
|
|
|
else if( keep_top_bottom )
|
|
|
|
m_rbCopperLayersSel->SetSelection( 1 );
|
|
|
|
else
|
|
|
|
m_rbCopperLayersSel->SetSelection( 2 );
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SMD_DLG_TYPE:
|
|
|
|
if( !layer_mask.any() )
|
2020-11-12 22:30:02 +00:00
|
|
|
layer_mask = PAD::SMDMask();
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
if( layer_mask.test( F_Cu ) )
|
2020-09-08 23:39:33 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 0 );
|
|
|
|
else
|
2020-11-05 11:49:05 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 1 );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONN_DLG_TYPE:
|
|
|
|
if( !layer_mask.any() )
|
2020-11-12 22:30:02 +00:00
|
|
|
layer_mask = PAD::ConnSMDMask();
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
if( layer_mask.test( F_Cu ) )
|
2020-08-23 17:11:47 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 0 );
|
|
|
|
else
|
|
|
|
m_rbCopperLayersSel->SetSelection( 1 );
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPTH_DLG_TYPE:
|
|
|
|
if( !layer_mask.any() )
|
2020-11-12 22:30:02 +00:00
|
|
|
layer_mask = PAD::UnplatedHoleMask();
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
if( layer_mask.test( F_Cu ) && layer_mask.test( B_Cu ) )
|
|
|
|
m_rbCopperLayersSel->SetSelection( 0 );
|
|
|
|
else if( layer_mask.test( F_Cu ) )
|
|
|
|
m_rbCopperLayersSel->SetSelection( 1 );
|
|
|
|
else if( layer_mask.test( B_Cu ) )
|
|
|
|
m_rbCopperLayersSel->SetSelection( 2 );
|
|
|
|
else
|
|
|
|
m_rbCopperLayersSel->SetSelection( 3 );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case APERTURE_DLG_TYPE:
|
|
|
|
if( !layer_mask.any() )
|
2020-11-12 22:30:02 +00:00
|
|
|
layer_mask = PAD::ApertureMask();
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
m_rbCopperLayersSel->SetSelection( 0 );
|
|
|
|
break;
|
2020-08-23 17:11:47 +00:00
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerAdhCmp->SetValue( layer_mask[F_Adhes] );
|
|
|
|
m_PadLayerAdhCu->SetValue( layer_mask[B_Adhes] );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerPateCmp->SetValue( layer_mask[F_Paste] );
|
|
|
|
m_PadLayerPateCu->SetValue( layer_mask[B_Paste] );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerSilkCmp->SetValue( layer_mask[F_SilkS] );
|
|
|
|
m_PadLayerSilkCu->SetValue( layer_mask[B_SilkS] );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerMaskCmp->SetValue( layer_mask[F_Mask] );
|
|
|
|
m_PadLayerMaskCu->SetValue( layer_mask[B_Mask] );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerECO1->SetValue( layer_mask[Eco1_User] );
|
|
|
|
m_PadLayerECO2->SetValue( layer_mask[Eco2_User] );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_PadLayerDraft->SetValue( layer_mask[Dwgs_User] );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-06 21:38:00 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::Show( bool aShow )
|
|
|
|
{
|
|
|
|
bool retVal = DIALOG_SHIM::Show( aShow );
|
|
|
|
|
|
|
|
if( aShow )
|
|
|
|
{
|
|
|
|
// It *should* work to set the stackup bitmap in the constructor, but it doesn't.
|
|
|
|
// wxWidgets needs to have these set when the panel is visible for some reason.
|
|
|
|
// https://gitlab.com/kicad/code/kicad/-/issues/5534
|
2021-03-08 02:59:07 +00:00
|
|
|
m_stackupImage0->SetBitmap( KiBitmap( BITMAPS::pads_reset_unused ) );
|
|
|
|
m_stackupImage1->SetBitmap( KiBitmap( BITMAPS::pads_remove_unused_keep_bottom ) );
|
|
|
|
m_stackupImage2->SetBitmap( KiBitmap( BITMAPS::pads_remove_unused ) );
|
|
|
|
m_stackupImage4->SetBitmap( KiBitmap( BITMAPS::pads_npth_top_bottom ) );
|
|
|
|
m_stackupImage5->SetBitmap( KiBitmap( BITMAPS::pads_npth_top ) );
|
|
|
|
m_stackupImage6->SetBitmap( KiBitmap( BITMAPS::pads_npth_bottom ) );
|
|
|
|
m_stackupImage7->SetBitmap( KiBitmap( BITMAPS::pads_npth ) );
|
2020-09-06 21:38:00 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
Layout();
|
2020-09-06 21:38:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-23 17:11:47 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnSetCopperLayers( wxCommandEvent& event )
|
|
|
|
{
|
2020-09-08 23:39:33 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2020-09-08 23:39:33 +00:00
|
|
|
redraw();
|
2020-08-23 17:11:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2012-04-11 23:30:06 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2014-07-09 09:22:43 +00:00
|
|
|
redraw();
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 02:11:44 +00:00
|
|
|
|
2012-04-11 23:30:06 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::padValuesOK()
|
2012-03-10 13:00:31 +00:00
|
|
|
{
|
2012-04-11 23:30:06 +00:00
|
|
|
bool error = transferDataToPad( m_dummyPad );
|
2012-03-10 13:00:31 +00:00
|
|
|
|
|
|
|
wxArrayString error_msgs;
|
2020-10-26 00:09:42 +00:00
|
|
|
wxArrayString warning_msgs;
|
2020-12-27 21:10:11 +00:00
|
|
|
wxString msg;
|
|
|
|
wxSize pad_size = m_dummyPad->GetSize();
|
|
|
|
wxSize drill_size = m_dummyPad->GetDrillSize();
|
2012-03-10 13:00:31 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM )
|
2021-01-08 17:45:04 +00:00
|
|
|
{
|
|
|
|
// allow 0-sized anchor pads
|
|
|
|
}
|
2021-05-01 12:22:35 +00:00
|
|
|
else if( m_dummyPad->GetShape() == PAD_SHAPE::CIRCLE )
|
2014-11-19 18:39:02 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
if( pad_size.x <= 0 )
|
|
|
|
warning_msgs.Add( _( "Warning: Pad size is less than zero." ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pad_size.x <= 0 || pad_size.y <= 0 )
|
|
|
|
warning_msgs.Add( _( "Warning: Pad size is less than zero." ) );
|
2014-11-19 18:39:02 +00:00
|
|
|
}
|
|
|
|
|
2020-10-26 00:09:42 +00:00
|
|
|
// Test hole size against pad size
|
2020-11-04 12:13:08 +00:00
|
|
|
if( m_dummyPad->IsOnCopperLayer() )
|
2020-11-02 12:44:52 +00:00
|
|
|
{
|
|
|
|
int maxError = m_board->GetDesignSettings().m_MaxError;
|
|
|
|
SHAPE_POLY_SET padOutline;
|
2020-10-26 00:09:42 +00:00
|
|
|
|
2022-08-01 16:44:23 +00:00
|
|
|
m_dummyPad->TransformShapeWithClearanceToPolygon( padOutline, UNDEFINED_LAYER, 0,
|
|
|
|
maxError, ERROR_INSIDE );
|
2020-10-26 00:09:42 +00:00
|
|
|
|
2020-11-02 12:44:52 +00:00
|
|
|
const SHAPE_SEGMENT* drillShape = m_dummyPad->GetEffectiveHoleShape();
|
|
|
|
const SEG drillSeg = drillShape->GetSeg();
|
|
|
|
SHAPE_POLY_SET drillOutline;
|
2020-10-26 00:09:42 +00:00
|
|
|
|
2020-11-02 12:44:52 +00:00
|
|
|
TransformOvalToPolygon( drillOutline, (wxPoint) drillSeg.A, (wxPoint) drillSeg.B,
|
|
|
|
drillShape->GetWidth(), maxError, ERROR_LOC::ERROR_INSIDE );
|
2020-10-27 14:30:36 +00:00
|
|
|
|
2020-11-02 12:44:52 +00:00
|
|
|
drillOutline.BooleanSubtract( padOutline, SHAPE_POLY_SET::POLYGON_MODE::PM_FAST );
|
2020-10-26 00:09:42 +00:00
|
|
|
|
2021-01-08 17:45:04 +00:00
|
|
|
if( drillOutline.BBox().GetWidth() > 0 || drillOutline.BBox().GetHeight() > 0 )
|
2020-11-02 12:44:52 +00:00
|
|
|
{
|
2021-01-03 23:58:39 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Pad drill will leave no copper or drill shape and "
|
2020-12-27 21:10:11 +00:00
|
|
|
"pad shape do not overlap." ) );
|
2020-11-02 12:44:52 +00:00
|
|
|
}
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 07:36:20 +00:00
|
|
|
if( m_dummyPad->GetLocalClearance() < 0 )
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Negative local clearance values will have no effect." ) );
|
2017-10-20 07:36:20 +00:00
|
|
|
|
2017-12-16 19:43:47 +00:00
|
|
|
// Some pads need a negative solder mask clearance (mainly for BGA with small pads)
|
|
|
|
// However the negative solder mask clearance must not create negative mask size
|
|
|
|
// Therefore test for minimal acceptable negative value
|
2021-05-15 23:38:14 +00:00
|
|
|
if( m_dummyPad->GetLocalSolderMaskMargin() < 0 )
|
2017-10-20 07:36:20 +00:00
|
|
|
{
|
2021-05-15 23:38:14 +00:00
|
|
|
int absMargin = abs( m_dummyPad->GetLocalSolderMaskMargin() );
|
|
|
|
|
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM )
|
|
|
|
{
|
|
|
|
for( const std::shared_ptr<PCB_SHAPE>& shape : m_dummyPad->GetPrimitives() )
|
|
|
|
{
|
|
|
|
EDA_RECT shapeBBox = shape->GetBoundingBox();
|
2017-12-16 19:43:47 +00:00
|
|
|
|
2021-05-15 23:38:14 +00:00
|
|
|
if( absMargin > shapeBBox.GetWidth() || absMargin > shapeBBox.GetHeight() )
|
|
|
|
{
|
|
|
|
warning_msgs.Add( _( "Warning: Negative solder mask clearances larger than "
|
|
|
|
"some shape primitives. Results may be surprising." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
|
2021-05-15 23:38:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( absMargin > pad_size.x || absMargin > pad_size.y )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Negative solder mask clearance larger than pad. No "
|
|
|
|
"solder mask will be generated." ) );
|
2017-12-16 19:43:47 +00:00
|
|
|
}
|
2017-10-20 07:36:20 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 16:46:35 +00:00
|
|
|
// Some pads need a positive solder paste clearance (mainly for BGA with small pads)
|
2021-06-09 19:32:58 +00:00
|
|
|
// However, a positive value can create issues if the resulting shape is too big.
|
2021-07-19 23:56:05 +00:00
|
|
|
// (like a solder paste creating a solder paste area on a neighbor pad or on the solder mask)
|
2018-02-14 16:46:35 +00:00
|
|
|
// So we could ask for user to confirm the choice
|
2020-12-27 21:10:11 +00:00
|
|
|
// For now we just check for disappearing paste
|
|
|
|
wxSize paste_size;
|
|
|
|
int paste_margin = m_dummyPad->GetLocalSolderPasteMargin();
|
|
|
|
double paste_ratio = m_dummyPad->GetLocalSolderPasteMarginRatio();
|
|
|
|
|
|
|
|
paste_size.x = pad_size.x + paste_margin + KiROUND( pad_size.x * paste_ratio );
|
|
|
|
paste_size.y = pad_size.y + paste_margin + KiROUND( pad_size.y * paste_ratio );
|
|
|
|
|
|
|
|
if( paste_size.x <= 0 || paste_size.y <= 0 )
|
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Negative solder paste margins larger than pad. No solder "
|
|
|
|
"paste mask will be generated." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
2017-10-20 07:36:20 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET padlayers_mask = m_dummyPad->GetLayerSet();
|
2012-03-10 13:00:31 +00:00
|
|
|
|
|
|
|
if( padlayers_mask == 0 )
|
2020-12-27 21:10:11 +00:00
|
|
|
error_msgs.Add( _( "Error: pad has no layer." ) );
|
2014-03-19 20:06:09 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !padlayers_mask[F_Cu] && !padlayers_mask[B_Cu] )
|
2012-03-10 13:00:31 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
if( ( drill_size.x || drill_size.y ) && m_dummyPad->GetAttribute() != PAD_ATTRIB::NPTH )
|
2012-03-10 13:00:31 +00:00
|
|
|
{
|
2020-12-27 21:10:11 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Plated through holes should normally have a copper pad "
|
|
|
|
"on at least one layer." ) );
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( error )
|
2020-12-27 21:10:11 +00:00
|
|
|
error_msgs.Add( _( "Too large value for pad delta size." ) );
|
2012-03-10 13:00:31 +00:00
|
|
|
|
|
|
|
switch( m_dummyPad->GetAttribute() )
|
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::NPTH: // Not plated, but through hole, a hole is expected
|
|
|
|
case PAD_ATTRIB::PTH: // Pad through hole, a hole is also expected
|
2020-12-27 21:10:11 +00:00
|
|
|
if( drill_size.x <= 0
|
|
|
|
|| ( drill_size.y <= 0 && m_dummyPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ) )
|
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Through hole pad has no hole." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
2013-10-02 20:25:44 +00:00
|
|
|
break;
|
2012-03-10 13:00:31 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::CONN: // Connector pads are smd pads, just they do not have solder paste.
|
2014-06-24 16:17:18 +00:00
|
|
|
if( padlayers_mask[B_Paste] || padlayers_mask[F_Paste] )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Connector pads normally have no solder paste. Use an "
|
|
|
|
"SMD pad instead." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
2020-04-24 23:44:09 +00:00
|
|
|
KI_FALLTHROUGH;
|
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::SMD: // SMD and Connector pads (One external copper layer only)
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2015-10-10 16:56:31 +00:00
|
|
|
LSET innerlayers_mask = padlayers_mask & LSET::InternalCuMask();
|
|
|
|
|
2021-01-08 17:45:04 +00:00
|
|
|
if( ( padlayers_mask[F_Cu] && padlayers_mask[B_Cu] ) || innerlayers_mask.count() != 0 )
|
2020-12-27 21:10:11 +00:00
|
|
|
warning_msgs.Add( _( "Warning: SMD pad has no outer layers." ) );
|
|
|
|
}
|
2014-09-10 15:18:42 +00:00
|
|
|
break;
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
if( ( m_dummyPad->GetProperty() == PAD_PROP::FIDUCIAL_GLBL ||
|
|
|
|
m_dummyPad->GetProperty() == PAD_PROP::FIDUCIAL_LOCAL ) &&
|
2021-05-01 14:46:50 +00:00
|
|
|
m_dummyPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Fiducial property makes no sense on NPTH pads." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
if( m_dummyPad->GetProperty() == PAD_PROP::TESTPOINT &&
|
2021-05-01 14:46:50 +00:00
|
|
|
m_dummyPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Testpoint property makes no sense on NPTH pads." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
if( m_dummyPad->GetProperty() == PAD_PROP::HEATSINK &&
|
2021-05-01 14:46:50 +00:00
|
|
|
m_dummyPad->GetAttribute() == PAD_ATTRIB::NPTH )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Heatsink property makes no sense of NPTH pads." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
if( m_dummyPad->GetProperty() == PAD_PROP::CASTELLATED &&
|
2021-05-01 14:46:50 +00:00
|
|
|
m_dummyPad->GetAttribute() != PAD_ATTRIB::PTH )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: Castellated property is for PTH pads." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
2019-12-11 10:36:45 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
if( m_dummyPad->GetProperty() == PAD_PROP::BGA &&
|
2021-05-01 14:46:50 +00:00
|
|
|
m_dummyPad->GetAttribute() != PAD_ATTRIB::SMD )
|
2020-12-27 21:10:11 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
warning_msgs.Add( _( "Warning: BGA property is for SMD pads." ) );
|
2020-12-27 21:10:11 +00:00
|
|
|
}
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE::ROUNDRECT ||
|
|
|
|
m_dummyPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT )
|
2016-04-06 18:15:49 +00:00
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
wxASSERT( m_cornerRatio.GetValue() == m_mixedCornerRatio.GetValue() );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2021-08-06 14:26:08 +00:00
|
|
|
if( m_cornerRatio.GetDoubleValue() < 0.0 )
|
|
|
|
error_msgs.Add( _( "Error: Negative corner size." ) );
|
|
|
|
else if( m_cornerRatio.GetDoubleValue() > 50.0 )
|
|
|
|
warning_msgs.Add( _( "Warning: Corner size will make pad circular." ) );
|
2016-04-06 18:15:49 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 21:18:13 +00:00
|
|
|
// PADSTACKS TODO: this will need to check each layer in the pad...
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2020-06-22 19:35:09 +00:00
|
|
|
SHAPE_POLY_SET mergedPolygon;
|
2021-08-23 11:29:38 +00:00
|
|
|
m_dummyPad->MergePrimitivesAsPolygon( &mergedPolygon );
|
2020-06-22 19:35:09 +00:00
|
|
|
|
|
|
|
if( mergedPolygon.OutlineCount() > 1 )
|
2020-12-27 21:10:11 +00:00
|
|
|
error_msgs.Add( _( "Error: Custom pad shape must resolve to a single polygon." ) );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-08 17:45:04 +00:00
|
|
|
if( error_msgs.GetCount() || warning_msgs.GetCount() )
|
2012-03-10 13:00:31 +00:00
|
|
|
{
|
2021-01-08 17:45:04 +00:00
|
|
|
wxString title = error_msgs.GetCount() ? _( "Pad Properties Errors" )
|
|
|
|
: _( "Pad Properties Warnings" );
|
|
|
|
HTML_MESSAGE_BOX dlg( this, title );
|
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
dlg.ListSet( error_msgs );
|
2020-10-26 00:09:42 +00:00
|
|
|
|
|
|
|
if( warning_msgs.GetCount() )
|
|
|
|
dlg.ListSet( warning_msgs );
|
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
2014-03-19 20:06:09 +00:00
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
return error_msgs.GetCount() == 0;
|
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::redraw()
|
|
|
|
{
|
2020-06-05 18:07:23 +00:00
|
|
|
if( !m_canUpdate )
|
|
|
|
return;
|
|
|
|
|
|
|
|
KIGFX::VIEW* view = m_padPreviewGAL->GetView();
|
|
|
|
m_padPreviewGAL->StopDrawing();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// The layer used to place primitive items selected when editing custom pad shapes
|
|
|
|
// we use here a layer never used in a pad:
|
|
|
|
#define SELECTED_ITEMS_LAYER Dwgs_User
|
2018-01-13 16:05:09 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
view->SetTopLayer( SELECTED_ITEMS_LAYER );
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
|
|
|
settings->SetLayerColor( SELECTED_ITEMS_LAYER, m_selectedColor );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
view->Update( m_dummyPad );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// delete previous items if highlight list
|
|
|
|
while( m_highlight.size() )
|
|
|
|
{
|
|
|
|
delete m_highlight.back(); // the dtor also removes item from view
|
|
|
|
m_highlight.pop_back();
|
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// highlight selected primitives:
|
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
while( select >= 0 )
|
|
|
|
{
|
2022-02-02 21:35:01 +00:00
|
|
|
PCB_SHAPE* dummyShape = static_cast<PCB_SHAPE*>( m_primitives[select]->Clone() );
|
2020-10-04 23:34:59 +00:00
|
|
|
dummyShape->SetLayer( SELECTED_ITEMS_LAYER );
|
|
|
|
dummyShape->Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
|
|
|
|
dummyShape->Move( m_dummyPad->GetPosition() );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
view->Add( dummyShape );
|
|
|
|
m_highlight.push_back( dummyShape );
|
2016-07-19 09:16:16 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
select = m_listCtrlPrimitives->GetNextSelected( select );
|
|
|
|
}
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
BOX2I bbox = m_dummyPad->ViewBBox();
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
|
2014-07-09 09:22:43 +00:00
|
|
|
{
|
2020-06-02 21:48:07 +00:00
|
|
|
// The origin always goes in the middle of the canvas; we want offsetting the pad
|
|
|
|
// shape to move the pad, not the hole
|
|
|
|
bbox.Move( -m_dummyPad->GetPosition() );
|
|
|
|
int maxXExtent = std::max( abs( bbox.GetLeft() ), abs( bbox.GetRight() ) );
|
|
|
|
int maxYExtent = std::max( abs( bbox.GetTop() ), abs( bbox.GetBottom() ) );
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2020-06-02 21:48:07 +00:00
|
|
|
// Don't blow up the GAL on too-large numbers
|
|
|
|
if( maxXExtent > INT_MAX / 4 )
|
|
|
|
maxXExtent = INT_MAX / 4;
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2020-06-02 21:48:07 +00:00
|
|
|
if( maxYExtent > INT_MAX / 4 )
|
|
|
|
maxYExtent = INT_MAX / 4;
|
|
|
|
|
2020-06-03 11:12:19 +00:00
|
|
|
BOX2D viewBox( m_dummyPad->GetPosition(), {0, 0} );
|
|
|
|
BOX2D canvasBox( m_dummyPad->GetPosition(), {0, 0} );
|
2020-06-02 21:48:07 +00:00
|
|
|
viewBox.Inflate( maxXExtent * 1.4, maxYExtent * 1.4 ); // add a margin
|
|
|
|
canvasBox.Inflate( maxXExtent * 2.0, maxYExtent * 2.0 );
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2020-06-02 21:48:07 +00:00
|
|
|
view->SetBoundary( canvasBox );
|
|
|
|
|
|
|
|
// Autozoom
|
|
|
|
view->SetViewport( viewBox );
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2020-06-05 18:07:23 +00:00
|
|
|
m_padPreviewGAL->StartDrawing();
|
|
|
|
m_padPreviewGAL->Refresh();
|
2014-07-09 09:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_panelGeneral->TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_localSettingsPanel->TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-10 10:40:31 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::TransferDataFromWindow()
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2016-06-20 13:46:58 +00:00
|
|
|
BOARD_COMMIT commit( m_parent );
|
|
|
|
|
2016-04-10 10:40:31 +00:00
|
|
|
if( !wxDialog::TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
if( !m_panelGeneral->TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( !m_localSettingsPanel->TransferDataFromWindow() )
|
|
|
|
return false;
|
|
|
|
|
2012-04-11 23:30:06 +00:00
|
|
|
if( !padValuesOK() )
|
2016-04-10 10:40:31 +00:00
|
|
|
return false;
|
2012-03-10 13:00:31 +00:00
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
transferDataToPad( m_padMaster );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
PAD_TOOL* padTool = m_parent->GetToolManager()->GetTool<PAD_TOOL>();
|
|
|
|
padTool->SetLastPadNumber( m_padMaster->GetNumber() );
|
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
// m_padMaster is a pattern: ensure there is no net for this pad:
|
|
|
|
m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
if( !m_currentPad ) // Set current Pad parameters
|
2017-02-08 08:27:52 +00:00
|
|
|
return true;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
commit.Modify( m_currentPad );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
// redraw the area where the pad was, without pad (delete pad on screen)
|
|
|
|
m_currentPad->SetFlags( DO_NOT_DRAW );
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->ClearFlags( DO_NOT_DRAW );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
// Update values
|
|
|
|
m_currentPad->SetShape( m_padMaster->GetShape() );
|
|
|
|
m_currentPad->SetAttribute( m_padMaster->GetAttribute() );
|
2020-10-27 14:30:36 +00:00
|
|
|
m_currentPad->SetOrientation( m_padMaster->GetOrientation() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-01-08 16:32:28 +00:00
|
|
|
m_currentPad->SetLocked( m_locked->GetValue() );
|
|
|
|
|
2021-01-12 16:27:08 +00:00
|
|
|
if( !m_locked->GetValue() || m_isFpEditor )
|
2021-01-08 16:32:28 +00:00
|
|
|
m_currentPad->SetPosition( m_padMaster->GetPosition() );
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
wxSize size;
|
|
|
|
FOOTPRINT* footprint = m_currentPad->GetParent();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->SetSize( m_padMaster->GetSize() );
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
size = m_padMaster->GetDelta();
|
|
|
|
m_currentPad->SetDelta( size );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->SetDrillSize( m_padMaster->GetDrillSize() );
|
|
|
|
m_currentPad->SetDrillShape( m_padMaster->GetDrillShape() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
wxPoint offset = m_padMaster->GetOffset();
|
|
|
|
m_currentPad->SetOffset( offset );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->SetPadToDieLength( m_padMaster->GetPadToDieLength() );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_padMaster->GetShape() != PAD_SHAPE::CUSTOM )
|
2017-09-20 08:28:52 +00:00
|
|
|
m_padMaster->DeletePrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
m_currentPad->SetAnchorPadShape( m_padMaster->GetAnchorPadShape() );
|
2020-07-24 16:02:56 +00:00
|
|
|
m_currentPad->ReplacePrimitives( m_padMaster->GetPrimitives() );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() );
|
2020-09-03 14:00:58 +00:00
|
|
|
m_currentPad->SetRemoveUnconnected( m_padMaster->GetRemoveUnconnected() );
|
|
|
|
m_currentPad->SetKeepTopBottom( m_padMaster->GetKeepTopBottom() );
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2021-08-23 23:10:21 +00:00
|
|
|
m_currentPad->SetNumber( m_padMaster->GetNumber() );
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
int padNetcode = NETINFO_LIST::UNCONNECTED;
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
// For PAD_ATTRIB::NPTH, ensure there is no net name selected
|
|
|
|
if( m_padMaster->GetAttribute() != PAD_ATTRIB::NPTH )
|
2021-10-22 18:55:06 +00:00
|
|
|
padNetcode = m_padNetSelector->GetSelectedNetcode();
|
2016-06-20 13:46:58 +00:00
|
|
|
|
2019-05-31 02:30:28 +00:00
|
|
|
m_currentPad->SetNetCode( padNetcode );
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->SetLocalClearance( m_padMaster->GetLocalClearance() );
|
|
|
|
m_currentPad->SetLocalSolderMaskMargin( m_padMaster->GetLocalSolderMaskMargin() );
|
|
|
|
m_currentPad->SetLocalSolderPasteMargin( m_padMaster->GetLocalSolderPasteMargin() );
|
|
|
|
m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster->GetLocalSolderPasteMarginRatio() );
|
2020-09-10 18:35:11 +00:00
|
|
|
m_currentPad->SetThermalSpokeWidth( m_padMaster->GetThermalSpokeWidth() );
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
|
|
|
|
m_currentPad->SetRoundRectRadiusRatio( m_padMaster->GetRoundRectRadiusRatio() );
|
2018-08-29 07:13:07 +00:00
|
|
|
m_currentPad->SetChamferRectRatio( m_padMaster->GetChamferRectRatio() );
|
|
|
|
m_currentPad->SetChamferPositions( m_padMaster->GetChamferPositions() );
|
2021-08-08 16:28:43 +00:00
|
|
|
m_currentPad->SetZoneConnection( m_padMaster->GetZoneConnection() );
|
2017-12-21 09:23:17 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
// rounded rect pads with radius ratio = 0 are in fact rect pads.
|
|
|
|
// So set the right shape (and perhaps issues with a radius = 0)
|
2021-05-01 12:22:35 +00:00
|
|
|
if( m_currentPad->GetShape() == PAD_SHAPE::ROUNDRECT &&
|
2016-06-20 13:46:58 +00:00
|
|
|
m_currentPad->GetRoundRectRadiusRatio() == 0.0 )
|
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
m_currentPad->SetShape( PAD_SHAPE::RECT );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 10:36:45 +00:00
|
|
|
// Set the fabrication property:
|
|
|
|
m_currentPad->SetProperty( getSelectedProperty() );
|
|
|
|
|
2017-12-21 09:23:17 +00:00
|
|
|
// define the way the clearance area is defined in zones
|
2017-01-13 17:51:22 +00:00
|
|
|
m_currentPad->SetCustomShapeInZoneOpt( m_padMaster->GetCustomShapeInZoneOpt() );
|
|
|
|
|
2020-10-27 14:30:36 +00:00
|
|
|
if( m_isFlipped )
|
|
|
|
{
|
|
|
|
// flip pad (up/down) around its position
|
|
|
|
m_currentPad->Flip( m_currentPad->GetPosition(), false );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
{
|
|
|
|
// compute the pos 0 value, i.e. pad position for footprint with orientation = 0
|
|
|
|
// i.e. relative to footprint origin (footprint position)
|
|
|
|
wxPoint pt = m_currentPad->GetPosition() - footprint->GetPosition();
|
|
|
|
RotatePoint( &pt, -footprint->GetOrientation() );
|
|
|
|
m_currentPad->SetPos0( pt );
|
|
|
|
m_currentPad->SetOrientation( m_currentPad->GetOrientation() +
|
|
|
|
footprint->GetOrientation() );
|
|
|
|
}
|
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
m_parent->SetMsgPanel( m_currentPad );
|
|
|
|
|
|
|
|
// redraw the area where the pad was
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2016-06-20 13:46:58 +00:00
|
|
|
|
|
|
|
commit.Push( _( "Modify pad" ) );
|
|
|
|
|
2016-04-10 10:40:31 +00:00
|
|
|
return true;
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
2012-04-11 23:51:16 +00:00
|
|
|
|
2021-05-01 14:58:30 +00:00
|
|
|
PAD_PROP DIALOG_PAD_PROPERTIES::getSelectedProperty()
|
2019-12-11 10:36:45 +00:00
|
|
|
{
|
2021-05-01 14:58:30 +00:00
|
|
|
PAD_PROP prop = PAD_PROP::NONE;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
|
|
|
switch( m_choiceFabProperty->GetSelection() )
|
|
|
|
{
|
2021-05-01 14:58:30 +00:00
|
|
|
case 0: prop = PAD_PROP::NONE; break;
|
|
|
|
case 1: prop = PAD_PROP::BGA; break;
|
|
|
|
case 2: prop = PAD_PROP::FIDUCIAL_LOCAL; break;
|
|
|
|
case 3: prop = PAD_PROP::FIDUCIAL_GLBL; break;
|
|
|
|
case 4: prop = PAD_PROP::TESTPOINT; break;
|
|
|
|
case 5: prop = PAD_PROP::HEATSINK; break;
|
|
|
|
case 6: prop = PAD_PROP::CASTELLATED; break;
|
2019-12-11 10:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::transferDataToPad( PAD* aPad )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxString msg;
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
if( !Validate() )
|
|
|
|
return true;
|
|
|
|
if( !m_panelGeneral->Validate() )
|
|
|
|
return true;
|
|
|
|
if( !m_localSettingsPanel->Validate() )
|
|
|
|
return true;
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_spokeWidth.Validate( 0, INT_MAX ) )
|
|
|
|
return false;
|
2016-04-10 22:14:28 +00:00
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
aPad->SetAttribute( code_type[m_padType->GetSelection()] );
|
2020-11-12 19:13:28 +00:00
|
|
|
aPad->SetShape( code_shape[m_PadShapeSelector->GetSelection()] );
|
2020-12-27 21:10:11 +00:00
|
|
|
|
|
|
|
if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CUSTOM_RECT_ANCHOR )
|
2021-05-01 12:22:35 +00:00
|
|
|
aPad->SetAnchorPadShape( PAD_SHAPE::RECT );
|
2020-12-27 21:10:11 +00:00
|
|
|
else
|
2021-05-01 12:22:35 +00:00
|
|
|
aPad->SetAnchorPadShape( PAD_SHAPE::CIRCLE );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
|
2020-07-24 16:02:56 +00:00
|
|
|
aPad->ReplacePrimitives( m_primitives );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// Read pad clearances values:
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetLocalClearance( m_clearance.GetValue() );
|
2021-08-06 14:26:08 +00:00
|
|
|
aPad->SetLocalSolderMaskMargin( m_maskMargin.GetValue() );
|
|
|
|
aPad->SetLocalSolderPasteMargin( m_pasteMargin.GetValue() );
|
|
|
|
aPad->SetLocalSolderPasteMarginRatio( m_pasteMarginRatio.GetDoubleValue() / 100.0 );
|
2020-09-10 18:35:11 +00:00
|
|
|
aPad->SetThermalSpokeWidth( m_spokeWidth.GetValue() );
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetThermalGap( m_thermalGap.GetValue() );
|
2020-12-27 21:10:11 +00:00
|
|
|
|
2021-10-30 09:56:24 +00:00
|
|
|
// And rotation
|
|
|
|
aPad->SetOrientation( m_pad_orientation.GetDoubleValue() );
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
switch( m_ZoneConnectionChoice->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
2020-06-01 16:05:40 +00:00
|
|
|
case 0: aPad->SetZoneConnection( ZONE_CONNECTION::INHERITED ); break;
|
|
|
|
case 1: aPad->SetZoneConnection( ZONE_CONNECTION::FULL ); break;
|
|
|
|
case 2: aPad->SetZoneConnection( ZONE_CONNECTION::THERMAL ); break;
|
|
|
|
case 3: aPad->SetZoneConnection( ZONE_CONNECTION::NONE ); break;
|
2018-03-11 16:23:51 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetPosition( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
if( m_holeShapeCtrl->GetSelection() == 0 )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
aPad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetDrillSize( wxSize( m_holeX.GetValue(), m_holeX.GetValue() ) );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
else
|
2018-05-23 06:11:47 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
aPad->SetDrillShape( PAD_DRILL_SHAPE_OBLONG );
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetDrillSize( wxSize( m_holeX.GetValue(), m_holeY.GetValue() ) );
|
|
|
|
}
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE::CIRCLE )
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetSize( wxSize( m_sizeX.GetValue(), m_sizeX.GetValue() ) );
|
|
|
|
else
|
|
|
|
aPad->SetSize( wxSize( m_sizeX.GetValue(), m_sizeY.GetValue() ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2015-10-10 16:56:31 +00:00
|
|
|
// For a trapezoid, test delta value (be sure delta is not too large for pad size)
|
2011-11-24 17:32:51 +00:00
|
|
|
// remember DeltaSize.x is the Y size variation
|
2010-09-11 16:33:43 +00:00
|
|
|
bool error = false;
|
2020-06-01 16:05:40 +00:00
|
|
|
wxSize delta( 0, 0 );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE::TRAPEZOID )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2020-06-01 16:05:40 +00:00
|
|
|
// For a trapezoid, only one of delta.x or delta.y is not 0, depending on axis.
|
2018-05-23 06:11:47 +00:00
|
|
|
if( m_trapAxisCtrl->GetSelection() == 0 )
|
|
|
|
delta.x = m_trapDelta.GetValue();
|
2015-10-10 16:56:31 +00:00
|
|
|
else
|
2018-05-23 06:11:47 +00:00
|
|
|
delta.y = m_trapDelta.GetValue();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2022-03-22 20:38:36 +00:00
|
|
|
if( delta.x < 0 && delta.x < -aPad->GetSize().y )
|
2015-10-10 16:56:31 +00:00
|
|
|
{
|
|
|
|
delta.x = -aPad->GetSize().y + 2;
|
|
|
|
error = true;
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2022-03-22 20:38:36 +00:00
|
|
|
if( delta.x > 0 && delta.x > aPad->GetSize().y )
|
2015-10-10 16:56:31 +00:00
|
|
|
{
|
|
|
|
delta.x = aPad->GetSize().y - 2;
|
|
|
|
error = true;
|
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2022-03-22 20:38:36 +00:00
|
|
|
if( delta.y < 0 && delta.y < -aPad->GetSize().x )
|
2015-10-10 16:56:31 +00:00
|
|
|
{
|
|
|
|
delta.y = -aPad->GetSize().x + 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
|
2022-03-22 20:38:36 +00:00
|
|
|
if( delta.y > 0 && delta.y > aPad->GetSize().x )
|
2015-10-10 16:56:31 +00:00
|
|
|
{
|
|
|
|
delta.y = aPad->GetSize().x - 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
aPad->SetDelta( delta );
|
|
|
|
|
|
|
|
if( m_offsetShapeOpt->GetValue() )
|
|
|
|
aPad->SetOffset( wxPoint( m_offsetX.GetValue(), m_offsetY.GetValue() ) );
|
|
|
|
else
|
|
|
|
aPad->SetOffset( wxPoint() );
|
|
|
|
|
|
|
|
// Read pad length die
|
|
|
|
if( m_padToDieOpt->GetValue() )
|
|
|
|
aPad->SetPadToDieLength( m_padToDie.GetValue() );
|
|
|
|
else
|
|
|
|
aPad->SetPadToDieLength( 0 );
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
aPad->SetNumber( m_padNumCtrl->GetValue() );
|
|
|
|
aPad->SetNetCode( m_padNetSelector->GetSelectedNetcode() );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2018-08-29 07:13:07 +00:00
|
|
|
int chamfers = 0;
|
|
|
|
|
2020-11-12 19:13:28 +00:00
|
|
|
if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CHAMFERED_RECT )
|
2020-06-01 16:05:40 +00:00
|
|
|
{
|
|
|
|
if( m_cbTopLeft->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_TOP_LEFT;
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
if( m_cbTopRight->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_TOP_RIGHT;
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
if( m_cbBottomLeft->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_BOTTOM_LEFT;
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
if( m_cbBottomRight->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_BOTTOM_RIGHT;
|
|
|
|
}
|
2020-11-12 19:13:28 +00:00
|
|
|
else if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
|
|
|
if( m_cbTopLeft1->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_TOP_LEFT;
|
2018-08-29 07:13:07 +00:00
|
|
|
|
2020-06-04 15:07:23 +00:00
|
|
|
if( m_cbTopRight1->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_TOP_RIGHT;
|
|
|
|
|
|
|
|
if( m_cbBottomLeft1->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_BOTTOM_LEFT;
|
|
|
|
|
|
|
|
if( m_cbBottomRight1->GetValue() )
|
|
|
|
chamfers |= RECT_CHAMFER_BOTTOM_RIGHT;
|
|
|
|
}
|
2018-08-29 07:13:07 +00:00
|
|
|
aPad->SetChamferPositions( chamfers );
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
|
2010-02-12 17:15:47 +00:00
|
|
|
{
|
2017-01-13 17:51:22 +00:00
|
|
|
// The pad custom has a "anchor pad" (a basic shape: round or rect pad)
|
2021-06-09 19:32:58 +00:00
|
|
|
// that is the minimal area of this pad, and is useful to ensure a hole
|
2017-01-13 17:51:22 +00:00
|
|
|
// diameter is acceptable, and is used in Gerber files as flashed area
|
|
|
|
// reference
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad->GetAnchorPadShape() == PAD_SHAPE::CIRCLE )
|
2018-05-23 06:11:47 +00:00
|
|
|
aPad->SetSize( wxSize( m_sizeX.GetValue(), m_sizeX.GetValue() ) );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
// define the way the clearance area is defined in zones
|
|
|
|
aPad->SetCustomShapeInZoneOpt( m_ZoneCustomPadShape->GetSelection() == 0 ?
|
|
|
|
CUST_PAD_SHAPE_IN_ZONE_OUTLINE :
|
|
|
|
CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL );
|
2010-02-12 17:15:47 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( aPad->GetAttribute() )
|
2010-02-12 17:15:47 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::PTH:
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::CONN:
|
|
|
|
case PAD_ATTRIB::SMD:
|
|
|
|
// SMD and PAD_ATTRIB::CONN has no hole.
|
|
|
|
// basically, SMD and PAD_ATTRIB::CONN are same type of pads
|
|
|
|
// PAD_ATTRIB::CONN has just a default non technical layers that differs from SMD
|
2012-03-20 20:22:38 +00:00
|
|
|
// and are intended to be used in virtual edge board connectors
|
|
|
|
// However we can accept a non null offset,
|
2016-04-06 18:15:49 +00:00
|
|
|
// mainly to allow complex pads build from a set of basic pad shapes
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetDrillSize( wxSize( 0, 0 ) );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
case PAD_ATTRIB::NPTH:
|
2011-08-19 13:08:24 +00:00
|
|
|
// Mechanical purpose only:
|
2020-04-17 23:24:38 +00:00
|
|
|
// no net name, no pad name allowed
|
2021-08-23 23:10:21 +00:00
|
|
|
aPad->SetNumber( wxEmptyString );
|
2014-02-25 10:40:34 +00:00
|
|
|
aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-02-04 22:44:59 +00:00
|
|
|
wxFAIL_MSG( wxT( "DIALOG_PAD_PROPERTIES::transferDataToPad: unknown pad type" ) );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-05-01 12:22:35 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE::ROUNDRECT )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
aPad->SetRoundRectRadiusRatio( m_cornerRatio.GetDoubleValue() / 100.0 );
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2021-08-06 14:26:08 +00:00
|
|
|
else if( aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT )
|
2020-06-04 15:07:23 +00:00
|
|
|
{
|
2020-11-12 19:13:28 +00:00
|
|
|
if( m_PadShapeSelector->GetSelection() == CHOICE_SHAPE_CHAMFERED_ROUNDED_RECT )
|
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
aPad->SetChamferRectRatio( m_mixedChamferRatio.GetDoubleValue() / 100.0 );
|
|
|
|
aPad->SetRoundRectRadiusRatio( m_mixedCornerRatio.GetDoubleValue() / 100.0 );
|
2020-11-12 19:13:28 +00:00
|
|
|
}
|
|
|
|
else // Choice is CHOICE_SHAPE_CHAMFERED_RECT, no rounded corner
|
|
|
|
{
|
2021-08-06 14:26:08 +00:00
|
|
|
aPad->SetChamferRectRatio( m_chamferRatio.GetDoubleValue() / 100.0 );
|
2020-11-12 19:13:28 +00:00
|
|
|
aPad->SetRoundRectRadiusRatio( 0 );
|
|
|
|
}
|
2020-06-04 15:07:23 +00:00
|
|
|
}
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2019-12-11 10:36:45 +00:00
|
|
|
aPad->SetProperty( getSelectedProperty() );
|
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
LSET padLayerMask = LSET();
|
2020-08-23 17:11:47 +00:00
|
|
|
int copperLayersChoice = m_rbCopperLayersSel->GetSelection();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2020-09-08 23:39:33 +00:00
|
|
|
aPad->SetRemoveUnconnected( false );
|
|
|
|
aPad->SetKeepTopBottom( false );
|
|
|
|
|
2021-10-22 18:55:06 +00:00
|
|
|
switch( m_padType->GetSelection() )
|
2011-08-19 13:08:24 +00:00
|
|
|
{
|
2020-11-05 11:49:05 +00:00
|
|
|
case PTH_DLG_TYPE:
|
2020-08-23 17:11:47 +00:00
|
|
|
switch( copperLayersChoice )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// All copper layers
|
|
|
|
padLayerMask |= LSET::AllCuMask();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// Front, back and connected
|
|
|
|
padLayerMask |= LSET::AllCuMask();
|
|
|
|
aPad->SetRemoveUnconnected( true );
|
|
|
|
aPad->SetKeepTopBottom( true );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// Connected only
|
|
|
|
padLayerMask |= LSET::AllCuMask();
|
|
|
|
aPad->SetRemoveUnconnected( true );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
// No copper layers
|
|
|
|
break;
|
|
|
|
}
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NPTH_DLG_TYPE:
|
2020-09-08 23:39:33 +00:00
|
|
|
switch( copperLayersChoice )
|
|
|
|
{
|
|
|
|
case 0: padLayerMask.set( F_Cu ).set( B_Cu ); break;
|
|
|
|
case 1: padLayerMask.set( F_Cu ); break;
|
|
|
|
case 2: padLayerMask.set( B_Cu ); break;
|
|
|
|
default: break;
|
|
|
|
}
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SMD_DLG_TYPE:
|
|
|
|
case CONN_DLG_TYPE:
|
2020-08-23 17:11:47 +00:00
|
|
|
switch( copperLayersChoice )
|
|
|
|
{
|
|
|
|
case 0: padLayerMask.set( F_Cu ); break;
|
|
|
|
case 1: padLayerMask.set( B_Cu ); break;
|
|
|
|
}
|
2020-11-05 11:49:05 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case APERTURE_DLG_TYPE:
|
|
|
|
// no copper layers
|
|
|
|
break;
|
2011-08-19 13:08:24 +00:00
|
|
|
}
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerAdhCmp->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( F_Adhes );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerAdhCu->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( B_Adhes );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerPateCmp->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( F_Paste );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerPateCu->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( B_Paste );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerSilkCmp->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( F_SilkS );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerSilkCu->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( B_SilkS );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerMaskCmp->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( F_Mask );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerMaskCu->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( B_Mask );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerECO1->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( Eco1_User );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerECO2->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( Eco2_User );
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerDraft->GetValue() )
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( Dwgs_User );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
aPad->SetLayerSet( padLayerMask );
|
2010-03-07 13:33:20 +00:00
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
return error;
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnOffsetCheckbox( wxCommandEvent& event )
|
|
|
|
{
|
2020-10-27 14:30:36 +00:00
|
|
|
if( m_offsetShapeOpt->GetValue() )
|
2020-06-01 16:05:40 +00:00
|
|
|
{
|
2020-10-27 14:30:36 +00:00
|
|
|
m_offsetX.SetValue( m_dummyPad->GetOffset().x );
|
|
|
|
m_offsetY.SetValue( m_dummyPad->GetOffset().y );
|
2020-06-01 16:05:40 +00:00
|
|
|
}
|
|
|
|
|
2020-06-11 10:52:05 +00:00
|
|
|
// Show/hide controls depending on m_offsetShapeOpt being enabled
|
2020-06-05 16:42:20 +00:00
|
|
|
m_offsetCtrls->Show( m_offsetShapeOpt->GetValue() );
|
|
|
|
m_offsetShapeOptLabel->Show( m_offsetShapeOpt->GetValue() );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
|
|
|
|
m_notebook->GetPage( i )->Layout();
|
|
|
|
|
2020-06-01 16:05:40 +00:00
|
|
|
OnValuesChanged( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnPadToDieCheckbox( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_padToDieOpt->GetValue() && m_currentPad )
|
|
|
|
m_padToDie.SetValue( m_currentPad->GetPadToDieLength() );
|
|
|
|
|
|
|
|
OnValuesChanged( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
2012-04-11 23:30:06 +00:00
|
|
|
transferDataToPad( m_dummyPad );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
// If the pad size has changed, update the displayed values for rounded rect pads.
|
2016-04-06 18:15:49 +00:00
|
|
|
updateRoundRectCornerValues();
|
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
redraw();
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::editPrimitive()
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( select < 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "No shape selected" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
std::shared_ptr<PCB_SHAPE>& shape = m_primitives[select];
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
if( shape->GetShape() == SHAPE_T::POLY )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2020-06-24 11:12:39 +00:00
|
|
|
DIALOG_PAD_PRIMITIVE_POLY_PROPS dlg( this, m_parent, shape.get() );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
dlg.TransferDataFromWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2020-06-24 11:12:39 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_PROPERTIES dlg( this, m_parent, shape.get() );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
dlg.TransferDataFromWindow();
|
|
|
|
}
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
|
|
|
transferDataToPad( m_dummyPad );
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnPrimitiveSelection( wxListEvent& event )
|
|
|
|
{
|
|
|
|
// Called on a double click on the basic shapes list
|
|
|
|
// To Do: highligth the primitive(s) currently selected.
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onPrimitiveDClick( wxMouseEvent& event )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
editPrimitive();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onEditPrimitive( wxCommandEvent& event )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
editPrimitive();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onDeletePrimitive( wxCommandEvent& event )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( select < 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Multiple selections are allowed. get them and remove corresponding shapes
|
|
|
|
std::vector<long> indexes;
|
|
|
|
indexes.push_back( select );
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
|
2017-01-13 17:51:22 +00:00
|
|
|
indexes.push_back( select );
|
|
|
|
|
|
|
|
// Erase all select shapes
|
|
|
|
for( unsigned ii = indexes.size(); ii > 0; --ii )
|
|
|
|
m_primitives.erase( m_primitives.begin() + indexes[ii-1] );
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
|
|
|
transferDataToPad( m_dummyPad );
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onAddPrimitive( wxCommandEvent& event )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
|
|
|
// Ask user for shape type
|
2020-11-14 01:16:02 +00:00
|
|
|
wxString shapelist[] = {
|
|
|
|
_( "Segment" ),
|
|
|
|
_( "Arc" ),
|
|
|
|
_( "Bezier" ),
|
|
|
|
_( "Ring/Circle" ),
|
|
|
|
_( "Polygon" )
|
|
|
|
};
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
int type = wxGetSingleChoiceIndex( _( "Shape type:" ), _( "Add Primitive" ),
|
2019-01-06 16:43:12 +00:00
|
|
|
arrayDim( shapelist ), shapelist, 0, this );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2019-04-14 17:58:35 +00:00
|
|
|
// User pressed cancel
|
|
|
|
if( type == -1 )
|
|
|
|
return;
|
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
SHAPE_T listtype[] = { SHAPE_T::SEGMENT, SHAPE_T::ARC, SHAPE_T::BEZIER, SHAPE_T::CIRCLE,
|
|
|
|
SHAPE_T::POLY };
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_SHAPE* primitive = new PCB_SHAPE();
|
2020-06-24 11:12:39 +00:00
|
|
|
primitive->SetShape( listtype[type] );
|
|
|
|
primitive->SetWidth( m_board->GetDesignSettings().GetLineThickness( F_Cu ) );
|
2020-11-14 01:16:02 +00:00
|
|
|
primitive->SetFilled( true );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2021-07-21 18:31:25 +00:00
|
|
|
if( listtype[type] == SHAPE_T::POLY )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2020-06-24 11:12:39 +00:00
|
|
|
DIALOG_PAD_PRIMITIVE_POLY_PROPS dlg( this, m_parent, primitive );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-24 11:12:39 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_PROPERTIES dlg( this, m_parent, primitive );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
m_primitives.emplace_back( primitive );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
|
|
|
transferDataToPad( m_dummyPad );
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::onGeometryTransform( wxCommandEvent& event )
|
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( select < 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "No shape selected" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multiple selections are allowed. Build selected shapes list
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<std::shared_ptr<PCB_SHAPE>> shapeList;
|
2020-06-24 11:12:39 +00:00
|
|
|
shapeList.emplace_back( m_primitives[select] );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
|
2020-06-24 11:12:39 +00:00
|
|
|
shapeList.emplace_back( m_primitives[select] );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_TRANSFORM dlg( this, m_parent, shapeList, false );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
dlg.Transform();
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
|
|
|
transferDataToPad( m_dummyPad );
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onDuplicatePrimitive( wxCommandEvent& event )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( select < 0 )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "No shape selected" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Multiple selections are allowed. Build selected shapes list
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<std::shared_ptr<PCB_SHAPE>> shapeList;
|
2020-06-24 11:12:39 +00:00
|
|
|
shapeList.emplace_back( m_primitives[select] );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
|
2020-06-24 11:12:39 +00:00
|
|
|
shapeList.emplace_back( m_primitives[select] );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2018-05-23 06:11:47 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_TRANSFORM dlg( this, m_parent, shapeList, true );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
2018-02-20 11:59:39 +00:00
|
|
|
// Transfer new settings
|
|
|
|
// save duplicates to a separate vector to avoid m_primitives reallocation,
|
|
|
|
// as shapeList contains pointers to its elements
|
2020-10-04 23:34:59 +00:00
|
|
|
std::vector<std::shared_ptr<PCB_SHAPE>> duplicates;
|
2018-02-20 11:59:39 +00:00
|
|
|
dlg.Transform( &duplicates, dlg.GetDuplicateCount() );
|
|
|
|
std::move( duplicates.begin(), duplicates.end(), std::back_inserter( m_primitives ) );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
|
|
|
transferDataToPad( m_dummyPad );
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|