Added ability control if the board underside display should render as transparent or not

This commit is contained in:
Bane Stojkovic
2025-03-30 13:18:08 +02:00
parent a5f6299de7
commit baaeefdbab
4 changed files with 27 additions and 7 deletions
@@ -8,9 +8,11 @@ public interface IBoard {
Rectangle2D getBoardRectangle(); Rectangle2D getBoardRectangle();
BoardUndersideDisplay getBoardUndersideDisplay(); BoardUndersideDisplay getUndersideDisplay();
Size getUndersideOffset(); Size getUndersideOffset();
Boolean getUndersideTransparency();
boolean shouldExportToGerber(); boolean shouldExportToGerber();
} }
@@ -191,7 +191,7 @@ public class DrawingManager {
Map<IBoard, List<IDIYComponent<?>>> boardMap = project.getComponents().stream() Map<IBoard, List<IDIYComponent<?>>> boardMap = project.getComponents().stream()
.filter(IBoard.class::isInstance) .filter(IBoard.class::isInstance)
.map(IBoard.class::cast) .map(IBoard.class::cast)
.filter(b -> b.getBoardUndersideDisplay() != BoardUndersideDisplay.NONE) .filter(b -> b.getUndersideDisplay() != BoardUndersideDisplay.NONE)
.collect(Collectors.toMap(x -> x, x -> new ArrayList<IDIYComponent<?>>())); .collect(Collectors.toMap(x -> x, x -> new ArrayList<IDIYComponent<?>>()));
Map<IDIYComponent<?>, Set<IBoard>> componentBoardMap = new HashMap<IDIYComponent<?>, Set<IBoard>>(); Map<IDIYComponent<?>, Set<IBoard>> componentBoardMap = new HashMap<IDIYComponent<?>, Set<IBoard>>();
@@ -524,7 +524,7 @@ public class DrawingManager {
IDIYComponent<?> clonedComponent = component.clone(); IDIYComponent<?> clonedComponent = component.clone();
int direction = 0; int direction = 0;
Point2D pivotPoint = new Point2D.Double(); Point2D pivotPoint = new Point2D.Double();
switch (board.getBoardUndersideDisplay()) { switch (board.getUndersideDisplay()) {
case ABOVE: case ABOVE:
direction = IComponentTransformer.VERTICAL; direction = IComponentTransformer.VERTICAL;
pivotPoint.setLocation(boardRectangle.getMinX(), boardRectangle.getMinY() - offset / 2); pivotPoint.setLocation(boardRectangle.getMinX(), boardRectangle.getMinY() - offset / 2);
@@ -543,7 +543,7 @@ public class DrawingManager {
break; break;
} }
componentType.getTransformer().mirror(clonedComponent, pivotPoint, direction); componentType.getTransformer().mirror(clonedComponent, pivotPoint, direction);
if (AbstractTransparentComponent.class.isInstance(clonedComponent)) { if (board.getUndersideTransparency() && AbstractTransparentComponent.class.isInstance(clonedComponent)) {
AbstractTransparentComponent<?> transparentComponent = (AbstractTransparentComponent<?>) clonedComponent; AbstractTransparentComponent<?> transparentComponent = (AbstractTransparentComponent<?>) clonedComponent;
transparentComponent.setAlpha(MIRROR_ALPHA); transparentComponent.setAlpha(MIRROR_ALPHA);
} }
@@ -337,6 +337,10 @@
<changeType>NEW_FEATURE</changeType> <changeType>NEW_FEATURE</changeType>
<description>Added a 'Save' button to all analysis screens which saves results of a circuit analysis to an HTML file</description> <description>Added a 'Save' button to all analysis screens which saves results of a circuit analysis to an HTML file</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added ability control if the board underside display should render as transparent or not</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Moved 'Analyze' functions from 'File' menu to their own menu for faster access</description> <description>Moved 'Analyze' functions from 'File' menu to their own menu for faster access</description>
@@ -79,6 +79,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
protected BoardUndersideDisplay boardUndersideDisplay = BoardUndersideDisplay.NONE; protected BoardUndersideDisplay boardUndersideDisplay = BoardUndersideDisplay.NONE;
protected Size undersideOffset = DEFAULT_UNDERSIDE_OFFSET; protected Size undersideOffset = DEFAULT_UNDERSIDE_OFFSET;
private Boolean undersideTransparency = true;
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project, public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
@@ -372,14 +373,14 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
@EditableProperty(name = "Underside Display") @EditableProperty(name = "Underside Display")
@Override @Override
public BoardUndersideDisplay getBoardUndersideDisplay() { public BoardUndersideDisplay getUndersideDisplay() {
if (this.boardUndersideDisplay == null) { if (this.boardUndersideDisplay == null) {
this.boardUndersideDisplay = BoardUndersideDisplay.NONE; this.boardUndersideDisplay = BoardUndersideDisplay.NONE;
} }
return this.boardUndersideDisplay; return this.boardUndersideDisplay;
} }
public void setBoardUndersideDisplay(BoardUndersideDisplay boardUndersideDisplay) { public void setUndersideDisplay(BoardUndersideDisplay boardUndersideDisplay) {
this.boardUndersideDisplay = boardUndersideDisplay; this.boardUndersideDisplay = boardUndersideDisplay;
} }
@@ -396,6 +397,19 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
this.undersideOffset = undersideOffset; this.undersideOffset = undersideOffset;
} }
@EditableProperty(name = "Underside Transparency")
@Override
public Boolean getUndersideTransparency() {
if (undersideTransparency == null) {
undersideTransparency = true;
}
return undersideTransparency;
}
public void setUndersideTransparency(Boolean undersideTransparency) {
this.undersideTransparency = undersideTransparency;
}
@Override @Override
public Rectangle2D getBoardRectangle() { public Rectangle2D getBoardRectangle() {
Point2D finalSecondPoint = getFinalSecondPoint(); Point2D finalSecondPoint = getFinalSecondPoint();