Commit bb3b7b54 authored by Nico Mack's avatar Nico Mack

New Branch for TULIP version used for SUCCESS Demo

parent 48800409
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}/python</path>
</pydev_pathproperty>
</pydev_project>
......@@ -96,12 +96,11 @@
</dependencies>
<repositories>
<repository>
<id>Kenai</id>
<name>Kenai</name>
<url>file:///Users/mack/.m2/repository</url>
</repository>
</repositories>
<repository>
<id>LIST</id>
<name>Artifacts</name>
<url>https://artefacts.list.lu/libs-release-local</url>
</repository>
</repositories>
</project>
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -224,7 +224,9 @@ public abstract class Variable<V> implements Cloneable {
* The {@link InputChangeListener} to add.
*/
public void addListener(InputChangeListener listener) {
listeners.add(listener);
if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
/**
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -25,13 +25,15 @@ public class SelectorWidget extends ValueWidget {
/** The currently selected position */
protected int currentPosition = NONE;
protected int presetPosition = NONE;
protected float presetAngleOffset = 0;
protected boolean isPersistent = false;
// ***************************************************************************
// * Constants *
// ***************************************************************************
public static int NONE = -1;
private static double TWO_PI = 2 * Math.PI;
public static final int NONE = -1;
private static final double TWO_PI = 2 * Math.PI;
// ---------------------------------------------------------------------------
// ***************************************************************************
......@@ -62,7 +64,7 @@ public class SelectorWidget extends ValueWidget {
// ***************************************************************************
// ---------------------------------------------------------------------------
private int getNumberOfPositions() {
protected int getNumberOfPositions() {
List<IndexedCorona> selectableCoronas = getCoronas(IndexedCorona.class);
HashSet<Integer> alreadySeen = new HashSet<>();
......@@ -77,6 +79,16 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
protected float moduloTwoPi(float rawAngle) {
double angle = rawAngle % TWO_PI;
if (angle < 0)
angle += TWO_PI;
return (float) angle;
}
// ---------------------------------------------------------------------------
@Override
protected void updateFromRotation(double angle) {
......@@ -84,10 +96,12 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
private int getCurrentPosition(float angle) {
protected int getCurrentPosition(float currentAngle) {
double segment = TWO_PI / numberOfPositions;
int current = 0;
float angle = this.moduloTwoPi(currentAngle);
// detect in which segment the current rotation is
for (int position = 0; position < numberOfPositions; position++) {
double minrot = (position - 0.5) * segment;
......@@ -104,7 +118,7 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
private float getCurrentAngle(int position) {
protected float getCurrentAngle(int position) {
double segment = TWO_PI / numberOfPositions;
float angle = 0;
......@@ -119,7 +133,7 @@ public class SelectorWidget extends ValueWidget {
// ---------------------------------------------------------------------------
private void selectPosition(int position) {
protected void selectPosition(int position) {
if (position != currentPosition) {
this.getCoronas(IndexedCorona.class).forEach(indexed -> indexed.setSelected(indexed.getIndex() == position));
......@@ -138,6 +152,18 @@ public class SelectorWidget extends ValueWidget {
// ***************************************************************************
// ---------------------------------------------------------------------------
public void reset() {
if (isPersistent) {
this.selectPosition(presetPosition);
Point centre = this.getPosition();
if (centre != null) {
presetAngleOffset = this.moduloTwoPi(this.getCurrentAngle(currentPosition) - (centre.getAngle() - presetAngleOffset));
}
}
}
// ---------------------------------------------------------------------------
public void setSelectedPosition(int position) {
currentPosition = position;
}
......@@ -160,9 +186,13 @@ public class SelectorWidget extends ValueWidget {
@Override
public void actionMove(TangibleObject tuioObject) {
super.actionMove(tuioObject);
int position = getCurrentPosition(tuioObject.getAngle());
double angle = this.moduloTwoPi(tuioObject.getAngle() + presetAngleOffset);
TangibleObject clone = tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), (float) angle));
super.actionMove(clone);
int position = getCurrentPosition(clone.getAngle());
int widgetId = tuioObject.getObjectId();
StateManager manager = states.get(widgetId);
......@@ -193,10 +223,12 @@ public class SelectorWidget extends ValueWidget {
@Override
public void actionDrop(TangibleObject tuioObject) {
int position = (this.isPersistent(tuioObject.getObjectId())) ? currentPosition : presetPosition;
float angle = this.getCurrentAngle(position);
isPersistent = this.isPersistent(tuioObject.getObjectId());
int position = (isPersistent) ? currentPosition : presetPosition;
presetAngleOffset = (isPersistent) ? this.moduloTwoPi(this.getCurrentAngle(position) - tuioObject.getAngle()) : 0;
TangibleObject clone = tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), angle));
TangibleObject clone = tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), presetAngleOffset));
super.actionDrop(clone);
this.selectPosition(position);
......@@ -216,7 +248,7 @@ public class SelectorWidget extends ValueWidget {
public void actionLift(TangibleObject tuioObject) {
super.actionLift(tuioObject);
if (!this.isPersistent(tuioObject.getObjectId())) {
if (!isPersistent) {
this.selectPosition(NONE);
}
}
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
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