Remove BuildNetListBase from netlisting paths

This commit is contained in:
Jon Evans 2020-05-23 13:14:05 -04:00
parent ca41dc2e66
commit a63df2fbf0
8 changed files with 39 additions and 71 deletions

View File

@ -399,7 +399,7 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( payload.find( "no-annotate" ) == std::string::npos )
{
// Ensure schematic is OK for netlist creation (especially that it is fully annotated):
if( !prepareForNetlist() )
if( !ReadyToNetlist() )
return;
}

View File

@ -474,10 +474,8 @@ void DIALOG_BOM::OnRunGenerator( wxCommandEvent& event )
m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
#endif
auto netlist = m_parent->CreateNetlist( false, false );
m_parent->WriteNetListFile( netlist, -1,
fullfilename, 0, &reporter );
if( m_parent->ReadyToNetlist( false, false ) )
m_parent->WriteNetListFile( -1, fullfilename, 0, &reporter );
m_Messages->SetValue( reportmsg );

View File

@ -498,12 +498,10 @@ bool NETLIST_DIALOG::TransferDataFromWindow()
else
m_Parent->SetNetListerCommand( wxEmptyString );
auto netlist = m_Parent->CreateNetlist( false, false );
if( netlist == nullptr )
wxMessageBox( _( "Schematic netlist not available" ) );
if( m_Parent->ReadyToNetlist( false, false ) )
m_Parent->WriteNetListFile( currPage->m_IdNetType, fullpath, netlist_opt, nullptr );
else
m_Parent->WriteNetListFile( netlist, currPage->m_IdNetType, fullpath, netlist_opt, NULL );
wxMessageBox( _( "Schematic netlist not available" ) );
WriteCurrentNetlistSetup();

View File

@ -518,8 +518,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
if( m_generateNetlistAndExit )
{
wxLogDebug( wxT( "Writing netlist to %s and exiting..." ), m_netlistFilename );
NETLIST_OBJECT_LIST* netlist = CreateNetlist( false, false );
WriteNetListFile( netlist, NET_TYPE_PCBNEW, m_netlistFilename, 0, nullptr );
WriteNetListFile( NET_TYPE_PCBNEW, m_netlistFilename, 0, nullptr );
Close( false );
}

View File

@ -23,11 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/netform.cpp
* @brief Net list generation code.
*/
#include <fctsys.h>
#include <kicad_string.h>
#include <gestfich.h>
@ -46,13 +41,14 @@
#include <netlist_exporter_kicad.h>
#include <netlist_exporter_generic.h>
#include <invoke_sch_dialog.h>
bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST* aConnectedItemsList,
int aFormat, const wxString& aFullFileName,
bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileName,
unsigned aNetlistOptions, REPORTER* aReporter )
{
if( aConnectedItemsList == nullptr ) // Schematic netlist not available.
// Ensure all power symbols have a valid reference
Schematic().GetSheets().AnnotatePowerSymbols();
if( !ReadyToNetlist( false ) )
return false;
bool res = true;
@ -163,25 +159,37 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST* aConnectedItemsList,
int TestDuplicateSheetNames( SCHEMATIC* aSchematic, bool aCreateMarker );
bool SCH_EDIT_FRAME::prepareForNetlist()
bool SCH_EDIT_FRAME::ReadyToNetlist( bool aSilent, bool aSilentAnnotate )
{
// Ensure all power symbols have a valid reference
Schematic().GetSheets().AnnotatePowerSymbols();
// Performs some controls:
if( CheckAnnotate( NULL_REPORTER::GetInstance(), 0 ) )
// Components must be annotated
if( CheckAnnotate( NULL_REPORTER::GetInstance(), false ) )
{
// Schematic must be annotated: call Annotate dialog and tell the user why.
ModalAnnotate( _( "Exporting the netlist requires a completely annotated schematic." ) );
if( CheckAnnotate( NULL_REPORTER::GetInstance(), 0 ) )
if( aSilentAnnotate )
{
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
NULL_REPORTER::GetInstance() );
}
else
{
if( aSilent )
return false;
// Schematic must be annotated: call Annotate dialog and tell the user why.
ModalAnnotate(
_( "Exporting the netlist requires a completely annotated schematic." ) );
if( CheckAnnotate( NULL_REPORTER::GetInstance(), false ) )
return false;
}
}
// Test duplicate sheet names:
if( TestDuplicateSheetNames( &Schematic(), false ) > 0 )
{
if( !IsOK( this, _( "Error: duplicate sheet names. Continue?" ) ) )
if( aSilent || !IsOK( this, _( "Error: duplicate sheet names. Continue?" ) ) )
return false;
}
@ -202,30 +210,6 @@ void SCH_EDIT_FRAME::sendNetlistToCvpcb()
}
NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::CreateNetlist( bool aSilent,
bool aSilentAnnotate )
{
if( !aSilent ) // checks for errors and invokes annotation dialog as necessary
{
if( !prepareForNetlist() )
return nullptr;
}
else // performs similar function as prepareForNetlist but without a dialog.
{
Schematic().GetSheets().AnnotatePowerSymbols();
if( aSilentAnnotate )
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
NULL_REPORTER::GetInstance() );
}
// TODO(JE) This is really going to turn into "PrepareForNetlist"
// when the old netlister (BuildNetListBase) is removed
return BuildNetListBase();
}
NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase( bool updateStatusText )
{
// Ensure netlist is up to date

View File

@ -839,7 +839,7 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
fn.SetExt( NetlistFileExtension );
if( !prepareForNetlist() )
if( !ReadyToNetlist() )
return;
try

View File

@ -167,14 +167,6 @@ protected:
*/
bool isAutoSaveRequired() const override;
/**
* Verify that annotation is complete so that a proper netlist is even
* possible. If not, asks the user if annotation should be done.
*
* @return bool - true if annotation is complete, else false.
*/
bool prepareForNetlist();
/**
* Send the kicad netlist over to CVPCB.
*/
@ -400,6 +392,7 @@ public:
/**
* Create a flat list which stores all connected objects.
* TODO(JE) Remove this once ERC is moved off of it
*
* @param updateStatusText decides if window StatusText should be modified.
* @return NETLIST_OBJECT_LIST* - caller owns the object.
@ -407,23 +400,19 @@ public:
NETLIST_OBJECT_LIST* BuildNetListBase( bool updateStatusText = true );
/**
* Create a netlist for the current schematic.
* Checks if we are ready to write a netlist file for the current schematic
*
* - Test for some issues (missing or duplicate references and sheet names)
* - Build netlist info
* - Create the netlist file (different formats)
*
* @param aSilent is true if annotation error dialog should be skipped
* @param aSilentAnnotate is true if components should be reannotated silently
* @returns a unique_ptr to the netlist
* @returns true if all is well (i.e. you can call WriteNetListFile next)
*/
NETLIST_OBJECT_LIST* CreateNetlist( bool aSilent = false,
bool aSilentAnnotate = false );
bool ReadyToNetlist( bool aSilent = false, bool aSilentAnnotate = false );
/**
* Create a netlist file.
*
* @param aConnectedItemsList = the initialized list of connected items, take ownership.
* @param aFormat = netlist format (NET_TYPE_PCBNEW ...)
* @param aFullFileName = full netlist file name
* @param aNetlistOptions = netlist options using OR'ed bits.
@ -437,8 +426,7 @@ public:
* mainly if a command line must be run (can be NULL
* @return true if success.
*/
bool WriteNetListFile( NETLIST_OBJECT_LIST* aConnectedItemsList,
int aFormat,
bool WriteNetListFile( int aFormat,
const wxString& aFullFileName,
unsigned aNetlistOptions,
REPORTER* aReporter = NULL );

View File

@ -638,6 +638,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
if( item->IsType( wires ) )
{
// TODO(JE) Port to connection graph
std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
for( NETLIST_OBJECT* obj : *netlist )