use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.
the class InputNumericProbeEditor method addBlankInputProbeProperty.
/**
* Adds a blank input probe property. -adds a (null) Property and (invalid)
* Driver to lists -adds the gui components corresponding to the proprty and
* driver
*/
public void addBlankInputProbeProperty() {
// Data components: add a null property, and an empty (invalid) driver
myProperties.add(myProperties.size(), null);
NumericProbeDriver driver = new NumericProbeDriver();
myDrivers.add(myDrivers.size(), driver);
// GUI components:
AddPropertyPane newPropPane = new AddPropertyPane(this);
newPropPane.removePropNameField();
addPropertyGUI(newPropPane);
AddEquationPane newEqPane = new AddEquationPane(this);
newEqPane.setEnabled(false);
addEquationGUI(newEqPane);
}
use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.
the class InputNumericProbeEditor method changeVariableDimension.
//
// Called when a user changes the variable's dimension
//
public void changeVariableDimension(String varname, int dimen) {
NumericProbeVariable var = myVariables.get(varname);
myVariables.remove(var);
myVariables.put(varname, new NumericProbeVariable(dimen));
for (NumericProbeDriver driver : myDrivers) {
if (driver.usesVariable(varname)) {
driver.setInvalid();
AddEquationPane eqPane = eqList.get(myDrivers.indexOf(driver));
eqPane.setEqText("");
System.out.println("invalidated driver with expr [" + driver.getExpression() + "]");
}
}
// super.updateGUI();
}
use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.
the class InputNumericProbeEditor method changeExpression.
public void changeExpression(int id, String newExpr) {
NumericProbeDriver driver = myDrivers.get(id);
AddEquationPane eqPane = eqList.get(id);
String oldExpr = driver.getExpression();
System.out.println("old driver expr is [" + oldExpr + "]");
if (newExpr == driver.getExpression()) {
System.out.println("same as old expression. do nothing.");
return;
}
if (// todo: either remove this bit, or remove it in the
newExpr == "") // function that calls it
{
driver.setInvalid();
System.out.println("invalidating driver");
return;
}
try {
driver.setExpression(newExpr, myVariables);
} catch (Exception exception) {
System.out.println(exception.getMessage());
showErrorWindow(exception.getMessage());
invalidateDriverAndGUI(id);
return;
}
// if everything is ok up to this point, check to see if the size matches:
checkExpressionConsistency(id);
eqPane.updateAppearance();
eqPane.revalidate();
eqPane.repaint();
// not sure if this is needed, since driver is a shallow copy?
myDrivers.remove(id);
myDrivers.add(id, driver);
System.out.println("change OK. replacing, [" + oldExpr + "] with [" + newExpr + "]");
}
use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.
the class InputNumericProbeEditor method deleteInputVariable.
//
// Called when a user deletes an input variable
//
public void deleteInputVariable(String varname) {
myVariables.remove(varname);
System.out.println("before remove, size =" + myVariables.size());
for (NumericProbeDriver driver : myDrivers) {
System.out.println("looking at driver expression: [" + driver.getExpression() + "]");
if (driver.usesVariable(varname)) {
System.out.println(driver.getExpression() + " invalidated");
driver.setInvalid();
}
}
super.updateGUI();
System.out.println("after remove, size =" + myVariables.size());
}
use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.
the class NumericProbeEditor method load.
public void load(NumericProbeBase probe) {
// when opening a probe we create local copies of:
//
// 1) the properties
// 2) the drivers
// 3) the variables
// 4) the variable dimensions (for input probes)
NumericProbeDriver[] drivers = probe.getDrivers();
myDrivers = new ArrayList<NumericProbeDriver>();
for (int i = 0; i < drivers.length; i++) {
myDrivers.add(new NumericProbeDriver(drivers[i]));
}
myProperties = new ArrayList<Property>();
Property[] props = probe.getAttachedProperties();
for (int i = 0; i < props.length; i++) {
myProperties.add(props[i]);
}
myVariables = new LinkedHashMap<String, NumericProbeVariable>();
for (Map.Entry<String, NumericProbeVariable> entry : probe.getVariables().entrySet()) {
myVariables.put(entry.getKey(), new NumericProbeVariable(entry.getValue()));
}
}
Aggregations