honor default lead properties, like point count

This commit is contained in:
bancika
2020-04-18 14:32:42 +02:00
parent e8031a6cb4
commit 01e1ed3f6c
4 changed files with 33 additions and 30 deletions
Binary file not shown.
@@ -73,21 +73,29 @@ public class FlexibleLeadsEditor implements IProjectEditor {
// create leads // create leads
HookupWire w1 = new HookupWire(); HookupWire w1 = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w1, null);
w1.setGauge(AWG._26); w1.setGauge(AWG._26);
w1.setLeadColor(leaded.getLeadColor()); w1.setLeadColor(leaded.getLeadColor());
w1.setPointCount(PointCount.THREE); // w1.setPointCount(PointCount.THREE);
w1.setControlPoint(p1, 0); w1.setControlPoint(p1, 0);
w1.setControlPoint(new Point((int)Math.round(centerX - Math.cos(theta) * (len / 2 + diff / 2)), (int)Math.round(centerY - Math.sin(theta) * (len / 2 + diff / 2))), 1); for (int i = 1; i < w1.getControlPointCount() - 1; i++) {
w1.setControlPoint(newP1, 2); double r = (len + diff) / (w1.getControlPointCount() - 1) * (w1.getControlPointCount() - i - 1);
w1.setControlPoint(new Point((int)Math.round(centerX - Math.cos(theta) * r), (int)Math.round(centerY - Math.sin(theta) * r)), i);
}
w1.setControlPoint(newP1, w1.getControlPointCount() - 1);
newSelection.add(w1); newSelection.add(w1);
HookupWire w2 = new HookupWire(); HookupWire w2 = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w2, null);
w2.setGauge(AWG._26); w2.setGauge(AWG._26);
w2.setLeadColor(leaded.getLeadColor()); w2.setLeadColor(leaded.getLeadColor());
w2.setPointCount(PointCount.THREE); // w2.setPointCount(PointCount.THREE);
w2.setControlPoint(p2, 0); w2.setControlPoint(p2, 0);
w2.setControlPoint(new Point((int)Math.round(centerX + Math.cos(theta) * (len / 2 + diff / 2)), (int)Math.round(centerY + Math.sin(theta) * (len / 2 + diff / 2))), 1); for (int i = 1; i < w2.getControlPointCount() - 1; i++) {
w2.setControlPoint(newP2, 2); double r = (len + diff) / (w2.getControlPointCount() - 1) * (w2.getControlPointCount() - i - 1);
w2.setControlPoint(new Point((int)Math.round(centerX + Math.cos(theta) * r), (int)Math.round(centerY + Math.sin(theta) * r)), i);
}
w2.setControlPoint(newP2, w2.getControlPointCount() - 1);
newSelection.add(w2); newSelection.add(w2);
// inject leads right before the component // inject leads right before the component
@@ -117,6 +125,7 @@ public class FlexibleLeadsEditor implements IProjectEditor {
} }
HookupWire w = new HookupWire(); HookupWire w = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w, null);
// make the leads thicker for TO220 and TO126 // make the leads thicker for TO220 and TO126
if (c instanceof TransistorTO220 || c instanceof TransistorTO126) if (c instanceof TransistorTO220 || c instanceof TransistorTO126)
w.setGauge(AWG._24); w.setGauge(AWG._24);
@@ -147,11 +156,11 @@ public class FlexibleLeadsEditor implements IProjectEditor {
} }
private void addLeads(PotentiometerPanel c, Project project, Set<IDIYComponent<?>> newSelection) { private void addLeads(PotentiometerPanel c, Project project, Set<IDIYComponent<?>> newSelection) {
Size offsetY = new Size(1d, SizeUnit.in); Size offsetY = new Size(0.5d, SizeUnit.in);
// don't do it for PCB type // don't do it for PCB type
if (c.getType() == Type.PCB) if (c.getType() == Type.PCB)
return; return;
// create leads // create leads
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@@ -159,22 +168,19 @@ public class FlexibleLeadsEditor implements IProjectEditor {
double dx = 0; double dx = 0;
double dy = offsetY.convertToPixels(); double dy = offsetY.convertToPixels();
// calculate lead position AffineTransform tx = null;
Point p1 = new Point((int)(p0.x + dx / 2), (int)(p0.y + dy / 2)); if (c.getOrientation() != Orientation.DEFAULT)
Point p2 = new Point((int)(p0.x + dx), (int)(p0.y + dy)); tx = AffineTransform.getRotateInstance(c.getOrientation().toRadians(), p0.x, p0.y);
if (c.getOrientation() != Orientation.DEFAULT) {
AffineTransform tx = AffineTransform.getRotateInstance(c.getOrientation().toRadians(), p0.x, p0.y);
tx.transform(p1, p1);
tx.transform(p2, p2);
}
HookupWire w = new HookupWire(); HookupWire w = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w, null); getInstantiationManager().fillWithDefaultProperties(w, null);
w.setPointCount(PointCount.THREE); for (int j = 0; j < w.getControlPointCount(); j++) {
w.setControlPoint(p0, 0); Point p = new Point((int)(p0.x + dx * j), (int)(p0.y + dy * j));
w.setControlPoint(p1, 1); if (tx != null)
w.setControlPoint(p2, 2); tx.transform(p, p);
w.setControlPoint(p, j);
}
newSelection.add(w); newSelection.add(w);
// inject leads right before the component // inject leads right before the component
@@ -196,16 +202,13 @@ public class FlexibleLeadsEditor implements IProjectEditor {
double dx = p.x - center.x; double dx = p.x - center.x;
double dy = p.y - center.y; double dy = p.y - center.y;
// calculate lead position // calculate lead position
Point p1 = new Point((int)(p.x + dx), (int)(p.y + dy));
Point p2 = new Point((int)(p.x + dx * 2), (int)(p.y + dy * 2));
HookupWire w = new HookupWire(); HookupWire w = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w, null); getInstantiationManager().fillWithDefaultProperties(w, null);
w.setPointCount(PointCount.THREE); for (int j = 0; j < w.getControlPointCount(); j++) {
w.setControlPoint(p, 0); Point pw = new Point((int)(p.x + dx * j), (int)(p.y + dy * j));
w.setControlPoint(p1, 1); w.setControlPoint(pw, j);
w.setControlPoint(p2, 2); }
newSelection.add(w); newSelection.add(w);
// inject leads right before the component // inject leads right before the component
Binary file not shown.
Binary file not shown.