use of artisynth.core.probes.NumericProbeVariable in project artisynth_core by artisynth.
the class OutputNumericProbeEditor method setOutputProbe.
private void setOutputProbe() {
ArrayList<String> variableNames = new ArrayList<String>();
for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
variableNames.add(entry.getKey());
System.out.println("variable: " + entry.getKey() + " added to list");
}
for (Property prop : myProperties) {
System.out.println("property " + prop.getName() + " found");
}
// System.out.println("myProps size ="+myProperties.size());
// System.out.println("myVars size ="+variableNames.size());
NumericOutputProbe probeToSet;
if (oldProbe == null) {
probeToSet = new NumericOutputProbe();
} else {
probeToSet = oldProbe;
}
probeToSet.set(myProperties.toArray(new Property[0]), getDriverExpressions(), variableNames.toArray(new String[0]));
probeToSet.setStartTime(startTimeField.getDoubleValue());
probeToSet.setStopTime(endTimeField.getDoubleValue());
probeToSet.setName(probeNameField.getStringValue());
probeToSet.setUpdateInterval(intervalField.getDoubleValue());
if (!rangeField.valueIsVoid()) {
DoubleInterval range = rangeField.getRangeValue();
probeToSet.setDefaultDisplayRange(range.getLowerBound(), range.getUpperBound());
}
// probeToSet.setDefaultDisplayRange(
// dispLowerField.getDoubleValue(), dispUpperField.getDoubleValue());
probeToSet.setAttachedFileName(attachedFileField.getText());
if (oldProbe == null) {
AddComponentsCommand cmd = new AddComponentsCommand("add output probe", probeToSet, myMain.getRootModel().getOutputProbes());
myMain.getUndoManager().saveStateAndExecute(cmd);
// System.out.println("track index: "+probeToSet.getTrack());
// myMain.getRootModel().addOutputProbe(probeToSet);
// myMain.getTimeline().addProbe(probeToSet);
}
}
use of artisynth.core.probes.NumericProbeVariable in project artisynth_core by artisynth.
the class InputNumericProbeEditor method renameInputVariable.
//
// Called when a user renames a variable.
// first rename the variable in myVariables, and then
// go through all the drivers and rename
//
public void renameInputVariable(String oldname, String newname) {
try {
NumericProbeVariable var = myVariables.get(oldname);
myVariables.remove(oldname);
myVariables.put(newname, var);
} catch (Exception e) {
System.out.println(e.getMessage());
}
for (NumericProbeDriver driver : myDrivers) {
if (driver.renameVariable(oldname, newname)) {
System.out.println("new name different... renaming");
}
int id = myDrivers.indexOf(driver);
getEqPane(id).setEqText(driver.getExpression());
System.out.println("setting driver expression to " + driver.getExpression());
}
super.updateGUI();
}
use of artisynth.core.probes.NumericProbeVariable 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.NumericProbeVariable 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()));
}
}
use of artisynth.core.probes.NumericProbeVariable in project artisynth_core by artisynth.
the class OutputNumericProbeEditor method updateVariable.
private void updateVariable(String name, Property prop) {
// the way we have to check to see the drivers work here is similar to
// updateProperty in the input probe editor.
NumericProbeVariable var = myVariables.get(name);
if (var.getDimension() != getPropDim(prop)) {
System.out.println(name + " variable changed to size " + getPropDim(prop));
var.setDimension(getPropDim(prop));
for (NumericProbeDriver driver : myDrivers) {
System.out.println("driver expression is : " + driver.getExpression());
if (driver.usesVariable(name)) {
int index = myDrivers.indexOf(driver);
System.out.println("Driver #" + index + "uses this variable");
AddEquationPane eqPane = eqList.get(index);
// AddVectorPane vecPane = probeChannels.get(index);
try {
System.out.println("size used to be: " + driver.getOutputSize());
driver.setExpression(driver.getExpression(), myVariables);
// vecPane = probeChannels.get(index);
System.out.println("size is now: " + driver.getOutputSize());
eqPane.setDimensionLabel(driver.getOutputSize());
} catch (Exception exception) {
System.out.println(exception.getMessage());
showErrorWindow(exception.getMessage());
invalidateDriverAndGUI(index);
// invalidate current driver.
eqPane.setEqText("");
eqPane.clearDimensionLabel();
System.out.println("invalidating driver @ index " + index);
}
}
}
}
}
Aggregations