DIL IC pin labels don't match between the rendered values and values in the netlist

This commit is contained in:
Bane Stojkovic
2022-12-12 23:35:02 +01:00
parent f4f4ba7458
commit b6f3020072
5 changed files with 565 additions and 552 deletions
@@ -4262,6 +4262,10 @@
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Improved find tool usability, make the screen pan to the selected components</description> <description>Improved find tool usability, make the screen pan to the selected components</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>DIL IC pin labels don't match between the rendered values and values in the netlist</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>
Binary file not shown.
@@ -1,24 +1,21 @@
/* /*
*
DIY Layout Creator (DIYLC). * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
Copyright (c) 2009-2018 held jointly by the individual authors. *
* This file is part of DIYLC.
This file is part of DIYLC. *
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
DIYLC is free software: you can redistribute it and/or modify * General Public License as published by the Free Software Foundation, either version 3 of the
it under the terms of the GNU General Public License as published by * License, or (at your option) any later version.
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
DIYLC is distributed in the hope that it will be useful, * Public License for more details.
but WITHOUT ANY WARRANTY; without even the implied warranty of *
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
GNU General Public License for more details. * <http://www.gnu.org/licenses/>.
*
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.semiconductors; package org.diylc.components.semiconductors;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
@@ -56,8 +53,8 @@ import org.diylc.utils.Constants;
@ComponentDescriptor(name = "DIP IC", author = "Branislav Stojkovic", category = "Semiconductors", @ComponentDescriptor(name = "DIP IC", author = "Branislav Stojkovic", category = "Semiconductors",
instanceNamePrefix = "IC", description = "Dual-in-line package IC", instanceNamePrefix = "IC", description = "Dual-in-line package IC",
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class, zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE,
enableCache = true) transformer = DIL_ICTransformer.class, enableCache = true)
public class DIL_IC extends AbstractLabeledComponent<String> { public class DIL_IC extends AbstractLabeledComponent<String> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -237,8 +234,10 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
default: default:
throw new RuntimeException("Unexpected orientation: " + orientation); throw new RuntimeException("Unexpected orientation: " + orientation);
} }
controlPoints[i] = new Point2D.Double((int) (firstPoint.getX() + dx1), (int) (firstPoint.getY() + dy1)); controlPoints[i] =
controlPoints[i + pinCount.getValue() / 2] = new Point2D.Double((int) (firstPoint.getX() + dx2), (int) (firstPoint.getY() + dy2)); new Point2D.Double((int) (firstPoint.getX() + dx1), (int) (firstPoint.getY() + dy1));
controlPoints[i + pinCount.getValue() / 2] =
new Point2D.Double((int) (firstPoint.getX() + dx2), (int) (firstPoint.getY() + dy2));
} }
} }
@@ -260,41 +259,38 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
height = (pinCount.getValue() / 2) * pinSpacing; height = (pinCount.getValue() / 2) * pinSpacing;
x += pinSize / 2; x += pinSize / 2;
y -= pinSpacing / 2; y -= pinSpacing / 2;
indentation = indentation = new Area(new Ellipse2D.Double(x + width / 2 - indentationSize / 2,
new Area(new Ellipse2D.Double(x + width / 2 - indentationSize / 2, y - indentationSize / 2, y - indentationSize / 2, indentationSize, indentationSize));
indentationSize, indentationSize));
break; break;
case _90: case _90:
width = (pinCount.getValue() / 2) * pinSpacing; width = (pinCount.getValue() / 2) * pinSpacing;
height = rowSpacing - pinSize; height = rowSpacing - pinSize;
x -= (pinSpacing / 2) + width - pinSpacing; x -= (pinSpacing / 2) + width - pinSpacing;
y += pinSize / 2; y += pinSize / 2;
indentation = indentation = new Area(new Ellipse2D.Double(x + width - indentationSize / 2,
new Area(new Ellipse2D.Double(x + width - indentationSize / 2, y + height / 2 - indentationSize / 2, y + height / 2 - indentationSize / 2, indentationSize, indentationSize));
indentationSize, indentationSize));
break; break;
case _180: case _180:
width = rowSpacing - pinSize; width = rowSpacing - pinSize;
height = (pinCount.getValue() / 2) * pinSpacing; height = (pinCount.getValue() / 2) * pinSpacing;
x -= rowSpacing - pinSize / 2; x -= rowSpacing - pinSize / 2;
y -= (pinSpacing / 2) + height - pinSpacing; y -= (pinSpacing / 2) + height - pinSpacing;
indentation = indentation = new Area(new Ellipse2D.Double(x + width / 2 - indentationSize / 2,
new Area(new Ellipse2D.Double(x + width / 2 - indentationSize / 2, y + height - indentationSize / 2, y + height - indentationSize / 2, indentationSize, indentationSize));
indentationSize, indentationSize));
break; break;
case _270: case _270:
width = (pinCount.getValue() / 2) * pinSpacing; width = (pinCount.getValue() / 2) * pinSpacing;
height = rowSpacing - pinSize; height = rowSpacing - pinSize;
x -= pinSpacing / 2; x -= pinSpacing / 2;
y += pinSize / 2 - rowSpacing; y += pinSize / 2 - rowSpacing;
indentation = indentation = new Area(new Ellipse2D.Double(x - indentationSize / 2,
new Area(new Ellipse2D.Double(x - indentationSize / 2, y + height / 2 - indentationSize / 2, y + height / 2 - indentationSize / 2, indentationSize, indentationSize));
indentationSize, indentationSize));
break; break;
default: default:
throw new RuntimeException("Unexpected orientation: " + orientation); throw new RuntimeException("Unexpected orientation: " + orientation);
} }
body[0] = new Area(new RoundRectangle2D.Double(x, y, width, height, EDGE_RADIUS, EDGE_RADIUS)); body[0] =
new Area(new RoundRectangle2D.Double(x, y, width, height, EDGE_RADIUS, EDGE_RADIUS));
body[1] = indentation; body[1] = indentation;
if (indentation != null) { if (indentation != null) {
indentation.intersect(body[0]); indentation.intersect(body[0]);
@@ -304,8 +300,8 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
} }
@Override @Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project, public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
IDrawingObserver drawingObserver) { Project project, IDrawingObserver drawingObserver) {
if (checkPointsClipped(g2d.getClip())) { if (checkPointsClipped(g2d.getClip())) {
return; return;
} }
@@ -314,7 +310,8 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
if (!outlineMode) { if (!outlineMode) {
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2; int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
for (Point2D point : controlPoints) { for (Point2D point : controlPoints) {
Rectangle2D rect = new Rectangle2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2, pinSize, pinSize); Rectangle2D rect = new Rectangle2D.Double(point.getX() - pinSize / 2,
point.getY() - pinSize / 2, pinSize, pinSize);
g2d.setColor(PIN_COLOR); g2d.setColor(PIN_COLOR);
g2d.fill(rect); g2d.fill(rect);
g2d.setColor(PIN_BORDER_COLOR); g2d.setColor(PIN_BORDER_COLOR);
@@ -331,14 +328,16 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
Color finalBorderColor; Color finalBorderColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); Constants.DEFAULT_THEME);
finalBorderColor = finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: theme.getOutlineColor(); : theme.getOutlineColor();
} else { } else {
finalBorderColor = finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: getBorderColor(); : getBorderColor();
} }
g2d.setColor(finalBorderColor); g2d.setColor(finalBorderColor);
@@ -366,14 +365,16 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
Color finalLabelColor; Color finalLabelColor;
if (outlineMode) { if (outlineMode) {
Theme theme = Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME); Constants.DEFAULT_THEME);
finalLabelColor = finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED
: theme.getOutlineColor(); : theme.getOutlineColor();
} else { } else {
finalLabelColor = finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED
: getLabelColor(); : getLabelColor();
} }
g2d.setColor(finalLabelColor); g2d.setColor(finalLabelColor);
@@ -415,72 +416,46 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
g2d.translate(0, textHeight / 2); g2d.translate(0, textHeight / 2);
} }
g2d.drawString(l, (int)x, (int)y); g2d.drawString(l, (int) x, (int) y);
g2d.setTransform(oldTransform); g2d.setTransform(oldTransform);
} }
} }
// draw pin numbers // draw pin numbers
int pinNo = 0; if (getDisplayNumbers() != DisplayNumbers.NO) {
int j = 0; int pinSize = (int) PIN_SIZE.convertToPixels();
int k = 0;
int pinSize = (int) PIN_SIZE.convertToPixels();
for (Point2D point : controlPoints) {
pinNo++;
// determine points relative to rotation for (int i = 0; i < controlPoints.length; i++) {
int textX1 = (int) (point.getX() - 2 * pinSize); Point2D point = controlPoints[i];
int textY1 = (int) (point.getY() + pinSize / 2);
int textX2 = (int) (point.getX() + pinSize);
int textY2 = (int) (point.getY() + pinSize / 2);
if (orientation == Orientation._90) {
textX2 = textX2 - pinSize - pinSize / 2;
textY2 = textY2 + pinSize;
textX1 = textX1 + 2 * pinSize - pinSize / 2;
textY1 = textY1 - pinSize;
}
if (orientation == Orientation._180) {
textX1 = textX1 + 3 * pinSize;
textX2 = textX2 - 3 * pinSize;
}
if (orientation == Orientation._270) {
textX1 = textX1 + pinSize + pinSize / 2;
textY1 = textY1 + pinSize;
textX2 = textX2 - pinSize - pinSize / 2;
textY2 = textY2 - pinSize;
}
g2d.setFont(project.getFont().deriveFont((float) (project.getFont().getSize2D() * 0.66))); // determine points relative to rotation
if (displayNumbers == DisplayNumbers.DIP) { int textX1 = (int) (point.getX() - 2 * pinSize);
if (pinNo > pinCount.getValue() / 2) { int textY1 = (int) (point.getY() + pinSize / 2);
g2d.drawString(Integer.toString(pinCount.getValue() - j), textX1, textY1); int textX2 = (int) (point.getX() + pinSize);
j++; int textY2 = (int) (point.getY() + pinSize / 2);
} else { if (orientation == Orientation._90) {
g2d.drawString(Integer.toString(pinNo), textX2, textY2); textX2 = textX2 - pinSize - pinSize / 2;
textY2 = textY2 + pinSize;
textX1 = textX1 + 2 * pinSize - pinSize / 2;
textY1 = textY1 - pinSize;
} }
} else if (displayNumbers == DisplayNumbers.CONNECTOR) { if (orientation == Orientation._180) {
if (pinNo > pinCount.getValue() / 2) { textX1 = textX1 + 3 * pinSize;
k++; textX2 = textX2 - 3 * pinSize;
g2d.drawString(Integer.toString(pinNo - (pinCount.getValue() / 2) + k), textX1, textY1);
} else {
g2d.drawString(Integer.toString(pinNo + j), textX2, textY2);
j++;
} }
} else if (displayNumbers == DisplayNumbers.DIP_MIRROR) { if (orientation == Orientation._270) {
if (pinNo > pinCount.getValue() / 2) { textX1 = textX1 + pinSize + pinSize / 2;
g2d.drawString(Integer.toString(pinCount.getValue() - pinCount.getValue() + j + 1), textX1, textY1); textY1 = textY1 + pinSize;
j++; textX2 = textX2 - pinSize - pinSize / 2;
} else { textY2 = textY2 - pinSize;
g2d.drawString(Integer.toString(pinCount.getValue() - pinNo + 1), textX2, textY2);
} }
} else if (displayNumbers == DisplayNumbers.CONNECTOR_MIRROR) {
if (pinNo > pinCount.getValue() / 2) { g2d.setFont(project.getFont().deriveFont((float) (project.getFont().getSize2D() * 0.66)));
k++; if (i >= pinCount.getValue() / 2) {
g2d.drawString(Integer.toString(pinNo - (pinCount.getValue() / 2) + k - 1), textX1, textY1); g2d.drawString(getControlPointNodeName(i), textX1, textY1);
} else { } else {
g2d.drawString(Integer.toString(pinNo + j + 1), textX2, textY2); g2d.drawString(getControlPointNodeName(i), textX2, textY2);
j++;
} }
} }
} }
@@ -582,7 +557,40 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
maxY = p.getY(); maxY = p.getY();
} }
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin); return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin,
maxY - minY + 2 * margin);
}
@Override
public String getControlPointNodeName(int index) {
index++;
if (displayNumbers == DisplayNumbers.DIP) {
if (index > pinCount.getValue() / 2) {
return Integer.toString(pinCount.getValue() * 3 / 2 - index + 1);
} else {
return Integer.toString(index);
}
} else if (displayNumbers == DisplayNumbers.CONNECTOR) {
if (index > pinCount.getValue() / 2) {
return Integer.toString(index - pinCount.getValue() + index);
} else {
return Integer.toString(index * 2 - 1);
}
} else if (displayNumbers == DisplayNumbers.DIP_MIRROR) {
if (index > pinCount.getValue() / 2) {
return Integer.toString((index - pinCount.getValue() / 2));
} else {
return Integer.toString(pinCount.getValue() - index + 1);
}
} else if (displayNumbers == DisplayNumbers.CONNECTOR_MIRROR) {
if (index > pinCount.getValue() / 2) {
return Integer.toString(index - pinCount.getValue() + index - 1);
} else {
return Integer.toString(2 * index);
}
}
return null;
} }
public static enum PinCount { public static enum PinCount {
@@ -601,7 +609,8 @@ public class DIL_IC extends AbstractLabeledComponent<String> {
public enum DisplayNumbers { public enum DisplayNumbers {
NO("No"), DIP("DIP"), CONNECTOR("Connector"), DIP_MIRROR("DIP (Mirrored)"), CONNECTOR_MIRROR("Connector (Mirrored)"); NO("No"), DIP("DIP"), CONNECTOR("Connector"), DIP_MIRROR("DIP (Mirrored)"), CONNECTOR_MIRROR(
"Connector (Mirrored)");
private String label; private String label;
Binary file not shown.
Binary file not shown.