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();
}
}
}
}
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 };
}
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;
}
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();
}
}
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);
}
}
Aggregations