From d67e3dc1ec6e4401d0ee334f526a53963d0720b5 Mon Sep 17 00:00:00 2001 From: iobyte Date: Fri, 19 Jan 2024 21:46:45 +0000 Subject: [PATCH] trackeditor: fix segment split profil steps length git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9264 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: e2d8499508515594060ced3a1b02ab422f187643 Former-commit-id: f8ed8814c421bbedc512c2db472a562078ce7875 --- src/tools/trackeditor/gui/view/CircuitView.java | 10 ++++++---- src/tools/trackeditor/utils/Properties.java | 2 +- src/tools/trackeditor/utils/circuit/Segment.java | 13 ++++--------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/tools/trackeditor/gui/view/CircuitView.java b/src/tools/trackeditor/gui/view/CircuitView.java index 4b66d46b..6583c593 100644 --- a/src/tools/trackeditor/gui/view/CircuitView.java +++ b/src/tools/trackeditor/gui/view/CircuitView.java @@ -454,6 +454,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene SegmentVector data = editorFrame.getTrackData().getSegments(); int pos = data.indexOf(handledShape); double splitPoint = 0.5; + double profilStepsLength = handledShape.getValidProfilStepsLength(editorFrame); switch (handledShape.getType()) { case "lft": @@ -465,7 +466,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene double rStart = oldShape.getRadiusStart(); double rEnd = oldShape.getRadiusEnd(); double L = (rStart + rEnd) / 2.0 * oldShape.getArcDeg(); - double nbSteps = (int)(L / 4.0 + 0.5) + 1; + double nbSteps = (int)(L / profilStepsLength + 0.5) + 1; double stepLength = L / nbSteps; double deltaRadiusStep = (rEnd - rStart) / (nbSteps - 1.0); double tmpAngle = 0.0; @@ -495,7 +496,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene newShape2.setRadiusEnd(rEnd); newShape2.setRadiusStart(tmpRadius); splitSegment(oldShape, newShape2, splitPoint); - newShape2.setProfilStepsLength(4.0); + newShape2.setProfilStepsLength(oldShape.getProfilStepsLength()); int count2 = Editor.getProperties().getCurveNameCount() + 1; Editor.getProperties().setCurveNameCount(count2); newShape2.setName("curve " + count2); @@ -512,7 +513,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene double rStart = oldShape.getRadiusStart(); double rEnd = oldShape.getRadiusEnd(); double L = (rStart + rEnd) / 2.0 * oldShape.getArcDeg(); - double nbSteps = (int)(L / 4.0 + 0.5) + 1; + double nbSteps = (int)(L / profilStepsLength + 0.5) + 1; double stepLength = L / nbSteps; final double deltaRadiusStep = (rEnd - rStart) / (nbSteps - 1.0); double tmpAngle = 0.0; @@ -542,7 +543,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene newShape2.setRadiusEnd(rEnd); newShape2.setRadiusStart(tmpRadius); splitSegment(oldShape, newShape2, splitPoint); - newShape2.setProfilStepsLength(4.0); + newShape2.setProfilStepsLength(oldShape.getProfilStepsLength()); int count2 = Editor.getProperties().getCurveNameCount() + 1; Editor.getProperties().setCurveNameCount(count2); newShape2.setName("curve " + count2); @@ -568,6 +569,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene } } splitSegment(oldShape, newShape3, splitPoint); + newShape3.setProfilStepsLength(oldShape.getProfilStepsLength()); int count3 = Editor.getProperties().getStraightNameCount() + 1; Editor.getProperties().setStraightNameCount(count3); newShape3.setName("straight " + count3); diff --git a/src/tools/trackeditor/utils/Properties.java b/src/tools/trackeditor/utils/Properties.java index 7359750f..fde7c5de 100644 --- a/src/tools/trackeditor/utils/Properties.java +++ b/src/tools/trackeditor/utils/Properties.java @@ -34,7 +34,7 @@ public class Properties private static Properties instance = new Properties(); private Vector propertiesListeners = new Vector(); public final String title = "sd2-trackeditor"; - public final String version = "1.4.10"; + public final String version = "1.4.11"; private String path; private double imageScale = 1; diff --git a/src/tools/trackeditor/utils/circuit/Segment.java b/src/tools/trackeditor/utils/circuit/Segment.java index ad07cfa3..5f2a91ff 100644 --- a/src/tools/trackeditor/utils/circuit/Segment.java +++ b/src/tools/trackeditor/utils/circuit/Segment.java @@ -877,18 +877,13 @@ public class Segment implements Cloneable return surf; } + // this is not inherited public double getValidProfilStepsLength(EditorFrame editorFrame) { - Segment previous = this; - double length; - while (previous != null) + double length = profilStepsLength; + if (hasProfilStepsLength()) { - length = profilStepsLength; - if (!Double.isNaN(profilStepsLength)) - { - return length; - } - previous = previous.previousShape; + return length; } length = editorFrame.getTrackData().getMainTrack().getProfilStepsLength();