Add 2D visualization for boosters
This commit is contained in:
parent
9c5d1e9e26
commit
b479809b62
@ -0,0 +1,49 @@
|
|||||||
|
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(220, 185, 185);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,8 @@ import net.sf.openrocket.util.Transformation;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
|
||||||
public class PodSetShapes extends RocketComponentShape {
|
public class PodSetShapes extends RocketComponentShape {
|
||||||
public static final Color podsetColor = new Color(160, 160, 160); // Normal color for the podset shape
|
//public static final Color podsetColor = new Color(180, 180, 225);
|
||||||
|
public static final Color podsetColor = new Color(160,160,215);
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) {
|
||||||
PodSet podset = (PodSet)component;
|
PodSet podset = (PodSet)component;
|
||||||
|
@ -17,7 +17,8 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.rocketfigure.PodSetShapes;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
|
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
||||||
import net.sf.openrocket.rocketcomponent.PodSet;
|
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -28,7 +29,6 @@ import net.sf.openrocket.gui.util.ColorConversion;
|
|||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
|
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.InstanceContext;
|
import net.sf.openrocket.rocketcomponent.InstanceContext;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
@ -382,17 +382,16 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
final RocketComponent comp = entry.getKey();
|
final RocketComponent comp = entry.getKey();
|
||||||
|
|
||||||
// Only draw podsets when they are selected
|
// Only draw podsets when they are selected
|
||||||
if (comp instanceof PodSet) {
|
if (comp instanceof PodSet || comp instanceof ParallelStage) {
|
||||||
boolean selected = false;
|
boolean selected = false;
|
||||||
|
|
||||||
// Check if component is in the selection
|
// Check if component is in the selection
|
||||||
for (int j = 0; j < selection.length; j++) {
|
for (RocketComponent component : selection) {
|
||||||
if (comp == selection[j]) {
|
if (comp == component) {
|
||||||
selected = true;
|
selected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selected) continue;
|
if (!selected) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +423,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
final net.sf.openrocket.util.Color color) {
|
final net.sf.openrocket.util.Color color) {
|
||||||
Reflection.Method m;
|
Reflection.Method m;
|
||||||
|
|
||||||
if(( component instanceof Rocket)||( component instanceof ComponentAssembly && !(component instanceof PodSet))){
|
if ((component instanceof Rocket) || (component instanceof AxialStage && !(component instanceof ParallelStage))){
|
||||||
// no-op; no shapes here
|
// no-op; no shapes here
|
||||||
return allShapes;
|
return allShapes;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user