Pcbnew: read netlist enhancements: add option to remove single pads nets, add enforce tests to report non existing netnames in zones.

Fix also some very minor errors in comments.
This commit is contained in:
jean-pierre charras 2013-08-24 10:08:55 +02:00
parent 3d40bd7e16
commit 8cca89ffbe
10 changed files with 189 additions and 6 deletions

View File

@ -1451,6 +1451,8 @@ public:
* @param aSelectByTimestamp if true, use timestamp instead of reference to identify
* footprints from components (use after reannotation of the
* schematic)
* @param aDeleteSinglePadNets if true, remove nets counting only one pad
* and set net code to 0 for these pads
* @param aIsDryRun performs a dry run without making any changes if true.
*/
void ReadPcbNetlist( const wxString& aNetlistFileName,
@ -1460,6 +1462,7 @@ public:
bool aDeleteBadTracks,
bool aDeleteExtraFootprints,
bool aSelectByTimestamp,
bool aDeleteSinglePadNets,
bool aIsDryRun );
/**

View File

@ -41,6 +41,7 @@
#include <msgpanel.h>
#include <netlist_reader.h>
#include <reporter.h>
#include <base_units.h>
#include <pcbnew.h>
#include <colors_selection.h>
@ -2332,7 +2333,8 @@ bool BOARD::NormalizeAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList, ZONE_CONTAI
}
void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
REPORTER* aReporter )
{
unsigned i;
wxPoint bestPosition;
@ -2603,7 +2605,53 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
}
}
// Last step: verify all pads found in netlist:
// If needed, remove the single pad nets:
if( aDeleteSinglePadNets && !aNetlist.IsDryRun() )
{
BuildListOfNets();
std::vector<D_PAD*> padlist = GetPads();
// padlist is the list of pads, sorted by netname.
int count = 0;
wxString netname;
D_PAD * pad = NULL;
D_PAD * previouspad = NULL;
for( unsigned ii = 0; ii < padlist.size(); ii++ )
{
pad = padlist[ii];
if( pad->GetNetname().IsEmpty() )
continue;
if( netname != pad->GetNetname() ) // End of net
{
if( previouspad && count == 1 )
{
if( aReporter && aReporter->ReportAll() )
{
msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad <%s>\n" ),
GetChars( pad->GetNetname() ),
GetChars( pad->GetParent()->GetReference() ),
GetChars( previouspad->GetPadName() ) );
aReporter->Report( msg );
}
previouspad->SetNetname( wxEmptyString );
}
netname = pad->GetNetname();
count = 1;
}
else
count++;
previouspad = pad;
}
// Examine last pad
if( pad && count == 1 )
pad->SetNetname( wxEmptyString );
}
// Last step: Some tests:
// verify all pads found in netlist:
// They should exist in footprints, otherwise the footprint is wrong
// note also references or time stamps are updated, so we use only
// the reference to find a footprint
@ -2636,5 +2684,30 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
}
}
}
// Verify zone net names validity:
// After schematic changes, a zone can have a non existing net name.
// It should be reported
if( aReporter && aReporter->ReportErrors() )
{
//Loop through all copper zones
for( i = 0; i < m_ZoneDescriptorList.size(); i++ )
{
ZONE_CONTAINER* zone = m_ZoneDescriptorList[i];
if( zone->GetNet() >= 0 || !zone->IsOnCopperLayer() )
continue;
// Net name not valid, report error
wxString coord;
coord << zone->GetPosition();
msg.Printf( _( "** Error: Zone %s layer <%s>"
" has non-existent net name \"%s\" **\n" ),
GetChars( coord ),
GetChars( zone->GetLayerName() ),
GetChars( zone->GetNetName() ) );
aReporter->Report( msg );
}
}
}

View File

@ -927,10 +927,13 @@ public:
* any extra unlock footprints are removed from the #BOARD.
*
* @param aNetlist is the new netlist to revise the contents of the #BOARD with.
* @param aDeleteSinglePadNets if true, remove nets counting only one pad
* and set net code to 0 for these pads
* @param aReporter is a #REPORTER object to report the changes \a aNetlist makes to
* the #BOARD. If NULL, no change reporting occurs.
*/
void ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter = NULL );
void ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
REPORTER* aReporter = NULL );
/**
* Function ReturnSortedNetnamesList

View File

@ -197,7 +197,7 @@ private:
void clear();
/**
* Function BuildListOfNets
* Function buildListOfNets
* builds or rebuilds the list of NETINFO_ITEMs
* The list is sorted by names.
*/

View File

@ -72,7 +72,7 @@ static bool padlistSortByNetnames( const D_PAD* a, const D_PAD* b )
* Be aware NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname )
* when search a net by its net name does a binary search
* and expects to have a nets list sorted by an alphabetic case sensitive sort
* So do not change Build_Pads_Full_List() taht build a sorted list of pads
* So do not change Build_Pads_Full_List() which build a sorted list of pads
*/
void NETINFO_LIST::buildListOfNets()
{

View File

@ -47,6 +47,7 @@
#define NETLIST_SILENTMODE_KEY wxT("SilentMode")
#define NETLIST_FULLMESSAGES_KEY wxT("NetlistReportAllMsg")
#define NETLIST_DELETESINGLEPADNETS_KEY wxT("NetlistDeleteSinglePadNets")
void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
{
@ -97,6 +98,8 @@ DIALOG_NETLIST::DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC * aDC,
m_config = wxGetApp().GetSettings();
m_silentMode = m_config->Read( NETLIST_SILENTMODE_KEY, 0l );
m_reportAll = m_config->Read( NETLIST_FULLMESSAGES_KEY, 1l );
bool tmp = m_config->Read( NETLIST_DELETESINGLEPADNETS_KEY, 0l );
m_rbSingleNets->SetSelection( tmp == 0 ? 0 : 1);
m_NetlistFilenameCtrl->SetValue( aNetlistFullFilename );
m_cmpNameSourceOpt->SetSelection( m_parent->GetUseCmpFileForFpNames() ? 1 : 0 );
m_checkBoxSilentMode->SetValue( m_silentMode );
@ -109,6 +112,8 @@ DIALOG_NETLIST::~DIALOG_NETLIST()
{
m_config->Write( NETLIST_SILENTMODE_KEY, (long) m_silentMode );
m_config->Write( NETLIST_FULLMESSAGES_KEY, (long) m_reportAll );
m_config->Write( NETLIST_DELETESINGLEPADNETS_KEY,
(long) m_rbSingleNets->GetSelection() );
}
void DIALOG_NETLIST::OnOpenNetlistClick( wxCommandEvent& event )
@ -187,6 +192,7 @@ void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )
m_DeleteBadTracks->GetSelection() == 1,
m_RemoveExtraFootprintsCtrl->GetSelection() == 1,
m_Select_By_Timestamp->GetSelection() == 1,
m_rbSingleNets->GetSelection() == 1,
m_checkDryRun->GetValue() );
}

View File

@ -74,6 +74,12 @@ DIALOG_NETLIST_FBP::DIALOG_NETLIST_FBP( wxWindow* parent, wxWindowID id, const w
bTracksSizer->Add( m_RemoveExtraFootprintsCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxString m_rbSingleNetsChoices[] = { _("Keep"), _("Delete") };
int m_rbSingleNetsNChoices = sizeof( m_rbSingleNetsChoices ) / sizeof( wxString );
m_rbSingleNets = new wxRadioBox( this, wxID_ANY, _("Single Pad Nets"), wxDefaultPosition, wxDefaultSize, m_rbSingleNetsNChoices, m_rbSingleNetsChoices, 1, wxRA_SPECIFY_COLS );
m_rbSingleNets->SetSelection( 0 );
bTracksSizer->Add( m_rbSingleNets, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bnetlistOptSizer->Add( bTracksSizer, 1, wxEXPAND, 5 );

View File

@ -588,6 +588,96 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Keep&quot; &quot;Delete&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Single Pad Nets</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_rbSingleNets</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRadioBox"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>

View File

@ -51,6 +51,7 @@ class DIALOG_NETLIST_FBP : public DIALOG_SHIM
wxRadioBox* m_ChangeExistingFootprintCtrl;
wxRadioBox* m_DeleteBadTracks;
wxRadioBox* m_RemoveExtraFootprintsCtrl;
wxRadioBox* m_rbSingleNets;
wxButton* m_buttonRead;
wxButton* m_buttonClose;
wxButton* m_buttonFPTest;

View File

@ -50,6 +50,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
bool aDeleteUnconnectedTracks,
bool aDeleteExtraFootprints,
bool aSelectByTimeStamp,
bool aDeleteSinglePadNets,
bool aIsDryRun )
{
wxString msg;
@ -90,7 +91,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
GetScreen()->ClearUndoRedoList();
netlist.SortByReference();
GetBoard()->ReplaceNetlist( netlist, aReporter );
GetBoard()->ReplaceNetlist( netlist, aDeleteSinglePadNets, aReporter );
// If it was a dry run, nothing has changed so we're done.
if( netlist.IsDryRun() )