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