Search in sources :

Example 41 with RootModel

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;
}
Also used : RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 42 with RootModel

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;
}
Also used : RootModel(artisynth.core.workspace.RootModel) Controller(artisynth.core.modelbase.Controller)

Example 43 with RootModel

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

Example 44 with RootModel

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

Aggregations

RootModel (artisynth.core.workspace.RootModel)44 ModelComponent (artisynth.core.modelbase.ModelComponent)10 InternalErrorException (maspack.util.InternalErrorException)7 IOException (java.io.IOException)6 WayPoint (artisynth.core.probes.WayPoint)4 FileNotFoundException (java.io.FileNotFoundException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Probe (artisynth.core.probes.Probe)3 WayPointProbe (artisynth.core.probes.WayPointProbe)3 File (java.io.File)3 Property (maspack.properties.Property)3 ControlPanel (artisynth.core.gui.ControlPanel)2 CompositeComponent (artisynth.core.modelbase.CompositeComponent)2 TracingProbe (artisynth.core.probes.TracingProbe)2 Point (java.awt.Point)2 JFileChooser (javax.swing.JFileChooser)2 JMenuItem (javax.swing.JMenuItem)2 JSeparator (javax.swing.JSeparator)2 CompositeProperty (maspack.properties.CompositeProperty)2 ArgParser (argparser.ArgParser)1