2014-10-23 17:53:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-02-08 09:51:05 +00:00
|
|
|
* Copyright (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-23 17:53:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file globaleditpad.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <footprint_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
2017-01-21 21:06:18 +00:00
|
|
|
#include <dialog_global_pads_edition.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
/*
|
|
|
|
* PCB_EDIT_FRAME::Function DlgGlobalChange_PadSettings
|
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
|
2011-12-30 12:29:54 +00:00
|
|
|
* Options are set by the opened dialog.
|
|
|
|
* aPad is the pattern. The given footprint is the parent of this pad
|
|
|
|
* aRedraw: if true: redraws the footprint
|
2007-10-11 04:56:44 +00:00
|
|
|
*/
|
2011-12-30 12:29:54 +00:00
|
|
|
void PCB_EDIT_FRAME::DlgGlobalChange_PadSettings( D_PAD* aPad, bool aRedraw )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:27:48 +00:00
|
|
|
int diag;
|
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
if( aPad == NULL )
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad = &GetDesignSettings().m_Pad_Master;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
MODULE* module = aPad->GetParent();
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( module == NULL )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( module );
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
{
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION dlg( this, aPad );
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
diag = dlg.ShowModal();
|
|
|
|
}
|
2008-03-04 14:27:48 +00:00
|
|
|
|
|
|
|
if( diag == -1 )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
bool edit_Same_Modules = false;
|
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
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
GlobalChange_PadSettings( aPad,edit_Same_Modules,
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter,
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter,
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter,
|
|
|
|
aRedraw, true );
|
|
|
|
}
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
/*
|
|
|
|
* FOOTPRINT_EDIT_FRAME::Function DlgGlobalChange_PadSettings
|
|
|
|
* Function to change pad caracteristics for the given footprint
|
|
|
|
* or alls footprints which look like the given footprint
|
|
|
|
* Options are set by the opened dialog.
|
|
|
|
* aPad is the pattern. The given footprint is the parent of this pad
|
|
|
|
*/
|
|
|
|
void FOOTPRINT_EDIT_FRAME::DlgGlobalChange_PadSettings( D_PAD* aPad )
|
|
|
|
{
|
|
|
|
int diag;
|
|
|
|
|
|
|
|
if( aPad == NULL )
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad = &GetDesignSettings().m_Pad_Master;
|
2011-12-30 12:29:54 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
MODULE* module = aPad->GetParent();
|
2011-12-30 12:29:54 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( module == NULL )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2011-12-30 12:29:54 +00:00
|
|
|
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
|
|
|
|
return;
|
|
|
|
}
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( module );
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
{
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION dlg( this, aPad );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
dlg.m_buttonIdModules->Enable( false );
|
|
|
|
|
|
|
|
diag = dlg.ShowModal();
|
|
|
|
}
|
2011-12-30 12:29:54 +00:00
|
|
|
|
|
|
|
if( diag == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool edit_Same_Modules = false;
|
|
|
|
if( diag == 1 )
|
|
|
|
edit_Same_Modules = true;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
GlobalChange_PadSettings( aPad, edit_Same_Modules,
|
2011-12-30 12:29:54 +00:00
|
|
|
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Shape_Filter,
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Orient_Filter,
|
|
|
|
DIALOG_GLOBAL_PADS_EDITION::m_Pad_Layer_Filter,
|
|
|
|
true, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function GlobalChange_PadSettings
|
|
|
|
* Function to change pad caracteristics for the given footprint
|
|
|
|
* or alls footprints which look like the given footprint
|
|
|
|
* aPad is the pattern. The given footprint is the parent of this pad
|
|
|
|
* aSameFootprints: if true, make changes on all identical footprints
|
|
|
|
* aPadShapeFilter: if true, make changes only on pads having the same shape as aPad
|
|
|
|
* aPadOrientFilter: if true, make changes only on pads having the same orientation as aPad
|
|
|
|
* aPadLayerFilter: if true, make changes only on pads having the same layers as aPad
|
|
|
|
* aRedraw: if true: redraws the footprint
|
|
|
|
* aSaveForUndo: if true: create an entry in the Undo/Redo list
|
|
|
|
* (usually: true in Schematic editor, false in Module editor)
|
|
|
|
*/
|
|
|
|
void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
|
|
|
|
bool aSameFootprints,
|
|
|
|
bool aPadShapeFilter,
|
|
|
|
bool aPadOrientFilter,
|
|
|
|
bool aPadLayerFilter,
|
|
|
|
bool aRedraw, bool aSaveForUndo )
|
|
|
|
{
|
|
|
|
if( aPad == NULL )
|
2012-02-19 04:02:19 +00:00
|
|
|
aPad = &GetDesignSettings().m_Pad_Master;
|
2011-12-30 12:29:54 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
MODULE* module = aPad->GetParent();
|
2011-12-30 12:29:54 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( module == NULL )
|
2011-12-30 12:29:54 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Search and copy the name of library reference.
|
|
|
|
MODULE* Module_Ref = module;
|
2013-05-04 11:57:09 +00:00
|
|
|
double pad_orient = aPad->GetOrientation() - Module_Ref->GetOrientation();
|
2011-12-30 12:29:54 +00:00
|
|
|
|
|
|
|
// Prepare an undo list:
|
|
|
|
if( aSaveForUndo )
|
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST itemsList;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
for( module = m_Pcb->m_Modules; module; module = module->Next() )
|
2009-12-13 10:30:19 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( !aSameFootprints && (module != Module_Ref) )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
|
|
|
|
2013-09-08 18:31:21 +00:00
|
|
|
if( module->GetFPID() != Module_Ref->GetFPID() )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
bool saveMe = false;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2018-02-08 08:24:38 +00:00
|
|
|
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
|
2011-12-30 12:29:54 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
// Filters changes prohibited.
|
|
|
|
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) )
|
2011-12-30 12:29:54 +00:00
|
|
|
continue;
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2013-05-05 07:17:48 +00:00
|
|
|
double currpad_orient = pad->GetOrientation() - module->GetOrientation();
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
|
|
|
|
continue;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( aPadLayerFilter && pad->GetLayerSet() != aPad->GetLayerSet() )
|
2011-12-30 12:29:54 +00:00
|
|
|
continue;
|
|
|
|
|
2018-02-08 08:24:38 +00:00
|
|
|
// Do not copy a pad into it, it can create issue, and this is useless
|
|
|
|
if( pad == aPad )
|
|
|
|
continue;
|
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
saveMe = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( saveMe )
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
ITEM_PICKER itemWrapper( module, UR_CHANGED );
|
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
itemsList.PushItem( itemWrapper );
|
|
|
|
}
|
2009-12-13 10:30:19 +00:00
|
|
|
}
|
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
SaveCopyInUndoList( itemsList, UR_CHANGED );
|
|
|
|
}
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Update the current module and same others modules if requested.
|
|
|
|
for( module = m_Pcb->m_Modules; module; module = module->Next() )
|
2009-12-13 10:30:19 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
if( !aSameFootprints && (module != Module_Ref) )
|
2008-03-04 14:27:48 +00:00
|
|
|
continue;
|
|
|
|
|
2013-09-08 18:31:21 +00:00
|
|
|
if( module->GetFPID() != Module_Ref->GetFPID() )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Erase module on screen
|
2011-12-30 12:29:54 +00:00
|
|
|
if( aRedraw )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
module->SetFlags( DO_NOT_DRAW );
|
|
|
|
m_canvas->RefreshDrawingRect( module->GetBoundingBox() );
|
|
|
|
module->ClearFlags( DO_NOT_DRAW );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2011-12-30 12:29:54 +00:00
|
|
|
// Filters changes prohibited.
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2018-02-08 08:24:38 +00:00
|
|
|
if( aPadOrientFilter &&
|
|
|
|
(pad->GetOrientation() - module->GetOrientation()) != pad_orient )
|
2009-12-13 10:30:19 +00:00
|
|
|
continue;
|
2008-03-04 14:27:48 +00:00
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
if( aPadLayerFilter )
|
2008-03-04 14:27:48 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( pad->GetLayerSet() != aPad->GetLayerSet() )
|
2008-03-04 14:27:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-02-08 08:24:38 +00:00
|
|
|
// Do not copy a pad into it, it can create issue in custom pads
|
|
|
|
// and primitive list.
|
|
|
|
if( pad == aPad )
|
|
|
|
continue;
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2018-02-08 08:24:38 +00:00
|
|
|
// Copy physical characteristics:
|
|
|
|
pad->ImportSettingsFromMaster( *aPad );
|
2009-12-13 10:30:19 +00:00
|
|
|
|
2018-02-08 08:24:38 +00:00
|
|
|
// copy also local mask margins:
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetLocalSolderMaskMargin( aPad->GetLocalSolderMaskMargin() );
|
|
|
|
pad->SetLocalSolderPasteMargin( aPad->GetLocalSolderPasteMargin() );
|
|
|
|
pad->SetLocalSolderPasteMarginRatio( aPad->GetLocalSolderPasteMarginRatio() );
|
2008-03-04 14:27:48 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
module->CalculateBoundingBox();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-30 12:29:54 +00:00
|
|
|
if( aRedraw )
|
2012-02-19 04:02:19 +00:00
|
|
|
m_canvas->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
|
|
|
}
|