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