Use KiwayExpress messaging for CvPcb footprint assignment instead of *.cmp file.

* Remove global s_NetObjectslist.
* Separate out non-owning version of NETLIST_OBJECTS_LIST into NETLIST_OBJECTS.
* Fix double free pertaining to ~NETLIST_READER().
* Remove all file-io from CvPCB.
* Remove exe launcher cvpcb, retain only cvpcb.kiface, since cvpcb.kiface has no file i/o.
* Add void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) and teach it to use old
  netlist loading code with a STRING_LINE_READER LINE_READER.
* Fix BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
This commit is contained in:
Dick Hollenbeck 2015-06-07 14:18:45 -04:00 committed by Wayne Stambaugh
parent aadcd93ab5
commit 8fb520249e
38 changed files with 410 additions and 521 deletions

View File

@ -752,7 +752,7 @@ add_subdirectory( qa )
# except perhaps bitmap lib. This allows a multi-threaded build to succeed.
add_dependencies( pcbnew boost )
add_dependencies( eeschema boost )
add_dependencies( cvpcb boost )
add_dependencies( cvpcb_kiface boost )
add_dependencies( gal boost )
add_dependencies( common boost )
add_dependencies( pcbcommon boost )

View File

@ -74,16 +74,15 @@ if( APPLE )
endif()
if( false ) # no CVPCB exe any more, only the *.kiface
add_executable( cvpcb WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${CVPCB_RESOURCES}
)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CVPCB;PGM_DATA_FILE_EXT=\"net\";BUILD_KIWAY_DLL"
)
target_link_libraries( cvpcb
#singletop # replaces common, giving us restrictive control and link warnings.
# There's way too much crap coming in from common yet.
@ -91,12 +90,44 @@ target_link_libraries( cvpcb
bitmaps
${wxWidgets_LIBRARIES}
)
if( MAKE_LINK_MAPS )
set_target_properties( cvpcb PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=cvpcb.map" )
endif()
if( APPLE )
set_target_properties( cvpcb PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/cvpcb.app/Contents/MacOS/cvpcb
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
endif() # no CVPCB exe
# the main cvpcb program, in DSO form.
add_library( cvpcb_kiface MODULE
cvpcb.cpp
@ -143,42 +174,13 @@ if( MAKE_LINK_MAPS )
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_cvpcb.kiface.map" )
endif()
# if building cvpcb, then also build cvpcb_kiface if out of date.
add_dependencies( cvpcb cvpcb_kiface )
# these 2 binaries are a matched set, keep them together:
if( APPLE )
set_target_properties( cvpcb PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
# puts binaries into the *.app bundle while linking
set_target_properties( cvpcb_kiface PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_KIFACE_DIR}
)
# put individual bundle outside of main bundle as a first step
# will be pulled into the main bundle when creating main bundle
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( CODE "
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
include( BundleUtilities )
fixup_bundle( ${KICAD_BIN}/cvpcb.app/Contents/MacOS/cvpcb
\"\"
\"\"
)
" COMPONENT Runtime
)
else()
install( TARGETS cvpcb
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
install( TARGETS cvpcb_kiface
DESTINATION ${KICAD_BIN}
COMPONENT binary

View File

@ -29,6 +29,7 @@
#include <fctsys.h>
#include <build_version.h>
#include <kiway_express.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <macros.h>
@ -58,13 +59,10 @@ static const wxString KeepCvpcbOpenEntry( wxT( "KeepCvpcbOpen" ) );
static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) );
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList )
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
// Menu events
EVT_MENU( ID_LOAD_PROJECT, CVPCB_MAINFRAME::LoadNetList )
EVT_MENU( wxID_SAVE, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( wxID_SAVEAS, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
@ -75,7 +73,7 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
// Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, CVPCB_MAINFRAME::LoadNetList )
EVT_TOOL( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
@ -243,8 +241,6 @@ void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
{
int diag;
if( m_modified )
{
wxString msg = _( "Component to Footprint links modified.\nSave before exit ?" );
@ -260,29 +256,11 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
break;
case wxID_YES:
diag = SaveCmpLinkFile( m_NetlistFileName.GetFullPath() );
if( diag > 0 )
{
m_modified = false;
}
else if( diag == 0 )
{
if( !IsOK( this, _( "Problem when saving file, exit anyway ?" ) ) )
{
Event.Veto();
return;
}
}
SaveEdits();
break;
}
}
if( m_NetlistFileName.IsOk() )
{
UpdateFileHistory( m_NetlistFileName.GetFullPath() );
}
// Close module display frame
if( GetFpViewerFrame() )
GetFpViewerFrame()->Close( true );
@ -370,19 +348,13 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent )
{
wxString fullFilename;
SaveEdits();
if( aEvent.GetId() != wxID_SAVEAS )
fullFilename = m_NetlistFileName.GetFullPath();
if( SaveCmpLinkFile( fullFilename ) > 0 )
{
m_modified = false;
if( !m_KeepCvpcbOpen )
Close( true );
}
}
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
@ -411,6 +383,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
}
/* Remove in favor of Kiway messaging method of sending netlist
void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
{
int id = event.GetId();
@ -437,43 +410,11 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
OpenProjectFiles( std::vector<wxString>( 1, newFileName.GetFullPath() ) );
}
*/
bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
if( aFileSet.size() != 1 ) // Unexpected comand
return false;
m_NetlistFileName = aFileSet[0];
if( Kiface().IsSingle() )
{
// PROJECT::SetProjectFullName() is an impactful function. It should only be
// called under carefully considered circumstances.
// The calling code should know not to ask me here to change projects unless
// it knows what consequences that will have on other KIFACEs running and using
// this same PROJECT. It can be very harmful if that calling code is stupid.
//
// In Cvpcb, we call SetProjectFullName only in Single mode, i.e. it is not
// called from a project
wxFileName pro = m_NetlistFileName;
pro.SetExt( ProjectFileExtension );
Prj().SetProjectFullName( pro.GetFullPath() );
}
ReadNetListAndLinkFiles();
UpdateTitle();
// Resize the components list box. This is needed in case the
// contents have shrunk compared to the previous netlist.
m_compListBox->UpdateWidth();
// OSX need it since some objects are "rebuild" just make aware AUI
// Fixes #1258081
m_auimgr.Update();
return true;
}
@ -753,9 +694,8 @@ void CVPCB_MAINFRAME::UpdateTitle()
if( fn.IsOk() && !prj.GetProjectFullName().IsEmpty() && fn.FileExists() )
{
title += wxString::Format( _("Project: '%s' (netlist: '%s')"),
GetChars( fn.GetFullPath() ),
GetChars( m_NetlistFileName.GetFullName() )
title += wxString::Format( _("Project: '%s'"),
GetChars( fn.GetFullPath() )
);
if( !fn.IsFileWritable() )
@ -792,46 +732,20 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA()
}
int CVPCB_MAINFRAME::ReadSchematicNetlist()
int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
{
NETLIST_READER* netlistReader;
wxString msg;
wxString compFootprintLinkFileName;
wxFileName fn = m_NetlistFileName;
// Ensure the netlist file exists, and wran the user if not:
if( ! wxFileExists( m_NetlistFileName.GetFullPath() ) )
{
msg.Printf( _( "Unable to find netlist file:\n'%s'\n\nPlease, create it" ),
GetChars( m_NetlistFileName.GetFullPath() ) );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
return 1;
}
// Load the footprint association file if it has already been created.
fn.SetExt( ComponentFileExtension );
if( fn.FileExists() && fn.IsFileReadable() )
compFootprintLinkFileName = fn.GetFullPath();
STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
m_netlist.Clear();
try
{
netlistReader = NETLIST_READER::GetNetlistReader( &m_netlist,
m_NetlistFileName.GetFullPath(),
compFootprintLinkFileName );
if( netlistReader != NULL )
{
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
netlistReader->LoadNetlist();
}
else
wxMessageBox( _( "Unknown netlist format." ), wxEmptyString, wxOK | wxICON_ERROR );
netrdr.LoadNetlist();
}
catch( const IO_ERROR& ioe )
{
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxString msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
return 1;
}
@ -851,56 +765,6 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
}
// File header.
static char headerLinkFile[] = "Cmp-Mod V01";
bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
{
COMPONENT* component;
FILE* outputFile;
wxFileName fn( aFullFileName );
wxString title = wxString::Format( wxT( "Cvpcb %s " ), GetChars( GetBuildVersion() ) );
outputFile = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
if( outputFile == NULL )
return false;
int retval = 0;
/*
* The header is:
* Cmp-Mod V01 Created by CvPcb (2012-02-08 BZR 3403)-testing date = 10/02/2012 20:45:59
* and write block per component like:
* BeginCmp
* TimeStamp = /322D3011;
* Reference = BUS1;
* ValeurCmp = BUSPC;
* IdModule = BUS_PC;
* EndCmp
*/
retval |= fprintf( outputFile, "%s", headerLinkFile );
retval |= fprintf( outputFile, " Created by %s", TO_UTF8( title ) );
retval |= fprintf( outputFile, " date = %s\n", TO_UTF8( DateAndTime() ) );
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
retval |= fprintf( outputFile, "\nBeginCmp\n" );
retval |= fprintf( outputFile, "TimeStamp = %s;\n", TO_UTF8( component->GetTimeStamp() ) );
retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component->GetReference() ) );
retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component->GetValue() ) );
retval |= fprintf( outputFile, "IdModule = %s;\n", component->GetFPID().Format().c_str() );
retval |= fprintf( outputFile, "EndCmp\n" );
}
retval |= fprintf( outputFile, "\nEndListe\n" );
fclose( outputFile );
return retval >= 0;
}
void CVPCB_MAINFRAME::CreateScreenCmp()
{
DISPLAY_FOOTPRINTS_FRAME* fpframe = GetFpViewerFrame();
@ -1040,3 +904,24 @@ void CVPCB_MAINFRAME::OnConfigurePaths( wxCommandEvent& aEvent )
{
Pgm().ConfigurePaths( this );
}
void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();
DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
switch( mail.Command() )
{
case MAIL_EESCHEMA_NETLIST:
ReadNetListAndLinkFiles( payload );
/* @todo
Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
*/
break;
default:
; // ignore most
}
}

View File

@ -56,36 +56,6 @@ const wxString EquFileExtension( wxT( "equ" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString EquFilesWildcard( _( "Component/footprint equ files (*.equ)|*.equ" ) );
#if 0 // add this logic to OpenProjectFiles()
/*
* MacOSX: Needed for file association
* http://wiki.wxwidgets.org/WxMac-specific_topics
*/
void PGM_BASE::MacOpenFile( const wxString& aFileName )
{
wxFileName filename = aFileName;
wxString oldPath;
CVPCB_MAINFRAME* frame = (CVPCB_MAINFRAME*) GetTopWindow();
if( !filename.FileExists() )
return;
if( frame->m_NetlistFileName.DirExists() )
oldPath = frame->m_NetlistFileName.GetPath();
// Update the library search path list.
if( Pgm().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
Pgm().GetLibraryPathList().Remove( oldPath );
Pgm().GetLibraryPathList().Insert( filename.GetPath(), 0 );
frame->m_NetlistFileName = filename;
frame->ReadNetListAndLinkFiles();
}
#endif
namespace CV {

View File

@ -65,7 +65,6 @@ public:
LIBRARY_LISTBOX* m_libListBox;
COMPONENTS_LISTBOX* m_compListBox;
wxAuiToolBar* m_mainToolBar;
wxFileName m_NetlistFileName;
wxArrayString m_ModuleLibNames;
wxArrayString m_EquFilesNames;
wxString m_NetlistFileExtension;
@ -88,6 +87,8 @@ public:
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl=0 ); // overload KIWAY_PLAYER
void KiwayMailIn( KIWAY_EXPRESS& aEvent ); // override virtual from KIWAY_PLAYER
/**
* @return a pointer on the Footprint Viewer frame, if exists, or NULL
*/
@ -192,36 +193,21 @@ public:
void CreateScreenCmp();
/**
* Function SaveCmpLinkFile
* Saves the component - footprint link file (.cmp file) to \a aFullFileName.
*
* @param aFullFileName A reference wxString object containing the full
* file name of the netlist or cmp file.
* If aFullFileName is empty, a file name will be asked to the user
* @return 0 if an error occurred saving the link file to \a aFullFileName.
* -1 if canceled
* 1 if OK
* Function SaveEdits
* saves the edits that the user has done by sending them back to eeschema
* via the kiway.
*/
int SaveCmpLinkFile( const wxString& aFullFileName );
/**
* Function WriteComponentLinkFile
* Writes the component footprint link file \a aFullFileName on disk.
*
* @param aFullFileName full filename of .cmp file to write.
* @return true if OK, false if error.
*/
bool WriteComponentLinkFile( const wxString& aFullFileName );
void SaveEdits();
/**
* Function ReadNetList
* reads the netlist (.net) file defined by #m_NetlistFileName.
* and the corresponding cmp to footprint (.cmp) link file
* @param aNetlist is the netlist from eeschema in kicad s-expr format.
*/
bool ReadNetListAndLinkFiles();
bool ReadNetListAndLinkFiles( const std::string& aNetlist );
int ReadSchematicNetlist();
int ReadSchematicNetlist( const std::string& aNetlist );
/**
* Function LoadProjectFile

View File

@ -64,42 +64,9 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
// Menu File:
wxMenu* filesMenu = new wxMenu;
// Open files can be used only outside a project, because opening a netlist
// which is not the project netlist is a non sense.
if( Kiface().IsSingle() )
{
AddMenuItem( filesMenu, ID_LOAD_PROJECT,
_( "&Open Netlist" ), LOAD_FILE_HELP, KiBitmap( open_document_xpm ) );
// Open Recent submenu
static wxMenu* openRecentMenu;
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
Kiface().GetFileHistory().UseMenu( openRecentMenu );
Kiface().GetFileHistory().AddFilesToMenu();
AddMenuItem( filesMenu, openRecentMenu, -1,
_( "Open &Recent" ),
_( "Open recent netlist" ),
KiBitmap( open_project_xpm ) );
// Separator
filesMenu->AppendSeparator();
}
// Save the .cmp file
// Save the footprints back into eeschema
AddMenuItem( filesMenu, wxID_SAVE,
_( "&Save Cmp File\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );
// Save as the .cmp file
AddMenuItem( filesMenu, wxID_SAVEAS,
_( "Save Cmp File &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
_( "&Save Edits\tCtrl+S" ), SAVE_HLP_MSG, KiBitmap( save_xpm ) );
// Separator
filesMenu->AppendSeparator();

View File

@ -156,12 +156,12 @@ static int guessNickname( FP_LIB_TABLE* aTbl, FPID* aFootprintId )
}
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist )
{
wxString msg;
bool hasMissingNicks = false;
ReadSchematicNetlist();
ReadSchematicNetlist( aNetlist );
if( m_compListBox == NULL )
return false;
@ -364,56 +364,17 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
DisplayStatus();
UpdateTitle();
UpdateFileHistory( m_NetlistFileName.GetFullPath() );
return true;
}
int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
{
wxFileName fn;
if( !aFullFileName.IsEmpty() )
{
fn = m_NetlistFileName;
fn.SetExt( ComponentFileExtension );
}
else
{
wxFileDialog dlg( this, _( "Save Component Footprint Link File" ),
Prj().GetProjectPath(),
wxT( "noname" ), ComponentFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return -1;
fn = dlg.GetPath();
if( !fn.HasExt() )
fn.SetExt( ComponentFileExtension );
}
if( !IsWritable( fn.GetFullPath() ) || WriteComponentLinkFile( fn.GetFullPath() ) == 0 )
{
DisplayError( this,
wxString::Format( _( "Unable to create component footprint link file '%s'" ),
fn.GetFullPath() ) );
return 0;
}
wxString msg = wxString::Format( _("File %s saved"), GetChars( fn.GetFullPath() ) );
// Perhaps this replaces all of the above someday.
void CVPCB_MAINFRAME::SaveEdits()
{
STRING_FORMATTER sf;
m_netlist.FormatBackAnnotation( &sf );
Kiway().ExpressMail( FRAME_SCH, MAIL_BACKANNOTATE_FOOTPRINTS, sf.GetString() );
}
SetStatusText( msg );
return 1;
SetStatusText( _("Edits sent to Eeschema") );
}

View File

@ -201,6 +201,7 @@ NETLIST_OBJECT::~NETLIST_OBJECT()
{
}
// return true if the object is a label of any type
bool NETLIST_OBJECT::IsLabelType() const
{

View File

@ -34,6 +34,7 @@
#include <sch_sheet_path.h>
#include <lib_pin.h> // LIB_PIN::PinStringNum( m_PinNum )
#include <sch_item_struct.h>
class NETLIST_OBJECT_LIST;
class SCH_COMPONENT;
@ -256,13 +257,21 @@ public:
/**
* NETLIST_OBJECT_LIST is a class to handle the list of connected items
* in a full schematic hierarchy for netlist and erc calculations
* Type NETLIST_OBJECTS
* is a container referring to (not owning) NETLIST_OBJECTs, which are connected items
* in a full schematic hierarchy. It is useful when referring to NETLIST_OBJECTs
* actually owned by some other container.
*/
class NETLIST_OBJECT_LIST : public std::vector <NETLIST_OBJECT*>
typedef std::vector<NETLIST_OBJECT*> NETLIST_OBJECTS;
/**
* Class NETLIST_OBJECT_LIST
* is a container holding and _owning_ NETLIST_OBJECTs, which are connected items
* in a full schematic hierarchy. It is helpful for netlist and ERC calculations.
*/
class NETLIST_OBJECT_LIST : public NETLIST_OBJECTS
{
bool m_isOwner; // = true if the objects in list are owned my me, and therefore
// the memory should be freed by the destructor and the list cleared
int m_lastNetCode; // Used in intermediate calculation: last net code created
int m_lastBusNetCode; // Used in intermediate calculation:
// last net code created for bus members
@ -276,10 +285,8 @@ public:
* @param aIsOwner true if the instance is the owner of item list
* (default = false)
*/
NETLIST_OBJECT_LIST( bool aIsOwner = false )
NETLIST_OBJECT_LIST()
{
m_isOwner = aIsOwner;
// Do not leave some members uninitialized:
m_lastNetCode = 0;
m_lastBusNetCode = 0;
@ -287,8 +294,6 @@ public:
~NETLIST_OBJECT_LIST();
void SetOwner( bool aIsOwner ) { m_isOwner = aIsOwner; }
/**
* Function BuildNetListInfo
* the master function of tgis class.
@ -299,7 +304,7 @@ public:
*/
bool BuildNetListInfo( SCH_SHEET_LIST& aSheets );
/*
/**
* Acces to an item in list
*/
NETLIST_OBJECT* GetItem( unsigned aIdx ) const
@ -307,7 +312,7 @@ public:
return *( this->begin() + aIdx );
}
/*
/**
* Acces to an item type
*/
NETLIST_ITEM_T GetItemType( unsigned aIdx ) const
@ -315,7 +320,7 @@ public:
return GetItem( aIdx )->m_Type;
}
/*
/**
* Acces to an item net code
*/
int GetItemNet( unsigned aIdx ) const
@ -340,17 +345,8 @@ public:
GetItem( aIdx )->SetConnectionType( aFlg );
}
/*
* Delete all objects in list and clear list
* (delete NETLIST_OBJECT items)
*/
void FreeList();
/*
* Clear list but do not delete NETLIST_OBJECT items
* (they can be deleted only if the instance is owner of the items
*/
void Clear() { this->clear(); }
/** Delete all objects in list and clear list */
void Clear();
/**
* Reset the connection type of all items to UNCONNECTED type
@ -456,6 +452,7 @@ private:
void findBestNetNameForEachNet();
};
/**
* Function IsBusLabel
* test if \a aLabel has a bus notation.

View File

@ -208,9 +208,7 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
}
break;
// many many others.
default:
;
}
}

View File

@ -466,7 +466,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
*/
TestDuplicateSheetNames( true );
NETLIST_OBJECT_LIST* objectsConnectedList = m_parent->BuildNetListBase();
std::auto_ptr<NETLIST_OBJECT_LIST> objectsConnectedList( m_parent->BuildNetListBase() );
// Reset the connection type indicator
objectsConnectedList->ResetConnectionsType();
@ -509,7 +509,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierarchical label
// Each hierarchical label must match a pin sheet
TestLabel( objectsConnectedList, net, nextNet );
TestLabel( objectsConnectedList.get(), net, nextNet );
break;
case NET_NOCONNECT:
@ -525,7 +525,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
case NET_PIN:
// Look for ERC problems between pins:
TestOthersItems( objectsConnectedList, net, nextNet, &NetNbItems, &MinConn );
TestOthersItems( objectsConnectedList.get(), net, nextNet, &NetNbItems, &MinConn );
break;
}

View File

@ -79,11 +79,11 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList
helper = new NETLIST_EXPORTER_GENERIC( aConnectedItemsList, Prj().SchLibs() );
executeCommandLine = true;
}
break;
}
}
res = helper->Write( fileName, aNetlistOptions );
res = helper->WriteNetlist( fileName, aNetlistOptions );
if( executeCommandLine )
{

View File

@ -30,6 +30,8 @@
#include <fctsys.h>
#include <schframe.h>
#include <confirm.h>
#include <netlist_exporter_kicad.h>
#include <kiway.h>
#include <netlist.h>
#include <class_netlist_object.h>
@ -51,8 +53,8 @@
//Imported function:
int TestDuplicateSheetNames( bool aCreateMarker );
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
unsigned aNetlistOptions )
bool SCH_EDIT_FRAME::prepareForNetlist()
{
SCH_SHEET_LIST sheets;
@ -85,32 +87,55 @@ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
screens.SchematicCleanUp();
NETLIST_OBJECT_LIST* connectedItemsList = BuildNetListBase();
return true;
}
bool success = WriteNetListFile( connectedItemsList, aFormat,
void SCH_EDIT_FRAME::sendNetlist()
{
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
NETLIST_EXPORTER_KICAD exporter( net_atoms, Prj().SchLibs() );
STRING_FORMATTER formatter;
// @todo : trim GNL_ALL down to minimum for CVPCB
exporter.Format( &formatter, GNL_ALL );
Kiway().ExpressMail( FRAME_CVPCB,
MAIL_EESCHEMA_NETLIST,
formatter.GetString(), // an abbreviated "kicad" (s-expr) netlist
this
);
}
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
unsigned aNetlistOptions )
{
if( !prepareForNetlist() )
return false;
std::auto_ptr<NETLIST_OBJECT_LIST> connectedItemsList( BuildNetListBase() );
bool success = WriteNetListFile( connectedItemsList.release(), aFormat,
aFullFileName, aNetlistOptions );
return success;
}
// Buffer to build the list of items used in netlist and erc calculations
NETLIST_OBJECT_LIST s_NetObjectslist( true );
//#define NETLIST_DEBUG
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()
{
if( m_isOwner )
FreeList();
else
Clear();
}
void NETLIST_OBJECT_LIST::FreeList()
void NETLIST_OBJECT_LIST::Clear()
{
std::vector<NETLIST_OBJECT*>::iterator iter;
NETLIST_OBJECTS::iterator iter;
for( iter = begin(); iter != end(); iter++ )
{
@ -136,34 +161,31 @@ void NETLIST_OBJECT_LIST::SortListbySheet()
NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase()
{
// I own this list until I return it to the new owner.
std::auto_ptr<NETLIST_OBJECT_LIST> ret( new NETLIST_OBJECT_LIST() );
// Creates the flattened sheet list:
SCH_SHEET_LIST aSheets;
// Build netlist info
bool success = s_NetObjectslist.BuildNetListInfo( aSheets );
bool success = ret->BuildNetListInfo( aSheets );
if( !success )
{
SetStatusText( _( "No Objects" ) );
return &s_NetObjectslist;
return ret.release();
}
/* The new %zu specification is needed to properly format a size_t
* value (returned by size(), here) */
wxString msg;
wxString msg = wxString::Format( _( "Net count = %zu" ), ret->size() );
msg.Printf( _( "Net count = %zu" ), s_NetObjectslist.size() );
SetStatusText( msg );
return &s_NetObjectslist;
return ret.release();
}
bool NETLIST_OBJECT_LIST::BuildNetListInfo( SCH_SHEET_LIST& aSheets )
{
s_NetObjectslist.SetOwner( true );
s_NetObjectslist.FreeList();
SCH_SHEET_PATH* sheet;
// Fill list with connected items from the flattened sheet list
@ -491,8 +513,9 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
// even if components are moved or deleted and undelete or replaced, as long
// the reference is kept)
// Build the list of items with no net names
NETLIST_OBJECT_LIST list;
// Build a list of items with no net names
NETLIST_OBJECTS list; // no ownership of elements being pointed at
for( unsigned ii = 0; ii < size(); ii++ )
{
item = GetItem( ii );
@ -505,12 +528,12 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
idxstart = 0;
candidate = NULL;
netcode = list.GetItemNet( 0 );
netcode = list[0]->GetNet();
for( unsigned ii = 0; ii <= list.size(); ii++ )
{
if( ii < list.size() )
item = list.GetItem( ii );
item = list[ii];
else
item = NULL;
@ -520,7 +543,7 @@ void NETLIST_OBJECT_LIST::findBestNetNameForEachNet()
{
for (unsigned jj = idxstart; jj < ii; jj++ )
{
NETLIST_OBJECT* obj = list.GetItem( jj );
NETLIST_OBJECT* obj = list[jj];
obj->SetNetNameCandidate( candidate );
}
}

View File

@ -45,6 +45,8 @@
#include <netlist.h>
#include <netlist_exporter.h>
wxString NETLIST_EXPORTER::MakeCommandLine( const wxString& aFormatString,
const wxString& aTempfile, const wxString& aFinalFile, const wxString& aProjectPath )
{

View File

@ -73,13 +73,14 @@ public:
class NETLIST_EXPORTER
{
protected:
NETLIST_OBJECT_LIST* m_masterList; /// The main connected items flat list
NETLIST_OBJECT_LIST* m_masterList; /// yes ownership, connected items flat list
PART_LIBS* m_libs; /// no ownership
/// Used to temporary store and filter the list of pins of a schematic component
/// when generating schematic component data in netlist (comp section)
NETLIST_OBJECT_LIST m_SortedComponentPinList;
/// when generating schematic component data in netlist (comp section). No ownership
/// of members.
NETLIST_OBJECTS m_SortedComponentPinList;
/// Used for "multi parts per package" components,
/// avoids processing a lib component more than once.
@ -91,7 +92,6 @@ protected:
std::set<void*> m_Libraries; ///< unique libraries used
/**
* Function sprintPinNetName
* formats the net name for \a aPin using \a aNetNameFormat into \a aResult.
@ -155,21 +155,27 @@ protected:
SCH_SHEET_PATH* aSheetPath );
public:
NETLIST_EXPORTER( NETLIST_OBJECT_LIST* aMasterList, PART_LIBS* aLibs )
/**
* Constructor
* @param aMasterList we take ownership of this here.
*/
NETLIST_EXPORTER( NETLIST_OBJECT_LIST* aMasterList, PART_LIBS* aLibs ) :
m_masterList( aMasterList ),
m_libs( aLibs )
{
m_masterList = aMasterList;
m_libs = aLibs;
}
virtual ~NETLIST_EXPORTER()
{
delete m_masterList; // I own the list itself in this instance.
}
/**
* Function Write
* Function WriteNetlist
* writes to specified output file
*/
virtual bool Write( const wxString& aOutFileName, unsigned aNetlistOptions )
virtual bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
return false;
}

View File

@ -36,7 +36,7 @@
/* Generate CADSTAR net list. */
static wxString StartLine( wxT( "." ) );
bool NETLIST_EXPORTER_CADSTAR::Write( const wxString& aOutFileName, unsigned aNetlistOptions )
bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
(void)aNetlistOptions; //unused
int ret = 0;

View File

@ -53,10 +53,10 @@ public:
}
/**
* Function Write
* Function WriteList
* writes to specified output file
*/
bool Write( const wxString& aOutFileName, unsigned aNetlistOptions );
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions );
};
#endif

View File

@ -32,7 +32,7 @@
static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 );
bool NETLIST_EXPORTER_GENERIC::Write( const wxString& aOutFileName, unsigned aNetlistOptions )
bool NETLIST_EXPORTER_GENERIC::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
// Prepare list of nets generation
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
@ -41,28 +41,33 @@ bool NETLIST_EXPORTER_GENERIC::Write( const wxString& aOutFileName, unsigned aNe
// output the XML format netlist.
wxXmlDocument xdoc;
xdoc.SetRoot( makeRoot() );
xdoc.SetRoot( makeRoot( GNL_ALL ) );
return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ );
}
XNODE* NETLIST_EXPORTER_GENERIC::makeRoot()
XNODE* NETLIST_EXPORTER_GENERIC::makeRoot( int aCtl )
{
XNODE* xroot = node( wxT( "export" ) );
xroot->AddAttribute( wxT( "version" ), wxT( "D" ) );
if( aCtl & GNL_HEADER )
// add the "design" header
xroot->AddChild( makeDesignHeader() );
if( aCtl & GNL_COMPONENTS )
xroot->AddChild( makeComponents() );
if( aCtl & GNL_PARTS )
xroot->AddChild( makeLibParts() );
if( aCtl & GNL_LIBRARIES )
// must follow makeGenericLibParts()
xroot->AddChild( makeLibraries() );
if( aCtl & GNL_NETS )
xroot->AddChild( makeListOfNets() );
return xroot;

View File

@ -32,6 +32,20 @@
#define GENERIC_INTERMEDIATE_NETLIST_EXT wxT( "xml" )
/**
* Enum GNL
* is a set of bit which control the totality of the tree built by makeRoot()
*/
enum GNL_T
{
GNL_LIBRARIES = 1 << 0,
GNL_COMPONENTS = 1 << 1,
GNL_PARTS = 1 << 2,
GNL_HEADER = 1 << 3,
GNL_NETS = 1 << 4,
};
/**
* Class NETLIST_EXPORTER_GENERIC
* generates a generic XML based netlist file. This allows using XSLT or other methods to
@ -39,6 +53,20 @@
*/
class NETLIST_EXPORTER_GENERIC : public NETLIST_EXPORTER
{
public:
NETLIST_EXPORTER_GENERIC( NETLIST_OBJECT_LIST* aMasterList, PART_LIBS* aLibs ) :
NETLIST_EXPORTER( aMasterList, aLibs )
{
}
/**
* Function WriteNetlist
* writes to specified output file
*/
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions );
#define GNL_ALL ( GNL_LIBRARIES | GNL_COMPONENTS | GNL_PARTS | GNL_HEADER | GNL_NETS )
protected:
/**
* Function node
@ -50,20 +78,23 @@ protected:
* of the returned node, and has type wxXML_TEXT_NODE.
*/
XNODE* node( const wxString& aName, const wxString& aTextualContent = wxEmptyString );
/**
* Function writeGENERICListOfNets
* writes out nets (ranked by Netcode), and elements that are
* connected as part of that net.
*/
bool writeListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjectsList );
/**
* Function makeGenericRoot
* builds the entire document tree for the generic export. This is factored
* out here so we can write the tree in either S-expression file format
* or in XML if we put the tree built here into a wxXmlDocument.
* @param aCtl - a bitset or-ed together from GNL_ENUM values
* @return XNODE* - the root nodes
*/
XNODE* makeRoot();
XNODE* makeRoot( int aCtl = GNL_ALL );
/**
* Function makeComponents
@ -99,18 +130,6 @@ protected:
* @return XNODE* - the library nodes
*/
XNODE* makeLibraries();
public:
NETLIST_EXPORTER_GENERIC( NETLIST_OBJECT_LIST* aMasterList, PART_LIBS* aLibs ) :
NETLIST_EXPORTER( aMasterList, aLibs )
{
}
/**
* Function Write
* writes to specified output file
*/
bool Write( const wxString& aOutFileName, unsigned aNetlistOptions );
};
#endif

View File

@ -31,8 +31,9 @@
#include <schframe.h>
#include "netlist_exporter_kicad.h"
bool NETLIST_EXPORTER_KICAD::Write( const wxString& aOutFileName, unsigned aNetlistOptions )
bool NETLIST_EXPORTER_KICAD::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
#if 0
// Prepare list of nets generation
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
m_masterList->GetItem( ii )->m_Flag = 0;
@ -45,6 +46,15 @@ bool NETLIST_EXPORTER_KICAD::Write( const wxString& aOutFileName, unsigned aNetl
xroot->Format( &formatter, 0 );
}
#else
try
{
FILE_OUTPUTFORMATTER formatter( aOutFileName );
Format( &formatter, GNL_ALL );
}
#endif
catch( const IO_ERROR& ioe )
{
DisplayError( NULL, ioe.errorText );
@ -53,3 +63,15 @@ bool NETLIST_EXPORTER_KICAD::Write( const wxString& aOutFileName, unsigned aNetl
return true;
}
void NETLIST_EXPORTER_KICAD::Format( OUTPUTFORMATTER* aOut, int aCtl )
{
// Prepare list of nets generation
for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
m_masterList->GetItem( ii )->m_Flag = 0;
std::auto_ptr<XNODE> xroot( makeRoot( aCtl ) );
xroot->Format( aOut, 0 );
}

View File

@ -28,6 +28,8 @@
#include <netlist_exporter_generic.h>
class OUTPUTFORMATTER;
/**
* Class NETLIST_EXPORTER_KICAD
* generates the kicad netlist format supported by pcbnew. It is basically
@ -42,10 +44,20 @@ public:
}
/**
* Function Write
* Function WriteNetlist
* writes to specified output file
*/
bool Write( const wxString& aOutFileName, unsigned aNetlistOptions );
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions ); // OVERRIDE
/**
* Function Format
* outputs this s-expression netlist into @a aOutputFormatter.
* @param aOutputFormatter is the destination of the serialization to text.
* @param aCtl is bit set composed by OR-ing together enum GNL bits, it allows ouputting
* a subset of the full document model.
* @throw IO_ERROR if any problems.
*/
void Format( OUTPUTFORMATTER* aOutputFormatter, int aCtl );
};
#endif

View File

@ -35,7 +35,7 @@
#include <netlist.h>
#include "netlist_exporter_orcadpcb2.h"
bool NETLIST_EXPORTER_ORCADPCB2::Write( const wxString& aOutFileName, unsigned aNetlistOptions )
bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
(void)aNetlistOptions; //unused
FILE* f = NULL;

View File

@ -40,7 +40,7 @@ public:
{
}
bool Write( const wxString& aOutFileName, unsigned aNetlistOptions );
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions );
};
#endif

View File

@ -34,7 +34,7 @@
#include <wx/tokenzr.h>
#include "netlist_exporter_pspice.h"
bool NETLIST_EXPORTER_PSPICE::Write( const wxString& aOutFileName, unsigned aNetlistOptions )
bool NETLIST_EXPORTER_PSPICE::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
{
FILE* f = NULL;
bool aUsePrefix = aNetlistOptions & NET_USE_X_PREFIX;

View File

@ -41,10 +41,10 @@ public:
}
/**
* Function Write
* Function WriteNetlist
* writes to specified output file
*/
bool Write( const wxString& aOutFileName, unsigned aNetlistOptions );
bool WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions );
};
#endif

View File

@ -27,7 +27,6 @@
*/
#include <fctsys.h>
#include <kiway.h>
#include <kiface_i.h>
#include <pgm_base.h>
#include <gr_basic.h>
@ -186,6 +185,23 @@ PART_LIBS* PROJECT::SchLibs()
return libs;
}
/*
NETLIST_OBJECT_LIST* PROJECT::Netlist()
{
NETLIST_OBJECT_LIST* netlist = (NETLIST_OBJECT_LIST*) GetElem( PROJECT::ELEM_SCH_NETLIST );
wxASSERT( !libs || dynamic_cast<NETLIST_OBJECT_LIST*>( netlist ) );
if( !netlist )
{
netlist = new NETLIST_OBJECT_LIST();
// Make PROJECT the new NETLIST_OBJECT_LIST owner.
SetElem( PROJECT::ELEM_SCH_NETLIST, netlist );
}
}
*/
//-----</SCH "data on demand" functions>------------------------------------------
@ -974,10 +990,16 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
if( Kiface().IsSingle() )
{
/* the CVPCB executable is now gone, only the *.kiface remains, that is because
* CVPCB can now read the netlist ONLY from the Kiway. This removes cvpcb's
* use of the *.cmp file altogether, and also its use of reading the *.net file
* from disk.
ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) );
*/
}
else
{
#if 0
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
if( !player )
@ -988,6 +1010,23 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
}
player->Raise();
#else
if( prepareForNetlist() )
{
KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
if( !player )
{
player = Kiway().Player( FRAME_CVPCB, true );
player->Show( true );
// player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
}
sendNetlist();
player->Raise();
}
#endif
}
}

View File

@ -209,6 +209,20 @@ protected:
void backAnnotateFootprints( const std::string& aChangedSetOfReferences )
throw( IO_ERROR, boost::bad_pointer );
/**
* Function prepareForNetlist
* verifies 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();
/**
* Function sendNetlist
* sends the kicad netlist over to CVPCB.
*/
void sendNetlist();
public:
SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent );
~SCH_EDIT_FRAME();
@ -476,7 +490,7 @@ public:
* netlist generation:
* Creates a flat list which stores all connected objects, and mainly
* pins and labels.
* @return a pointer to the list
* @return NETLIST_OBJECT_LIST* - caller owns the object.
*/
NETLIST_OBJECT_LIST* BuildNetListBase();
@ -506,7 +520,7 @@ public:
* Function WriteNetListFile
* Create the netlist file. Netlist info must be existing
* (BuildNetListBase() creates this info)
* @param aConnectedItemsList = the initialized list of connected items
* @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.

View File

@ -156,14 +156,16 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
// The user must HAVE footprints before he can assign them. So put this before
// the CVPCB.
if( !Kiface().IsSingle() ) // if pcbnew is not a separate process
if( !Kiface().IsSingle() ) // if eeschema is not a separate process
{
m_mainToolBar->AddTool( ID_RUN_PCB_MODULE_EDITOR, wxEmptyString, KiBitmap( module_editor_xpm ),
_( "Footprint Editor" ) );
}
// CVPCB only reads from the kiway now, and the kiway is only implemented in the
// project manager, not single_top.
m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiBitmap( cvpcb_xpm ),
_( "Run CvPcb to associate components and footprints" ) );
}
m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiBitmap( pcbnew_xpm ),
_( "Run Pcbnew to layout printed circuit board" ) );

View File

@ -38,7 +38,7 @@ enum MAIL_T
{
MAIL_CROSS_PROBE, ///< PCB<->SCH, CVPCB->SCH cross-probing.
MAIL_BACKANNOTATE_FOOTPRINTS, ///< CVPCB->SCH footprint stuffing at cvpcb termination
MAIL_EESCHEMA_NETLIST, ///< EESCHEMA->CVPCB netlist immediately after launching CVPCB
};
#endif // MAIL_TYPE_H_

View File

@ -605,7 +605,7 @@ public:
*/
void StripUseless();
std::string GetString()
const std::string& GetString()
{
return mystring;
}

View File

@ -222,9 +222,12 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
OpenPDF( fullFileName );
break;
/* No, use a text editor. Netlists can only be handled sanely now from within
eeschema's launcher for the *.kiface, NOT THE EXE which is now gone.
case TREE_NET:
frame->Execute( m_parent, CVPCB_EXE, fullFileName );
break;
*/
case TREE_TXT:
{

View File

@ -69,11 +69,6 @@ void LAUNCHER_PANEL::CreateCommandToolbar()
btn = AddBitmapButton( ID_TO_SCH_LIB_EDITOR, KiBitmap( libedit_icon_xpm ) );
btn->SetToolTip( _( "Schematic library editor" ) );
#if 0
btn = AddBitmapButton( ID_TO_CVPCB, KiBitmap( icon_cvpcb_xpm ) );
btn->SetToolTip( _( "CvPcb - Associate footprint to components" ) );
#endif
btn = AddBitmapButton( ID_TO_PCB, KiBitmap( icon_pcbnew_xpm ) );
btn->SetToolTip( _( "Pcbnew - Printed circuit board editor" ) );

View File

@ -179,7 +179,6 @@ public:
void OnRunSchLibEditor( wxCommandEvent& event );
void OnRunPcbNew( wxCommandEvent& event );
void OnRunPcbFpEditor( wxCommandEvent& event );
void OnRunCvpcb( wxCommandEvent& event );
void OnRunGerbview( wxCommandEvent& event );
void OnRunBitmapConverter( wxCommandEvent& event );
void OnRunPcbCalculator( wxCommandEvent& event );

View File

@ -421,6 +421,7 @@ void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor( wxCommandEvent& event )
// are now always set by Cvpcb.
// ( The idea is to drop the .cmp files to avoid to have 2 places were
// footprints are stored, but only one: the schematic )
/*
void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
{
wxFileName fn( GetProjectFileName() );
@ -437,6 +438,8 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
frame->Raise();
}
*/
#include <wx/filefn.h>
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )

View File

@ -85,8 +85,6 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME )
EVT_BUTTON( ID_TO_SCH_LIB_EDITOR, KICAD_MANAGER_FRAME::OnRunSchLibEditor )
EVT_MENU( ID_TO_SCH_LIB_EDITOR, KICAD_MANAGER_FRAME::OnRunSchLibEditor )
EVT_BUTTON( ID_TO_CVPCB, KICAD_MANAGER_FRAME::OnRunCvpcb )
EVT_BUTTON( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )
EVT_MENU( ID_TO_PCB, KICAD_MANAGER_FRAME::OnRunPcbNew )

View File

@ -64,7 +64,6 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
{
wxString msg;
NETLIST netlist;
NETLIST_READER* netlistReader;
KIGFX::VIEW* view = GetGalCanvas()->GetView();
BOARD* board = GetBoard();
@ -75,17 +74,16 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
try
{
netlistReader = NETLIST_READER::GetNetlistReader( &netlist, aNetlistFileName,
aCmpFileName );
std::auto_ptr<NETLIST_READER> netlistReader( NETLIST_READER::GetNetlistReader(
&netlist, aNetlistFileName, aCmpFileName ) );
if( netlistReader == NULL )
if( !netlistReader.get() )
{
msg.Printf( _( "Cannot open netlist file \"%s\"." ), GetChars( aNetlistFileName ) );
wxMessageBox( msg, _( "Netlist Load Error." ), wxOK | wxICON_ERROR, this );
return;
}
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
SetLastNetListRead( aNetlistFileName );
netlistReader->LoadNetlist();
loadFootprints( netlist, aReporter );

View File

@ -39,18 +39,9 @@
NETLIST_READER::~NETLIST_READER()
{
if( m_lineReader )
{
delete m_lineReader;
m_lineReader = NULL;
}
if( m_footprintReader )
{
delete m_footprintReader;
m_footprintReader = NULL;
}
}
@ -92,43 +83,29 @@ NETLIST_READER* NETLIST_READER::GetNetlistReader( NETLIST* aNetlist,
{
wxASSERT( aNetlist != NULL );
FILE* file = wxFopen( aNetlistFileName, wxT( "rt" ) );
std::auto_ptr< FILE_LINE_READER > file_rdr(new FILE_LINE_READER( aNetlistFileName ) );
if( file == NULL )
{
wxString msg;
msg.Printf( _( "Cannot open file %s for reading." ), GetChars( aNetlistFileName ) );
THROW_IO_ERROR( msg );
}
FILE_LINE_READER* reader = new FILE_LINE_READER( file, aNetlistFileName );
std::auto_ptr< FILE_LINE_READER > r( reader );
NETLIST_FILE_T type = GuessNetlistFileType( reader );
reader->Rewind();
NETLIST_FILE_T type = GuessNetlistFileType( file_rdr.get() );
file_rdr->Rewind();
// The component footprint link reader is NULL if no file name was specified.
CMP_READER* cmpFileReader = NULL;
if( !aCompFootprintFileName.IsEmpty() )
{
cmpFileReader = new CMP_READER( new FILE_LINE_READER( aCompFootprintFileName ) );
}
std::auto_ptr<CMP_READER> cmp_rdr( aCompFootprintFileName.IsEmpty() ?
NULL :
new CMP_READER( new FILE_LINE_READER( aCompFootprintFileName ) ) );
switch( type )
{
case LEGACY:
case ORCAD:
return new LEGACY_NETLIST_READER( r.release(), aNetlist, cmpFileReader );
return new LEGACY_NETLIST_READER( file_rdr.release(), aNetlist, cmp_rdr.release() );
case KICAD:
return new KICAD_NETLIST_READER( r.release(), aNetlist, cmpFileReader );
return new KICAD_NETLIST_READER( file_rdr.release(), aNetlist, cmp_rdr.release() );
default: // Unrecognized format:
break;
}
delete cmpFileReader;
return NULL;
}

View File

@ -110,15 +110,6 @@ public:
*/
class NETLIST_READER
{
protected:
NETLIST* m_netlist; ///< The net list to read the file(s) into.
bool m_loadFootprintFilters; ///< Load the component footprint filters section if true.
bool m_loadNets; ///< Load the nets section of the netlist file if true.
LINE_READER* m_lineReader; ///< The line reader of the netlist.
/// The reader used to load the footprint links. If NULL, footprint links are not read.
CMP_READER* m_footprintReader;
public:
enum NETLIST_FILE_T
@ -133,6 +124,12 @@ public:
// function.
};
/**
* Constructor
* @param aLineReader ownership is taken of this LINE_READER.
* @param aFootprintLinkReader ownership is taken of this CMP_READER.
*/
NETLIST_READER( LINE_READER* aLineReader,
NETLIST* aNetlist,
CMP_READER* aFootprintLinkReader = NULL )
@ -190,6 +187,15 @@ public:
* @return the #LINE_READER associated with the #NETLIST_READER.
*/
LINE_READER* GetLineReader();
protected:
NETLIST* m_netlist; ///< The net list to read the file(s) into.
bool m_loadFootprintFilters; ///< Load the component footprint filters section if true.
bool m_loadNets; ///< Load the nets section of the netlist file if true.
LINE_READER* m_lineReader; ///< The line reader of the netlist.
/// The reader used to load the footprint links. If NULL, footprint links are not read.
CMP_READER* m_footprintReader;
};
@ -388,7 +394,6 @@ public:
virtual ~KICAD_NETLIST_READER()
{
if( m_parser )
delete m_parser;
}