← Back to team overview

kicad-developers team mailing list archive

[PATCH] Plotting and exporting from nanometers and PDF plotter


At last the big patch. It includes about a work of week so it's somewhat
big; it contains also the previous patch (reason: there where commits on
trunk in between and it was difficult to exclude them... I'm not so
fluent with bzr). Anyway, apply it against today's bzr.

What contains:

- Plotter members renames to FunctionName

- DPOINT based internal plot coordinates (users always use IUs)

- Some refactoring and lot of new markers

- The DXF plotter can optionally export text as TEXT entities instead of
  stroked path (look for SetDXFTextMode)

- The DXF file is exported in millimeters of decimils

- The default PlotImage behaviour (a rectangle) was moved in the base

- Same for the SetLayerPolarity method

- The PS_PLOTTER was broken in PSLIKE_PLOTTER and the PS_PLOTTER proper,
  to correctly factor in PDF support

- Postscript dashed lines were fixed:P

- A whole new PDF plotting engine, which is 100% compatible with the
  postscript one (derived from the PSLIKE_PLOTTER). It can also do
  multipage 'plots' and each page can be of different size. It also
  supports the PlotImage method

- Both PDF and Postscript PlotImage methods turn the image to grayscale
  when BW mode is active

- Support for native Postscript text. It uses Helvetica instead of the
  builtin stroke font. Native text handles all the alignments, the
  mirror function, the four styles (regular, bold, oblique,
  bold-oblique) and the ~ overline formatting; for obvious reasons trace
  width is not supported. Also only Latin-1 repertoire is handled by the
  Helvetica fonts. Metrics are different so maybe some fudge factor
  would be useful to match them with the stroked text

- Stroked and native text can be combined in 3 different ways (both for
  PS and PDF), set by SetPsTextMode. See the attached file to see how an
  assembly plot could be searched (in both PSTEXTMODE_NATIVE and

  PSTEXTMODE_STROKE: only draws stroked text (previous behaviour)

  PSTEXTMODE_NATIVE: only draws native (Helvetica) text (which can be
  searched/selected in a PDF file, for example)

  PSTEXTMODE_PHANTOM: draws stroked text (to obtain wysiwyg plotting)
  and 'hidden' helvetica text to aid in searching: postscript doesn't
  support invisible text so it's handled with a pixel wide string; PDF
  uses rendermode 3 so even the highlight box is at least plausible

- As a demonstration of multipage support I cloned the plot PS dialog
  and redone the 'plot all' processing to put all the sheets in the same
  PDF file (they come out in numeric order, too... but maybe that's
  depend on the enumeration of the sheet, I don't guarantee it)

- Converted to properly support the nanometer unit the excellon
  generator, the gencad exporter and the pick and place generator

- Added the package to the pick and place report

What's missing:

- User interface for the new features (options for DXF and to the
  SetPsTextMode options, if desired; also PDF support in pcbnew:
  you could just change the instanced class!)

- To create compressed PDFs I'm using zlib; it's surely available since
  it's needed for PNG handling, but I don't know it cmake can find it
  automatically. For now I simply added 'z' to the list of libraries to
  link, maybe a configuration check would be useful here

- Some gerber apertures (trapezoidal and rotated not in 90 degrees
  increments) are drawn, not flashed; this is a long term project since
  requires the use of aperture macros!

Other comments:

- The PSLIKE_PLOTTER class and the PS_PLOTTER class are in the same file
  at the moment; obviously they could be put in separate files

- The width metrics for the four helvetica fonts are const array at the
  end of the same file

- The plot width adjustment isn't really part of the plot classes... it
  should be moved in the pcbnew routines which uses it. It's only
  'carried along' for now

- I'm not too satisfied with the PDF stream compression... all the page
  content is written to a temporary file which is then read, compressed
  and written to the output PDF. Something like a stringstream FILE*
  would be useful here:P or at least using zlib streaming compression
  (but it was sufficiently difficult to make it work this way, since PDF
  specs are misleading...). It works and it shouldn't give problems, if
  someone is bored it's there to fix...

- PDF hidden text could be useful for other things (i.e. searching
  a component by reference without having the reference on the silk
  screen plot); that wouldn't be too difficult to implement if someone
  likes the idea

- PDF has a lot of other features which could be harvested (annotations,
  links and so on); the basic infrastructure is already there, it 'only'
  need the implementation for the specific dictionary types (PDF 1.5
  compressed object streams are *not* supported and probably will never
  be since they're too complex to implements for the little gain they
  offer...): for example linking subsheet objects (you click on the
  subsheet on the pdf page and *poof* it send you on the right PDF
  page); another feature would be attaching fields to components as
  annotation (for crowded schematics!)

Lorenzo Marcantonio
Logos Srl

Attachment: assembly-demo-native.pdf
Description: Adobe PDF document

Attachment: assembly-demo-phantom.pdf
Description: Adobe PDF document

Attachment: kicad-nanoplot-pdf.diff.gz
Description: application/gunzip

Follow ups