Add scaleFactor back into some shapes
NoseCones aren't rendered correctly when printing/exporting as PDF due to the scaleFactor not being honored correctly in TransitionShapes. There was a good refactor to move some of the scaling pieces out, however the PrintableNoseCone didn't benefit from these changes. This restores part of the scaleFactor bits to the TransitionShapes in order to get the printing to correctly work again. This code should be transitioned to the new method for scaling. Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
parent
5bf8a7af15
commit
5977bfa95a
@ -19,6 +19,10 @@ public class SymmetricComponentShapes extends RocketComponentShape {
|
||||
// TODO: LOW: Uses only first component of cluster (not currently clusterable)
|
||||
|
||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||
return getShapesSide(component, transformation, 1.0d);
|
||||
}
|
||||
|
||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation, final double scaleFactor ) {
|
||||
|
||||
|
||||
SymmetricComponent c = (SymmetricComponent) component;
|
||||
@ -82,14 +86,14 @@ public class SymmetricComponentShapes extends RocketComponentShape {
|
||||
|
||||
// TODO: LOW: curved path instead of linear
|
||||
Path2D.Double path = new Path2D.Double();
|
||||
path.moveTo((nose.x + points.get(len - 1).x) , (nose.y+points.get(len - 1).y) );
|
||||
path.moveTo((nose.x + points.get(len - 1).x) * scaleFactor, (nose.y+points.get(len - 1).y) * scaleFactor);
|
||||
for (i = len - 2; i >= 0; i--) {
|
||||
path.lineTo((nose.x+points.get(i).x), (nose.y+points.get(i).y) );
|
||||
path.lineTo((nose.x+points.get(i).x) * scaleFactor, (nose.y+points.get(i).y) * scaleFactor);
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
path.lineTo((nose.x+points.get(i).x) , (nose.y-points.get(i).y) );
|
||||
path.lineTo((nose.x+points.get(i).x) * scaleFactor, (nose.y-points.get(i).y) * scaleFactor);
|
||||
}
|
||||
path.lineTo((nose.x+points.get(len - 1).x) , (nose.y+points.get(len - 1).y) );
|
||||
path.lineTo((nose.x+points.get(len - 1).x) * scaleFactor , (nose.y+points.get(len - 1).y) * scaleFactor);
|
||||
path.closePath();
|
||||
|
||||
//s[len] = path;
|
||||
|
@ -37,15 +37,15 @@ public class TransitionShapes extends RocketComponentShape {
|
||||
double r2 = transition.getAftRadius();
|
||||
|
||||
Path2D.Float path = new Path2D.Float();
|
||||
path.moveTo( (frontCenter.x), (frontCenter.y+ r1));
|
||||
path.lineTo( (frontCenter.x+length), (frontCenter.y+r2));
|
||||
path.lineTo( (frontCenter.x+length), (frontCenter.y-r2));
|
||||
path.lineTo( (frontCenter.x), (frontCenter.y-r1));
|
||||
path.moveTo( (frontCenter.x) * scaleFactor, (frontCenter.y+ r1) * scaleFactor);
|
||||
path.lineTo( (frontCenter.x+length) * scaleFactor, (frontCenter.y+r2) * scaleFactor);
|
||||
path.lineTo( (frontCenter.x+length) * scaleFactor, (frontCenter.y-r2) * scaleFactor);
|
||||
path.lineTo( (frontCenter.x) * scaleFactor, (frontCenter.y-r1) * scaleFactor);
|
||||
path.closePath();
|
||||
|
||||
mainShapes = new RocketComponentShape[] { new RocketComponentShape( path, component) };
|
||||
} else {
|
||||
mainShapes = SymmetricComponentShapes.getShapesSide(component, transformation);
|
||||
mainShapes = SymmetricComponentShapes.getShapesSide(component, transformation, scaleFactor);
|
||||
}
|
||||
|
||||
Shape foreShoulder=null, aftShoulder=null;
|
||||
@ -57,7 +57,7 @@ public class TransitionShapes extends RocketComponentShape {
|
||||
final Transformation offsetTransform = Transformation.getTranslationTransform(-transition.getForeShoulderLength(), 0, 0);
|
||||
final Transformation foreShoulderTransform = transformation.applyTransformation(offsetTransform);
|
||||
|
||||
foreShoulder = TubeShapes.getShapesSide( foreShoulderTransform, shoulderLength, shoulderRadius);
|
||||
foreShoulder = TubeShapes.getShapesSide( foreShoulderTransform, shoulderLength, shoulderRadius, scaleFactor);
|
||||
arrayLength++;
|
||||
}
|
||||
if (transition.getAftShoulderLength() > 0.0005) {
|
||||
@ -66,7 +66,7 @@ public class TransitionShapes extends RocketComponentShape {
|
||||
final Transformation offsetTransform = Transformation.getTranslationTransform(transition.getLength(), 0, 0);
|
||||
final Transformation aftShoulderTransform = transformation.applyTransformation(offsetTransform);
|
||||
|
||||
aftShoulder = TubeShapes.getShapesSide(aftShoulderTransform, shoulderLength, shoulderRadius);
|
||||
aftShoulder = TubeShapes.getShapesSide(aftShoulderTransform, shoulderLength, shoulderRadius, scaleFactor);
|
||||
arrayLength++;
|
||||
}
|
||||
if (foreShoulder==null && aftShoulder==null)
|
||||
|
@ -10,14 +10,19 @@ import net.sf.openrocket.util.Transformation;
|
||||
|
||||
public class TubeShapes extends RocketComponentShape {
|
||||
|
||||
|
||||
public static Shape getShapesSide( final Transformation transformation, final double length, final double radius ){
|
||||
return getShapesSide(transformation, length, radius, 1.0d);
|
||||
}
|
||||
|
||||
public static Shape getShapesSide( final Transformation transformation, final double length, final double radius, final double scaleFactor ){
|
||||
|
||||
final Coordinate instanceAbsoluteLocation = transformation.transform(Coordinate.ZERO);
|
||||
|
||||
return new Rectangle2D.Double((instanceAbsoluteLocation.x), //x - the X coordinate of the upper-left corner of the newly constructed Rectangle2D
|
||||
(instanceAbsoluteLocation.y-radius), // y - the Y coordinate of the upper-left corner of the newly constructed Rectangle2D
|
||||
length, // w - the width of the newly constructed Rectangle2D
|
||||
2*radius); // h - the height of the newly constructed Rectangle2D
|
||||
return new Rectangle2D.Double((instanceAbsoluteLocation.x) * scaleFactor, //x - the X coordinate of the upper-left corner of the newly constructed Rectangle2D
|
||||
(instanceAbsoluteLocation.y-radius) * scaleFactor, // y - the Y coordinate of the upper-left corner of the newly constructed Rectangle2D
|
||||
length * scaleFactor, // w - the width of the newly constructed Rectangle2D
|
||||
2*radius * scaleFactor); // h - the height of the newly constructed Rectangle2D
|
||||
}
|
||||
|
||||
public static Shape getShapesBack( final Transformation transformation, final double radius ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user