Search in sources :

Example 1 with NumericProbeDriver

use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.

the class InputNumericProbeEditor method addProperty.

/**
 * Called when a valid property has been selected for the first time. A
 * property is null before this point. so we set the property at the
 * corresponding index in the ArrayList. Then we automatically create an
 * input variable to go along with this property. The GUI elements are added
 * accordingly for the new input vector. The driver at the current index is
 * also created with the input variable name as its expression.
 *
 * @param index
 * index of property (also of driver, since they should be in sync)
 * @param prop
 * the selected property.
 */
public void addProperty(int index, Property prop) {
    myProperties.set(index, prop);
    NumericConverter conv = new NumericConverter(prop.get());
    String varname = getUniqueVariableName(INPUT_PREFIX);
    NumericProbeVariable var = new NumericProbeVariable(conv.getDimension());
    myVariables.put(varname, var);
    AddVectorPane newVec = new AddVectorPane(this, varname);
    newVec.setDim(var.getDimension());
    addVectorGUI(newVec);
    NumericProbeDriver driver = new NumericProbeDriver();
    driver.setExpression(varname, myVariables);
    myDrivers.set(index, driver);
    updateGUI();
}
Also used : NumericConverter(maspack.properties.NumericConverter) NumericProbeDriver(artisynth.core.probes.NumericProbeDriver) NumericProbeVariable(artisynth.core.probes.NumericProbeVariable)

Example 2 with NumericProbeDriver

use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.

the class NumericProbeEditor method changeExpression.

// 
// Called when a user changes an expression
// 
public void changeExpression(String newexpr, int idx) {
    NumericProbeDriver driver = myDrivers.get(idx);
    try {
        driver.setExpression(newexpr, myVariables);
    } catch (Exception e) {
    // handle error
    }
    updateGUI();
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver)

Example 3 with NumericProbeDriver

use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.

the class OutputNumericProbeEditor method addBlankOutputProbeVector.

private void addBlankOutputProbeVector() {
    // Data components:
    NumericProbeDriver driver = new NumericProbeDriver();
    driver.setInvalid();
    myDrivers.add(myDrivers.size(), driver);
    // GUI components:
    // String name = getUniqueVariableName(OUTPUT_PREFIX);
    // AddVectorPane newVecPane = new AddVectorPane(this, null);
    // newVecPane.setAsOutput();
    // addVectorGUI(newVecPane);
    AddEquationPane newEqPane = createEquationPane("");
    addEquationGUI(newEqPane);
}
Also used : NumericProbeDriver(artisynth.core.probes.NumericProbeDriver)

Example 4 with NumericProbeDriver

use of artisynth.core.probes.NumericProbeDriver in project artisynth_core by artisynth.

the class OutputNumericProbeEditor method addProperty.

public boolean addProperty(int index, Property prop) {
    myProperties.set(index, prop);
    AddPropertyPane propPane = propList.get(index);
    String varname = propPane.getPropNameFieldText();
    NumericConverter conv = new NumericConverter(prop.get());
    NumericProbeVariable var = new NumericProbeVariable(conv.getDimension());
    myVariables.put(varname, var);
    // list. If so, use that:
    if (myDrivers.size() > 0 && !myDrivers.get(myDrivers.size() - 1).isValid()) {
        int id = myDrivers.size() - 1;
        AddEquationPane eqn = eqList.get(id);
        eqn.setEqText(varname);
        changeExpression(id, varname);
        updateGUI();
        return false;
    } else {
        // otherwise, add a new driver
        NumericProbeDriver driver = new NumericProbeDriver();
        // System.out.println("addProperty; var name= "+varname);
        driver.setExpression(varname, myVariables);
        // add it at the end of list
        myDrivers.add(myDrivers.size(), driver);
        // add an equation pane for it
        AddEquationPane newEq = createEquationPane(driver.getExpression());
        newEq.setDimensionLabel(driver.getOutputSize());
        newEq.updateAppearance();
        addEquationGUI(newEq);
        updateGUI();
        return true;
    }
}
Also used : NumericConverter(maspack.properties.NumericConverter) NumericProbeDriver(artisynth.core.probes.NumericProbeDriver) NumericProbeVariable(artisynth.core.probes.NumericProbeVariable)

Example 5 with NumericProbeDriver

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

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