From f3765a32d8b682deae27f17d0615ccadaa390080 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 3 Dec 2014 17:22:06 +0100 Subject: [PATCH] Fix minor issues. Fix some outdated and broken BOM python scripts. Add info in BOM python scripts. BOM dialog: remove a not very useful button, and merge its function with an other (not perfect, need more work) Add message box to show info added in BOM python scripts (See scripts/bom-in-python/README-bom.txt about this info) --- eeschema/dialogs/dialog_bom.cpp | 113 +++++++- eeschema/dialogs/dialog_bom_base.cpp | 11 +- eeschema/dialogs/dialog_bom_base.fbp | 264 ++++++++++++------ eeschema/dialogs/dialog_bom_base.h | 8 +- eeschema/netform.cpp | 4 +- eeschema/plugins/bom2csv.xsl | 8 + eeschema/plugins/bom_cvs.xsl | 22 +- gerbview/events_called_functions.cpp | 12 - gerbview/files.cpp | 2 +- gerbview/onrightclick.cpp | 3 - ...board_items_to_polygon_shape_transform.cpp | 3 +- pcbnew/edit.cpp | 3 + pcbnew/zones_by_polygon.cpp | 1 - scripting/build_tools/fix_swig_imports.py | 4 +- scripts/bom-in-python/README-bom.txt | 26 +- scripts/bom-in-python/bom-generation.py | 12 +- scripts/bom-in-python/bom_csv_by_ref.py | 15 +- scripts/bom-in-python/bom_csv_by_ref_v2.py | 14 +- .../bom-in-python/bom_csv_grouped_by_value.py | 4 +- scripts/bom-in-python/bom_html_by_value.py | 14 +- .../bom_html_grouped_by_value.py | 22 +- scripts/bom-in-python/kicad_netlist_reader.py | 9 + scripts/bom-in-python/round_robin.py | 5 +- scripts/bom-in-python/round_value_robin.py | 3 +- 24 files changed, 424 insertions(+), 158 deletions(-) diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 6a3bbe66dd..416d2ac0e7 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -69,7 +69,6 @@ public: private: void parsePlugin() throw( IO_ERROR, PARSE_ERROR ); - }; // PCB_PLOT_PARAMS_PARSER @@ -175,7 +174,6 @@ private: void OnCancelClick( wxCommandEvent& event ); void OnHelp( wxCommandEvent& event ); void OnAddPlugin( wxCommandEvent& event ); - void OnChoosePlugin( wxCommandEvent& event ); void OnRemovePlugin( wxCommandEvent& event ); void OnEditPlugin( wxCommandEvent& event ); void OnCommandLineEdited( wxCommandEvent& event ); @@ -183,6 +181,18 @@ private: void pluginInit(); void installPluginsList(); + wxString getPluginFileName(); + + /** + * display (when exists) the text found between the keyword "@package" + * and the end of comment block (""" in python", --> in xml) + */ + void displayPluginInfo( FILE * aFile, const wxString& aFilename ); + + /** + * Browse plugin files, and set m_CommandStringCtrl field + */ + void choosePlugin(); }; // Create and show DIALOG_BOM. @@ -215,12 +225,14 @@ DIALOG_BOM::~DIALOG_BOM() STRING_FORMATTER writer; writer.Print( 0, "(plugins" ); + for( unsigned ii = 0; ii < m_plugins.GetCount(); ii += 2 ) { writer.Print( 1, "(plugin %s (cmd %s))", writer.Quotew( m_plugins[ii] ).c_str(), writer.Quotew( m_plugins[ii+1] ).c_str() ); } + writer.Print( 0, ")" ); wxString list( FROM_UTF8( writer.GetString().c_str() ) ); @@ -272,6 +284,7 @@ void DIALOG_BOM::OnPluginSelected( wxCommandEvent& event ) pluginInit(); } +#include void DIALOG_BOM::pluginInit() { int ii = m_lbPlugins->GetSelection(); @@ -285,8 +298,67 @@ void DIALOG_BOM::pluginInit() m_textCtrlName->SetValue( m_plugins[2 * ii] ); m_textCtrlCommand->SetValue( m_plugins[(2 * ii)+1] ); + + wxString pluginName = getPluginFileName(); + + if( pluginName.IsEmpty() ) + return; + + FILE* pluginFile = wxFopen( pluginName, "rt" ); + + if( pluginFile == NULL ) + { + wxString msg; + msg.Printf( _( "Failed to open file '%s'" ), GetChars( pluginName ) ); + DisplayError( this, msg ); + return; + } + + displayPluginInfo( pluginFile, pluginName ); } +/* display (when exists) the text found between the keyword "@package" + * and the end of comment block (""" in python", --> in xml) + */ +void DIALOG_BOM::displayPluginInfo( FILE * aFile, const wxString& aFilename ) +{ + m_Messages->Clear(); + + // display (when exists) the text found between the keyword "@package" + // and the end of comment block (""" in python", --> in xml) + + wxString data; + wxFFile fdata( aFile ); // dtor will close the file + + if( !fdata.ReadAll( &data ) ) + return; + + wxString header( wxT( "@package" ) ); + wxString endsection( wxT( "-->" ) ); // For xml + + wxFileName fn( aFilename ); + + if( fn.GetExt().IsSameAs( wxT("py"), false ) ) + endsection = wxT( "\"\"\"" ); + + // Extract substring between @package and """ + int strstart = data.Find( header ); + + if( strstart == wxNOT_FOUND ) + return; + + strstart += header.Length(); + int strend = data.find( endsection, strstart ); + + if( strend == wxNOT_FOUND) + return; + + // Remove emty line if any + while( data[strstart] < ' ' ) + strstart++; + + m_Messages->SetValue( data.SubString( strstart, strend-1 ) ); +} /** * Function RunPlugin @@ -351,7 +423,7 @@ void DIALOG_BOM::OnRemovePlugin( wxCommandEvent& event ) void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event ) { // Creates a new plugin entry - wxString name = wxGetTextFromUser( _("Plugin") ); + wxString name = wxGetTextFromUser( _("Plugin name in plugin list") ); if( name.IsEmpty() ) return; @@ -361,7 +433,7 @@ void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event ) { if( name == m_plugins[ii] ) { - wxMessageBox( _("This plugin already exists. Abort") ); + wxMessageBox( _("This name already exists. Abort") ); return; } } @@ -370,13 +442,16 @@ void DIALOG_BOM::OnAddPlugin( wxCommandEvent& event ) m_plugins.Add( wxEmptyString ); m_lbPlugins->Append( name ); m_lbPlugins->SetSelection( m_lbPlugins->GetCount() - 1 ); + + choosePlugin(); + pluginInit(); } /* * Browse plugin files, and set m_CommandStringCtrl field */ -void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event ) +void DIALOG_BOM::choosePlugin() { wxString mask = wxT( "*" ); #ifndef __WXMAC__ @@ -417,13 +492,14 @@ void DIALOG_BOM::OnChoosePlugin( wxCommandEvent& event ) m_textCtrlCommand->SetValue( cmdLine ); } -void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event ) + +wxString DIALOG_BOM::getPluginFileName() { - wxString pluginName, cmdline; + wxString pluginName; // Try to find the plugin name. // This is possible if the name ends by .py or .xsl - cmdline = m_textCtrlCommand->GetValue(); + wxString cmdline = m_textCtrlCommand->GetValue(); int pos = -1; if( (pos = cmdline.Find( wxT(".py") )) != wxNOT_FOUND ) @@ -449,9 +525,30 @@ void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event ) // extract the name if( jj >= 0 ) + { + eos = cmdline[jj]; + + if( eos == ' '|| eos == '\"' ) // do not include delimiters + jj++; + pluginName = cmdline.SubString( jj, pos ); + } } } + + return pluginName; +} + +void DIALOG_BOM::OnEditPlugin( wxCommandEvent& event ) +{ + wxString pluginName = getPluginFileName(); + + if( pluginName.Length() <= 2 ) // if name != "" + { + wxMessageBox( _("Plugin file name not found. Cannot edit plugin file") ); + return; + } + AddDelimiterString( pluginName ); wxString editorname = Pgm().GetEditorName(); diff --git a/eeschema/dialogs/dialog_bom_base.cpp b/eeschema/dialogs/dialog_bom_base.cpp index e8888467a5..6f96e35428 100644 --- a/eeschema/dialogs/dialog_bom_base.cpp +++ b/eeschema/dialogs/dialog_bom_base.cpp @@ -16,7 +16,6 @@ BEGIN_EVENT_TABLE( DIALOG_BOM_BASE, DIALOG_SHIM ) EVT_BUTTON( wxID_CANCEL, DIALOG_BOM_BASE::_wxFB_OnCancelClick ) EVT_BUTTON( ID_HELP, DIALOG_BOM_BASE::_wxFB_OnHelp ) EVT_BUTTON( ID_ADD_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnAddPlugin ) - EVT_BUTTON( wxID_BROWSE_PLUGINS, DIALOG_BOM_BASE::_wxFB_OnChoosePlugin ) EVT_BUTTON( ID_REMOVEL_PLUGIN, DIALOG_BOM_BASE::_wxFB_OnRemovePlugin ) EVT_BUTTON( wxID_ANY, DIALOG_BOM_BASE::_wxFB_OnEditPlugin ) EVT_TEXT( ID_CMDLINE, DIALOG_BOM_BASE::_wxFB_OnCommandLineEdited ) @@ -72,9 +71,6 @@ DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxStrin m_buttonAddPlugin = new wxButton( this, ID_ADD_PLUGIN, _("Add Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); bRightSizer->Add( m_buttonAddPlugin, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_buttonBrowsePlugin = new wxButton( this, wxID_BROWSE_PLUGINS, _("Set Plugin Cmd"), wxDefaultPosition, wxDefaultSize, 0 ); - bRightSizer->Add( m_buttonBrowsePlugin, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_buttonDelPlugin = new wxButton( this, ID_REMOVEL_PLUGIN, _("Remove Plugin"), wxDefaultPosition, wxDefaultSize, 0 ); bRightSizer->Add( m_buttonDelPlugin, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -103,6 +99,13 @@ DIALOG_BOM_BASE::DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id, const wxStrin bMainSizer->Add( bbottomSizer, 0, wxEXPAND, 5 ); + m_staticTextInfo = new wxStaticText( this, wxID_ANY, _("Plugin Info:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextInfo->Wrap( -1 ); + bMainSizer->Add( m_staticTextInfo, 0, wxRIGHT|wxLEFT, 5 ); + + m_Messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + bMainSizer->Add( m_Messages, 1, wxALL|wxEXPAND, 5 ); + this->SetSizer( bMainSizer ); this->Layout(); diff --git a/eeschema/dialogs/dialog_bom_base.fbp b/eeschema/dialogs/dialog_bom_base.fbp index 49b6273625..3393de4827 100644 --- a/eeschema/dialogs/dialog_bom_base.fbp +++ b/eeschema/dialogs/dialog_bom_base.fbp @@ -44,7 +44,7 @@ DIALOG_BOM_BASE - 404,315 + 409,393 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Bill of Material @@ -900,94 +900,6 @@ - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_BROWSE_PLUGINS - Set Plugin Cmd - - 0 - - - 0 - - 1 - m_buttonBrowsePlugin - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnChoosePlugin - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxRIGHT|wxLEFT @@ -1353,6 +1265,180 @@ + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Plugin Info: + + 0 + + + 0 + + 1 + m_staticTextInfo + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_Messages + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/dialogs/dialog_bom_base.h b/eeschema/dialogs/dialog_bom_base.h index 2ba54c81f9..cf47f8fea4 100644 --- a/eeschema/dialogs/dialog_bom_base.h +++ b/eeschema/dialogs/dialog_bom_base.h @@ -44,7 +44,6 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } void _wxFB_OnHelp( wxCommandEvent& event ){ OnHelp( event ); } void _wxFB_OnAddPlugin( wxCommandEvent& event ){ OnAddPlugin( event ); } - void _wxFB_OnChoosePlugin( wxCommandEvent& event ){ OnChoosePlugin( event ); } void _wxFB_OnRemovePlugin( wxCommandEvent& event ){ OnRemovePlugin( event ); } void _wxFB_OnEditPlugin( wxCommandEvent& event ){ OnEditPlugin( event ); } void _wxFB_OnCommandLineEdited( wxCommandEvent& event ){ OnCommandLineEdited( event ); } @@ -57,7 +56,6 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM ID_CREATE_BOM, ID_HELP, ID_ADD_PLUGIN, - wxID_BROWSE_PLUGINS, ID_REMOVEL_PLUGIN, ID_CMDLINE }; @@ -71,11 +69,12 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM wxButton* m_buttonHelp; wxStaticLine* m_staticline2; wxButton* m_buttonAddPlugin; - wxButton* m_buttonBrowsePlugin; wxButton* m_buttonDelPlugin; wxButton* m_buttonEdit; wxStaticText* m_staticTextCmd; wxTextCtrl* m_textCtrlCommand; + wxStaticText* m_staticTextInfo; + wxTextCtrl* m_Messages; // Virtual event handlers, overide them in your derived class virtual void OnPluginSelected( wxCommandEvent& event ) { event.Skip(); } @@ -84,7 +83,6 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnHelp( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddPlugin( wxCommandEvent& event ) { event.Skip(); } - virtual void OnChoosePlugin( wxCommandEvent& event ) { event.Skip(); } virtual void OnRemovePlugin( wxCommandEvent& event ) { event.Skip(); } virtual void OnEditPlugin( wxCommandEvent& event ) { event.Skip(); } virtual void OnCommandLineEdited( wxCommandEvent& event ) { event.Skip(); } @@ -92,7 +90,7 @@ class DIALOG_BOM_BASE : public DIALOG_SHIM public: - DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 404,315 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_BOM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Bill of Material"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 409,393 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_BOM_BASE(); }; diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 16f9bde6a8..a87dec87f3 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -381,7 +381,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList NETLIST_EXPORT_TOOL helper( aConnectedItemsList, Prj().SchLibs() ); - bool open_file = aFormat < NET_TYPE_CUSTOM1; + bool open_file = (aFormat < NET_TYPE_CUSTOM1) && (aFormat >= 0); if( (aFormat == NET_TYPE_PCBNEW) && (aNetlistOptions & NET_PCBNEW_USE_NEW_FORMAT ) ) open_file = false; @@ -390,7 +390,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( NETLIST_OBJECT_LIST * aConnectedItemsList if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) { wxString msg; - msg.Printf( _( "Failed to create file <%s>" ), + msg.Printf( _( "Failed to create file '%s'" ), GetChars( aFullFileName ) ); DisplayError( this, msg ); return false; diff --git a/eeschema/plugins/bom2csv.xsl b/eeschema/plugins/bom2csv.xsl index 3140609928..1991d4953e 100644 --- a/eeschema/plugins/bom2csv.xsl +++ b/eeschema/plugins/bom2csv.xsl @@ -19,6 +19,14 @@ in the filename. --> + + ]> diff --git a/eeschema/plugins/bom_cvs.xsl b/eeschema/plugins/bom_cvs.xsl index eacf860ea1..21d6b18a62 100644 --- a/eeschema/plugins/bom_cvs.xsl +++ b/eeschema/plugins/bom_cvs.xsl @@ -7,6 +7,14 @@ How to use: Eeschema.pdf: chapter 14 --> + @@ -18,20 +26,18 @@ - - - , - , + + ," + "," + "," - &nl; + "&nl; - qty,partname,description,lib&nl; + Qty,partname,description,lib&nl; diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 96b5d3d577..c06911658b 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -90,9 +90,6 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME ) EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp ) EVT_MENU( wxID_ABOUT, EDA_DRAW_FRAME::GetKicadAbout ) - EVT_TOOL( wxID_CUT, GERBVIEW_FRAME::Process_Special_Functions ) - EVT_TOOL( wxID_COPY, GERBVIEW_FRAME::Process_Special_Functions ) - EVT_TOOL( wxID_PASTE, GERBVIEW_FRAME::Process_Special_Functions ) EVT_TOOL( wxID_UNDO, GERBVIEW_FRAME::Process_Special_Functions ) EVT_TOOL( wxID_PRINT, GERBVIEW_FRAME::ToPrinter ) EVT_COMBOBOX( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER, @@ -145,9 +142,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) switch( id ) { - case wxID_CUT: - case wxID_COPY: - case ID_POPUP_DELETE_BLOCK: case ID_POPUP_PLACE_BLOCK: case ID_POPUP_ZOOM_BLOCK: break; @@ -219,12 +213,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event ) HandleBlockEnd( &dc ); break; - case ID_POPUP_DELETE_BLOCK: - GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE ); - GetScreen()->m_BlockLocate.SetMessageBlock( this ); - HandleBlockEnd( &dc ); - break; - default: wxFAIL_MSG( wxT( "GERBVIEW_FRAME::Process_Special_Functions error" ) ); break; diff --git a/gerbview/files.cpp b/gerbview/files.cpp index b35a61a021..98f4122d41 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -80,7 +80,7 @@ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) break; case ID_GERBVIEW_ERASE_ALL: - Clear_DrawLayers( true ); + Clear_DrawLayers( false ); Zoom_Automatique( false ); m_canvas->Refresh(); ClearMsgPanel(); diff --git a/gerbview/onrightclick.cpp b/gerbview/onrightclick.cpp index 33928cc488..8f5cfe33b0 100644 --- a/gerbview/onrightclick.cpp +++ b/gerbview/onrightclick.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -75,8 +74,6 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) PopMenu->AppendSeparator(); AddMenuItem( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), KiBitmap( checked_ok_xpm ) ); - AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, - _( "Delete Block (ctrl + drag mouse)" ), KiBitmap( delete_xpm ) ); } else { diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 020c5d6b8a..67446d245c 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -999,7 +999,6 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, double angle = aPad.GetOrientation(); int rounding_radius = KiROUND( aThermalGap * aCorrectionFactor ); // Corner rounding radius - double angle_pg; // Polygon increment angle for( int i = 0; i < aCircleToSegmentsCount / 4 + 1; i++ ) { @@ -1007,7 +1006,7 @@ void CreateThermalReliefPadPolygon( CPOLYGONS_LIST& aCornerBuffer, // Start at half increment offset RotatePoint( &corner_position, 1800.0 / aCircleToSegmentsCount ); - angle_pg = i * delta; + double angle_pg = i * delta; RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation corner_position -= aPad.GetSize() / 2; // Rounding vector + Pad corner offset diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index f43ebabde7..d5077f0d25 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -541,6 +541,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_DELETE_ZONE_CONTAINER: + // Force the main contour selection, to remove the entire zone: + ((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 ); + // Fall through case ID_POPUP_PCB_DELETE_ZONE_CUTOUT: m_canvas->MoveCursorToCrossHair(); { diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 512141d5fc..76ae549a9e 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -29,7 +29,6 @@ */ #include -//#include #include #include #include diff --git a/scripting/build_tools/fix_swig_imports.py b/scripting/build_tools/fix_swig_imports.py index 9fcbdc64c6..e333deb89a 100644 --- a/scripting/build_tools/fix_swig_imports.py +++ b/scripting/build_tools/fix_swig_imports.py @@ -13,7 +13,7 @@ from sys import argv,exit if len(argv)<2: print "usage:" - print " fixswigimports.py file.py" + print " fix_swig_imports.py file.py" print "" print " will fix the swig import code for working inside KiCad" print " where it happended that the external _pcbnew.so/dll was" @@ -52,7 +52,7 @@ if doneOk: print "swig_import_helper fixed for",filename else: print "Error: the swig import helper was not fixed, check",filename - print " and fix this script: fixswigimports.py" + print " and fix this script: fix_swig_imports.py" exit(2) diff --git a/scripts/bom-in-python/README-bom.txt b/scripts/bom-in-python/README-bom.txt index e5be840892..89e10c19a7 100644 --- a/scripts/bom-in-python/README-bom.txt +++ b/scripts/bom-in-python/README-bom.txt @@ -1,7 +1,7 @@ bom_?.py are some python scripts which read a generic xml netlist from eeschema, and create a bom. -All examples use ky_generic_netlist_reader.py, which is a python utility to read +All examples use ky_netlist_reader.py, which is a python utility to read and parse this generic xml netlist and create the corresponding data used to build the bom. @@ -12,3 +12,27 @@ python bom_example?.py See Eeschema doc, chapter 14 for info about the generic xml netlist format, and how to run a script from Eeschema to create a customized netlist or BOM. + +If the python comment +""" + @package + some comments +""" +is added to the begining of the python script, the comment will be displayed +in Eescheam, in the BOM dialog + +For instance: +""" + @package + Generate a HTML BOM list. + Components are sorted and grouped by value + Fields are (if exist) + Ref, Quantity, Value, Part, Datasheet, Description, Vendor +""" + +displays: + Generate a HTML BOM list. + Components are sorted and grouped by value + Fields are (if exist) + Ref, Quantity, Value, Part, Datasheet, Description, Vendor +in BOM dialog diff --git a/scripts/bom-in-python/bom-generation.py b/scripts/bom-in-python/bom-generation.py index c0cda72fd8..9d7d704af7 100644 --- a/scripts/bom-in-python/bom-generation.py +++ b/scripts/bom-in-python/bom-generation.py @@ -4,6 +4,15 @@ # Example: Sorted and Grouped HTML BOM with more advanced grouping # +""" + @package + Generate a HTML BOM list. + Components are sorted and grouped by value + Fields are (if exist) + Ref, Quantity, Value, Part, Datasheet, Description, Vendor +""" + + from __future__ import print_function # Import the KiCad python helper module and the csv formatter @@ -74,8 +83,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: + e = "Can't open output file for writing: " + sys.argv[2] print(__file__, ":", e, file=sys.stderr) - f = stdout + f = sys.stdout # Output a set of rows for a header providing general information html = html.replace('', net.getSource()) diff --git a/scripts/bom-in-python/bom_csv_by_ref.py b/scripts/bom-in-python/bom_csv_by_ref.py index 046272dec4..5fb0f175fa 100644 --- a/scripts/bom-in-python/bom_csv_by_ref.py +++ b/scripts/bom-in-python/bom_csv_by_ref.py @@ -1,8 +1,14 @@ # # Example python script to generate a BOM from a KiCad generic netlist # -# Example: Tab delimited list (The same as std output) Ungrouped -# +""" + @package + Generate a csv list file. + Components are sorted by ref and grouped by value + One component per line + Fields are (if exist) + Ref, Quantity, value, Part, 'footprint', 'Description', 'Vendor' +""" from __future__ import print_function @@ -20,8 +26,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: - print(__file__, ":", e, file=sys.stderr) - f = stdout + e = "Can't open output file for writing: " + sys.argv[2] + print(__file__, ":", e, sys.stderr) + f = sys.stdout # Create a new csv writer object to use as the output formatter, although we # are created a tab delimited list instead! diff --git a/scripts/bom-in-python/bom_csv_by_ref_v2.py b/scripts/bom-in-python/bom_csv_by_ref_v2.py index ccb303e097..c82c3286bb 100644 --- a/scripts/bom-in-python/bom_csv_by_ref_v2.py +++ b/scripts/bom-in-python/bom_csv_by_ref_v2.py @@ -4,6 +4,15 @@ # Example: Ungrouped (One component per row) CSV output # +""" + @package + Generate a csv list file. + Components are sorted by ref and grouped by value + One component per line + Fields are (if exist) + Ref, value, Part, footprint, Datasheet, Manufacturer, Vendor +""" + from __future__ import print_function # Import the KiCad python helper module @@ -20,8 +29,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: - print(__file__, ":", e, file=sys.stderr) - f = stdout + e = "Can't open output file for writing: " + sys.argv[2] + print( __file__, ":", e, sys.stderr ) + f = sys.stdout # Create a new csv writer object to use as the output formatter out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar="\"", quoting=csv.QUOTE_ALL) diff --git a/scripts/bom-in-python/bom_csv_grouped_by_value.py b/scripts/bom-in-python/bom_csv_grouped_by_value.py index 3051b93bba..4d3ddb3b82 100644 --- a/scripts/bom-in-python/bom_csv_grouped_by_value.py +++ b/scripts/bom-in-python/bom_csv_grouped_by_value.py @@ -27,7 +27,7 @@ try: f = open(sys.argv[2], 'w') except IOError: e = "Can't open output file for writing: " + sys.argv[2] - print(__file__, ":", e, file=sys.stderr) + print( __file__, ":", e, sys.stderr ) f = sys.stdout # subset the components to those wanted in the BOM, controlled @@ -46,7 +46,7 @@ columnset = compfields | partfields # union columns = ['Item', 'Qty', 'Reference(s)', 'Value', 'LibPart', 'Footprint', 'Datasheet'] + sorted(list(columnset)) # Create a new csv writer object to use as the output formatter -out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL) +out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL ) # override csv.writer's writerow() to support utf8 encoding: def writerow( acsvwriter, columns ): diff --git a/scripts/bom-in-python/bom_html_by_value.py b/scripts/bom-in-python/bom_html_by_value.py index b4493f5fe4..c8205b0a1b 100644 --- a/scripts/bom-in-python/bom_html_by_value.py +++ b/scripts/bom-in-python/bom_html_by_value.py @@ -4,6 +4,15 @@ # Example: Sorted and Grouped HTML BOM with more advanced grouping # +""" + @package + Generate a HTML BOM list. + Components are sorted and grouped by ref + Fields are (if exist) + Ref, Quantity, Value, Part, Datasheet, Description, Vendor +""" + + from __future__ import print_function # Import the KiCad python helper module and the csv formatter @@ -74,8 +83,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: - print(__file__, ":", e, file=sys.stderr) - f = stdout + e = "Can't open output file for writing: " + sys.argv[2] + print( __file__, ":", e, sys.stderr ) + f = sys.stdout components = net.getInterestingComponents() diff --git a/scripts/bom-in-python/bom_html_grouped_by_value.py b/scripts/bom-in-python/bom_html_grouped_by_value.py index 175191bcc4..b9f7aa05f3 100644 --- a/scripts/bom-in-python/bom_html_grouped_by_value.py +++ b/scripts/bom-in-python/bom_html_grouped_by_value.py @@ -3,6 +3,13 @@ # # Example: Sorted and Grouped HTML BOM # +""" + @package + Generate a HTML BOM list. + Components are sorted by ref and grouped by value + Fields are (if exist) + Ref, Quantity, Value, Part, Datasheet, Description, Vendor +""" from __future__ import print_function @@ -39,8 +46,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: + e = "Can't open output file for writing: " + sys.argv[2] print(__file__, ":", e, file=sys.stderr) - f = stdout + f = sys.stdout components = net.getInterestingComponents() @@ -51,7 +59,8 @@ html = html.replace('', net.getTool()) html = html.replace('', "Component Count:" + \ str(len(components))) -row = "Ref" + "Qnty" +row = "Ref" +row += "Qnty" row += "Value" + "Part" + "Datasheet" row += "Description" + "Vendor" @@ -74,10 +83,11 @@ for group in grouped: c = component row = "" + refs +"" + str(len(group)) - row += "" + c.getValue() + "" + c.getLibName() + ":" - row += c.getPartName() + "" + c.getDatasheet() + "" - row += c.getDescription() + "" + c.getField("Vendor") - row += "" + row += "" + c.getValue() + row += "" + c.getLibName() + ":" + c.getPartName() + row += "" + c.getDatasheet() + row += "" + c.getDescription() + row += "" + c.getField("Vendor")+ "" html = html.replace('', row + "") diff --git a/scripts/bom-in-python/kicad_netlist_reader.py b/scripts/bom-in-python/kicad_netlist_reader.py index 8a01adcd19..c60e4432a9 100644 --- a/scripts/bom-in-python/kicad_netlist_reader.py +++ b/scripts/bom-in-python/kicad_netlist_reader.py @@ -7,6 +7,15 @@ # is due to be deprecated in 3.0+ soon # +""" + @package + Generate a HTML BOM list. + Components are sorted and grouped by value + Fields are (if exist) + Ref, Quantity, Value, Part, Datasheet, Description, Vendor +""" + + from __future__ import print_function import sys import xml.sax as sax diff --git a/scripts/bom-in-python/round_robin.py b/scripts/bom-in-python/round_robin.py index 245f7ad16d..0f15e6f292 100644 --- a/scripts/bom-in-python/round_robin.py +++ b/scripts/bom-in-python/round_robin.py @@ -21,7 +21,8 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: - print( __file__, ":", e, file=sys.stderr) - f = stdout + e = "Can't open output file for writing: " + sys.argv[2] + print( __file__, ":", e, sys.stderr) + f = sys.stdout print(net.formatXML(), file=f) diff --git a/scripts/bom-in-python/round_value_robin.py b/scripts/bom-in-python/round_value_robin.py index 028312fc2a..e1bf3ff5ff 100644 --- a/scripts/bom-in-python/round_value_robin.py +++ b/scripts/bom-in-python/round_value_robin.py @@ -64,8 +64,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1]) try: f = open(sys.argv[2], 'w') except IOError: + e = "Can't open output file for writing: " + sys.argv[2] print(__file__, ":", e, file=sys.stderr) - f = stdout + f = sys.stdout for c in net.components: c.checkvalue()