Search in sources :

Example 1 with PlotTraceInfo

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

the class NumericProbePanel method swapDrawIndicies.

public void swapDrawIndicies(int a, int b) {
    PlotTraceInfo ptiA = myProbe.getPlotTraceInfo(a);
    PlotTraceInfo ptiB = myProbe.getPlotTraceInfo(b);
    myProbe.swapPlotTraceOrder(ptiA, ptiB);
}
Also used : PlotTraceInfo(artisynth.core.probes.PlotTraceInfo)

Example 2 with PlotTraceInfo

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

the class NumericProbePanel method drawKnots.

private void drawKnots(Graphics g) {
    if (drawKnotsP) {
        double timePerPixel = (maxXRange - minXRange) / getWidth();
        double yFactor = 1.0 / yValuePerPixel;
        NumericList list = myProbe.getNumericList();
        Iterator<NumericListKnot> it = list.iterator();
        // used only if we are not working in virtual time
        double probeScale = myProbe.getScale();
        double probeStartTime = myProbe.getStartTime();
        while (it.hasNext()) {
            NumericListKnot knot = it.next();
            double t = knot.t;
            if (!useVirtualTime) {
                // convert t to timeline time
                t = t * probeScale + probeStartTime;
            }
            int x = (int) ((t - minXRange) / timePerPixel);
            for (int v = knot.v.size() - 1; v >= 0; v--) {
                int idx = myProbe.getOrderedTraceIndex(v);
                PlotTraceInfo pti = myProbe.getPlotTraceInfo(idx);
                if (pti.isVisible()) {
                    g.setColor(pti.getColor());
                    double y = -(knot.v.get(idx) - maxYRange) * yFactor;
                    if (largeDisplay)
                        g.fillOval(x - 4, (int) y - 4, 8, 8);
                    else
                        g.fillRect(x - 2, (int) y - 2, 5, 5);
                }
            }
        }
    }
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot) NumericList(maspack.interpolation.NumericList) Point(java.awt.Point) PlotTraceInfo(artisynth.core.probes.PlotTraceInfo)

Example 3 with PlotTraceInfo

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

the class NumericProbePanel method drawPlotLines.

private void drawPlotLines(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    NumericList list = myProbe.getNumericList();
    if (list != null) {
        int numXPixels = this.getWidth();
        NumericListKnot tempKnot;
        int yVectorSize = 0;
        int[] xInterpolationBuffer = null;
        int[][] yInterpolationBuffer = null;
        tempKnot = null;
        // Fix by Ian for interpolation before 1st knot point
        yVectorSize = list.getVectorSize();
        // VectorNd yVector = new VectorNd(yVectorSize);
        yVector.setSize(yVectorSize);
        xInterpolationBuffer = new int[numXPixels];
        yInterpolationBuffer = new int[yVectorSize][numXPixels + 1];
        double timePerPixel = (maxXRange - minXRange) / getWidth();
        tempKnot = null;
        double t;
        // used only if we are not working in virtual time
        double probeScale = myProbe.getScale();
        double probeStartTime = myProbe.getStartTime();
        // Create line plot
        for (int index = 0; index < numXPixels; index++) {
            t = minXRange + timePerPixel * index;
            if (!useVirtualTime) {
                // convert t back to virtual time
                t = (t - probeStartTime) / probeScale;
            }
            // we have to offset the time increment by the minimum x range
            // because we are not starting from zero
            tempKnot = list.interpolate(yVector, t, myProbe.getInterpolation(), tempKnot);
            xInterpolationBuffer[index] = index;
            for (int k = 0; k < yVectorSize; k++) {
                if (k < yVector.size()) {
                    yInterpolationBuffer[k][index] = (int) -((yVector.get(k) - maxYRange) / yValuePerPixel);
                }
            }
        }
        if (largeDisplay) {
            g2.setStroke(new BasicStroke(2));
        }
        // Draw line plot
        for (int k = yVectorSize - 1; k >= 0; k--) {
            int idx = myProbe.getOrderedTraceIndex(k);
            PlotTraceInfo pti = myProbe.getPlotTraceInfo(idx);
            if (pti.isVisible()) {
                g2.setColor(pti.getColor());
                g2.drawPolyline(xInterpolationBuffer, yInterpolationBuffer[idx], numXPixels);
            }
        }
    }
    myLastInterpolationOrder = myProbe.getInterpolationOrder();
}
Also used : BasicStroke(java.awt.BasicStroke) NumericListKnot(maspack.interpolation.NumericListKnot) NumericList(maspack.interpolation.NumericList) Point(java.awt.Point) Graphics2D(java.awt.Graphics2D) PlotTraceInfo(artisynth.core.probes.PlotTraceInfo)

Aggregations

PlotTraceInfo (artisynth.core.probes.PlotTraceInfo)3 Point (java.awt.Point)2 NumericList (maspack.interpolation.NumericList)2 NumericListKnot (maspack.interpolation.NumericListKnot)2 BasicStroke (java.awt.BasicStroke)1 Graphics2D (java.awt.Graphics2D)1