From 0945961fc475f9580b8f2c68fc0a5d7bf761d4ef Mon Sep 17 00:00:00 2001 From: Daniel_M_Williams Date: Thu, 25 Jun 2015 17:12:27 -0400 Subject: [PATCH] bugfix commits - fixed rearview display bug, implemented component.getPositionVector() --- .../rocketcomponent/RocketComponent.java | 16 ++++++++++++++++ .../net/sf/openrocket/rocketcomponent/Stage.java | 15 ++++++++++++--- .../gui/rocketfigure/RingComponentShapes.java | 8 +++++--- .../gui/rocketfigure/RocketComponentShape.java | 1 - .../openrocket/gui/scalefigure/RocketFigure.java | 12 +++--------- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java index 906bfc3dd..67538f5b1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RocketComponent.java @@ -967,6 +967,22 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab } + /* + * + */ + public Coordinate getRelativePositionVector() { + // ghetto version of this.... + return new Coordinate(this.getPositionValue(), 0, 0); + } + + + /* + * + */ + public void setRelativePositionVector(final Coordinate _newPos) { + // ghetto version of this.... + this.position = _newPos.x; + } /////////// Coordinate changes /////////// diff --git a/core/src/net/sf/openrocket/rocketcomponent/Stage.java b/core/src/net/sf/openrocket/rocketcomponent/Stage.java index 0750c5a1f..70cf13a9d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Stage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Stage.java @@ -89,13 +89,16 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon this.count = 1; } - fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); } @Override public int getCount() { - return this.count; + if (this.isInline()) { + return 1; + } else { + return this.count; + } } @Override @@ -194,19 +197,25 @@ public class Stage extends ComponentAssembly implements FlightConfigurableCompon @Override public Coordinate[] getInstanceOffsets() { + if (this.isInline()) { + return new Coordinate[] { new Coordinate(0, 0, 0) }; + } + Coordinate[] toReturn = new Coordinate[this.count]; double radius = this.radialPosition_m; double angle0 = this.angularPosition_rad; double angleIncr = this.angularSeparation; + System.err.println("Producing offsets list: "); double thisAngle = angle0; for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) { - toReturn[instanceNumber] = new Coordinate(0, radius * Math.cos(thisAngle), radius * Math.sin(thisAngle)); + System.err.println(" instance#: " + instanceNumber + " = " + toReturn[instanceNumber]); thisAngle += angleIncr; } return toReturn; } + } diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/RingComponentShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/RingComponentShapes.java index 26fa3cbce..125f296c6 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/RingComponentShapes.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/RingComponentShapes.java @@ -47,8 +47,10 @@ public class RingComponentShapes extends RocketComponentShape { } - public static RocketComponentShape[] getShapesBack(net.sf.openrocket.rocketcomponent.RocketComponent component, - Transformation transformation) { + public static RocketComponentShape[] getShapesBack( + net.sf.openrocket.rocketcomponent.RocketComponent component, + Transformation transformation, + Coordinate instanceOffset) { net.sf.openrocket.rocketcomponent.RingComponent tube = (net.sf.openrocket.rocketcomponent.RingComponent)component; Shape[] s; @@ -56,7 +58,7 @@ public class RingComponentShapes extends RocketComponentShape { double ir = tube.getInnerRadius(); - Coordinate[] start = transformation.transform(tube.toAbsolute(new Coordinate(0,0,0))); + Coordinate[] start = transformation.transform(tube.toAbsolute(instanceOffset)); if ((ir < or) && (ir > 0)) { // Draw inner and outer diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java b/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java index 972fea100..348078d81 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/RocketComponentShape.java @@ -30,7 +30,6 @@ public class RocketComponentShape { this.color = null; this.lineStyle = null; this.component=null; - } public RocketComponentShape( final Shape _shape, final RocketComponent _comp){ diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 1eab306dc..f3aeb285a 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -433,20 +433,15 @@ public class RocketFigure extends AbstractScaleFigure { RocketPanel.VIEW_TYPE viewType = this.currentViewType; Transformation viewTransform = this.transformation; - - // TODO: Implement actual locations in the components - Coordinate componentLocation = new Coordinate(comp.getPositionValue(),0,0); + Coordinate componentLocation = comp.getRelativePositionVector(); if( comp instanceof MultipleComponent ){ MultipleComponent multi = (MultipleComponent)comp; int instanceCount; instanceCount = multi.getInstanceCount(); - - // get m instance locations + // get the offsets for m instances Coordinate[] instanceOffsets = multi.getInstanceOffsets(); - assert(false); - assert( instanceOffsets.length == instanceCount ); // replicate n children m times each int childCount = comp.getChildCount(); @@ -465,8 +460,7 @@ public class RocketFigure extends AbstractScaleFigure { allShapes.add( curShape); } - } - + } }else{ if( comp instanceof Rocket){ // the Rocket doesn't have any graphics to get.