From 02fa9639cd8bedb5eefb3b3747d51cd19dd15bcb Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 4 Jan 2017 15:03:43 +0100 Subject: [PATCH] DIALOG_FOOTPRINT_WIZARD_LIST: minor enhancement. qrcode_footprint_wizard.py: use filled polygons instead of square pads on silkscren layer. --- .../dialogs/dialog_footprint_wizard_list.cpp | 15 ++++---- .../dialog_footprint_wizard_list_base.cpp | 9 ++--- .../dialog_footprint_wizard_list_base.fbp | 6 ++-- .../dialog_footprint_wizard_list_base.h | 4 +-- pcbnew/footprint_wizard_frame.cpp | 2 +- pcbnew/python/plugins/FootprintWizardBase.py | 2 +- .../python/plugins/qrcode_footprint_wizard.py | 35 +++++++++++++++---- 7 files changed, 49 insertions(+), 24 deletions(-) diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index c9c221a5cf..466d205057 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2014 Miguel Angel Ajo - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -36,7 +36,8 @@ enum FPGeneratorRowNames { - FP_GEN_ROW_NAME = 0, + FP_GEN_ROW_NUMBER = 0, + FP_GEN_ROW_NAME, FP_GEN_ROW_DESCR, }; @@ -61,15 +62,17 @@ DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent ) m_footprintGeneratorsGrid->InsertRows( 0, n_wizards, true ); // Put all wizards in the list - for( int i=0; iGetName(); wxString description = wizard->GetDescription(); wxString image = wizard->GetImage(); - m_footprintGeneratorsGrid->SetCellValue( i, FP_GEN_ROW_NAME, name ); - m_footprintGeneratorsGrid->SetCellValue( i, FP_GEN_ROW_DESCR, description ); + m_footprintGeneratorsGrid->SetCellValue( ii, FP_GEN_ROW_NUMBER, num ); + m_footprintGeneratorsGrid->SetCellValue( ii, FP_GEN_ROW_NAME, name ); + m_footprintGeneratorsGrid->SetCellValue( ii, FP_GEN_ROW_DESCR, description ); } diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list_base.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list_base.cpp index 73641f7817..eb901b1978 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list_base.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -19,7 +19,7 @@ DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow* m_footprintGeneratorsGrid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid - m_footprintGeneratorsGrid->CreateGrid( 0, 2 ); + m_footprintGeneratorsGrid->CreateGrid( 0, 3 ); m_footprintGeneratorsGrid->EnableEditing( false ); m_footprintGeneratorsGrid->EnableGridLines( true ); m_footprintGeneratorsGrid->EnableDragGridSize( false ); @@ -31,8 +31,9 @@ DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow* m_footprintGeneratorsGrid->EnableDragColMove( false ); m_footprintGeneratorsGrid->EnableDragColSize( true ); m_footprintGeneratorsGrid->SetColLabelSize( 20 ); - m_footprintGeneratorsGrid->SetColLabelValue( 0, _("Name") ); - m_footprintGeneratorsGrid->SetColLabelValue( 1, _("Description") ); + m_footprintGeneratorsGrid->SetColLabelValue( 0, wxEmptyString ); + m_footprintGeneratorsGrid->SetColLabelValue( 1, _("Name") ); + m_footprintGeneratorsGrid->SetColLabelValue( 2, _("Description") ); m_footprintGeneratorsGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); // Rows diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list_base.fbp b/pcbnew/dialogs/dialog_footprint_wizard_list_base.fbp index 02901a7776..a59028dd93 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list_base.fbp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list_base.fbp @@ -44,7 +44,7 @@ 400,200 DIALOG_FOOTPRINT_WIZARD_LIST_BASE - 501,273 + 554,286 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Footprint Generators @@ -121,9 +121,9 @@ 1 wxALIGN_LEFT 20 - "Name" "Description" + "" "Name" "Description" wxALIGN_CENTRE - 2 + 3 160,325 1 diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list_base.h b/pcbnew/dialogs/dialog_footprint_wizard_list_base.h index 0d8c48cdfe..c19ce02bbe 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list_base.h +++ b/pcbnew/dialogs/dialog_footprint_wizard_list_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version May 6 2016) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -48,7 +48,7 @@ class DIALOG_FOOTPRINT_WIZARD_LIST_BASE : public DIALOG_SHIM public: - DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint Generators"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 501,273 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint Generators"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 554,286 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_FOOTPRINT_WIZARD_LIST_BASE(); }; diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index dbe617b8dc..3428c8094a 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -387,7 +387,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() if( units == WIZARD_PARAM_UNITS_BOOL ) { wxGridCellBoolEditor *boolEditor = new wxGridCellBoolEditor; - boolEditor->UseStringValues("True","False"); + boolEditor->UseStringValues( "1", "0" ); m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, boolEditor ); m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer ); } diff --git a/pcbnew/python/plugins/FootprintWizardBase.py b/pcbnew/python/plugins/FootprintWizardBase.py index 6a57ac1fe4..e0305e2f76 100644 --- a/pcbnew/python/plugins/FootprintWizardBase.py +++ b/pcbnew/python/plugins/FootprintWizardBase.py @@ -457,7 +457,7 @@ class FootprintWizardDrawingAids: The transform matrix is applied Note that this won't work properly if the result is not a - circular arc (eg a horzontal scale) + circular arc (eg a horizontal scale) """ circle = pcbnew.EDGE_MODULE(self.module) circle.SetWidth(self.dc['lineThickness']) diff --git a/pcbnew/python/plugins/qrcode_footprint_wizard.py b/pcbnew/python/plugins/qrcode_footprint_wizard.py index f4858ea150..af3b512427 100644 --- a/pcbnew/python/plugins/qrcode_footprint_wizard.py +++ b/pcbnew/python/plugins/qrcode_footprint_wizard.py @@ -13,6 +13,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. +# last change: 2017, Jan 4. + import pcbnew import FootprintWizardBase @@ -22,7 +24,7 @@ import qrcode class QRCodeWizard(FootprintWizardBase.FootprintWizard): GetName = lambda self: '2D Barcode QRCode' - GetDescription = lambda self: 'QR Code' + GetDescription = lambda self: 'QR Code barcode generator' GetReferencePrefix = lambda self: 'QR***' GetValue = lambda self: self.module.Value().GetText() @@ -56,8 +58,26 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): self.qr.addData(str(self.Barcode)) self.qr.make() + def drawSquareArea( self, layer, size, xposition, yposition): + # creates a EDGE_MODULE of polygon type + polygon = pcbnew.EDGE_MODULE(self.module) + polygon.SetShape(pcbnew.S_POLYGON) + polygon.SetWidth( 0 ) + polygon.SetLayer(layer) + clist = polygon.GetPolyPoints(); + halfsize = size/2 + pos = pcbnew.wxPoint(xposition, yposition) + clist.push_back( pcbnew.wxPoint( halfsize, halfsize ) + pos ) + clist.push_back( pcbnew.wxPoint( halfsize, -halfsize ) + pos ) + clist.push_back( pcbnew.wxPoint( -halfsize, -halfsize ) + pos ) + clist.push_back( pcbnew.wxPoint( -halfsize, halfsize ) + pos ) + polygon.SetPolyPoints(clist) + return polygon + + def _drawPixel(self, xposition, yposition): - # build a rectangular pad: as a dot + # build a rectangular pad as a dot on copper layer, + # and a polygon (a square) on silkscreen pad = pcbnew.D_PAD(self.module) pad.SetSize(pcbnew.wxSize(self.X, self.X)) pad.SetShape(pcbnew.PAD_SHAPE_RECT) @@ -66,12 +86,13 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): if self.UseCu: layerset.AddLayer(pcbnew.F_Cu) layerset.AddLayer(pcbnew.F_Mask) + pad.SetLayerSet( layerset ) + pad.SetPosition(pcbnew.wxPoint(xposition,yposition)) + pad.SetPadName("1") + self.module.Add(pad) if self.UseSilkS: - layerset.AddLayer(pcbnew.F_SilkS) - pad.SetLayerSet( layerset ) - pad.SetPosition(pcbnew.wxPoint(xposition,yposition)) - pad.SetPadName("1") - self.module.Add(pad) + polygon=self.drawSquareArea(pcbnew.F_SilkS, self.X, xposition, yposition) + self.module.Add(polygon) def BuildThisFootprint(self):