[fix][ui][graphics] Mass components now display their Radial / Angle position in Side Views

This commit is contained in:
Daniel_M_Williams 2020-09-01 22:31:44 -04:00
parent 685b40ef2f
commit 01562d6ae1
4 changed files with 42 additions and 79 deletions

View File

@ -19,19 +19,23 @@ import net.sf.openrocket.util.Transformation;
public class MassComponentShapes extends RocketComponentShape {
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
final MassComponent massObj = (MassComponent)component;
MassComponent.MassComponentType type = ((MassComponent)component).getMassComponentType();
double length = tube.getLength();
double radius = tube.getRadius();
double arc = Math.min(length, 2*radius) * 0.7;
final double length = massObj.getLength();
final double radius = massObj.getRadius(); // radius of the object, itself
// magic number, but it's only cosmetic -- it just has to look pretty
final double arc = Math.min(length, 2*radius) * 0.7;
final double radialDistance = massObj.getRadialPosition();
final double radialAngleRadians = massObj.getRadialDirection();
final Coordinate start = transformation.transform(Coordinate.ZERO);
final Coordinate localPosition = new Coordinate(0,
radialDistance * Math.cos(radialAngleRadians),
radialDistance * Math.sin(radialAngleRadians));
final Coordinate renderPosition = transformation.transform(localPosition);
Shape[] s = {new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc)};
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
final MassComponent.MassComponentType type = ((MassComponent)component).getMassComponentType();
switch (type) {
case ALTIMETER:
s = addAltimeterSymbol(s);

View File

@ -1,44 +0,0 @@
package net.sf.openrocket.gui.rocketfigure;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.awt.geom.RoundRectangle2D;
import net.sf.openrocket.rocketcomponent.MassObject;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.Transformation;
public class MassObjectShapes extends RocketComponentShape {
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
MassObject tube = (MassObject)component;
double length = tube.getLength();
double radius = tube.getRadius();
double arc = Math.min(length, 2*radius) * 0.7;
Coordinate start = transformation.transform(Coordinate.ZERO);
Shape[] s = {new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc)};
return RocketComponentShape.toArray(s, component);
}
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
MassObject tube = (MassObject)component;
double or = tube.getRadius();
final Coordinate start = transformation.transform(Coordinate.ZERO);
Shape[] s = {new Ellipse2D.Double((start.z-or), (start.y-or), 2*or, 2*or)};
return RocketComponentShape.toArray(s, component);
}
}

View File

@ -1,5 +1,6 @@
package net.sf.openrocket.gui.rocketfigure;
import net.sf.openrocket.rocketcomponent.MassObject;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.Transformation;
@ -14,18 +15,21 @@ import java.awt.geom.RoundRectangle2D;
public class ParachuteShapes extends RocketComponentShape {
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
final MassObject massObj = (MassObject)component;
double length = tube.getLength();
double radius = tube.getRadius();
double arc = Math.min(length, 2*radius) * 0.7;
final double length = massObj.getLength();
final double radius = massObj.getRadius(); // radius of the object, itself
// magic number, but it's only cosmetic -- it just has to look pretty
final double arc = Math.min(length, 2*radius) * 0.7;
final double radialDistance = massObj.getRadialPosition();
final double radialAngleRadians = massObj.getRadialDirection();
Coordinate start = transformation.transform( Coordinate.ZERO);
Shape[] s = new Shape[1];
final Coordinate localPosition = new Coordinate(0,
radialDistance * Math.cos(radialAngleRadians),
radialDistance * Math.sin(radialAngleRadians));
final Coordinate renderPosition = transformation.transform(localPosition);
s[0] = new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc);
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
return RocketComponentShape.toArray( addSymbol(s), component);
}

View File

@ -1,5 +1,6 @@
package net.sf.openrocket.gui.rocketfigure;
import net.sf.openrocket.rocketcomponent.MassObject;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.Transformation;
@ -13,24 +14,22 @@ import java.awt.geom.RoundRectangle2D;
public class StreamerShapes extends RocketComponentShape {
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
net.sf.openrocket.rocketcomponent.MassObject massObj = (net.sf.openrocket.rocketcomponent.MassObject)component;
final MassObject massObj = (MassObject)component;
double length = massObj.getLength();
double radius = massObj.getRadius();
double arc = Math.min(length, 2*radius) * 0.7;
final double length = massObj.getLength();
final double radius = massObj.getRadius(); // radius of the object, itself
// magic number, but it's only cosmetic -- it just has to look pretty
final double arc = Math.min(length, 2*radius) * 0.7;
final double radialDistance = massObj.getRadialPosition();
final double radialAngleRadians = massObj.getRadialDirection();
final Coordinate localPosition = new Coordinate(0,
radialDistance * Math.cos(radialAngleRadians),
radialDistance * Math.sin(radialAngleRadians));
final Coordinate renderPosition = transformation.transform(localPosition);
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
Shape[] s = new Shape[1];
Coordinate frontCenter = transformation.transform(Coordinate.ZERO);
s[0] = new RoundRectangle2D.Double((frontCenter.x),(frontCenter.y-radius),
length,2*radius,arc,arc);
// Coordinate[] start = transformation.transform(tube.toAbsolute(instanceOffset));
// Shape[] s = new Shape[start.length];
// for (int i=0; i < start.length; i++) {
// s[i] = new RoundRectangle2D.Double(start[i].x,(start[i].y-radius),
// length,2*radius,arc,arc);
// }
return RocketComponentShape.toArray(addSymbol(s), component);
}