2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file globaleditpad.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "wxBasePcbFrame.h"
|
|
|
|
#include "pcbcommon.h"
|
|
|
|
|
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_module.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-12-13 10:30:19 +00:00
|
|
|
#include "dialog_global_pads_edition_base.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
/************************************/
|
2009-12-13 10:30:19 +00:00
|
|
|
/* class DIALOG_GLOBAL_PADS_EDITION */
|
2008-03-04 14:27:48 +00:00
|
|
|
/************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
class DIALOG_GLOBAL_PADS_EDITION : public DIALOG_GLOBAL_PADS_EDITION_BASE
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
private:
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* m_Parent;
|
2009-12-13 10:30:19 +00:00
|
|
|
D_PAD* m_CurrentPad;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static bool m_Pad_Shape_Filter;
|
|
|
|
static bool m_Pad_Layer_Filter;
|
|
|
|
static bool m_Pad_Orient_Filter;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_GLOBAL_PADS_EDITION( PCB_BASE_FRAME* parent, D_PAD* Pad );
|
2009-12-13 10:30:19 +00:00
|
|
|
~DIALOG_GLOBAL_PADS_EDITION() { }
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2009-12-13 10:30:19 +00:00
|
|
|
void InstallPadEditor( wxCommandEvent& event );
|
2009-11-14 22:15:22 +00:00
|
|
|
void PadPropertiesAccept( wxCommandEvent& event );
|
|
|
|
void OnCancelClick( wxCommandEvent& event );
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_GLOBAL_PADS_EDITION::DIALOG_GLOBAL_PADS_EDITION( PCB_BASE_FRAME* parent, D_PAD* Pad ) :
|
2009-12-13 10:30:19 +00:00
|
|
|
DIALOG_GLOBAL_PADS_EDITION_BASE( parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-12-13 10:30:19 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_CurrentPad = Pad;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Pad filter selection.
|
2009-12-13 10:30:19 +00:00
|
|
|
m_Pad_Shape_Filter_CB->SetValue( m_Pad_Shape_Filter );
|
|
|
|
m_Pad_Layer_Filter_CB->SetValue( m_Pad_Layer_Filter );
|
|
|
|
m_Pad_Orient_Filter_CB->SetValue( m_Pad_Orient_Filter );
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 11:53:19 +00:00
|
|
|
SetFocus();
|
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
Centre();
|
|
|
|
}
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
|
2009-12-13 11:53:19 +00:00
|
|
|
/* Class DIALOG_GLOBAL_PADS_EDITION static variables */
|
2009-12-13 10:30:19 +00:00
|
|
|
bool DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter = true;
|
|
|
|
bool DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter = true;
|
|
|
|
bool DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter = true;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
void DIALOG_GLOBAL_PADS_EDITION::OnCancelClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( -1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 04:56:44 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
/* Calls the Pad editor.
|
|
|
|
*/
|
|
|
|
void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-12-19 19:24:49 +00:00
|
|
|
m_Parent->InstallPadOptionsFrame( m_CurrentPad );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update the parameters for the component being edited.
|
2007-10-11 04:56:44 +00:00
|
|
|
*/
|
2009-12-13 10:30:19 +00:00
|
|
|
void DIALOG_GLOBAL_PADS_EDITION::PadPropertiesAccept( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
int returncode = 0;
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_CHANGE_ID_MODULES:
|
|
|
|
returncode = 1;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Fall through
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
case ID_CHANGE_CURRENT_MODULE:
|
2009-12-13 10:30:19 +00:00
|
|
|
m_Pad_Shape_Filter = m_Pad_Shape_Filter_CB->GetValue();
|
|
|
|
m_Pad_Layer_Filter = m_Pad_Layer_Filter_CB->GetValue();
|
|
|
|
m_Pad_Orient_Filter = m_Pad_Orient_Filter_CB->GetValue();
|
2008-03-04 14:27:48 +00:00
|
|
|
EndModal( returncode );
|
|
|
|
break;
|
|
|
|
}
|
2010-09-18 17:55:08 +00:00
|
|
|
|
|
|
|
m_Parent->OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function Global_Import_Pad_Settings
|
2008-04-18 13:28:56 +00:00
|
|
|
* Function to change pad caracteristics for the given footprint
|
|
|
|
* or alls footprints which look like the given footprint
|
2009-11-14 22:15:22 +00:00
|
|
|
* @param aPad pad to use as pattern. The given footprint is the parent of
|
|
|
|
* this pad
|
2008-04-18 13:28:56 +00:00
|
|
|
* @param aDraw: if true: redraws the footprint
|
2007-10-11 04:56:44 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
MODULE* Module_Ref, * Module;
|
|
|
|
int diag;
|
2009-12-13 10:30:19 +00:00
|
|
|
bool edit_Same_Modules = false;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
if( aPad == NULL )
|
2009-12-13 10:30:19 +00:00
|
|
|
aPad = &g_Pad_Master;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
Module = (MODULE*) aPad->GetParent();
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
if( Module == NULL )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
|
2008-03-04 14:27:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
Module->DisplayInfo( this );
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
DIALOG_GLOBAL_PADS_EDITION* dlg = new DIALOG_GLOBAL_PADS_EDITION( this, aPad );
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
diag = dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
if( diag == -1 )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-04 14:27:48 +00:00
|
|
|
if( diag == 1 )
|
2009-12-13 10:30:19 +00:00
|
|
|
edit_Same_Modules = true;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Search and copy the name of library reference. */
|
2008-03-04 14:27:48 +00:00
|
|
|
Module_Ref = Module;
|
2009-12-13 10:30:19 +00:00
|
|
|
int pad_orient = aPad->m_Orient - Module_Ref->m_Orient;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2010-03-01 17:48:17 +00:00
|
|
|
// Prepare an undo list:
|
2009-12-13 10:30:19 +00:00
|
|
|
PICKED_ITEMS_LIST itemsList;
|
2008-03-04 14:27:48 +00:00
|
|
|
Module = (MODULE*) m_Pcb->m_Modules;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2009-12-13 10:30:19 +00:00
|
|
|
if( !edit_Same_Modules && (Module != Module_Ref) )
|
|
|
|
continue;
|
|
|
|
|
2010-03-01 17:48:17 +00:00
|
|
|
if( Module->m_LibRef != Module_Ref->m_LibRef )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
bool saveMe = false;
|
|
|
|
D_PAD* pt_pad = (D_PAD*) Module->m_Pads;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
|
|
|
|
{
|
|
|
|
/* Filters changes prohibited. */
|
|
|
|
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter
|
|
|
|
&& ( pt_pad->m_PadShape != aPad->m_PadShape ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter
|
|
|
|
&& ( (pt_pad->m_Orient - Module->m_Orient) != pad_orient ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter
|
2011-09-07 19:41:04 +00:00
|
|
|
&& ( pt_pad->m_layerMask != aPad->m_layerMask ) )
|
2008-03-04 14:27:48 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
saveMe = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( saveMe )
|
|
|
|
{
|
|
|
|
ITEM_PICKER itemWrapper( Module, UR_CHANGED );
|
|
|
|
itemWrapper.m_PickedItemType = Module->Type();
|
|
|
|
itemsList.PushItem( itemWrapper );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveCopyInUndoList( itemsList, UR_CHANGED );
|
|
|
|
|
|
|
|
/* Update the current module and same others modules if requested. */
|
|
|
|
Module = (MODULE*) m_Pcb->m_Modules;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
|
|
|
{
|
|
|
|
if( !edit_Same_Modules && (Module != Module_Ref) )
|
2008-03-04 14:27:48 +00:00
|
|
|
continue;
|
|
|
|
|
2010-03-01 17:48:17 +00:00
|
|
|
if( Module->m_LibRef != Module_Ref->m_LibRef )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
/* Erase module on screen */
|
2009-11-14 22:15:22 +00:00
|
|
|
if( aDraw )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
Module->m_Flags |= DO_NOT_DRAW;
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
|
2008-11-24 06:53:43 +00:00
|
|
|
Module->m_Flags &= ~DO_NOT_DRAW;
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
D_PAD* pt_pad = (D_PAD*) Module->m_Pads;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Filters changes prohibited. */
|
2009-12-13 10:30:19 +00:00
|
|
|
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter
|
|
|
|
&& ( pt_pad->m_PadShape != aPad->m_PadShape ) )
|
|
|
|
continue;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter
|
|
|
|
&& ( (pt_pad->m_Orient - Module->m_Orient) != pad_orient ) )
|
|
|
|
continue;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
if( DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( pt_pad->m_layerMask != aPad->m_layerMask )
|
2008-03-04 14:27:48 +00:00
|
|
|
continue;
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Pcb->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK);
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Change characteristics.: */
|
2009-12-13 10:30:19 +00:00
|
|
|
pt_pad->m_Attribut = aPad->m_Attribut;
|
|
|
|
pt_pad->m_PadShape = aPad->m_PadShape;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
pt_pad->m_layerMask = aPad->m_layerMask;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
pt_pad->m_Size = aPad->m_Size;
|
|
|
|
pt_pad->m_DeltaSize = aPad->m_DeltaSize;
|
|
|
|
pt_pad->m_Offset = aPad->m_Offset;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
pt_pad->m_Drill = aPad->m_Drill;
|
|
|
|
pt_pad->m_DrillShape = aPad->m_DrillShape;
|
|
|
|
|
|
|
|
pt_pad->m_Orient = pad_orient + Module->m_Orient;
|
|
|
|
|
|
|
|
// copy also local mask margins,
|
|
|
|
// because these parameters usually depend on
|
|
|
|
// pads sizes and layers
|
|
|
|
pt_pad->m_LocalSolderMaskMargin = aPad->m_LocalSolderMaskMargin;
|
|
|
|
pt_pad->m_LocalSolderPasteMargin = aPad->m_LocalSolderPasteMargin;
|
|
|
|
pt_pad->m_LocalSolderPasteMarginRatio = aPad->m_LocalSolderPasteMarginRatio;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
if( pt_pad->m_PadShape != PAD_TRAPEZOID )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2011-11-24 17:32:51 +00:00
|
|
|
pt_pad->m_DeltaSize.x = 0;
|
|
|
|
pt_pad->m_DeltaSize.y = 0;
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
2009-12-13 10:30:19 +00:00
|
|
|
if( pt_pad->m_PadShape == PAD_CIRCLE )
|
2011-11-24 17:32:51 +00:00
|
|
|
pt_pad->m_Size.y = pt_pad->m_Size.x;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2009-12-13 10:30:19 +00:00
|
|
|
switch( pt_pad->m_Attribut & 0x7F )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
|
|
|
case PAD_SMD:
|
|
|
|
case PAD_CONN:
|
2011-11-24 17:32:51 +00:00
|
|
|
pt_pad->m_Drill = wxSize( 0, 0 );
|
|
|
|
pt_pad->m_Offset.x = 0;
|
|
|
|
pt_pad->m_Offset.y = 0;
|
2008-03-04 14:27:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-18 17:55:08 +00:00
|
|
|
pt_pad->ComputeShapeMaxRadius();
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
Module->CalculateBoundingBox();
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( aDraw )
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|