Commit graph

60 commits

Author SHA1 Message Date
jaseg
a7a5981e0e Make primitives with unset level polarity inherit from region
This fixes region rendering with programatically generated primitives
such that clear level polarity works in an intuitive way. This is useful
for e.g. cutouts in regions. Before, the renderer would set level
polarity twice, both when starting the region and then again once for
each region primitive (line or arc). The problem was that the primitives
in a region with "clear" polarity would when constructed with unset
polarity default to "dark". Thus the renderer would emit something like
LPC (clear polarity) -> G36 (start region) -> LPD (dark polarity) ->
{lines...} instead of LPC -> G36 -> {lines...}.

After this commit, Line and Arc will retain None as level polarity when
created with unset level polarity, and region rendering will override
None with the region's polarity. Outside regions, the old dark default
remains unchanged.

Note on verification: Somehow, gEDA gerbv would still render the broken
regions the way one would have intended, but other viewers (KiCAD
gerbview, the online EasyEDA one and whatever JLC uses to make their
silkscreens) would not.
2019-02-03 14:37:26 +09:00
jaseg
b87629c2ae Add hole support to ADParamStmt.rect 2017-11-25 16:14:23 +01:00
Hamilton Kibbe
c70ece73ea Add support for square holes in basic primitives 2016-11-18 07:56:51 -05:00
Hamilton Kibbe
422c86bcc6 Merge upstream changes 2016-11-06 14:44:40 -05:00
Hamilton Kibbe
724c2b3bce Finish Merge, most tests passing 2016-11-05 20:56:47 -04:00
Hamilton Kibbe
5af19af190 Commit partial merge so I can work on the plane 2016-09-24 02:28:36 +08:00
Hamilton Kibbe
8cd842a41a Manually mere rendering changes 2016-08-06 09:40:40 +08:00
Garret Fick
965d3ce23b Add more tests for rendering to PNG. Start adding tests for rendering to Gerber format. Changed definition of no hole to use None instead of 0 so we can differentiate when writing to Gerber format. Makde polygon use hole diameter instead of hole radius to match other primitives 2016-07-24 22:08:31 +08:00
Garret Fick
7cd6acf126 Add many render tests based on the Umaco gerger specification. Fix multiple rendering bugs, especially related to holes in flashed apertures 2016-07-24 17:08:47 +08:00
Garret Fick
9b0d3b1122 Fix issue with chaning region mode via flash. Add options for controlling output from rendered gerber 2016-07-10 15:07:17 +08:00
Garret Fick
b140f5e476 Don't flash G03-only commands 2016-06-28 23:15:20 +08:00
Garret Fick
ccb6eb7a76 Add support for polygon apertures 2016-06-25 16:46:44 +08:00
Paulo Henrique Silva
49dadd46ee Fix AMParamStmt to_gerber to write changes back.
AMParamStmt was not calling to_gerber on each of its primitives
on his own to_gerber method. That way primitives that changes after reading,
such as when you call to_inch/to_metric was failing because it was
writing only the original macro back.
2016-05-28 12:39:05 +08:00
Garret Fick
c9c1313d59 Fix units statement. Keep track of original macro statement in the AMGroup 2016-05-28 12:36:31 +08:00
Garret Fick
74c638c718 Fix issue where did not always switch into the G01 mode after G03 when the point was unchanged 2016-05-19 23:19:28 +08:00
Garret Fick
20a9af279a More rendering of AMGroup to statements 2016-03-01 00:06:14 +08:00
Garret Fick
223a010831 Fix critical issue with rotatin points (when the angle is zero the y would be flipped). Render AM with outline to gerber 2016-02-27 18:18:04 +08:00
Garret Fick
29c0d82bf5 RS274X backend for rendering. Incompelte still 2016-02-27 15:24:36 +08:00
Hamilton Kibbe
5476da8aa3 Fix a bunch of rendering bugs.
- 'clear' polarity primitives no longer erase background
  - Added aperture macro support for polygons
  - Added aperture macro rendring support
  - Renderer now creates a new surface for each layer and merges them instead of working
    directly on a single surface
  - Updated examples accordingly
2016-01-21 03:57:44 -05:00
Garret Fick
4a815bf25d First time any macro renders 2015-12-30 14:05:00 +08:00
Paulo Henrique Silva
2e2b4e49c3 Fix AMParamStmt to_gerber to write changes back.
AMParamStmt was not calling to_gerber on each of its primitives
on his own to_gerber method. That way primitives that changes after reading,
such as when you call to_inch/to_metric was failing because it was
writing only the original macro back.
2015-11-23 16:04:25 -02:00
Paulo Henrique Silva
d3b19efb48 Add support for PCBmodE generated files.
PCBmodE uses a standard but probably undefined behaviour issue
on Gerber where it defines circle apertures with a single modifier
but leaves a trilling 'X' after it. 'X' is modifiers separator but
when there is only one modifier the behaviour is undefined.

For parsing we are just ignoring blank modifiers.

Test updated to catch this case.
2015-05-20 16:20:02 -03:00
Hamilton Kibbe
8ec3077be9 Add checks to ensure statement unit conversions are idempotent 2015-05-16 09:45:34 -04:00
Paulo Henrique Silva
51c630ab77 AMStatement are used as is when gerbers are generated 2015-04-14 23:27:11 -03:00
Paulo Henrique Silva
d7ce97b180 (really) Fix parsing for AM macros with zero modifiers 2015-04-07 18:55:12 -03:00
Paulo Henrique Silva
50c01d4635 Fix CommentStmt for multi-line comments 2015-04-07 18:27:31 -03:00
Paulo Henrique Silva
d1c74317c8 Add some deprecated but still found statements 2015-04-07 18:26:33 -03:00
Paulo Henrique Silva
bbfa66eb38 Small change on __str__ for SF Statement 2015-04-07 18:25:44 -03:00
Paulo Henrique Silva
9ab4ec360c Fix parsing for AM macros with zero modifiers 2015-04-07 18:24:47 -03:00
Paulo Henrique Silva
b93804ed9a Add unspecified FS D leading zeros format
FS D leading zero format (probably form Direct) is an unspecified
coordinate format where all numbers are specified with both leading
and trailing zeros.
2015-04-07 18:22:02 -03:00
Paulo Henrique Silva
a13b981c1c Fix tests for macros with no variables.
All AM*Primitive classes now handles float for all but the code
modifiers. This simplifies the reading/parsing.
2015-03-05 14:43:30 -03:00
Paulo Henrique Silva
670d3fbbd7 Add aperture macro parsing and evaluation.
Aperture macros can get complex with arithmetical operations,
variables and variables substitution.

Current pcb-tools code just read each macro block as an independent
unit, this cannot deal with variables that get changed after used.

This patch splits the task in two: first we parse all macro content
and creates a bytecode representation of all operations. This bytecode
representation will be executed when an AD command is issues passing
the required parameters.

Parsing is heavily based on gerbv using a Shunting Yard approach to
math parsing.

Integration with rs274x.py code is not finished as I need to figure out
how to integrate the final macro primitives with the graphical primitives
already in use.
2015-03-03 03:41:55 -03:00
Hamilton Kibbe
5966d7830b Add offset operation 2015-02-18 23:13:23 -05:00
Hamilton Kibbe
e71d7a24b5 Python 3 tests passing 2015-02-18 21:14:30 -05:00
Hamilton Kibbe
288ac27084 Get unit conversion working for Gerber/Excellon files
Started operations module for file operations/transforms
2015-02-18 04:31:23 -05:00
Hamilton Kibbe
5cf1fa74b4 Tests and bugfixes 2015-02-15 02:20:02 -05:00
Hamilton Kibbe
41f9475b13 Tests and bugfixes 2015-02-09 17:39:24 -05:00
Paulo Henrique Silva
e38071868a Fix copy-paste error on ASParamStmt 2015-02-08 00:29:08 -02:00
Hamilton Kibbe
f98b918634 Added some Aperture Macro Primitives. Moved AM primitives to seperate file 2015-02-02 20:03:26 -05:00
Hamilton Kibbe
1cc20b351c tests 2015-02-02 11:42:47 -05:00
Hamilton Kibbe
208149d676 merge upstream changes 2015-01-26 22:24:45 -05:00
Hamilton Kibbe
c054136a65 Added some tests 2015-01-26 22:17:09 -05:00
Paulo Henrique Silva
a9b5a17c53 Fix Mirror (deprecated) param generation 2015-01-14 14:30:53 -02:00
Paulo Henrique Silva
cbb662491c Refactor AM aperture handling and add unit conversion support
* Add support to convert between metric/impertial
* AM primitives are now properly created and can be
  converted between metric/imperial.
  (only Outline primitive is supported, no rendering yet)
2015-01-14 03:15:52 -02:00
Paulo Henrique Silva
be5b94b8c0 Fix parsing for OrCAD.
* Modify the way we parse parameters to allow more than
  one parameter in a single line as in the following example:

  %FSLAX55Y55*MOIN*%
  %IR0*IPPOS*OFA0.00000B0.00000*MIA0B0*SFA1.00000B1.00000*%

  (this is from OrCAD 16 default output)

* Add missing deprecated parameters.

* Change API to use given FileSettings on output. This allows
  us to use pcb-tools to convert between FS formats.
2014-12-15 23:44:12 -02:00
Hamilton Kibbe
29deffcf77 add ipc2581 primitives 2014-12-05 23:59:28 -05:00
Paulo Henrique Silva
ab69ee0172 Bunch of small fixes to improve Gerber read/write. 2014-11-10 12:24:09 -02:00
Paulo Henrique Silva
459e0205d1 Fix ValueError, missing self. 2014-10-26 22:25:26 -02:00
Hamilton Kibbe
4f076d7b76 Merge aperture fixses from upstream 2014-10-26 17:59:57 -04:00
Hamilton Kibbe
18e3b87625 Test update 2014-10-19 22:23:00 -04:00