2013-03-30 09:28:59 +00:00
|
|
|
/**
|
2013-04-25 16:29:35 +00:00
|
|
|
* @file dialog_pad_properties.cpp
|
2016-04-06 18:15:49 +00:00
|
|
|
* @brief dialog pad properties editor.
|
2013-03-30 09:28:59 +00:00
|
|
|
*/
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2012-03-20 20:22:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-13 16:05:09 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-03-30 09:28:59 +00:00
|
|
|
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
|
|
|
|
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2018-01-13 16:05:09 +00:00
|
|
|
* Copyright (C) 1992-2018 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-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <gr_basic.h>
|
2017-11-07 09:18:13 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2018-02-08 23:41:45 +00:00
|
|
|
#include <view/view_controls.h>
|
2017-01-13 17:51:22 +00:00
|
|
|
#include <trigo.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2017-09-20 12:17:55 +00:00
|
|
|
#include <unit_format.h>
|
2016-06-20 13:46:58 +00:00
|
|
|
#include <board_commit.h>
|
2018-02-03 23:22:45 +00:00
|
|
|
#include <bitmaps.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2018-01-12 18:46:44 +00:00
|
|
|
#include <pcb_painter.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
#include <dialog_pad_properties.h>
|
2012-03-10 13:00:31 +00:00
|
|
|
#include <html_messagebox.h>
|
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.
|
2014-06-24 16:17:18 +00:00
|
|
|
static PAD_SHAPE_T code_shape[] = {
|
2015-08-23 19:40:33 +00:00
|
|
|
PAD_SHAPE_CIRCLE,
|
|
|
|
PAD_SHAPE_OVAL,
|
|
|
|
PAD_SHAPE_RECT,
|
2016-04-06 18:15:49 +00:00
|
|
|
PAD_SHAPE_TRAPEZOID,
|
|
|
|
PAD_SHAPE_ROUNDRECT,
|
2017-01-13 17:51:22 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
// the ordered index of the pad shape wxChoice in dialog.
|
|
|
|
// keep it consistent with code_shape[] and dialog strings
|
|
|
|
enum CODE_CHOICE {
|
|
|
|
CHOICE_SHAPE_CIRCLE = 0,
|
|
|
|
CHOICE_SHAPE_OVAL,
|
|
|
|
CHOICE_SHAPE_RECT,
|
|
|
|
CHOICE_SHAPE_TRAPEZOID,
|
|
|
|
CHOICE_SHAPE_ROUNDRECT,
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
static PAD_ATTR_T code_type[] = {
|
2015-08-23 19:40:33 +00:00
|
|
|
PAD_ATTRIB_STANDARD,
|
|
|
|
PAD_ATTRIB_SMD,
|
|
|
|
PAD_ATTRIB_CONN,
|
|
|
|
PAD_ATTRIB_HOLE_NOT_PLATED
|
2008-11-22 11:10:40 +00:00
|
|
|
};
|
|
|
|
|
2012-03-17 02:11:44 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
// Default mask layers setup for pads according to the pad type
|
2014-06-24 16:17:18 +00:00
|
|
|
static const LSET std_pad_layers[] = {
|
2015-08-23 19:40:33 +00:00
|
|
|
// PAD_ATTRIB_STANDARD:
|
2014-06-24 16:17:18 +00:00
|
|
|
D_PAD::StandardMask(),
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
// PAD_ATTRIB_SMD:
|
2014-06-24 16:17:18 +00:00
|
|
|
D_PAD::SMDMask(),
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
// PAD_ATTRIB_CONN:
|
2014-07-02 13:08:28 +00:00
|
|
|
D_PAD::ConnSMDMask(),
|
2014-06-30 18:14:06 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
// PAD_ATTRIB_HOLE_NOT_PLATED:
|
2014-06-24 16:17:18 +00:00
|
|
|
D_PAD::UnplatedHoleMask()
|
2008-11-22 11:10:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad )
|
|
|
|
{
|
|
|
|
DIALOG_PAD_PROPERTIES dlg( this, aPad );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
|
2016-04-10 22:14:28 +00:00
|
|
|
DIALOG_PAD_PROPERTIES_BASE( aParent ),
|
|
|
|
m_OrientValidator( 1, &m_OrientValue )
|
2012-02-19 04:02:19 +00:00
|
|
|
{
|
|
|
|
m_canUpdate = false;
|
2013-03-30 09:28:59 +00:00
|
|
|
m_parent = aParent;
|
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
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
m_OrientValidator.SetRange( -360.0, 360.0 );
|
|
|
|
m_PadOrientCtrl->SetValidator( m_OrientValidator );
|
2016-04-10 22:28:06 +00:00
|
|
|
m_OrientValidator.SetWindow( m_PadOrientCtrl );
|
2016-04-10 22:14:28 +00:00
|
|
|
|
2018-01-13 16:05:09 +00:00
|
|
|
m_cbShowPadOutline->SetValue( m_drawPadOutlineMode );
|
|
|
|
|
2018-05-04 16:20:41 +00:00
|
|
|
m_FlippedWarningIcon->SetBitmap( KiBitmap( dialog_warning_xpm ) );
|
|
|
|
m_nonCopperWarningIcon->SetBitmap( KiBitmap( dialog_warning_xpm ) );
|
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
m_padMaster = &m_parent->GetDesignSettings().m_Pad_Master;
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad = new D_PAD( (MODULE*) NULL );
|
|
|
|
|
|
|
|
if( aPad )
|
2016-05-31 08:27:52 +00:00
|
|
|
*m_dummyPad = *aPad;
|
2016-04-06 18:15:49 +00:00
|
|
|
else // We are editing a "master" pad, i.e. a template to create new pads
|
2016-05-31 08:27:52 +00:00
|
|
|
*m_dummyPad = *m_padMaster;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
initValues();
|
|
|
|
|
2018-05-04 16:20:41 +00:00
|
|
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
|
|
|
|
m_staticTextInfoNegVal->SetFont( infoFont );
|
|
|
|
m_staticTextInfoPosValue->SetFont( infoFont );
|
|
|
|
m_nonCopperNote->SetFont( infoFont );
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
// Usually, TransferDataToWindow is called by OnInitDialog
|
|
|
|
// calling it here fixes all widgets sizes, and FinishDialogSettings can
|
|
|
|
// safely fix minsizes
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
2017-09-28 07:57:46 +00:00
|
|
|
// Initialize canvas to be able to display the dummy pad:
|
|
|
|
prepareCanvas();
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
m_sdbSizerOK->SetDefault();
|
|
|
|
m_canUpdate = true;
|
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
|
|
|
}
|
|
|
|
|
2018-01-13 16:05:09 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::m_drawPadOutlineMode = false; // Stores the pad draw option during a session
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnInitDialog( wxInitDialogEvent& event )
|
|
|
|
{
|
|
|
|
m_PadNumCtrl->SetFocus();
|
|
|
|
m_PadNumCtrl->SetSelection( -1, -1 );
|
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:
|
|
|
|
if( m_parent->IsGalCanvasActive() )
|
|
|
|
m_panelShowPadGal->StopDrawing();
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
m_buttonImport->Enable( aEnable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::prepareCanvas()
|
|
|
|
{
|
|
|
|
// Initialize the canvases (legacy or gal) to display the pad
|
|
|
|
// Enable the suitable canvas and make some inits
|
|
|
|
|
2016-07-19 09:16:16 +00:00
|
|
|
// Show the X and Y axis. It is usefull because pad shape can have an offset
|
|
|
|
// or be a complex shape.
|
2017-01-13 17:51:22 +00:00
|
|
|
KIGFX::COLOR4D axis_color = LIGHTBLUE;
|
|
|
|
|
|
|
|
m_axisOrigin = new KIGFX::ORIGIN_VIEWITEM( axis_color,
|
2016-02-13 15:34:52 +00:00
|
|
|
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 );
|
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
if( m_parent->IsGalCanvasActive() )
|
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
m_panelShowPadGal->UseColorScheme( &m_parent->Settings().Colors() );
|
2014-07-09 09:22:43 +00:00
|
|
|
m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
|
2018-02-08 23:41:45 +00:00
|
|
|
m_panelShowPadGal->GetViewControls()->
|
|
|
|
EnableMousewheelPan( m_parent->GetCanvas()->GetEnableMousewheelPan() );
|
2018-01-12 18:46:44 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
m_panelShowPadGal->Show();
|
2014-07-15 14:02:08 +00:00
|
|
|
m_panelShowPad->Hide();
|
2018-01-12 18:46:44 +00:00
|
|
|
|
|
|
|
KIGFX::VIEW* view = m_panelShowPadGal->GetView();
|
|
|
|
|
|
|
|
// 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
|
|
|
bool filled = !m_cbShowPadOutline->IsChecked();
|
2018-01-12 18:46:44 +00:00
|
|
|
settings->SetSketchMode( LAYER_PADS_TH, !filled );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_FR, !filled );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_BK, !filled );
|
|
|
|
settings->SetSketchModeGraphicItems( !filled );
|
|
|
|
|
2017-11-07 17:33:13 +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;
|
2017-11-07 09:18:13 +00:00
|
|
|
view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) );
|
|
|
|
view->Add( m_dummyPad );
|
|
|
|
view->Add( m_axisOrigin );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
m_panelShowPadGal->StartDrawing();
|
2014-07-15 14:02:08 +00:00
|
|
|
Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) );
|
2014-07-09 09:22:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_panelShowPad->Show();
|
|
|
|
m_panelShowPadGal->Hide();
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
|
|
|
|
{
|
|
|
|
wxPaintDC dc( m_panelShowPad );
|
|
|
|
PAD_DRAWINFO drawInfo;
|
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
COLOR4D color = COLOR4D::BLACK;
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_dummyPad->GetLayerSet()[F_Cu] )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
color = m_parent->Settings().Colors().GetItemColor( LAYER_PAD_FR );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_dummyPad->GetLayerSet()[B_Cu] )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
color = color.LegacyMix( m_parent->Settings().Colors().GetItemColor( LAYER_PAD_BK ) );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 19:20:21 +00:00
|
|
|
// What could happen: the pad color is *actually* black, or no
|
|
|
|
// copper was selected
|
|
|
|
if( color == BLACK )
|
2010-09-11 16:33:43 +00:00
|
|
|
color = LIGHTGRAY;
|
|
|
|
|
|
|
|
drawInfo.m_Color = color;
|
|
|
|
drawInfo.m_HoleColor = DARKGRAY;
|
2012-02-19 04:02:19 +00:00
|
|
|
drawInfo.m_Offset = m_dummyPad->GetPosition();
|
2010-09-11 16:33:43 +00:00
|
|
|
drawInfo.m_Display_padnum = true;
|
|
|
|
drawInfo.m_Display_netname = true;
|
2018-01-13 16:05:09 +00:00
|
|
|
drawInfo.m_ShowPadFilled = !m_drawPadOutlineMode;
|
2012-03-17 02:11:44 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
|
2011-08-19 13:08:24 +00:00
|
|
|
drawInfo.m_ShowNotPlatedHole = true;
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
// Shows the local pad clearance
|
2012-02-19 04:02:19 +00:00
|
|
|
drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
wxSize dc_size = dc.GetSize();
|
|
|
|
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
|
|
|
|
|
|
|
|
// Calculate a suitable scale to fit the available draw area
|
2016-04-06 18:15:49 +00:00
|
|
|
int dim = m_dummyPad->GetBoundingRadius() *2;
|
2014-11-19 18:39:02 +00:00
|
|
|
|
|
|
|
// Invalid x size. User could enter zero, or have deleted all text prior to
|
|
|
|
// entering a new value; this is also treated as zero. If dim is left at
|
|
|
|
// zero, the drawing scale is zero and we get a crash.
|
|
|
|
if( dim == 0 )
|
|
|
|
{
|
|
|
|
// If drill size has been set, use that. Otherwise default to 1mm.
|
|
|
|
dim = m_dummyPad->GetDrillSize().x;
|
|
|
|
if( dim == 0 )
|
2015-10-10 16:56:31 +00:00
|
|
|
dim = Millimeter2iu( 1.0 );
|
2014-11-19 18:39:02 +00:00
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
if( m_dummyPad->GetLocalClearance() > 0 )
|
|
|
|
dim += m_dummyPad->GetLocalClearance() * 2;
|
|
|
|
|
|
|
|
double scale = (double) dc_size.x / dim;
|
|
|
|
|
2014-11-19 18:39:02 +00:00
|
|
|
// If the pad is a circle, use the x size here instead.
|
|
|
|
int ysize;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE_CIRCLE )
|
2014-11-19 18:39:02 +00:00
|
|
|
ysize = m_dummyPad->GetSize().x;
|
|
|
|
else
|
|
|
|
ysize = m_dummyPad->GetSize().y;
|
|
|
|
|
|
|
|
dim = ysize + std::abs( m_dummyPad->GetDelta().x );
|
|
|
|
|
|
|
|
// Invalid y size. See note about x size above.
|
|
|
|
if( dim == 0 )
|
|
|
|
{
|
|
|
|
dim = m_dummyPad->GetDrillSize().y;
|
|
|
|
if( dim == 0 )
|
2015-12-27 15:51:13 +00:00
|
|
|
dim = Millimeter2iu( 0.1 );
|
2014-11-19 18:39:02 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( m_dummyPad->GetLocalClearance() > 0 )
|
|
|
|
dim += m_dummyPad->GetLocalClearance() * 2;
|
|
|
|
|
2010-09-11 19:15:24 +00:00
|
|
|
double altscale = (double) dc_size.y / dim;
|
2012-09-22 11:19:37 +00:00
|
|
|
scale = std::min( scale, altscale );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
// Give a margin
|
|
|
|
scale *= 0.7;
|
|
|
|
dc.SetUserScale( scale, scale );
|
|
|
|
|
2011-04-18 20:22:17 +00:00
|
|
|
GRResetPenAndBrush( &dc );
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
// draw selected primitives:
|
2017-09-20 08:28:52 +00:00
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
wxPoint start, end, center;
|
|
|
|
|
|
|
|
while( select >= 0 )
|
|
|
|
{
|
|
|
|
PAD_CS_PRIMITIVE& primitive = m_primitives[select];
|
|
|
|
|
|
|
|
// The best way to calculate parameters to draw a primitive is to
|
|
|
|
// use a dummy DRAWSEGMENT and use its methods
|
|
|
|
// Note: in legacy canvas, the pad has the 0,0 position
|
|
|
|
DRAWSEGMENT dummySegment;
|
|
|
|
primitive.ExportTo( &dummySegment );
|
|
|
|
dummySegment.Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
|
|
|
|
|
|
|
|
switch( primitive.m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT: // usual segment : line with rounded ends
|
2018-01-13 16:05:09 +00:00
|
|
|
if( !m_drawPadOutlineMode )
|
|
|
|
GRFilledSegment( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
|
|
|
|
primitive.m_Thickness, m_selectedColor );
|
|
|
|
else
|
|
|
|
GRCSegm( NULL, &dc, dummySegment.GetStart(), dummySegment.GetEnd(),
|
|
|
|
primitive.m_Thickness, m_selectedColor );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC: // Arc with rounded ends
|
2018-01-13 16:05:09 +00:00
|
|
|
if( !m_drawPadOutlineMode )
|
|
|
|
GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
|
|
|
|
dummySegment.GetCenter(), primitive.m_Thickness, m_selectedColor );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
|
|
|
|
dummySegment.GetCenter(), 0, m_selectedColor );
|
|
|
|
/* GRArc1( NULL, &dc, dummySegment.GetArcEnd(), dummySegment.GetArcStart(),
|
|
|
|
dummySegment.GetCenter() - primitive.m_Thickness, 0, m_selectedColor );*/
|
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE: // ring or circle
|
|
|
|
if( primitive.m_Thickness )
|
|
|
|
{
|
2018-01-13 16:05:09 +00:00
|
|
|
if( !m_drawPadOutlineMode )
|
|
|
|
GRCircle( NULL, &dc, dummySegment.GetCenter(), primitive.m_Radius,
|
|
|
|
primitive.m_Thickness, m_selectedColor );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GRCircle( NULL, &dc, dummySegment.GetCenter(),
|
|
|
|
primitive.m_Radius + primitive.m_Thickness/2, 0,
|
|
|
|
m_selectedColor );
|
|
|
|
GRCircle( NULL, &dc, dummySegment.GetCenter(),
|
|
|
|
primitive.m_Radius - primitive.m_Thickness/2, 0,
|
|
|
|
m_selectedColor );
|
|
|
|
}
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-13 16:05:09 +00:00
|
|
|
if( !m_drawPadOutlineMode )
|
|
|
|
GRFilledCircle( NULL, &dc, dummySegment.GetCenter(),
|
|
|
|
primitive.m_Radius, m_selectedColor );
|
|
|
|
else
|
|
|
|
GRCircle( NULL, &dc, dummySegment.GetCenter(),
|
|
|
|
primitive.m_Radius, 0, m_selectedColor );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON: // polygon
|
|
|
|
{
|
2018-01-24 13:22:43 +00:00
|
|
|
std::vector<wxPoint> poly = dummySegment.BuildPolyPointsList();
|
2018-01-13 16:05:09 +00:00
|
|
|
GRClosedPoly( NULL, &dc, poly.size(), &poly[0],
|
|
|
|
m_drawPadOutlineMode ? false : true,
|
|
|
|
primitive.m_Thickness, m_selectedColor, m_selectedColor );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
select = m_listCtrlPrimitives->GetNextSelected( select );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw X and Y axis. This is particularly useful to show the
|
2016-04-06 18:15:49 +00:00
|
|
|
// reference position of pads with offset and no hole, or custom pad shapes
|
|
|
|
const int linethickness = 0;
|
|
|
|
GRLine( NULL, &dc, -int( dc_size.x/scale ), 0, int( dc_size.x/scale ), 0,
|
|
|
|
linethickness, LIGHTBLUE ); // X axis
|
|
|
|
GRLine( NULL, &dc, 0, -int( dc_size.y/scale ), 0, int( dc_size.y/scale ),
|
|
|
|
linethickness, LIGHTBLUE ); // Y axis
|
2012-03-20 20:22:38 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::updateRoundRectCornerValues()
|
|
|
|
{
|
|
|
|
// Note:
|
|
|
|
// To avoid generating a wxEVT_TEXT event from m_tcCornerSizeRatio
|
|
|
|
// we use ChangeValue instead of SetValue, to set the displayed string
|
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE_ROUNDRECT )
|
|
|
|
{
|
|
|
|
m_tcCornerSizeRatio->ChangeValue( wxString::Format( "%.1f",
|
|
|
|
m_dummyPad->GetRoundRectRadiusRatio()*100 ) );
|
|
|
|
m_staticTextCornerRadiusValue->SetLabel( StringFromValue( g_UserUnit,
|
|
|
|
m_dummyPad->GetRoundRectCornerRadius() ) );
|
|
|
|
}
|
2016-04-10 10:40:31 +00:00
|
|
|
else if( m_dummyPad->GetShape() == PAD_SHAPE_RECT )
|
|
|
|
{
|
|
|
|
m_tcCornerSizeRatio->ChangeValue( "0" );
|
|
|
|
m_staticTextCornerRadiusValue->SetLabel( "0" );
|
|
|
|
}
|
2016-04-06 18:15:49 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_tcCornerSizeRatio->ChangeValue( wxEmptyString );
|
|
|
|
m_staticTextCornerRadiusValue->SetLabel( wxEmptyString );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PAD_PROPERTIES::onCornerSizePercentChange( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_dummyPad->GetShape() != PAD_SHAPE_ROUNDRECT )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString value = m_tcCornerSizeRatio->GetValue();
|
|
|
|
double rrRadiusRatioPercent;
|
|
|
|
|
|
|
|
if( value.ToDouble( &rrRadiusRatioPercent ) )
|
|
|
|
{
|
|
|
|
// Clamp rrRadiusRatioPercent to acceptable value (0.0 to 50.0)
|
|
|
|
if( rrRadiusRatioPercent < 0.0 )
|
|
|
|
{
|
|
|
|
rrRadiusRatioPercent = 0.0;
|
|
|
|
m_tcCornerSizeRatio->ChangeValue( "0.0" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rrRadiusRatioPercent > 50.0 )
|
|
|
|
{
|
|
|
|
rrRadiusRatioPercent = 0.5;
|
|
|
|
m_tcCornerSizeRatio->ChangeValue( "50.0" );
|
|
|
|
}
|
|
|
|
|
|
|
|
transferDataToPad( m_dummyPad );
|
|
|
|
m_staticTextCornerRadiusValue->SetLabel( StringFromValue( g_UserUnit,
|
|
|
|
m_dummyPad->GetRoundRectCornerRadius() ) );
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
double angle;
|
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
|
|
|
|
m_canEditNetName = m_parent->IsType( FRAME_PCB );
|
|
|
|
|
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
// Setup layers names from board
|
|
|
|
// Should be made first, before calling m_rbCopperLayersSel->SetSelection()
|
2014-06-24 16:17:18 +00:00
|
|
|
m_rbCopperLayersSel->SetString( 0, m_board->GetLayerName( F_Cu ) );
|
|
|
|
m_rbCopperLayersSel->SetString( 1, m_board->GetLayerName( B_Cu ) );
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
m_isFlipped = false;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-03-30 09:28:59 +00:00
|
|
|
if( m_currentPad )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
m_isFlipped = m_currentPad->IsFlipped();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
if( m_isFlipped )
|
2010-09-11 16:33:43 +00:00
|
|
|
m_staticModuleSideValue->SetLabel( _( "Back side (footprint is mirrored)" ) );
|
2018-02-09 09:50:45 +00:00
|
|
|
else
|
|
|
|
m_staticModuleSideValue->SetLabel( _( "Front side" ) );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
// Diplay footprint rotation ( angles are in 0.1 degree )
|
2017-02-12 07:09:21 +00:00
|
|
|
MODULE* footprint = m_currentPad->GetParent();
|
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
msg.Printf( "%.1f", footprint->GetOrientationDegrees() );
|
|
|
|
else
|
|
|
|
msg = _("No footprint" );
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
m_staticModuleRotValue->SetLabel( msg );
|
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( m_isFlipped )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxPoint pt = m_dummyPad->GetOffset();
|
2015-06-26 13:41:56 +00:00
|
|
|
pt.y = -pt.y;
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad->SetOffset( pt );
|
|
|
|
|
|
|
|
wxSize sz = m_dummyPad->GetDelta();
|
2015-06-26 13:41:56 +00:00
|
|
|
sz.y = -sz.y;
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad->SetDelta( sz );
|
|
|
|
|
|
|
|
// flip pad's layers
|
2014-06-24 16:17:18 +00:00
|
|
|
m_dummyPad->SetLayerSet( FlipLayerMask( m_dummyPad->GetLayerSet() ) );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
// flip custom pad shapes
|
2017-09-20 08:28:52 +00:00
|
|
|
m_dummyPad->FlipPrimitives();
|
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
|
|
|
|
2017-08-11 09:22:13 +00:00
|
|
|
m_PadNumCtrl->SetValue( m_dummyPad->GetName() );
|
2010-09-11 16:33:43 +00:00
|
|
|
m_PadNetNameCtrl->SetValue( m_dummyPad->GetNetname() );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
// Set the unit name in dialog:
|
|
|
|
wxStaticText* unitTexts[] =
|
|
|
|
{
|
|
|
|
m_PadPosX_Unit, m_PadPosY_Unit,
|
|
|
|
m_PadDrill_X_Unit, m_PadDrill_Y_Unit,
|
|
|
|
m_PadShapeSizeX_Unit, m_PadShapeSizeY_Unit,
|
|
|
|
m_PadShapeOffsetX_Unit,m_PadShapeOffsetY_Unit,
|
|
|
|
m_PadShapeDelta_Unit, m_PadLengthDie_Unit,
|
|
|
|
m_NetClearanceUnits, m_SolderMaskMarginUnits, m_SolderPasteMarginUnits,
|
|
|
|
m_ThermalWidthUnits, m_ThermalGapUnits, m_staticTextCornerSizeUnit
|
|
|
|
};
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < DIM( unitTexts ); ++ii )
|
|
|
|
unitTexts[ii]->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Display current pad parameters units:
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x );
|
|
|
|
PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x );
|
|
|
|
PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x );
|
|
|
|
PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x );
|
|
|
|
PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, 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
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_trapDeltaDirChoice->SetSelection( 0 );
|
2010-09-15 14:53:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().y );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_trapDeltaDirChoice->SetSelection( 1 );
|
2010-09-15 14:53:33 +00:00
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2012-12-12 11:57:17 +00:00
|
|
|
PutValueInLocalUnits( *m_LengthPadToDieCtrl, m_dummyPad->GetPadToDieLength() );
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->GetLocalClearance() );
|
|
|
|
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_dummyPad->GetLocalSolderMaskMargin() );
|
|
|
|
PutValueInLocalUnits( *m_ThermalWidthCtrl, m_dummyPad->GetThermalWidth() );
|
|
|
|
PutValueInLocalUnits( *m_ThermalGapCtrl, m_dummyPad->GetThermalGap() );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2009-11-06 12:55:20 +00:00
|
|
|
// These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
|
2012-04-13 18:51:24 +00:00
|
|
|
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_dummyPad->GetLocalSolderPasteMargin() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
if( m_dummyPad->GetLocalSolderPasteMargin() == 0 )
|
2010-09-11 16:33:43 +00:00
|
|
|
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
|
|
|
|
|
2013-05-30 19:32:00 +00:00
|
|
|
msg.Printf( wxT( "%f" ), m_dummyPad->GetLocalSolderPasteMarginRatio() * 100.0 );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
if( m_dummyPad->GetLocalSolderPasteMarginRatio() == 0.0 && msg[0] == '0' )
|
|
|
|
// Sometimes Printf adds a sign if the value is small
|
2010-09-11 16:33:43 +00:00
|
|
|
m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
|
2009-11-06 12:55:20 +00:00
|
|
|
else
|
2010-01-31 20:01:46 +00:00
|
|
|
m_SolderPasteMarginRatioCtrl->SetValue( msg );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
switch( m_dummyPad->GetZoneConnection() )
|
|
|
|
{
|
|
|
|
default:
|
2015-08-18 14:19:17 +00:00
|
|
|
case PAD_ZONE_CONN_INHERITED:
|
2012-02-24 23:23:46 +00:00
|
|
|
m_ZoneConnectionChoice->SetSelection( 0 );
|
2018-03-11 16:23:51 +00:00
|
|
|
m_ZoneConnectionCustom->SetSelection( 0 );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-18 14:19:17 +00:00
|
|
|
case PAD_ZONE_CONN_FULL:
|
2012-02-24 23:23:46 +00:00
|
|
|
m_ZoneConnectionChoice->SetSelection( 1 );
|
2018-03-11 16:23:51 +00:00
|
|
|
m_ZoneConnectionCustom->SetSelection( 1 );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-18 14:19:17 +00:00
|
|
|
case PAD_ZONE_CONN_THERMAL:
|
2012-02-24 23:23:46 +00:00
|
|
|
m_ZoneConnectionChoice->SetSelection( 2 );
|
2018-03-11 16:23:51 +00:00
|
|
|
m_ZoneConnectionCustom->SetSelection( 0 );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-18 14:19:17 +00:00
|
|
|
case PAD_ZONE_CONN_NONE:
|
2012-02-24 23:23:46 +00:00
|
|
|
m_ZoneConnectionChoice->SetSelection( 3 );
|
2018-03-11 16:23:51 +00:00
|
|
|
m_ZoneConnectionCustom->SetSelection( 0 );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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 );
|
|
|
|
|
2013-03-30 09:28:59 +00:00
|
|
|
if( m_currentPad )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2017-02-12 07:09:21 +00:00
|
|
|
angle = m_currentPad->GetOrientation();
|
2016-04-06 18:15:49 +00:00
|
|
|
MODULE* footprint = m_currentPad->GetParent();
|
2017-02-12 07:09:21 +00:00
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
angle -= footprint->GetOrientation();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( m_isFlipped )
|
2015-06-26 13:41:56 +00:00
|
|
|
angle = -angle;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
m_dummyPad->SetOrientation( angle );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
angle = m_dummyPad->GetOrientation();
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
NORMALIZE_ANGLE_180( angle ); // ? normalizing is in D_PAD::SetOrientation()
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Set layers used by this pad: :
|
2014-06-24 16:17:18 +00:00
|
|
|
setPadLayersList( m_dummyPad->GetLayerSet() );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
// Pad Orient
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( int( angle ) )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_PadOrient->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 900:
|
|
|
|
m_PadOrient->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
2012-03-08 20:44:03 +00:00
|
|
|
case -900:
|
2008-11-22 11:10:40 +00:00
|
|
|
m_PadOrient->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1800:
|
2011-12-31 05:44:00 +00:00
|
|
|
case -1800:
|
2008-11-22 11:10:40 +00:00
|
|
|
m_PadOrient->SetSelection( 3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_PadOrient->SetSelection( 4 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( m_dummyPad->GetShape() )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
|
|
|
default:
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
2016-04-06 18:15:49 +00:00
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_CIRCLE );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
2016-04-06 18:15:49 +00:00
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_OVAL );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_RECT:
|
2016-04-06 18:15:49 +00:00
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_RECT );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
2016-04-06 18:15:49 +00:00
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_TRAPEZOID );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_ROUNDRECT );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
case PAD_SHAPE_CUSTOM:
|
|
|
|
if( m_dummyPad->GetAnchorPadShape() == PAD_SHAPE_RECT )
|
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_CUSTOM_RECT_ANCHOR );
|
|
|
|
else
|
|
|
|
m_PadShape->SetSelection( CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR );
|
|
|
|
break;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 13:37:20 +00:00
|
|
|
enablePrimitivePage( PAD_SHAPE_CUSTOM == m_dummyPad->GetShape() );
|
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
m_OrientValue = angle / 10.0;
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
// Type of pad selection
|
2008-11-22 11:10:40 +00:00
|
|
|
m_PadType->SetSelection( 0 );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( unsigned ii = 0; ii < DIM( code_type ); ii++ )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( code_type[ii] == m_dummyPad->GetAttribute() )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
m_PadType->SetSelection( ii );
|
|
|
|
break;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
// Enable/disable Pad name,and pad length die
|
|
|
|
// (disable for NPTH pads (mechanical pads)
|
2015-08-23 19:40:33 +00:00
|
|
|
bool enable = m_dummyPad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
m_PadNumCtrl->Enable( enable );
|
2014-04-24 18:54:49 +00:00
|
|
|
m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
|
2012-12-12 11:57:17 +00:00
|
|
|
m_LengthPadToDieCtrl->Enable( enable );
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( m_dummyPad->GetDrillShape() != PAD_DRILL_SHAPE_OBLONG )
|
2008-11-22 11:10:40 +00:00
|
|
|
m_DrillShapeCtrl->SetSelection( 0 );
|
|
|
|
else
|
|
|
|
m_DrillShapeCtrl->SetSelection( 1 );
|
2010-03-01 17:48:17 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Update some dialog widgets state (Enable/disable options):
|
2010-09-11 16:33:43 +00:00
|
|
|
wxCommandEvent cmd_event;
|
2014-06-24 16:17:18 +00:00
|
|
|
setPadLayersList( m_dummyPad->GetLayerSet() );
|
2010-09-11 16:33:43 +00:00
|
|
|
OnDrillShapeSelected( cmd_event );
|
2012-06-25 20:59:19 +00:00
|
|
|
OnPadShapeSelection( cmd_event );
|
2016-04-06 18:15:49 +00:00
|
|
|
updateRoundRectCornerValues();
|
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:
|
|
|
|
static wxString formatCoord( wxPoint aCoord )
|
|
|
|
{
|
|
|
|
return wxString::Format( "(X:%s Y:%s)",
|
|
|
|
CoordinateToString( aCoord.x, true ),
|
|
|
|
CoordinateToString( aCoord.y, true ) );
|
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 )
|
|
|
|
{
|
|
|
|
const PAD_CS_PRIMITIVE& primitive = m_primitives[ii];
|
|
|
|
|
|
|
|
for( unsigned jj = 0; jj < 5; ++jj )
|
|
|
|
bs_info[jj].Empty();
|
|
|
|
|
|
|
|
bs_info[4] = wxString::Format( _( "width %s" ),
|
|
|
|
CoordinateToString( primitive.m_Thickness, true ) );
|
|
|
|
|
|
|
|
switch( primitive.m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT: // usual segment : line with rounded ends
|
|
|
|
bs_info[0] = _( "Segment" );
|
|
|
|
bs_info[1] = _( "from " ) + formatCoord( primitive.m_Start );
|
|
|
|
bs_info[2] = _( "to " ) + formatCoord( primitive.m_End );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC: // Arc with rounded ends
|
|
|
|
bs_info[0] = _( "Arc" );
|
|
|
|
bs_info[1] = _( "center " ) + formatCoord( primitive.m_Start ); // Center
|
|
|
|
bs_info[2] = _( "start " ) + formatCoord( primitive.m_End ); // Start point
|
|
|
|
bs_info[3] = wxString::Format( _( "angle %s" ), FMT_ANGLE( primitive.m_ArcAngle ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE: // ring or circle
|
|
|
|
if( primitive.m_Thickness )
|
|
|
|
bs_info[0] = _( "ring" );
|
|
|
|
else
|
|
|
|
bs_info[0] = _( "circle" );
|
|
|
|
|
|
|
|
bs_info[1] = formatCoord( primitive.m_Start );
|
|
|
|
bs_info[2] = wxString::Format( _( "radius %s" ),
|
|
|
|
CoordinateToString( primitive.m_Radius, true ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON: // polygon
|
|
|
|
bs_info[0] = "Polygon";
|
2018-02-20 10:00:40 +00:00
|
|
|
bs_info[1] = wxString::Format( _( "corners count %d" ), (int) primitive.m_Poly.size() );
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bs_info[0] = "Unknown primitive";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-09-20 08:28:52 +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 )
|
|
|
|
{
|
2017-09-20 08:28:52 +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
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
m_drawPadOutlineMode = m_cbShowPadOutline->GetValue();
|
|
|
|
|
|
|
|
if( m_parent->IsGalCanvasActive() )
|
|
|
|
{
|
|
|
|
KIGFX::VIEW* view = m_panelShowPadGal->GetView();
|
|
|
|
|
|
|
|
// fix the pad render mode (filled/not filled)
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
|
|
|
|
|
|
|
settings->SetSketchMode( LAYER_PADS_TH, m_drawPadOutlineMode );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_FR, m_drawPadOutlineMode );
|
|
|
|
settings->SetSketchMode( LAYER_PAD_BK, m_drawPadOutlineMode );
|
|
|
|
settings->SetSketchModeGraphicItems( m_drawPadOutlineMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2017-01-13 17:51:22 +00:00
|
|
|
bool is_custom = false;
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
switch( m_PadShape->GetSelection() )
|
|
|
|
{
|
2016-04-06 18:15:49 +00:00
|
|
|
case CHOICE_SHAPE_CIRCLE:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_trapDeltaDirChoice->Enable( false );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( false );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_ShapeOffset_X_Ctrl->Enable( false );
|
|
|
|
m_ShapeOffset_Y_Ctrl->Enable( false );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case CHOICE_SHAPE_OVAL:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_trapDeltaDirChoice->Enable( false );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_ShapeOffset_X_Ctrl->Enable( true );
|
|
|
|
m_ShapeOffset_Y_Ctrl->Enable( true );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case CHOICE_SHAPE_RECT:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_trapDeltaDirChoice->Enable( false );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_ShapeOffset_X_Ctrl->Enable( true );
|
|
|
|
m_ShapeOffset_Y_Ctrl->Enable( true );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case CHOICE_SHAPE_TRAPEZOID:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( true );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_trapDeltaDirChoice->Enable( true );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
2012-03-08 20:44:03 +00:00
|
|
|
m_ShapeOffset_X_Ctrl->Enable( true );
|
|
|
|
m_ShapeOffset_Y_Ctrl->Enable( true );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
case CHOICE_SHAPE_ROUNDRECT:
|
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
|
|
|
m_trapDeltaDirChoice->Enable( false );
|
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
|
|
|
m_ShapeOffset_X_Ctrl->Enable( true );
|
|
|
|
m_ShapeOffset_Y_Ctrl->Enable( true );
|
2016-04-10 10:40:31 +00:00
|
|
|
// Ensure m_tcCornerSizeRatio contains the right value:
|
|
|
|
m_tcCornerSizeRatio->ChangeValue( wxString::Format( "%.1f",
|
|
|
|
m_dummyPad->GetRoundRectRadiusRatio()*100 ) );
|
2016-04-06 18:15:49 +00:00
|
|
|
break;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
case CHOICE_SHAPE_CUSTOM_CIRC_ANCHOR: // PAD_SHAPE_CUSTOM, circular anchor
|
|
|
|
case CHOICE_SHAPE_CUSTOM_RECT_ANCHOR: // PAD_SHAPE_CUSTOM, rect anchor
|
|
|
|
is_custom = true;
|
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
|
|
|
m_trapDeltaDirChoice->Enable( false );
|
|
|
|
m_ShapeSize_Y_Ctrl->Enable(
|
|
|
|
m_PadShape->GetSelection() == CHOICE_SHAPE_CUSTOM_RECT_ANCHOR );
|
|
|
|
m_ShapeOffset_X_Ctrl->Enable( false );
|
|
|
|
m_ShapeOffset_Y_Ctrl->Enable( false );
|
|
|
|
break;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2017-09-20 13:37:20 +00:00
|
|
|
enablePrimitivePage( is_custom );
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
// A few widgets are enabled only for rounded rect pads:
|
2016-05-19 16:38:36 +00:00
|
|
|
m_tcCornerSizeRatio->Enable( m_PadShape->GetSelection() == CHOICE_SHAPE_ROUNDRECT );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
// PAD_SHAPE_CUSTOM type has constraints for zone connection and thermal shape:
|
2018-03-11 16:23:51 +00:00
|
|
|
// only not connected or solid connection is allowed to avoid destroying the shape.
|
2017-12-21 09:23:17 +00:00
|
|
|
// Enable/disable options only available for custom shaped pads
|
2017-01-13 17:51:22 +00:00
|
|
|
m_ZoneConnectionChoice->Enable( !is_custom );
|
2018-03-11 16:23:51 +00:00
|
|
|
m_ZoneConnectionCustom->Enable( is_custom );
|
2017-01-13 17:51:22 +00:00
|
|
|
m_ThermalWidthCtrl->Enable( !is_custom );
|
|
|
|
m_ThermalGapCtrl->Enable( !is_custom );
|
2017-12-21 09:23:17 +00:00
|
|
|
|
|
|
|
m_sbSizerZonesSettings->Show( !is_custom );
|
|
|
|
m_sbSizerCustomShapedZonesSettings->Show( 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();
|
2014-07-09 09:22:43 +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-02-19 04:02:19 +00:00
|
|
|
if( m_PadType->GetSelection() == 1 || m_PadType->GetSelection() == 2 )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
|
|
|
// pad type = SMD or CONN: no hole allowed
|
2009-11-05 20:59:42 +00:00
|
|
|
m_PadDrill_X_Ctrl->Enable( false );
|
|
|
|
m_PadDrill_Y_Ctrl->Enable( false );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
else
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
switch( m_DrillShapeCtrl->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0: //CIRCLE:
|
|
|
|
m_PadDrill_X_Ctrl->Enable( true );
|
|
|
|
m_PadDrill_Y_Ctrl->Enable( false );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: //OVALE:
|
|
|
|
m_PadDrill_X_Ctrl->Enable( true );
|
|
|
|
m_PadDrill_Y_Ctrl->Enable( true );
|
|
|
|
break;
|
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
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();
|
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
|
|
|
{
|
|
|
|
switch( m_PadOrient->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0:
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad->SetOrientation( 0 );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad->SetOrientation( 900 );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad->SetOrientation( -900 );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2012-02-19 04:02:19 +00:00
|
|
|
m_dummyPad->SetOrientation( 1800 );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
m_OrientValue = m_dummyPad->GetOrientation() / 10.0;
|
|
|
|
m_OrientValidator.TransferToWindow();
|
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();
|
2008-11-22 11:10:40 +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
|
|
|
{
|
2014-04-24 18:54:49 +00:00
|
|
|
unsigned ii = m_PadType->GetSelection();
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ii >= DIM( code_type ) ) // catches < 0 also
|
2008-11-22 11:10:40 +00:00
|
|
|
ii = 0;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layer_mask = std_pad_layers[ii];
|
2012-04-11 23:30:06 +00:00
|
|
|
setPadLayersList( layer_mask );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
// Enable/disable drill dialog items:
|
2010-09-11 16:33:43 +00:00
|
|
|
event.SetId( m_DrillShapeCtrl->GetSelection() );
|
2008-11-22 11:10:40 +00:00
|
|
|
OnDrillShapeSelected( event );
|
2012-03-17 02:11:44 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ii == 0 || ii == DIM( code_type )-1 )
|
2012-03-08 20:44:03 +00:00
|
|
|
m_DrillShapeCtrl->Enable( true );
|
|
|
|
else
|
|
|
|
m_DrillShapeCtrl->Enable( false );
|
2011-08-19 13:08:24 +00:00
|
|
|
|
|
|
|
// Enable/disable Pad name,and pad length die
|
|
|
|
// (disable for NPTH pads (mechanical pads)
|
|
|
|
bool enable = ii != 3;
|
|
|
|
m_PadNumCtrl->Enable( enable );
|
2014-04-24 18:54:49 +00:00
|
|
|
m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
|
2012-12-12 11:57:17 +00:00
|
|
|
m_LengthPadToDieCtrl->Enable( enable );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::setPadLayersList( LSET layer_mask )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET cu_set = layer_mask & LSET::AllCuMask();
|
|
|
|
|
|
|
|
if( cu_set == LSET( F_Cu ) )
|
2014-11-19 18:39:02 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 0 );
|
2014-06-24 16:17:18 +00:00
|
|
|
else if( cu_set == LSET( B_Cu ) )
|
2014-11-19 18:39:02 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 1 );
|
2014-06-24 16:17:18 +00:00
|
|
|
else if( cu_set.any() )
|
2014-11-19 18:39:02 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 2 );
|
2011-08-19 13:08:24 +00:00
|
|
|
else
|
2014-11-19 18:39:02 +00:00
|
|
|
m_rbCopperLayersSel->SetSelection( 3 );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
// Called when select/deselect a layer.
|
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-03-10 13:00:31 +00:00
|
|
|
// test if all values are acceptable for the pad
|
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 );
|
2015-12-27 15:51:13 +00:00
|
|
|
bool skip_tstoffset = false; // the offset prm is not always tested
|
2012-03-10 13:00:31 +00:00
|
|
|
|
|
|
|
wxArrayString error_msgs;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
// Test for incorrect values
|
2014-11-19 18:39:02 +00:00
|
|
|
if( (m_dummyPad->GetSize().x <= 0) ||
|
2015-08-23 19:40:33 +00:00
|
|
|
((m_dummyPad->GetSize().y <= 0) && (m_dummyPad->GetShape() != PAD_SHAPE_CIRCLE)) )
|
2014-11-19 18:39:02 +00:00
|
|
|
{
|
|
|
|
error_msgs.Add( _( "Pad size must be greater than zero" ) );
|
|
|
|
}
|
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
if( (m_dummyPad->GetSize().x < m_dummyPad->GetDrillSize().x) ||
|
|
|
|
(m_dummyPad->GetSize().y < m_dummyPad->GetDrillSize().y) )
|
|
|
|
{
|
|
|
|
error_msgs.Add( _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
|
2015-12-27 15:51:13 +00:00
|
|
|
skip_tstoffset = true; // offset prm will be not tested because if the drill value
|
|
|
|
// is incorrect the offset prm is always seen as incorrect, even if it is 0
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 07:36:20 +00:00
|
|
|
if( m_dummyPad->GetLocalClearance() < 0 )
|
|
|
|
{
|
|
|
|
error_msgs.Add( _( "Pad local clearance must be zero or greater than zero" ) );
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
// Hovewer, a negative value can give strange result with custom shapes, so it is not
|
|
|
|
// allowed for custom pad shape
|
2017-10-20 07:36:20 +00:00
|
|
|
if( m_dummyPad->GetLocalSolderMaskMargin() < 0 )
|
|
|
|
{
|
2017-12-16 19:43:47 +00:00
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE_CUSTOM )
|
|
|
|
error_msgs.Add( _( "Pad local solder mask clearance must be zero or greater than zero" ) );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int min_smClearance = -std::min( m_dummyPad->GetSize().x, m_dummyPad->GetSize().y )/2;
|
|
|
|
|
|
|
|
if( m_dummyPad->GetLocalSolderMaskMargin() <= min_smClearance )
|
|
|
|
{
|
|
|
|
error_msgs.Add( wxString::Format(
|
|
|
|
_( "Pad local solder mask clearance must be greater than %s" ),
|
|
|
|
StringFromValue( g_UserUnit, min_smClearance, true ) ) );
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
// Hovewer, a positive value can create issues if the resulting shape is too big.
|
|
|
|
// (like a solder paste creating a solder paste area on a neighbour pad or on the solder mask)
|
|
|
|
// So we could ask for user to confirm the choice
|
2018-02-16 08:02:25 +00:00
|
|
|
// Currently there are no test
|
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 )
|
2014-03-19 20:06:09 +00:00
|
|
|
error_msgs.Add( _( "Error: pad has no layer" ) );
|
|
|
|
|
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
|
|
|
{
|
|
|
|
if( m_dummyPad->GetDrillSize().x || m_dummyPad->GetDrillSize().y )
|
|
|
|
{
|
2014-03-05 17:40:23 +00:00
|
|
|
// Note: he message is shown in an HTML window
|
|
|
|
msg = _( "Error: the pad is not on a copper layer and has a hole" );
|
2013-10-02 20:25:44 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
|
2012-03-10 13:00:31 +00:00
|
|
|
{
|
2014-11-19 18:39:02 +00:00
|
|
|
msg += wxT( "<br><br><i>" );
|
|
|
|
msg += _( "For NPTH pad, set pad size value to pad drill value,"
|
|
|
|
" if you do not want this pad plotted in gerber files"
|
|
|
|
);
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
2013-10-02 20:25:44 +00:00
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
error_msgs.Add( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
if( !skip_tstoffset )
|
2012-03-10 13:00:31 +00:00
|
|
|
{
|
2015-12-27 15:51:13 +00:00
|
|
|
wxPoint max_size;
|
|
|
|
max_size.x = std::abs( m_dummyPad->GetOffset().x );
|
|
|
|
max_size.y = std::abs( m_dummyPad->GetOffset().y );
|
|
|
|
max_size.x += m_dummyPad->GetDrillSize().x / 2;
|
|
|
|
max_size.y += m_dummyPad->GetDrillSize().y / 2;
|
|
|
|
|
|
|
|
if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||
|
|
|
|
( m_dummyPad->GetSize().y / 2 < max_size.y ) )
|
|
|
|
{
|
|
|
|
error_msgs.Add( _( "Incorrect value for pad offset" ) );
|
|
|
|
}
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( error )
|
|
|
|
{
|
|
|
|
error_msgs.Add( _( "Too large value for pad delta size" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( m_dummyPad->GetAttribute() )
|
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_ATTRIB_HOLE_NOT_PLATED: // Not plated, but through hole, a hole is expected
|
|
|
|
case PAD_ATTRIB_STANDARD : // Pad through hole, a hole is also expected
|
2018-06-17 12:29:26 +00:00
|
|
|
if( m_dummyPad->GetDrillSize().x <= 0 ||
|
|
|
|
( m_dummyPad->GetDrillSize().y <= 0 && m_dummyPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ) )
|
2014-03-19 20:06:09 +00:00
|
|
|
error_msgs.Add( _( "Error: Through hole pad: drill diameter set to 0" ) );
|
2013-10-02 20:25:44 +00:00
|
|
|
break;
|
2012-03-10 13:00:31 +00:00
|
|
|
|
2015-08-23 19:40:33 +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] )
|
2014-03-19 20:06:09 +00:00
|
|
|
error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n"
|
|
|
|
"Use SMD pads instead" ) );
|
|
|
|
// Fall trough
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_ATTRIB_SMD: // SMD and Connector pads (One external copper layer only)
|
2015-10-10 16:56:31 +00:00
|
|
|
{
|
|
|
|
LSET innerlayers_mask = padlayers_mask & LSET::InternalCuMask();
|
|
|
|
|
|
|
|
if( ( padlayers_mask[F_Cu] && padlayers_mask[B_Cu] ) ||
|
|
|
|
innerlayers_mask.count() != 0 )
|
|
|
|
error_msgs.Add( _( "Error: only one external copper layer allowed for SMD or Connector pads" ) );
|
|
|
|
}
|
2014-09-10 15:18:42 +00:00
|
|
|
break;
|
2012-03-10 13:00:31 +00:00
|
|
|
}
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE_ROUNDRECT )
|
|
|
|
{
|
|
|
|
wxString value = m_tcCornerSizeRatio->GetValue();
|
|
|
|
double rrRadiusRatioPercent;
|
|
|
|
|
|
|
|
if( !value.ToDouble( &rrRadiusRatioPercent ) )
|
|
|
|
error_msgs.Add( _( "Incorrect corner size value" ) );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( rrRadiusRatioPercent < 0.0 )
|
|
|
|
error_msgs.Add( _( "Incorrect (negative) corner size value" ) );
|
|
|
|
else if( rrRadiusRatioPercent > 50.0 )
|
|
|
|
error_msgs.Add( _( "Corner size value must be smaller than 50%" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
if( m_dummyPad->GetShape() == PAD_SHAPE_CUSTOM )
|
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
if( !m_dummyPad->MergePrimitivesAsPolygon( ) )
|
2017-01-13 17:51:22 +00:00
|
|
|
error_msgs.Add(
|
|
|
|
_( "Incorrect pad shape: the shape must be equivalent to only one polygon" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-10 13:00:31 +00:00
|
|
|
if( error_msgs.GetCount() )
|
|
|
|
{
|
|
|
|
HTML_MESSAGE_BOX dlg( this, _("Pad setup errors list" ) );
|
|
|
|
dlg.ListSet( error_msgs );
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
if( m_parent->IsGalCanvasActive() )
|
|
|
|
{
|
2018-01-12 18:46:44 +00:00
|
|
|
KIGFX::VIEW* view = m_panelShowPadGal->GetView();
|
2017-01-13 17:51:22 +00:00
|
|
|
m_panelShowPadGal->StopDrawing();
|
|
|
|
|
2018-01-13 16:05:09 +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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
view->Update( m_dummyPad );
|
|
|
|
|
|
|
|
// delete previous items if highlight list
|
|
|
|
while( m_highligth.size() )
|
|
|
|
{
|
|
|
|
delete m_highligth.back(); // the dtor also removes item from view
|
|
|
|
m_highligth.pop_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
// highlight selected primitives:
|
2017-09-20 08:28:52 +00:00
|
|
|
long select = m_listCtrlPrimitives->GetFirstSelected();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
while( select >= 0 )
|
|
|
|
{
|
|
|
|
PAD_CS_PRIMITIVE& primitive = m_primitives[select];
|
|
|
|
|
|
|
|
DRAWSEGMENT* dummySegment = new DRAWSEGMENT;
|
2018-01-13 16:05:09 +00:00
|
|
|
dummySegment->SetLayer( SELECTED_ITEMS_LAYER );
|
2017-01-13 17:51:22 +00:00
|
|
|
primitive.ExportTo( dummySegment );
|
|
|
|
dummySegment->Rotate( wxPoint( 0, 0), m_dummyPad->GetOrientation() );
|
|
|
|
dummySegment->Move( m_dummyPad->GetPosition() );
|
|
|
|
|
|
|
|
// Update selected primitive (highligth selected)
|
|
|
|
switch( primitive.m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
|
|
|
case S_ARC:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE: // ring or circle
|
|
|
|
if( primitive.m_Thickness == 0 ) // filled circle
|
|
|
|
{ // the filled circle option does not exist in a DRAWSEGMENT
|
|
|
|
// but it is easy to create it with a circle having the
|
|
|
|
// right radius and outline width
|
|
|
|
wxPoint end = dummySegment->GetCenter();
|
|
|
|
end.x += primitive.m_Radius/2;
|
|
|
|
dummySegment->SetEnd( end );
|
|
|
|
dummySegment->SetWidth( primitive.m_Radius );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-01-13 16:05:09 +00:00
|
|
|
case S_POLYGON:
|
2017-01-13 17:51:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
delete dummySegment;
|
|
|
|
dummySegment = nullptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( dummySegment )
|
|
|
|
{
|
|
|
|
view->Add( dummySegment );
|
|
|
|
m_highligth.push_back( dummySegment );
|
|
|
|
}
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
select = m_listCtrlPrimitives->GetNextSelected( select );
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
2014-07-09 09:22:43 +00:00
|
|
|
|
|
|
|
BOX2I bbox = m_dummyPad->ViewBBox();
|
|
|
|
|
2014-07-28 12:01:29 +00:00
|
|
|
if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
|
|
|
|
{
|
2016-07-19 09:16:16 +00:00
|
|
|
// gives a size to the full drawable area
|
|
|
|
BOX2I drawbox;
|
|
|
|
drawbox.Move( m_dummyPad->GetPosition() );
|
|
|
|
drawbox.Inflate( bbox.GetSize().x*2, bbox.GetSize().y*2 );
|
2017-01-13 17:51:22 +00:00
|
|
|
view->SetBoundary( drawbox );
|
2016-07-19 09:16:16 +00:00
|
|
|
|
2014-07-28 12:01:29 +00:00
|
|
|
// Autozoom
|
2017-01-13 17:51:22 +00:00
|
|
|
view->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2014-07-28 12:01:29 +00:00
|
|
|
// Add a margin
|
2017-01-13 17:51:22 +00:00
|
|
|
view->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
m_panelShowPadGal->StartDrawing();
|
2014-07-28 12:01:29 +00:00
|
|
|
m_panelShowPadGal->Refresh();
|
|
|
|
}
|
2014-07-09 09:22:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_panelShowPad->Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
bool rastnestIsChanged = false;
|
|
|
|
int isign = m_isFlipped ? -1 : 1;
|
|
|
|
|
2014-04-24 18:54:49 +00:00
|
|
|
transferDataToPad( m_padMaster );
|
|
|
|
// 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 );
|
|
|
|
m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
|
|
|
|
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() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
if( m_currentPad->GetPosition() != m_padMaster->GetPosition() )
|
|
|
|
{
|
|
|
|
m_currentPad->SetPosition( m_padMaster->GetPosition() );
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2017-03-11 21:18:45 +00:00
|
|
|
wxSize size;
|
|
|
|
MODULE* footprint = m_currentPad->GetParent();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2017-03-11 21:18:45 +00:00
|
|
|
if( footprint )
|
|
|
|
{
|
|
|
|
footprint->SetLastEditTime();
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2017-03-11 21:18:45 +00:00
|
|
|
// 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_padMaster->GetOrientation() * isign
|
|
|
|
+ footprint->GetOrientation() );
|
|
|
|
}
|
2011-08-19 13:08:24 +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();
|
|
|
|
size.y *= isign;
|
|
|
|
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();
|
|
|
|
offset.y *= isign;
|
|
|
|
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
|
|
|
|
2017-01-13 17:51:22 +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() );
|
2017-09-20 08:28:52 +00:00
|
|
|
m_currentPad->SetPrimitives( m_padMaster->GetPrimitives() );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( m_isFlipped )
|
|
|
|
{
|
|
|
|
m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
|
2017-09-20 08:28:52 +00:00
|
|
|
m_currentPad->FlipPrimitives();
|
2017-01-13 17:51:22 +00:00
|
|
|
}
|
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
if( m_currentPad->GetLayerSet() != m_padMaster->GetLayerSet() )
|
|
|
|
{
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() );
|
|
|
|
}
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
if( m_isFlipped )
|
|
|
|
{
|
|
|
|
m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
|
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2017-08-11 09:22:13 +00:00
|
|
|
m_currentPad->SetName( m_padMaster->GetName() );
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
wxString padNetname;
|
2014-04-24 18:54:49 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
// For PAD_ATTRIB_HOLE_NOT_PLATED, ensure there is no net name selected
|
|
|
|
if( m_padMaster->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
|
|
|
|
padNetname = m_PadNetNameCtrl->GetValue();
|
|
|
|
|
|
|
|
if( m_currentPad->GetNetname() != padNetname )
|
|
|
|
{
|
|
|
|
const NETINFO_ITEM* netinfo = m_board->FindNet( padNetname );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
if( !padNetname.IsEmpty() && netinfo == NULL )
|
2016-04-10 10:40:31 +00:00
|
|
|
{
|
2016-06-20 13:46:58 +00:00
|
|
|
DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
|
2016-04-10 10:40:31 +00:00
|
|
|
}
|
2016-06-20 13:46:58 +00:00
|
|
|
else if( netinfo )
|
|
|
|
{
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
m_currentPad->SetNetCode( netinfo->GetNet() );
|
|
|
|
}
|
|
|
|
}
|
2016-04-10 10:40:31 +00:00
|
|
|
|
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() );
|
|
|
|
m_currentPad->SetThermalWidth( m_padMaster->GetThermalWidth() );
|
|
|
|
m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
|
|
|
|
m_currentPad->SetRoundRectRadiusRatio( m_padMaster->GetRoundRectRadiusRatio() );
|
|
|
|
|
2017-12-21 09:23:17 +00:00
|
|
|
if( m_currentPad->GetShape() == PAD_SHAPE_CUSTOM )
|
2018-03-11 16:23:51 +00:00
|
|
|
{
|
|
|
|
if( m_padMaster->GetZoneConnection() == PAD_ZONE_CONN_FULL )
|
|
|
|
m_currentPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
|
|
|
|
else
|
|
|
|
m_currentPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
|
|
|
|
}
|
2017-12-21 09:23:17 +00:00
|
|
|
else
|
|
|
|
m_currentPad->SetZoneConnection( m_padMaster->GetZoneConnection() );
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
if( m_currentPad->GetShape() == PAD_SHAPE_ROUNDRECT &&
|
|
|
|
m_currentPad->GetRoundRectRadiusRatio() == 0.0 )
|
|
|
|
{
|
|
|
|
m_currentPad->SetShape( PAD_SHAPE_RECT );
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
|
|
|
|
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() );
|
|
|
|
|
2017-05-29 18:47:21 +00:00
|
|
|
if( footprint )
|
|
|
|
footprint->CalculateBoundingBox();
|
|
|
|
|
2016-06-20 13:46:58 +00:00
|
|
|
m_parent->SetMsgPanel( m_currentPad );
|
|
|
|
|
|
|
|
// redraw the area where the pad was
|
|
|
|
m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
|
|
|
|
|
|
|
|
commit.Push( _( "Modify pad" ) );
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( rastnestIsChanged ) // The net ratsnest must be recalculated
|
2013-03-30 09:28:59 +00:00
|
|
|
m_board->m_Status_Pcb = 0;
|
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
|
|
|
|
2012-04-11 23:30:06 +00:00
|
|
|
bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxString msg;
|
|
|
|
int x, y;
|
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;
|
|
|
|
|
|
|
|
m_OrientValidator.TransferFromWindow();
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
aPad->SetAttribute( code_type[m_PadType->GetSelection()] );
|
|
|
|
aPad->SetShape( code_shape[m_PadShape->GetSelection()] );
|
2017-01-13 17:51:22 +00:00
|
|
|
aPad->SetAnchorPadShape( m_PadShape->GetSelection() == CHOICE_SHAPE_CUSTOM_RECT_ANCHOR ?
|
|
|
|
PAD_SHAPE_RECT : PAD_SHAPE_CIRCLE );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
|
2017-09-20 08:28:52 +00:00
|
|
|
aPad->SetPrimitives( m_primitives );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// Read pad clearances values:
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
aPad->SetLocalClearance( ValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
|
|
|
|
aPad->SetLocalSolderMaskMargin( ValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
|
|
|
|
aPad->SetLocalSolderPasteMargin( ValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
|
|
|
|
aPad->SetThermalWidth( ValueFromTextCtrl( *m_ThermalWidthCtrl ) );
|
|
|
|
aPad->SetThermalGap( ValueFromTextCtrl( *m_ThermalGapCtrl ) );
|
2010-09-11 16:33:43 +00:00
|
|
|
double dtmp = 0.0;
|
2009-11-05 20:59:42 +00:00
|
|
|
msg = m_SolderPasteMarginRatioCtrl->GetValue();
|
|
|
|
msg.ToDouble( &dtmp );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2012-05-18 08:33:57 +00:00
|
|
|
// A -50% margin ratio means no paste on a pad, the ratio must be >= -50%
|
|
|
|
if( dtmp < -50.0 )
|
|
|
|
dtmp = -50.0;
|
|
|
|
// A margin ratio is always <= 0
|
|
|
|
// 0 means use full pad copper area
|
|
|
|
if( dtmp > 0.0 )
|
|
|
|
dtmp = 0.0;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
aPad->SetLocalSolderPasteMarginRatio( dtmp / 100 );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
switch( m_ZoneConnectionChoice->GetSelection() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0:
|
2015-08-18 14:19:17 +00:00
|
|
|
aPad->SetZoneConnection( PAD_ZONE_CONN_INHERITED );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2015-08-18 14:19:17 +00:00
|
|
|
aPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2015-08-18 14:19:17 +00:00
|
|
|
aPad->SetZoneConnection( PAD_ZONE_CONN_THERMAL );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2015-08-18 14:19:17 +00:00
|
|
|
aPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
|
2012-02-24 23:23:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-11 16:23:51 +00:00
|
|
|
// Custom shape has only 2 options:
|
|
|
|
if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
|
|
|
|
{
|
|
|
|
if( m_ZoneConnectionCustom->GetSelection() == 0 )
|
|
|
|
aPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
|
|
|
|
else
|
|
|
|
aPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
|
|
|
|
}
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// Read pad position:
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
x = ValueFromTextCtrl( *m_PadPosition_X_Ctrl );
|
|
|
|
y = ValueFromTextCtrl( *m_PadPosition_Y_Ctrl );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
aPad->SetPosition( wxPoint( x, y ) );
|
|
|
|
aPad->SetPos0( wxPoint( x, y ) );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad drill:
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
x = ValueFromTextCtrl( *m_PadDrill_X_Ctrl );
|
|
|
|
y = ValueFromTextCtrl( *m_PadDrill_Y_Ctrl );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_DrillShapeCtrl->GetSelection() == 0 )
|
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
aPad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
|
2012-02-19 04:02:19 +00:00
|
|
|
y = x;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
else
|
2015-08-23 19:40:33 +00:00
|
|
|
aPad->SetDrillShape( PAD_DRILL_SHAPE_OBLONG );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
aPad->SetDrillSize( wxSize( x, y ) );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad shape size:
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
x = ValueFromTextCtrl( *m_ShapeSize_X_Ctrl );
|
|
|
|
y = ValueFromTextCtrl( *m_ShapeSize_Y_Ctrl );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
|
2012-02-19 04:02:19 +00:00
|
|
|
y = x;
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
// for custom shped pads, the pad size is the anchor pad size:
|
|
|
|
if( aPad->GetShape() == PAD_SHAPE_CUSTOM && aPad->GetAnchorPadShape() == PAD_SHAPE_CIRCLE )
|
|
|
|
y = x;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetSize( wxSize( x, y ) );
|
|
|
|
|
|
|
|
// Read pad length die
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
aPad->SetPadToDieLength( ValueFromTextCtrl( *m_LengthPadToDieCtrl ) );
|
2009-11-05 20:59:42 +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;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2015-10-10 16:56:31 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE_TRAPEZOID )
|
2010-09-11 16:33:43 +00:00
|
|
|
{
|
2015-10-10 16:56:31 +00:00
|
|
|
wxSize delta;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2015-10-10 16:56:31 +00:00
|
|
|
// For a trapezoid, only one of delta.x or delta.y is not 0, depending on
|
|
|
|
// the direction.
|
|
|
|
if( m_trapDeltaDirChoice->GetSelection() == 0 )
|
|
|
|
delta.x = ValueFromTextCtrl( *m_ShapeDelta_Ctrl );
|
|
|
|
else
|
|
|
|
delta.y = ValueFromTextCtrl( *m_ShapeDelta_Ctrl );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2015-10-10 16:56:31 +00:00
|
|
|
if( delta.x < 0 && delta.x <= -aPad->GetSize().y )
|
|
|
|
{
|
|
|
|
delta.x = -aPad->GetSize().y + 2;
|
|
|
|
error = true;
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2015-10-10 16:56:31 +00:00
|
|
|
if( delta.x > 0 && delta.x >= aPad->GetSize().y )
|
|
|
|
{
|
|
|
|
delta.x = aPad->GetSize().y - 2;
|
|
|
|
error = true;
|
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2015-10-10 16:56:31 +00:00
|
|
|
if( delta.y < 0 && delta.y <= -aPad->GetSize().x )
|
|
|
|
{
|
|
|
|
delta.y = -aPad->GetSize().x + 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( delta.y > 0 && delta.y >= aPad->GetSize().x )
|
|
|
|
{
|
|
|
|
delta.y = aPad->GetSize().x - 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
aPad->SetDelta( delta );
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// Read pad shape offset:
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
x = ValueFromTextCtrl( *m_ShapeOffset_X_Ctrl );
|
|
|
|
y = ValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl );
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetOffset( wxPoint( x, y ) );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2016-04-10 22:14:28 +00:00
|
|
|
aPad->SetOrientation( m_OrientValue * 10.0 );
|
2017-08-11 09:22:13 +00:00
|
|
|
aPad->SetName( m_PadNumCtrl->GetValue() );
|
Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.
I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.
Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 09:41:52 +00:00
|
|
|
|
|
|
|
// Check if user has set an existing net name
|
|
|
|
const NETINFO_ITEM* netinfo = m_board->FindNet( m_PadNetNameCtrl->GetValue() );
|
2014-04-24 18:54:49 +00:00
|
|
|
|
Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.
I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.
Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 09:41:52 +00:00
|
|
|
if( netinfo != NULL )
|
2014-02-25 10:40:34 +00:00
|
|
|
aPad->SetNetCode( netinfo->GetNet() );
|
Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.
I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.
Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 09:41:52 +00:00
|
|
|
else
|
2014-02-25 10:40:34 +00:00
|
|
|
aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-02-12 17:15:47 +00:00
|
|
|
// Clear some values, according to the pad type and shape
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( aPad->GetShape() )
|
2010-02-12 17:15:47 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_CIRCLE:
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetOffset( wxPoint( 0, 0 ) );
|
|
|
|
aPad->SetDelta( wxSize( 0, 0 ) );
|
|
|
|
x = aPad->GetSize().x;
|
|
|
|
aPad->SetSize( wxSize( x, x ) );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_RECT:
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetDelta( wxSize( 0, 0 ) );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_OVAL:
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetDelta( wxSize( 0, 0 ) );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_SHAPE_TRAPEZOID:
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
case PAD_SHAPE_ROUNDRECT:
|
|
|
|
aPad->SetDelta( wxSize( 0, 0 ) );
|
|
|
|
break;
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
case PAD_SHAPE_CUSTOM:
|
|
|
|
aPad->SetOffset( wxPoint( 0, 0 ) );
|
|
|
|
aPad->SetDelta( wxSize( 0, 0 ) );
|
|
|
|
|
|
|
|
// The pad custom has a "anchor pad" (a basic shape: round or rect pad)
|
|
|
|
// that is the minimal area of this pad, and is usefull to ensure a hole
|
|
|
|
// diameter is acceptable, and is used in Gerber files as flashed area
|
|
|
|
// reference
|
|
|
|
if( aPad->GetAnchorPadShape() == PAD_SHAPE_CIRCLE )
|
|
|
|
{
|
|
|
|
x = aPad->GetSize().x;
|
|
|
|
aPad->SetSize( wxSize( x, x ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
default:
|
|
|
|
;
|
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
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_ATTRIB_STANDARD:
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-23 19:40:33 +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;
|
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
case PAD_ATTRIB_HOLE_NOT_PLATED:
|
2011-08-19 13:08:24 +00:00
|
|
|
// Mechanical purpose only:
|
|
|
|
// no offset, no net name, no pad name allowed
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad->SetOffset( wxPoint( 0, 0 ) );
|
2017-08-11 09:22:13 +00:00
|
|
|
aPad->SetName( wxEmptyString );
|
2014-02-25 10:40:34 +00:00
|
|
|
aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-08-19 13:08:24 +00:00
|
|
|
DisplayError( NULL, wxT( "Error: unknown pad type" ) );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
if( aPad->GetShape() == PAD_SHAPE_ROUNDRECT )
|
|
|
|
{
|
|
|
|
wxString value = m_tcCornerSizeRatio->GetValue();
|
|
|
|
double rrRadiusRatioPercent;
|
|
|
|
|
|
|
|
if( value.ToDouble( &rrRadiusRatioPercent ) )
|
|
|
|
aPad->SetRoundRectRadiusRatio( rrRadiusRatioPercent / 100.0 );
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET padLayerMask;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2011-08-19 13:08:24 +00:00
|
|
|
switch( m_rbCopperLayersSel->GetSelection() )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
case 0:
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( F_Cu );
|
2012-02-19 04:02:19 +00:00
|
|
|
break;
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
case 1:
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask.set( B_Cu );
|
2012-02-19 04:02:19 +00:00
|
|
|
break;
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
case 2:
|
2014-06-24 16:17:18 +00:00
|
|
|
padLayerMask |= LSET::AllCuMask();
|
2012-02-19 04:02:19 +00:00
|
|
|
break;
|
2011-08-19 13:08:24 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
case 3: // 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
|
|
|
|
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 );
|
2016-04-06 18:15:49 +00:00
|
|
|
// If the pad size has changed, update the displayed values
|
|
|
|
// for rounded rect pads
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
PAD_CS_PRIMITIVE& shape = m_primitives[select];
|
|
|
|
|
|
|
|
if( shape.m_Shape == S_POLYGON )
|
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
DIALOG_PAD_PRIMITIVE_POLY_PROPS dlg( this, &shape );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
dlg.TransferDataFromWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_PROPERTIES dlg( this, &shape );
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Called on a double click on the basic shapes list
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Called on a click on basic shapes list panel button
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Called on a click on basic shapes list panel button
|
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
|
|
|
|
wxString shapelist[] =
|
|
|
|
{
|
|
|
|
_( "Segment" ), _( "Arc" ), _( "ring/circle" ), _( "polygon" )
|
|
|
|
};
|
|
|
|
|
2017-09-30 14:34:02 +00:00
|
|
|
int type = wxGetSingleChoiceIndex( wxEmptyString, _( "Select shape type:" ),
|
2018-06-08 10:52:35 +00:00
|
|
|
DIM( shapelist ), shapelist, 0, this );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
STROKE_T listtype[] =
|
|
|
|
{
|
|
|
|
S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON
|
|
|
|
};
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
PAD_CS_PRIMITIVE primitive( listtype[type] );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( listtype[type] == S_POLYGON )
|
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
DIALOG_PAD_PRIMITIVE_POLY_PROPS dlg( this, &primitive );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-20 08:28:52 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_PROPERTIES dlg( this, &primitive );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
m_primitives.push_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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::onImportPrimitives( wxCommandEvent& event )
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
|
|
|
wxMessageBox( "Not yet available" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
std::vector<PAD_CS_PRIMITIVE*> shapeList;
|
|
|
|
shapeList.push_back( &m_primitives[select] );
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
|
2017-01-13 17:51:22 +00:00
|
|
|
shapeList.push_back( &m_primitives[select] );
|
|
|
|
|
2017-09-20 14:14:23 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_TRANSFORM dlg( this, shapeList, false );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Transfert new settings:
|
|
|
|
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
|
|
|
|
std::vector<PAD_CS_PRIMITIVE*> shapeList;
|
|
|
|
shapeList.push_back( &m_primitives[select] );
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
while( ( select = m_listCtrlPrimitives->GetNextSelected( select ) ) >= 0 )
|
2017-01-13 17:51:22 +00:00
|
|
|
shapeList.push_back( &m_primitives[select] );
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_TRANSFORM dlg( this, 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
|
|
|
|
std::vector<PAD_CS_PRIMITIVE> duplicates;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|