Pcbnew: Fix typo in 2 filenames. Add comments in ratsnest.cpp.
Fix bug 887202.
This commit is contained in:
parent
936d831b82
commit
7c17187052
|
@ -689,7 +689,7 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( struct EDA_HOTKEY_CONFIG* aDesc
|
|||
mask,
|
||||
this,
|
||||
wxFD_OPEN,
|
||||
TRUE );
|
||||
true );
|
||||
|
||||
if( filename.IsEmpty() )
|
||||
return;
|
||||
|
@ -710,14 +710,14 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( struct EDA_HOTKEY_CONFIG* aDescLi
|
|||
wxString path = wxGetCwd();
|
||||
wxString filename;
|
||||
|
||||
filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
|
||||
filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
|
||||
path,
|
||||
filename,
|
||||
ext,
|
||||
mask,
|
||||
this,
|
||||
wxFD_OPEN,
|
||||
TRUE );
|
||||
wxFD_OPEN | wxFD_SAVE,
|
||||
true );
|
||||
|
||||
if( filename.IsEmpty() )
|
||||
return;
|
||||
|
|
|
@ -132,7 +132,7 @@ set(PCBNEW_SRCS
|
|||
magnetic_tracks_functions.cpp
|
||||
menubar_modedit.cpp
|
||||
menubar_pcbframe.cpp
|
||||
minumun_spanning_tree.cpp
|
||||
minimun_spanning_tree.cpp
|
||||
mirepcb.cpp
|
||||
modedit.cpp
|
||||
modedit_onclick.cpp
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file minumun_spanning_tree.cpp
|
||||
* @file minimun_spanning_tree.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <limits.h>
|
||||
|
||||
#include "minumun_spanning_tree.h"
|
||||
#include "minimun_spanning_tree.h"
|
||||
#include "class_pad.h"
|
||||
|
||||
/*
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file minumun_spanning_tree.h
|
||||
* @file minimun_spanning_tree.h
|
||||
*/
|
||||
|
||||
#include <vector>
|
|
@ -17,12 +17,7 @@
|
|||
|
||||
#include "pcbnew.h"
|
||||
|
||||
#include "minumun_spanning_tree.h"
|
||||
|
||||
static std::vector <D_PAD*> s_localPadBuffer; // for local ratsnest
|
||||
// calculations when moving a
|
||||
// footprint: buffer of pads to
|
||||
// consider
|
||||
#include "minimun_spanning_tree.h"
|
||||
|
||||
/**
|
||||
* @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 )
|
|||
|
||||
/**
|
||||
* Function to compute the full ratsnest
|
||||
* In the functions tracks are not considered
|
||||
* This is only the "basic" ratsnest depending only on pads.
|
||||
* This is the "basic" ratsnest depending only on pads.
|
||||
*
|
||||
* Create the sorted pad list (if necessary)
|
||||
* 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 )
|
|||
* Update :
|
||||
* nb_nodes = Active pads count for the board
|
||||
* 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()
|
||||
{
|
||||
|
@ -265,10 +258,10 @@ void PCB_BASE_FRAME::Build_Board_Ratsnest()
|
|||
|
||||
|
||||
/**
|
||||
* function Displays the general ratsnest
|
||||
* Only ratsnest with the status bit CH_VISIBLE is set are displayed
|
||||
* function DrawGeneralRatsnest
|
||||
* Only ratsnest items with the status bit CH_VISIBLE set are displayed
|
||||
* @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
|
||||
*/
|
||||
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 )
|
||||
return;
|
||||
|
||||
int state = CH_VISIBLE | CH_ACTIF;
|
||||
const int state = CH_VISIBLE | CH_ACTIF;
|
||||
|
||||
for( unsigned ii = 0; ii < m_Pcb->GetRatsnestsCount(); ii++ )
|
||||
{
|
||||
|
@ -363,12 +356,10 @@ static int tst_rats_block_to_block( NETINFO_ITEM* net,
|
|||
|
||||
/**
|
||||
* Function used by TestRatsNest_general
|
||||
* The general ratsnest list must exists
|
||||
* Activates the ratsnest between 2 pads ( assumes the same net )
|
||||
* The function links 1 pad not already connected an other pad and activate
|
||||
* some blocks linked by a ratsnest
|
||||
* It tests only the existing ratsnest and activate some ratsnest (status bit
|
||||
* CH_ACTIF set)
|
||||
* The general ratsnest list must exists because this function explore this ratsnest
|
||||
* Activates (set the CH_ACTIF flag) the ratsnest links between 2 pads when needed
|
||||
* The function links 1 pad not already connected to an other pad (SubRatsnest = 0)
|
||||
* and active the correspondint link
|
||||
*
|
||||
* @param start_rat_list = starting 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,
|
|||
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 )
|
||||
{
|
||||
RATSNEST_ITEM* rats;
|
||||
|
@ -492,6 +499,11 @@ int PCB_BASE_FRAME::TestOneRatsNest( wxDC* aDC, int aNetCode )
|
|||
|
||||
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
|
||||
// code) for the footprint being moved
|
||||
static unsigned internalRatsCount; // number of internal links (links
|
||||
|
@ -514,38 +526,38 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
|
|||
* footprints which are "connected" to
|
||||
* a pad in the current footprint
|
||||
*/
|
||||
if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) != 0 )
|
||||
goto CalculateExternalRatsnest;
|
||||
|
||||
if( (m_Pcb->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 )
|
||||
{
|
||||
/* Compute the "internal" ratsnest, i.e the links between the current
|
||||
* footprint pads
|
||||
*/
|
||||
s_localPadBuffer.clear();
|
||||
localPadList.clear();
|
||||
m_Pcb->m_LocalRatsnest.clear();
|
||||
|
||||
// collect active pads of the module:
|
||||
for( pad_ref = aModule->m_Pads; pad_ref != NULL; pad_ref = pad_ref->Next() )
|
||||
{
|
||||
if( pad_ref->GetNet() == 0 )
|
||||
continue;
|
||||
|
||||
s_localPadBuffer.push_back( pad_ref );
|
||||
localPadList.push_back( pad_ref );
|
||||
pad_ref->SetSubRatsnest( 0 );
|
||||
pad_ref->SetSubNet( 0 );
|
||||
}
|
||||
|
||||
pads_module_count = s_localPadBuffer.size();
|
||||
pads_module_count = localPadList.size();
|
||||
|
||||
if( pads_module_count == 0 )
|
||||
return; /* no connection! */
|
||||
|
||||
sort( s_localPadBuffer.begin(), s_localPadBuffer.end(), sortByNetcode );
|
||||
sort( localPadList.begin(), localPadList.end(), sortByNetcode );
|
||||
|
||||
/* Build the list of pads linked to the current footprint pads */
|
||||
current_net_code = 0;
|
||||
|
||||
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 )
|
||||
continue;
|
||||
|
@ -569,12 +581,12 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
|
|||
pad_externe->SetSubRatsnest( 0 );
|
||||
pad_externe->SetSubNet( 0 );
|
||||
|
||||
s_localPadBuffer.push_back( pad_externe );
|
||||
localPadList.push_back( pad_externe );
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the pad list by net_code */
|
||||
sort( s_localPadBuffer.begin() + pads_module_count, s_localPadBuffer.end(),
|
||||
sort( localPadList.begin() + pads_module_count, localPadList.end(),
|
||||
sortByNetcode );
|
||||
|
||||
/* Compute the internal rats nest:
|
||||
|
@ -582,11 +594,10 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
|
|||
* footprint pads it is therefore not time consuming, and it is made only
|
||||
* once
|
||||
*/
|
||||
current_net_code = s_localPadBuffer[0]->GetNet();
|
||||
current_net_code = localPadList[0]->GetNet();
|
||||
|
||||
{
|
||||
MIN_SPAN_TREE_PADS min_spanning_tree;
|
||||
std::vector<D_PAD*> padsBuffer;
|
||||
std::vector<D_PAD*> padsBuffer; // contains pads of only one net
|
||||
for( unsigned ii = 0; ii < pads_module_count; ii++ )
|
||||
{
|
||||
/* Search the end of pad list relative to the current net */
|
||||
|
@ -597,38 +608,33 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
|
|||
if( jj >= pads_module_count )
|
||||
break;
|
||||
|
||||
if( s_localPadBuffer[jj]->GetNet() != current_net_code )
|
||||
if( localPadList[jj]->GetNet() != current_net_code )
|
||||
break;
|
||||
}
|
||||
|
||||
for(unsigned kk = ii; kk < jj; kk++ )
|
||||
padsBuffer.push_back( s_localPadBuffer[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 < s_localPadBuffer.size() )
|
||||
current_net_code = s_localPadBuffer[ii]->GetNet();
|
||||
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++ )
|
||||
{
|
||||
m_Pcb->m_LocalRatsnest[ii].m_Status = LOCAL_RATSNEST_ITEM;
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
CalculateExternalRatsnest:
|
||||
|
||||
/* This section search:
|
||||
*
|
||||
* This section search:
|
||||
* for each current module pad the nearest neighbor external pad (of
|
||||
* course for the same net code).
|
||||
* For each current footprint cluster of pad (pads having the same net
|
||||
|
@ -637,19 +643,20 @@ CalculateExternalRatsnest:
|
|||
* so, for each net, only one rats nest item is created
|
||||
*/
|
||||
RATSNEST_ITEM local_rats;
|
||||
local_rats.m_Lenght = 0x7FFFFFFF;
|
||||
local_rats.m_Lenght = INT_MAX;
|
||||
local_rats.m_Status = 0;
|
||||
bool addRats = false;
|
||||
|
||||
// Erase external ratsnest items:
|
||||
if( internalRatsCount < m_Pcb->m_LocalRatsnest.size() )
|
||||
m_Pcb->m_LocalRatsnest.erase( m_Pcb->m_LocalRatsnest.begin() + internalRatsCount,
|
||||
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++ )
|
||||
{
|
||||
pad_ref = s_localPadBuffer[ii];
|
||||
pad_ref = localPadList[ii];
|
||||
|
||||
if( pad_ref->GetNet() != current_net_code )
|
||||
{
|
||||
|
@ -661,15 +668,15 @@ CalculateExternalRatsnest:
|
|||
|
||||
addRats = false;
|
||||
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;
|
||||
|
||||
// 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 */
|
||||
if( pad_externe->GetNet() < pad_ref->GetNet() )
|
||||
|
|
Loading…
Reference in New Issue