Commit fda20d28 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Allows an offset for SMD type (and CONNECTOR type) pads.

parent 00e6f015
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2004 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
......
/*******************************************************************/ /*******************************************************************/
/* dialog_pad_properties.cpp: Pad editing functions and dialog box */ /* dialog_pad_properties.cpp: Pad editing functions and dialog box */
/* see also dialog_pad_properties.xxx (built with wxFormBuilder) */ /* see also dialog_pad_properties_base.xxx (built with wxFormBuilder) */
/*******************************************************************/ /*******************************************************************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras
* Copyright (C) 1992-2012 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 <fctsys.h>
#include <common.h> #include <common.h>
#include <gr_basic.h> #include <gr_basic.h>
...@@ -19,6 +43,7 @@ ...@@ -19,6 +43,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <dialog_helpers.h>
#include <dialog_pad_properties_base.h> #include <dialog_pad_properties_base.h>
#include <html_messagebox.h> #include <html_messagebox.h>
...@@ -58,7 +83,7 @@ static long Std_Pad_Layers[] = { ...@@ -58,7 +83,7 @@ static long Std_Pad_Layers[] = {
* class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE, * class DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
* created by wxFormBuilder * created by wxFormBuilder
*/ */
class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE DIALOG_EXTEND_WITH_SHIM( DIALOG_PAD_PROPERTIES, DIALOG_PAD_PROPERTIES_BASE )
{ {
public: public:
DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ); DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
...@@ -69,23 +94,14 @@ public: ...@@ -69,23 +94,14 @@ public:
private: private:
PCB_BASE_FRAME* m_Parent; PCB_BASE_FRAME* m_Parent;
D_PAD* m_CurrentPad; // pad currently being edited D_PAD* m_CurrentPad; // pad currently being edited
D_PAD* m_dummyPad; // a working copy used to show changes D_PAD* m_dummyPad; // a working copy used to show changes
BOARD* m_Board; BOARD* m_Board;
D_PAD& m_Pad_Master; D_PAD& m_Pad_Master;
bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored) bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
// in this case, some Y coordinates values must be negated // in this case, some Y coordinates values must be negated
bool m_canUpdate; bool m_canUpdate;
static wxPoint prevPosition;
static wxSize prevSize;
void initValues(); void initValues();
bool PadValuesOK(); ///< test if all values are acceptable for the pad bool PadValuesOK(); ///< test if all values are acceptable for the pad
...@@ -116,12 +132,8 @@ private: ...@@ -116,12 +132,8 @@ private:
}; };
wxPoint DIALOG_PAD_PROPERTIES::prevPosition( -1, -1 );
wxSize DIALOG_PAD_PROPERTIES::prevSize;
DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) : DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
DIALOG_PAD_PROPERTIES_BASE( aParent ), DIALOG_PAD_PROPERTIES_BASE_SHIM( aParent ),
m_Pad_Master( aParent->GetBoard()->GetDesignSettings().m_Pad_Master ) m_Pad_Master( aParent->GetBoard()->GetDesignSettings().m_Pad_Master )
{ {
m_canUpdate = false; m_canUpdate = false;
...@@ -140,12 +152,6 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP ...@@ -140,12 +152,6 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
m_sdbSizer1OK->SetDefault(); m_sdbSizer1OK->SetDefault();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
if( prevPosition.x != -1 )
SetSize( prevPosition.x, prevPosition.y,
prevSize.x, prevSize.y );
else
Center();
m_PadNumCtrl->SetFocus(); m_PadNumCtrl->SetFocus();
m_canUpdate = true; m_canUpdate = true;
} }
...@@ -208,6 +214,13 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) ...@@ -208,6 +214,13 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
GRResetPenAndBrush( &dc ); GRResetPenAndBrush( &dc );
m_dummyPad->DrawShape( NULL, &dc, drawInfo ); 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
int width = 0;
GRLine( NULL, &dc, -dim, 0, dim, 0, width, BLUE ); // X axis
GRLine( NULL, &dc, 0, -dim, 0, dim, width, BLUE ); // Y axis
event.Skip(); event.Skip();
} }
...@@ -673,8 +686,13 @@ if you do not want this pad plotted in gerber files"); ...@@ -673,8 +686,13 @@ if you do not want this pad plotted in gerber files");
} }
} }
if( m_dummyPad->GetSize().x / 2 <= ABS( m_dummyPad->GetOffset().x ) || wxPoint max_size;
m_dummyPad->GetSize().y / 2 <= ABS( m_dummyPad->GetOffset().y ) ) max_size.x = ABS( m_dummyPad->GetOffset().x );
max_size.y = 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" ) ); error_msgs.Add( _( "Incorrect value for pad offset" ) );
} }
...@@ -719,9 +737,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -719,9 +737,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
bool rastnestIsChanged = false; bool rastnestIsChanged = false;
int isign = m_isFlipped ? -1 : 1; int isign = m_isFlipped ? -1 : 1;
prevPosition = GetPosition();
prevSize = GetSize();
TransfertDataToPad( &m_Pad_Master ); TransfertDataToPad( &m_Pad_Master );
if( m_CurrentPad ) // Set current Pad parameters if( m_CurrentPad ) // Set current Pad parameters
...@@ -999,8 +1014,12 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad ) ...@@ -999,8 +1014,12 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad )
case PAD_CONN: case PAD_CONN:
case PAD_SMD: case PAD_SMD:
// Offset is a translation of border relative to hole. SMD has no hole. // SMD and PAD_CONN has no hole.
aPad->SetOffset( wxPoint( 0, 0 ) ); // basically, SMD and PAD_CONN are same type of pads
// PAD_CONN has just a default non technical layers that differs frm 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
aPad->SetDrillSize( wxSize( 0, 0 ) ); aPad->SetDrillSize( wxSize( 0, 0 ) );
break; break;
...@@ -1078,7 +1097,5 @@ void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event ) ...@@ -1078,7 +1097,5 @@ void DIALOG_PAD_PROPERTIES::OnValuesChanged( wxCommandEvent& event )
void DIALOG_PAD_PROPERTIES::OnCancelButtonClick( wxCommandEvent& event ) void DIALOG_PAD_PROPERTIES::OnCancelButtonClick( wxCommandEvent& event )
{ {
prevPosition = GetPosition();
prevSize = GetSize();
EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment