Commit 7c171870 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Fix typo in 2 filenames. Add comments in ratsnest.cpp.

Fix bug 887202.
parent 936d831b
...@@ -689,7 +689,7 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc ...@@ -689,7 +689,7 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc
mask, mask,
this, this,
wxFD_OPEN, wxFD_OPEN,
TRUE ); true );
if( filename.IsEmpty() ) if( filename.IsEmpty() )
return; return;
...@@ -710,14 +710,14 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescLi ...@@ -710,14 +710,14 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescLi
wxString path = wxGetCwd(); wxString path = wxGetCwd();
wxString filename; wxString filename;
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ), filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
path, path,
filename, filename,
ext, ext,
mask, mask,
this, this,
wxFD_OPEN, wxFD_OPEN | wxFD_SAVE,
TRUE ); true );
if( filename.IsEmpty() ) if( filename.IsEmpty() )
return; return;
......
...@@ -132,7 +132,7 @@ set(PCBNEW_SRCS ...@@ -132,7 +132,7 @@ set(PCBNEW_SRCS
magnetic_tracks_functions.cpp magnetic_tracks_functions.cpp
menubar_modedit.cpp menubar_modedit.cpp
menubar_pcbframe.cpp menubar_pcbframe.cpp
minumun_spanning_tree.cpp minimun_spanning_tree.cpp
mirepcb.cpp mirepcb.cpp
modedit.cpp modedit.cpp
modedit_onclick.cpp modedit_onclick.cpp
......
/** /**
* @file minumun_spanning_tree.cpp * @file minimun_spanning_tree.cpp
*/ */
/* /*
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <limits.h> #include <limits.h>
#include "minumun_spanning_tree.h" #include "minimun_spanning_tree.h"
#include "class_pad.h" #include "class_pad.h"
/* /*
......
/** /**
* @file minumun_spanning_tree.h * @file minimun_spanning_tree.h
*/ */
#include <vector> #include <vector>
......
...@@ -17,12 +17,7 @@ ...@@ -17,12 +17,7 @@
#include "pcbnew.h" #include "pcbnew.h"
#include "minumun_spanning_tree.h" #include "minimun_spanning_tree.h"
static std::vector <D_PAD*> s_localPadBuffer; // for local ratsnest
// calculations when moving a
// footprint: buffer of pads to
// consider
/** /**
* @brief class MIN_SPAN_TREE_PADS (derived from MIN_SPAN_TREE) specialize * @brief class MIN_SPAN_TREE_PADS (derived from MIN_SPAN_TREE) specialize
...@@ -190,8 +185,7 @@ static bool sortByNetcode( const D_PAD* const & ref, const D_PAD* const & item ) ...@@ -190,8 +185,7 @@ static bool sortByNetcode( const D_PAD* const & ref, const D_PAD* const & item )
/** /**
* Function to compute the full ratsnest * Function to compute the full ratsnest
* In the functions tracks are not considered * This is the "basic" ratsnest depending only on pads.
* This is only the "basic" ratsnest depending only on pads.
* *
* Create the sorted pad list (if necessary) * Create the sorted pad list (if necessary)
* The active pads (i.e included in a net ) are called nodes * The active pads (i.e included in a net ) are called nodes
...@@ -201,8 +195,7 @@ static bool sortByNetcode( const D_PAD* const & ref, const D_PAD* const & item ) ...@@ -201,8 +195,7 @@ static bool sortByNetcode( const D_PAD* const & ref, const D_PAD* const & item )
* Update : * Update :
* nb_nodes = Active pads count for the board * nb_nodes = Active pads count for the board
* nb_links = link count for the board (logical connection count) * nb_links = link count for the board (logical connection count)
* (there are n-1 links for a connection which have n active pads) . * (there are n-1 links in a net which counting n active pads) .
*
*/ */
void PCB_BASE_FRAME::Build_Board_Ratsnest() void PCB_BASE_FRAME::Build_Board_Ratsnest()
{ {
...@@ -265,10 +258,10 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest() ...@@ -265,10 +258,10 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest()
/** /**
* function Displays the general ratsnest * function DrawGeneralRatsnest
* Only ratsnest with the status bit CH_VISIBLE is set are displayed * Only ratsnest items with the status bit CH_VISIBLE set are displayed
* @param aDC = the current device context (can be NULL) * @param aDC = the current device context (can be NULL)
* @param aNetcode if > 0, Display only the ratsnest relative to the * @param aNetcode: if > 0, Display only the ratsnest relative to the
* corresponding net_code * corresponding net_code
*/ */
void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode ) void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode )
...@@ -282,7 +275,7 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode ) ...@@ -282,7 +275,7 @@ void PCB_BASE_FRAME::DrawGeneralRatsnest( wxDC* aDC, int aNetcode )
if( aDC == NULL ) if( aDC == NULL )
return; return;
int state = CH_VISIBLE | CH_ACTIF; const int state = CH_VISIBLE | CH_ACTIF;
for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ )
{ {
...@@ -363,12 +356,10 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net, ...@@ -363,12 +356,10 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net,
/** /**
* Function used by TestRatsNest_general * Function used by TestRatsNest_general
* The general ratsnest list must exists * The general ratsnest list must exists because this function explore this ratsnest
* Activates the ratsnest between 2 pads ( assumes the same net ) * Activates (set the CH_ACTIF flag) the ratsnest links between 2 pads when needed
* The function links 1 pad not already connected an other pad and activate * The function links 1 pad not already connected to an other pad (SubRatsnest = 0)
* some blocks linked by a ratsnest * and active the correspondint link
* It tests only the existing ratsnest and activate some ratsnest (status bit
* CH_ACTIF set)
* *
* @param start_rat_list = starting address for the ratsnest list * @param start_rat_list = starting address for the ratsnest list
* @param end_rat_list = ending address for the ratsnest list * @param end_rat_list = ending address for the ratsnest list
...@@ -419,7 +410,23 @@ static int tst_rats_pad_to_pad( int current_num_block, ...@@ -419,7 +410,23 @@ static int tst_rats_pad_to_pad( int current_num_block,
return current_num_block; return current_num_block;
} }
/* function TestRatsNest
* determine the active links inside the full ratsnest
*
* I used an derived from the "lee algorithm".
* The algorithm explore the existing full ratnest
* This is a 2 steps algorithm (executed for each net).
* - First:
* Initialise for each pad the subratsnest id to its subnet value
* explore the full ratnest (relative to the net) and active a link each time at least one pad of
* the given link is not connected to an other pad by a track ( subratsnest = 0)
* If the 2 pads linked have both the subratsnest id = 0, a new subratsnest value is created
* - Second:
* explore the full ratnest (relative to the net) and find a link that links
* 2 pads having different subratsnest values
* Active the link and merge the 2 subratsnest value.
*
*/
void PCB_BASE_FRAME::TestRatsNest( wxDC* aDC, int aNetCode ) void PCB_BASE_FRAME::TestRatsNest( wxDC* aDC, int aNetCode )
{ {
RATSNEST_ITEM* rats; RATSNEST_ITEM* rats;
...@@ -492,6 +499,11 @@ int PCB_BASE_FRAME::TestOneRatsNest( wxDC* aDC, int aNetCode ) ...@@ -492,6 +499,11 @@ int PCB_BASE_FRAME::TestOneRatsNest( wxDC* aDC, int aNetCode )
void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
{ {
// for local ratsnest calculation when moving a footprint:
// list of pads to use for this local ratsnets:
// this is the list of connected pads of the current module,
// and all pads connected to these pads:
static std::vector <D_PAD*> localPadList;
static unsigned pads_module_count; // node count (node = pad with a net static unsigned pads_module_count; // node count (node = pad with a net
// code) for the footprint being moved // code) for the footprint being moved
static unsigned internalRatsCount; // number of internal links (links static unsigned internalRatsCount; // number of internal links (links
...@@ -514,121 +526,115 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -514,121 +526,115 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
* footprints which are "connected" to * footprints which are "connected" to
* a pad in the current footprint * a pad in the current footprint
*/ */
if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) != 0 ) if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 )
goto CalculateExternalRatsnest;
/* Compute the "internal" ratsnest, i.e the links between the current
* footprint pads
*/
s_localPadBuffer.clear();
m_Pcb->m_LocalRatsnest.clear();
for( pad_ref = aModule->m_Pads; pad_ref != NULL; pad_ref = pad_ref->Next() )
{ {
if( pad_ref->GetNet() == 0 ) /* Compute the "internal" ratsnest, i.e the links between the current
continue; * footprint pads
*/
localPadList.clear();
m_Pcb->m_LocalRatsnest.clear();
s_localPadBuffer.push_back( pad_ref ); // collect active pads of the module:
pad_ref->SetSubRatsnest( 0 ); for( pad_ref = aModule->m_Pads; pad_ref != NULL; pad_ref = pad_ref->Next() )
pad_ref->SetSubNet( 0 ); {
} if( pad_ref->GetNet() == 0 )
continue;
pads_module_count = s_localPadBuffer.size(); localPadList.push_back( pad_ref );
pad_ref->SetSubRatsnest( 0 );
pad_ref->SetSubNet( 0 );
}
if( pads_module_count == 0 ) pads_module_count = localPadList.size();
return; /* no connection! */
sort( s_localPadBuffer.begin(), s_localPadBuffer.end(), sortByNetcode ); if( pads_module_count == 0 )
return; /* no connection! */
/* Build the list of pads linked to the current footprint pads */ sort( localPadList.begin(), localPadList.end(), sortByNetcode );
current_net_code = 0;
for( unsigned ii = 0; ii < pads_module_count; ii++ ) /* Build the list of pads linked to the current footprint pads */
{ current_net_code = 0;
pad_ref = s_localPadBuffer[ii];
if( pad_ref->GetNet() == current_net_code ) for( unsigned ii = 0; ii < pads_module_count; ii++ )
continue; {
pad_ref = localPadList[ii];
// A new net was found, load all pads of others modules members of this net: if( pad_ref->GetNet() == current_net_code )
NETINFO_ITEM* net = m_Pcb->FindNet( pad_ref->GetNet() ); continue;
if( net == NULL ) //Should not occur // A new net was found, load all pads of others modules members of this net:
{ NETINFO_ITEM* net = m_Pcb->FindNet( pad_ref->GetNet() );
wxMessageBox( wxT( "build_ratsnest_module() error: net not found" ) );
return;
}
for( unsigned jj = 0; jj < net->m_ListPad.size(); jj++ ) if( net == NULL ) //Should not occur
{ {
pad_externe = net->m_ListPad[jj]; wxMessageBox( wxT( "build_ratsnest_module() error: net not found" ) );
return;
}
if( pad_externe->GetParent() == aModule ) for( unsigned jj = 0; jj < net->m_ListPad.size(); jj++ )
continue; {
pad_externe = net->m_ListPad[jj];
pad_externe->SetSubRatsnest( 0 ); if( pad_externe->GetParent() == aModule )
pad_externe->SetSubNet( 0 ); continue;
s_localPadBuffer.push_back( pad_externe ); pad_externe->SetSubRatsnest( 0 );
} pad_externe->SetSubNet( 0 );
}
/* Sort the pad list by net_code */ localPadList.push_back( pad_externe );
sort( s_localPadBuffer.begin() + pads_module_count, s_localPadBuffer.end(), }
sortByNetcode ); }
/* Compute the internal rats nest: /* Sort the pad list by net_code */
* this is the same as general ratsnest, but considers only the current sort( localPadList.begin() + pads_module_count, localPadList.end(),
* footprint pads it is therefore not time consuming, and it is made only sortByNetcode );
* once
*/
current_net_code = s_localPadBuffer[0]->GetNet();
{ /* Compute the internal rats nest:
MIN_SPAN_TREE_PADS min_spanning_tree; * this is the same as general ratsnest, but considers only the current
std::vector<D_PAD*> padsBuffer; * footprint pads it is therefore not time consuming, and it is made only
for( unsigned ii = 0; ii < pads_module_count; ii++ ) * once
{ */
/* Search the end of pad list relative to the current net */ current_net_code = localPadList[0]->GetNet();
unsigned jj = ii + 1;
for( ; jj <= pads_module_count; jj++ ) MIN_SPAN_TREE_PADS min_spanning_tree;
std::vector<D_PAD*> padsBuffer; // contains pads of only one net
for( unsigned ii = 0; ii < pads_module_count; ii++ )
{ {
if( jj >= pads_module_count ) /* Search the end of pad list relative to the current net */
break; unsigned jj = ii + 1;
if( s_localPadBuffer[jj]->GetNet() != current_net_code ) for( ; jj <= pads_module_count; jj++ )
break; {
} if( jj >= pads_module_count )
break;
for(unsigned kk = ii; kk < jj; kk++ ) if( localPadList[jj]->GetNet() != current_net_code )
padsBuffer.push_back( s_localPadBuffer[kk] ); break;
min_spanning_tree.MSP_Init( &padsBuffer ); }
min_spanning_tree.BuildTree();
min_spanning_tree.AddItemsToRatsnest( m_Pcb->m_LocalRatsnest );
padsBuffer.clear();
ii = jj;
if( ii < s_localPadBuffer.size() )
current_net_code = s_localPadBuffer[ii]->GetNet();
}
}
internalRatsCount = m_Pcb->m_LocalRatsnest.size(); for(unsigned kk = ii; kk < jj; kk++ )
padsBuffer.push_back( localPadList[kk] );
min_spanning_tree.MSP_Init( &padsBuffer );
min_spanning_tree.BuildTree();
min_spanning_tree.AddItemsToRatsnest( m_Pcb->m_LocalRatsnest );
padsBuffer.clear();
ii = jj;
if( ii < localPadList.size() )
current_net_code = localPadList[ii]->GetNet();
}
internalRatsCount = m_Pcb->m_LocalRatsnest.size();
/* set the ratsnest status, flag LOCAL_RATSNEST_ITEM */ // set the flag LOCAL_RATSNEST_ITEM of the ratsnest status:
for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ ) for( unsigned ii = 0; ii < m_Pcb->m_LocalRatsnest.size(); ii++ )
{ m_Pcb->m_LocalRatsnest[ii].m_Status = LOCAL_RATSNEST_ITEM;
m_Pcb->m_LocalRatsnest[ii].m_Status = LOCAL_RATSNEST_ITEM;
}
m_Pcb->m_Status_Pcb |= RATSNEST_ITEM_LOCAL_OK; m_Pcb->m_Status_Pcb |= RATSNEST_ITEM_LOCAL_OK;
} // End of internal ratsnest build
/* This section computes the "external" ratsnest: must be done when the /* This section computes the "external" ratsnest: it is done when the
* footprint position changes * footprint position changes
*/ *
CalculateExternalRatsnest: * This section search:
/* This section search:
* for each current module pad the nearest neighbor external pad (of * for each current module pad the nearest neighbor external pad (of
* course for the same net code). * course for the same net code).
* For each current footprint cluster of pad (pads having the same net * For each current footprint cluster of pad (pads having the same net
...@@ -637,19 +643,20 @@ CalculateExternalRatsnest: ...@@ -637,19 +643,20 @@ CalculateExternalRatsnest:
* so, for each net, only one rats nest item is created * so, for each net, only one rats nest item is created
*/ */
RATSNEST_ITEM local_rats; RATSNEST_ITEM local_rats;
local_rats.m_Lenght = 0x7FFFFFFF; local_rats.m_Lenght = INT_MAX;
local_rats.m_Status = 0; local_rats.m_Status = 0;
bool addRats = false; bool addRats = false;
// Erase external ratsnest items:
if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() ) if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() )
m_Pcb->m_LocalRatsnest.erase( m_Pcb->m_LocalRatsnest.begin() + internalRatsCount, m_Pcb->m_LocalRatsnest.erase( m_Pcb->m_LocalRatsnest.begin() + internalRatsCount,
m_Pcb->m_LocalRatsnest.end() ); m_Pcb->m_LocalRatsnest.end() );
current_net_code = s_localPadBuffer[0]->GetNet(); current_net_code = localPadList[0]->GetNet();
for( unsigned ii = 0; ii < pads_module_count; ii++ ) for( unsigned ii = 0; ii < pads_module_count; ii++ )
{ {
pad_ref = s_localPadBuffer[ii]; pad_ref = localPadList[ii];
if( pad_ref->GetNet() != current_net_code ) if( pad_ref->GetNet() != current_net_code )
{ {
...@@ -661,15 +668,15 @@ CalculateExternalRatsnest: ...@@ -661,15 +668,15 @@ CalculateExternalRatsnest:
addRats = false; addRats = false;
current_net_code = pad_ref->GetNet(); current_net_code = pad_ref->GetNet();
local_rats.m_Lenght = 0x7FFFFFFF; local_rats.m_Lenght = INT_MAX;
} }
pad_pos = pad_ref->m_Pos - g_Offset_Module; pad_pos = pad_ref->m_Pos - g_Offset_Module;
// Search the nearest external pad of this current pad // Search the nearest external pad of this current pad
for( unsigned jj = pads_module_count; jj < s_localPadBuffer.size(); jj++ ) for( unsigned jj = pads_module_count; jj < localPadList.size(); jj++ )
{ {
pad_externe = s_localPadBuffer[jj]; pad_externe = localPadList[jj];
/* we search pads having the same net code */ /* we search pads having the same net code */
if( pad_externe->GetNet() < pad_ref->GetNet() ) if( pad_externe->GetNet() < pad_ref->GetNet() )
......
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