Search in sources :

Example 6 with NumericProbeDriver

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);
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver)

Example 7 with NumericProbeDriver

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();
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver) NumericProbeVariable(artisynth.core.probes.NumericProbeVariable)

Example 8 with NumericProbeDriver

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 + "]");
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver) IOException(java.io.IOException)

Example 9 with NumericProbeDriver

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());
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver)

Example 10 with NumericProbeDriver

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()));
    }
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver) NumericProbeVariable(artisynth.core.probes.NumericProbeVariable) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

NumericProbeDriver (artisynth.core.probes.NumericProbeDriver)15 NumericProbeVariable (artisynth.core.probes.NumericProbeVariable)7 IOException (java.io.IOException)2 NumericConverter (maspack.properties.NumericConverter)2 Property (maspack.properties.Property)2 Timeline (artisynth.core.gui.Timeline)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 CompositeProperty (maspack.properties.CompositeProperty)1