use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class ControlPanel method isStale.
private boolean isStale(Property prop) {
ModelComponent comp = ComponentUtils.getPropertyComponent(prop);
if (comp == null) {
System.out.println("no comp");
return true;
}
if (!PropertyUtils.isConnectedToHierarchy(prop)) {
System.out.println("not connected");
return true;
}
RootModel myroot = RootModel.getRoot(this);
// we don't bother with the stale check
if (myroot != null && RootModel.getRoot(comp) != myroot) {
System.out.println("not in root");
return true;
}
return false;
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class InverseManager method findInverseController.
public static TrackingController findInverseController() {
TrackingController ic = null;
RootModel root = Main.getMain().getRootModel();
for (Controller c : root.getControllers()) {
if (c instanceof TrackingController) {
ic = (TrackingController) c;
break;
}
}
return ic;
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class ComponentPropertyField method textToValue.
protected Object textToValue(String text, BooleanHolder corrected, StringHolder errMsg) {
corrected.value = false;
RootModel root = myMain.getRootModel();
Object compOrProp = null;
if (root == null || text == null || text.equals("")) {
return validValue(null, errMsg);
}
if (!myPropertiesAllowed) {
compOrProp = root.findComponent(text);
if (compOrProp == null) {
return illegalValue("No such component", errMsg);
}
} else {
boolean colonInText = (text.indexOf(':') != -1);
if (!colonInText) {
compOrProp = root.findComponent(text);
// if (compOrProp != null) {
// // match with last property if possible
// if (myLastPropName != null) {
// Property prop =
// ((ModelComponent)compOrProp).getProperty (myLastPropName);
// if (prop != null) {
// compOrProp = prop;
// }
// }
}
if (compOrProp == null) {
compOrProp = root.getProperty(text);
}
if (compOrProp == null) {
if (colonInText) {
return illegalValue("Property does not exist or is inaccessible", errMsg);
} else {
return illegalValue("No such component or property", errMsg);
}
}
}
return validValue(compOrProp, errMsg);
}
use of artisynth.core.workspace.RootModel in project artisynth_core by artisynth.
the class ComponentPropertyField method valueToText.
protected String valueToText(Object value) {
ModelComponent comp = getComponent(value);
RootModel root = myMain.getRootModel();
if (root == null || comp == null) {
return "";
}
if (value instanceof ModelComponent) {
return 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);
if (!path.contains(":")) {
// root component + property
path = "/:" + path;
}
return path;
} else {
throw new InternalErrorException("Unknown value type: " + value.getClass());
}
// String text = ComponentUtils.getPathName(root, comp);
// if (value instanceof Property)
// { Property prop = (Property)value;
// String propPath = getPropertyPath (prop, myPropertySelector != null);
// if (propPath.length() > 0)
// { text += "/" + propPath;
// }
// }
// return text;
}
Aggregations