BOARD_COMMIT code cleaning
Moved a few conditionals to scopes where they can be executed. Simpler way to create ITEM_PICKERs.
This commit is contained in:
parent
c7ce82a4bf
commit
f1b37109e3
|
@ -68,6 +68,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
|
|
||||||
for( COMMIT_LINE& ent : m_changes )
|
for( COMMIT_LINE& ent : m_changes )
|
||||||
{
|
{
|
||||||
|
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
|
||||||
|
|
||||||
// Module items need to be saved in the undo buffer before modification
|
// Module items need to be saved in the undo buffer before modification
|
||||||
if( m_editModules )
|
if( m_editModules )
|
||||||
{
|
{
|
||||||
|
@ -91,7 +93,9 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
itemWrapper.SetLink( ent.m_copy );
|
itemWrapper.SetLink( ent.m_copy );
|
||||||
undoList.PushItem( itemWrapper );
|
undoList.PushItem( itemWrapper );
|
||||||
frame->SaveCopyInUndoList( undoList, UR_CHANGED );
|
frame->SaveCopyInUndoList( undoList, UR_CHANGED );
|
||||||
|
|
||||||
savedModules.insert( ent.m_item );
|
savedModules.insert( ent.m_item );
|
||||||
|
static_cast<MODULE*>( ent.m_item )->SetLastEditTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,23 +105,23 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
{
|
{
|
||||||
if( !m_editModules )
|
if( !m_editModules )
|
||||||
{
|
{
|
||||||
ITEM_PICKER itemWrapper( boardItem, UR_NEW );
|
undoList.PushItem( ITEM_PICKER( boardItem, UR_NEW ) );
|
||||||
undoList.PushItem( itemWrapper );
|
|
||||||
board->Add( boardItem );
|
board->Add( boardItem );
|
||||||
|
//ratsnest->Add( boardItem ); // TODO currently done by BOARD::Add()
|
||||||
|
|
||||||
|
if( boardItem->Type() == PCB_MODULE_T )
|
||||||
|
{
|
||||||
|
MODULE* mod = static_cast<MODULE*>( boardItem );
|
||||||
|
mod->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assert( boardItem->Type() != PCB_MODULE_T );
|
||||||
board->m_Modules->Add( boardItem );
|
board->m_Modules->Add( boardItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( boardItem->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* mod = static_cast<MODULE*>( boardItem );
|
|
||||||
mod->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
view->Add( boardItem );
|
view->Add( boardItem );
|
||||||
//ratsnest->Add( boardItem ); // TODO currently done by BOARD::Add()
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,29 +129,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
{
|
{
|
||||||
if( !m_editModules )
|
if( !m_editModules )
|
||||||
{
|
{
|
||||||
ITEM_PICKER itemWrapper( boardItem, UR_DELETED );
|
undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) );
|
||||||
undoList.PushItem( itemWrapper );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( boardItem->Type() )
|
switch( boardItem->Type() )
|
||||||
{
|
{
|
||||||
case PCB_MODULE_T:
|
|
||||||
{
|
|
||||||
// There are no modules inside a module yet
|
|
||||||
assert( !m_editModules );
|
|
||||||
|
|
||||||
MODULE* module = static_cast<MODULE*>( boardItem );
|
|
||||||
module->ClearFlags();
|
|
||||||
module->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
|
|
||||||
view->Remove( module );
|
|
||||||
board->Remove( module );
|
|
||||||
|
|
||||||
// Clear flags to indicate, that the ratsnest, list of nets & pads are not valid anymore
|
|
||||||
board->m_Status_Pcb = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Module items
|
// Module items
|
||||||
case PCB_PAD_T:
|
case PCB_PAD_T:
|
||||||
case PCB_MODULE_EDGE_T:
|
case PCB_MODULE_EDGE_T:
|
||||||
|
@ -189,18 +175,16 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
view->Remove( boardItem );
|
view->Remove( boardItem );
|
||||||
|
|
||||||
MODULE* module = static_cast<MODULE*>( boardItem->GetParent() );
|
MODULE* module = static_cast<MODULE*>( boardItem->GetParent() );
|
||||||
module->Remove( boardItem );
|
assert( module && module->Type() == PCB_MODULE_T );
|
||||||
module->SetLastEditTime();
|
module->Delete( boardItem );
|
||||||
board->m_Status_Pcb = 0; // it is done in the legacy view
|
|
||||||
|
|
||||||
// Footprint editor saves a full copy of the footprint in the undo buffer,
|
board->m_Status_Pcb = 0; // it is done in the legacy view (ratsnest perhaps?)
|
||||||
// so we have to actually delete the text/drawing/pad to avoid memleaks
|
|
||||||
boardItem->DeleteStructure();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Board items
|
||||||
case PCB_LINE_T: // a segment not on copper layers
|
case PCB_LINE_T: // a segment not on copper layers
|
||||||
case PCB_TEXT_T: // a text on a layer
|
case PCB_TEXT_T: // a text on a layer
|
||||||
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
||||||
|
@ -215,6 +199,23 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
//ratsnest->Remove( boardItem ); // currently done by BOARD::Remove()
|
//ratsnest->Remove( boardItem ); // currently done by BOARD::Remove()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCB_MODULE_T:
|
||||||
|
{
|
||||||
|
// There are no modules inside a module yet
|
||||||
|
assert( !m_editModules );
|
||||||
|
|
||||||
|
MODULE* module = static_cast<MODULE*>( boardItem );
|
||||||
|
module->ClearFlags();
|
||||||
|
module->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
||||||
|
|
||||||
|
view->Remove( module );
|
||||||
|
board->Remove( module );
|
||||||
|
|
||||||
|
// Clear flags to indicate, that the ratsnest, list of nets & pads are not valid anymore
|
||||||
|
board->m_Status_Pcb = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default: // other types do not need to (or should not) be handled
|
default: // other types do not need to (or should not) be handled
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
|
@ -227,23 +228,18 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
if( !m_editModules )
|
if( !m_editModules )
|
||||||
{
|
{
|
||||||
ITEM_PICKER itemWrapper( boardItem, UR_CHANGED );
|
ITEM_PICKER itemWrapper( boardItem, UR_CHANGED );
|
||||||
|
assert( ent.m_copy );
|
||||||
itemWrapper.SetLink( ent.m_copy );
|
itemWrapper.SetLink( ent.m_copy );
|
||||||
undoList.PushItem( itemWrapper );
|
undoList.PushItem( itemWrapper );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( boardItem->Type() == PCB_MODULE_T )
|
|
||||||
{
|
|
||||||
MODULE* mod = static_cast<MODULE*>( boardItem );
|
|
||||||
//mod->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) );
|
|
||||||
mod->RunOnChildren( boost::bind( &RN_DATA::Update, ratsnest, _1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
boardItem->ViewUpdate( KIGFX::VIEW_ITEM::ALL );
|
boardItem->ViewUpdate( KIGFX::VIEW_ITEM::ALL );
|
||||||
ratsnest->Update( boardItem );
|
ratsnest->Update( boardItem );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
assert( false );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,4 +319,3 @@ void BOARD_COMMIT::Revert()
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue