Ratsnest is updated after rotation, flip, undo/redo operations.
Fixed crashes of ratsnest when a pointer for an item has changed after undo/redo operations. Vias are properly removed from ratsnest (pcbnew/class_board.cpp).
This commit is contained in:
parent
83f7c7e35e
commit
bec24b6c7f
|
@ -41,6 +41,8 @@
|
|||
#include <class_zone.h>
|
||||
#include <class_edge_mod.h>
|
||||
|
||||
#include <ratsnest_data.h>
|
||||
|
||||
#include <tools/selection_tool.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
|
@ -453,13 +455,14 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
bool not_found = false;
|
||||
bool reBuild_ratsnest = false;
|
||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||
RN_DATA* ratsnest = GetBoard()->GetRatsnest();
|
||||
|
||||
// Undo in the reverse order of list creation: (this can allow stacked changes
|
||||
// like the same item can be changes and deleted in the same complex command
|
||||
|
||||
bool build_item_list = true; // if true the list of existing items must be rebuilt
|
||||
|
||||
for( int ii = aList->GetCount()-1; ii >= 0 ; ii-- )
|
||||
for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- )
|
||||
{
|
||||
item = (BOARD_ITEM*) aList->GetPickedItem( ii );
|
||||
wxASSERT( item );
|
||||
|
@ -519,8 +522,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
if( item->Type() == PCB_MODULE_T )
|
||||
{
|
||||
MODULE* oldModule = static_cast<MODULE*>( item );
|
||||
oldModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Remove ),
|
||||
view ) );
|
||||
oldModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Remove ), view ) );
|
||||
oldModule->RunOnChildren( std::bind1st( std::mem_fun( &RN_DATA::Remove ), ratsnest ) );
|
||||
}
|
||||
|
||||
item->SwapData( image );
|
||||
|
@ -530,8 +533,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
if( item->Type() == PCB_MODULE_T )
|
||||
{
|
||||
MODULE* newModule = static_cast<MODULE*>( item );
|
||||
newModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ),
|
||||
view ) );
|
||||
newModule->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ), view ) );
|
||||
newModule->RunOnChildren( std::bind1st( std::mem_fun( &RN_DATA::Add ), ratsnest ) );
|
||||
}
|
||||
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
|
||||
|
@ -577,11 +580,13 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
case UR_ROTATED:
|
||||
item->Rotate( aList->m_TransformPoint,
|
||||
aRedoCommand ? m_rotationAngle : -m_rotationAngle );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
break;
|
||||
|
||||
case UR_ROTATED_CLOCKWISE:
|
||||
item->Rotate( aList->m_TransformPoint,
|
||||
aRedoCommand ? -m_rotationAngle : m_rotationAngle );
|
||||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
break;
|
||||
|
||||
case UR_FLIPPED:
|
||||
|
@ -598,6 +603,8 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ratsnest->Update( item );
|
||||
}
|
||||
|
||||
if( not_found )
|
||||
|
@ -605,7 +612,12 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
|
||||
// Rebuild pointers and ratsnest that can be changed.
|
||||
if( reBuild_ratsnest && aRebuildRatsnet )
|
||||
{
|
||||
if( IsGalCanvasActive() )
|
||||
ratsnest->Recalculate();
|
||||
else
|
||||
Compile_Ratsnest( NULL, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -895,7 +895,6 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
|
|||
break;
|
||||
|
||||
case PCB_TRACE_T:
|
||||
case PCB_VIA_T:
|
||||
{
|
||||
TRACK* track = static_cast<TRACK*>( aBoardItem );
|
||||
m_Track.Remove( track );
|
||||
|
@ -903,6 +902,14 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
|
|||
}
|
||||
break;
|
||||
|
||||
case PCB_VIA_T:
|
||||
{
|
||||
SEGVIA* via = static_cast<SEGVIA*>( aBoardItem );
|
||||
m_Track.Remove( via );
|
||||
m_ratsnest->GetNets()[via->GetNet()].RemoveItem( via );
|
||||
}
|
||||
break;
|
||||
|
||||
case PCB_ZONE_T:
|
||||
m_Zone.Remove( (SEGZONE*) aBoardItem );
|
||||
break;
|
||||
|
|
|
@ -119,7 +119,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
|||
{
|
||||
Remove( aEvent );
|
||||
|
||||
break;
|
||||
break; // exit the loop, as there is no further processing for removed items
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
|
|||
|
||||
setTransitions();
|
||||
updateRatsnest( true );
|
||||
getModel<BOARD>( PCB_T )->GetRatsnest()->Recalculate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -233,12 +234,14 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
|
|||
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
}
|
||||
|
||||
if( m_dragging )
|
||||
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
setTransitions();
|
||||
updateRatsnest( true );
|
||||
|
||||
if( m_dragging )
|
||||
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
else
|
||||
getModel<BOARD>( PCB_T )->GetRatsnest()->Recalculate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -264,12 +267,14 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
|
|||
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
|
||||
}
|
||||
|
||||
if( m_dragging )
|
||||
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
||||
setTransitions();
|
||||
updateRatsnest( true );
|
||||
|
||||
if( m_dragging )
|
||||
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
else
|
||||
getModel<BOARD>( PCB_T )->GetRatsnest()->Recalculate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue