Search in sources :

Example 6 with TracingProbe

use of artisynth.core.probes.TracingProbe in project artisynth_core by artisynth.

the class TracingProbePanel method getPrototypeProbe.

protected TracingProbe getPrototypeProbe(String traceableName) {
    TracingProbe tmpProbe = TracingProbe.create(myTraceable, traceableName);
    Class<?> type = tmpProbe.getClass();
    TracingProbe comp = myPrototypeMap.get(type);
    if (comp == null) {
        // look for prototype as the last instance in the
        // container
        RootModel root = myMain.getRootModel();
        for (Probe probe : root.getOutputProbes()) {
            if (type.isAssignableFrom(probe.getClass())) {
                comp = (TracingProbe) probe;
            }
        }
        if (comp == null || !(comp instanceof CopyableComponent)) {
            comp = tmpProbe;
            // try {
            // comp = (TracingProbe)type.newInstance();
            // }
            // catch (Exception e) {
            // throw new InternalErrorException (
            // "cannot create no-args instance of " + type);
            // }
            initializePrototype(comp);
        } else {
            comp = (TracingProbe) ((CopyableComponent) comp).copy(0, null);
        }
        myPrototypeMap.put(type, comp);
    }
    return comp;
}
Also used : RootModel(artisynth.core.workspace.RootModel) CopyableComponent(artisynth.core.modelbase.CopyableComponent) TracingProbe(artisynth.core.probes.TracingProbe) TracingProbe(artisynth.core.probes.TracingProbe) Probe(artisynth.core.probes.Probe)

Example 7 with TracingProbe

use of artisynth.core.probes.TracingProbe in project artisynth_core by artisynth.

the class SelectionPopup method addTracing.

private void addTracing(LinkedList<ModelComponent> selectedItems) {
    // RootModel root = myMain.getRootModel();
    // String name = null;
    // double startTime = myMain.getTimeSec();
    // double updateInterval = root.getMaxStepSizeSec();
    Traceable firstTraceable = null;
    for (ModelComponent comp : selectedItems) {
        if (comp instanceof Traceable) {
            firstTraceable = (Traceable) comp;
        }
    }
    if (firstTraceable == null) {
        throw new InternalErrorException("'Add tracing' called with no traceabled in selection");
    }
    TracingProbePanel panel = new TracingProbePanel(firstTraceable, getCommonTraceables(selectedItems));
    panel.pack();
    GuiUtils.locateRelative(panel, myLastBounds, 0.5, 0.5, 0, 0.5);
    // if (myTraceItemLoc != null)
    // { panel.setLocation (
    // myTraceItemLoc.x, myTraceItemLoc.y);
    // }
    panel.setVisible(true);
    if (panel.getReturnValue() == OptionPanel.OK_OPTION) {
        for (ModelComponent comp : selectedItems) {
            if (comp instanceof Traceable) {
                TracingProbe probe = panel.createProbe((Traceable) comp);
                myMain.getRootModel().addOutputProbe(probe);
            }
        }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) TracingProbePanel(artisynth.core.gui.editorManager.TracingProbePanel) InternalErrorException(maspack.util.InternalErrorException) TracingProbe(artisynth.core.probes.TracingProbe) Traceable(artisynth.core.modelbase.Traceable)

Example 8 with TracingProbe

use of artisynth.core.probes.TracingProbe in project artisynth_core by artisynth.

the class RootModel method clearTracing.

public void clearTracing(Traceable tr) {
    TracingProbe tp = getTracingProbe(tr, "position");
    if (tp != null) {
        tp.getNumericList().clear();
        tp.setData(tp.getStartTime());
        tp.setData(tp.getStopTime());
        rerender();
    }
}
Also used : TracingProbe(artisynth.core.probes.TracingProbe)

Example 9 with TracingProbe

use of artisynth.core.probes.TracingProbe in project artisynth_core by artisynth.

the class RootModel method disableTracing.

public boolean disableTracing(Traceable tr) {
    TracingProbe tp = getTracingProbe(tr, "position");
    if (tp != null) {
        removeOutputProbe(tp);
        rerender();
        return true;
    } else {
        return false;
    }
}
Also used : TracingProbe(artisynth.core.probes.TracingProbe)

Example 10 with TracingProbe

use of artisynth.core.probes.TracingProbe in project artisynth_core by artisynth.

the class RootModel method clearTraces.

public void clearTraces() {
    Collection<TracingProbe> tprobes = getTracingProbes();
    for (TracingProbe tp : tprobes) {
        tp.getNumericList().clear();
        tp.setData(tp.getStartTime());
        tp.setData(tp.getStopTime());
    }
    rerender();
}
Also used : TracingProbe(artisynth.core.probes.TracingProbe)

Aggregations

TracingProbe (artisynth.core.probes.TracingProbe)10 Traceable (artisynth.core.modelbase.Traceable)2 Probe (artisynth.core.probes.Probe)2 RootModel (artisynth.core.workspace.RootModel)2 TracingProbePanel (artisynth.core.gui.editorManager.TracingProbePanel)1 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)1 CopyableComponent (artisynth.core.modelbase.CopyableComponent)1 ModelComponent (artisynth.core.modelbase.ModelComponent)1 JMenuItem (javax.swing.JMenuItem)1 JSeparator (javax.swing.JSeparator)1 InternalErrorException (maspack.util.InternalErrorException)1