Commit 78da4c87 authored by Nico Mack's avatar Nico Mack

Added stepSize property to PositionWidget

Disabled logging of Executor for ConditionScene
parent f59ec94a
......@@ -65,7 +65,9 @@ public class ConditonalScene extends Scene implements VariableBased, InputChange
outputs.add(new Declaration(satisfied));
condition = new Equation(this.identifier, new Mapping(inputs, outputs), this.expression);
condition.setExecutor(new JavascriptExecutor());
JavascriptExecutor executor = new JavascriptExecutor();
executor.setVerbosity(false);
condition.setExecutor(executor);
}
// ---------------------------------------------------------------------------
......
......@@ -45,6 +45,7 @@ public class PositionWidget extends PointingWidget implements InformationProvide
protected boolean modifyValueOnTranslation;
protected boolean trackRotationContinuously;
protected boolean trackTranslationContinuously;
protected double stepSize;
// ***************************************************************************
// * Constants *
......@@ -72,6 +73,7 @@ public class PositionWidget extends PointingWidget implements InformationProvide
this.modifyValueOnTranslation = builder.modifyValueOnTranslation;
this.trackRotationContinuously = builder.trackRotationContinuously;
this.trackTranslationContinuously = builder.trackTranslationContinuously;
this.stepSize = builder.stepSize;
}
// ---------------------------------------------------------------------------
......@@ -87,14 +89,23 @@ public class PositionWidget extends PointingWidget implements InformationProvide
if (position != null) {
CoordinateState coordinates = position.getState();
newPosition = newPosition.toCoordinates(coordinates.getClass());
boolean doUpdate = false;
if (modifyValueOnRotation && (!continuous || trackRotationContinuously)) {
position.setAngle(newPosition.getAngle());
doUpdate = true;
}
if (modifyValueOnTranslation && (!continuous || trackTranslationContinuously)) {
if (!Double.isNaN(this.stepSize)) {
double distance = position.distance(newPosition);
doUpdate = distance >= this.stepSize;
}
position.setLocation(newPosition.x, newPosition.y);
}
this.variable.setValue(position);
if (doUpdate) {
this.variable.setValue(position);
}
} else {
this.variable.setValue(newPosition);
}
......
......@@ -32,6 +32,7 @@ public abstract class BasePositionWidgetBuilder<B extends BasePositionWidgetBuil
public boolean modifyValueOnTranslation;
public boolean trackRotationContinuously;
public boolean trackTranslationContinuously;
public double stepSize;
// ***************************************************************************
// * Constants *
......@@ -71,6 +72,7 @@ public abstract class BasePositionWidgetBuilder<B extends BasePositionWidgetBuil
this.modifyValueOnTranslation = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.MODIFY_VALUE_ON_TRANSLATION_NODE, BootstrappingUtils.OPTIONAL, true, context);
this.trackRotationContinuously = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.TRACK_ROTATION_CONTINUOUSLY_NODE, BootstrappingUtils.OPTIONAL, false, context);
this.trackTranslationContinuously = BootstrappingUtils.getContentAsBoolean(rootElement, CpsNamespace.TRACK_TRANSLATION_CONTINUOUSLY_NODE, BootstrappingUtils.OPTIONAL, false, context);
this.stepSize = BootstrappingUtils.getContentAsDouble(rootElement, CpsNamespace.STEP_SIZE_NODE, BootstrappingUtils.OPTIONAL, Double.NaN, context);
}
// ---------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment