Commit 9bed4814 authored by Maciej Suminski's avatar Maciej Suminski

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

parent f06690c8
...@@ -2635,66 +2635,18 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem, ...@@ -2635,66 +2635,18 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem,
new_module->IncrementReference( true ); new_module->IncrementReference( true );
} }
m_Modules.PushBack( new_module );
new_item = new_module; new_item = new_module;
break; break;
} }
case PCB_TEXT_T: 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: 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: 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: 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: 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: case PCB_DIMENSION_T:
{ new_item = static_cast<BOARD_ITEM*>( aItem->Clone() );
DIMENSION* new_dim = new DIMENSION(
*static_cast<const DIMENSION*>(aItem) );
m_Drawings.PushBack( new_dim );
new_item = new_dim;
break; break;
}
default: default:
// Un-handled item for duplication // Un-handled item for duplication
wxASSERT_MSG( false, "Duplication not supported for items of class " wxASSERT_MSG( false, "Duplication not supported for items of class "
...@@ -2702,6 +2654,9 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem, ...@@ -2702,6 +2654,9 @@ BOARD_ITEM* BOARD::DuplicateAndAddItem( const BOARD_ITEM* aItem,
break; break;
} }
if( new_item )
Add( new_item );
return new_item; return new_item;
} }
...@@ -2723,7 +2678,7 @@ wxString BOARD::GetNextModuleReferenceWithPrefix( const wxString& aPrefix, ...@@ -2723,7 +2678,7 @@ wxString BOARD::GetNextModuleReferenceWithPrefix( const wxString& aPrefix,
continue; continue;
// the suffix must be a number // the suffix must be a number
if ( !remainder.IsNumber() ) if( !remainder.IsNumber() )
continue; continue;
long number; long number;
......
...@@ -699,10 +699,10 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) ...@@ -699,10 +699,10 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
BOARD_ITEM* new_item = NULL; BOARD_ITEM* new_item = NULL;
if ( PCB_EDIT_FRAME* frame = dynamic_cast<PCB_EDIT_FRAME*>( editFrame ) ) if( m_editModules )
new_item = frame->GetBoard()->DuplicateAndAddItem( item, increment ); new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else if ( FOOTPRINT_EDIT_FRAME* frame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( editFrame ) ) else
new_item = frame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment ); new_item = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
if( new_item ) if( new_item )
{ {
...@@ -759,9 +759,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) ...@@ -759,9 +759,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>(); PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
editFrame->OnModify(); editFrame->OnModify();
const bool editingModule = NULL != dynamic_cast<FOOTPRINT_EDIT_FRAME*>( editFrame ); if( m_editModules )
if( editingModule )
{ {
// Module editors do their undo point upfront for the whole module // Module editors do their undo point upfront for the whole module
editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT ); editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT );
...@@ -819,10 +817,10 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) ...@@ -819,10 +817,10 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
// if renumbering, no need to increment // if renumbering, no need to increment
const bool increment = !array_opts->ShouldRenumberItems(); const bool increment = !array_opts->ShouldRenumberItems();
if ( PCB_EDIT_FRAME* frame = dynamic_cast<PCB_EDIT_FRAME*>( editFrame ) ) if( m_editModules )
newItem = frame->GetBoard()->DuplicateAndAddItem( item, increment ); newItem = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else if ( FOOTPRINT_EDIT_FRAME* frame = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( editFrame ) ) else
newItem = frame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment ); newItem = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
if( newItem ) if( newItem )
{ {
...@@ -839,6 +837,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) ...@@ -839,6 +837,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
} }
editFrame->GetGalCanvas()->GetView()->Add( newItem ); editFrame->GetGalCanvas()->GetView()->Add( newItem );
getModel<BOARD>()->GetRatsnest()->Update( newItem );
} }
} }
...@@ -881,7 +880,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) ...@@ -881,7 +880,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
} }
} }
if( !editingModule ) if( !m_editModules )
{ {
if( originalItemsModified ) if( originalItemsModified )
{ {
...@@ -896,6 +895,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) ...@@ -896,6 +895,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
} }
} }
getModel<BOARD>()->GetRatsnest()->Recalculate();
setTransitions(); setTransitions();
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment