From db174862c89300936b03c9ef21e9bb1a716f30a5 Mon Sep 17 00:00:00 2001 From: Miles McCoo Date: Fri, 17 Mar 2017 10:41:00 -0400 Subject: [PATCH] Minor Pcbnew Python scripting improvements. Add typedef for wxCoord to wx.i to enable usage of methods like EDA_RECT.Inflate. Added id.h to pcbnew.i to expose window toolbar identifier names. Added Refresh() and WindowZoom() to pcbnew_scripting_helper. --- common/swig/wx.i | 4 ++++ pcbnew/swig/pcbnew.i | 1 + pcbnew/swig/pcbnew_scripting_helpers.cpp | 19 +++++++++++++++++-- pcbnew/swig/pcbnew_scripting_helpers.h | 4 +++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/common/swig/wx.i b/common/swig/wx.i index dddd68391b..9f74deee2d 100644 --- a/common/swig/wx.i +++ b/common/swig/wx.i @@ -39,6 +39,10 @@ void wxSetDefaultPyEncoding(const char* encoding); const char* wxGetDefaultPyEncoding(); +// wxCoord ///////////////////////////////////////////////////////// +// need to let swig know that wxCoord is an int. Ref: wx/defs.h +typedef int wxCoord; + // wxRect class wrapper /////////////////////////////////////////////////////// diff --git a/pcbnew/swig/pcbnew.i b/pcbnew/swig/pcbnew.i index 6e9997c8d9..ddfc1516b4 100644 --- a/pcbnew/swig/pcbnew.i +++ b/pcbnew/swig/pcbnew.i @@ -104,6 +104,7 @@ HANDLE_EXCEPTIONS(PLUGIN::FootprintDelete) %include %include %include +%include %include diff --git a/pcbnew/swig/pcbnew_scripting_helpers.cpp b/pcbnew/swig/pcbnew_scripting_helpers.cpp index 62b21b3df1..12ed46fdc7 100644 --- a/pcbnew/swig/pcbnew_scripting_helpers.cpp +++ b/pcbnew/swig/pcbnew_scripting_helpers.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * Copyright (C) 1992-2012 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 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -92,7 +93,7 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard, wxString header; PROPERTIES props; - if( aFormat==IO_MGR::LEGACY ) + if( aFormat == IO_MGR::LEGACY ) { header = wxString::Format( wxT( "PCBNEW-BOARD Version %d date %s\n\n# Created by Pcbnew%s scripting\n\n" ), @@ -107,3 +108,17 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard, #endif return true; } + + +void Refresh() +{ + // first argument is erase background, second is a wxRect + PcbEditFrame->GetCanvas()->Refresh( true, NULL ); +} + + +void WindowZoom( int xl, int yl, int width, int height ) +{ + EDA_RECT Rect( wxPoint( xl, yl ), wxSize( width, height )) ; + PcbEditFrame->Window_Zoom( Rect ); +} diff --git a/pcbnew/swig/pcbnew_scripting_helpers.h b/pcbnew/swig/pcbnew_scripting_helpers.h index bff3d0e133..d5e31a067b 100644 --- a/pcbnew/swig/pcbnew_scripting_helpers.h +++ b/pcbnew/swig/pcbnew_scripting_helpers.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo - * Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2013-2017 KiCad Developers, see CHANGELOG.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 @@ -43,5 +43,7 @@ BOARD* LoadBoard( wxString& aFileName ); bool SaveBoard( wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat ); bool SaveBoard( wxString& aFileName, BOARD* aBoard ); +void Refresh(); +void WindowZoom( int xl, int yl, int width, int height ); #endif