Merge pull request #979 from SiboVG/issue-976
This commit is contained in:
commit
0b5e7a3cb0
@ -45,6 +45,8 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
|
|||||||
this.outerRadius = Math.max(radius, 0);
|
this.outerRadius = Math.max(radius, 0);
|
||||||
this.length = Math.max(length, 0);
|
this.length = Math.max(length, 0);
|
||||||
motors = new MotorConfigurationSet(this);
|
motors = new MotorConfigurationSet(this);
|
||||||
|
super.displayOrder_side = 0; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 1; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
public BodyTube(double length, double radius, boolean filled) {
|
public BodyTube(double length, double radius, boolean filled) {
|
||||||
|
@ -13,6 +13,8 @@ public class Bulkhead extends RadiusRingComponent {
|
|||||||
public Bulkhead() {
|
public Bulkhead() {
|
||||||
setOuterRadiusAutomatic(true);
|
setOuterRadiusAutomatic(true);
|
||||||
setLength(0.002);
|
setLength(0.002);
|
||||||
|
super.displayOrder_side = 8; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 6; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,8 @@ public class CenteringRing extends RadiusRingComponent {
|
|||||||
setOuterRadiusAutomatic(true);
|
setOuterRadiusAutomatic(true);
|
||||||
setInnerRadiusAutomatic(true);
|
setInnerRadiusAutomatic(true);
|
||||||
setLength(0.002);
|
setLength(0.002);
|
||||||
|
super.displayOrder_side = 7; // 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 Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
@ -16,6 +16,8 @@ public class EngineBlock extends ThicknessRingComponent implements AxialPosition
|
|||||||
setOuterRadiusAutomatic(true);
|
setOuterRadiusAutomatic(true);
|
||||||
setThickness(0.005);
|
setThickness(0.005);
|
||||||
setLength(0.005);
|
setLength(0.005);
|
||||||
|
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
|
@Override
|
||||||
|
@ -134,6 +134,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
public FinSet() {
|
public FinSet() {
|
||||||
super( AxialMethod.BOTTOM);
|
super( AxialMethod.BOTTOM);
|
||||||
this.filletMaterial = Application.getPreferences().getDefaultComponentMaterial(this.getClass(), Material.Type.BULK);
|
this.filletMaterial = Application.getPreferences().getDefaultComponentMaterial(this.getClass(), Material.Type.BULK);
|
||||||
|
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
|
@Override
|
||||||
|
@ -48,6 +48,9 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab
|
|||||||
this.setLength(0.070);
|
this.setLength(0.070);
|
||||||
|
|
||||||
motors = new MotorConfigurationSet(this);
|
motors = new MotorConfigurationSet(this);
|
||||||
|
|
||||||
|
super.displayOrder_side = 5; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 14; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
|||||||
radius = 0.01 / 2;
|
radius = 0.01 / 2;
|
||||||
thickness = 0.001;
|
thickness = 0.001;
|
||||||
length = 0.03;
|
length = 0.03;
|
||||||
|
super.displayOrder_side = 15; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 12; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,11 +41,15 @@ public class MassComponent extends MassObject {
|
|||||||
|
|
||||||
public MassComponent() {
|
public MassComponent() {
|
||||||
super();
|
super();
|
||||||
|
super.displayOrder_side = 13; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 10; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
public MassComponent(double length, double radius, double mass) {
|
public MassComponent(double length, double radius, double mass) {
|
||||||
super(length, radius);
|
super(length, radius);
|
||||||
this.mass = mass;
|
this.mass = mass;
|
||||||
|
super.displayOrder_side = 13; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 10; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,9 @@ public class NoseCone extends Transition implements InsideColorComponent {
|
|||||||
|
|
||||||
super.setAftRadiusAutomatic(false);
|
super.setAftRadiusAutomatic(false);
|
||||||
super.setAftRadius(radius);
|
super.setAftRadius(radius);
|
||||||
|
|
||||||
|
super.displayOrder_side = 1; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 0; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ public class Parachute extends RecoveryDevice {
|
|||||||
this.diameter = 0.3;
|
this.diameter = 0.3;
|
||||||
this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE);
|
this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE);
|
||||||
this.lineLength = 0.3;
|
this.lineLength = 0.3;
|
||||||
|
super.displayOrder_side = 11; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 9; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,12 +69,16 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
|
|||||||
this.setStandoff( 0.002);
|
this.setStandoff( 0.002);
|
||||||
this.setInstanceSeparation( this.outerDiameter_m * 6);
|
this.setInstanceSeparation( this.outerDiameter_m * 6);
|
||||||
this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin"));
|
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 = 11; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
public RailButton( final double od, final double ht ) {
|
public RailButton( final double od, final double ht ) {
|
||||||
this();
|
this();
|
||||||
this.setOuterDiameter( od);
|
this.setOuterDiameter( od);
|
||||||
this.setTotalHeight( ht);
|
this.setTotalHeight( ht);
|
||||||
|
super.displayOrder_side = 14; // Order for displaying the component in the 2D side 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 ) {
|
public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) {
|
||||||
@ -86,6 +90,8 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
|
|||||||
this.setStandoff( _standoff);
|
this.setStandoff( _standoff);
|
||||||
this.setInstanceSeparation( od*2);
|
this.setInstanceSeparation( od*2);
|
||||||
this.setMaterial(Databases.findMaterial(Material.Type.BULK, "Delrin"));
|
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 = 11; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final RailButton make1010Button(){
|
private static final RailButton make1010Button(){
|
||||||
|
@ -128,6 +128,15 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
private Invalidator invalidator = new Invalidator(this);
|
private Invalidator invalidator = new Invalidator(this);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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_side = 100;
|
||||||
|
protected int displayOrder_back = 100;
|
||||||
|
|
||||||
//// NOTE !!! All fields must be copied in the method copyFrom()! ////
|
//// NOTE !!! All fields must be copied in the method copyFrom()! ////
|
||||||
|
|
||||||
|
|
||||||
@ -2014,6 +2023,8 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
this.name = src.name;
|
this.name = src.name;
|
||||||
this.comment = src.comment;
|
this.comment = src.comment;
|
||||||
this.id = src.id;
|
this.id = src.id;
|
||||||
|
this.displayOrder_side = src.displayOrder_side;
|
||||||
|
this.displayOrder_back = src.displayOrder_back;
|
||||||
|
|
||||||
// Add source components to invalidation tree
|
// Add source components to invalidation tree
|
||||||
for (RocketComponent c : src) {
|
for (RocketComponent c : src) {
|
||||||
@ -2229,4 +2240,19 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDisplayOrder_side() {
|
||||||
|
return displayOrder_side;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ public class ShockCord extends MassObject {
|
|||||||
public ShockCord() {
|
public ShockCord() {
|
||||||
material = Application.getPreferences().getDefaultComponentMaterial(ShockCord.class, Material.Type.LINE);
|
material = Application.getPreferences().getDefaultComponentMaterial(ShockCord.class, Material.Type.LINE);
|
||||||
cordLength = 0.4;
|
cordLength = 0.4;
|
||||||
|
super.displayOrder_side = 12; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 7; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ public class Streamer extends RecoveryDevice {
|
|||||||
public Streamer() {
|
public Streamer() {
|
||||||
this.stripLength = 0.5;
|
this.stripLength = 0.5;
|
||||||
this.stripWidth = 0.05;
|
this.stripWidth = 0.05;
|
||||||
|
super.displayOrder_side = 10; // Order for displaying the component in the 2D side view
|
||||||
|
super.displayOrder_back = 8; // Order for displaying the component in the 2D back view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ public class Transition extends SymmetricComponent implements InsideColorCompone
|
|||||||
this.type = Shape.CONICAL;
|
this.type = Shape.CONICAL;
|
||||||
this.shapeParameter = 0;
|
this.shapeParameter = 0;
|
||||||
this.clipped = true;
|
this.clipped = true;
|
||||||
|
|
||||||
|
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 ////////
|
//////// Length ////////
|
||||||
|
@ -13,6 +13,8 @@ public class TubeCoupler extends ThicknessRingComponent implements RadialParent
|
|||||||
setOuterRadiusAutomatic(true);
|
setOuterRadiusAutomatic(true);
|
||||||
setThickness(0.002);
|
setThickness(0.002);
|
||||||
setLength(0.06);
|
setLength(0.06);
|
||||||
|
super.displayOrder_side = 6; // 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
|
@Override
|
||||||
|
@ -56,6 +56,8 @@ public class TubeFinSet extends ExternalComponent implements AxialPositionable,
|
|||||||
public TubeFinSet() {
|
public TubeFinSet() {
|
||||||
super(AxialMethod.BOTTOM);
|
super(AxialMethod.BOTTOM);
|
||||||
length = 0.10;
|
length = 0.10;
|
||||||
|
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) {
|
public void setLength(double length) {
|
||||||
|
@ -71,6 +71,4 @@ public class RocketComponentShape {
|
|||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ import java.awt.geom.Ellipse2D;
|
|||||||
import java.awt.geom.NoninvertibleTransformException;
|
import java.awt.geom.NoninvertibleTransformException;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -74,10 +73,15 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
private double rotation;
|
private double rotation;
|
||||||
private Transformation axialRotation;
|
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<RocketComponentShape> figureShapes = new ArrayList<RocketComponentShape>();
|
private final PriorityQueue<RocketComponentShape> figureShapes_side = new PriorityQueue<>(
|
||||||
|
Comparator.comparingInt(o -> -o.component.getDisplayOrder_side()));
|
||||||
|
private final PriorityQueue<RocketComponentShape> figureShapes_back = new PriorityQueue<>(
|
||||||
|
Comparator.comparingInt(o -> -o.component.getDisplayOrder_back()));
|
||||||
|
|
||||||
|
|
||||||
private final ArrayList<FigureElement> relativeExtra = new ArrayList<FigureElement>();
|
private final ArrayList<FigureElement> relativeExtra = new ArrayList<FigureElement>();
|
||||||
@ -191,12 +195,22 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
AffineTransform baseTransform = g2.getTransform();
|
AffineTransform baseTransform = g2.getTransform();
|
||||||
|
|
||||||
|
PriorityQueue<RocketComponentShape> 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();
|
updateSubjectDimensions();
|
||||||
updateCanvasOrigin();
|
updateCanvasOrigin();
|
||||||
updateCanvasSize();
|
updateCanvasSize();
|
||||||
updateTransform();
|
updateTransform();
|
||||||
|
|
||||||
updateShapes(this.figureShapes);
|
updateShapes(figureShapes);
|
||||||
|
|
||||||
g2.transform(projection);
|
g2.transform(projection);
|
||||||
|
|
||||||
@ -208,10 +222,10 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
int shapeCount = figureShapes.size();
|
|
||||||
// Draw all shapes
|
// Draw all shapes
|
||||||
for (int i = 0; i < shapeCount; i++) {
|
PriorityQueue<RocketComponentShape> figureShapesCopy = new PriorityQueue<>(figureShapes);
|
||||||
RocketComponentShape rcs = figureShapes.get(i);
|
while (!figureShapesCopy.isEmpty()) {
|
||||||
|
RocketComponentShape rcs = figureShapesCopy.poll();
|
||||||
RocketComponent c = rcs.getComponent();
|
RocketComponent c = rcs.getComponent();
|
||||||
boolean selected = false;
|
boolean selected = false;
|
||||||
|
|
||||||
@ -331,15 +345,26 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
LinkedHashSet<RocketComponent> l = new LinkedHashSet<RocketComponent>();
|
LinkedHashSet<RocketComponent> l = new LinkedHashSet<RocketComponent>();
|
||||||
|
|
||||||
for (int i = 0; i < figureShapes.size(); i++) {
|
PriorityQueue<RocketComponentShape> figureShapes;
|
||||||
RocketComponentShape rcs = this.figureShapes.get(i);
|
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<RocketComponentShape> figureShapesCopy = new PriorityQueue<>(figureShapes);
|
||||||
|
while (!figureShapesCopy.isEmpty()) {
|
||||||
|
RocketComponentShape rcs = figureShapesCopy.poll();
|
||||||
if (rcs.shape.contains(p))
|
if (rcs.shape.contains(p))
|
||||||
l.add(rcs.component);
|
l.add(rcs.component);
|
||||||
}
|
}
|
||||||
return l.toArray(new RocketComponent[0]);
|
return l.toArray(new RocketComponent[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShapes(ArrayList<RocketComponentShape> allShapes) {
|
private void updateShapes(PriorityQueue<RocketComponentShape> allShapes) {
|
||||||
// source input
|
// source input
|
||||||
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
final FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
|
|
||||||
@ -369,8 +394,8 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
*
|
*
|
||||||
* @return the <code>ArrayList</code> containing all the shapes to draw.
|
* @return the <code>ArrayList</code> containing all the shapes to draw.
|
||||||
*/
|
*/
|
||||||
private static ArrayList<RocketComponentShape> addThisShape(
|
private static PriorityQueue<RocketComponentShape> addThisShape(
|
||||||
ArrayList<RocketComponentShape> allShapes, // this is the output parameter
|
PriorityQueue<RocketComponentShape> allShapes, // this is the output parameter
|
||||||
final RocketPanel.VIEW_TYPE viewType,
|
final RocketPanel.VIEW_TYPE viewType,
|
||||||
final RocketComponent component,
|
final RocketComponent component,
|
||||||
final Transformation transformation) {
|
final Transformation transformation) {
|
||||||
@ -405,9 +430,7 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
|
|
||||||
RocketComponentShape[] returnValue = (RocketComponentShape[]) m.invokeStatic(component, transformation);
|
RocketComponentShape[] returnValue = (RocketComponentShape[]) m.invokeStatic(component, transformation);
|
||||||
for ( RocketComponentShape curShape : returnValue ){
|
allShapes.addAll(Arrays.asList(returnValue));
|
||||||
allShapes.add( curShape );
|
|
||||||
}
|
|
||||||
return allShapes;
|
return allShapes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user