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
@@ -23,6 +23,9 @@ package org.diylc.swing.plugins.file;
import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PCBLayer;
import org.diylc.core.IBoardSideComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.filter.PCBLayerFilter;
import org.diylc.filter.SilkScreenFilter;
import org.diylc.swingframework.IDrawingProvider;
@@ -53,11 +56,17 @@ public class SilkScreenDrawingProvider implements IDrawingProvider {
@Override
public void draw(int page, Graphics g, double zoomFactor) {
plugInPort.draw((Graphics2D) g, EnumSet.of(DrawOption.ANTIALIASING, DrawOption.OUTLINE_MODE, DrawOption.MONOCHROMATIC),
new SilkScreenFilter(), zoomFactor, null, null);
new SilkScreenFilter(page == 0 ? PCBLayer._2 : PCBLayer._1), zoomFactor, null, null);
}
// the top side, followed by the bottom side when a part is mounted there
@Override
public int getPageCount() {
for (IDIYComponent<?> c : plugInPort.getCurrentProject().getComponents()) {
if (c instanceof IBoardSideComponent && ((IBoardSideComponent) c).getBoardSide() == PCBLayer._1) {
return 2;
}
}
return 1;
}
}
@@ -0,0 +1,50 @@
/*
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.swing.plugins.file;
import static org.junit.Assert.assertEquals;
import java.awt.Point;
import org.diylc.TestBase;
import org.diylc.common.PCBLayer;
import org.diylc.components.passive.Resistor;
import org.junit.Test;
public class SilkScreenDrawingProviderTest extends TestBase {
@Test
public void testOnePageWithoutBottomParts() {
instantiateTwoClick("Passive", "Resistor", new Point(1000, 1000), new Point(1200, 1000));
assertEquals(1, new SilkScreenDrawingProvider(presenter).getPageCount());
}
@Test
public void testBottomPageForBottomParts() {
instantiateTwoClick("Passive", "Resistor", new Point(1000, 1000), new Point(1200, 1000));
Resistor resistor = (Resistor) presenter.getCurrentProject().getComponents().get(0);
resistor.setBoardSide(PCBLayer._1);
assertEquals(2, new SilkScreenDrawingProvider(presenter).getPageCount());
}
}