From 9ac2d2f8442237bdaba1e352eebf61feea386996 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sun, 4 Jul 2021 21:25:55 +0200 Subject: [PATCH 1/4] [fixes #976] Sometimes can't select components when behind body tube --- .../openrocket/rocketcomponent/BodyTube.java | 1 + .../openrocket/rocketcomponent/Bulkhead.java | 1 + .../rocketcomponent/CenteringRing.java | 1 + .../rocketcomponent/EngineBlock.java | 1 + .../sf/openrocket/rocketcomponent/FinSet.java | 1 + .../openrocket/rocketcomponent/InnerTube.java | 2 + .../openrocket/rocketcomponent/LaunchLug.java | 1 + .../rocketcomponent/MassComponent.java | 2 + .../openrocket/rocketcomponent/NoseCone.java | 2 + .../openrocket/rocketcomponent/Parachute.java | 1 + .../rocketcomponent/RailButton.java | 3 ++ .../rocketcomponent/RocketComponent.java | 18 ++++++++- .../openrocket/rocketcomponent/ShockCord.java | 1 + .../openrocket/rocketcomponent/Streamer.java | 1 + .../rocketcomponent/Transition.java | 2 + .../rocketcomponent/TubeCoupler.java | 1 + .../rocketcomponent/TubeFinSet.java | 1 + .../rocketfigure/RocketComponentShape.java | 10 +++-- .../gui/scalefigure/RocketFigure.java | 39 ++++++++++--------- 19 files changed, 65 insertions(+), 24 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java index 2a43e7279..577576a51 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java @@ -45,6 +45,7 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou this.outerRadius = Math.max(radius, 0); this.length = Math.max(length, 0); motors = new MotorConfigurationSet(this); + super.displayOrder = 0; // Order for displaying the component in the 2D view } public BodyTube(double length, double radius, boolean filled) { diff --git a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java index deedd0814..409d18399 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java @@ -13,6 +13,7 @@ public class Bulkhead extends RadiusRingComponent { public Bulkhead() { setOuterRadiusAutomatic(true); setLength(0.002); + super.displayOrder = 10; // Order for displaying the component in the 2D view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java index be94964ec..d3c70aeb4 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java +++ b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java @@ -13,6 +13,7 @@ public class CenteringRing extends RadiusRingComponent { setOuterRadiusAutomatic(true); setInnerRadiusAutomatic(true); setLength(0.002); + super.displayOrder = 9; // Order for displaying the component in the 2D view } private static final Translator trans = Application.getTranslator(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java b/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java index 748b548ac..d3d88fbbc 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java +++ b/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java @@ -16,6 +16,7 @@ public class EngineBlock extends ThicknessRingComponent implements AxialPosition setOuterRadiusAutomatic(true); setThickness(0.005); setLength(0.005); + super.displayOrder = 11; // Order for displaying the component in the 2D view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index be8333acf..c58bea2a3 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -134,6 +134,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona public FinSet() { super( AxialMethod.BOTTOM); this.filletMaterial = Application.getPreferences().getDefaultComponentMaterial(this.getClass(), Material.Type.BULK); + super.displayOrder = 4; // Order for displaying the component in the 2D view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index 4d167d58d..11d71bd8d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -48,6 +48,8 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab this.setLength(0.070); motors = new MotorConfigurationSet(this); + + super.displayOrder = 7; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java index 26a4a126c..4f8403581 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java +++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java @@ -37,6 +37,7 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B radius = 0.01 / 2; thickness = 0.001; length = 0.03; + super.displayOrder = 6; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java index 0bfb75c03..d97b4b9ce 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java @@ -41,11 +41,13 @@ public class MassComponent extends MassObject { public MassComponent() { super(); + super.displayOrder = 15; // Order for displaying the component in the 2D view } public MassComponent(double length, double radius, double mass) { super(length, radius); this.mass = mass; + super.displayOrder = 14; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java index bc9855953..99100e3cd 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java +++ b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java @@ -42,6 +42,8 @@ public class NoseCone extends Transition implements InsideColorComponent { super.setAftRadiusAutomatic(false); super.setAftRadius(radius); + + super.displayOrder = 1; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java index aabb6117f..78a4aab40 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java @@ -23,6 +23,7 @@ public class Parachute extends RecoveryDevice { this.diameter = 0.3; this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE); this.lineLength = 0.3; + super.displayOrder = 12; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index 5ce537034..65bfa4892 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -69,12 +69,14 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( 0.002); this.setInstanceSeparation( this.outerDiameter_m * 6); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); + super.displayOrder = 5; // Order for displaying the component in the 2D view } public RailButton( final double od, final double ht ) { this(); this.setOuterDiameter( od); this.setTotalHeight( ht); + super.displayOrder = 5; // Order for displaying the component in the 2D view } public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) { @@ -86,6 +88,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( _standoff); this.setInstanceSeparation( od*2); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); + super.displayOrder = 5; // Order for displaying the component in the 2D view } private static final RailButton make1010Button(){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java index 269ec1813..b4d96c75b 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java @@ -126,8 +126,14 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab * Used to invalidate the component after calling {@link #copyFrom(RocketComponent)}. */ private Invalidator invalidator = new Invalidator(this); - - + + + /** + * This is for determining the order in which the component should be drawn in the 2D views. + * Lower values will be placed more in the back, higher values more in the front. + */ + protected int displayOrder = 100; // Take a high enough init value to not mess with pre-defined values + //// NOTE !!! All fields must be copied in the method copyFrom()! //// @@ -2014,6 +2020,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab this.name = src.name; this.comment = src.comment; this.id = src.id; + this.displayOrder = src.displayOrder; // Add source components to invalidation tree for (RocketComponent c : src) { @@ -2229,4 +2236,11 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab return false; } + public int getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(int displayOrder) { + this.displayOrder = displayOrder; + } } diff --git a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java index 8012a87e1..93f0f8cc2 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java @@ -15,6 +15,7 @@ public class ShockCord extends MassObject { public ShockCord() { material = Application.getPreferences().getDefaultComponentMaterial(ShockCord.class, Material.Type.LINE); cordLength = 0.4; + super.displayOrder = 13; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java index 058392e93..f9cf3db47 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java @@ -21,6 +21,7 @@ public class Streamer extends RecoveryDevice { public Streamer() { this.stripLength = 0.5; this.stripWidth = 0.05; + super.displayOrder = 12; // Order for displaying the component in the 2D view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Transition.java b/core/src/net/sf/openrocket/rocketcomponent/Transition.java index f8852c12a..c70b95bf8 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Transition.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Transition.java @@ -58,6 +58,8 @@ public class Transition extends SymmetricComponent implements InsideColorCompone this.type = Shape.CONICAL; this.shapeParameter = 0; this.clipped = true; + + super.displayOrder = 2; // Order for displaying the component in the 2D view } //////// Length //////// diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java index 4f50099c3..2ca4fdabb 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java @@ -13,6 +13,7 @@ public class TubeCoupler extends ThicknessRingComponent implements RadialParent setOuterRadiusAutomatic(true); setThickness(0.002); setLength(0.06); + super.displayOrder = 8; // Order for displaying the component in the 2D view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java index 4dd4843b6..711c2feb7 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java @@ -56,6 +56,7 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, public TubeFinSet() { super(AxialMethod.BOTTOM); length = 0.10; + super.displayOrder = 3; // Order for displaying the component in the 2D view } public void setLength(double length) { diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java b/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java index 29603ffc3..986888c6e 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java @@ -12,7 +12,7 @@ import net.sf.openrocket.util.Transformation; /** * A catch-all, no-operation drawing component. */ -public class RocketComponentShape { +public class RocketComponentShape implements Comparable { final public boolean hasShape; final public Shape shape; @@ -71,6 +71,10 @@ public class RocketComponentShape { } return toReturn; } - - + + + @Override + public int compareTo(RocketComponentShape o) { + return Integer.compare(o.component.getDisplayOrder(), this.component.getDisplayOrder()); + } } diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index a5574267b..986ad3c90 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -14,8 +14,7 @@ import java.awt.geom.Ellipse2D; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.LinkedHashSet; +import java.util.*; import java.util.Map.Entry; import org.slf4j.Logger; @@ -74,10 +73,12 @@ public class RocketFigure extends AbstractScaleFigure { private double rotation; private Transformation axialRotation; - /* - * figureComponents contains the corresponding RocketComponents of the figureShapes + /** + * The shapes to be drawn are stored in this Priority Queue, where the first shape to be drawn is the one with + * the highest priority, namely being the one where the corresponding RocketComponent has the highest displayOrder + * (declared in RocketComponent, can be overridden in separate components). */ - private final ArrayList figureShapes = new ArrayList(); + private final PriorityQueue figureShapes = new PriorityQueue<>(); private final ArrayList relativeExtra = new ArrayList(); @@ -207,12 +208,12 @@ public class RocketFigure extends AbstractScaleFigure { RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - int shapeCount = figureShapes.size(); + // Draw all shapes - for (int i = 0; i < shapeCount; i++) { - RocketComponentShape rcs = figureShapes.get(i); - RocketComponent c = rcs.getComponent(); + PriorityQueue figureShapesCopy = new PriorityQueue<>(figureShapes); + while (!figureShapesCopy.isEmpty()) { + RocketComponentShape rcs = figureShapesCopy.poll(); + RocketComponent c = rcs.getComponent(); boolean selected = false; // Check if component is in the selection @@ -330,16 +331,18 @@ public class RocketFigure extends AbstractScaleFigure { } LinkedHashSet l = new LinkedHashSet(); - - for (int i = 0; i < figureShapes.size(); i++) { - RocketComponentShape rcs = this.figureShapes.get(i); + + + PriorityQueue figureShapesCopy = new PriorityQueue<>(figureShapes); + while (!figureShapesCopy.isEmpty()) { + RocketComponentShape rcs = figureShapesCopy.poll(); if (rcs.shape.contains(p)) l.add(rcs.component); } return l.toArray(new RocketComponent[0]); } - private void updateShapes(ArrayList allShapes) { + private void updateShapes(PriorityQueue allShapes) { // source input final FlightConfiguration config = rocket.getSelectedConfiguration(); @@ -369,8 +372,8 @@ public class RocketFigure extends AbstractScaleFigure { * * @return the ArrayList containing all the shapes to draw. */ - private static ArrayList addThisShape( - ArrayList allShapes, // this is the output parameter + private static PriorityQueue addThisShape( + PriorityQueue allShapes, // this is the output parameter final RocketPanel.VIEW_TYPE viewType, final RocketComponent component, final Transformation transformation) { @@ -405,9 +408,7 @@ public class RocketFigure extends AbstractScaleFigure { RocketComponentShape[] returnValue = (RocketComponentShape[]) m.invokeStatic(component, transformation); - for ( RocketComponentShape curShape : returnValue ){ - allShapes.add( curShape ); - } + allShapes.addAll(Arrays.asList(returnValue)); return allShapes; } From c21127f4e3621ec26042b1ae0bcff0230db8ad8b Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sat, 10 Jul 2021 19:29:39 +0200 Subject: [PATCH 2/4] [fixes #976] Added different display order for side view and back view --- .../openrocket/rocketcomponent/BodyTube.java | 3 ++- .../openrocket/rocketcomponent/Bulkhead.java | 3 ++- .../rocketcomponent/CenteringRing.java | 3 ++- .../rocketcomponent/EngineBlock.java | 3 ++- .../sf/openrocket/rocketcomponent/FinSet.java | 3 ++- .../openrocket/rocketcomponent/InnerTube.java | 3 ++- .../openrocket/rocketcomponent/LaunchLug.java | 3 ++- .../rocketcomponent/MassComponent.java | 6 +++-- .../openrocket/rocketcomponent/NoseCone.java | 3 ++- .../openrocket/rocketcomponent/Parachute.java | 3 ++- .../rocketcomponent/RailButton.java | 9 ++++--- .../rocketcomponent/RocketComponent.java | 26 ++++++++++++++----- .../openrocket/rocketcomponent/ShockCord.java | 3 ++- .../openrocket/rocketcomponent/Streamer.java | 3 ++- .../rocketcomponent/Transition.java | 3 ++- .../rocketcomponent/TubeCoupler.java | 3 ++- .../rocketcomponent/TubeFinSet.java | 3 ++- .../rocketfigure/RocketComponentShape.java | 8 +----- .../gui/scalefigure/RocketFigure.java | 26 +++++++++++++++++-- 19 files changed, 82 insertions(+), 35 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java index 577576a51..846174e3f 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java @@ -45,7 +45,8 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou this.outerRadius = Math.max(radius, 0); this.length = Math.max(length, 0); motors = new MotorConfigurationSet(this); - super.displayOrder = 0; // Order for displaying the component in the 2D view + super.displayOrder_side = 0; // Order for displaying the component in the 2D side view + super.displayOrder_back = 0; // Order for displaying the component in the 2D back view } public BodyTube(double length, double radius, boolean filled) { diff --git a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java index 409d18399..2e67cee3e 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java @@ -13,7 +13,8 @@ public class Bulkhead extends RadiusRingComponent { public Bulkhead() { setOuterRadiusAutomatic(true); setLength(0.002); - super.displayOrder = 10; // Order for displaying the component in the 2D view + super.displayOrder_side = 10; // Order for displaying the component in the 2D side view + super.displayOrder_back = 10; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java index d3c70aeb4..15e67ba9a 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java +++ b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java @@ -13,7 +13,8 @@ public class CenteringRing extends RadiusRingComponent { setOuterRadiusAutomatic(true); setInnerRadiusAutomatic(true); setLength(0.002); - super.displayOrder = 9; // Order for displaying the component in the 2D view + super.displayOrder_side = 9; // Order for displaying the component in the 2D side view + super.displayOrder_back = 9; // Order for displaying the component in the 2D back view } private static final Translator trans = Application.getTranslator(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java b/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java index d3d88fbbc..a33b9109f 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java +++ b/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java @@ -16,7 +16,8 @@ public class EngineBlock extends ThicknessRingComponent implements AxialPosition setOuterRadiusAutomatic(true); setThickness(0.005); setLength(0.005); - super.displayOrder = 11; // Order for displaying the component in the 2D view + super.displayOrder_side = 11; // Order for displaying the component in the 2D side view + super.displayOrder_back = 11; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index c58bea2a3..7c07b0c57 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -134,7 +134,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona public FinSet() { super( AxialMethod.BOTTOM); this.filletMaterial = Application.getPreferences().getDefaultComponentMaterial(this.getClass(), Material.Type.BULK); - super.displayOrder = 4; // Order for displaying the component in the 2D view + super.displayOrder_side = 4; // Order for displaying the component in the 2D side view + super.displayOrder_back = 4; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index 11d71bd8d..5dfa8b9b8 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -49,7 +49,8 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab motors = new MotorConfigurationSet(this); - super.displayOrder = 7; // Order for displaying the component in the 2D view + super.displayOrder_side = 7; // Order for displaying the component in the 2D side view + super.displayOrder_back = 7; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java index 4f8403581..24e82e884 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java +++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java @@ -37,7 +37,8 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B radius = 0.01 / 2; thickness = 0.001; length = 0.03; - super.displayOrder = 6; // Order for displaying the component in the 2D view + super.displayOrder_side = 6; // Order for displaying the component in the 2D side view + super.displayOrder_back = 6; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java index d97b4b9ce..a2c5ba194 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java @@ -41,13 +41,15 @@ public class MassComponent extends MassObject { public MassComponent() { super(); - super.displayOrder = 15; // Order for displaying the component in the 2D view + super.displayOrder_side = 14; // Order for displaying the component in the 2D side view + super.displayOrder_back = 14; // Order for displaying the component in the 2D back view } public MassComponent(double length, double radius, double mass) { super(length, radius); this.mass = mass; - super.displayOrder = 14; // Order for displaying the component in the 2D view + super.displayOrder_side = 14; // Order for displaying the component in the 2D side view + super.displayOrder_back = 14; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java index 99100e3cd..864f443fa 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java +++ b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java @@ -43,7 +43,8 @@ public class NoseCone extends Transition implements InsideColorComponent { super.setAftRadiusAutomatic(false); super.setAftRadius(radius); - super.displayOrder = 1; // Order for displaying the component in the 2D view + super.displayOrder_side = 1; // Order for displaying the component in the 2D side view + super.displayOrder_back = 1; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java index 78a4aab40..a0975417f 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java @@ -23,7 +23,8 @@ public class Parachute extends RecoveryDevice { this.diameter = 0.3; this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE); this.lineLength = 0.3; - super.displayOrder = 12; // Order for displaying the component in the 2D view + super.displayOrder_side = 12; // Order for displaying the component in the 2D side view + super.displayOrder_back = 12; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index 65bfa4892..32dc7a2eb 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -69,14 +69,16 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( 0.002); this.setInstanceSeparation( this.outerDiameter_m * 6); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); - super.displayOrder = 5; // Order for displaying the component in the 2D view + super.displayOrder_side = 5; // Order for displaying the component in the 2D side view + super.displayOrder_back = 5; // Order for displaying the component in the 2D back view } public RailButton( final double od, final double ht ) { this(); this.setOuterDiameter( od); this.setTotalHeight( ht); - super.displayOrder = 5; // Order for displaying the component in the 2D view + super.displayOrder_side = 5; // Order for displaying the component in the 2D side view + super.displayOrder_back = 5; // Order for displaying the component in the 2D back view } public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) { @@ -88,7 +90,8 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( _standoff); this.setInstanceSeparation( od*2); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); - super.displayOrder = 5; // Order for displaying the component in the 2D view + super.displayOrder_side = 5; // Order for displaying the component in the 2D side view + super.displayOrder_back = 5; // Order for displaying the component in the 2D back view } private static final RailButton make1010Button(){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java index b4d96c75b..92c8f3fea 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java @@ -129,10 +129,13 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab /** - * This is for determining the order in which the component should be drawn in the 2D views. + * This is for determining the order in which the component should be drawn in the 2D views, both + * in the side view and in the back view. * Lower values will be placed more in the back, higher values more in the front. + * A high enough init value is picked to not mess with pre-defined values. */ - protected int displayOrder = 100; // Take a high enough init value to not mess with pre-defined values + protected int displayOrder_side = 100; + protected int displayOrder_back = 100; //// NOTE !!! All fields must be copied in the method copyFrom()! //// @@ -2020,7 +2023,8 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab this.name = src.name; this.comment = src.comment; this.id = src.id; - this.displayOrder = src.displayOrder; + this.displayOrder_side = src.displayOrder_side; + this.displayOrder_back = src.displayOrder_back; // Add source components to invalidation tree for (RocketComponent c : src) { @@ -2236,11 +2240,19 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab return false; } - public int getDisplayOrder() { - return displayOrder; + public int getDisplayOrder_side() { + return displayOrder_side; } - public void setDisplayOrder(int displayOrder) { - this.displayOrder = displayOrder; + public void setDisplayOrder_side(int displayOrder_side) { + this.displayOrder_side = displayOrder_side; + } + + public int getDisplayOrder_back() { + return displayOrder_back; + } + + public void setDisplayOrder_back(int displayOrder_back) { + this.displayOrder_back = displayOrder_back; } } diff --git a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java index 93f0f8cc2..395965f2d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java @@ -15,7 +15,8 @@ public class ShockCord extends MassObject { public ShockCord() { material = Application.getPreferences().getDefaultComponentMaterial(ShockCord.class, Material.Type.LINE); cordLength = 0.4; - super.displayOrder = 13; // Order for displaying the component in the 2D view + super.displayOrder_side = 13; // Order for displaying the component in the 2D side view + super.displayOrder_back = 13; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java index f9cf3db47..55404a050 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java @@ -21,7 +21,8 @@ public class Streamer extends RecoveryDevice { public Streamer() { this.stripLength = 0.5; this.stripWidth = 0.05; - super.displayOrder = 12; // Order for displaying the component in the 2D view + super.displayOrder_side = 12; // Order for displaying the component in the 2D side view + super.displayOrder_back = 12; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Transition.java b/core/src/net/sf/openrocket/rocketcomponent/Transition.java index c70b95bf8..304750066 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Transition.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Transition.java @@ -59,7 +59,8 @@ public class Transition extends SymmetricComponent implements InsideColorCompone this.shapeParameter = 0; this.clipped = true; - super.displayOrder = 2; // Order for displaying the component in the 2D view + super.displayOrder_side = 2; // Order for displaying the component in the 2D side view + super.displayOrder_back = 2; // Order for displaying the component in the 2D back view } //////// Length //////// diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java index 2ca4fdabb..d09e77875 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java @@ -13,7 +13,8 @@ public class TubeCoupler extends ThicknessRingComponent implements RadialParent setOuterRadiusAutomatic(true); setThickness(0.002); setLength(0.06); - super.displayOrder = 8; // Order for displaying the component in the 2D view + super.displayOrder_side = 8; // Order for displaying the component in the 2D side view + super.displayOrder_back = 8; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java index 711c2feb7..1dcc33dd2 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeFinSet.java @@ -56,7 +56,8 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable, public TubeFinSet() { super(AxialMethod.BOTTOM); length = 0.10; - super.displayOrder = 3; // Order for displaying the component in the 2D view + super.displayOrder_side = 3; // Order for displaying the component in the 2D side view + super.displayOrder_back = 3; // Order for displaying the component in the 2D back view } public void setLength(double length) { diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java b/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java index 986888c6e..8bc9cf7a3 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java @@ -12,7 +12,7 @@ import net.sf.openrocket.util.Transformation; /** * A catch-all, no-operation drawing component. */ -public class RocketComponentShape implements Comparable { +public class RocketComponentShape { final public boolean hasShape; final public Shape shape; @@ -71,10 +71,4 @@ public class RocketComponentShape implements Comparable { } return toReturn; } - - - @Override - public int compareTo(RocketComponentShape o) { - return Integer.compare(o.component.getDisplayOrder(), this.component.getDisplayOrder()); - } } diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 986ad3c90..ab3330a0b 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -78,7 +78,10 @@ public class RocketFigure extends AbstractScaleFigure { * the highest priority, namely being the one where the corresponding RocketComponent has the highest displayOrder * (declared in RocketComponent, can be overridden in separate components). */ - private final PriorityQueue figureShapes = new PriorityQueue<>(); + private final PriorityQueue figureShapes_side = new PriorityQueue<>( + Comparator.comparingInt(o -> -o.component.getDisplayOrder_side())); + private final PriorityQueue figureShapes_back = new PriorityQueue<>( + Comparator.comparingInt(o -> -o.component.getDisplayOrder_back())); private final ArrayList relativeExtra = new ArrayList(); @@ -191,13 +194,23 @@ public class RocketFigure extends AbstractScaleFigure { Graphics2D g2 = (Graphics2D) g; AffineTransform baseTransform = g2.getTransform(); + + PriorityQueue figureShapes; + if (currentViewType == RocketPanel.VIEW_TYPE.SideView) + figureShapes = figureShapes_side; + else if (currentViewType == RocketPanel.VIEW_TYPE.BackView) + figureShapes = figureShapes_back; + else { + log.warn("Unknown view type for paintComponent"); + return; + } updateSubjectDimensions(); updateCanvasOrigin(); updateCanvasSize(); updateTransform(); - updateShapes(this.figureShapes); + updateShapes(figureShapes); g2.transform(projection); @@ -332,6 +345,15 @@ public class RocketFigure extends AbstractScaleFigure { LinkedHashSet l = new LinkedHashSet(); + PriorityQueue figureShapes; + if (currentViewType == RocketPanel.VIEW_TYPE.SideView) + figureShapes = figureShapes_side; + else if (currentViewType == RocketPanel.VIEW_TYPE.BackView) + figureShapes = figureShapes_back; + else { + log.warn("Unknown view type for getComponentsByPoint"); + return null; + } PriorityQueue figureShapesCopy = new PriorityQueue<>(figureShapes); while (!figureShapesCopy.isEmpty()) { From 6d7e25b0a894dc3f2099ecea44b857dadc252e19 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Sat, 10 Jul 2021 19:49:42 +0200 Subject: [PATCH 3/4] [fixes #976] Updated display order v1.0 --- .../net/sf/openrocket/rocketcomponent/BodyTube.java | 2 +- .../net/sf/openrocket/rocketcomponent/Bulkhead.java | 4 ++-- .../sf/openrocket/rocketcomponent/CenteringRing.java | 4 ++-- .../sf/openrocket/rocketcomponent/EngineBlock.java | 4 ++-- .../net/sf/openrocket/rocketcomponent/InnerTube.java | 4 ++-- .../net/sf/openrocket/rocketcomponent/LaunchLug.java | 4 ++-- .../sf/openrocket/rocketcomponent/MassComponent.java | 8 ++++---- .../net/sf/openrocket/rocketcomponent/NoseCone.java | 2 +- .../net/sf/openrocket/rocketcomponent/Parachute.java | 4 ++-- .../sf/openrocket/rocketcomponent/RailButton.java | 12 ++++++------ .../net/sf/openrocket/rocketcomponent/ShockCord.java | 4 ++-- .../net/sf/openrocket/rocketcomponent/Streamer.java | 4 ++-- .../sf/openrocket/rocketcomponent/TubeCoupler.java | 4 ++-- 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java index 846174e3f..03b979543 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java @@ -46,7 +46,7 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou this.length = Math.max(length, 0); motors = new MotorConfigurationSet(this); super.displayOrder_side = 0; // Order for displaying the component in the 2D side view - super.displayOrder_back = 0; // Order for displaying the component in the 2D back view + super.displayOrder_back = 1; // Order for displaying the component in the 2D back view } public BodyTube(double length, double radius, boolean filled) { diff --git a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java index 2e67cee3e..bf3212631 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java @@ -13,8 +13,8 @@ public class Bulkhead extends RadiusRingComponent { public Bulkhead() { setOuterRadiusAutomatic(true); setLength(0.002); - super.displayOrder_side = 10; // Order for displaying the component in the 2D side view - super.displayOrder_back = 10; // Order for displaying the component in the 2D back view + super.displayOrder_side = 8; // Order for displaying the component in the 2D side view + super.displayOrder_back = 13; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java index 15e67ba9a..40df576a1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java +++ b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java @@ -13,8 +13,8 @@ public class CenteringRing extends RadiusRingComponent { setOuterRadiusAutomatic(true); setInnerRadiusAutomatic(true); setLength(0.002); - super.displayOrder_side = 9; // Order for displaying the component in the 2D side view - super.displayOrder_back = 9; // Order for displaying the component in the 2D back view + super.displayOrder_side = 7; // Order for displaying the component in the 2D side view + super.displayOrder_back = 14; // Order for displaying the component in the 2D back view } private static final Translator trans = Application.getTranslator(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java b/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java index a33b9109f..0f4a2aee1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java +++ b/core/src/net/sf/openrocket/rocketcomponent/EngineBlock.java @@ -16,8 +16,8 @@ public class EngineBlock extends ThicknessRingComponent implements AxialPosition setOuterRadiusAutomatic(true); setThickness(0.005); setLength(0.005); - super.displayOrder_side = 11; // Order for displaying the component in the 2D side view - super.displayOrder_back = 11; // Order for displaying the component in the 2D back view + super.displayOrder_side = 9; // Order for displaying the component in the 2D side view + super.displayOrder_back = 15; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index 5dfa8b9b8..7c1166cd2 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -49,8 +49,8 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab motors = new MotorConfigurationSet(this); - super.displayOrder_side = 7; // Order for displaying the component in the 2D side view - super.displayOrder_back = 7; // Order for displaying the component in the 2D back view + super.displayOrder_side = 5; // Order for displaying the component in the 2D side view + super.displayOrder_back = 12; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java index 24e82e884..e461f51bb 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java +++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java @@ -37,8 +37,8 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B radius = 0.01 / 2; thickness = 0.001; length = 0.03; - super.displayOrder_side = 6; // Order for displaying the component in the 2D side view - super.displayOrder_back = 6; // Order for displaying the component in the 2D back view + super.displayOrder_side = 15; // Order for displaying the component in the 2D side view + super.displayOrder_back = 10; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java index a2c5ba194..37c221fb8 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java @@ -41,15 +41,15 @@ public class MassComponent extends MassObject { public MassComponent() { super(); - super.displayOrder_side = 14; // Order for displaying the component in the 2D side view - super.displayOrder_back = 14; // Order for displaying the component in the 2D back view + super.displayOrder_side = 13; // Order for displaying the component in the 2D side view + super.displayOrder_back = 8; // Order for displaying the component in the 2D back view } public MassComponent(double length, double radius, double mass) { super(length, radius); this.mass = mass; - super.displayOrder_side = 14; // Order for displaying the component in the 2D side view - super.displayOrder_back = 14; // Order for displaying the component in the 2D back view + super.displayOrder_side = 13; // Order for displaying the component in the 2D side view + super.displayOrder_back = 8; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java index 864f443fa..a7316fdb3 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java +++ b/core/src/net/sf/openrocket/rocketcomponent/NoseCone.java @@ -44,7 +44,7 @@ public class NoseCone extends Transition implements InsideColorComponent { super.setAftRadius(radius); super.displayOrder_side = 1; // Order for displaying the component in the 2D side view - super.displayOrder_back = 1; // Order for displaying the component in the 2D back view + super.displayOrder_back = 0; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java index a0975417f..d73cbc4e0 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java @@ -23,8 +23,8 @@ public class Parachute extends RecoveryDevice { this.diameter = 0.3; this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE); this.lineLength = 0.3; - super.displayOrder_side = 12; // Order for displaying the component in the 2D side view - super.displayOrder_back = 12; // Order for displaying the component in the 2D back view + super.displayOrder_side = 11; // Order for displaying the component in the 2D side view + super.displayOrder_back = 7; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index 32dc7a2eb..76ecb22d8 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -69,16 +69,16 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( 0.002); this.setInstanceSeparation( this.outerDiameter_m * 6); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); - super.displayOrder_side = 5; // Order for displaying the component in the 2D side view - super.displayOrder_back = 5; // Order for displaying the component in the 2D back view + super.displayOrder_side = 14; // Order for displaying the component in the 2D side view + super.displayOrder_back = 9; // Order for displaying the component in the 2D back view } public RailButton( final double od, final double ht ) { this(); this.setOuterDiameter( od); this.setTotalHeight( ht); - super.displayOrder_side = 5; // Order for displaying the component in the 2D side view - super.displayOrder_back = 5; // Order for displaying the component in the 2D back view + super.displayOrder_side = 14; // Order for displaying the component in the 2D side view + super.displayOrder_back = 9; // Order for displaying the component in the 2D back view } public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) { @@ -90,8 +90,8 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setStandoff( _standoff); this.setInstanceSeparation( od*2); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); - super.displayOrder_side = 5; // Order for displaying the component in the 2D side view - super.displayOrder_back = 5; // Order for displaying the component in the 2D back view + super.displayOrder_side = 14; // Order for displaying the component in the 2D side view + super.displayOrder_back = 9; // Order for displaying the component in the 2D back view } private static final RailButton make1010Button(){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java index 395965f2d..43e79e894 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java @@ -15,8 +15,8 @@ public class ShockCord extends MassObject { public ShockCord() { material = Application.getPreferences().getDefaultComponentMaterial(ShockCord.class, Material.Type.LINE); cordLength = 0.4; - super.displayOrder_side = 13; // Order for displaying the component in the 2D side view - super.displayOrder_back = 13; // Order for displaying the component in the 2D back view + super.displayOrder_side = 12; // Order for displaying the component in the 2D side view + super.displayOrder_back = 5; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java index 55404a050..4534b17d1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java @@ -21,8 +21,8 @@ public class Streamer extends RecoveryDevice { public Streamer() { this.stripLength = 0.5; this.stripWidth = 0.05; - super.displayOrder_side = 12; // Order for displaying the component in the 2D side view - super.displayOrder_back = 12; // Order for displaying the component in the 2D back view + super.displayOrder_side = 10; // Order for displaying the component in the 2D side view + super.displayOrder_back = 6; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java index d09e77875..e3057ae21 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java @@ -13,8 +13,8 @@ public class TubeCoupler extends ThicknessRingComponent implements RadialParent setOuterRadiusAutomatic(true); setThickness(0.002); setLength(0.06); - super.displayOrder_side = 8; // Order for displaying the component in the 2D side view - super.displayOrder_back = 8; // Order for displaying the component in the 2D back view + super.displayOrder_side = 6; // Order for displaying the component in the 2D side view + super.displayOrder_back = 11; // Order for displaying the component in the 2D back view } @Override From 2c0870fa4d3b5782300f7fb5a25c994756dd34fb Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Tue, 13 Jul 2021 20:58:02 +0200 Subject: [PATCH 4/4] [fixes #976] Updated display order v1.1 --- core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java | 2 +- .../net/sf/openrocket/rocketcomponent/CenteringRing.java | 2 +- core/src/net/sf/openrocket/rocketcomponent/InnerTube.java | 2 +- core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java | 2 +- .../net/sf/openrocket/rocketcomponent/MassComponent.java | 4 ++-- core/src/net/sf/openrocket/rocketcomponent/Parachute.java | 2 +- core/src/net/sf/openrocket/rocketcomponent/RailButton.java | 6 +++--- core/src/net/sf/openrocket/rocketcomponent/ShockCord.java | 2 +- core/src/net/sf/openrocket/rocketcomponent/Streamer.java | 2 +- core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java index bf3212631..638c0a8d4 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Bulkhead.java @@ -14,7 +14,7 @@ public class Bulkhead extends RadiusRingComponent { setOuterRadiusAutomatic(true); setLength(0.002); super.displayOrder_side = 8; // Order for displaying the component in the 2D side view - super.displayOrder_back = 13; // Order for displaying the component in the 2D back view + super.displayOrder_back = 6; // Order for displaying the component in the 2D back view } @Override diff --git a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java index 40df576a1..cc24ce7e5 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java +++ b/core/src/net/sf/openrocket/rocketcomponent/CenteringRing.java @@ -14,7 +14,7 @@ public class CenteringRing extends RadiusRingComponent { setInnerRadiusAutomatic(true); setLength(0.002); super.displayOrder_side = 7; // Order for displaying the component in the 2D side view - super.displayOrder_back = 14; // Order for displaying the component in the 2D back view + super.displayOrder_back = 5; // Order for displaying the component in the 2D back view } private static final Translator trans = Application.getTranslator(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index 7c1166cd2..bd7cfcd42 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -50,7 +50,7 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab motors = new MotorConfigurationSet(this); super.displayOrder_side = 5; // Order for displaying the component in the 2D side view - super.displayOrder_back = 12; // Order for displaying the component in the 2D back view + super.displayOrder_back = 14; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java index e461f51bb..bf90d26e6 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java +++ b/core/src/net/sf/openrocket/rocketcomponent/LaunchLug.java @@ -38,7 +38,7 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B thickness = 0.001; length = 0.03; super.displayOrder_side = 15; // Order for displaying the component in the 2D side view - super.displayOrder_back = 10; // Order for displaying the component in the 2D back view + super.displayOrder_back = 12; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java index 37c221fb8..7524fc0d4 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/MassComponent.java @@ -42,14 +42,14 @@ public class MassComponent extends MassObject { public MassComponent() { super(); super.displayOrder_side = 13; // Order for displaying the component in the 2D side view - super.displayOrder_back = 8; // Order for displaying the component in the 2D back view + super.displayOrder_back = 10; // Order for displaying the component in the 2D back view } public MassComponent(double length, double radius, double mass) { super(length, radius); this.mass = mass; super.displayOrder_side = 13; // Order for displaying the component in the 2D side view - super.displayOrder_back = 8; // Order for displaying the component in the 2D back view + super.displayOrder_back = 10; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java index d73cbc4e0..721d5fab3 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Parachute.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Parachute.java @@ -24,7 +24,7 @@ public class Parachute extends RecoveryDevice { this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE); this.lineLength = 0.3; super.displayOrder_side = 11; // Order for displaying the component in the 2D side view - super.displayOrder_back = 7; // Order for displaying the component in the 2D back view + super.displayOrder_back = 9; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java index 76ecb22d8..9a7a637bf 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RailButton.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RailButton.java @@ -70,7 +70,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setInstanceSeparation( this.outerDiameter_m * 6); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); super.displayOrder_side = 14; // Order for displaying the component in the 2D side view - super.displayOrder_back = 9; // Order for displaying the component in the 2D back view + super.displayOrder_back = 11; // Order for displaying the component in the 2D back view } public RailButton( final double od, final double ht ) { @@ -78,7 +78,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setOuterDiameter( od); this.setTotalHeight( ht); super.displayOrder_side = 14; // Order for displaying the component in the 2D side view - super.displayOrder_back = 9; // Order for displaying the component in the 2D back view + super.displayOrder_back = 11; // Order for displaying the component in the 2D back view } public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) { @@ -91,7 +91,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable, this.setInstanceSeparation( od*2); this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin")); super.displayOrder_side = 14; // Order for displaying the component in the 2D side view - super.displayOrder_back = 9; // Order for displaying the component in the 2D back view + super.displayOrder_back = 11; // Order for displaying the component in the 2D back view } private static final RailButton make1010Button(){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java index 43e79e894..d2f9cc7fa 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ShockCord.java @@ -16,7 +16,7 @@ public class ShockCord extends MassObject { material = Application.getPreferences().getDefaultComponentMaterial(ShockCord.class, Material.Type.LINE); cordLength = 0.4; super.displayOrder_side = 12; // Order for displaying the component in the 2D side view - super.displayOrder_back = 5; // Order for displaying the component in the 2D back view + super.displayOrder_back = 7; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java index 4534b17d1..33352590e 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Streamer.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Streamer.java @@ -22,7 +22,7 @@ public class Streamer extends RecoveryDevice { this.stripLength = 0.5; this.stripWidth = 0.05; super.displayOrder_side = 10; // Order for displaying the component in the 2D side view - super.displayOrder_back = 6; // Order for displaying the component in the 2D back view + super.displayOrder_back = 8; // Order for displaying the component in the 2D back view } diff --git a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java index e3057ae21..14b3ad233 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java +++ b/core/src/net/sf/openrocket/rocketcomponent/TubeCoupler.java @@ -14,7 +14,7 @@ public class TubeCoupler extends ThicknessRingComponent implements RadialParent setThickness(0.002); setLength(0.06); super.displayOrder_side = 6; // Order for displaying the component in the 2D side view - super.displayOrder_back = 11; // Order for displaying the component in the 2D back view + super.displayOrder_back = 13; // Order for displaying the component in the 2D back view } @Override