The silkscreen print-out has a separate page for parts placed on the bottom of the board

This commit is contained in:
Bane Stojkovic
2026-11-11 15:37:27 +01:00
parent 246763419c
commit 122a91a6f0
6 changed files with 173 additions and 9 deletions
@@ -1,6 +1,8 @@
package org.diylc.filter;
import org.diylc.common.PCBLayer;
import org.diylc.core.IBoard;
import org.diylc.core.IBoardSideComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.gerber.GerberRenderMode;
import org.diylc.core.gerber.IGerberComponent;
@@ -9,6 +11,20 @@ import java.util.Set;
public class SilkScreenFilter implements IComponentFilter {
private PCBLayer side;
public SilkScreenFilter() {
this(null);
}
/**
* @param side the side of the board whose silkscreen to keep, or null for both; board outlines
* are kept on either side
*/
public SilkScreenFilter(PCBLayer side) {
this.side = side;
}
@Override
public boolean testComponent(IDIYComponent<?> component) {
if (component instanceof IBoard board) {
@@ -17,7 +33,16 @@ public class SilkScreenFilter implements IComponentFilter {
if (!(component instanceof IGerberComponent gerberComponent)) {
return false;
}
if (side != null && getSide(component) != side) {
return false;
}
Set<GerberRenderMode> gerberRenderModes = gerberComponent.getGerberRenderModes();
return gerberRenderModes.contains(GerberRenderMode.Outline);
}
// components that do not say which side they are on are on top
private static PCBLayer getSide(IDIYComponent<?> component) {
return component instanceof IBoardSideComponent sided && sided.getBoardSide() == PCBLayer._1
? PCBLayer._1 : PCBLayer._2;
}
}
@@ -635,7 +635,7 @@
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Resistors, capacitors, diodes, ICs, transistors, switches, jacks, tube sockets and other PCB parts have a new 'Board Side' property to place them on the bottom of the board; bottom parts are drawn faded on the canvas and solid in the board's Underside Display, and Gerber export puts their silkscreen on the bottom layer with the text mirrored</description>
<description>Resistors, capacitors, diodes, ICs, transistors, switches, jacks, tube sockets and other PCB parts have a new 'Board Side' property to place them on the bottom of the board; bottom parts are drawn faded on the canvas and solid in the board's Underside Display, and Gerber export puts their silkscreen on the bottom layer with the text mirrored, and the silkscreen print-out has a separate page for the bottom</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
@@ -0,0 +1,76 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.filter;
import static org.junit.Assert.assertTrue;
import org.diylc.common.PCBLayer;
import org.diylc.core.gerber.GerberExporterTest.SidedGerberComponent;
import org.diylc.core.gerber.GerberExporterTest.SimpleGerberComponent;
import org.diylc.presenter.DrawingManagerTest.MockBoard;
import org.junit.Test;
public class SilkScreenFilterTest {
@Test
public void testPartsGoToTheirOwnSide() {
SidedGerberComponent top = new SidedGerberComponent(PCBLayer._2);
SidedGerberComponent bottom = new SidedGerberComponent(PCBLayer._1);
assertTrue(new SilkScreenFilter(PCBLayer._2).testComponent(top));
assertTrue(!new SilkScreenFilter(PCBLayer._2).testComponent(bottom));
assertTrue(new SilkScreenFilter(PCBLayer._1).testComponent(bottom));
assertTrue(!new SilkScreenFilter(PCBLayer._1).testComponent(top));
}
@Test
public void testPartsWithoutSideAreOnTop() {
SimpleGerberComponent part = new SimpleGerberComponent(null);
assertTrue(new SilkScreenFilter(PCBLayer._2).testComponent(part));
assertTrue(!new SilkScreenFilter(PCBLayer._1).testComponent(part));
}
@Test
public void testBoardOutlineOnBothSides() {
MockBoard board = new ExportedBoard();
assertTrue(new SilkScreenFilter(PCBLayer._2).testComponent(board));
assertTrue(new SilkScreenFilter(PCBLayer._1).testComponent(board));
}
@Test
public void testNoSideKeepsEverything() {
assertTrue(new SilkScreenFilter().testComponent(new SidedGerberComponent(PCBLayer._1)));
assertTrue(new SilkScreenFilter().testComponent(new SidedGerberComponent(PCBLayer._2)));
}
public static class ExportedBoard extends MockBoard {
private static final long serialVersionUID = 1L;
@Override
public boolean shouldExportToGerber() {
return true;
}
}
}