From aafdfd015e6334b9d3642baad2ac8514defed9e9 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 18 Feb 2015 20:30:14 +0100 Subject: [PATCH] Disabled 'Duplicate' & 'Create array' for pads in the layout editor. --- include/class_board_item.h | 2 +- pcbnew/edit.cpp | 20 ++++++++++++++++---- pcbnew/tools/common_actions.cpp | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/class_board_item.h b/include/class_board_item.h index ebbf4bcff5..953759fa6d 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -79,7 +79,7 @@ protected: LAYER_ID m_Layer; static int getTrailingInt( wxString aStr ); - static int getNextNumberInSequence( std::set aSeq, bool aFillSequenceGaps); + static int getNextNumberInSequence( std::set aSeq, bool aFillSequenceGaps ); public: diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 25b3d8be0f..d4c25cdd69 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -1531,11 +1531,16 @@ void PCB_EDIT_FRAME::moveExact() void PCB_EDIT_FRAME::duplicateItem( bool aIncrement ) { BOARD_ITEM* item = GetScreen()->GetCurItem(); - + bool editingModule = NULL != dynamic_cast( this ); int move_cmd = 0; - BOARD_ITEM* new_item = GetBoard()->DuplicateAndAddItem( - item, aIncrement ); + if( item->Type() == PCB_PAD_T && !editingModule ) + { + // If it is not the module editor, then duplicate the parent module instead + item = static_cast( item )->GetParent(); + } + + BOARD_ITEM* new_item = GetBoard()->DuplicateAndAddItem( item, aIncrement ); SaveCopyInUndoList( new_item, UR_NEW ); @@ -1595,6 +1600,7 @@ void PCB_BASE_EDIT_FRAME::createArray() bool editingModule = NULL != dynamic_cast( this ); BOARD* board = GetBoard(); + // Remember it is valid only in the module editor MODULE* module = static_cast( item->GetParent() ); DIALOG_CREATE_ARRAY::ARRAY_OPTIONS* array_opts = NULL; @@ -1608,6 +1614,12 @@ void PCB_BASE_EDIT_FRAME::createArray() { PICKED_ITEMS_LIST newItemsList; + if( item->Type() == PCB_PAD_T && !editingModule ) + { + // If it is not the module editor, then duplicate the parent module instead + item = static_cast( item )->GetParent(); + } + if( editingModule ) { // modedit saves everything upfront @@ -1631,7 +1643,7 @@ void PCB_BASE_EDIT_FRAME::createArray() cachedString = text->GetText(); } - for( int ptN = 0; ptN < array_opts->GetArraySize(); ptN++) + for( int ptN = 0; ptN < array_opts->GetArraySize(); ptN++ ) { BOARD_ITEM* new_item = NULL; diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index d747e1e5ee..1d511a0558 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -56,7 +56,7 @@ TOOL_ACTION COMMON_ACTIONS::findDummy( "pcbnew.Find.Dummy", // only block the ho AS_GLOBAL, MD_CTRL + int( 'F' ) ); TOOL_ACTION COMMON_ACTIONS::findMove( "pcbnew.InteractiveSelection.FindMove", - AS_GLOBAL, 'T'); + AS_GLOBAL, 'T' ); // Edit tool actions @@ -77,7 +77,7 @@ TOOL_ACTION COMMON_ACTIONS::moveExact( "pcbnew.InteractiveEdit.moveExact", "Move Exactly...", "Moves the selected item(s) by an exact amount" ); TOOL_ACTION COMMON_ACTIONS::createArray( "pcbnew.InteractiveEdit.createArray", - AS_GLOBAL, MD_CTRL + int('N'), + AS_GLOBAL, MD_CTRL + int( 'N' ), "Create array", "Create array", AF_ACTIVATE ); TOOL_ACTION COMMON_ACTIONS::rotate( "pcbnew.InteractiveEdit.rotate",