Some schematic symbols (transistors, potentiometer...) get into bad

state when rotated and flipped at the same time
This commit is contained in:
Branislav Stojkovic
2019-03-20 20:06:38 +01:00
parent 714db98afa
commit 78dcd27e1d
4 changed files with 26 additions and 12 deletions
@@ -104,8 +104,6 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
}
g2d.setColor(finalColor);
// Draw transistor
if (this.body == null) {
this.body = getBody();
applyOrientation(this.body);
@@ -164,7 +162,7 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
if (getMoveLabel()) {
drawCenteredText(g2d, label, controlPoints[3].x, controlPoints[3].y, flip == SymbolFlipping.X ? HorizontalAlignment.RIGHT
: HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
: HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
} else {
drawCenteredText(g2d, label, getLabelX(shapeRect, textRect, fontMetrics, outlineMode),
getLabelY(shapeRect, textRect, fontMetrics, outlineMode), flip == SymbolFlipping.X ? HorizontalAlignment.RIGHT
@@ -194,22 +192,22 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
protected void updateControlPoints() {
int pinSpacing = (int) PIN_SPACING.convertToPixels();
Point[] controlPoints = getNewControlPoints();
// Update control points.
Point[] controlPoints = getNewControlPoints();
int x = controlPoints[0].x;
int y = controlPoints[0].y;
int f = flip == SymbolFlipping.X ? -1 : 1;
int d = flip == SymbolFlipping.X ? (int) PIN_SPACING.convertToPixels() / 2 : 0;
controlPoints[1].x = x + f * pinSpacing * 2;
// set default point positions
controlPoints[1].x = x + pinSpacing * 2;
controlPoints[1].y = y - pinSpacing * 2;
controlPoints[2].x = x + f * pinSpacing * 2;
controlPoints[2].x = x + pinSpacing * 2;
controlPoints[2].y = y + pinSpacing * 2;
controlPoints[3].x = x + f * (int) (PIN_SPACING.convertToPixels() * 1.5 + d);
controlPoints[3].x = x + (int) (PIN_SPACING.convertToPixels() * 2);
controlPoints[3].y = y;
// apply rotation if needed
if (getOrientation() != Orientation.DEFAULT)
{
Point first = controlPoints[0];
@@ -218,6 +216,18 @@ public abstract class Abstract3LegSymbol extends AbstractComponent<String> {
for (int i = 1; i < controlPoints.length; i++) {
rotate.transform(controlPoints[i], controlPoints[i]);
}
}
// flip at the end
if (flip == SymbolFlipping.X) {
controlPoints[1].x = controlPoints[0].x - (controlPoints[1].x - controlPoints[0].x);
controlPoints[2].x = controlPoints[0].x - (controlPoints[2].x - controlPoints[0].x);
controlPoints[3].x = controlPoints[0].x - (controlPoints[3].x - controlPoints[0].x);
}
if (flip == SymbolFlipping.Y) {
controlPoints[1].y = controlPoints[0].y - (controlPoints[1].y - controlPoints[0].y);
controlPoints[2].y = controlPoints[0].y - (controlPoints[2].y - controlPoints[0].y);
controlPoints[3].y = controlPoints[0].y - (controlPoints[3].y - controlPoints[0].y);
}
}
Binary file not shown.
Binary file not shown.
+4
View File
@@ -2662,6 +2662,10 @@
<changeType>IMPROVEMENT</changeType>
<description>Scan "library" folder for any additional JAR files that may contain more components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Some schematic symbols (transistors, potentiometer...) get into bad state when rotated and flipped at the same time</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Z-order of components sometimes gets wrong when importing a DIY file into another file</description>