[fix][ui][graphics] Mass components now display their Radial / Angle position in Side Views
This commit is contained in:
parent
685b40ef2f
commit
01562d6ae1
@ -19,19 +19,23 @@ import net.sf.openrocket.util.Transformation;
|
|||||||
public class MassComponentShapes extends RocketComponentShape {
|
public class MassComponentShapes extends RocketComponentShape {
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassComponent massObj = (MassComponent)component;
|
||||||
|
|
||||||
MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
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();
|
||||||
|
|
||||||
MassComponent.MassComponentType type = ((MassComponent)component).getMassComponentType();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
double length = tube.getLength();
|
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
|
||||||
double radius = tube.getRadius();
|
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
|
||||||
|
|
||||||
final Coordinate start = transformation.transform(Coordinate.ZERO);
|
|
||||||
|
|
||||||
Shape[] s = {new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc)};
|
|
||||||
|
|
||||||
|
final MassComponent.MassComponentType type = ((MassComponent)component).getMassComponentType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ALTIMETER:
|
case ALTIMETER:
|
||||||
s = addAltimeterSymbol(s);
|
s = addAltimeterSymbol(s);
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.rocketfigure;
|
package net.sf.openrocket.gui.rocketfigure;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.Transformation;
|
import net.sf.openrocket.util.Transformation;
|
||||||
@ -14,18 +15,21 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
public class ParachuteShapes extends RocketComponentShape {
|
public class ParachuteShapes extends RocketComponentShape {
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
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();
|
||||||
|
|
||||||
double length = tube.getLength();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
double radius = tube.getRadius();
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
Coordinate start = transformation.transform( Coordinate.ZERO);
|
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
|
||||||
|
|
||||||
Shape[] s = new Shape[1];
|
|
||||||
|
|
||||||
s[0] = new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc);
|
|
||||||
|
|
||||||
return RocketComponentShape.toArray( addSymbol(s), component);
|
return RocketComponentShape.toArray( addSymbol(s), component);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.rocketfigure;
|
package net.sf.openrocket.gui.rocketfigure;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.Transformation;
|
import net.sf.openrocket.util.Transformation;
|
||||||
@ -13,24 +14,22 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
public class StreamerShapes extends RocketComponentShape {
|
public class StreamerShapes extends RocketComponentShape {
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject massObj = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
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();
|
||||||
|
|
||||||
double length = massObj.getLength();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
double radius = massObj.getRadius();
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
Shape[] s = new Shape[1];
|
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
|
||||||
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);
|
return RocketComponentShape.toArray(addSymbol(s), component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user