Commit 4da1fb4e authored by Nico Mack's avatar Nico Mack

Fixed minor bugs in handling of initial handle angles when dropping

widgets having persistence enabled.
parent ad7bb857
......@@ -39,7 +39,7 @@ public class SelectorWidget extends ValueWidget {
/** The currently selected position */
protected int currentPosition = NONE;
protected int presetPosition = NONE;
protected float presetAngleOffset = 0;
protected float presetAngleOffset = Float.NaN;
protected Map<String, SelectionGroup> selectionGroups;
private double segmentSpan;
......@@ -220,10 +220,8 @@ public class SelectorWidget extends ValueWidget {
protected void updateFromRotation(double angle, Direction direction) {
if (this.multiTurn) {
super.updateFromRotation(angle, direction);
// if (this.variable.wasModified()) {
int position = this.variable.getValue().intValue();
selectableCoronas.forEach(indexed -> indexed.satisfiedBy(position));
// }
}
}
......@@ -310,7 +308,6 @@ public class SelectorWidget extends ValueWidget {
if ((presetPosition != NONE) && connected.contains(variable)) {
variable.setValue((double) presetPosition);
// variable.notifyInputChangeListeners();
}
List<Conditional> conditionalCoronas = getCoronas(Conditional.class);
......@@ -336,6 +333,30 @@ public class SelectorWidget extends ValueWidget {
return currentPosition;
}
// ---------------------------------------------------------------------------
/**
* Method invoked when the tangible is detected on the table surface for the first time. The
* {@link TangibleWidget} instance is set to be active.
*
* @param tuioObject
* The TuioObject that was triggering the drop action.
*/
// ---------------------------------------------------------------------------
@Override
public void actionDrop(TangibleObject tuioObject) {
// isPersistent = this.isPersistent(tuioObject.getObjectId());
int position = (isPersistent) ? currentPosition : presetPosition;
if (Float.isNaN(presetAngleOffset)) {
presetAngleOffset = (isPersistent) ? (float) AngleUtils.moduloTwoPi(this.getCurrentAngle(position) - tuioObject.getAngle() - Math.PI) : 0;
}
super.actionDrop(tuioObject);
this.selectPosition(position);
}
// ---------------------------------------------------------------------------
/**
* Method invoked when a handle of the widget was moved. This default implementation will set the
......@@ -349,9 +370,12 @@ public class SelectorWidget extends ValueWidget {
@Override
public void actionMove(TangibleObject tuioObject) {
super.actionMove(tuioObject);
double angle = AngleUtils.moduloTwoPi(tuioObject.getAngle() + presetAngleOffset);
TangibleObject clone = tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), (float) angle));
super.actionMove(clone);
int widgetId = tuioObject.getObjectId();
int widgetId = clone.getObjectId();
StateManager manager = objectStates.get(widgetId);
......@@ -363,25 +387,6 @@ public class SelectorWidget extends ValueWidget {
}
}
// ---------------------------------------------------------------------------
/**
* Method invoked when the tangible is detected on the table surface for the first time. The
* {@link TangibleWidget} instance is set to be active.
*
* @param tuioObject
* The TuioObject that was triggering the drop action.
*/
// ---------------------------------------------------------------------------
@Override
public void actionDrop(TangibleObject tuioObject) {
isPersistent = this.isPersistent(tuioObject.getObjectId());
int position = (isPersistent) ? currentPosition : presetPosition;
super.actionDrop(tuioObject);
this.selectPosition(position);
}
// ---------------------------------------------------------------------------
/**
* Method invoked when the tangible is removed from the table surface. The {@link TangibleWidget}
......
......@@ -83,9 +83,10 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
* Field holding the current angular position of the constrainted (lowerStopAngle | upperStopAngle)
* angle.
*/
protected double dialAngle;
protected double dropAngle;
protected double dialAngle = Double.NaN;
protected double dropAngle = Double.NaN;
protected double initialAngle;
private double stepAngle;
private double lastAngle;
private double value;
......@@ -291,8 +292,13 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
@Override
public void actionDrop(TangibleObject tuioObject) {
dropAngle = AngleUtils.moduloTwoPi(tuioObject.getAngle());
dialAngle = (withStopAngles) ? this.initialAngle : dropAngle;
if (Double.isNaN(dropAngle)) {
dropAngle = (isPersistent) ? 0 : AngleUtils.moduloTwoPi(tuioObject.getAngle());
}
if (!isPersistent) {
dialAngle = (withStopAngles) ? this.initialAngle : dropAngle;
}
super.actionDrop(tuioObject);
......@@ -335,7 +341,8 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
if (null == position) {
super.actionMove(tuioObject.constrainedClone(new Point()));
} else {
super.actionMove(tuioObject.constrainedClone(new Point(position.x, position.y, (float) dialAngle, position.getState().getClass())));
position.setAngle((float) dialAngle);
super.actionMove(tuioObject.constrainedClone(position));
}
} else {
dialAngle = AngleUtils.moduloTwoPi(Math.PI + tuioObject.getAngle() - dropAngle);
......
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