Board underside display does not work if there's a Label or PCB Text component on the board

This commit is contained in:
Bane Stojkovic
2025-03-30 23:46:13 +02:00
parent baaeefdbab
commit 58e28a95fd
3 changed files with 41 additions and 36 deletions
@@ -201,10 +201,10 @@ public class DrawingManager {
if (c == board) { if (c == board) {
continue; continue;
} }
boolean include = true; boolean include = false;
for (int i = 0; i < c.getControlPointCount(); i++) { for (int i = 0; i < c.getControlPointCount(); i++) {
if (!boardRect.contains(c.getControlPoint(i))) { if (boardRect.contains(c.getControlPoint(i))) {
include = false; include = true;
break; break;
} }
} }
@@ -333,27 +333,35 @@ public class DrawingManager {
lastDrawnStateMap.put(component, state); lastDrawnStateMap.put(component, state);
} }
// Mirror components that belong to boards that need to be mirrored try {
if (componentBoardMap.containsKey(component)) { // Mirror components that belong to boards that need to be mirrored
@SuppressWarnings("unchecked") if (componentBoardMap.containsKey(component)) {
ComponentType componentType = ComponentProcessor.getInstance() @SuppressWarnings("unchecked")
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass()); ComponentType componentType = ComponentProcessor.getInstance()
if (componentType.getTransformer() != null) { .extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
Set<IBoard> boards = componentBoardMap.get(component); if (componentType.getTransformer() != null) {
for (IBoard board : boards) { Set<IBoard> boards = componentBoardMap.get(component);
drawMirroredComponent(project, board, component, componentType, g2dWrapper, state, outlineMode); for (IBoard board : boards) {
drawMirroredComponent(project, board, component, componentType, g2dWrapper, state,
outlineMode);
}
} }
} }
}
// if a component itself is a board that needs to be mirrored, do it // if a component itself is a board that needs to be mirrored, do it
if (IBoard.class.isInstance(component) && componentBoardMap.values().stream() if (IBoard.class.isInstance(component) && componentBoardMap.values().stream()
.anyMatch(boards -> boards.contains(component))) { .anyMatch(boards -> boards.contains(component))) {
ComponentType componentType = ComponentProcessor.getInstance() ComponentType componentType = ComponentProcessor.getInstance()
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass()); .extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
if (componentType.getTransformer() != null) { if (componentType.getTransformer() != null) {
drawMirroredComponent(project, (IBoard) component, component, componentType, g2dWrapper, state, outlineMode); drawMirroredComponent(project, (IBoard) component, component, componentType,
g2dWrapper, state, outlineMode);
}
} }
} finally {
// revert composite
g2d.setComposite(oldComposite);
g2d.setFont(oldFont);
} }
} }
} }
@@ -357,6 +357,10 @@
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Removed 'DP3T' options from 'Mini Toggle Switch' because that is covered by 'Slide Switch' component and does not belong here</description> <description>Removed 'DP3T' options from 'Mini Toggle Switch' because that is covered by 'Slide Switch' component and does not belong here</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Include components in the underside display that have at least one control point laying in the board, as opposed to all</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Applying a variant to a 'Hookup Wire' or 'Curved Trace' makes it lose its shape</description> <description>Applying a variant to a 'Hookup Wire' or 'Curved Trace' makes it lose its shape</description>
@@ -365,6 +369,14 @@
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Copy operation doesn't work when certain component types are selected</description> <description>Copy operation doesn't work when certain component types are selected</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Board underside display does not work if there's a Label or PCB Text component on the board</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Using board underside display sometimes makes other components semi-transparent</description>
</org.diylc.appframework.update.Change>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>
@@ -26,23 +26,13 @@ import org.diylc.components.misc.Label;
import org.diylc.components.misc.PCBText; import org.diylc.components.misc.PCBText;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class TextTransformer implements IComponentTransformer { public class TextTransformer extends SimpleComponentTransformer {
@Override @Override
public boolean canRotate(IDIYComponent<?> component) { public boolean canRotate(IDIYComponent<?> component) {
return component.getClass().equals(Label.class) || component.getClass().equals(PCBText.class); return component.getClass().equals(Label.class) || component.getClass().equals(PCBText.class);
} }
@Override
public boolean canMirror(IDIYComponent<?> component) {
return false;
}
@Override
public boolean mirroringChangesCircuit() {
return false;
}
@Override @Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) { public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY()); AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY());
@@ -76,9 +66,4 @@ public class TextTransformer implements IComponentTransformer {
snap.setOrientation(o); snap.setOrientation(o);
} }
} }
@Override
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {
throw new RuntimeException("Unexpected call to mirror() in LabelTransformer");
}
} }