Commit 83f7c7e3 authored by Maciej Suminski's avatar Maciej Suminski

Added RN_DATA::Add()/Remove() methods.

RN_DATA::Update()/AddSimple() take BOARD_ITEM* as the parameter (instead of being split to versions with BOARD_CONNECTED_ITEM* and MODULE*), to make the code look clearer.
parent 2b8f9fc6
...@@ -673,34 +673,45 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con ...@@ -673,34 +673,45 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con
} }
void RN_NET::ClearSimple() void RN_DATA::AddSimple( const BOARD_ITEM* aItem )
{ {
BOOST_FOREACH( const RN_NODE_PTR& node, m_simpleNodes ) int net;
node->SetFlag( false );
m_simpleNodes.clear(); if( aItem->IsConnected() )
} {
const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( aItem );
net = item->GetNet();
if( net < 1 ) // do not process unconnected items
return;
void RN_DATA::AddSimple( const BOARD_CONNECTED_ITEM* aItem ) // Get list of nodes responding to the item
{ std::list<RN_NODE_PTR> nodes = m_nets[net].GetNodes( item );
int net = aItem->GetNet(); std::list<RN_NODE_PTR>::iterator it, itEnd;
if( net < 1 ) // do not process unconnected items
return;
// Get list of nodes responding to the item for( it = nodes.begin(), itEnd = nodes.end(); it != itEnd; ++it )
std::list<RN_NODE_PTR> nodes = m_nets[net].GetNodes( aItem ); m_nets[net].AddSimpleNode( *it );
std::list<RN_NODE_PTR>::iterator it, itEnd; }
else if( aItem->Type() == PCB_MODULE_T )
{
const MODULE* module = static_cast<const MODULE*>( aItem );
for( it = nodes.begin(), itEnd = nodes.end(); it != itEnd; ++it ) for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
m_nets[net].AddSimpleNode( *it ); AddSimple( pad );
return;
}
else
return;
} }
void RN_DATA::AddSimple( const MODULE* aModule ) void RN_NET::ClearSimple()
{ {
for( const D_PAD* pad = aModule->Pads().GetFirst(); pad; pad = pad->Next() ) BOOST_FOREACH( const RN_NODE_PTR& node, m_simpleNodes )
AddSimple( pad ); node->SetFlag( false );
m_simpleNodes.clear();
} }
...@@ -762,45 +773,51 @@ void RN_DATA::updateNet( int aNetCode ) ...@@ -762,45 +773,51 @@ void RN_DATA::updateNet( int aNetCode )
} }
void RN_DATA::Update( const BOARD_CONNECTED_ITEM* aItem ) void RN_DATA::Add( const BOARD_ITEM* aItem )
{ {
int net = aItem->GetNet(); int net;
if( net < 1 ) // do not process unconnected items
if( aItem->IsConnected() )
{
net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNet();
if( net < 1 ) // do not process unconnected items
return;
}
else if( aItem->Type() == PCB_MODULE_T )
{
const MODULE* module = static_cast<const MODULE*>( aItem );
for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
net = pad->GetNet();
if( net < 1 ) // do not process unconnected items
continue;
m_nets[net].AddItem( pad );
}
return;
}
else
return; return;
switch( aItem->Type() ) switch( aItem->Type() )
{ {
case PCB_PAD_T: case PCB_PAD_T:
{ m_nets[net].AddItem( static_cast<const D_PAD*>( aItem ) );
const D_PAD* pad = static_cast<const D_PAD*>( aItem ); break;
m_nets[net].RemoveItem( pad );
m_nets[net].AddItem( pad );
}
break;
case PCB_TRACE_T: case PCB_TRACE_T:
{ m_nets[net].AddItem( static_cast<const TRACK*>( aItem ) );
const TRACK* track = static_cast<const TRACK*>( aItem ); break;
m_nets[net].RemoveItem( track );
m_nets[net].AddItem( track );
}
break;
case PCB_VIA_T: case PCB_VIA_T:
{ m_nets[net].AddItem( static_cast<const SEGVIA*>( aItem ) );
const SEGVIA* via = static_cast<const SEGVIA*>( aItem ); break;
m_nets[net].RemoveItem( via );
m_nets[net].AddItem( via );
}
break;
case PCB_ZONE_AREA_T: case PCB_ZONE_AREA_T:
{ m_nets[net].AddItem( static_cast<const ZONE_CONTAINER*>( aItem ) );
const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( aItem ); break;
m_nets[net].RemoveItem( zone);
m_nets[net].AddItem( zone );
}
break;
default: default:
break; break;
...@@ -808,18 +825,62 @@ void RN_DATA::Update( const BOARD_CONNECTED_ITEM* aItem ) ...@@ -808,18 +825,62 @@ void RN_DATA::Update( const BOARD_CONNECTED_ITEM* aItem )
} }
void RN_DATA::Update( const MODULE* aModule ) void RN_DATA::Remove( const BOARD_ITEM* aItem )
{ {
for( const D_PAD* pad = aModule->Pads().GetFirst(); pad; pad = pad->Next() ) int net;
{
int net = pad->GetNet();
if( net > 0 ) // do not process unconnected items if( aItem->IsConnected() )
{
net = static_cast<const BOARD_CONNECTED_ITEM*>( aItem )->GetNet();
if( net < 1 ) // do not process unconnected items
return;
}
else if( aItem->Type() == PCB_MODULE_T )
{
const MODULE* module = static_cast<const MODULE*>( aItem );
for( const D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{ {
net = pad->GetNet();
if( net < 1 ) // do not process unconnected items
continue;
m_nets[net].RemoveItem( pad ); m_nets[net].RemoveItem( pad );
m_nets[net].AddItem( pad );
} }
return;
} }
else
return;
switch( aItem->Type() )
{
case PCB_PAD_T:
m_nets[net].RemoveItem( static_cast<const D_PAD*>( aItem ) );
break;
case PCB_TRACE_T:
m_nets[net].RemoveItem( static_cast<const TRACK*>( aItem ) );
break;
case PCB_VIA_T:
m_nets[net].RemoveItem( static_cast<const SEGVIA*>( aItem ) );
break;
case PCB_ZONE_AREA_T:
m_nets[net].RemoveItem( static_cast<const ZONE_CONTAINER*>( aItem ) );
break;
default:
break;
}
}
void RN_DATA::Update( const BOARD_ITEM* aItem )
{
Remove( aItem );
Add( aItem );
} }
......
...@@ -524,34 +524,33 @@ public: ...@@ -524,34 +524,33 @@ public:
RN_DATA( const BOARD* aBoard ) : m_board( aBoard ) {} RN_DATA( const BOARD* aBoard ) : m_board( aBoard ) {}
/** /**
* Function UpdateItem() * Function Add()
* Updates ratsnest data for an item. * Adds an item to the ratsnest data.
* @param aItem is an item to be updated. * @param aItem is an item to be added.
*/ */
void Update( const BOARD_CONNECTED_ITEM* aItem ); void Add( const BOARD_ITEM* aItem );
/** /**
* Function UpdateItem() * Function Remove()
* Updates ratsnest data for a module. * Removes an item from the ratsnest data.
* @param aItem is a module to be updated. * @param aItem is an item to be updated.
*/ */
void Update( const MODULE* aModule ); void Remove( const BOARD_ITEM* aItem );
/** /**
* Function AddSimple() * Function Update()
* Sets an item to be drawn in simple mode (ie. one line per node, instead of full ratsnest). * Updates the ratsnest data for an item.
* It is used for drawing temporary ratsnest, eg. while moving an item. * @param aItem is an item to be updated.
* @param aItem is an item to be drawn in simple node.
*/ */
void AddSimple( const BOARD_CONNECTED_ITEM* aItem ); void Update( const BOARD_ITEM* aItem );
/** /**
* Function AddSimple() * Function AddSimple()
* Sets a module to be drawn in simple mode (ie. one line per node, instead of full ratsnest). * Sets an item to be drawn in simple mode (ie. one line per node, instead of full ratsnest).
* It is used for drawing temporary ratsnest, eg. while moving a module. * It is used for drawing quick, temporary ratsnest, eg. while moving an item.
* @param aModule is a module to be drawn in simple node. * @param aItem is an item to be drawn in simple node.
*/ */
void AddSimple( const MODULE* aModule ); void AddSimple( const BOARD_ITEM* aItem );
/** /**
* Function ClearSimple() * Function ClearSimple()
......
...@@ -631,7 +631,7 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode ) ...@@ -631,7 +631,7 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode )
newBI->ClearFlags(); newBI->ClearFlags();
m_view->Add( newBI ); m_view->Add( newBI );
m_board->Add( newBI ); m_board->Add( newBI );
m_board->GetRatsnest()->Update( static_cast<BOARD_CONNECTED_ITEM*>( newBI ) ); m_board->GetRatsnest()->Update( newBI );
newBI->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); newBI->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
} }
} }
......
...@@ -376,20 +376,9 @@ void EDIT_TOOL::updateRatsnest( bool aRedraw ) ...@@ -376,20 +376,9 @@ void EDIT_TOOL::updateRatsnest( bool aRedraw )
{ {
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( i ) ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( i ) );
if( item->Type() == PCB_PAD_T || item->Type() == PCB_TRACE_T || ratsnest->Update( static_cast<BOARD_CONNECTED_ITEM*>( item ) );
item->Type() == PCB_VIA_T || item->Type() == PCB_ZONE_AREA_T )
{
ratsnest->Update( static_cast<BOARD_CONNECTED_ITEM*>( item ) );
if( aRedraw ) if( aRedraw )
ratsnest->AddSimple( static_cast<BOARD_CONNECTED_ITEM*>( item ) ); ratsnest->AddSimple( item );
}
else if( item->Type() == PCB_MODULE_T )
{
ratsnest->Update( static_cast<MODULE*>( item ) );
if( aRedraw )
ratsnest->AddSimple( static_cast<MODULE*>( item ) );
}
} }
} }
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