Commit Graph

194 Commits

Author SHA1 Message Date
Julian Fellinger dcf058d91e added vrml export via python api 2020-08-28 16:41:09 +00:00
Jeff Young 9e12ea9bb6 Cleanup some dead code and make better use of iterators.
Also applies coding style around auto and lambdas.
2020-08-28 11:05:58 +01:00
Mark Roszko 1082402b33 Convert UNDO_REDO_T to an enum class 2020-08-26 18:04:32 +00:00
Ian McInerney e8b11c911e Migrate Pcbnew/footprint viewer/footprint editor to the new UI update system 2020-08-16 19:10:26 +00:00
Jon Evans bd14f8a82a ADDED: New appearance control widget for PcbNew
Featuring:
- Layer view presets
- Per-type opacity for tracks, vias, pads, zones
- Net and netclass color and visibility controls

CHANGED: Simplified object visibilty controls

Fixes https://gitlab.com/kicad/code/kicad/-/issues/1951
Fixes https://gitlab.com/kicad/code/kicad/-/issues/1981
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2003
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2173
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2254
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4325
2020-08-15 15:24:28 -04:00
Qbort b41892e4da Rename class GROUP in pcbnew to PCB_GROUP
Fixes https://gitlab.com/kicad/code/kicad/-/issues/5156
2020-08-12 15:36:08 +01:00
Ian McInerney 47f7c616f8 Fix Python environment variable handling
The variables in the common settings struct are only updated on
save, so Python must use the ones from Pgm to get its values.
This does lead to the observation that Python's changes to the
variables do affect KiCad (they can break resolvers). So apparently
it can mess with us but we can't mess with it easily.

Also, improve the environment variable tracing infrastructure to capture
more changes.
2020-08-12 00:14:19 +01:00
Joshua Redstone ee428876ec ADDED: Group/Ungroup function
This implements the group/ungroup functions to mark a set of EDA_ITEMs as a unit, allowing them to be moved and rotated as a unit
2020-08-11 19:37:07 +00:00
Ian McInerney 0a0ed9e064 Escape all env var strings sent to the Python interpreter
Fixes https://gitlab.com/kicad/code/kicad/issues/5130
2020-08-11 00:51:02 +01:00
qu1ck 1bb6d4e22c Fix pads python api compatibility
* Add GetCustomShapeAsPolygon() to swig wrapper
* Make shared_ptr<SHAPE_POLY_SET> usable for GetEffectivePolygon()

Fixes #4999
2020-08-10 03:22:24 +00:00
Ian McInerney c458b50fd9 Ensure the environment variables are synchronized between KiCad and Python
Before this, the environment variables inside Python wouldn't reflect
the updates to them made after the interpreter was started in Pcbnew.
This will call into Python and set the variables when they are changed,
since Python can't synchronize itself when running in an embedded
interpreter.

Fixes https://gitlab.com/kicad/code/kicad/issues/5071
2020-08-09 19:56:12 +01:00
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