2008-12-23 13:14:01 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
/* dialog_pad_properties.cpp: Pad editing functions and dialog box */
|
|
|
|
/* see also dialog_pad_properties.xxx (built with wxFormBuilder) */
|
|
|
|
/*******************************************************************/
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2008-11-22 11:10:40 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "trigo.h"
|
2010-09-11 16:33:43 +00:00
|
|
|
#include <wx/dcbuffer.h>
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
#define NBSHAPES 4
|
2010-09-11 16:33:43 +00:00
|
|
|
int CodeShape[NBSHAPES] = // list of pad shapes.
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
|
|
|
PAD_CIRCLE, PAD_OVAL, PAD_RECT, PAD_TRAPEZOID
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define NBTYPES 4
|
|
|
|
int CodeType[NBTYPES] =
|
|
|
|
{
|
|
|
|
PAD_STANDARD, PAD_SMD, PAD_CONN, PAD_HOLE_NOT_PLATED
|
|
|
|
};
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
// Default mask layers setup for pads according to the pad type
|
2008-11-22 11:10:40 +00:00
|
|
|
static long Std_Pad_Layers[NBTYPES] =
|
|
|
|
{
|
|
|
|
// PAD_STANDARD:
|
2009-09-23 06:02:37 +00:00
|
|
|
PAD_STANDARD_DEFAULT_LAYERS,
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
// PAD_CONN:
|
2009-09-23 06:02:37 +00:00
|
|
|
PAD_CONN_DEFAULT_LAYERS,
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
// PAD_SMD:
|
2009-09-23 06:02:37 +00:00
|
|
|
PAD_SMD_DEFAULT_LAYERS,
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
//PAD_HOLE_NOT_PLATED:
|
2009-09-23 06:02:37 +00:00
|
|
|
PAD_HOLE_NOT_PLATED_DEFAULT_LAYERS
|
2008-11-22 11:10:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#include "dialog_pad_properties_base.h"
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
extern int ChangeSideMaskLayer( int masque );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
|
|
|
|
* created by wxFormBuilder
|
|
|
|
*/
|
2009-11-05 20:59:42 +00:00
|
|
|
class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2010-03-01 17:48:17 +00:00
|
|
|
private:
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* m_Parent;
|
2010-09-11 16:33:43 +00:00
|
|
|
D_PAD* m_CurrentPad; // Pad currently edited
|
|
|
|
D_PAD* m_dummyPad; // a working copy used to show changes
|
|
|
|
BOARD* m_Board;
|
|
|
|
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;
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
public:
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* parent, D_PAD* Pad );
|
2010-09-11 16:33:43 +00:00
|
|
|
~DIALOG_PAD_PROPERTIES()
|
|
|
|
{
|
|
|
|
delete m_dummyPad;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-01 17:48:17 +00:00
|
|
|
private:
|
2010-09-11 16:33:43 +00:00
|
|
|
void initValues();
|
2008-11-22 11:10:40 +00:00
|
|
|
void OnPadShapeSelection( wxCommandEvent& event );
|
|
|
|
void OnDrillShapeSelected( wxCommandEvent& event );
|
|
|
|
void PadOrientEvent( wxCommandEvent& event );
|
|
|
|
void PadTypeSelected( wxCommandEvent& event );
|
|
|
|
void PadPropertiesAccept( wxCommandEvent& event );
|
|
|
|
void SetPadLayersList( long layer_mask );
|
2010-09-11 16:33:43 +00:00
|
|
|
void OnSetLayer( wxCommandEvent& event );
|
|
|
|
void OnCancelButtonClick( wxCommandEvent& event );
|
|
|
|
void OnPaintShowPanel( wxPaintEvent& event );
|
|
|
|
bool TransfertDataToPad( D_PAD* aPad, bool aPromptOnError = false );
|
|
|
|
void OnValuesChanged( wxCommandEvent& event );
|
2008-11-22 11:10:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
|
|
|
|
{
|
|
|
|
wxPaintDC dc( m_panelShowPad );
|
|
|
|
PAD_DRAWINFO drawInfo;
|
|
|
|
|
|
|
|
int color = 0;
|
|
|
|
|
|
|
|
if( m_dummyPad->m_Masque_Layer & LAYER_FRONT )
|
|
|
|
{
|
|
|
|
color = m_Board->GetVisibleElementColor( PAD_FR_VISIBLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_dummyPad->m_Masque_Layer & LAYER_BACK )
|
|
|
|
{
|
|
|
|
color |= m_Board->GetVisibleElementColor( PAD_BK_VISIBLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( color == 0 )
|
|
|
|
color = LIGHTGRAY;
|
|
|
|
|
|
|
|
drawInfo.m_Color = color;
|
|
|
|
drawInfo.m_HoleColor = DARKGRAY;
|
|
|
|
drawInfo.m_Offset = m_dummyPad->m_Pos;
|
|
|
|
drawInfo.m_Display_padnum = true;
|
|
|
|
drawInfo.m_Display_netname = true;
|
|
|
|
|
|
|
|
// Shows the local pad clearance
|
|
|
|
drawInfo.m_PadClearance = m_dummyPad->m_LocalClearance;
|
|
|
|
|
|
|
|
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
|
2010-09-11 19:15:24 +00:00
|
|
|
int dim = m_dummyPad->m_Size.x + ABS( m_dummyPad->m_DeltaSize.y);
|
|
|
|
if( m_dummyPad->m_LocalClearance > 0 )
|
|
|
|
dim += m_dummyPad->m_LocalClearance * 2;
|
|
|
|
double scale = (double) dc_size.x / dim;
|
|
|
|
dim = m_dummyPad->m_Size.y + ABS( m_dummyPad->m_DeltaSize.x);
|
|
|
|
if( m_dummyPad->m_LocalClearance > 0 )
|
|
|
|
dim += m_dummyPad->m_LocalClearance * 2;
|
|
|
|
double altscale = (double) dc_size.y / dim;
|
2010-09-11 16:33:43 +00:00
|
|
|
scale = MIN( scale, altscale );
|
|
|
|
|
|
|
|
// Give a margin
|
|
|
|
scale *= 0.7;
|
|
|
|
dc.SetUserScale( scale, scale );
|
|
|
|
|
|
|
|
m_dummyPad->DrawShape( NULL, &dc, drawInfo );
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
/*******************************************************************************************/
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* parent, D_PAD* Pad ) :
|
2009-11-05 20:59:42 +00:00
|
|
|
DIALOG_PAD_PROPERTIES_BASE( parent )
|
2008-11-22 11:10:40 +00:00
|
|
|
/*******************************************************************************************/
|
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
m_canUpdate = false;
|
|
|
|
m_Parent = parent;
|
2008-11-22 11:10:40 +00:00
|
|
|
m_CurrentPad = Pad;
|
2010-09-11 16:33:43 +00:00
|
|
|
m_Board = m_Parent->GetBoard();
|
|
|
|
m_dummyPad = new D_PAD( (MODULE*) NULL );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
if( m_CurrentPad )
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->Copy( m_CurrentPad );
|
|
|
|
else
|
|
|
|
m_dummyPad->Copy( &g_Pad_Master );
|
2009-08-23 15:22:44 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
initValues();
|
2010-01-20 12:43:05 +00:00
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
m_sdbSizer1OK->SetDefault();
|
2010-09-11 16:33:43 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2010-01-20 12:43:05 +00:00
|
|
|
Center();
|
2010-09-11 16:33:43 +00:00
|
|
|
m_canUpdate = true;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* Pad )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2009-12-19 19:24:49 +00:00
|
|
|
DIALOG_PAD_PROPERTIES dlg( this, Pad );
|
2010-04-23 14:46:00 +00:00
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
dlg.ShowModal();
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
/***************************************/
|
|
|
|
void DIALOG_PAD_PROPERTIES::initValues()
|
|
|
|
/***************************************/
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
SetFocus(); // Required under wxGTK if we want to demiss the dialog with the ESC key
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
int internalUnits = m_Parent->m_InternalUnits;
|
2009-11-06 12:55:20 +00:00
|
|
|
wxString msg;
|
2010-09-11 16:33:43 +00:00
|
|
|
m_isFlipped = false;
|
|
|
|
if( m_CurrentPad )
|
|
|
|
{
|
|
|
|
MODULE* Module = (MODULE*) m_CurrentPad->GetParent();
|
|
|
|
if( Module->GetLayer() == LAYER_N_BACK )
|
|
|
|
{
|
|
|
|
m_isFlipped = true;
|
|
|
|
m_staticModuleSideValue->SetLabel( _( "Back side (footprint is mirrored)" ) );
|
|
|
|
}
|
|
|
|
msg.Printf( wxT( "%.1f" ), (double) Module->m_Orient / 10 );
|
|
|
|
m_staticModuleRotValue->SetLabel( msg );
|
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( m_isFlipped )
|
|
|
|
{
|
|
|
|
NEGATE( m_dummyPad->m_Offset.y );
|
|
|
|
NEGATE( m_dummyPad->m_DeltaSize.y );
|
|
|
|
/* flip pads layers*/
|
|
|
|
m_dummyPad->m_Masque_Layer = ChangeSideMaskLayer( m_dummyPad->m_Masque_Layer );
|
|
|
|
}
|
2010-09-11 19:15:24 +00:00
|
|
|
m_staticTextWarningPadFlipped->Show(m_isFlipped);
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
m_PadNumCtrl->SetValue( m_dummyPad->ReturnStringPadName() );
|
|
|
|
m_PadNetNameCtrl->SetValue( m_dummyPad->GetNetname() );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// Display current unit name in dialog:
|
2010-07-12 14:07:09 +00:00
|
|
|
m_PadPosX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadPosY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadDrill_X_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadDrill_Y_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadShapeSizeX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadShapeSizeY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadShapeOffsetX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_PadShapeOffsetY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
2010-09-15 14:53:33 +00:00
|
|
|
m_PadShapeDelta_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
2010-07-12 14:07:09 +00:00
|
|
|
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// Display current pad masks clearances units
|
2010-07-12 14:07:09 +00:00
|
|
|
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
|
|
|
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Display current pad parameters units:
|
2010-09-11 16:33:43 +00:00
|
|
|
PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->m_Pos.x, internalUnits );
|
|
|
|
PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->m_Pos.y, internalUnits );
|
|
|
|
|
|
|
|
PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->m_Drill.x, internalUnits );
|
|
|
|
PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->m_Drill.y, internalUnits );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->m_Size.x, internalUnits );
|
|
|
|
PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->m_Size.y, internalUnits );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->m_Offset.x, internalUnits );
|
|
|
|
PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->m_Offset.y, internalUnits );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2010-09-15 14:53:33 +00:00
|
|
|
if( m_dummyPad->m_DeltaSize.x )
|
|
|
|
{
|
|
|
|
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.x, internalUnits );
|
|
|
|
m_radioBtnDeltaXdir->SetValue(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.y, internalUnits );
|
|
|
|
m_radioBtnDeltaYdir->SetValue(true);
|
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->m_LocalClearance, internalUnits );
|
|
|
|
PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
|
|
|
|
m_dummyPad->m_LocalSolderMaskMargin,
|
|
|
|
internalUnits );
|
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
|
2010-09-11 16:33:43 +00:00
|
|
|
PutValueInLocalUnits( *m_SolderPasteMarginCtrl,
|
|
|
|
m_dummyPad->m_LocalSolderPasteMargin,
|
|
|
|
internalUnits );
|
|
|
|
if( m_dummyPad->m_LocalSolderPasteMargin == 0 )
|
|
|
|
m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() );
|
|
|
|
msg.Printf( wxT( "%.1f" ), m_dummyPad->m_LocalSolderPasteMarginRatio * 100.0 );
|
|
|
|
|
|
|
|
if( m_dummyPad->m_LocalSolderPasteMarginRatio == 0.0
|
|
|
|
&& msg[0] == '0' ) // Sometimes Printf add a sign if the value is small
|
|
|
|
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
|
|
|
|
|
|
|
if( m_CurrentPad )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
MODULE* Module = (MODULE*) m_CurrentPad->GetParent();
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->m_Orient = m_CurrentPad->m_Orient - Module->m_Orient;
|
|
|
|
if( m_isFlipped )
|
|
|
|
NEGATE( m_dummyPad->m_Orient );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
// adjust rotation agngle to -1800 to 1800 in internal units (0.1 deg)
|
|
|
|
NORMALIZE_ANGLE_180( m_dummyPad->m_Orient );
|
|
|
|
|
|
|
|
// Set layers used by this pad: :
|
|
|
|
SetPadLayersList( m_dummyPad->m_Masque_Layer );
|
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
msg.Clear();
|
2010-09-20 16:21:47 +00:00
|
|
|
msg << m_dummyPad->m_Orient;
|
2008-11-22 11:10:40 +00:00
|
|
|
m_PadOrientCtrl->SetValue( msg );
|
|
|
|
|
|
|
|
// Pad Orient
|
2010-09-11 16:33:43 +00:00
|
|
|
switch( m_dummyPad->m_Orient )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_PadOrient->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 900:
|
|
|
|
m_PadOrient->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case - 900:
|
|
|
|
m_PadOrient->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1800:
|
|
|
|
case - 1800:
|
|
|
|
m_PadOrient->SetSelection( 3 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_PadOrient->SetSelection( 4 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
switch( m_dummyPad->m_PadShape )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case PAD_CIRCLE:
|
|
|
|
m_PadShape->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
|
|
|
m_PadShape->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
m_PadShape->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
m_PadShape->SetSelection( 3 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
msg.Printf( wxT( "%d" ), m_dummyPad->m_Orient );
|
|
|
|
m_PadOrientCtrl->SetValue( msg );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
// Selection du type
|
|
|
|
m_PadType->SetSelection( 0 );
|
|
|
|
for( int ii = 0; ii < NBTYPES; ii++ )
|
|
|
|
{
|
2010-09-20 16:21:47 +00:00
|
|
|
if( CodeType[ii] == m_dummyPad->m_Attribut )
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( m_dummyPad->m_DrillShape != PAD_OVAL )
|
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
|
|
|
|
|
|
|
// Setup layers names from board
|
2010-09-11 16:33:43 +00:00
|
|
|
m_PadLayerCu->SetLabel( m_Board->GetLayerName( LAYER_N_BACK ) );
|
|
|
|
m_PadLayerCmp->SetLabel( m_Board->GetLayerName( LAYER_N_FRONT ) );
|
|
|
|
|
|
|
|
m_PadLayerAdhCmp->SetLabel( m_Board->GetLayerName( ADHESIVE_N_FRONT ) );
|
|
|
|
m_PadLayerAdhCu->SetLabel( m_Board->GetLayerName( ADHESIVE_N_BACK ) );
|
|
|
|
m_PadLayerPateCmp->SetLabel( m_Board->GetLayerName( SOLDERPASTE_N_FRONT ) );
|
|
|
|
m_PadLayerPateCu->SetLabel( m_Board->GetLayerName( SOLDERPASTE_N_BACK ) );
|
|
|
|
m_PadLayerSilkCmp->SetLabel( m_Board->GetLayerName( SILKSCREEN_N_FRONT ) );
|
|
|
|
m_PadLayerSilkCu->SetLabel( m_Board->GetLayerName( SILKSCREEN_N_BACK ) );
|
|
|
|
m_PadLayerMaskCmp->SetLabel( m_Board->GetLayerName( SOLDERMASK_N_FRONT ) );
|
|
|
|
m_PadLayerMaskCu->SetLabel( m_Board->GetLayerName( SOLDERMASK_N_BACK ) );
|
|
|
|
m_PadLayerECO1->SetLabel( m_Board->GetLayerName( ECO1_N ) );
|
|
|
|
m_PadLayerECO2->SetLabel( m_Board->GetLayerName( ECO2_N ) );
|
|
|
|
m_PadLayerDraft->SetLabel( m_Board->GetLayerName( DRAW_N ) );
|
|
|
|
|
|
|
|
/* All init are done,
|
|
|
|
* Update some dialog widgets state (Enable/disable options):
|
|
|
|
*/
|
|
|
|
wxCommandEvent cmd_event;
|
|
|
|
OnPadShapeSelection( cmd_event );
|
|
|
|
OnDrillShapeSelected( cmd_event );
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnPadShapeSelection( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
{
|
|
|
|
switch( m_PadShape->GetSelection() )
|
|
|
|
{
|
|
|
|
case 0: //CIRCLE:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
|
|
|
m_radioBtnDeltaXdir->Enable( false );
|
|
|
|
m_radioBtnDeltaYdir->Enable( false );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( false );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: //OVALE:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
|
|
|
m_radioBtnDeltaXdir->Enable( false );
|
|
|
|
m_radioBtnDeltaYdir->Enable( false );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // PAD_RECT:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( false );
|
|
|
|
m_radioBtnDeltaXdir->Enable( false );
|
|
|
|
m_radioBtnDeltaYdir->Enable( false );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: //TRAPEZE:
|
2010-09-15 14:53:33 +00:00
|
|
|
m_ShapeDelta_Ctrl->Enable( true );
|
|
|
|
m_radioBtnDeltaXdir->Enable( true );
|
|
|
|
m_radioBtnDeltaYdir->Enable( true );
|
2009-11-05 20:59:42 +00:00
|
|
|
m_ShapeSize_Y_Ctrl->Enable( true );
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
TransfertDataToPad( m_dummyPad );
|
|
|
|
m_panelShowPad->Refresh();
|
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
|
|
|
/**********************************************************************/
|
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
if( (m_PadType->GetSelection() == 1) || (m_PadType->GetSelection() == 2) )
|
|
|
|
{
|
|
|
|
// 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
|
|
|
|
|
|
|
TransfertDataToPad( m_dummyPad );
|
|
|
|
m_panelShowPad->Refresh();
|
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:
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->m_Orient = 0;
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->m_Orient = 900;
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->m_Orient = -900;
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2010-09-11 16:33:43 +00:00
|
|
|
m_dummyPad->m_Orient = 1800;
|
2008-11-22 11:10:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( wxT( "%d" ), m_dummyPad->m_Orient );
|
|
|
|
m_PadOrientCtrl->SetValue( msg );
|
|
|
|
|
|
|
|
TransfertDataToPad( m_dummyPad );
|
|
|
|
m_panelShowPad->Refresh();
|
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
|
|
|
/*****************************************************************/
|
|
|
|
|
|
|
|
/* Adjust the better mask layer according to the selected pad type
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
long layer_mask;
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
ii = m_PadType->GetSelection();
|
|
|
|
if( (ii < 0) || ( ii >= NBTYPES) )
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
layer_mask = Std_Pad_Layers[ii];
|
|
|
|
SetPadLayersList( layer_mask );
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::SetPadLayersList( long layer_mask )
|
2008-11-22 11:10:40 +00:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
/** SetPadLayersList
|
|
|
|
* Update the CheckBoxes state in pad layers list,
|
|
|
|
* @param layer_mask = pad layer mask (ORed layers bit mask)
|
|
|
|
*/
|
|
|
|
{
|
2009-12-21 13:05:11 +00:00
|
|
|
m_PadLayerCu->SetValue( ( layer_mask & LAYER_BACK ) );
|
|
|
|
m_PadLayerCmp->SetValue( ( layer_mask & LAYER_FRONT ) );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
m_PadLayerAdhCmp->SetValue( ( layer_mask & ADHESIVE_LAYER_FRONT ) );
|
|
|
|
m_PadLayerAdhCu->SetValue( ( layer_mask & ADHESIVE_LAYER_BACK ) );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
m_PadLayerPateCmp->SetValue( ( layer_mask & SOLDERPASTE_LAYER_FRONT ) );
|
|
|
|
m_PadLayerPateCu->SetValue( ( layer_mask & SOLDERPASTE_LAYER_BACK ) );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
m_PadLayerSilkCmp->SetValue( ( layer_mask & SILKSCREEN_LAYER_FRONT ) );
|
|
|
|
m_PadLayerSilkCu->SetValue( ( layer_mask & SILKSCREEN_LAYER_BACK ) );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
m_PadLayerMaskCmp->SetValue( ( layer_mask & SOLDERMASK_LAYER_FRONT ) );
|
|
|
|
m_PadLayerMaskCu->SetValue( ( layer_mask & SOLDERMASK_LAYER_BACK ) );
|
2008-11-22 11:10:40 +00:00
|
|
|
|
|
|
|
m_PadLayerECO1->SetValue( ( layer_mask & ECO1_LAYER ) );
|
|
|
|
m_PadLayerECO2->SetValue( ( layer_mask & ECO2_LAYER ) );
|
|
|
|
|
|
|
|
m_PadLayerDraft->SetValue( ( layer_mask & DRAW_LAYER ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
// Called when select/deselect a layer.
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnSetLayer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
TransfertDataToPad( m_dummyPad );
|
|
|
|
m_panelShowPad->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
/*************************************************************************/
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
|
2008-11-22 11:10:40 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Updates the different parameters for the component being edited.
|
2008-11-22 11:10:40 +00:00
|
|
|
*/
|
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
bool rastnestIsChanged = false;
|
|
|
|
int isign = m_isFlipped ? -1 : 1;
|
|
|
|
|
|
|
|
bool success = TransfertDataToPad( m_dummyPad, true );
|
|
|
|
if( !success ) // An error on parameters has occured
|
|
|
|
return;
|
|
|
|
|
|
|
|
TransfertDataToPad( &g_Pad_Master, false );
|
|
|
|
g_Current_PadName = g_Pad_Master.ReturnStringPadName();
|
|
|
|
|
|
|
|
if( m_CurrentPad ) // Set current Pad parameters
|
|
|
|
{
|
|
|
|
MODULE* Module = (MODULE*) m_CurrentPad->GetParent();
|
|
|
|
m_Parent->SaveCopyInUndoList( Module, UR_CHANGED );
|
|
|
|
Module->m_LastEdit_Time = time( NULL );
|
|
|
|
|
|
|
|
// redraw the area where the pad was, without pad (delete pad on screen)
|
|
|
|
m_CurrentPad->m_Flags |= DO_NOT_DRAW;
|
2011-01-30 22:22:38 +00:00
|
|
|
m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() );
|
2010-09-11 16:33:43 +00:00
|
|
|
m_CurrentPad->m_Flags &= ~DO_NOT_DRAW;
|
|
|
|
|
|
|
|
// Update values
|
|
|
|
m_CurrentPad->m_PadShape = g_Pad_Master.m_PadShape;
|
|
|
|
m_CurrentPad->m_Attribut = g_Pad_Master.m_Attribut;
|
|
|
|
if( m_CurrentPad->m_Pos != g_Pad_Master.m_Pos )
|
|
|
|
{
|
|
|
|
m_CurrentPad->m_Pos = g_Pad_Master.m_Pos;
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the pos 0 value, i.e. pad position for module orient = 0 i.e.
|
|
|
|
* refer to module origin (module position) */
|
|
|
|
m_CurrentPad->m_Pos0 = m_CurrentPad->m_Pos;
|
|
|
|
m_CurrentPad->m_Pos0 -= Module->m_Pos;
|
|
|
|
m_CurrentPad->m_Orient = (g_Pad_Master.m_Orient * isign) + Module->m_Orient;
|
|
|
|
RotatePoint( &m_CurrentPad->m_Pos0.x, &m_CurrentPad->m_Pos0.y, -Module->m_Orient );
|
|
|
|
|
|
|
|
m_CurrentPad->m_Size = g_Pad_Master.m_Size;
|
|
|
|
m_CurrentPad->m_DeltaSize = g_Pad_Master.m_DeltaSize;
|
|
|
|
m_CurrentPad->m_DeltaSize.y *= isign;
|
|
|
|
m_CurrentPad->m_Drill = g_Pad_Master.m_Drill;
|
|
|
|
m_CurrentPad->m_DrillShape = g_Pad_Master.m_DrillShape;
|
|
|
|
m_CurrentPad->m_Offset = g_Pad_Master.m_Offset;
|
|
|
|
m_CurrentPad->m_Offset.y *= isign;
|
|
|
|
if( m_CurrentPad->m_Masque_Layer != g_Pad_Master.m_Masque_Layer )
|
|
|
|
{
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
m_CurrentPad->m_Masque_Layer = g_Pad_Master.m_Masque_Layer;
|
|
|
|
}
|
|
|
|
if( m_isFlipped )
|
|
|
|
m_CurrentPad->m_Masque_Layer = ChangeSideMaskLayer( m_CurrentPad->m_Masque_Layer );
|
|
|
|
|
|
|
|
m_CurrentPad->SetPadName( g_Pad_Master.ReturnStringPadName() );
|
|
|
|
|
|
|
|
if( m_CurrentPad->GetNetname() != g_Pad_Master.GetNetname() )
|
|
|
|
{
|
|
|
|
if( g_Pad_Master.GetNetname().IsEmpty() )
|
|
|
|
{
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
m_CurrentPad->SetNet( 0 );
|
|
|
|
m_CurrentPad->SetNetname( wxEmptyString );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( g_Pad_Master.GetNetname() );
|
|
|
|
if( net )
|
|
|
|
{
|
|
|
|
rastnestIsChanged = true;
|
|
|
|
m_CurrentPad->SetNetname( g_Pad_Master.GetNetname() );
|
|
|
|
m_CurrentPad->SetNet( net->GetNet() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_CurrentPad->m_LocalClearance = g_Pad_Master.m_LocalClearance;
|
|
|
|
m_CurrentPad->m_LocalSolderMaskMargin = g_Pad_Master.m_LocalSolderMaskMargin;
|
|
|
|
m_CurrentPad->m_LocalSolderPasteMargin = g_Pad_Master.m_LocalSolderPasteMargin;
|
|
|
|
m_CurrentPad->m_LocalSolderPasteMarginRatio = g_Pad_Master.m_LocalSolderPasteMarginRatio;
|
|
|
|
|
2010-09-18 17:55:08 +00:00
|
|
|
m_CurrentPad->ComputeShapeMaxRadius();
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
Module->Set_Rectangle_Encadrement();
|
|
|
|
m_CurrentPad->DisplayInfo( m_Parent );
|
|
|
|
|
|
|
|
// redraw the area where the pad was
|
2011-01-30 22:22:38 +00:00
|
|
|
m_Parent->DrawPanel->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() );
|
2010-09-11 16:33:43 +00:00
|
|
|
m_Parent->OnModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
EndModal( wxID_OK );
|
|
|
|
|
|
|
|
if( rastnestIsChanged ) // The net ratsnest must be recalculated
|
|
|
|
m_Parent->GetBoard()->m_Status_Pcb = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError )
|
|
|
|
{
|
|
|
|
long PadLayerMask;
|
|
|
|
int internalUnits = m_Parent->m_InternalUnits;
|
2009-11-05 20:59:42 +00:00
|
|
|
wxString msg;
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Attribut = CodeType[m_PadType->GetSelection()];
|
|
|
|
aPad->m_PadShape = CodeShape[m_PadShape->GetSelection()];
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad clearances values:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_LocalClearance = ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl,
|
|
|
|
internalUnits );
|
|
|
|
aPad->m_LocalSolderMaskMargin = ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl,
|
2010-04-23 14:46:00 +00:00
|
|
|
internalUnits );
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_LocalSolderPasteMargin = ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl,
|
|
|
|
internalUnits );
|
|
|
|
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
|
|
|
|
2009-11-05 20:59:42 +00:00
|
|
|
// A margin ratio de -50% means no paste on a pad, the ratio must be >= 50 %
|
|
|
|
if( dtmp < -50 )
|
|
|
|
dtmp = -50;
|
2010-01-31 20:01:46 +00:00
|
|
|
if( dtmp > +100 )
|
|
|
|
dtmp = +100;
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_LocalSolderPasteMarginRatio = dtmp / 100;
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad position:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Pos.x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl, internalUnits );
|
|
|
|
aPad->m_Pos.y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl, internalUnits );
|
|
|
|
aPad->m_Pos0 = aPad->m_Pos;
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad drill:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Drill.x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl, internalUnits );
|
|
|
|
aPad->m_Drill.y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl, internalUnits );
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_DrillShapeCtrl->GetSelection() == 0 )
|
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_DrillShape = PAD_CIRCLE;
|
|
|
|
aPad->m_Drill.y = aPad->m_Drill.x;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
else
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_DrillShape = PAD_OVAL;
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad shape size:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Size.x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl, internalUnits );
|
|
|
|
aPad->m_Size.y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl, internalUnits );
|
|
|
|
if( aPad->m_PadShape == PAD_CIRCLE )
|
|
|
|
aPad->m_Size.y = aPad->m_Size.x;
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad shape delta size:
|
2010-09-11 16:33:43 +00:00
|
|
|
// m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid.
|
2010-09-15 14:53:33 +00:00
|
|
|
wxSize delta;
|
|
|
|
if( m_radioBtnDeltaXdir->GetValue() )
|
|
|
|
delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits );
|
|
|
|
else
|
|
|
|
delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits );
|
|
|
|
aPad->m_DeltaSize = delta;
|
2010-09-11 16:33:43 +00:00
|
|
|
|
|
|
|
// Test bad values (be sure delta values are not to large)
|
2010-09-15 14:53:33 +00:00
|
|
|
// remember DeltaSize.x is the Y size variation
|
2010-09-11 16:33:43 +00:00
|
|
|
bool error = false;
|
|
|
|
if( (aPad->m_DeltaSize.x < 0) && (aPad->m_DeltaSize.x <= -aPad->m_Size.y) )
|
|
|
|
{
|
|
|
|
aPad->m_DeltaSize.x = -aPad->m_Size.y + 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
if( (aPad->m_DeltaSize.x > 0) && (aPad->m_DeltaSize.x >= aPad->m_Size.y) )
|
|
|
|
{
|
|
|
|
aPad->m_DeltaSize.x = aPad->m_Size.y - 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
if( (aPad->m_DeltaSize.y < 0) && (aPad->m_DeltaSize.y <= -aPad->m_Size.x) )
|
|
|
|
{
|
|
|
|
aPad->m_DeltaSize.y = -aPad->m_Size.x + 2;
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
if( (aPad->m_DeltaSize.y > 0) && (aPad->m_DeltaSize.y >= aPad->m_Size.x) )
|
|
|
|
{
|
|
|
|
aPad->m_DeltaSize.y = aPad->m_Size.x - 2;
|
|
|
|
error = true;
|
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
|
|
|
// Read pad shape offset:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Offset.x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits );
|
|
|
|
aPad->m_Offset.y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits );
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
long orient_value = 0;
|
|
|
|
msg = m_PadOrientCtrl->GetValue();
|
2009-11-05 20:59:42 +00:00
|
|
|
msg.ToLong( &orient_value );
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Orient = orient_value;
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
msg = m_PadNumCtrl->GetValue().Left( 4 );
|
|
|
|
aPad->SetPadName( msg );
|
|
|
|
aPad->SetNetname( m_PadNetNameCtrl->GetValue() );
|
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
|
2010-09-11 16:33:43 +00:00
|
|
|
switch( aPad->m_PadShape )
|
2010-02-12 17:15:47 +00:00
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Offset = wxSize( 0, 0 );
|
|
|
|
aPad->m_DeltaSize = wxSize( 0, 0 );
|
|
|
|
aPad->m_Size.y = aPad->m_Size.x;
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_DeltaSize = wxSize( 0, 0 );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_DeltaSize = wxSize( 0, 0 );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
switch( aPad->m_Attribut )
|
2010-02-12 17:15:47 +00:00
|
|
|
{
|
|
|
|
case PAD_STANDARD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_CONN:
|
|
|
|
case PAD_SMD:
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Offset = wxSize( 0, 0 );
|
|
|
|
aPad->m_Drill = wxSize( 0, 0 );
|
2010-02-12 17:15:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_HOLE_NOT_PLATED:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "Error: unknown pad type" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
PadLayerMask = 0;
|
|
|
|
if( m_PadLayerCu->GetValue() )
|
2009-12-21 13:05:11 +00:00
|
|
|
PadLayerMask |= LAYER_BACK;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerCmp->GetValue() )
|
2009-12-21 13:05:11 +00:00
|
|
|
PadLayerMask |= LAYER_FRONT;
|
|
|
|
if( ( PadLayerMask & (LAYER_BACK | LAYER_FRONT) ) == (LAYER_BACK | LAYER_FRONT) )
|
2008-11-22 11:10:40 +00:00
|
|
|
PadLayerMask |= ALL_CU_LAYERS;
|
|
|
|
if( m_PadLayerAdhCmp->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= ADHESIVE_LAYER_FRONT;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerAdhCu->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= ADHESIVE_LAYER_BACK;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerPateCmp->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= SOLDERPASTE_LAYER_FRONT;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerPateCu->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= SOLDERPASTE_LAYER_BACK;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerSilkCmp->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= SILKSCREEN_LAYER_FRONT;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerSilkCu->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= SILKSCREEN_LAYER_BACK;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerMaskCmp->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= SOLDERMASK_LAYER_FRONT;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerMaskCu->GetValue() )
|
2009-12-21 18:51:37 +00:00
|
|
|
PadLayerMask |= SOLDERMASK_LAYER_BACK;
|
2008-11-22 11:10:40 +00:00
|
|
|
if( m_PadLayerECO1->GetValue() )
|
|
|
|
PadLayerMask |= ECO1_LAYER;
|
|
|
|
if( m_PadLayerECO2->GetValue() )
|
|
|
|
PadLayerMask |= ECO2_LAYER;
|
|
|
|
if( m_PadLayerDraft->GetValue() )
|
|
|
|
PadLayerMask |= DRAW_LAYER;
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
aPad->m_Masque_Layer = PadLayerMask;
|
2010-03-07 13:33:20 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
/* Test for incorrect values */
|
|
|
|
if( aPromptOnError )
|
2010-03-07 13:33:20 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
if( (aPad->m_Size.x < aPad->m_Drill.x)
|
|
|
|
|| (aPad->m_Size.y < aPad->m_Drill.y) )
|
2010-03-07 13:33:20 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
DisplayError( this, _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
|
|
|
|
return false;
|
2010-03-07 13:33:20 +00:00
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
int padlayers_mask = PadLayerMask & (LAYER_BACK | LAYER_FRONT);
|
|
|
|
if( padlayers_mask == 0 )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
if( aPad->m_Drill.x || aPad->m_Drill.y )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Error: pad is not on a copper layer and has a hole" ) );
|
|
|
|
return false;
|
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( ( aPad->m_Size.x / 2 <= ABS( aPad->m_Offset.x ) )
|
|
|
|
|| ( aPad->m_Size.y / 2 <= ABS( aPad->m_Offset.y ) ) )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Incorrect value for pad offset" ) );
|
|
|
|
return false;
|
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( error )
|
2008-11-22 11:10:40 +00:00
|
|
|
{
|
2010-09-11 16:33:43 +00:00
|
|
|
DisplayError( this, _( "Too large value for pad delta size" ) );
|
|
|
|
return false;
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
2010-09-11 16:33:43 +00:00
|
|
|
}
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-11-05 20:59:42 +00:00
|
|
|
|
2008-11-22 11:10:40 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
// Called when a dimension has change.
|
|
|
|
// Update the pad dimensions shown in the panel.
|
|
|
|
void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_canUpdate )
|
|
|
|
{
|
|
|
|
TransfertDataToPad( m_dummyPad );
|
|
|
|
m_panelShowPad->Refresh();
|
2008-11-22 11:10:40 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-23 15:22:44 +00:00
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
/*********************************************************************/
|
2009-11-05 20:59:42 +00:00
|
|
|
void DIALOG_PAD_PROPERTIES::OnCancelButtonClick( wxCommandEvent& event )
|
2009-08-23 15:22:44 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
{
|
2010-04-23 14:46:00 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2009-08-23 15:22:44 +00:00
|
|
|
}
|