Search in sources :

Example 51 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class ComponentPropertyField method updateInternalValue.

protected boolean updateInternalValue(Object value) {
    ModelComponent newComp = getComponent(value);
    if (mySelectionEnabled) {
        if (newComp != null && mySelectionManager.getLastSelected() != newComp) {
            mySelectionListenerMasked = true;
            mySelectionManager.clearSelections();
            mySelectionManager.addSelected(newComp);
            mySelectionListenerMasked = false;
        }
    }
    if (!valuesEqual(value, myValue)) {
        // ModelComponent oldComp = getComponent (myValue);
        // ModelComponent newComp = getComponent (value);
        myValue = value;
        // }
        if (myPropertySelector != null) {
            updatePropertySelector();
        }
        return true;
    } else {
        return false;
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 52 with ModelComponent

use of artisynth.core.modelbase.ModelComponent 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)

Example 53 with ModelComponent

use of artisynth.core.modelbase.ModelComponent in project artisynth_core by artisynth.

the class HydrostatInvDemo method addInverseController.

protected void addInverseController() {
    trackingController = new TrackingController(mech, "tcon");
    for (ModelComponent comp : hydro.createTargetList()) {
        trackingController.addMotionTarget((MotionTargetComponent) comp);
    }
    if (useBundlesForInverse) {
        for (MuscleBundle b : hydro.getMuscleBundles()) {
            trackingController.addExciter(b);
            Color exColor = b.getRenderProps().getLineColor();
            b.setExcitationColor(exColor);
            RenderProps.setLineColor(b, Color.WHITE);
        }
    } else {
        for (ExcitationComponent exciter : hydro.getMuscleExciters()) {
            trackingController.addExciter(exciter);
        }
    }
    trackingController.addL2RegularizationTerm(100 * 100);
    trackingController.setProbeDuration(5.0);
    trackingController.setProbeUpdateInterval(stepsize);
    trackingController.createProbesAndPanel(this);
    addController(trackingController);
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) ModelComponent(artisynth.core.modelbase.ModelComponent) Color(java.awt.Color) ExcitationComponent(artisynth.core.mechmodels.ExcitationComponent) TrackingController(artisynth.core.inverse.TrackingController)

Aggregations

ModelComponent (artisynth.core.modelbase.ModelComponent)53 RootModel (artisynth.core.workspace.RootModel)9 Property (maspack.properties.Property)8 CompositeComponent (artisynth.core.modelbase.CompositeComponent)5 ArrayList (java.util.ArrayList)5 Point (artisynth.core.mechmodels.Point)4 Renderable (maspack.render.Renderable)4 InternalErrorException (maspack.util.InternalErrorException)4 HasCoordinateFrame (artisynth.core.modelbase.HasCoordinateFrame)3 Traceable (artisynth.core.modelbase.Traceable)3 WayPoint (artisynth.core.probes.WayPoint)3 Point (java.awt.Point)3 LinkedList (java.util.LinkedList)3 CompositeProperty (maspack.properties.CompositeProperty)3 FractionRenderType (artisynth.core.femmodels.AuxMaterialBundle.FractionRenderType)2 FemModel3d (artisynth.core.femmodels.FemModel3d)2 HexElement (artisynth.core.femmodels.HexElement)2 DirectionRenderType (artisynth.core.femmodels.MuscleBundle.DirectionRenderType)2 RemoveComponentsCommand (artisynth.core.gui.editorManager.RemoveComponentsCommand)2 ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)2