Search in sources :

Example 1 with ExcitationComponent

use of artisynth.core.mechmodels.ExcitationComponent in project artisynth_core by artisynth.

the class ExcitationTargetAgent method selectionChanged.

public void selectionChanged(SelectionEvent e) {
    ModelComponent c = e.getLastAddedComponent();
    if (isValidTarget(c)) {
        ExcitationComponent ex = (ExcitationComponent) c;
        if (myState == State.SelectingExciters && ex != myExciter && myExciter.findTarget(ex) == -1) {
            myExciter.addTarget(ex, 1.0);
            DoubleField widget = createTargetWidget(ex, 1.0);
            myTargetPanel.addWidget(widget);
            myTargetPanel.mapWidgetToComponent(widget, ex);
            myTargetPanel.revalidate();
            myTargetPanel.repaint();
        }
    // else if (myExciter.findTarget(ex) != -1)
    // { mySelectedTargets.add (ex);
    // }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) ExcitationComponent(artisynth.core.mechmodels.ExcitationComponent) DoubleField(maspack.widgets.DoubleField)

Example 2 with ExcitationComponent

use of artisynth.core.mechmodels.ExcitationComponent in project artisynth_core by artisynth.

the class TrackingController method dispose.

/**
 * Clears all terms and disposes storage
 */
public void dispose() {
    System.out.println("tracking controller dispose()");
    myMotionTerm = null;
    myRegularizationTerm = null;
    myBoundsTerm = null;
    myCostFunction.dispose();
    targetPoints.clear();
    remove(targetPoints);
    targetFrames.clear();
    remove(targetFrames);
    sourcePoints.clear();
    remove(sourcePoints);
    sourceFrames.clear();
    remove(sourceFrames);
    if (useMyExciters) {
        myExciters.removeAllTargets();
        remove(myExciters);
    } else {
        for (@SuppressWarnings("unused") ExcitationComponent excCom : exciters) {
        }
        exciters.clear();
        remove(exciters);
    }
    excitationRegularizationWeights = null;
    upperExcitationBounds.clear();
    lowerExcitationBounds.clear();
}
Also used : ExcitationComponent(artisynth.core.mechmodels.ExcitationComponent)

Example 3 with ExcitationComponent

use of artisynth.core.mechmodels.ExcitationComponent in project artisynth_core by artisynth.

the class ExcitationTargetAgent method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd.equals("Add")) {
        mySelectionManager.clearSelections();
        myMain.rerender();
        setState(State.SelectingExciters);
    } else if (cmd.equals("Stop")) {
        mySelectionManager.clearSelections();
        setState(State.Complete);
        myMain.rerender();
    } else if (cmd.equals("remove target")) {
        JComponent[] widgets = myTargetPanel.getSelectedWidgets();
        for (int i = 0; i < widgets.length; i++) {
            ExcitationComponent target = (ExcitationComponent) myTargetPanel.getComponent(widgets[i]);
            myExciter.removeTarget(target);
            myTargetPanel.removeWidget(widgets[i]);
        }
        myTargetPanel.revalidate();
        myTargetPanel.repaint();
    } else {
        super.actionPerformed(e);
    }
}
Also used : JComponent(javax.swing.JComponent) ExcitationComponent(artisynth.core.mechmodels.ExcitationComponent)

Example 4 with ExcitationComponent

use of artisynth.core.mechmodels.ExcitationComponent 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

ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)4 ModelComponent (artisynth.core.modelbase.ModelComponent)2 MuscleBundle (artisynth.core.femmodels.MuscleBundle)1 TrackingController (artisynth.core.inverse.TrackingController)1 Color (java.awt.Color)1 JComponent (javax.swing.JComponent)1 DoubleField (maspack.widgets.DoubleField)1