mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 02:32:09 +10:00
A part's Gerber silkscreen layer follows its Board Side in IGerberComponentSimple's default, so the exporter no longer swaps layers after the fact and GerberLayer.flip() is gone
This commit is contained in:
@@ -160,15 +160,10 @@ public class GerberExporter {
|
||||
gerberComponentCustom.draw(g2d, ComponentState.NORMAL, outlineMode, currentProject, g2d, g2d);
|
||||
} else if (gerberComponent instanceof IGerberComponentSimple) {
|
||||
IGerberComponentSimple gerberComponentSimple = (IGerberComponentSimple) gerberComponent;
|
||||
GerberLayer layer = gerberComponentSimple.getGerberLayer();
|
||||
// components emit their top-side layer; a part mounted underneath goes to the bottom one
|
||||
boolean bottomSide = IBoardSideComponent.sideOf(c) == PCBLayer._1;
|
||||
if (bottomSide) {
|
||||
layer = layer.flip();
|
||||
}
|
||||
g2d.startGerberOutput(layer, gerberComponentSimple.getGerberFunction(),
|
||||
gerberComponentSimple.isGerberNegative());
|
||||
g2d.setMirrorText(bottomSide);
|
||||
g2d.startGerberOutput(gerberComponentSimple.getGerberLayer(),
|
||||
gerberComponentSimple.getGerberFunction(), gerberComponentSimple.isGerberNegative());
|
||||
// text on the bottom silkscreen is read from below, so it is written mirrored
|
||||
g2d.setMirrorText(IBoardSideComponent.sideOf(c) == PCBLayer._1);
|
||||
c.draw(g2d, ComponentState.NORMAL, outlineMode, currentProject, g2d);
|
||||
g2d.setMirrorText(false);
|
||||
g2d.stopGerberOutput();
|
||||
|
||||
@@ -55,29 +55,6 @@ public enum GerberLayer {
|
||||
return mirrored;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the same layer on the other side of the board; the outline and the drill layers go
|
||||
* through the whole board and are returned unchanged
|
||||
*/
|
||||
public GerberLayer flip() {
|
||||
switch (this) {
|
||||
case CopperBot:
|
||||
return CopperTop;
|
||||
case CopperTop:
|
||||
return CopperBot;
|
||||
case SilkscreenBot:
|
||||
return SilkscreenTop;
|
||||
case SilkscreenTop:
|
||||
return SilkscreenBot;
|
||||
case SolderMaskBot:
|
||||
return SolderMaskTop;
|
||||
case SolderMaskTop:
|
||||
return SolderMaskBot;
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public String formatFileName(String fileNameBase, String boardName) {
|
||||
return fileNameBase + (fileNameBase.endsWith(".") ? "" : ".")
|
||||
+ boardName + "-" + getSuffix() + "." + getExtension();
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
package org.diylc.core.gerber;
|
||||
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.core.IBoardSideComponent;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public interface IGerberComponentSimple extends IGerberComponent {
|
||||
|
||||
|
||||
/**
|
||||
* @return the silkscreen on the side of the board the component is mounted on
|
||||
*/
|
||||
default GerberLayer getGerberLayer() {
|
||||
return GerberLayer.SilkscreenTop;
|
||||
return this instanceof IDIYComponent<?> component
|
||||
&& IBoardSideComponent.sideOf(component) == PCBLayer._1
|
||||
? GerberLayer.SilkscreenBot : GerberLayer.SilkscreenTop;
|
||||
}
|
||||
|
||||
default String getGerberFunction() {
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
|
||||
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.core.gerber;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class GerberLayerTest {
|
||||
|
||||
@Test
|
||||
public void testFlipSwapsSides() {
|
||||
assertEquals(GerberLayer.CopperBot, GerberLayer.CopperTop.flip());
|
||||
assertEquals(GerberLayer.CopperTop, GerberLayer.CopperBot.flip());
|
||||
assertEquals(GerberLayer.SilkscreenBot, GerberLayer.SilkscreenTop.flip());
|
||||
assertEquals(GerberLayer.SilkscreenTop, GerberLayer.SilkscreenBot.flip());
|
||||
assertEquals(GerberLayer.SolderMaskBot, GerberLayer.SolderMaskTop.flip());
|
||||
assertEquals(GerberLayer.SolderMaskTop, GerberLayer.SolderMaskBot.flip());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlipKeepsLayersThroughTheBoard() {
|
||||
assertEquals(GerberLayer.Outline, GerberLayer.Outline.flip());
|
||||
assertEquals(GerberLayer.DrillPlated, GerberLayer.DrillPlated.flip());
|
||||
assertEquals(GerberLayer.DrillNonPlated, GerberLayer.DrillNonPlated.flip());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFlipTwiceReturnsLayer() {
|
||||
for (GerberLayer layer : GerberLayer.values()) {
|
||||
assertEquals(layer, layer.flip().flip());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user