Esempio n. 1
0
File: graf.c Progetto: imr/ngspice
/* redraw everything in struct graph */
void
gr_redraw(GRAPH *graph)
{
    struct dveclist *link;

    /* establish current graph so default graphic calls will work right */
    PushGraphContext(graph);

    DevClear();

    /* redraw grid */
    gr_redrawgrid(graph);

    cur.plotno = 0;
    for (link = graph->plotdata; link; link = link->next) {
        /* redraw legend */
        drawlegend(graph, cur.plotno++, link->vector);

        /* replot data
           if onevalue, pass it a NULL scale
           otherwise, if vec has its own scale, pass that
           else pass vec's plot's scale
        */
        ft_graf(link->vector,
                graph->onevalue ? NULL :
                (link->vector->v_scale ?
                 link->vector->v_scale :
                 link->vector->v_plot->pl_scale),
                TRUE);
    }

    gr_restoretext(graph);

    PopGraphContext();
}
Esempio n. 2
0
static void
gr_start_internal(struct dvec *dv, bool copyvec)
{
    struct dveclist *link;

    /* Do something special with poles and zeros.  Poles are 'x's, and
     * zeros are 'o's.  */
    if (dv->v_type == SV_POLE) {
        dv->v_linestyle = 'x';
        return;
    } else if (dv->v_type == SV_ZERO) {
        dv->v_linestyle = 'o';
        return;
    }

    /* Find a (hopefully) new line style and color. */
    if (currentgraph->plottype == PLOT_POINT) {
        if (pointchars[cur.linestyle - 1])
            cur.linestyle++;
        else
            cur.linestyle = 2;
    } else if ((cur.linestyle > 0) && (++cur.linestyle == dispdev->numlinestyles)) {
        cur.linestyle = 2;
    }

    if ((cur.color > 0) && (++cur.color == dispdev->numcolors))
        cur.color = (((currentgraph->grid.gridtype == GRID_SMITH ||
                      currentgraph->grid.gridtype == GRID_SMITHGRID) &&
                     (dispdev->numcolors > 3)) ? 4 : 2);

    if (currentgraph->plottype == PLOT_POINT)
        dv->v_linestyle = pointchars[cur.linestyle - 2];
    else
        dv->v_linestyle = cur.linestyle;

    dv->v_color = cur.color;

    /* save the data so we can refresh */
    link = TMALLOC(struct dveclist, 1);
    link->next = currentgraph->plotdata;

    if (copyvec) {
        link->vector = vec_copy(dv);
        /* vec_copy doesn't set v_color or v_linestyle */
        link->vector->v_color = dv->v_color;
        link->vector->v_linestyle = dv->v_linestyle;
        link->vector->v_flags |= VF_PERMANENT;
    } else {
        link->vector = dv;
    }

    currentgraph->plotdata = link;

    /* Put the legend entry on the screen. */
    drawlegend(currentgraph, cur.plotno, dv);

    cur.plotno++;
}