Pictures

There are many good reasons for including bitmap images in schematics or boards, such as documentation or reverse engineering PCBs from photos. Since I needed the latter for a project of mine, I decided to have a go at implementing it.

However, there are some challenges that need to be overcome:

  • Embedding bitmap data directly into the picture object would result in the bitmap data being copied for undo/redo which isn’t optimal from a performance point of view.
  • Saving bitmap data serialized as base64 in json files will cause them to grow to unwieldy sizes.
  • Uploading all bitmaps to the GPU on each render cycle isn’t that efficient.

To solve all of these issues in one go, imported bitmap data is assigned a UUID, stored in a shared_ptr and is immutable thereafter. The actual Picture object then just contains a shared_ptr reference to the bitmap data, so copying is cheap. Rather than embedding the bitmap data into the json, it’s saved to a png file in the pictures directory located in the project directory. Since bitmap data is immutable, the png only needs to be written once which makes saving a lot faster. The rendering also benefits from the the immutability as the bitmap data only has to be sent to a texture once.

Pictures are imported using Gdk’s pixbuf loader infrastructure, so it’s possible to import a wide variety of image formats. For maximum convenience, pictures can also be imported by pasting.

This is how it looks like. In this case, the imported picture was used as a reference to retrace the board outline. picture

Layer pairs (Issue #410)

When placing vias while routing it can be desirable to automatically switch layers. This is easy for two-layer boards as there’s only one other copper layer to switch to for but not so easy for multilayer boards as there are multiple layers to switch to.

To solve this issue, we now have a rule to specify layer pairs that supports different layer pairs based on net:

layer pairs

Grid improvements (Issue #407)

The grid has hasn’t seen much development since it’s inception. Issue #407 got me motivated to spend some time improving it in two ways:

  • Support for nonzero origin
  • Non-square spacing

With these changes in place, this is what the new grid controls look like:

grid

The grid’s appearance also got an upgrade with the grid marks now being aligned to the pixel grid for pixel-perfect rendering even with antialiasing enabled.

grid

KiCad Router

Motivated by Robin’s and anuejn’s reports about issues with the KiCad router integrated in Horizon EDA, I decided it was about time to improve a few things:

  • Update the Router to the latest stable version from the KiCad sources
  • Profiling revealed that a disproportionate amount time is spent sorting rules, so the cooper clearance sort order is now cached
  • Dragging a single track invokes the router’s interactive drag if enabled in the preferences

Distraction free mode (PR #413)

To maximize screen real estate available to the the canvas and reduce clutter we now have a distraction free mode that hides the left and right panel in the interactive manipulator:

distraction free mode

Keeping arcs circular

In Horizon EDA, arcs are specified using start point, end point, center point and direction that determines wether the arc goes clockwise or counter-clockwise. Unfortunately, this leaves us with two radii. Initially the arc just wasn’t rendered if it happened to have non-identical radii. As the disappearing arc was a bit confusing, I modified the renderer to interpolate between the two radii in order to have something to show.

This however isn’t optimal either as arcs are supposed to be circle segments with constant radius. To fix this, the center point provided by the user is now projected onto the perpendicular bisector between start and end point to always have the same start and end radius.

Airwire filter window enhancements

Probably the biggest improvement that landed in June is the greatly improved Airwire filter window that got renamed to “Nets”:

nets

The nets window gained these features:

  • Nets are searchable by net name / class
  • Shows all nets by default
  • Selecting a net in the list highlights it on the board
  • Context menu for showing/hiding multiple airwires in one go and setting net color

When setting a net color, all tracks, vias, pads, planes and airwires that belong to the given net have their color replaced with the set one for easier identification. That resolved Issue #408.

Better visibility of polygon outlines

Selecting any vertex/edge of a polygon, all of its vertices and edges now get highlighted to make it easier to see the outline of the polygon. This is especially useful for planes where the polygon’s outline is replaced by the plane’s:

polygon outline