Ratsnest update in 'Create array' tool (GAL).

This commit is contained in:
Maciej Suminski 2015-02-18 20:29:52 +01:00
parent f06690c8d3
commit 9bed4814a3
2 changed files with 18 additions and 63 deletions

View File

@ -2635,66 +2635,18 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem,
new_module->IncrementReference( true );
}
m_Modules.PushBack( new_module );
new_item = new_module;
break;
}
case PCB_TEXT_T:
{
const TEXTE_PCB* old_text = static_cast<const TEXTE_PCB*>( aItem );
TEXTE_PCB* new_text = new TEXTE_PCB( *old_text );
m_Drawings.PushBack( new_text );
new_item = new_text;
break;
}
case PCB_LINE_T:
{
DRAWSEGMENT* new_edge = new DRAWSEGMENT(
*static_cast<const DRAWSEGMENT*>(aItem) );
m_Drawings.PushBack( new_edge );
new_item = new_edge;
break;
}
case PCB_TRACE_T:
{
TRACK* new_track = new TRACK(
*static_cast<const TRACK*>(aItem) );
m_Track.PushBack( new_track );
new_item = new_track;
break;
}
case PCB_ZONE_AREA_T:
{
ZONE_CONTAINER* new_zone = new ZONE_CONTAINER(
*static_cast<const ZONE_CONTAINER*>(aItem) );
m_ZoneDescriptorList.push_back( new_zone );
new_item = new_zone;
break;
}
case PCB_TARGET_T:
{
PCB_TARGET* new_target = new PCB_TARGET(
*static_cast<const PCB_TARGET*>(aItem) );
m_Drawings.PushBack( new_target );
new_item = new_target;
break;
}
case PCB_DIMENSION_T:
{
DIMENSION* new_dim = new DIMENSION(
*static_cast<const DIMENSION*>(aItem) );
m_Drawings.PushBack( new_dim );
new_item = new_dim;
new_item = static_cast<BOARD_ITEM*>( aItem->Clone() );
break;
}
default:
// Un-handled item for duplication
wxASSERT_MSG( false, "Duplication not supported for items of class "
@ -2702,6 +2654,9 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem,
break;
}
if( new_item )
Add( new_item );
return new_item;
}
@ -2723,7 +2678,7 @@ wxString BOARD::GetNextModuleReferenceWithPrefix( const wxString& aPrefix,
continue;
// the suffix must be a number
if ( !remainder.IsNumber() )
if( !remainder.IsNumber() )
continue;
long number;

View File

@ -699,10 +699,10 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
BOARD_ITEM* new_item = NULL;
if ( PCB_EDIT_FRAME* frame = dynamic_cast<PCB_EDIT_FRAME*>( editFrame ) )
new_item = frame->GetBoard()->DuplicateAndAddItem( item, increment );
else if ( FOOTPRINT_EDIT_FRAME* frame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( editFrame ) )
new_item = frame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
if( m_editModules )
new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else
new_item = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
if( new_item )
{
@ -759,9 +759,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
editFrame->OnModify();
const bool editingModule = NULL != dynamic_cast<FOOTPRINT_EDIT_FRAME*>( editFrame );
if( editingModule )
if( m_editModules )
{
// Module editors do their undo point upfront for the whole module
editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT );
@ -819,10 +817,10 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
// if renumbering, no need to increment
const bool increment = !array_opts->ShouldRenumberItems();
if ( PCB_EDIT_FRAME* frame = dynamic_cast<PCB_EDIT_FRAME*>( editFrame ) )
newItem = frame->GetBoard()->DuplicateAndAddItem( item, increment );
else if ( FOOTPRINT_EDIT_FRAME* frame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( editFrame ) )
newItem = frame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
if( m_editModules )
newItem = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else
newItem = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
if( newItem )
{
@ -839,6 +837,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
}
editFrame->GetGalCanvas()->GetView()->Add( newItem );
getModel<BOARD>()->GetRatsnest()->Update( newItem );
}
}
@ -881,7 +880,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
}
}
if( !editingModule )
if( !m_editModules )
{
if( originalItemsModified )
{
@ -896,6 +895,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
}
}
getModel<BOARD>()->GetRatsnest()->Recalculate();
setTransitions();
return 0;