When rotating Vero and Tri-Pad boards, change the orientation of strips

to match the rotation angle
This commit is contained in:
bancika
2020-12-11 23:51:32 +01:00
parent a03dd74c80
commit b6b50d376d
6 changed files with 116 additions and 97 deletions
@@ -3290,14 +3290,6 @@
<changeType>IMPROVEMENT</changeType>
<description>macOS: two finger click shows the popup menu without deselecting a selected component</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Apply context menu rotation and mirroring to Trimmer potentiometers</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Apply context menu rotation and mirroring to SMD components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Do not allow for components like traces, jumpers and wires to be reduced to nothing by dragging connected components</description>
@@ -3305,7 +3297,19 @@
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>In cases when there's already a component in the selection that is reduced to nothing, allow moving the selection</description>
</org.diylc.appframework.update.Change>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Apply context menu rotation and mirroring to Trimmer potentiometers</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Apply context menu rotation and mirroring to SMD components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>When rotating Vero and Tri-Pad boards, change the orientation of strips to match the rotation angle</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
Binary file not shown.
@@ -0,0 +1,52 @@
package org.diylc.components.boards;
import java.awt.Color;
import org.diylc.common.OrientationHV;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
public abstract class AbstractVeroBoard extends AbstractBoard {
private static final long serialVersionUID = 1L;
public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in);
public static Size STRIP_SIZE = new Size(0.07d, SizeUnit.in);
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
// strip
protected Size spacing = SPACING;
protected Color stripColor = COPPER_COLOR;
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
@EditableProperty(name = "Strip Color")
public Color getStripColor() {
return stripColor;
}
public void setStripColor(Color padColor) {
this.stripColor = padColor;
}
@EditableProperty(validatorClass = PositiveNonZeroMeasureValidator.class)
public Size getSpacing() {
return spacing;
}
public void setSpacing(Size spacing) {
this.spacing = spacing;
}
@EditableProperty
public OrientationHV getOrientation() {
return orientation;
}
public void setOrientation(OrientationHV orientation) {
this.orientation = orientation;
}
}
@@ -22,14 +22,13 @@
package org.diylc.components.boards;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Point2D;
import org.diylc.common.OrientationHV;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.transform.VeroBoardTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
@@ -37,30 +36,17 @@ import org.diylc.core.Project;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "TriPad Board", category = "Boards", author = "Hauke Juhls", zOrder = IDIYComponent.BOARD,
instanceNamePrefix = "Board",
description = "Perforated FR4 board with copper strips connecting 3 holes in a row (aka TriPad Board)",
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class, enableCache = true)
public class TriPadBoard extends AbstractBoard {
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = VeroBoardTransformer.class, enableCache = true)
public class TriPadBoard extends AbstractVeroBoard {
private static final long serialVersionUID = 1L;
public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in);
public static Size STRIP_SIZE = new Size(0.07d, SizeUnit.in);
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
protected int stripSpan = 3; // determines how many holes are covered by a
// strip
protected Size spacing = SPACING;
protected Color stripColor = COPPER_COLOR;
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
@@ -166,33 +152,6 @@ public class TriPadBoard extends AbstractBoard {
}
}
@EditableProperty(name = "Strip Color")
public Color getStripColor() {
return stripColor;
}
public void setStripColor(Color padColor) {
this.stripColor = padColor;
}
@EditableProperty(validatorClass = PositiveNonZeroMeasureValidator.class)
public Size getSpacing() {
return spacing;
}
public void setSpacing(Size spacing) {
this.spacing = spacing;
}
@EditableProperty
public OrientationHV getOrientation() {
return orientation;
}
public void setOrientation(OrientationHV orientation) {
this.orientation = orientation;
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setColor(BOARD_COLOR);
@@ -22,46 +22,31 @@
package org.diylc.components.boards;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Point2D;
import org.diylc.common.OrientationHV;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.transform.VeroBoardTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.annotations.BomPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Vero Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
description = "Perforated FR4 board with copper strips connecting all holes in a row",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME,
transformer = SimpleComponentTransformer.class, enableCache = true)
public class VeroBoard extends AbstractBoard {
transformer = VeroBoardTransformer.class, enableCache = true)
public class VeroBoard extends AbstractVeroBoard {
private static final long serialVersionUID = 1L;
public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size SPACING = new Size(0.1d, SizeUnit.in);
public static Size STRIP_SIZE = new Size(0.07d, SizeUnit.in);
public static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
protected Size spacing = SPACING;
protected Color stripColor = COPPER_COLOR;
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
@@ -126,32 +111,7 @@ public class VeroBoard extends AbstractBoard {
}
}
@EditableProperty(name = "Strip Color")
public Color getStripColor() {
return stripColor;
}
public void setStripColor(Color padColor) {
this.stripColor = padColor;
}
@EditableProperty(validatorClass = PositiveNonZeroMeasureValidator.class)
public Size getSpacing() {
return spacing;
}
public void setSpacing(Size spacing) {
this.spacing = spacing;
}
@EditableProperty
public OrientationHV getOrientation() {
return orientation;
}
public void setOrientation(OrientationHV orientation) {
this.orientation = orientation;
}
@Override
public String getControlPointNodeName(int index) {
@@ -0,0 +1,44 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 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.components.transform;
import java.awt.geom.Point2D;
import org.diylc.common.OrientationHV;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.components.boards.AbstractVeroBoard;
import org.diylc.core.IDIYComponent;
public class VeroBoardTransformer extends SimpleComponentTransformer {
@Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
super.rotate(component, center, direction);
AbstractVeroBoard board = (AbstractVeroBoard)component;
OrientationHV orientation = board.getOrientation();
if (orientation == OrientationHV.HORIZONTAL)
board.setOrientation(OrientationHV.VERTICAL);
else
board.setOrientation(OrientationHV.HORIZONTAL);
}
}