Commit Graph

183 Commits

Author SHA1 Message Date
jean-pierre charras 0c774aa163 Pcbnew: fix a python interface issue ( a not defined constant in some modules).
Was due to incorrect order of definitions in board.i interface.
2020-07-30 10:42:23 +02:00
Jeff Young 7340c97ef9 Undo for schematic-wide operations.
Editing value/footprint fields of multi-unit components.
Find/Change.
Annotation.
Back annotation.

Fixes https://gitlab.com/kicad/code/kicad/issues/2122

Fixes https://gitlab.com/kicad/code/kicad/issues/4869

Fixes https://gitlab.com/kicad/code/kicad/issues/3933

Fixes https://gitlab.com/kicad/code/kicad/issues/4871

Fixes https://gitlab.com/kicad/code/kicad/issues/3899
2020-07-13 12:32:17 +01:00
Jon Evans 4dbbe1cf68 Project settings fixes from review
- Fix file extension for new project
- Fixes for exceptions on MSW
- Fix some ASAN issues
- Allow SETTINGS_MANAGER to run headless
- Don't flag schematic as modified after schematic setup is closed
- Don't automatically unload projects when LoadProject is called
- Don't unload project if it's the same as the current one
- Make sure to properly init/de-init template field names
2020-07-02 22:08:54 -04:00
Jon Evans c0aa6965de Migrate PcbNew project settings to new framework
Various architecture upgrades to support this.
Creating a BOARD now requires a valid PROJECT, which caused
some (mostly transparent) changes to the Python API internals.

ADDED: Project local settings file
CHANGED: Board design settings are no longer stored in PCB file
CHANGED: Net classes are no longer stored in PCB file
CHANGED: Importing board settings now reads boards, not just projects

Fixes https://gitlab.com/kicad/code/kicad/-/issues/2578
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4070
2020-07-02 22:08:54 -04:00
Ian McInerney 52856a8ce4 Move scaled toolbar separator into ACTION_TOOLBAR
* Ensure all separators are scaled separators
* Clean up toolbar creation functions
2020-06-26 21:29:03 +00:00
Jeff Young e376750f62 Flatten CS_PAD_PRIMITIVE out in favour of reusing DRAWSEGMENT.
(In prep for the eventual replacement of DRAWSEGMENT internals with
SHAPE.)
2020-06-24 12:22:42 +01:00
Paul Ewing 40250c427a Expose the footprint library table to Python 2020-06-05 22:21:41 +00:00
Hufo 992a553d43 pcbnew: Refactor D_PAD::AddPrimitives() and allow use from python
Rename all the D_PAD::AddPrimitive methods to clean up their API,
and expose the vector<PAD_CS_PRIMITIVE> type in the python API.
2020-02-27 23:54:19 +00:00
Seth Hillbrand 8c19b4b6ae pcbnew: Adding arcs to PNS
This is allows ARCs in tracks to be synchronized with
the PNS router.  Note this does not yet include the UI components
to route curved traces
2020-02-21 16:11:41 -08:00
Jon Evans 1a216f3703 Change action plugin settings storage to preserve hidden buttons 2020-02-20 11:01:49 -05:00
Jon Evans e59a3d981e Implement a new settings framework across all of KiCad
CHANGED: Settings are now stored in versioned sub-directories
ADDED: First-run dialog for migrating settings from a previous version
CHANGED: Settings are now stored as JSON files instead of wxConfig-style INI files
CHANGED: Color settings are now all stored in a separate settings file
CHANGED: The symbol editor and footprint editor now have their own settings files
CHANGED: Color settings are no longer exposed through BOARD object
CHANGED: Page layout editor now uses Eeschema's color scheme

Settings are now managed through a central SETTINGS_MANAGER held by PGM_BASE.
Existing settings will be migrated from the wxConfig format on first run of each application.
Per-application settings are now stored in one class for each application.
2020-02-19 23:44:56 -05:00
Jon Evans ce4542cced ADDED: Allow exporting IPC-356D netlists from Python 2020-02-04 13:31:56 +00:00
Jeff Young 17710c15d3 Fix leak of empty PICKED_ITEMS_LIST. 2020-01-11 21:29:25 +00:00
Ian McInerney a8d9fcb4e0 Fix event handler type casting
The old methods were very clunky and not recommended (and didn't
properly cast the function types). This changes to useing the
recommended way of declaring events and casting the event handlers.
2020-01-09 18:08:49 +00:00
Ian McInerney 5d46e721e5 pcbnew: Cleanup includes of pcbnew_id.h
* Remove unused IDs from the enum
* Remove the include statements from files that no longer need it
2020-01-03 15:39:05 +00:00
Mark Roszko 19ceb11ae7 Change more enums over to scoped enums 2019-12-28 00:55:11 +00:00
Ian McInerney 7fb56cf9a3 Fix compile error due to enum changes
Merge request !23 changed to strongly typed enums,
so we now need to explicitly cast the output in the
Python getters.
2019-12-20 14:47:41 +00:00
Seth Hillbrand 4d2e953f42 Cleanup: Replace C-only deprecated headers
This replaces headers deprecated by C++14 with their equivalent
replacement
2019-12-05 11:03:15 -08:00
jean-pierre charras 840c77fa9c pcbnew/swig/pcbnew_action_plugins.cpp: fix crash due to broken detection of deleted items after running a script.
the old way was not compatible with the current management if board item lists.
The crash was probably due to double deletions.
Note also the management of undo command in pcbnew_action_plugins needs serious optimization.

Fixes: lp:1844880
https://bugs.launchpad.net/kicad/+bug/1844880
2019-09-23 14:07:45 +02:00
Jeff Young e269b5d1b9 Workaround an issue where a throw terminates (even when there's a catch for it).
You can trigger it before this fix by running Cvpcb when a .kicad_mod file is
incorrectly set as "Legacy" in your footprint table.
2019-08-31 15:18:27 +01:00
Dave Vandenbout 44734dc059 python: Return copy of netclasses not reference
Fix Board.GetAllNetClasses() so it no longer creates a duplicate of the Default netclass in the design rules net classes list.

Fixes: lp:1803623
* https://bugs.launchpad.net/kicad/+bug/1803623
2019-07-06 07:40:33 -07:00
Jeff Young 8f84c3ec4f Grid rid of GetCanvas/GetGalCanvas distinction now that there's only gal. 2019-06-13 19:58:37 +01:00
Jeff Young 5e49517781 Move hotkeys to ACTION architecture. 2019-06-10 23:46:00 +01:00
qu1ck 3cb90063a1 Pcbnew scripting fixes
* Remove infinite recursion calls in footprint.i
* Extend DRAWINGS deque iterator to auto cast contained BOARD_ITEMS,
similar to what dlist implementation did.
2019-06-04 19:29:31 -07:00
Jeff Young 568c8c336b Move DRC control to a tool; move assorted commands to ACTIONS. 2019-06-03 21:08:30 +01:00
Seth Hillbrand 1f30d0c803 pcbnew: remove the last dlist components from pcbnew 2019-06-02 20:06:11 -07:00
Seth Hillbrand 6a45446496 pcbnew: Remove the last dlist from modules/pcbnew 2019-06-01 20:55:32 -07:00
Seth Hillbrand 888c01d11b pcbnew: Move tracks to std::deque 2019-06-01 09:53:23 -07:00
Seth Hillbrand d1877d7c1b Moving modules from DLIST to std::deque 2019-06-01 09:53:23 -07:00
Seth Hillbrand 961b22d603 pcbnew: Changing drawings from dlist to std::deque 2019-06-01 09:51:57 -07:00
Jeff Young 7553cc2651 Clean up some dangling legacy odds and ends. 2019-06-01 01:17:46 +01:00
Jeff Young c2662b0e11 Retire EDA_DRAW_PANEL and legacy_wx/EDA_DRAW_FRAME. 2019-05-31 21:55:30 +01:00
Jeff Young d6e9bdf07b Convert remaining legacy drawing code to print code. 2019-05-31 21:54:22 +01:00
Jeff Young d2daab808c Remove some legacy cursor handling stuff. 2019-05-31 21:54:22 +01:00
Jeff Young a27e4246e0 Move some more menu commands to ACTIONs. 2019-05-29 00:26:29 +01:00
Jeff Young 9d9745b555 Remove more legacy editing code. 2019-05-27 18:47:20 +01:00
Jeff Young 323bb0f8e1 Moving PageLayout editor to GAL canvas and modern toolset. 2019-05-24 19:49:09 +01:00
Wayne Stambaugh 816f6db310 Pcbnew: Python scripting support clean up.
Always check the return value of PyRun_SimpleString() for errors when a
Python script is run and show an error message rather than fail silently.

Enable Python interpreter I/O redirection in debug builds so that script
string errors will be shown when PyRun_SimpleString() is called.

Do not call PyErr_Print() after a PyRun_SimpleString() call failure.  It
doesn't do anything useful.

Do not call Py_Finalize() after a PyRun_SimpleString() call failure.  It
seems to cause Pcbnew to crash.
2019-05-24 07:32:38 -04:00
Andrei Pozolotin 3e4913adce Pcbnew export/import scripting functions.
Discussion can be found at
https://forum.kicad.info/t/pcbnew-export-import-scripting-functions/16343

Fixes lp:1824668

https://bugs.launchpad.net/kicad/+bug/1824668
2019-05-04 09:55:25 -04:00
Jeff Young dae41b7460 Remove legacy segment-based zones.
Give the user the option of cancelling a file open if there are
segment zones; otherwise they're converted to polygon fills.

Fixes: lp:1823087
* https://bugs.launchpad.net/kicad/+bug/1823087
2019-04-12 20:19:23 +01:00
Seth Hillbrand b426b9e784 pcbnew: Re-add missing user units python
When moving user user units out of the global, we missed that Python
calls were using it.  This re-adds a function to retrieve user units
allowing the python scripts to show users dialogs in their preferred
units.
2019-02-19 10:52:39 -08:00
Seth Hillbrand ff9d814fbd Fix unused vars in wxpython3 2019-01-24 21:25:39 -08:00
Seth Hillbrand 8b060799eb python: Fix Phoenix app setting
Phoenix doesn't have the same initialization as wxpython3 and so the
namespace doesn't get the wxApp() initialized to the existing instance.
In python, this is worked around by starting a new wxApp.
Unfortunately, this appears to overwrite the existing global instance
variable.  The issue _appears_ to be in Phoenix but for now we work
around it by saving and resetting the instance pointer in the main app.
The downside is that Python likely won't be able to respond to events
from C++

Fixes: lp:1809913
* https://bugs.launchpad.net/kicad/+bug/1809913
2019-01-24 19:41:07 -08:00
jean-pierre charras a18c7496bb Ensure compatibility with "old" pythons scripts after renaming SetUseGerberAttributes() to SetUseGerberX2format() 2018-12-09 08:38:23 +01:00
Seth Hillbrand 2a574c4f65 pcbnew: Synchonize net info when loading via python
When loading the load using the UI, netclasses and net info are
synchronized to the board object after parsing the file.  This needs to
happen automatically when loading the board via the Python interface as
well.

Fixes: lp:1806506
* https://bugs.launchpad.net/kicad/+bug/1806506
2018-12-03 17:05:18 -08:00
Thomas Pointhuber 0e0b4d52a2 Add initial support for Phoenix (new wxPython binding)
Based on the work of @mmccoo:
https://kicad.mmccoo.com/2017/11/23/learnings-from-moving-kicad-to-wxpython-4-0/
and this additional patchset to remove wxpy_api.h dependency:
http://mmccoo.com/random/0001-Remove-dependence-on-pywx_api.h.patch

Please note CreatePythonShellWindow changed quite a lot. Throughful testing
should be made for the old as well as new wxPython version on all platforms
2018-10-26 13:21:11 +02:00
Thomas Pointhuber e39eeb2f92 Remove debug printf and fix indentation inside of block 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 95e55eb17a Fix coding style issue (space after if) 2018-10-19 09:59:06 +02:00
Thomas Pointhuber e09785db1d Introduce PyStringToWx helper to remove code duplication 2018-10-19 09:59:06 +02:00
Thomas Pointhuber ce471ec898 Fix braces 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 6ac444f587 Fix style issue 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 8bf1954625 NoneType was incorrectly passed to PyString_AsString
The implementation relied on the fact that PyString_AsString is returning NULL
for invalid inputs (and causing an error condition), which is then fixed by the
call to FROM_UTF8. Now, we will simply return an empty string if Py_None is
returned by a python fuction, which resemebles the old behaviour of those methods
2018-10-19 09:59:06 +02:00
Thomas Pointhuber 0812f71bd3 Fix builtins import in Python3 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 22e5e52598 Fix warning: 'HAVE_CLOCK_GETTIME' macro redefined 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 7365cb8e52 Get Exception handling working with Python 3
The old way to get the full stacktrace was incorrect, and does not work
with Python 3:
https://stackoverflow.com/questions/3702675/how-to-print-the-full-traceback-without-halting-the-program#comment84297600_33723119
2018-10-19 09:59:06 +02:00
Thomas Pointhuber 88d04f3bcb Get Action Plugins working with Python 3, fix some unicode string errors 2018-10-19 09:59:06 +02:00
Thomas Pointhuber 8805706ccb Fix incompatibilites between Python 2 and Python 3 2018-10-19 09:59:05 +02:00
Thomas Pointhuber e9da6811a6 Fix initialisation of the pcbnew python module 2018-10-19 09:59:05 +02:00
Thomas Pointhuber 284904b72c Rewrite C extensions to also support Python 3 2018-10-19 09:59:05 +02:00
Seth Hillbrand 4460313104 pcbnew: Separating connectivity to subdir 2018-10-12 16:31:09 -07:00
Jeff Young 732e0b0bf8 Remove extra rebuild of toolbar.
It's called from CommmonSettingsChanged() anyway.
2018-10-11 18:53:00 +01:00
Seth Hillbrand b3a5e08c2f pcbnew: Rename PCB_ZONE_T and remove from connectivity
SEGZONE types were confusingly named PCB_ZONE_T.  Zones in pcbnew are
now _only_ PCB_ZONE_AREA_T, so we name segzone types PCB_SEGZONE_T to be
clear.

This also removes processing of the SEGZONEs from connectivity
calculations.
2018-09-29 15:09:15 -07:00
qu1ck c68ad411ff pcbnew: add 3d models properties to swig
Fixes: lp:1758858

https://bugs.launchpad.net/kicad/+bug/1758858
2018-09-08 10:28:55 -04:00
qu1ck 72f87861bb pcbnew: Add toolbar buttons for action plugins
Allows optional toolbar buttons for action plugins.
2018-08-26 19:39:27 -07:00
Seth Hillbrand 42c5017db7 PCBNEW: Re-add missing SWIG zone filler
Zone filler was factored out into a separate header.  To allow python
access to zone filling, we need to include the revised signatures.
2018-08-08 12:25:58 -07:00
jean-pierre charras fc6547f5c0 Make gerber job file writer accessible by Python scripts 2018-08-01 16:32:37 +02:00
jean-pierre charras c585964da9 fix coding style issues. 2018-07-17 19:55:33 +02:00
Baranovskiy Konstantin 5e1605af19 Values of argc and argv transfers to python environment. 2018-07-08 08:10:44 +02:00
jean-pierre charras 6d77e594b5 Python binding: fix pcbnew.Refresh() to make a better re-initialization.
Minor fixes in comments.

Fixes: lp:1775003
https://bugs.launchpad.net/kicad/+bug/1775003
2018-06-07 10:04:29 +02:00
jean-pierre charras 6090f9001e netinfo.i: fix incorrect position of a declaration, that was not taken in account.
Fixes: lp:1544750
https://bugs.launchpad.net/kicad/+bug/1544750
2018-05-24 09:43:04 +02:00
jean-pierre charras b94e0a2031 Fix forgotten change (m_Zone to m_SegZoneDeprecated) 2018-05-13 09:19:44 +02:00
jean-pierre charras ccce376e33 Refinements for commit 986b904
(Add comments and a minor fix)
2018-04-27 16:01:59 +02:00
jean-pierre charras 986b90424b Fix an issue in LoadPlugins(bundlepath=None) python method (Windows specific).
For some obscure (for me) reason, the path separators in bundlepath are seen as escape seq, and the path can be incorrectly handled
(when \n or \r are found in this string).
it happens only for this path, not for other paths in LoadPlugins.
For bundlepath parameter, unix separator is now used.

Fixes: lp:1766879
https://bugs.launchpad.net/kicad/+bug/1766879
2018-04-27 14:04:24 +02:00
Seth Hillbrand 7d3d9f7188 Wrapping left-over debug printf() in DBG() 2018-03-30 16:17:29 -07:00
Miles McCoo 9d98fe1b80 Fix for crash due to pcbnew_action_plugin object tracking
pcbnew_action_plug tracks items that were modified within a plugin. In the case of
deletion, the old object is no longer valid. This commit turns off the call to delete
if a plugin is active.
2018-03-13 10:19:39 +01:00
jean-pierre charras de72ef8518 Fix code after renaming files 2018-02-16 20:27:57 +01:00
jean-pierre charras 35a7f7a7b4 rename files: replace module by footprint in dialog filenames 2018-02-16 20:27:14 +01:00
Damien Espitallier a04965c36c Enable exception handler for python LoadBoard function 2018-02-10 18:34:20 -05:00
jean-pierre charras 1858852f57 rename files 2018-02-02 21:57:12 +01:00
jean-pierre charras 6d6ef0097b Fix code after renaming files. Minor other fix. 2018-01-30 20:23:35 +01:00
jean-pierre charras b43dc7954c fix code after renaming files 2018-01-30 15:34:09 +01:00
jean-pierre charras 342197bb3e fix forgotten code change after renaming 2018-01-30 08:13:33 +01:00
jean-pierre charras 30e3f2e781 fix forgotten change after renaming files 2018-01-29 17:34:12 +01:00
jean-pierre charras ac0dd118fd fix compil issue in swig interface. 2018-01-28 20:03:46 +01:00
Miles McCoo 5cc1cda29f BuildConnectivity and re-DisplayBoard in python Refresh function
Refresh is used in the python domain to refresh the display with the current
design. If something has changed, board connectivity likely needs rebuilding.
If using GAL canvas, update its display db.
2017-12-22 08:59:19 -05:00
Maciej Suminski d205366da7 Add support for wchar_t to SWIG 2017-12-08 18:04:51 +01:00
Miles McCoo d16a5c1d6c Changes to python interface enabling net->pads access.
Added new file connectivity.i to expose CONNECTIVITY_DATA to
python. enables access to d_pads from nets.

Added typemap to board_connected_item.i. since board_connected_item
doesn't use virtual inheritance, when returning a std::list of these
items, the typemap populates the return list with the child
types. This enables python scripts to use the full interface of those
classes (pad, track, zone)

Added typeinfo.i to enable passing a list of KICAD_T values to methods
GetNetItems. This list acts as a query filter. typeinfo.i is included
from pcbnew.i right after kicad.i (instead of in board.i like the
others) typeinfo.h is already being included kicad.i so to ensure the
typemap(s) are properly applied I put them next to each other.

The two new files (typeinfo.i and connectivity.i) were added to
pcbnew's CMakeLists.txt as dependencies.
2017-11-23 17:35:39 +01:00
Henner Zeller ff5ee05def Fix Python scripting bug when saving board to file. 2017-11-18 11:00:24 -05:00
jean-pierre charras 00bb00016b Fix a forgotten change. 2017-11-16 16:22:12 +01:00
Tomasz Włostowski 9932ff32ae refactoring: wrapped boost::optional in OPT<> class for the purpose of easier transition to C++17 in the future 2017-11-03 23:59:02 +01:00
Tomasz Włostowski b945d2a708 cleanup: replace CLASS_MIRE with CLASS_PCB_TARGET for naming clarity 2017-11-03 20:02:06 +01:00
Russell Oliver 3b0855d204 Eagle Project Import: Code cleanup and documentation.
- Also makes the project and file import functions filetype dependent.
- The change from IO_MGR::KICAD to IO_MGR::KICAD_SEXP removes a conflict from a compile definition for KICAD when compiling kicad/import_project.cpp
2017-10-20 08:58:40 +02:00
jean-pierre charras cb3d28f11b define SetPadName() and GetPadName() (old name of D_PAD::SetName() and GetName()) for compatibility with existing python scripts 2017-10-09 09:58:15 +02:00
Maciej Suminski cca63801bf Renamed D_PAD::{Set,Get}PadName() to D_PAD::{Set,Get}Name() 2017-09-19 18:23:50 +02:00
jean-pierre charras a557838c61 Fix incorrect refresh of User Interface after running an action plugin, and add comments 2017-08-27 08:13:35 +02:00
jean-pierre charras 4d0c1577d2 Fix Pcbnew Python: LoadBoard does not rebuild connectivity database, and later, SaveBoard does not save net class memberships
Fixes: lp:1711268
https://bugs.launchpad.net/kicad/+bug/1711268
2017-08-17 18:00:34 +02:00
jean-pierre charras bafb8c3688 Add old python method FootprintEnumerate which did not word after changes in C++ code 2017-06-29 20:43:39 +02:00
Maciej Suminski 37f8c83c5b Fix the BOARD & MODULE classes SWIG interface 2017-06-26 18:28:23 +02:00
Maciej Suminski 3aaf26da2e Fixes for pcbnew_scripting_helpers.cpp 2017-06-23 19:22:27 +02:00
Tomasz Włostowski d8018ded0b fix build with Python 2017-06-23 11:12:37 +02:00