Commit 510fee13 authored by Maciej Suminski's avatar Maciej Suminski

Another way of handling items for the ratsnest (clearer and now finally...

Another way of handling items for the ratsnest (clearer and now finally supports undo/redo of the PNS created tracks).
parent bbb3972f
...@@ -548,8 +548,7 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -548,8 +548,7 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
if( item->Type() == PCB_MODULE_T ) if( item->Type() == PCB_MODULE_T )
{ {
MODULE* module = static_cast<MODULE*>( item ); MODULE* module = static_cast<MODULE*>( item );
module->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Remove ), module->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Remove ), view ) );
view ) );
} }
view->Remove( item ); view->Remove( item );
...@@ -563,8 +562,7 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -563,8 +562,7 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
if( item->Type() == PCB_MODULE_T ) if( item->Type() == PCB_MODULE_T )
{ {
MODULE* module = static_cast<MODULE*>( item ); MODULE* module = static_cast<MODULE*>( item );
module->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ), module->RunOnChildren( std::bind1st( std::mem_fun( &KIGFX::VIEW::Add ), view ) );
view ) );
} }
view->Add( item ); view->Add( item );
...@@ -575,23 +573,27 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -575,23 +573,27 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
case UR_MOVED: case UR_MOVED:
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint ); item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
ratsnest->Update( item );
break; break;
case UR_ROTATED: case UR_ROTATED:
item->Rotate( aList->m_TransformPoint, item->Rotate( aList->m_TransformPoint,
aRedoCommand ? m_rotationAngle : -m_rotationAngle ); aRedoCommand ? m_rotationAngle : -m_rotationAngle );
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
ratsnest->Update( item );
break; break;
case UR_ROTATED_CLOCKWISE: case UR_ROTATED_CLOCKWISE:
item->Rotate( aList->m_TransformPoint, item->Rotate( aList->m_TransformPoint,
aRedoCommand ? -m_rotationAngle : m_rotationAngle ); aRedoCommand ? -m_rotationAngle : m_rotationAngle );
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
ratsnest->Update( item );
break; break;
case UR_FLIPPED: case UR_FLIPPED:
item->Flip( aList->m_TransformPoint ); item->Flip( aList->m_TransformPoint );
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS ); item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
ratsnest->Update( item );
break; break;
default: default:
...@@ -603,8 +605,6 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -603,8 +605,6 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
} }
break; break;
} }
ratsnest->Update( item );
} }
if( not_found ) if( not_found )
......
...@@ -842,6 +842,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) ...@@ -842,6 +842,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
} }
break; break;
} }
m_ratsnest->Add( aBoardItem );
} }
...@@ -867,56 +869,26 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) ...@@ -867,56 +869,26 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
break; break;
case PCB_ZONE_AREA_T: // this one uses a vector case PCB_ZONE_AREA_T: // this one uses a vector
{
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( aBoardItem );
// find the item in the vector, then delete then erase it. // find the item in the vector, then delete then erase it.
for( unsigned i = 0; i < m_ZoneDescriptorList.size(); ++i ) for( unsigned i = 0; i<m_ZoneDescriptorList.size(); ++i )
{ {
if( m_ZoneDescriptorList[i] == zone ) if( m_ZoneDescriptorList[i] == (ZONE_CONTAINER*) aBoardItem )
{ {
m_ZoneDescriptorList.erase( m_ZoneDescriptorList.begin() + i ); m_ZoneDescriptorList.erase( m_ZoneDescriptorList.begin() + i );
break; break;
} }
} }
if( zone->GetNet() > 0 ) break;
m_ratsnest->GetNet( zone->GetNet() ).RemoveItem( zone );
}
break;
case PCB_MODULE_T: case PCB_MODULE_T:
{
MODULE* module = static_cast<MODULE*>( aBoardItem );
m_Modules.Remove( (MODULE*) aBoardItem ); m_Modules.Remove( (MODULE*) aBoardItem );
break;
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
if( pad->GetNet() > 0 )
m_ratsnest->GetNet( pad->GetNet() ).RemoveItem( pad );
}
}
break;
case PCB_TRACE_T: case PCB_TRACE_T:
{
TRACK* track = static_cast<TRACK*>( aBoardItem );
m_Track.Remove( track );
if( track->GetNet() > 0 )
m_ratsnest->GetNet( track->GetNet() ).RemoveItem( track );
}
break;
case PCB_VIA_T: case PCB_VIA_T:
{ m_Track.Remove( (TRACK*) aBoardItem );
SEGVIA* via = static_cast<SEGVIA*>( aBoardItem ); break;
m_Track.Remove( via );
if( via->GetNet() > 0 )
m_ratsnest->GetNet( via->GetNet() ).RemoveItem( via );
}
break;
case PCB_ZONE_T: case PCB_ZONE_T:
m_Zone.Remove( (SEGZONE*) aBoardItem ); m_Zone.Remove( (SEGZONE*) aBoardItem );
...@@ -935,6 +907,8 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) ...@@ -935,6 +907,8 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) ); wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
} }
m_ratsnest->Remove( aBoardItem );
return aBoardItem; return aBoardItem;
} }
......
...@@ -428,11 +428,11 @@ BOARD* PCB_PARSER::parseBOARD() throw( IO_ERROR, PARSE_ERROR ) ...@@ -428,11 +428,11 @@ BOARD* PCB_PARSER::parseBOARD() throw( IO_ERROR, PARSE_ERROR )
break; break;
case T_segment: case T_segment:
m_board->m_Track.Append( parseTRACK() ); m_board->Add( parseTRACK(), ADD_APPEND );
break; break;
case T_via: case T_via:
m_board->m_Track.Append( parseSEGVIA() ); m_board->Add( parseSEGVIA(), ADD_APPEND );
break; break;
case T_zone: case T_zone:
......
...@@ -612,7 +612,6 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -612,7 +612,6 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
// Add an entry for the ratsnest // Add an entry for the ratsnest
RN_DATA* ratsnest = aBoard->GetRatsnest(); RN_DATA* ratsnest = aBoard->GetRatsnest();
ratsnest->ProcessBoard();
ratsnest->Recalculate(); ratsnest->Recalculate();
view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) ); view->Add( new KIGFX::RATSNEST_VIEWITEM( ratsnest ) );
......
...@@ -782,6 +782,10 @@ void RN_DATA::Add( const BOARD_ITEM* aItem ) ...@@ -782,6 +782,10 @@ void RN_DATA::Add( const BOARD_ITEM* aItem )
net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNet(); net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNet();
if( net < 1 ) // do not process unconnected items if( net < 1 ) // do not process unconnected items
return; return;
// Autoresize
if( net >= (int) m_nets.size() )
m_nets.resize( net + 1 );
} }
else if( aItem->Type() == PCB_MODULE_T ) else if( aItem->Type() == PCB_MODULE_T )
{ {
...@@ -789,10 +793,13 @@ void RN_DATA::Add( const BOARD_ITEM* aItem ) ...@@ -789,10 +793,13 @@ void RN_DATA::Add( const BOARD_ITEM* aItem )
for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() ) for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{ {
net = pad->GetNet(); net = pad->GetNet();
if( net < 1 ) // do not process unconnected items if( net < 1 ) // do not process unconnected items
continue; continue;
// Autoresize
if( net >= (int) m_nets.size() )
m_nets.resize( net + 1 );
m_nets[net].AddItem( pad ); m_nets[net].AddItem( pad );
} }
...@@ -841,7 +848,6 @@ void RN_DATA::Remove( const BOARD_ITEM* aItem ) ...@@ -841,7 +848,6 @@ void RN_DATA::Remove( const BOARD_ITEM* aItem )
for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() ) for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{ {
net = pad->GetNet(); net = pad->GetNet();
if( net < 1 ) // do not process unconnected items if( net < 1 ) // do not process unconnected items
continue; continue;
...@@ -916,8 +922,8 @@ void RN_DATA::Recalculate( int aNet ) ...@@ -916,8 +922,8 @@ void RN_DATA::Recalculate( int aNet )
{ {
if( aNet < 0 ) // Recompute everything if( aNet < 0 ) // Recompute everything
{ {
// Start with net number 1, as 0 stand for not connected // Start with net number 1, as 0 stands for not connected
for( unsigned int i = 1; i < m_board->GetNetCount(); ++i ) for( unsigned int i = 1; i < m_nets.size(); ++i )
{ {
// Recompute only nets that require it // Recompute only nets that require it
if( m_nets[i].IsDirty() ) if( m_nets[i].IsDirty() )
......
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