Search in sources :

Example 1 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class FemControlPanel method addBundlesToPanel.

public static void addBundlesToPanel(ControlPanel panel, FemMuscleModel fem, boolean reColor) {
    int ncolors = PlotTraceInfo.numPalatteColors();
    ComponentList<MuscleBundle> bundles = fem.getMuscleBundles();
    for (int i = 0; i < bundles.size(); ++i) {
        MuscleBundle bundle = bundles.get(i);
        DoubleFieldSlider slider = (DoubleFieldSlider) panel.addWidget(bundle.getName(), fem, "bundles/" + bundle.getNumber() + ":excitation", 0, 1);
        if (slider == null)
            continue;
        slider.setRoundingTolerance(0.00001);
        if (reColor) {
            slider.getLabel().setForeground(PlotTraceInfo.getPaletteColors()[i % ncolors]);
            RenderProps.setLineColor(bundles.get(i), PlotTraceInfo.getPaletteColors()[i % ncolors]);
            RenderProps.setFaceColor(bundles.get(i), PlotTraceInfo.getPaletteColors()[i % ncolors]);
        } else {
            if (bundles.get(i).getRenderProps() != null) {
                slider.getLabel().setForeground(bundles.get(i).getRenderProps().getLineColor());
            }
        }
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Point(java.awt.Point) DoubleFieldSlider(maspack.widgets.DoubleFieldSlider)

Example 2 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class MuscleBundleEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    MuscleBundle bundle;
    if ((bundle = getEditableBundle(selection)) != null) {
        if (actionCommand == "Edit fibres ...") {
            if (myEditManager.acquireEditLock()) {
                MuscleFibreAgent agent = new MuscleFibreAgent(myMain, bundle, getBundleAncestor(bundle));
                agent.setContinuousAdd(true);
                agent.show(popupBounds);
            }
        } else if (actionCommand == "Edit elements ...") {
            if (myEditManager.acquireEditLock()) {
                MuscleElementAgent agent = new MuscleElementAgent(myMain, bundle, getBundleAncestor(bundle));
                agent.show(popupBounds);
            }
        } else if (actionCommand == "Compute element directions") {
            bundle.computeElementDirections();
        } else if (actionCommand == "Add elements near fibres ...") {
            addElementsNearFibres(bundle);
        } else if (actionCommand == "Delete elements") {
            deleteElements(bundle);
        }
    } else if (containsBundleAndFibres(selection)) {
        LinkedList<Muscle> fibres = new LinkedList<Muscle>();
        bundle = null;
        for (ModelComponent c : selection) {
            if (bundle == null && c instanceof MuscleBundle) {
                bundle = (MuscleBundle) c;
            } else if (c instanceof Muscle) {
                fibres.add((Muscle) c);
            } else {
                throw new InternalErrorException("Unexepected item in selection list: " + c.getClass());
            }
        }
        MoveFibresCommand command = new MoveFibresCommand("move Muscles", bundle, fibres);
        myMain.getUndoManager().saveStateAndExecute(command);
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) InternalErrorException(maspack.util.InternalErrorException) LinkedList(java.util.LinkedList)

Example 3 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class MuscleBundleEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    MuscleBundle bundle;
    if ((bundle = getEditableBundle(selection)) != null) {
        actions.add(this, "Edit fibres ...", EXCLUSIVE);
        actions.add(this, "Edit elements ...", EXCLUSIVE);
        if (bundle.getFibres().size() > 0) {
            actions.add(this, "Compute element directions");
            actions.add(this, "Add elements near fibres ...");
            actions.add(this, "Delete elements");
        }
    } else if (containsBundleAndFibres(selection)) {
        actions.add(this, "Move fibres to bundle");
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle)

Example 4 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class MFreeMuscleModel method addFiberMeshBundle.

public MuscleBundle addFiberMeshBundle(double rad, PolylineMesh mesh) {
    MuscleBundle bundle = new MuscleBundle();
    addMuscleBundle(bundle);
    bundle.addFiberMeshElements(rad, mesh);
    return bundle;
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle)

Example 5 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class FemMuscleDemo method createMusclePanel.

public void createMusclePanel() {
    ControlPanel myControlPanel = new ControlPanel("options", "LiveUpdate");
    FemControlPanel.addMuscleControls(myControlPanel, tissue, myModel);
    myControlPanel.addWidget(tissue, "profile");
    ComponentList<MuscleBundle> muscles = ((FemMuscleModel) tissue).getMuscleBundles();
    for (int i = 0; i < muscles.size(); ++i) {
        DoubleFieldSlider slider = (DoubleFieldSlider) myControlPanel.addWidget("activation [N per Muscle]", this, "models/FemBeam/models/fem/bundles/" + i + ":excitation", 0, 1);
        slider.setRoundingTolerance(0.00001);
        slider.getLabel().setForeground(getMuscleColor(i));
        BooleanSelector checkBox = (BooleanSelector) PropertyWidget.create("", muscles.get(i), "renderProps.visible");
        checkBox.addValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent e) {
                rerender();
            }
        });
        slider.add(checkBox);
    }
    for (int i = 0; i < muscles.size(); ++i) {
        BooleanSelector selector = (BooleanSelector) myControlPanel.addWidget("fibres active", this, "models/FemBeam/models/fem/bundles/" + i + ":fibresActive");
        selector.getLabel().setForeground(getMuscleColor(i));
        BooleanSelector checkBox = (BooleanSelector) PropertyWidget.create("", muscles.get(i).getFibres(), "renderProps.visible");
        checkBox.addValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent e) {
                rerender();
            }
        });
        selector.add(checkBox);
    }
    addControlPanel(myControlPanel);
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) BooleanSelector(maspack.widgets.BooleanSelector) ControlPanel(artisynth.core.gui.ControlPanel) FemControlPanel(artisynth.core.gui.FemControlPanel) FemMuscleModel(artisynth.core.femmodels.FemMuscleModel) Point(artisynth.core.mechmodels.Point) DoubleFieldSlider(maspack.widgets.DoubleFieldSlider)

Aggregations

MuscleBundle (artisynth.core.femmodels.MuscleBundle)25 Muscle (artisynth.core.mechmodels.Muscle)6 FemElement3d (artisynth.core.femmodels.FemElement3d)4 ConstantAxialMuscle (artisynth.core.materials.ConstantAxialMuscle)4 Point3d (maspack.matrix.Point3d)4 FemMuscleModel (artisynth.core.femmodels.FemMuscleModel)3 Point (artisynth.core.mechmodels.Point)3 Color (java.awt.Color)3 DoubleFieldSlider (maspack.widgets.DoubleFieldSlider)3 TrackingController (artisynth.core.inverse.TrackingController)2 SimpleForceMuscle (artisynth.core.materials.SimpleForceMuscle)2 MuscleExciter (artisynth.core.mechmodels.MuscleExciter)2 Point (java.awt.Point)2 LinkedList (java.util.LinkedList)2 RenderProps (maspack.render.RenderProps)2 FemMarker (artisynth.core.femmodels.FemMarker)1 FemMeshComp (artisynth.core.femmodels.FemMeshComp)1 FemNode (artisynth.core.femmodels.FemNode)1 FemNode3d (artisynth.core.femmodels.FemNode3d)1 MuscleElementDesc (artisynth.core.femmodels.MuscleElementDesc)1