Search in sources :

Example 16 with Property

use of maspack.properties.Property in project artisynth_core by artisynth.

the class InverseManager method configureTargetMotionProbe.

private void configureTargetMotionProbe(NumericProbeBase probe, ArrayList<MotionTargetComponent> targets, String filename) {
    // System.out.println ("configuring motion probe");
    ArrayList<Property> props = new ArrayList<Property>();
    for (ModelComponent target : targets) {
        if (target instanceof Point) {
            props.add(target.getProperty("position"));
        } else if (target instanceof Frame) {
            props.add(target.getProperty("position"));
            props.add(target.getProperty("orientation"));
        } else {
            System.err.println("Unknown target component type: " + target.getClass().toString());
        }
    }
    // probe.setModel(myController.getMech());
    probe.setAttachedFileName(filename);
    if (probe instanceof NumericInputProbe) {
        ((NumericInputProbe) probe).setInputProperties(props.toArray(new Property[props.size()]));
    } else if (probe instanceof NumericOutputProbe) {
        ((NumericOutputProbe) probe).setOutputProperties(props.toArray(new Property[props.size()]));
    }
    if (probe instanceof NumericInputProbe) {
        File file = probe.getAttachedFile();
        if (file == null || !file.exists()) {
            ((NumericInputProbe) probe).loadEmpty();
            probe.setActive(false);
        } else {
            try {
                probe.load();
                probe.setActive(true);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Frame(artisynth.core.mechmodels.Frame) ModelComponent(artisynth.core.modelbase.ModelComponent) NumericInputProbe(artisynth.core.probes.NumericInputProbe) ArrayList(java.util.ArrayList) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) Point(artisynth.core.mechmodels.Point) WayPoint(artisynth.core.probes.WayPoint) IOException(java.io.IOException) Property(maspack.properties.Property) File(java.io.File)

Example 17 with Property

use of maspack.properties.Property in project artisynth_core by artisynth.

the class ComponentPropertyField method valueToTextArray.

protected String[] valueToTextArray(Object value) {
    ModelComponent comp = getComponent(value);
    RootModel root = myMain.getRootModel();
    String compStr = "/";
    String propStr = "";
    if (root == null || comp == null) {
        return new String[] { "", "" };
    }
    if (value instanceof ModelComponent) {
        compStr = ComponentUtils.getPathName(root, comp);
    } else if (value instanceof Property) {
        Property prop = (Property) value;
        boolean excludeLeaf = (myPropertySelector != null && !(prop.get() instanceof CompositeProperty));
        String path = ComponentUtils.getPropertyPathName(prop, root, false);
        int idx = path.indexOf(':');
        // default to root
        propStr = path;
        if (idx >= 0) {
            compStr = path.substring(0, idx);
            if (idx < path.length() - 1) {
                propStr = path.substring(idx + 1);
            }
        }
    } else {
        throw new InternalErrorException("Unknown value type: " + value.getClass());
    }
    return new String[] { compStr, propStr };
}
Also used : RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent) InternalErrorException(maspack.util.InternalErrorException) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) CompositeProperty(maspack.properties.CompositeProperty)

Example 18 with Property

use of maspack.properties.Property in project artisynth_core by artisynth.

the class ComponentPropertyField method getPropertyForComposite.

private Property getPropertyForComposite(CompositeProperty cprop) {
    PropertyInfo info = cprop.getPropertyInfo();
    HasProperties host = cprop.getPropertyHost();
    Property prop = host.getProperty(info.getName());
    if (prop == null) {
        throw new InternalErrorException("Property not found in composite property host");
    }
    return prop;
}
Also used : HasProperties(maspack.properties.HasProperties) InternalErrorException(maspack.util.InternalErrorException) PropertyInfo(maspack.properties.PropertyInfo) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property)

Example 19 with Property

use of maspack.properties.Property in project artisynth_core by artisynth.

the class PropertyField method setWidgetableOnly.

/**
 * Sets this field to accept only properties for which widgets can be
 * created.
 *
 * @param enable
 * if true, enables only properties which are widgetable
 */
public void setWidgetableOnly(boolean enable) {
    if (myWidgetableOnly != enable) {
        myWidgetableOnly = enable;
        // clear to ensure property selection list will be rebuilt ...
        myLastSelectorHost = null;
        if (enable) {
            Property prop = getProperty();
            if (prop != null && !PropertyWidget.canCreate(prop.getInfo())) {
                updateValueAndDisplay(getValueForHost());
                return;
            }
        }
        // will redo property selector entries
        updatePropertySelector();
    }
}
Also used : Property(maspack.properties.Property)

Example 20 with Property

use of maspack.properties.Property 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);
    }
}
Also used : NumericProbeVariable(artisynth.core.probes.NumericProbeVariable) AddComponentsCommand(artisynth.core.gui.editorManager.AddComponentsCommand) ArrayList(java.util.ArrayList) NumericOutputProbe(artisynth.core.probes.NumericOutputProbe) DoubleInterval(maspack.util.DoubleInterval) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Property(maspack.properties.Property)

Aggregations

Property (maspack.properties.Property)44 CompositeProperty (maspack.properties.CompositeProperty)15 EditingProperty (maspack.properties.EditingProperty)15 InheritableProperty (maspack.properties.InheritableProperty)10 ModelComponent (artisynth.core.modelbase.ModelComponent)9 IOException (java.io.IOException)7 InternalErrorException (maspack.util.InternalErrorException)7 ArrayList (java.util.ArrayList)6 LabeledComponentBase (maspack.widgets.LabeledComponentBase)6 NumericInputProbe (artisynth.core.probes.NumericInputProbe)5 HasProperties (maspack.properties.HasProperties)5 NumericOutputProbe (artisynth.core.probes.NumericOutputProbe)4 NumericProbeVariable (artisynth.core.probes.NumericProbeVariable)4 RootModel (artisynth.core.workspace.RootModel)3 Component (java.awt.Component)3 Point (java.awt.Point)3 File (java.io.File)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Timeline (artisynth.core.gui.Timeline)2