Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TULIP-CPS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP-CPS
Commits
0ce0f844
Commit
0ce0f844
authored
Aug 21, 2017
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented reset feature in SelectorWidget. Better handling of
preselect
parent
59630dc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
47 deletions
+75
-47
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
...list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
+7
-3
CPS/src/lu/list/itis/dkd/tui/widget/DisplayWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/DisplayWidget.java
+39
-37
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
+29
-7
No files found.
CPS/src/lu/list/itis/dkd/tui/cps/system/executor/PythonExecutor.java
View file @
0ce0f844
...
...
@@ -4,6 +4,7 @@ import lu.list.itis.dkd.tui.cps.system.Import;
import
lu.list.itis.dkd.tui.cps.variable.SpatialVariable
;
import
lu.list.itis.dkd.tui.cps.variable.Variable
;
import
lu.list.itis.dkd.tui.cps.variable.VectorVariable
;
import
lu.list.itis.dkd.tui.utility.StringUtils
;
import
org.python.core.Py
;
import
org.python.core.PyArray
;
...
...
@@ -54,7 +55,10 @@ public class PythonExecutor extends Executor {
engine
.
setErr
(
this
.
executionErrors
);
engine
.
exec
(
"import sys"
);
//$NON-NLS-1$
engine
.
exec
(
"sys.path.append ('"
+
properties
.
getProperty
(
SCRIPT_ENGINE_WORKING_DIR
)
+
"')"
);
//$NON-NLS-1$//$NON-NLS-2$
engine
.
exec
(
StringUtils
.
build
(
"sys.path.append ('{}')"
,
properties
.
getProperty
(
SCRIPT_ENGINE_WORKING_DIR
)));
//$NON-NLS-1$
// engine.exec("sys.path.append ('" + properties.getProperty(SCRIPT_ENGINE_WORKING_DIR) +
// "')"); //$NON-NLS-1$//$NON-NLS-2$
}
// ---------------------------------------------------------------------------
...
...
@@ -274,7 +278,7 @@ public class PythonExecutor extends Executor {
}
}
else
{
for
(
PyObject
item
:
array
.
asIterable
())
{
vector
.
add
(
item
.
__tojava__
(
Object
.
class
));
vector
.
add
(
this
.
depythonizeObject
(
item
));
}
}
vector
.
suspendListenerNotification
(
false
);
...
...
@@ -451,6 +455,6 @@ public class PythonExecutor extends Executor {
/** {@inheritDoc} */
@Override
public
void
resetContext
()
{
// TODO figure out
a way to clear engine
context
// TODO figure out
how to reset
context
}
}
CPS/src/lu/list/itis/dkd/tui/widget/DisplayWidget.java
View file @
0ce0f844
...
...
@@ -167,54 +167,56 @@ public class DisplayWidget extends BaseWidget implements InputChangeListener {
// ---------------------------------------------------------------------------
public
void
setVariables
(
Collection
<
Variable
<?>>
newVariables
)
{
Preconditions
.
checkArgument
(
newVariables
!=
null
,
"Set of variables can't be null!"
);
// $NON-NLS-1$
assert
newVariables
!=
null
;
this
.
variables
=
new
HashMap
<>();
for
(
Variable
<?>
variable
:
newVariables
)
{
NumericalVariable
numeric
=
(
NumericalVariable
)
variable
;
this
.
variables
.
put
(
numeric
.
getName
(),
numeric
);
variable
.
addListener
(
this
);
if
(
dispatcher
.
containsKey
(
numeric
.
getName
()))
{
Collection
<
ValueCorona
>
displays
=
dispatcher
.
get
(
numeric
.
getName
());
for
(
ValueCorona
display
:
displays
)
{
display
.
setVariable
(
numeric
);
}
}
else
{
LOGGER
.
warn
(
"Variable {} appears not to be used by any Value Corona!"
,
numeric
.
getName
());
// $NON-NLS-1$
}
}
}
// public void setVariables(Collection<Variable<?>> newVariables) {
// Preconditions.checkArgument(newVariables != null, "Set of variables can't be null!");
// //$NON-NLS-1$
// Preconditions.checkArgument(newVariables != null, "Set of variables can't be null!"); //
// $NON-NLS-1$
//
// assert newVariables != null;
//
// this.variables = new HashMap<
String, NumericalVariable
>();
// this.variables = new HashMap<>();
// for (Variable<?> variable : newVariables) {
// this.variables.put(variable.getName(), (NumericalVariable) variable);
// NumericalVariable numeric = (NumericalVariable) variable;
//
// this.variables.put(numeric.getName(), numeric);
// variable.addListener(this);
// }
//
// List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
// if (dispatcher.containsKey(numeric.getName())) {
// Collection<ValueCorona> displays = dispatcher.get(numeric.getName());
// for (ValueCorona display : displays) {
// Variable<?> variable = display.getVariable();
// if (variable != null) {
// String variableName = variable.getName();
// if (this.variables.containsKey(variableName)) {
// display.setVariable(this.variables.get(variableName));
// } else {
// LOGGER.warn("Corona requires variable {} unkown to display widget!", variableName);
// //$NON-NLS-1$
// display.setVariable(numeric);
// }
// } else {
// LOGGER.warn("Variable {} appears not to be used by any Value Corona!", numeric.getName()); //
// $NON-NLS-1$
// }
// }
// }
public
void
setVariables
(
Collection
<
Variable
<?>>
newVariables
)
{
Preconditions
.
checkArgument
(
newVariables
!=
null
,
"Set of variables can't be null!"
);
// $NON-NLS-1$
this
.
variables
=
new
HashMap
<>();
for
(
Variable
<?>
variable
:
newVariables
)
{
this
.
variables
.
put
(
variable
.
getName
(),
(
NumericalVariable
)
variable
);
variable
.
addListener
(
this
);
}
List
<
ValueCorona
>
displays
=
this
.
getCoronas
(
ValueCorona
.
class
);
for
(
ValueCorona
display
:
displays
)
{
Variable
<?>
variable
=
display
.
getVariable
();
if
(
variable
!=
null
)
{
String
variableName
=
variable
.
getName
();
if
(
this
.
variables
.
containsKey
(
variableName
))
{
display
.
setVariable
(
this
.
variables
.
get
(
variableName
));
}
else
{
LOGGER
.
warn
(
"Corona requires variable {} unkown to display widget!"
,
variableName
);
// $NON-NLS-1$
}
}
}
}
// ---------------------------------------------------------------------------
@Override
...
...
CPS/src/lu/list/itis/dkd/tui/widget/SelectorWidget.java
View file @
0ce0f844
...
...
@@ -25,6 +25,8 @@ 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 *
...
...
@@ -157,6 +159,18 @@ public class SelectorWidget extends ValueWidget {
// ***************************************************************************
// ---------------------------------------------------------------------------
public
void
reset
()
{
if
(
isPersistent
)
{
this
.
selectPosition
(
presetPosition
);
Point
centre
=
this
.
getPosition
();
if
(
centre
!=
null
)
{
presetAngleOffset
=
(
float
)
((
this
.
getCurrentAngle
(
currentPosition
)
-
(
centre
.
getAngle
()
-
presetAngleOffset
))
%
TWO_PI
);
}
}
}
// ---------------------------------------------------------------------------
public
void
setSelectedPosition
(
int
position
)
{
currentPosition
=
position
;
}
...
...
@@ -179,9 +193,13 @@ public class SelectorWidget extends ValueWidget {
@Override
public
void
actionMove
(
TangibleObject
tuioObject
)
{
super
.
actionMove
(
tuioObject
);
int
position
=
getCurrentPosition
(
tuioObject
.
getAngle
());
double
angle
=
(
tuioObject
.
getAngle
()
+
presetAngleOffset
)
%
TWO_PI
;
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,8 +211,10 @@ public class SelectorWidget extends ValueWidget {
autoFading
.
forEach
(
corona
->
corona
.
fadeIn
());
}
if
(
manager
.
isRotating
()
&&
(
position
!=
currentPosition
))
{
this
.
selectPosition
(
position
);
if
(
manager
.
isRotating
())
{
if
(
position
!=
currentPosition
)
{
this
.
selectPosition
(
position
);
}
}
}
...
...
@@ -210,10 +230,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
)
?
(
float
)
((
this
.
getCurrentAngle
(
position
)
-
tuioObject
.
getAngle
())
%
TWO_PI
)
:
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment