Traces, curved traces, ground fills, solder pads and PCB text call their layer 'Board Side', like every other part, and count as Board Side components in code; the saved field is still 'layer'

This commit is contained in:
Bane Stojkovic
2026-11-11 21:15:26 +01:00
parent 7ae773ab77
commit aef300d902
13 changed files with 87 additions and 51 deletions
@@ -52,7 +52,7 @@ import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
@AiNote(value = "Use for copper on PCB layouts; for a wire link use Jumper or Hookup Wire", scope = Scope.SELECTION)
@AiNote("A single straight segment on the copper side chosen by 'Layer'; chain segments end to end for bends, or use Curved Trace")
@AiNote("A single straight segment on the copper side chosen by 'Board Side'; chain segments end to end for bends, or use Curved Trace")
@AiNote("The whole length is copper: any terminal or copper on the same layer that it touches or crosses is connected, not just its ends, so traces of different nets must not cross")
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace",
@@ -117,7 +117,7 @@ public class CopperTrace extends AbstractLeadedComponent<Void>
this.thickness = thickness;
}
@EditableProperty
@EditableProperty(name = "Board Side")
@Override
public PCBLayer getLayer() {
if (layer == null) {
@@ -105,7 +105,7 @@ public class CurvedTrace extends AbstractCurvedComponent<Void>
this.size = size;
}
@EditableProperty
@EditableProperty(name = "Board Side")
@Override
public PCBLayer getLayer() {
if (layer == null) {
@@ -152,7 +152,7 @@ public class GroundFill extends AbstractTransparentComponent<Void>
this.pointCount = pointCount;
}
@EditableProperty
@EditableProperty(name = "Board Side")
@Override
public PCBLayer getLayer() {
if (layer == null) {
@@ -190,7 +190,7 @@ public class SolderPad extends AbstractTransparentComponent<Void>
this.holeSize = holeSize;
}
@EditableProperty
@EditableProperty(name = "Board Side")
@Override
public PCBLayer getLayer() {
if (layer == null) {
@@ -325,7 +325,7 @@ public class PCBText extends AbstractComponent<Void>
this.horizontalAlignment = alignment;
}
@EditableProperty
@EditableProperty(name = "Board Side")
@Override
public PCBLayer getLayer() {
if (layer == null) {
@@ -29,9 +29,11 @@ import java.util.ArrayList;
import java.util.List;
import org.diylc.common.PCBLayer;
import org.diylc.components.connectivity.CopperTrace;
import org.diylc.components.misc.Label;
import org.diylc.core.IBoardSideComponent;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IPCBLayerComponent;
import org.diylc.core.gerber.GerberLayer;
import org.diylc.core.gerber.IGerberComponentSimple;
import org.diylc.utils.ReflectionUtils;
@@ -73,10 +75,26 @@ public class BoardSideComponentsTest {
}
}
// copper starts on the bottom, where single-sided boards carry it
@Test
public void testCopperBoardSideIsItsLayer() {
CopperTrace trace = new CopperTrace();
assertEquals(PCBLayer._1, trace.getBoardSide());
trace.setBoardSide(PCBLayer._2);
assertEquals(PCBLayer._2, trace.getLayer());
// the deprecated inner layers are inside the board, which counts as the bottom
trace.setLayer(PCBLayer._3);
assertEquals(PCBLayer._1, trace.getBoardSide());
}
// parts, which start on top; copper starts on the bottom and is covered above
private static List<IDIYComponent<?>> createBoardSideComponents() throws Exception {
List<IDIYComponent<?>> components = new ArrayList<IDIYComponent<?>>();
for (Class<?> type : ReflectionUtils.getIndexedClasses(IDIYComponent.class)) {
if (IBoardSideComponent.class.isAssignableFrom(type)
&& !IPCBLayerComponent.class.isAssignableFrom(type)
&& !Modifier.isAbstract(type.getModifiers())) {
components.add((IDIYComponent<?>) type.getDeclaredConstructor().newInstance());
}
@@ -98,7 +98,7 @@ public class ComponentCatalogGeneratorTest {
assertTrue("a switch carries its switching table", variants.get(0).containsKey("switching"));
// the deprecated inner layers are kept only so that old files load
Map<String, Object> layer = findProperty(find(components, "connectivity.CopperTrace"), "Layer");
Map<String, Object> layer = findProperty(find(components, "connectivity.CopperTrace"), "Board Side");
assertEquals(List.of("_1", "_2"), layer.get("possibleValues"));
}