Browse Source
Simplify copy/paste of pad settings.
Simplify copy/paste of pad settings.
Fixes: lp:1743141 * https://bugs.launchpad.net/kicad/+bug/1743141 (cherry picked from commit 13ece03)pull/17/head
20 changed files with 535 additions and 1124 deletions
-
20include/pcb_base_frame.h
-
7pcbnew/CMakeLists.txt
-
10pcbnew/class_pad.cpp
-
81pcbnew/dialogs/dialog_global_pads_edition_base.cpp
-
52pcbnew/dialogs/dialog_push_pad_properties.cpp
-
11pcbnew/dialogs/dialog_push_pad_properties.h
-
67pcbnew/dialogs/dialog_push_pad_properties_base.cpp
-
401pcbnew/dialogs/dialog_push_pad_properties_base.fbp
-
27pcbnew/dialogs/dialog_push_pad_properties_base.h
-
2pcbnew/edit.cpp
-
2pcbnew/footprint_edit_frame.h
-
2pcbnew/footprint_editor_onclick.cpp
-
2pcbnew/footprint_editor_utils.cpp
-
269pcbnew/globaleditpad.cpp
-
2pcbnew/onrightclick.cpp
-
338pcbnew/pad_edit_functions.cpp
-
236pcbnew/pad_edition_functions.cpp
-
5pcbnew/pcb_edit_frame.h
-
123pcbnew/tools/pad_tool.cpp
-
2pcbnew/tools/pad_tool.h
@ -1,81 +0,0 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO *NOT* EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "dialog_global_pads_edition_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DIALOG_GLOBAL_PADS_EDITION_BASE::DIALOG_GLOBAL_PADS_EDITION_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) |
|||
{ |
|||
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
|||
|
|||
wxBoxSizer* bMainSizer; |
|||
bMainSizer = new wxBoxSizer( wxHORIZONTAL ); |
|||
|
|||
wxBoxSizer* bLeftSizer; |
|||
bLeftSizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxStaticBoxSizer* sbSizer1; |
|||
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Pad Filter :") ), wxVERTICAL ); |
|||
|
|||
m_Pad_Shape_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different shape"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
sbSizer1->Add( m_Pad_Shape_Filter_CB, 0, wxALL, 5 ); |
|||
|
|||
m_Pad_Layer_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having different layers"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
sbSizer1->Add( m_Pad_Layer_Filter_CB, 0, wxALL, 5 ); |
|||
|
|||
m_Pad_Orient_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different orientation"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
sbSizer1->Add( m_Pad_Orient_Filter_CB, 0, wxALL, 5 ); |
|||
|
|||
|
|||
bLeftSizer->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
bMainSizer->Add( bLeftSizer, 1, wxEXPAND, 5 ); |
|||
|
|||
wxBoxSizer* bRightSizer; |
|||
bRightSizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
m_buttonPadEditor = new wxButton( this, ID_CHANGE_GET_PAD_SETTINGS, _("Pad Properties..."), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bRightSizer->Add( m_buttonPadEditor, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
bRightSizer->Add( 10, 10, 0, 0, 5 ); |
|||
|
|||
m_buttonChangeModule = new wxButton( this, ID_CHANGE_CURRENT_MODULE, _("Change Pads on Footprint"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bRightSizer->Add( m_buttonChangeModule, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
m_buttonIdModules = new wxButton( this, ID_CHANGE_ID_MODULES, _("Change Pads on Identical Footprints"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bRightSizer->Add( m_buttonIdModules, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
bRightSizer->Add( m_buttonCancel, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
bMainSizer->Add( bRightSizer, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
this->SetSizer( bMainSizer ); |
|||
this->Layout(); |
|||
bMainSizer->Fit( this ); |
|||
|
|||
// Connect Events
|
|||
m_buttonPadEditor->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::InstallPadEditor ), NULL, this ); |
|||
m_buttonChangeModule->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this ); |
|||
m_buttonIdModules->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this ); |
|||
m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::OnCancelClick ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_GLOBAL_PADS_EDITION_BASE::~DIALOG_GLOBAL_PADS_EDITION_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_buttonPadEditor->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::InstallPadEditor ), NULL, this ); |
|||
m_buttonChangeModule->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this ); |
|||
m_buttonIdModules->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::PadPropertiesAccept ), NULL, this ); |
|||
m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_PADS_EDITION_BASE::OnCancelClick ), NULL, this ); |
|||
|
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
///////////////////////////////////////////////////////////////////////////
|
|||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
|||
// http://www.wxformbuilder.org/
|
|||
//
|
|||
// PLEASE DO *NOT* EDIT THIS FILE!
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
#include "dialog_push_pad_properties_base.h"
|
|||
|
|||
///////////////////////////////////////////////////////////////////////////
|
|||
|
|||
DIALOG_PUSH_PAD_PROPERTIES_BASE::DIALOG_PUSH_PAD_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) |
|||
{ |
|||
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); |
|||
|
|||
wxBoxSizer* bMainSizer; |
|||
bMainSizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxBoxSizer* bLeftSizer; |
|||
bLeftSizer = new wxBoxSizer( wxVERTICAL ); |
|||
|
|||
wxStaticBoxSizer* sbSizer1; |
|||
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); |
|||
|
|||
m_Pad_Shape_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different shape"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
sbSizer1->Add( m_Pad_Shape_Filter_CB, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); |
|||
|
|||
m_Pad_Layer_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having different layers"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
sbSizer1->Add( m_Pad_Layer_Filter_CB, 0, wxALL, 5 ); |
|||
|
|||
m_Pad_Orient_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different orientation"), wxDefaultPosition, wxDefaultSize, 0 ); |
|||
sbSizer1->Add( m_Pad_Orient_Filter_CB, 0, wxALL, 5 ); |
|||
|
|||
|
|||
bLeftSizer->Add( sbSizer1, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); |
|||
|
|||
|
|||
bMainSizer->Add( bLeftSizer, 1, wxALL|wxEXPAND, 5 ); |
|||
|
|||
m_sdbSizer1 = new wxStdDialogButtonSizer(); |
|||
m_sdbSizer1OK = new wxButton( this, wxID_OK ); |
|||
m_sdbSizer1->AddButton( m_sdbSizer1OK ); |
|||
m_sdbSizer1Apply = new wxButton( this, wxID_APPLY ); |
|||
m_sdbSizer1->AddButton( m_sdbSizer1Apply ); |
|||
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); |
|||
m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); |
|||
m_sdbSizer1->Realize(); |
|||
|
|||
bMainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); |
|||
|
|||
|
|||
this->SetSizer( bMainSizer ); |
|||
this->Layout(); |
|||
bMainSizer->Fit( this ); |
|||
|
|||
// Connect Events
|
|||
m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PUSH_PAD_PROPERTIES_BASE::PadPropertiesAccept ), NULL, this ); |
|||
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PUSH_PAD_PROPERTIES_BASE::PadPropertiesAccept ), NULL, this ); |
|||
} |
|||
|
|||
DIALOG_PUSH_PAD_PROPERTIES_BASE::~DIALOG_PUSH_PAD_PROPERTIES_BASE() |
|||
{ |
|||
// Disconnect Events
|
|||
m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PUSH_PAD_PROPERTIES_BASE::PadPropertiesAccept ), NULL, this ); |
|||
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PUSH_PAD_PROPERTIES_BASE::PadPropertiesAccept ), NULL, this ); |
|||
|
|||
} |
|||
@ -1,269 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2009-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 1992-2018 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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file globaleditpad.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <common.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <footprint_edit_frame.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <dialog_global_pads_edition.h>
|
|||
|
|||
/*
|
|||
* PCB_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 |
|||
* aRedraw: if true: redraws the footprint |
|||
*/ |
|||
void PCB_EDIT_FRAME::DlgGlobalChange_PadSettings( D_PAD* aPad, bool aRedraw ) |
|||
{ |
|||
int diag; |
|||
|
|||
if( aPad == NULL ) |
|||
aPad = &GetDesignSettings().m_Pad_Master; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
if( module == NULL ) |
|||
{ |
|||
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) ); |
|||
return; |
|||
} |
|||
|
|||
SetMsgPanel( module ); |
|||
|
|||
{ |
|||
DIALOG_GLOBAL_PADS_EDITION dlg( this, aPad ); |
|||
|
|||
diag = dlg.ShowModal(); |
|||
} |
|||
|
|||
if( diag == -1 ) |
|||
return; |
|||
|
|||
bool edit_Same_Modules = false; |
|||
if( diag == 1 ) |
|||
edit_Same_Modules = true; |
|||
|
|||
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 ); |
|||
} |
|||
|
|||
/*
|
|||
* 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 ) |
|||
aPad = &GetDesignSettings().m_Pad_Master; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
if( module == NULL ) |
|||
{ |
|||
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) ); |
|||
return; |
|||
} |
|||
|
|||
SetMsgPanel( module ); |
|||
|
|||
{ |
|||
DIALOG_GLOBAL_PADS_EDITION dlg( this, aPad ); |
|||
|
|||
dlg.m_buttonIdModules->Enable( false ); |
|||
|
|||
diag = dlg.ShowModal(); |
|||
} |
|||
|
|||
if( diag == -1 ) |
|||
return; |
|||
|
|||
bool edit_Same_Modules = false; |
|||
if( diag == 1 ) |
|||
edit_Same_Modules = true; |
|||
|
|||
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, |
|||
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 ) |
|||
aPad = &GetDesignSettings().m_Pad_Master; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
if( module == NULL ) |
|||
{ |
|||
DisplayError( this, wxT( "Global_Import_Pad_Settings() Error: NULL module" ) ); |
|||
return; |
|||
} |
|||
|
|||
// Search and copy the name of library reference.
|
|||
MODULE* Module_Ref = module; |
|||
double pad_orient = aPad->GetOrientation() - Module_Ref->GetOrientation(); |
|||
|
|||
// Prepare an undo list:
|
|||
if( aSaveForUndo ) |
|||
{ |
|||
PICKED_ITEMS_LIST itemsList; |
|||
|
|||
for( module = m_Pcb->m_Modules; module; module = module->Next() ) |
|||
{ |
|||
if( !aSameFootprints && (module != Module_Ref) ) |
|||
continue; |
|||
|
|||
if( module->GetFPID() != Module_Ref->GetFPID() ) |
|||
continue; |
|||
|
|||
bool saveMe = false; |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) |
|||
{ |
|||
// Filters changes prohibited.
|
|||
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) ) |
|||
continue; |
|||
|
|||
double currpad_orient = pad->GetOrientation() - module->GetOrientation(); |
|||
|
|||
if( aPadOrientFilter && ( currpad_orient != pad_orient ) ) |
|||
continue; |
|||
|
|||
if( aPadLayerFilter && pad->GetLayerSet() != aPad->GetLayerSet() ) |
|||
continue; |
|||
|
|||
// Do not copy a pad into it, it can create issue, and this is useless
|
|||
if( pad == aPad ) |
|||
continue; |
|||
|
|||
saveMe = true; |
|||
} |
|||
|
|||
if( saveMe ) |
|||
{ |
|||
ITEM_PICKER itemWrapper( module, UR_CHANGED ); |
|||
|
|||
itemsList.PushItem( itemWrapper ); |
|||
} |
|||
} |
|||
|
|||
SaveCopyInUndoList( itemsList, UR_CHANGED ); |
|||
} |
|||
|
|||
// Update the current module and same others modules if requested.
|
|||
for( module = m_Pcb->m_Modules; module; module = module->Next() ) |
|||
{ |
|||
if( !aSameFootprints && (module != Module_Ref) ) |
|||
continue; |
|||
|
|||
if( module->GetFPID() != Module_Ref->GetFPID() ) |
|||
continue; |
|||
|
|||
// Erase module on screen
|
|||
if( aRedraw ) |
|||
{ |
|||
module->SetFlags( DO_NOT_DRAW ); |
|||
m_canvas->RefreshDrawingRect( module->GetBoundingBox() ); |
|||
module->ClearFlags( DO_NOT_DRAW ); |
|||
} |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) |
|||
{ |
|||
// Filters changes prohibited.
|
|||
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) ) |
|||
continue; |
|||
|
|||
if( aPadOrientFilter && |
|||
(pad->GetOrientation() - module->GetOrientation()) != pad_orient ) |
|||
continue; |
|||
|
|||
if( aPadLayerFilter ) |
|||
{ |
|||
if( pad->GetLayerSet() != aPad->GetLayerSet() ) |
|||
continue; |
|||
} |
|||
|
|||
// Do not copy a pad into it, it can create issue in custom pads
|
|||
// and primitive list.
|
|||
if( pad == aPad ) |
|||
continue; |
|||
|
|||
// Copy physical characteristics:
|
|||
pad->ImportSettingsFromMaster( *aPad ); |
|||
|
|||
// copy also local mask margins:
|
|||
pad->SetLocalSolderMaskMargin( aPad->GetLocalSolderMaskMargin() ); |
|||
pad->SetLocalSolderPasteMargin( aPad->GetLocalSolderPasteMargin() ); |
|||
pad->SetLocalSolderPasteMarginRatio( aPad->GetLocalSolderPasteMarginRatio() ); |
|||
} |
|||
|
|||
module->CalculateBoundingBox(); |
|||
|
|||
if( aRedraw ) |
|||
m_canvas->RefreshDrawingRect( module->GetBoundingBox() ); |
|||
} |
|||
|
|||
OnModify(); |
|||
} |
|||
@ -0,0 +1,338 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> |
|||
* Copyright (C) 1992-2018 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 <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <trigo.h>
|
|||
#include <macros.h>
|
|||
#include <pcb_base_frame.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <footprint_edit_frame.h>
|
|||
#include <pcbnew.h>
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_pad.h>
|
|||
#include <board_design_settings.h>
|
|||
#include <dialog_push_pad_properties.h>
|
|||
|
|||
/*
|
|||
* Exports the current pad settings to board design settings. |
|||
*/ |
|||
void PCB_BASE_FRAME::Export_Pad_Settings( D_PAD* aPad ) |
|||
{ |
|||
if( aPad == NULL ) |
|||
return; |
|||
|
|||
SetMsgPanel( aPad ); |
|||
|
|||
D_PAD& masterPad = GetDesignSettings().m_Pad_Master; |
|||
|
|||
masterPad.ImportSettingsFromMaster( *aPad ); |
|||
} |
|||
|
|||
|
|||
/*
|
|||
* Imports the board design settings to aPad |
|||
* - The position, names, and keys are not modifed. |
|||
* The parameters are expected to be correct (i.e. settings are valid) |
|||
*/ |
|||
void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) |
|||
{ |
|||
if( aDraw ) |
|||
{ |
|||
aPad->SetFlags( DO_NOT_DRAW ); |
|||
m_canvas->RefreshDrawingRect( aPad->GetBoundingBox() ); |
|||
aPad->ClearFlags( DO_NOT_DRAW ); |
|||
} |
|||
|
|||
const D_PAD& mp = GetDesignSettings().m_Pad_Master; |
|||
|
|||
aPad->ImportSettingsFromMaster( mp ); |
|||
|
|||
if( aDraw ) |
|||
m_canvas->RefreshDrawingRect( aPad->GetBoundingBox() ); |
|||
|
|||
aPad->GetParent()->SetLastEditTime(); |
|||
|
|||
OnModify(); |
|||
} |
|||
|
|||
/*
|
|||
* Compute the 'next' pad number for autoincrement |
|||
* aPadName is the last pad name used |
|||
* */ |
|||
static wxString GetNextPadName( wxString aPadName ) |
|||
{ |
|||
// Automatically increment the current pad number.
|
|||
int num = 0; |
|||
int ponder = 1; |
|||
|
|||
// Trim and extract the trailing numeric part
|
|||
while( aPadName.Len() && aPadName.Last() >= '0' && aPadName.Last() <= '9' ) |
|||
{ |
|||
num += ( aPadName.Last() - '0' ) * ponder; |
|||
aPadName.RemoveLast(); |
|||
ponder *= 10; |
|||
} |
|||
|
|||
num++; // Use next number for the new pad
|
|||
aPadName << num; |
|||
|
|||
return aPadName; |
|||
} |
|||
|
|||
/*
|
|||
* Add a new pad to aModule. |
|||
*/ |
|||
void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw ) |
|||
{ |
|||
m_Pcb->m_Status_Pcb = 0; |
|||
aModule->SetLastEditTime(); |
|||
|
|||
D_PAD* pad = new D_PAD( aModule ); |
|||
|
|||
// Add the new pad to end of the module pad list.
|
|||
aModule->PadsList().PushBack( pad ); |
|||
|
|||
// Update the pad properties,
|
|||
// and keep NETINFO_LIST::ORPHANED as net info
|
|||
// which is the default when nets cannot be handled.
|
|||
Import_Pad_Settings( pad, false ); |
|||
|
|||
pad->SetPosition( GetCrossHairPosition() ); |
|||
|
|||
// Set the relative pad position
|
|||
// ( pad position for module orient, 0, and relative to the module position)
|
|||
|
|||
wxPoint pos0 = pad->GetPosition() - aModule->GetPosition(); |
|||
RotatePoint( &pos0, -aModule->GetOrientation() ); |
|||
pad->SetPos0( pos0 ); |
|||
|
|||
/* NPTH pads take empty pad number (since they can't be connected),
|
|||
* other pads get incremented from the last one edited */ |
|||
wxString padName; |
|||
|
|||
if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED ) |
|||
padName = GetNextPadName( GetDesignSettings().m_Pad_Master.GetName() ); |
|||
|
|||
pad->SetName( padName ); |
|||
GetDesignSettings().m_Pad_Master.SetName( padName ); |
|||
|
|||
aModule->CalculateBoundingBox(); |
|||
SetMsgPanel( pad ); |
|||
|
|||
if( draw ) |
|||
m_canvas->RefreshDrawingRect( aModule->GetBoundingBox() ); |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery ) |
|||
{ |
|||
if( aPad == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
module->SetLastEditTime(); |
|||
|
|||
// aQuery = true to prompt for confirmation, false to delete silently
|
|||
if( aQuery ) |
|||
{ |
|||
wxString msg = wxString::Format( _( "Delete pad (footprint %s %s)?" ), |
|||
module->GetReference(), |
|||
module->GetValue() ); |
|||
|
|||
if( !IsOK( this, msg ) ) |
|||
return; |
|||
} |
|||
|
|||
// Stores the initial bounding box to refresh the old area
|
|||
EDA_RECT bbox = module->GetBoundingBox(); |
|||
|
|||
m_Pcb->m_Status_Pcb = 0; |
|||
|
|||
GetBoard()->PadDelete( aPad ); |
|||
|
|||
// Update the bounding box
|
|||
module->CalculateBoundingBox(); |
|||
|
|||
// Refresh the modified screen area, using the initial bounding box
|
|||
// which is perhaps larger than the new bounding box
|
|||
m_canvas->RefreshDrawingRect( bbox ); |
|||
|
|||
OnModify(); |
|||
} |
|||
|
|||
|
|||
/*
|
|||
* PCB_EDIT_FRAME::Function PushPadProperties |
|||
* Function to change pad caracteristics for the given footprint or all identical footprints |
|||
* Options are set by the opened dialog. |
|||
*/ |
|||
void PCB_EDIT_FRAME::PushPadProperties( D_PAD* aPad ) |
|||
{ |
|||
if( !aPad ) |
|||
return; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
if( !module ) |
|||
return; |
|||
|
|||
SetMsgPanel( module ); |
|||
|
|||
DIALOG_PUSH_PAD_PROPERTIES dlg( this ); |
|||
int retCode = dlg.ShowModal(); |
|||
|
|||
if( retCode == wxID_CANCEL ) |
|||
return; |
|||
|
|||
bool edit_Same_Modules = ( retCode == 1 ); |
|||
|
|||
DoPushPadProperties( aPad, edit_Same_Modules, |
|||
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Shape_Filter, |
|||
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Orient_Filter, |
|||
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Layer_Filter, |
|||
true ); |
|||
} |
|||
|
|||
/*
|
|||
* FOOTPRINT_EDIT_FRAME::Function PushPadProperties |
|||
* Function to change pad caracteristics for the footprint. |
|||
* Options are set by the opened dialog. |
|||
*/ |
|||
void FOOTPRINT_EDIT_FRAME::PushPadProperties( D_PAD* aPad ) |
|||
{ |
|||
if( !aPad ) |
|||
return; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
if( !module ) |
|||
return; |
|||
|
|||
SetMsgPanel( module ); |
|||
|
|||
DIALOG_PUSH_PAD_PROPERTIES dlg( this ); |
|||
int retCode = dlg.ShowModal(); |
|||
|
|||
if( retCode == wxID_CANCEL ) |
|||
return; |
|||
|
|||
bool edit_Same_Modules = ( retCode == 1 ); |
|||
|
|||
DoPushPadProperties( aPad, edit_Same_Modules, |
|||
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Shape_Filter, |
|||
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Orient_Filter, |
|||
DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Layer_Filter, |
|||
false ); |
|||
} |
|||
|
|||
/*
|
|||
* Function DoPushPadProperties |
|||
* Function to change pad properties for the given footprint or all identical footprints |
|||
* 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 |
|||
* aSaveForUndo: if true: create an entry in the Undo/Redo list |
|||
* (usually: true in Schematic editor, false in Module editor) |
|||
*/ |
|||
void PCB_BASE_FRAME::DoPushPadProperties( D_PAD* aPad, bool aSameFootprints, |
|||
bool aPadShapeFilter, |
|||
bool aPadOrientFilter, |
|||
bool aPadLayerFilter, |
|||
bool aSaveForUndo ) |
|||
{ |
|||
MODULE* Module_Ref = aPad->GetParent(); |
|||
double pad_orient = aPad->GetOrientation() - Module_Ref->GetOrientation(); |
|||
|
|||
// Prepare an undo list:
|
|||
if( aSaveForUndo ) |
|||
{ |
|||
PICKED_ITEMS_LIST itemsList; |
|||
|
|||
if( aSameFootprints ) |
|||
{ |
|||
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) |
|||
{ |
|||
if( module->GetFPID() == Module_Ref->GetFPID() ) |
|||
{ |
|||
ITEM_PICKER itemWrapper( module, UR_CHANGED ); |
|||
itemsList.PushItem( itemWrapper ); |
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
ITEM_PICKER itemWrapper( Module_Ref, UR_CHANGED ); |
|||
itemsList.PushItem( itemWrapper ); |
|||
} |
|||
|
|||
SaveCopyInUndoList( itemsList, UR_CHANGED ); |
|||
} |
|||
|
|||
// Update the current module and same others modules if requested.
|
|||
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) |
|||
{ |
|||
if( !aSameFootprints && (module != Module_Ref) ) |
|||
continue; |
|||
|
|||
if( module->GetFPID() != Module_Ref->GetFPID() ) |
|||
continue; |
|||
|
|||
// Erase module on screen
|
|||
module->SetFlags( DO_NOT_DRAW ); |
|||
m_canvas->RefreshDrawingRect( module->GetBoundingBox() ); |
|||
module->ClearFlags( DO_NOT_DRAW ); |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) |
|||
{ |
|||
if( aPadShapeFilter && ( pad->GetShape() != aPad->GetShape() ) ) |
|||
continue; |
|||
|
|||
double currpad_orient = pad->GetOrientation() - module->GetOrientation(); |
|||
|
|||
if( aPadOrientFilter && ( currpad_orient != pad_orient ) ) |
|||
continue; |
|||
|
|||
if( aPadLayerFilter && ( pad->GetLayerSet() != aPad->GetLayerSet() ) ) |
|||
continue; |
|||
|
|||
// Do not copy pad to itself, it can create issues with custom pad primitives.
|
|||
if( pad == aPad ) |
|||
continue; |
|||
|
|||
pad->ImportSettingsFromMaster( *aPad ); |
|||
} |
|||
|
|||
module->CalculateBoundingBox(); |
|||
m_canvas->RefreshDrawingRect( module->GetBoundingBox() ); |
|||
} |
|||
|
|||
OnModify(); |
|||
} |
|||
@ -1,236 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> |
|||
* Copyright (C) 1992-2011 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 |
|||
*/ |
|||
|
|||
/**
|
|||
* @file pad_edition_functions.cpp |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <trigo.h>
|
|||
#include <macros.h>
|
|||
#include <pcb_base_frame.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
#include <class_board.h>
|
|||
#include <class_module.h>
|
|||
#include <class_pad.h>
|
|||
#include <board_design_settings.h>
|
|||
|
|||
/* Exports the current pad settings to board design settings.
|
|||
*/ |
|||
void PCB_BASE_FRAME::Export_Pad_Settings( D_PAD* aPad ) |
|||
{ |
|||
if( aPad == NULL ) |
|||
return; |
|||
|
|||
SetMsgPanel( aPad ); |
|||
|
|||
D_PAD& masterPad = GetDesignSettings().m_Pad_Master; |
|||
|
|||
masterPad.ImportSettingsFromMaster( *aPad ); |
|||
} |
|||
|
|||
|
|||
/* Imports the board design settings to aPad
|
|||
* - The position, names, and keys are not modifed. |
|||
* The parameters are expected to be correct (i.e. settings are valid) |
|||
*/ |
|||
void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) |
|||
{ |
|||
if( aDraw ) |
|||
{ |
|||
aPad->SetFlags( DO_NOT_DRAW ); |
|||
m_canvas->RefreshDrawingRect( aPad->GetBoundingBox() ); |
|||
aPad->ClearFlags( DO_NOT_DRAW ); |
|||
} |
|||
|
|||
const D_PAD& mp = GetDesignSettings().m_Pad_Master; |
|||
|
|||
aPad->ImportSettingsFromMaster( mp ); |
|||
|
|||
aPad->SetPrimitives( mp.GetPrimitives() ); |
|||
aPad->SetAnchorPadShape( mp.GetAnchorPadShape() ); |
|||
aPad->MergePrimitivesAsPolygon(); |
|||
|
|||
if( aDraw ) |
|||
m_canvas->RefreshDrawingRect( aPad->GetBoundingBox() ); |
|||
|
|||
aPad->GetParent()->SetLastEditTime(); |
|||
|
|||
OnModify(); |
|||
} |
|||
|
|||
/** Compute the 'next' pad number for autoincrement
|
|||
* aPadName is the last pad name used */ |
|||
static wxString GetNextPadName( wxString aPadName ) |
|||
{ |
|||
// Automatically increment the current pad number.
|
|||
int num = 0; |
|||
int ponder = 1; |
|||
|
|||
// Trim and extract the trailing numeric part
|
|||
while( aPadName.Len() |
|||
&& aPadName.Last() >= '0' |
|||
&& aPadName.Last() <= '9' ) |
|||
{ |
|||
num += ( aPadName.Last() - '0' ) * ponder; |
|||
aPadName.RemoveLast(); |
|||
ponder *= 10; |
|||
} |
|||
|
|||
num++; // Use next number for the new pad
|
|||
aPadName << num; |
|||
|
|||
return aPadName; |
|||
} |
|||
|
|||
/* Add a new pad to aModule.
|
|||
*/ |
|||
void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw ) |
|||
{ |
|||
m_Pcb->m_Status_Pcb = 0; |
|||
aModule->SetLastEditTime(); |
|||
|
|||
D_PAD* pad = new D_PAD( aModule ); |
|||
|
|||
// Add the new pad to end of the module pad list.
|
|||
aModule->PadsList().PushBack( pad ); |
|||
|
|||
// Update the pad properties,
|
|||
// and keep NETINFO_LIST::ORPHANED as net info
|
|||
// which is the default when nets cannot be handled.
|
|||
Import_Pad_Settings( pad, false ); |
|||
|
|||
pad->SetPosition( GetCrossHairPosition() ); |
|||
|
|||
// Set the relative pad position
|
|||
// ( pad position for module orient, 0, and relative to the module position)
|
|||
|
|||
wxPoint pos0 = pad->GetPosition() - aModule->GetPosition(); |
|||
RotatePoint( &pos0, -aModule->GetOrientation() ); |
|||
pad->SetPos0( pos0 ); |
|||
|
|||
/* NPTH pads take empty pad number (since they can't be connected),
|
|||
* other pads get incremented from the last one edited */ |
|||
wxString padName; |
|||
|
|||
if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED ) |
|||
{ |
|||
padName = GetNextPadName( GetDesignSettings() |
|||
.m_Pad_Master.GetName() ); |
|||
} |
|||
|
|||
pad->SetName( padName ); |
|||
GetDesignSettings().m_Pad_Master.SetName( padName ); |
|||
|
|||
aModule->CalculateBoundingBox(); |
|||
SetMsgPanel( pad ); |
|||
|
|||
if( draw ) |
|||
m_canvas->RefreshDrawingRect( aModule->GetBoundingBox() ); |
|||
} |
|||
|
|||
|
|||
void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery ) |
|||
{ |
|||
if( aPad == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
module->SetLastEditTime(); |
|||
|
|||
// aQuery = true to prompt for confirmation, false to delete silently
|
|||
if( aQuery ) |
|||
{ |
|||
wxString msg; |
|||
msg.Printf( _( "Delete Pad (footprint %s %s) ?" ), |
|||
GetChars( module->GetReference() ), |
|||
GetChars( module->GetValue() ) ); |
|||
|
|||
if( !IsOK( this, msg ) ) |
|||
return; |
|||
} |
|||
|
|||
// Stores the initial bounding box to refresh the old area
|
|||
EDA_RECT bbox = module->GetBoundingBox(); |
|||
|
|||
m_Pcb->m_Status_Pcb = 0; |
|||
|
|||
GetBoard()->PadDelete( aPad ); |
|||
|
|||
// Update the bounding box
|
|||
module->CalculateBoundingBox(); |
|||
|
|||
// Refresh the modified screen area, using the initial bounding box
|
|||
// which is perhaps larger than the new bounding box
|
|||
m_canvas->RefreshDrawingRect( bbox ); |
|||
|
|||
OnModify(); |
|||
} |
|||
|
|||
|
|||
// Rotate selected pad 90 degrees.
|
|||
void PCB_BASE_FRAME::RotatePad( D_PAD* aPad, wxDC* DC ) |
|||
{ |
|||
if( aPad == NULL ) |
|||
return; |
|||
|
|||
MODULE* module = aPad->GetParent(); |
|||
|
|||
module->SetLastEditTime(); |
|||
|
|||
OnModify(); |
|||
|
|||
if( DC ) |
|||
module->Draw( m_canvas, DC, GR_XOR ); |
|||
|
|||
wxSize sz = aPad->GetSize(); |
|||
std::swap( sz.x, sz.y ); |
|||
aPad->SetSize( sz ); |
|||
|
|||
sz = aPad->GetDrillSize(); |
|||
std::swap( sz.x, sz.y ); |
|||
aPad->SetDrillSize( sz ); |
|||
|
|||
wxPoint pt = aPad->GetOffset(); |
|||
std::swap( pt.x, pt.y ); |
|||
aPad->SetOffset( pt ); |
|||
|
|||
aPad->SetOffset( wxPoint( aPad->GetOffset().x, -aPad->GetOffset().y ) ); |
|||
|
|||
sz = aPad->GetDelta(); |
|||
std::swap( sz.x, sz.y ); |
|||
sz.x = -sz.x; |
|||
aPad->SetDelta( sz ); |
|||
|
|||
module->CalculateBoundingBox(); |
|||
SetMsgPanel( aPad ); |
|||
|
|||
if( DC ) |
|||
module->Draw( m_canvas, DC, GR_OR ); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue