Fix Pcbnew Python: LoadBoard does not rebuild connectivity database, and later, SaveBoard does not save net class memberships

Fixes: lp:1711268
https://bugs.launchpad.net/kicad/+bug/1711268
This commit is contained in:
jean-pierre charras 2017-08-17 17:55:05 +02:00
parent 352919658d
commit 4d0c1577d2
5 changed files with 26 additions and 9 deletions

View File

@ -123,6 +123,12 @@ BOARD::~BOARD()
}
void BOARD::BuildConnectivity()
{
GetConnectivity()->Build( this );
}
const wxPoint& BOARD::GetPosition() const
{
wxLogWarning( wxT( "This should not be called on the BOARD object") );

View File

@ -292,6 +292,14 @@ public:
return m_connectivity;
}
/**
* Builds or rebuilds the board connectivity database for the board,
* especially the list of connected items, list of nets and rastnest data
* Needed after loading a board to have the connectivity database updated.
*/
void BuildConnectivity();
/**
* Function DeleteMARKERs
* deletes ALL MARKERS from the board.

View File

@ -579,11 +579,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetCurrentNetClass( NETCLASS::Default );
// Rebuild list of nets (full ratsnest rebuild)
{
wxBusyCursor dummy; // Displays an Hourglass while building connectivity
Compile_Ratsnest( NULL, true );
GetBoard()->GetConnectivity()->Build( GetBoard() );
}
GetBoard()->BuildConnectivity();
// Update info shown by the horizontal toolbars
ReFillLayerWidget();

View File

@ -11,4 +11,4 @@ for module in pcb.GetModules():
module.Value().SetVisible(False) # set Value as Hidden
module.Reference().SetVisible(True) # set Reference as Visible
pcb.Save("mod_"+filename)
SaveBoard("mod_"+filename, pcb)

View File

@ -72,12 +72,18 @@ BOARD* LoadBoard( wxString& aFileName )
BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
{
return IO_MGR::Load( aFormat, aFileName );
BOARD* brd = IO_MGR::Load( aFormat, aFileName );
if( brd )
brd->BuildConnectivity();
return brd;
}
bool SaveBoard( wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat )
{
aBoard->BuildConnectivity();
aBoard->SynchronizeNetsAndNetClasses();
aBoard->GetDesignSettings().SetCurrentNetClass( NETCLASS::Default );