Add pad import/export/push to GAL canvas
This implements the pad import/export to the board's master pad setting in the GAL canvases. Implemented as a new GAL tool: PAD_TOOL. It uses the same dialog, which has been split out into its own files in pcbnew/dialogs, rather than along with frame methods in pcbnew/globaleditpad.cpp. Fixes: lp:1619304 * https://bugs.launchpad.net/kicad/+bug/1619304
This commit is contained in:
parent
8e7fe9dab2
commit
beed72ffbb
|
@ -87,6 +87,7 @@ set( PCBNEW_DIALOGS
|
|||
dialogs/dialog_global_modules_fields_edition.cpp
|
||||
dialogs/dialog_global_modules_fields_edition_base.cpp
|
||||
dialogs/dialog_global_pads_edition_base.cpp
|
||||
dialogs/dialog_global_pads_edition.cpp
|
||||
dialogs/dialog_graphic_items_options.cpp
|
||||
dialogs/dialog_graphic_items_options_base.cpp
|
||||
dialogs/dialog_graphic_item_properties.cpp
|
||||
|
@ -292,6 +293,7 @@ set( PCBNEW_CLASS_SRCS
|
|||
tools/placement_tool.cpp
|
||||
tools/common_actions.cpp
|
||||
tools/grid_helper.cpp
|
||||
tools/pad_tool.cpp
|
||||
tools/picker_tool.cpp
|
||||
tools/zoom_tool.cpp
|
||||
tools/tools_common.cpp
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 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 <dialog_global_pads_edition.h>
|
||||
|
||||
#include <class_pad.h>
|
||||
#include <wxPcbStruct.h>
|
||||
|
||||
|
||||
DIALOG_GLOBAL_PADS_EDITION::DIALOG_GLOBAL_PADS_EDITION( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
|
||||
DIALOG_GLOBAL_PADS_EDITION_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_currentPad = aPad;
|
||||
|
||||
// Pad filter selection.
|
||||
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 );
|
||||
|
||||
SetFocus();
|
||||
|
||||
GetSizer()->Fit( this );
|
||||
Centre();
|
||||
}
|
||||
|
||||
|
||||
// Class DIALOG_GLOBAL_PADS_EDITION static variables
|
||||
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;
|
||||
|
||||
|
||||
void DIALOG_GLOBAL_PADS_EDITION::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
EndModal( -1 );
|
||||
}
|
||||
|
||||
|
||||
/* Calls the Pad editor.
|
||||
*/
|
||||
void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event )
|
||||
{
|
||||
m_parent->InstallPadOptionsFrame( m_currentPad );
|
||||
}
|
||||
|
||||
|
||||
/* Update the parameters for the component being edited.
|
||||
*/
|
||||
void DIALOG_GLOBAL_PADS_EDITION::PadPropertiesAccept( wxCommandEvent& event )
|
||||
{
|
||||
int returncode = 0;
|
||||
|
||||
switch( event.GetId() )
|
||||
{
|
||||
case ID_CHANGE_ID_MODULES:
|
||||
returncode = 1;
|
||||
|
||||
// Fall through
|
||||
|
||||
case ID_CHANGE_CURRENT_MODULE:
|
||||
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();
|
||||
EndModal( returncode );
|
||||
break;
|
||||
}
|
||||
|
||||
m_parent->OnModify();
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 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
|
||||
*/
|
||||
|
||||
#ifndef __DIALOG_GLOBAL_PADS_EDITION_H
|
||||
#define __DIALOG_GLOBAL_PADS_EDITION_H
|
||||
|
||||
#include <dialog_global_pads_edition_base.h>
|
||||
|
||||
class D_PAD;
|
||||
class PCB_BASE_FRAME;
|
||||
/************************************/
|
||||
/* class DIALOG_GLOBAL_PADS_EDITION */
|
||||
/************************************/
|
||||
|
||||
class DIALOG_GLOBAL_PADS_EDITION : public DIALOG_GLOBAL_PADS_EDITION_BASE
|
||||
{
|
||||
private:
|
||||
PCB_BASE_FRAME* m_parent;
|
||||
D_PAD* m_currentPad;
|
||||
|
||||
public:
|
||||
static bool m_Pad_Shape_Filter;
|
||||
static bool m_Pad_Layer_Filter;
|
||||
static bool m_Pad_Orient_Filter;
|
||||
|
||||
public:
|
||||
DIALOG_GLOBAL_PADS_EDITION( PCB_BASE_FRAME* aParent, D_PAD* aPad );
|
||||
|
||||
private:
|
||||
void InstallPadEditor( wxCommandEvent& event ) override;
|
||||
void PadPropertiesAccept( wxCommandEvent& event ) override;
|
||||
void OnCancelClick( wxCommandEvent& event ) override;
|
||||
};
|
||||
|
||||
|
||||
#endif // __DIALOG_GLOBAL_PADS_EDITION_H
|
|
@ -37,96 +37,7 @@
|
|||
#include <class_module.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
#include <dialog_global_pads_edition_base.h>
|
||||
|
||||
|
||||
/************************************/
|
||||
/* class DIALOG_GLOBAL_PADS_EDITION */
|
||||
/************************************/
|
||||
|
||||
class DIALOG_GLOBAL_PADS_EDITION : public DIALOG_GLOBAL_PADS_EDITION_BASE
|
||||
{
|
||||
private:
|
||||
PCB_BASE_FRAME* m_parent;
|
||||
D_PAD* m_currentPad;
|
||||
|
||||
public:
|
||||
static bool m_Pad_Shape_Filter;
|
||||
static bool m_Pad_Layer_Filter;
|
||||
static bool m_Pad_Orient_Filter;
|
||||
|
||||
public:
|
||||
DIALOG_GLOBAL_PADS_EDITION( PCB_BASE_FRAME* aParent, D_PAD* aPad );
|
||||
|
||||
private:
|
||||
void InstallPadEditor( wxCommandEvent& event ) override;
|
||||
void PadPropertiesAccept( wxCommandEvent& event ) override;
|
||||
void OnCancelClick( wxCommandEvent& event ) override;
|
||||
};
|
||||
|
||||
|
||||
DIALOG_GLOBAL_PADS_EDITION::DIALOG_GLOBAL_PADS_EDITION( PCB_BASE_FRAME* aParent, D_PAD* aPad ) :
|
||||
DIALOG_GLOBAL_PADS_EDITION_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_currentPad = aPad;
|
||||
|
||||
// Pad filter selection.
|
||||
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 );
|
||||
|
||||
SetFocus();
|
||||
|
||||
GetSizer()->Fit( this );
|
||||
Centre();
|
||||
}
|
||||
|
||||
|
||||
// Class DIALOG_GLOBAL_PADS_EDITION static variables
|
||||
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;
|
||||
|
||||
|
||||
void DIALOG_GLOBAL_PADS_EDITION::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
EndModal( -1 );
|
||||
}
|
||||
|
||||
|
||||
/* Calls the Pad editor.
|
||||
*/
|
||||
void DIALOG_GLOBAL_PADS_EDITION::InstallPadEditor( wxCommandEvent& event )
|
||||
{
|
||||
m_parent->InstallPadOptionsFrame( m_currentPad );
|
||||
}
|
||||
|
||||
|
||||
/* Update the parameters for the component being edited.
|
||||
*/
|
||||
void DIALOG_GLOBAL_PADS_EDITION::PadPropertiesAccept( wxCommandEvent& event )
|
||||
{
|
||||
int returncode = 0;
|
||||
|
||||
switch( event.GetId() )
|
||||
{
|
||||
case ID_CHANGE_ID_MODULES:
|
||||
returncode = 1;
|
||||
|
||||
// Fall through
|
||||
|
||||
case ID_CHANGE_CURRENT_MODULE:
|
||||
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();
|
||||
EndModal( returncode );
|
||||
break;
|
||||
}
|
||||
|
||||
m_parent->OnModify();
|
||||
}
|
||||
|
||||
#include <dialog_global_pads_edition.h>
|
||||
|
||||
/*
|
||||
* PCB_EDIT_FRAME::Function DlgGlobalChange_PadSettings
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include "tools/module_tools.h"
|
||||
#include "tools/placement_tool.h"
|
||||
#include "tools/picker_tool.h"
|
||||
#include "tools/pad_tool.h"
|
||||
#include "tools/common_actions.h"
|
||||
|
||||
|
||||
|
@ -950,6 +951,7 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
|
|||
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
||||
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
||||
m_toolManager->RegisterTool( new EDIT_TOOL );
|
||||
m_toolManager->RegisterTool( new PAD_TOOL );
|
||||
m_toolManager->RegisterTool( new DRAWING_TOOL );
|
||||
m_toolManager->RegisterTool( new POINT_EDITOR );
|
||||
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||
|
@ -957,6 +959,7 @@ void FOOTPRINT_EDIT_FRAME::setupTools()
|
|||
m_toolManager->RegisterTool( new PLACEMENT_TOOL );
|
||||
m_toolManager->RegisterTool( new PICKER_TOOL );
|
||||
|
||||
|
||||
m_toolManager->GetTool<SELECTION_TOOL>()->SetEditModules( true );
|
||||
m_toolManager->GetTool<EDIT_TOOL>()->SetEditModules( true );
|
||||
m_toolManager->GetTool<DRAWING_TOOL>()->SetEditModules( true );
|
||||
|
|
|
@ -459,6 +459,24 @@ TOOL_ACTION COMMON_ACTIONS::moduleTextOutlines( "pcbnew.ModuleEditor.textOutline
|
|||
AS_GLOBAL, 0,
|
||||
"", "" );
|
||||
|
||||
// Pad tools
|
||||
TOOL_ACTION COMMON_ACTIONS::exportPadSettings(
|
||||
"pcbnew.PadTool.ExportPadSettings",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Export pad settings" ), _( "Copy current pad's settings to the board design settings" ),
|
||||
export_options_pad_xpm );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::importPadSettings(
|
||||
"pcbnew.PadTool.ImportPadSettings",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Import pad settings" ), _( "Copy the board design settings pad properties to the current pad" ),
|
||||
options_new_pad_xpm );
|
||||
|
||||
TOOL_ACTION COMMON_ACTIONS::pushPadSettings(
|
||||
"pcbnew.PadTool.PushPadSettings",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Push pad settings" ), _( "Copy the current pad settings to other pads" ),
|
||||
global_options_pad_xpm );
|
||||
|
||||
// Cursor control
|
||||
TOOL_ACTION COMMON_ACTIONS::cursorUp( "pcbnew.Control.cursorUp",
|
||||
|
|
|
@ -272,6 +272,16 @@ public:
|
|||
/// Display module texts as outlines
|
||||
static TOOL_ACTION moduleTextOutlines;
|
||||
|
||||
// Pad tools
|
||||
/// Copy the selected pad's settings to the board design settings
|
||||
static TOOL_ACTION exportPadSettings;
|
||||
|
||||
/// Copy the pad settings in the board design settings to the selected pad
|
||||
static TOOL_ACTION importPadSettings;
|
||||
|
||||
/// Copy the current pad's settings to other pads in the module or on the board
|
||||
static TOOL_ACTION pushPadSettings;
|
||||
|
||||
/// Cursor control with keyboard
|
||||
static TOOL_ACTION cursorUp;
|
||||
static TOOL_ACTION cursorDown;
|
||||
|
|
|
@ -0,0 +1,397 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 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 "pad_tool.h"
|
||||
|
||||
#include <wxPcbStruct.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <view/view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <class_board_item.h>
|
||||
#include <class_module.h>
|
||||
#include <board_commit.h>
|
||||
|
||||
#include <dialogs/dialog_global_pads_edition.h>
|
||||
|
||||
#include "common_actions.h"
|
||||
#include "selection_tool.h"
|
||||
#include "selection_conditions.h"
|
||||
#include "edit_tool.h"
|
||||
|
||||
class PAD_CONTEXT_MENU : public CONTEXT_MENU
|
||||
{
|
||||
public:
|
||||
PAD_CONTEXT_MENU()
|
||||
{
|
||||
SetIcon( pad_xpm );
|
||||
SetTitle( _( "Pads" ) );
|
||||
|
||||
Add( COMMON_ACTIONS::importPadSettings );
|
||||
Add( COMMON_ACTIONS::exportPadSettings );
|
||||
Add( COMMON_ACTIONS::pushPadSettings );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
CONTEXT_MENU* create() const override
|
||||
{
|
||||
return new PAD_CONTEXT_MENU();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void update() override
|
||||
{
|
||||
auto selTool = getToolManager()->GetTool<SELECTION_TOOL>();
|
||||
const SELECTION& selection = selTool->GetSelection();
|
||||
|
||||
auto anyPadSel = SELECTION_CONDITIONS::HasType( PCB_PAD_T );
|
||||
|
||||
auto singlePadSel = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( PCB_PAD_T );
|
||||
auto emptySel = SELECTION_CONDITIONS::Count( 0 );
|
||||
|
||||
// Import pads enabled when any pads selected (it applies to each one
|
||||
// individually)
|
||||
const bool canImport = ( anyPadSel )( selection );
|
||||
Enable( getMenuId( COMMON_ACTIONS::importPadSettings ), canImport );
|
||||
|
||||
// Export pads item enabled only when there is a single pad selected
|
||||
// (otherwise how would we know which one to export?)
|
||||
const bool canExport = ( singlePadSel )( selection );
|
||||
Enable( getMenuId( COMMON_ACTIONS::exportPadSettings ), canExport );
|
||||
|
||||
// Push pads available when nothing selected, or a single pad
|
||||
const bool canPush = ( singlePadSel || emptySel ) ( selection );
|
||||
Enable( getMenuId( COMMON_ACTIONS::pushPadSettings ), canPush );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
PAD_TOOL::PAD_TOOL() :
|
||||
PCB_TOOL( "pcbnew.PadTool" )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PAD_TOOL::~PAD_TOOL()
|
||||
{}
|
||||
|
||||
|
||||
void PAD_TOOL::Reset( RESET_REASON aReason )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool PAD_TOOL::Init()
|
||||
{
|
||||
auto contextMenu = std::make_shared<PAD_CONTEXT_MENU>();
|
||||
contextMenu->SetTool( this );
|
||||
|
||||
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
|
||||
if( selTool )
|
||||
{
|
||||
auto& toolMenu = selTool->GetToolMenu();
|
||||
auto& menu = toolMenu.GetMenu();
|
||||
|
||||
toolMenu.AddSubMenu( contextMenu );
|
||||
|
||||
// show menu when any pads selected, or nothing selected
|
||||
// (push settings works on no selection)
|
||||
auto showCond = SELECTION_CONDITIONS::HasType( PCB_PAD_T )
|
||||
|| SELECTION_CONDITIONS::Count( 0 );
|
||||
|
||||
menu.AddMenu( contextMenu.get(), false, showCond );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function doExportPadSettings
|
||||
*
|
||||
* Export a given pad to the destination pad. Normally, the destination
|
||||
* would be a board reference settings master pad.
|
||||
*/
|
||||
static void doExportPadSettings( const D_PAD& aSrc, D_PAD& aDest )
|
||||
{
|
||||
// Copy all settings. Some of them are not used, but they break anything
|
||||
aDest = aSrc;
|
||||
|
||||
// The pad orientation, for historical reasons is the
|
||||
// pad rotation + parent rotation.
|
||||
// store only the pad rotation.
|
||||
aDest.SetOrientation( aSrc.GetOrientation() - aSrc.GetParent()->GetOrientation() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function doImportPadSettings
|
||||
*
|
||||
* Import pad settings from a "reference" source to a destination.
|
||||
* Often, the reference source will be a board reference settings
|
||||
* master pad.
|
||||
*/
|
||||
static void doImportPadSettings( const D_PAD& aSrc, D_PAD& aDest )
|
||||
{
|
||||
const auto& destParent = *aDest.GetParent();
|
||||
|
||||
aDest.SetShape( aSrc.GetShape() );
|
||||
aDest.SetLayerSet( aSrc.GetLayerSet() );
|
||||
aDest.SetAttribute( aSrc.GetAttribute() );
|
||||
aDest.SetOrientation( aSrc.GetOrientation() + destParent.GetOrientation() );
|
||||
aDest.SetSize( aSrc.GetSize() );
|
||||
aDest.SetDelta( wxSize( 0, 0 ) );
|
||||
aDest.SetOffset( aSrc.GetOffset() );
|
||||
aDest.SetDrillSize( aSrc.GetDrillSize() );
|
||||
aDest.SetDrillShape( aSrc.GetDrillShape() );
|
||||
aDest.SetRoundRectRadiusRatio( aSrc.GetRoundRectRadiusRatio() );
|
||||
|
||||
switch( aSrc.GetShape() )
|
||||
{
|
||||
case PAD_SHAPE_TRAPEZOID:
|
||||
aDest.SetDelta( aSrc.GetDelta() );
|
||||
break;
|
||||
|
||||
case PAD_SHAPE_CIRCLE:
|
||||
// ensure size.y == size.x
|
||||
aDest.SetSize( wxSize( aDest.GetSize().x, aDest.GetSize().x ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
switch( aSrc.GetAttribute() )
|
||||
{
|
||||
case PAD_ATTRIB_SMD:
|
||||
case PAD_ATTRIB_CONN:
|
||||
// These pads do not have hole (they are expected to be only on one
|
||||
// external copper layer)
|
||||
aDest.SetDrillSize( wxSize( 0, 0 ) );
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int PAD_TOOL::importPadSettings( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
const auto& selection = selTool.GetSelection();
|
||||
|
||||
auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
const D_PAD& masterPad = frame.GetDesignSettings().m_Pad_Master;
|
||||
|
||||
BOARD_COMMIT commit( &frame );
|
||||
|
||||
// for every selected pad, copy global settings
|
||||
for( auto item : selection )
|
||||
{
|
||||
if( item->Type() == PCB_PAD_T )
|
||||
{
|
||||
commit.Modify( item );
|
||||
|
||||
auto& destPad = static_cast<D_PAD&>( *item );
|
||||
|
||||
doImportPadSettings( masterPad, destPad );
|
||||
}
|
||||
}
|
||||
|
||||
commit.Push( _( "Import pad settings" ) );
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::editModifiedSelection, true );
|
||||
frame.Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int PAD_TOOL::exportPadSettings( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
const auto& selection = selTool.GetSelection();
|
||||
|
||||
auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
D_PAD& masterPad = frame.GetDesignSettings().m_Pad_Master;
|
||||
|
||||
// can only export from a single pad
|
||||
if( selection.Size() == 1 )
|
||||
{
|
||||
auto item = selection[0];
|
||||
|
||||
if( item->Type() == PCB_PAD_T )
|
||||
{
|
||||
const auto& selPad = static_cast<const D_PAD&>( *item );
|
||||
|
||||
doExportPadSettings( selPad, masterPad );
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void globalChangePadSettings( BOARD& board,
|
||||
const D_PAD& aSrcPad,
|
||||
BOARD_COMMIT& commit,
|
||||
bool aSameFootprints,
|
||||
bool aPadShapeFilter,
|
||||
bool aPadOrientFilter,
|
||||
bool aPadLayerFilter )
|
||||
{
|
||||
const MODULE* moduleRef = aSrcPad.GetParent();
|
||||
|
||||
// if there is no module, we can't make the comparisons to see which
|
||||
// pads to aply the src pad settings to
|
||||
if( moduleRef == nullptr )
|
||||
{
|
||||
wxLogDebug( _( "globalChangePadSettings() Error: NULL module" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
double pad_orient = aSrcPad.GetOrientation() - moduleRef->GetOrientation();
|
||||
|
||||
for( const MODULE* module = board.m_Modules; module; module = module->Next() )
|
||||
{
|
||||
if( !aSameFootprints && ( module != moduleRef ) )
|
||||
continue;
|
||||
|
||||
if( module->GetFPID() != moduleRef->GetFPID() )
|
||||
continue;
|
||||
|
||||
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
|
||||
{
|
||||
// Filters changes prohibited.
|
||||
if( aPadShapeFilter && ( pad->GetShape() != aSrcPad.GetShape() ) )
|
||||
continue;
|
||||
|
||||
double currpad_orient = pad->GetOrientation() - module->GetOrientation();
|
||||
|
||||
if( aPadOrientFilter && ( currpad_orient != pad_orient ) )
|
||||
continue;
|
||||
|
||||
if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
|
||||
continue;
|
||||
|
||||
if( aPadLayerFilter && ( pad->GetLayerSet() != aSrcPad.GetLayerSet() ) )
|
||||
continue;
|
||||
|
||||
commit.Modify( pad );
|
||||
|
||||
// copy source pad settings to this pad
|
||||
doImportPadSettings( aSrcPad, *pad );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int PAD_TOOL::pushPadSettings( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
auto& selTool = *m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||
const auto& selection = selTool.GetSelection();
|
||||
|
||||
auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
// not const - can be changed in the dialog
|
||||
D_PAD* srcPad = nullptr;
|
||||
|
||||
// If nothing selected, use the master pad setting,
|
||||
// otherwise, if one pad selected, use the selected pad
|
||||
if( selection.Size() == 0 )
|
||||
{
|
||||
srcPad = &frame.GetDesignSettings().m_Pad_Master;
|
||||
}
|
||||
else if( selection.Size() == 1 )
|
||||
{
|
||||
if( selection[0]->Type() == PCB_PAD_T )
|
||||
{
|
||||
srcPad = static_cast<D_PAD*>( selection[0] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// multiple selected what to do?
|
||||
// maybe master->selection? same as import multiple?
|
||||
}
|
||||
|
||||
// no valid selection, nothing to do
|
||||
if( !srcPad )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MODULE* module = srcPad->GetParent();
|
||||
|
||||
if( module != nullptr )
|
||||
{
|
||||
frame.SetMsgPanel( module );
|
||||
}
|
||||
|
||||
int dialogRet;
|
||||
{
|
||||
DIALOG_GLOBAL_PADS_EDITION dlg( &frame, srcPad );
|
||||
dialogRet = dlg.ShowModal();
|
||||
}
|
||||
|
||||
// cancel
|
||||
if( dialogRet == -1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const bool edit_Same_Modules = (dialogRet == 1);
|
||||
|
||||
BOARD_COMMIT commit( &frame );
|
||||
|
||||
globalChangePadSettings( *getModel<BOARD>(), *srcPad, commit,
|
||||
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 );
|
||||
|
||||
commit.Push( _( "Import pad settings" ) );
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::editModifiedSelection, true );
|
||||
frame.Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PAD_TOOL::SetTransitions()
|
||||
{
|
||||
Go( &PAD_TOOL::importPadSettings, COMMON_ACTIONS::importPadSettings.MakeEvent() );
|
||||
Go( &PAD_TOOL::exportPadSettings, COMMON_ACTIONS::exportPadSettings.MakeEvent() );
|
||||
Go( &PAD_TOOL::pushPadSettings, COMMON_ACTIONS::pushPadSettings.MakeEvent() );
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 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
|
||||
*/
|
||||
|
||||
#ifndef __PAD_TOOL_H
|
||||
#define __PAD_TOOL_H
|
||||
|
||||
|
||||
#include <tools/pcb_tool.h>
|
||||
|
||||
class CONTEXT_MENU;
|
||||
|
||||
/**
|
||||
* Class PAD_TOOL
|
||||
*
|
||||
* Tools relating to pads and pad settings
|
||||
*/
|
||||
class PAD_TOOL : public PCB_TOOL
|
||||
{
|
||||
public:
|
||||
PAD_TOOL();
|
||||
~PAD_TOOL();
|
||||
|
||||
///> React to model/view changes
|
||||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
///> Basic initalization
|
||||
bool Init() override;
|
||||
|
||||
///> Bind handlers to corresponding TOOL_ACTIONs
|
||||
void SetTransitions() override;
|
||||
|
||||
private:
|
||||
///> Import pad settings from board design settings to a pad
|
||||
int importPadSettings( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Export pad settings from a pad to the board design settings
|
||||
int exportPadSettings( const TOOL_EVENT& aEvent );
|
||||
|
||||
///> Push pad settings from a pad to other pads on board or module
|
||||
int pushPadSettings( const TOOL_EVENT& aEvent );
|
||||
};
|
||||
|
||||
|
||||
#endif // __PAD_TOOL_H
|
|
@ -36,6 +36,7 @@
|
|||
#include <tools/pcbnew_control.h>
|
||||
#include <tools/pcb_editor_control.h>
|
||||
#include <tools/placement_tool.h>
|
||||
#include <tools/pad_tool.h>
|
||||
#include <tools/common_actions.h>
|
||||
|
||||
#include <router/router_tool.h>
|
||||
|
@ -49,9 +50,11 @@ void registerAllTools( TOOL_MANAGER *aToolManager )
|
|||
aToolManager->RegisterTool( new ROUTER_TOOL );
|
||||
aToolManager->RegisterTool( new LENGTH_TUNER_TOOL );
|
||||
aToolManager->RegisterTool( new EDIT_TOOL );
|
||||
aToolManager->RegisterTool( new PAD_TOOL );
|
||||
aToolManager->RegisterTool( new DRAWING_TOOL );
|
||||
aToolManager->RegisterTool( new POINT_EDITOR );
|
||||
aToolManager->RegisterTool( new PCBNEW_CONTROL );
|
||||
aToolManager->RegisterTool( new PCB_EDITOR_CONTROL );
|
||||
aToolManager->RegisterTool( new PLACEMENT_TOOL );
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue