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) {
continue;
}
boolean include = true;
boolean include = false;
for (int i = 0; i < c.getControlPointCount(); i++) {
if (!boardRect.contains(c.getControlPoint(i))) {
include = false;
if (boardRect.contains(c.getControlPoint(i))) {
include = true;
break;
}
}
@@ -333,27 +333,35 @@ public class DrawingManager {
lastDrawnStateMap.put(component, state);
}
// Mirror components that belong to boards that need to be mirrored
if (componentBoardMap.containsKey(component)) {
@SuppressWarnings("unchecked")
ComponentType componentType = ComponentProcessor.getInstance()
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
if (componentType.getTransformer() != null) {
Set<IBoard> boards = componentBoardMap.get(component);
for (IBoard board : boards) {
drawMirroredComponent(project, board, component, componentType, g2dWrapper, state, outlineMode);
try {
// Mirror components that belong to boards that need to be mirrored
if (componentBoardMap.containsKey(component)) {
@SuppressWarnings("unchecked")
ComponentType componentType = ComponentProcessor.getInstance()
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
if (componentType.getTransformer() != null) {
Set<IBoard> boards = componentBoardMap.get(component);
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 (IBoard.class.isInstance(component) && componentBoardMap.values().stream()
.anyMatch(boards -> boards.contains(component))) {
ComponentType componentType = ComponentProcessor.getInstance()
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
if (componentType.getTransformer() != null) {
drawMirroredComponent(project, (IBoard) component, component, componentType, g2dWrapper, state, outlineMode);
// if a component itself is a board that needs to be mirrored, do it
if (IBoard.class.isInstance(component) && componentBoardMap.values().stream()
.anyMatch(boards -> boards.contains(component))) {
ComponentType componentType = ComponentProcessor.getInstance()
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) component.getClass());
if (componentType.getTransformer() != null) {
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>
<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>
<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>
<changeType>BUG_FIX</changeType>
<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>
<description>Copy operation doesn't work when certain component types are selected</description>
</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>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
@@ -26,23 +26,13 @@ import org.diylc.components.misc.Label;
import org.diylc.components.misc.PCBText;
import org.diylc.core.IDIYComponent;
public class TextTransformer implements IComponentTransformer {
public class TextTransformer extends SimpleComponentTransformer {
@Override
public boolean canRotate(IDIYComponent<?> component) {
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
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY());
@@ -76,9 +66,4 @@ public class TextTransformer implements IComponentTransformer {
snap.setOrientation(o);
}
}
@Override
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {
throw new RuntimeException("Unexpected call to mirror() in LabelTransformer");
}
}