diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index 307b1e2d4..44089a499 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -67,6 +67,7 @@ public class FlightConfiguration implements FlightConfigurableParameter preloadStageActiveness = null; final private Collection activeMotors = new ConcurrentLinkedQueue(); final private InstanceMap activeInstances = new InstanceMap(); + final private InstanceMap extraRenderInstances = new InstanceMap(); // Extra instances to be rendered, besides the active instances private int boundsModID = -1; private BoundingBox cachedBoundsAerodynamic = new BoundingBox(); // Bounding box of all aerodynamic components @@ -288,7 +289,7 @@ public class FlightConfiguration implements FlightConfigurableParameter 0 && + return stage != null && stage.getChildCount() > 0 && // Stages with no children are marked as inactive stages.get(stageNumber) != null && stages.get(stageNumber).active; } @@ -398,6 +399,15 @@ public class FlightConfiguration implements FlightConfigurableParameter()); + public void emplace(final RocketComponent component, int number, final Transformation transform) { + if (!containsKey(component)) { + put(component, new ArrayList<>()); } - final InstanceContext context = new InstanceContext(component, number, xform); - get(key).add(context); + final InstanceContext context = new InstanceContext(component, number, transform); + get(component).add(context); } public List getInstanceContexts(final RocketComponent key) { diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java new file mode 100644 index 000000000..da8250474 --- /dev/null +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java @@ -0,0 +1,66 @@ +package net.sf.openrocket.gui.rocketfigure; + +import net.sf.openrocket.rocketcomponent.AxialStage; +import net.sf.openrocket.rocketcomponent.ParallelStage; +import net.sf.openrocket.rocketcomponent.PodSet; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.util.Color; +import net.sf.openrocket.util.Transformation; + +import java.awt.Shape; + +public class ComponentAssemblyShapes extends RocketComponentShape { + + public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) { + // Ignore normal stages + if (component instanceof AxialStage && !(component instanceof ParallelStage)) { + return null; + } + + double radius = getDisplayRadius(component); + + Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); + RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); + + // Set the color of the shapes + Color color = getColor(component); + for (int i = 0; i < shapes.length - 1; i++) { + shapes[i].setColor(color); + } + + return shapes; + } + + public static RocketComponentShape[] getShapesBack(final RocketComponent component, final Transformation transformation) { + // Ignore normal stages + if (component instanceof AxialStage && !(component instanceof ParallelStage)) { + return null; + } + double radius = getDisplayRadius(component); + + Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); + RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); + + // Set the color of the shapes + Color color = getColor(component); + for (int i = 0; i < shapes.length - 1; i++) { + shapes[i].setColor(color); + } + + return shapes; + } + + private static double getDisplayRadius(RocketComponent component) { + return component.getRocket().getBoundingRadius() * 0.03; + } + + private static Color getColor(RocketComponent component) { + if (component instanceof PodSet) { + return new Color(160,160,215); + } else if (component instanceof ParallelStage) { + return new Color(198,163,184); + } else { + return new Color(160, 160, 160); + } + } +} diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java deleted file mode 100644 index 565a23591..000000000 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.sf.openrocket.gui.rocketfigure; - -import net.sf.openrocket.rocketcomponent.ParallelStage; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.util.Color; -import net.sf.openrocket.util.Transformation; - -import java.awt.Shape; - -public class ParallelStageShapes extends RocketComponentShape { - public static final Color boosterColor = new Color(198,163,184); - - public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) { - ParallelStage booster = (ParallelStage)component; - double radius = getDisplayRadius(booster); - - Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(boosterColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - public static RocketComponentShape[] getShapesBack(final RocketComponent component, final Transformation transformation) { - ParallelStage booster = (ParallelStage)component; - double radius = getDisplayRadius(booster); - - Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(boosterColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - private static double getDisplayRadius(ParallelStage booster) { - return booster.getRocket().getBoundingRadius() * 0.03; - } -} diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java deleted file mode 100644 index 7ef928f2d..000000000 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.sf.openrocket.gui.rocketfigure; - -import net.sf.openrocket.rocketcomponent.PodSet; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.util.Color; -import net.sf.openrocket.util.Transformation; - -import java.awt.Shape; - -public class PodSetShapes extends RocketComponentShape { - public static final Color podsetColor = new Color(160,160,215); - - public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) { - PodSet podset = (PodSet)component; - double radius = getDisplayRadius(podset); - - Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(podsetColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - public static RocketComponentShape[] getShapesBack(final RocketComponent component, final Transformation transformation) { - PodSet podset = (PodSet)component; - double radius = getDisplayRadius(podset); - - Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(podsetColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - private static double getDisplayRadius(PodSet podset) { - return podset.getRocket().getBoundingRadius() * 0.03; - } -} diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 0f62a28f7..0925aca8a 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -384,11 +384,16 @@ public class RocketFigure extends AbstractScaleFigure { // allShapes is an output buffer -- it stores all the generated shapes allShapes.clear(); - for (Entry> entry : config.getActiveInstances().entrySet()) { + addShapesFromInstanceEntries(allShapes, config.getActiveInstances().entrySet()); + addShapesFromInstanceEntries(allShapes, config.getExtraRenderInstances().entrySet()); + } + + private void addShapesFromInstanceEntries(PriorityQueue allShapes, Set>> entries) { + for (Entry> entry : entries) { final RocketComponent comp = entry.getKey(); - // Only draw podsets when they are selected - if ((comp instanceof PodSet || comp instanceof ParallelStage) && preferences.isShowMarkers()) { + // Only draw pod sets and boosters when they are selected + if (preferences.isShowMarkers() && (comp instanceof PodSet || comp instanceof ParallelStage)) { boolean selected = false; // Check if component is in the selection @@ -409,7 +414,7 @@ public class RocketFigure extends AbstractScaleFigure { } } } - + /** * Gets the shapes required to draw the component. *