Changed DuplicateAndAddItem() to parametrized Duplicate().

This commit is contained in:
Tomasz Wlostowski 2016-05-11 10:17:34 +02:00 committed by Maciej Suminski
parent 1924507001
commit a5b7a7ca0a
6 changed files with 28 additions and 23 deletions

View File

@ -81,13 +81,12 @@ void ARRAY_CREATOR::Invoke()
{
// increment pad numbers if do any renumbering
// (we will number again later according to the numbering scheme if set)
new_item = module->DuplicateAndAddItem(
item, array_opts->ShouldNumberItems() );
new_item = module->Duplicate( item, array_opts->ShouldNumberItems(), true );
}
else
{
// PCB items keep the same numbering
new_item = getBoard()->DuplicateAndAddItem( item );
new_item = getBoard()->Duplicate( item, true );
// @TODO: we should merge zones. This is a bit tricky, because
// the undo command needs saving old area, if it is merged.

View File

@ -2770,7 +2770,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
}
BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem )
BOARD_ITEM* BOARD::Duplicate( const BOARD_ITEM* aItem,
bool aAddToBoard )
{
BOARD_ITEM* new_item = NULL;
@ -2799,7 +2800,10 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem )
}
if( new_item )
Add( new_item );
{
if( aAddToBoard )
Add( new_item );
}
return new_item;
}

View File

@ -277,13 +277,7 @@ public:
///> @copydoc BOARD_ITEM_CONTAINER::Remove()
void Remove( BOARD_ITEM* aBoardItem ) override;
/**
* Function DuplicateAndAddItem
* duplicates an item, and add it to the board list.
* @param aItem The item to duplicate.
* @return BOARD_ITEM* \a the new item which was added.
*/
BOARD_ITEM* DuplicateAndAddItem( const BOARD_ITEM* aItem );
BOARD_ITEM* Duplicate( const BOARD_ITEM* aItem, bool aAddToBoard = false );
/**
* Function GetRatsnest()

View File

@ -1110,8 +1110,9 @@ void MODULE::SetOrientation( double newangle )
CalculateBoundingBox();
}
BOARD_ITEM* MODULE::DuplicateAndAddItem( const BOARD_ITEM* aItem,
bool aIncrementPadNumbers )
BOARD_ITEM* MODULE::Duplicate( const BOARD_ITEM* aItem,
bool aIncrementPadNumbers,
bool aAddToModule )
{
BOARD_ITEM* new_item = NULL;
D_PAD* new_pad = NULL;
@ -1122,7 +1123,9 @@ BOARD_ITEM* MODULE::DuplicateAndAddItem( const BOARD_ITEM* aItem,
{
new_pad = new D_PAD( *static_cast<const D_PAD*>( aItem ) );
Pads().PushBack( new_pad );
if( aAddToModule )
Pads().PushBack( new_pad );
new_item = new_pad;
break;
}
@ -1137,7 +1140,9 @@ BOARD_ITEM* MODULE::DuplicateAndAddItem( const BOARD_ITEM* aItem,
{
TEXTE_MODULE* new_text = new TEXTE_MODULE( *old_text );
GraphicalItems().PushBack( new_text );
if( aAddToModule )
GraphicalItems().PushBack( new_text );
new_item = new_text;
}
break;
@ -1148,7 +1153,9 @@ BOARD_ITEM* MODULE::DuplicateAndAddItem( const BOARD_ITEM* aItem,
EDGE_MODULE* new_edge = new EDGE_MODULE(
*static_cast<const EDGE_MODULE*>(aItem) );
GraphicalItems().PushBack( new_edge );
if( aAddToModule )
GraphicalItems().PushBack( new_edge );
new_item = new_edge;
break;
}

View File

@ -520,12 +520,13 @@ public:
void SetPlacementCost90( int aCost ) { m_CntRot90 = aCost; }
/**
* Function DuplicateAndAddItem
* Duplicate a given item within the module
* Function Duplicate
* Duplicate a given item within the module, without adding to the board
* @return the new item, or NULL if the item could not be duplicated
*/
BOARD_ITEM* DuplicateAndAddItem( const BOARD_ITEM* item,
bool aIncrementPadNumbers );
BOARD_ITEM* Duplicate( const BOARD_ITEM* aItem,
bool aIncrementPadNumbers,
bool aAddToModule = false );
/**
* Function Add3DModel

View File

@ -714,7 +714,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
// TODO move DuplicateAndAddItem() to BOARD_ITEM_CONTAINER? dunno..
if( m_editModules )
new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
new_item = editFrame->GetBoard()->m_Modules->Duplicate( item, increment, true );
else
{
#if 0
@ -723,7 +723,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
// so zones are not duplicated
if( item->Type() != PCB_ZONE_AREA_T )
#endif
new_item = editFrame->GetBoard()->DuplicateAndAddItem( item );
new_item = editFrame->GetBoard()->Duplicate( item, true );
}
if( new_item )