kicad/pcbnew/dialogs/dialog_pad_properties.cpp

1245 lines
38 KiB
C++
Raw Normal View History

/**
* @file dialog_pad_properties.cpp
* @brief Pad editing functions and dialog pad editor.
*/
2008-11-22 11:10:40 +00:00
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#include <fctsys.h>
#include <common.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <pcbnew.h>
#include <trigo.h>
#include <macros.h>
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <base_units.h>
#include <wx/dcbuffer.h>
2008-11-22 11:10:40 +00:00
#include <class_board.h>
#include <class_module.h>
#include <dialog_pad_properties_base.h>
#include <html_messagebox.h>
2012-02-19 04:02:19 +00:00
// list of pad shapes.
static PAD_SHAPE_T code_shape[] = {
PAD_SHAPE_CIRCLE,
PAD_SHAPE_OVAL,
PAD_SHAPE_RECT,
PAD_SHAPE_TRAPEZOID
2008-11-22 11:10:40 +00:00
};
static PAD_ATTR_T code_type[] = {
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
// Default mask layers setup for pads according to the pad type
static const LSET std_pad_layers[] = {
// PAD_ATTRIB_STANDARD:
D_PAD::StandardMask(),
2008-11-22 11:10:40 +00:00
// PAD_ATTRIB_SMD:
D_PAD::SMDMask(),
2008-11-22 11:10:40 +00:00
// PAD_ATTRIB_CONN:
D_PAD::ConnSMDMask(),
// PAD_ATTRIB_HOLE_NOT_PLATED:
D_PAD::UnplatedHoleMask()
2008-11-22 11:10:40 +00:00
};
/**
* class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
* created by wxFormBuilder
*/
class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
2008-11-22 11:10:40 +00:00
{
public:
2012-02-19 04:02:19 +00:00
DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
~DIALOG_PAD_PROPERTIES()
{
delete m_dummyPad;
}
private:
PCB_BASE_FRAME* m_parent;
D_PAD* m_currentPad; // pad currently being edited
D_PAD* m_dummyPad; // a working copy used to show changes
D_PAD* m_padMaster; // The pad used to create new pads in board or
// footprint editor
BOARD* m_board; // the main board: this is the board handled by
// the PCB editor, if running or the dummy
// board used by the footprint editor
// (could happen when the Footprint editor will be run
// alone, outside the board editor
2012-02-19 04:02:19 +00:00
bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
// in this case, some Y coordinates values must be negated
bool m_canUpdate;
bool m_canEditNetName; // true only if the called is the board editor
2012-02-19 04:02:19 +00:00
private:
void initValues();
2012-03-17 02:11:44 +00:00
bool padValuesOK(); ///< test if all values are acceptable for the pad
2012-03-17 02:11:44 +00:00
void redraw();
2012-03-17 02:11:44 +00:00
/**
* Function setPadLayersList
2012-03-17 02:11:44 +00:00
* updates the CheckBox states in pad layers list,
* @param layer_mask = pad layer mask (ORed layers bit mask)
*/
void setPadLayersList( LSET layer_mask );
/// Copy values from dialog field to aPad's members
bool transferDataToPad( D_PAD* aPad );
// event handlers:
void OnResize( wxSizeEvent& event );
void OnPadShapeSelection( wxCommandEvent& event );
void OnDrillShapeSelected( wxCommandEvent& event );
void PadOrientEvent( wxCommandEvent& event );
void PadTypeSelected( wxCommandEvent& event );
2012-03-17 02:11:44 +00:00
void OnSetLayers( wxCommandEvent& event );
void OnCancelButtonClick( wxCommandEvent& event );
void OnPaintShowPanel( wxPaintEvent& event );
2012-03-17 02:11:44 +00:00
/// Called when a dimension has changed.
/// Update the graphical pad shown in the panel.
void OnValuesChanged( wxCommandEvent& event );
/// Updates the different parameters for the component being edited.
2012-04-11 23:51:16 +00:00
/// Fired from the OK button click.
void PadPropertiesAccept( wxCommandEvent& event );
2008-11-22 11:10:40 +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 ) :
DIALOG_PAD_PROPERTIES_BASE( aParent )
2012-02-19 04:02:19 +00:00
{
m_canUpdate = false;
m_parent = aParent;
2014-03-14 07:37:04 +00:00
m_currentPad = aPad; // aPad can be NULL, if the dialog is called
// from the module editor to set default pad characteristics
m_board = m_parent->GetBoard();
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 )
m_dummyPad->Copy( aPad );
else // We are editing a "master" pad, i.e. a pad used to create new pads
m_dummyPad->Copy( m_padMaster );
2012-02-19 04:02:19 +00:00
if( m_parent->IsGalCanvasActive() )
{
m_panelShowPadGal->UseColorScheme( m_board->GetColorsSettings() );
m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() );
m_panelShowPadGal->Show();
m_panelShowPad->Hide();
m_panelShowPadGal->GetView()->Add( m_dummyPad );
m_panelShowPadGal->StartDrawing();
Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_PAD_PROPERTIES::OnResize ) );
}
else
{
m_panelShowPad->Show();
m_panelShowPadGal->Hide();
}
2012-02-19 04:02:19 +00:00
initValues();
m_sdbSizer1OK->SetDefault();
GetSizer()->SetSizeHints( this );
m_PadNumCtrl->SetFocus();
2012-02-19 04:02:19 +00:00
m_canUpdate = true;
}
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
{
wxPaintDC dc( m_panelShowPad );
PAD_DRAWINFO drawInfo;
2013-04-09 19:20:21 +00:00
EDA_COLOR_T color = BLACK;
if( m_dummyPad->GetLayerSet()[F_Cu] )
{
color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
}
if( m_dummyPad->GetLayerSet()[B_Cu] )
{
2013-04-09 19:20:21 +00:00
color = ColorMix( color, m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) );
}
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 )
color = LIGHTGRAY;
drawInfo.m_Color = color;
drawInfo.m_HoleColor = DARKGRAY;
2012-02-19 04:02:19 +00:00
drawInfo.m_Offset = m_dummyPad->GetPosition();
drawInfo.m_Display_padnum = true;
drawInfo.m_Display_netname = true;
2012-03-17 02:11:44 +00:00
if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
drawInfo.m_ShowNotPlatedHole = true;
// Shows the local pad clearance
2012-02-19 04:02:19 +00:00
drawInfo.m_PadClearance = m_dummyPad->GetLocalClearance();
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
int dim = m_dummyPad->GetSize().x + std::abs( m_dummyPad->GetDelta().y );
// 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 )
dim = Millimeter2iu( 1.0 );
}
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;
// If the pad is a circle, use the x size here instead.
int ysize;
if( m_dummyPad->GetShape() == PAD_SHAPE_CIRCLE )
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 )
dim = Millimeter2iu( 0.1 );
}
2012-02-19 04:02:19 +00:00
if( m_dummyPad->GetLocalClearance() > 0 )
dim += m_dummyPad->GetLocalClearance() * 2;
double altscale = (double) dc_size.y / dim;
scale = std::min( scale, altscale );
// Give a margin
scale *= 0.7;
dc.SetUserScale( scale, scale );
2011-04-18 20:22:17 +00:00
GRResetPenAndBrush( &dc );
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
// Draw X and Y axis.
// this is particularly useful to show the reference position of pads
// with offset and no hole
2013-04-09 19:20:21 +00:00
GRLine( NULL, &dc, -dim, 0, dim, 0, 0, BLUE ); // X axis
GRLine( NULL, &dc, 0, -dim, 0, dim, 0, BLUE ); // Y axis
event.Skip();
}
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;
// 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 );
// Setup layers names from board
// Should be made first, before calling m_rbCopperLayersSel->SetSelection()
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 ) );
m_isFlipped = false;
2012-02-19 04:02:19 +00:00
if( m_currentPad )
{
MODULE* module = m_currentPad->GetParent();
2012-02-19 04:02:19 +00:00
if( module->GetLayer() == B_Cu )
{
m_isFlipped = true;
m_staticModuleSideValue->SetLabel( _( "Back side (footprint is mirrored)" ) );
}
2012-02-19 04:02:19 +00:00
//Internal angles are in 0.1 degree
msg.Printf( wxT( "%.1f" ), module->GetOrientation() / 10.0 );
m_staticModuleRotValue->SetLabel( msg );
}
2008-11-22 11:10:40 +00:00
if( m_isFlipped )
{
2012-02-19 04:02:19 +00:00
wxPoint pt = m_dummyPad->GetOffset();
pt.y = -pt.y;
2012-02-19 04:02:19 +00:00
m_dummyPad->SetOffset( pt );
wxSize sz = m_dummyPad->GetDelta();
sz.y = -sz.y;
2012-02-19 04:02:19 +00:00
m_dummyPad->SetDelta( sz );
// flip pad's layers
m_dummyPad->SetLayerSet( FlipLayerMask( m_dummyPad->GetLayerSet() ) );
}
2012-02-19 04:02:19 +00:00
m_staticTextWarningPadFlipped->Show(m_isFlipped);
2008-11-22 11:10:40 +00:00
2011-12-12 08:37:05 +00:00
m_PadNumCtrl->SetValue( m_dummyPad->GetPadName() );
m_PadNetNameCtrl->SetValue( m_dummyPad->GetNetname() );
2008-11-22 11:10:40 +00:00
// Display current unit name in dialog:
m_PadPosX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadPosY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadDrill_X_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadDrill_Y_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeSizeX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeSizeY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeOffsetX_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeOffsetY_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadShapeDelta_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_PadLengthDie_Unit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
// Display current pad masks clearances units
m_NetClearanceUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_SolderMaskMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_ThermalWidthUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
m_ThermalGapUnits->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
// Display current pad parameters units:
PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x );
PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y );
PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x );
PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y );
PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x );
PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y );
PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x );
PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->GetOffset().y );
2012-02-19 04:02:19 +00:00
if( m_dummyPad->GetDelta().x )
{
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x );
m_trapDeltaDirChoice->SetSelection( 0 );
}
else
{
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().y );
m_trapDeltaDirChoice->SetSelection( 1 );
}
PutValueInLocalUnits( *m_LengthPadToDieCtrl, m_dummyPad->GetPadToDieLength() );
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->GetLocalClearance() );
PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_dummyPad->GetLocalSolderMaskMargin() );
PutValueInLocalUnits( *m_ThermalWidthCtrl, m_dummyPad->GetThermalWidth() );
PutValueInLocalUnits( *m_ThermalGapCtrl, m_dummyPad->GetThermalGap() );
// These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0
PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_dummyPad->GetLocalSolderPasteMargin() );
2012-02-19 04:02:19 +00:00
if( m_dummyPad->GetLocalSolderPasteMargin() == 0 )
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
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
m_SolderPasteMarginRatioCtrl->SetValue( wxT( "-" ) + msg );
else
m_SolderPasteMarginRatioCtrl->SetValue( msg );
2008-11-22 11:10:40 +00:00
switch( m_dummyPad->GetZoneConnection() )
{
default:
case PAD_ZONE_CONN_INHERITED:
m_ZoneConnectionChoice->SetSelection( 0 );
break;
case PAD_ZONE_CONN_FULL:
m_ZoneConnectionChoice->SetSelection( 1 );
break;
case PAD_ZONE_CONN_THERMAL:
m_ZoneConnectionChoice->SetSelection( 2 );
break;
case PAD_ZONE_CONN_NONE:
m_ZoneConnectionChoice->SetSelection( 3 );
break;
}
if( m_currentPad )
2008-11-22 11:10:40 +00:00
{
MODULE* module = m_currentPad->GetParent();
2012-02-19 04:02:19 +00:00
angle = m_currentPad->GetOrientation() - module->GetOrientation();
2012-02-19 04:02:19 +00:00
if( m_isFlipped )
angle = -angle;
2012-02-19 04:02:19 +00:00
m_dummyPad->SetOrientation( angle );
2008-11-22 11:10:40 +00:00
}
2012-02-19 04:02:19 +00:00
angle = m_dummyPad->GetOrientation();
2012-02-19 04:02:19 +00:00
NORMALIZE_ANGLE_180( angle ); // ? normalizing is in D_PAD::SetOrientation()
2012-02-19 04:02:19 +00:00
// Set layers used by this pad: :
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;
case -900:
2008-11-22 11:10:40 +00:00
m_PadOrient->SetSelection( 2 );
break;
case 1800:
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:
case PAD_SHAPE_CIRCLE:
2008-11-22 11:10:40 +00:00
m_PadShape->SetSelection( 0 );
break;
case PAD_SHAPE_OVAL:
2008-11-22 11:10:40 +00:00
m_PadShape->SetSelection( 1 );
break;
case PAD_SHAPE_RECT:
2008-11-22 11:10:40 +00:00
m_PadShape->SetSelection( 2 );
break;
case PAD_SHAPE_TRAPEZOID:
2008-11-22 11:10:40 +00:00
m_PadShape->SetSelection( 3 );
break;
}
2012-02-19 04:02:19 +00:00
msg.Printf( wxT( "%g" ), angle );
m_PadOrientCtrl->SetValue( msg );
2008-11-22 11:10:40 +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
for( unsigned ii = 0; ii < DIM( code_type ); ii++ )
2008-11-22 11:10:40 +00:00
{
if( code_type[ii] == m_dummyPad->GetAttribute() )
2008-11-22 11:10:40 +00:00
{
m_PadType->SetSelection( ii );
break;
2008-11-22 11:10:40 +00:00
}
}
// Enable/disable Pad name,and pad length die
// (disable for NPTH pads (mechanical pads)
bool enable = m_dummyPad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED;
2012-02-19 04:02:19 +00:00
m_PadNumCtrl->Enable( enable );
m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
m_LengthPadToDieCtrl->Enable( enable );
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 );
2012-02-19 04:02:19 +00:00
// Update some dialog widgets state (Enable/disable options):
wxCommandEvent cmd_event;
setPadLayersList( m_dummyPad->GetLayerSet() );
OnDrillShapeSelected( cmd_event );
OnPadShapeSelection( cmd_event );
2008-11-22 11:10:40 +00:00
}
void DIALOG_PAD_PROPERTIES::OnResize( wxSizeEvent& event )
{
redraw();
event.Skip();
}
void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
2008-11-22 11:10:40 +00:00
{
switch( m_PadShape->GetSelection() )
{
case 0: // PAD_SHAPE_CIRCLE:
m_ShapeDelta_Ctrl->Enable( false );
m_trapDeltaDirChoice->Enable( false );
m_ShapeSize_Y_Ctrl->Enable( false );
m_ShapeOffset_X_Ctrl->Enable( false );
m_ShapeOffset_Y_Ctrl->Enable( false );
2008-11-22 11:10:40 +00:00
break;
case 1: // PAD_SHAPE_OVAL:
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 );
2008-11-22 11:10:40 +00:00
break;
case 2: // PAD_SHAPE_RECT:
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 );
2008-11-22 11:10:40 +00:00
break;
case 3: // PAD_SHAPE_TRAPEZOID:
m_ShapeDelta_Ctrl->Enable( true );
m_trapDeltaDirChoice->Enable( true );
m_ShapeSize_Y_Ctrl->Enable( true );
m_ShapeOffset_X_Ctrl->Enable( true );
m_ShapeOffset_Y_Ctrl->Enable( true );
2008-11-22 11:10:40 +00:00
break;
}
transferDataToPad( m_dummyPad );
redraw();
2008-11-22 11:10:40 +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 )
{
// pad type = SMD or CONN: no hole allowed
m_PadDrill_X_Ctrl->Enable( false );
m_PadDrill_Y_Ctrl->Enable( false );
2008-11-22 11:10:40 +00:00
}
else
2008-11-22 11:10:40 +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
}
transferDataToPad( m_dummyPad );
redraw();
2008-11-22 11:10:40 +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;
}
wxString msg;
2012-01-04 06:18:38 +00:00
msg.Printf( wxT( "%g" ), m_dummyPad->GetOrientation() );
m_PadOrientCtrl->SetValue( msg );
transferDataToPad( m_dummyPad );
redraw();
2008-11-22 11:10:40 +00:00
}
void DIALOG_PAD_PROPERTIES::PadTypeSelected( wxCommandEvent& event )
2008-11-22 11:10:40 +00:00
{
unsigned ii = m_PadType->GetSelection();
2008-11-22 11:10:40 +00:00
if( ii >= DIM( code_type ) ) // catches < 0 also
2008-11-22 11:10:40 +00:00
ii = 0;
LSET layer_mask = std_pad_layers[ii];
setPadLayersList( layer_mask );
2008-11-22 11:10:40 +00:00
// Enable/disable drill dialog items:
event.SetId( m_DrillShapeCtrl->GetSelection() );
2008-11-22 11:10:40 +00:00
OnDrillShapeSelected( event );
2012-03-17 02:11:44 +00:00
if( ii == 0 || ii == DIM( code_type )-1 )
m_DrillShapeCtrl->Enable( true );
else
m_DrillShapeCtrl->Enable( false );
// Enable/disable Pad name,and pad length die
// (disable for NPTH pads (mechanical pads)
bool enable = ii != 3;
m_PadNumCtrl->Enable( enable );
m_PadNetNameCtrl->Enable( m_canEditNetName && enable && m_currentPad != NULL );
m_LengthPadToDieCtrl->Enable( enable );
2008-11-22 11:10:40 +00:00
}
void DIALOG_PAD_PROPERTIES::setPadLayersList( LSET layer_mask )
2008-11-22 11:10:40 +00:00
{
LSET cu_set = layer_mask & LSET::AllCuMask();
if( cu_set == LSET( F_Cu ) )
m_rbCopperLayersSel->SetSelection( 0 );
else if( cu_set == LSET( B_Cu ) )
m_rbCopperLayersSel->SetSelection( 1 );
else if( cu_set.any() )
m_rbCopperLayersSel->SetSelection( 2 );
else
m_rbCopperLayersSel->SetSelection( 3 );
2008-11-22 11:10:40 +00:00
m_PadLayerAdhCmp->SetValue( layer_mask[F_Adhes] );
m_PadLayerAdhCu->SetValue( layer_mask[B_Adhes] );
2008-11-22 11:10:40 +00:00
m_PadLayerPateCmp->SetValue( layer_mask[F_Paste] );
m_PadLayerPateCu->SetValue( layer_mask[B_Paste] );
2008-11-22 11:10:40 +00:00
m_PadLayerSilkCmp->SetValue( layer_mask[F_SilkS] );
m_PadLayerSilkCu->SetValue( layer_mask[B_SilkS] );
2008-11-22 11:10:40 +00:00
m_PadLayerMaskCmp->SetValue( layer_mask[F_Mask] );
m_PadLayerMaskCu->SetValue( layer_mask[B_Mask] );
2008-11-22 11:10:40 +00:00
m_PadLayerECO1->SetValue( layer_mask[Eco1_User] );
m_PadLayerECO2->SetValue( layer_mask[Eco2_User] );
2008-11-22 11:10:40 +00:00
m_PadLayerDraft->SetValue( layer_mask[Dwgs_User] );
2008-11-22 11:10:40 +00:00
}
// Called when select/deselect a layer.
void DIALOG_PAD_PROPERTIES::OnSetLayers( wxCommandEvent& event )
{
transferDataToPad( m_dummyPad );
redraw();
}
2012-03-17 02:11:44 +00:00
// test if all values are acceptable for the pad
bool DIALOG_PAD_PROPERTIES::padValuesOK()
{
bool error = transferDataToPad( m_dummyPad );
bool skip_tstoffset = false; // the offset prm is not always tested
wxArrayString error_msgs;
wxString msg;
// Test for incorrect values
if( (m_dummyPad->GetSize().x <= 0) ||
((m_dummyPad->GetSize().y <= 0) && (m_dummyPad->GetShape() != PAD_SHAPE_CIRCLE)) )
{
error_msgs.Add( _( "Pad size must be greater than zero" ) );
}
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" ) );
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
}
LSET padlayers_mask = m_dummyPad->GetLayerSet();
if( padlayers_mask == 0 )
error_msgs.Add( _( "Error: pad has no layer" ) );
if( !padlayers_mask[F_Cu] && !padlayers_mask[B_Cu] )
{
if( m_dummyPad->GetDrillSize().x || m_dummyPad->GetDrillSize().y )
{
// Note: he message is shown in an HTML window
msg = _( "Error: the pad is not on a copper layer and has a hole" );
if( m_dummyPad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED )
{
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"
);
}
error_msgs.Add( msg );
}
}
if( !skip_tstoffset )
{
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" ) );
}
}
if( error )
{
error_msgs.Add( _( "Too large value for pad delta size" ) );
}
switch( m_dummyPad->GetAttribute() )
{
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
if( m_dummyPad->GetDrillSize().x <= 0 )
error_msgs.Add( _( "Error: Through hole pad: drill diameter set to 0" ) );
break;
case PAD_ATTRIB_CONN: // Connector pads are smd pads, just they do not have solder paste.
if( padlayers_mask[B_Paste] || padlayers_mask[F_Paste] )
error_msgs.Add( _( "Error: Connector pads are not on the solder paste layer\n"
"Use SMD pads instead" ) );
// Fall trough
case PAD_ATTRIB_SMD: // SMD and Connector pads (One external copper layer only)
{
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" ) );
}
break;
}
if( error_msgs.GetCount() )
{
HTML_MESSAGE_BOX dlg( this, _("Pad setup errors list" ) );
dlg.ListSet( error_msgs );
dlg.ShowModal();
}
return error_msgs.GetCount() == 0;
}
2008-11-22 11:10:40 +00:00
void DIALOG_PAD_PROPERTIES::redraw()
{
if( m_parent->IsGalCanvasActive() )
{
m_dummyPad->ViewUpdate();
BOX2I bbox = m_dummyPad->ViewBBox();
if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 )
{
// Autozoom
m_panelShowPadGal->GetView()->SetViewport( BOX2D( bbox.GetOrigin(), bbox.GetSize() ) );
// Add a margin
m_panelShowPadGal->GetView()->SetScale( m_panelShowPadGal->GetView()->GetScale() * 0.7 );
m_panelShowPadGal->Refresh();
}
}
else
{
m_panelShowPad->Refresh();
}
}
2012-03-17 02:11:44 +00:00
void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
2008-11-22 11:10:40 +00:00
{
if( !padValuesOK() )
return;
bool rastnestIsChanged = false;
int isign = m_isFlipped ? -1 : 1;
transferDataToPad( m_padMaster );
// m_padMaster is a pattern: ensure there is no net for this pad:
m_padMaster->SetNetCode( NETINFO_LIST::UNCONNECTED );
if( m_currentPad ) // Set current Pad parameters
{
2012-02-19 04:02:19 +00:00
wxSize size;
MODULE* module = m_currentPad->GetParent();
2012-02-19 04:02:19 +00:00
m_parent->SaveCopyInUndoList( module, UR_CHANGED );
module->SetLastEditTime();
// 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 );
// Update values
m_currentPad->SetShape( m_padMaster->GetShape() );
m_currentPad->SetAttribute( m_padMaster->GetAttribute() );
if( m_currentPad->GetPosition() != m_padMaster->GetPosition() )
{
m_currentPad->SetPosition( m_padMaster->GetPosition() );
2012-02-19 04:02:19 +00:00
rastnestIsChanged = true;
}
2012-02-19 04:02:19 +00:00
// compute the pos 0 value, i.e. pad position for module with orientation = 0
// i.e. relative to module origin (module position)
wxPoint pt = m_currentPad->GetPosition() - module->GetPosition();
2012-02-19 04:02:19 +00:00
RotatePoint( &pt, -module->GetOrientation() );
m_currentPad->SetPos0( pt );
2012-02-19 04:02:19 +00:00
m_currentPad->SetOrientation( m_padMaster->GetOrientation() * isign + module->GetOrientation() );
2012-02-19 04:02:19 +00:00
m_currentPad->SetSize( m_padMaster->GetSize() );
size = m_padMaster->GetDelta();
2012-02-19 04:02:19 +00:00
size.y *= isign;
m_currentPad->SetDelta( size );
m_currentPad->SetDrillSize( m_padMaster->GetDrillSize() );
m_currentPad->SetDrillShape( m_padMaster->GetDrillShape() );
wxPoint offset = m_padMaster->GetOffset();
2012-02-19 04:02:19 +00:00
offset.y *= isign;
m_currentPad->SetOffset( offset );
2012-02-19 04:02:19 +00:00
m_currentPad->SetPadToDieLength( m_padMaster->GetPadToDieLength() );
2012-02-19 04:02:19 +00:00
if( m_currentPad->GetLayerSet() != m_padMaster->GetLayerSet() )
{
rastnestIsChanged = true;
m_currentPad->SetLayerSet( m_padMaster->GetLayerSet() );
}
2012-02-19 04:02:19 +00:00
if( m_isFlipped )
m_currentPad->SetLayerSet( FlipLayerMask( m_currentPad->GetLayerSet() ) );
m_currentPad->SetPadName( m_padMaster->GetPadName() );
wxString padNetname;
// 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 );
2015-03-11 13:17:43 +00:00
if( !padNetname.IsEmpty() && netinfo == NULL )
{
2014-01-14 09:41:52 +00:00
DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
}
2015-03-11 13:17:43 +00:00
else if( netinfo )
{
2014-01-14 09:41:52 +00:00
rastnestIsChanged = true;
m_currentPad->SetNetCode( netinfo->GetNet() );
}
}
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->SetZoneConnection( m_padMaster->GetZoneConnection() );
m_currentPad->SetThermalWidth( m_padMaster->GetThermalWidth() );
m_currentPad->SetThermalGap( m_padMaster->GetThermalGap() );
2012-02-19 04:02:19 +00:00
module->CalculateBoundingBox();
m_parent->SetMsgPanel( m_currentPad );
// redraw the area where the pad was
m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
m_parent->OnModify();
}
EndModal( wxID_OK );
if( rastnestIsChanged ) // The net ratsnest must be recalculated
m_board->m_Status_Pcb = 0;
}
2012-04-11 23:51:16 +00:00
bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
{
2012-02-19 04:02:19 +00:00
wxString msg;
int x, y;
2008-11-22 11:10:40 +00:00
aPad->SetAttribute( code_type[m_PadType->GetSelection()] );
aPad->SetShape( code_shape[m_PadShape->GetSelection()] );
// 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 ) );
double dtmp = 0.0;
msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp );
// 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 );
switch( m_ZoneConnectionChoice->GetSelection() )
{
default:
case 0:
aPad->SetZoneConnection( PAD_ZONE_CONN_INHERITED );
break;
case 1:
aPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
break;
case 2:
aPad->SetZoneConnection( PAD_ZONE_CONN_THERMAL );
break;
case 3:
aPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
break;
}
// 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 ) );
// 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 )
{
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
aPad->SetDrillShape( PAD_DRILL_SHAPE_OBLONG );
2012-02-19 04:02:19 +00:00
aPad->SetDrillSize( wxSize( x, y ) );
// 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 );
if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
2012-02-19 04:02:19 +00:00
y = x;
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 ) );
// For a trapezoid, test delta value (be sure delta is not too large for pad size)
// remember DeltaSize.x is the Y size variation
bool error = false;
2012-02-19 04:02:19 +00:00
if( aPad->GetShape() == PAD_SHAPE_TRAPEZOID )
{
wxSize delta;
2012-02-19 04:02:19 +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
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
if( delta.x > 0 && delta.x >= aPad->GetSize().y )
{
delta.x = aPad->GetSize().y - 2;
error = true;
}
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
// 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 ) );
2012-01-04 06:18:38 +00:00
double orient_value = 0;
msg = m_PadOrientCtrl->GetValue();
2012-01-04 06:18:38 +00:00
msg.ToDouble( &orient_value );
aPad->SetOrientation( orient_value );
2008-11-22 11:10:40 +00:00
msg = m_PadNumCtrl->GetValue().Left( 4 );
aPad->SetPadName( msg );
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-01-14 09:41:52 +00:00
if( netinfo != NULL )
aPad->SetNetCode( netinfo->GetNet() );
2014-01-14 09:41:52 +00:00
else
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
{
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;
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;
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;
case PAD_SHAPE_TRAPEZOID:
2010-02-12 17:15:47 +00:00
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
{
case PAD_ATTRIB_STANDARD:
2010-02-12 17:15:47 +00:00
break;
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
// and are intended to be used in virtual edge board connectors
// However we can accept a non null offset,
// mainly to allow complex pads build from a set of from 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;
case PAD_ATTRIB_HOLE_NOT_PLATED:
// 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 ) );
aPad->SetPadName( wxEmptyString );
aPad->SetNetCode( NETINFO_LIST::UNCONNECTED );
2010-02-12 17:15:47 +00:00
break;
default:
DisplayError( NULL, wxT( "Error: unknown pad type" ) );
2010-02-12 17:15:47 +00:00
break;
}
LSET padLayerMask;
2012-02-19 04:02:19 +00:00
switch( m_rbCopperLayersSel->GetSelection() )
{
2012-02-19 04:02:19 +00:00
case 0:
padLayerMask.set( F_Cu );
2012-02-19 04:02:19 +00:00
break;
2012-02-19 04:02:19 +00:00
case 1:
padLayerMask.set( B_Cu );
2012-02-19 04:02:19 +00:00
break;
2012-02-19 04:02:19 +00:00
case 2:
padLayerMask |= LSET::AllCuMask();
2012-02-19 04:02:19 +00:00
break;
2012-02-19 04:02:19 +00:00
case 3: // No copper layers
break;
}
2008-11-22 11:10:40 +00:00
if( m_PadLayerAdhCmp->GetValue() )
padLayerMask.set( F_Adhes );
2008-11-22 11:10:40 +00:00
if( m_PadLayerAdhCu->GetValue() )
padLayerMask.set( B_Adhes );
2008-11-22 11:10:40 +00:00
if( m_PadLayerPateCmp->GetValue() )
padLayerMask.set( F_Paste );
2008-11-22 11:10:40 +00:00
if( m_PadLayerPateCu->GetValue() )
padLayerMask.set( B_Paste );
2008-11-22 11:10:40 +00:00
if( m_PadLayerSilkCmp->GetValue() )
padLayerMask.set( F_SilkS );
2008-11-22 11:10:40 +00:00
if( m_PadLayerSilkCu->GetValue() )
padLayerMask.set( B_SilkS );
2008-11-22 11:10:40 +00:00
if( m_PadLayerMaskCmp->GetValue() )
padLayerMask.set( F_Mask );
2008-11-22 11:10:40 +00:00
if( m_PadLayerMaskCu->GetValue() )
padLayerMask.set( B_Mask );
2008-11-22 11:10:40 +00:00
if( m_PadLayerECO1->GetValue() )
padLayerMask.set( Eco1_User );
2008-11-22 11:10:40 +00:00
if( m_PadLayerECO2->GetValue() )
padLayerMask.set( Eco2_User );
2008-11-22 11:10:40 +00:00
if( m_PadLayerDraft->GetValue() )
padLayerMask.set( Dwgs_User );
2008-11-22 11:10:40 +00:00
aPad->SetLayerSet( padLayerMask );
2010-03-07 13:33:20 +00:00
return error;
}
2008-11-22 11:10:40 +00:00
void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
{
if( m_canUpdate )
{
transferDataToPad( m_dummyPad );
redraw();
2008-11-22 11:10:40 +00:00
}
}
void DIALOG_PAD_PROPERTIES::OnCancelButtonClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
}