7.1 KiB
Bottom-Side Components
Let a component be mounted on the bottom of a PCB, so that its silkscreen goes to the bottom Gerber layers and the canvas shows it as a part on the far side of the board.
Status: not started.
1. Current state
- Traces, pads, PCB text and ground fills carry a
PCBLayer(Bottom,Top,Inner 1..6). It feedsPCBLayer.toGerberCopperLayer(),PCBLayerFilter, the trace-mask print and continuity (ILayeredComponent.getLayerId()). - Every other Gerber-aware component implements
IGerberComponentSimple, whosegetGerberLayer()defaults toSilkscreenTop. About 35 classes indiylc-libraryrely on that default (resistors, film and radial capacitors, diodes, LEDs, transistor packages, DIL/SIL ICs, SMD passives, switches, jacks, relays, transformers, tube sockets, ...). None of them emit copper. Their pads are separateSolderPadcomponents, which already have a layer. - Two copies of the same dispatch decide the layer for a simple component:
GerberExporter.drawComponentandGerberPathRenderer.drawComponent. Both callg2d.startGerberOutput(getGerberLayer(), ...). - Z-order is paint order only. A trace on the bottom layer already paints above the board
(
zOrder = TRACE), so the codebase already treats the physical side as separate from z-order.
2. Decisions
| Decision | Rationale |
|---|---|
A new two-value BoardSide (Top, Bottom), not a reuse of PCBLayer |
Parts mount on the outer faces only. Inner layers would be invalid choices in the editor. |
| The side is the physical fact. Z-order stays paint order and is not tied to it | Boards are drawn opaque, so painting bottom parts beneath the board would hide them. Bottom-layer traces already follow this rule. |
| The canvas shows the side visually and does not rely on z-order for it | That is what removes the ambiguity of a "bottom" part drawn above the board. |
| Flipping a part is an action that sets the side, mirrors the part and sends it back | A part seen from above through the board is a mirror image. Changing the side without mirroring gives a footprint that is wrong for fabrication. |
| The Gerber layer is swapped centrally, not inside each component | Components keep emitting their *Top layer. One place maps it to the other side. |
Default Top, with null meaning Top |
Fields added to existing classes deserialize as null in old files. |
3. Design
diylc-core
org.diylc.common.BoardSide: enumTop,Bottom, with atoString()label likePCBLayer.org.diylc.core.IBoardSideComponent:BoardSide getBoardSide();with Javadoc and@author, in the same shape asILayeredComponent. Core knows the side only through this interface.GerberLayer.flip(): mapsCopperTop/CopperBot,SilkscreenTop/SilkscreenBotandSolderMaskTop/SolderMaskBotto each other.Outlineand the drill layers map to themselves.- Gerber dispatch: in the simple-component branch, use
getGerberLayer().flip()when the component is anIBoardSideComponentonBottom. MergeGerberExporter.drawComponentandGerberPathRenderer.drawComponentinto one method first, so the rule is written once. - Canvas rendering:
DrawingManager.drawProjectdraws bottom-side components with a composite that sets them apart. Locked components already use a 0.5 alpha composite (lockedComposite), so the bottom-side treatment has to look different from that, for example a lower alpha or a tint. Pick one and check it against a locked bottom-side part.
diylc-library
- The ~35 classes that use the
SilkscreenTopdefault implementIBoardSideComponent. Each adds a nullableBoardSide boardSidefield and a getter/setter pair, with@EditableProperty(name = "Board Side")on the getter. The getter returnsTopwhen the field isnull. This duplicates the field across classes in the same way thePCBLayerfield is duplicated today. Where several of these classes share an abstract base (AbstractRadialComponent,AbstractFilmCapacitor,AbstractTransistorPackage, ...), put it on the base. CopperTrace,CurvedTrace,GroundFill,SolderPad,PCBTextandDrillHoledo not implement it. TheirPCBLayeralready says where they are.- Before allowing
Bottomon a class, check that its transformer can mirror it (canMirror). A class that cannot be mirrored must not offerBottom, or the footprint would be wrong.
diylc-swing
-
Flip to Other Side action in the Edit menu and the canvas popup menu, following the align-distribute actions. For each selected
IBoardSideComponentit:- toggles the side,
- mirrors horizontally about the selection centre with the component's
IComponentTransformer, - sends the component to the back of its z-order band.
The whole action is one undo step, and it is enabled only when the selection holds at least one
IBoardSideComponent. The work is done inPresenterbehindIPlugInPort, with the plugin only wiring the menu items. -
PCB print-outs:
SilkScreenDrawingProviderprints one page of everything that has a silkscreen outline. Split it into top and bottom pages, filtered by side, the same wayTraceMaskDrawingProvidergives one page perPCBLayer.
4. Open questions
- Bottom silkscreen text. Component labels drawn through
IGerberComponentSimplehave to read correctly once the board is turned over, which means they must look mirrored from the top. Check whether mirroring through the transformer does that for every class, or whether labels are drawn unmirrored regardless.GerberLayer.mirroredis currentlyfalsefor every layer, and the exporter output must stay in top view. - SolderPad solder mask.
SolderPadalways writes its mask opening toSolderMaskBot, whatever its ownPCBLayer. Confirm whether this is intended for top-layer SMD pads beforeGerberLayer.flip()is introduced next to it. - Plain property or action only. A plain editable property lets a user change the side without mirroring. Either keep both (the property for already-mirrored parts) or show the side as read-only and change it only through the action.
5. Verification
- Unit tests in
diylc-coreforGerberLayer.flip()and for the merged dispatch method, using a stubIBoardSideComponent(top, bottom andnull). - Load an old
.diywith PCB parts and confirm every component reportsTopand that the Gerber output is byte-identical to before. - Export a board with one part on each side and open the files in a Gerber viewer: the bottom part
appears only in
.gbo, mirrored, and in the right position. - Run the regression suite, since rendering and serialization both change.
6. Next steps
- Merge the two
drawComponentcopies indiylc-coreand addGerberLayer.flip()with tests. - Add
BoardSideandIBoardSideComponent, and swap the Gerber layer in the dispatch. - Add the field to the library components, putting it on shared bases where they exist. Settle the silkscreen-text question while doing so.
- Add the bottom-side composite in
DrawingManager. - Add the Flip to Other Side action.
- Split the silkscreen print-out by side.
- Run the regression suite.