void leaveCB(Widget w, XtPointer client_data, XtPointer calld)
{
    double *datap;
    String **cells;
    char buf[128];
    EditPoints *ep = (EditPoints *) client_data;
    XbaeMatrixLeaveCellCallbackStruct *cs =
    	    (XbaeMatrixLeaveCellCallbackStruct *) calld;
    XtVaGetValues(w, XmNcells, &cells, NULL);
    datap = getcol(ep->gno, ep->setno, cs->column);
    sprintf(buf, scformat[(ep->cformat[cs->column])], ep->cprec[cs->column],
    	    datap[cs->row]);
    if (strcmp(buf, cs->value) != 0) {
	String s = (String) XtMalloc(sizeof(char) * (strlen(buf) + 1));
	strcpy(s, buf);
	cells[cs->row][cs->column] = s;
	datap[cs->row] = atof(cs->value);
	updatesetminmax(ep->gno, ep->setno);
	update_set_status(ep->gno, ep->setno);
	drawgraph();
    }
}
Exemple #2
0
static void eblock_accept_notify_proc(Widget, XtPointer, XtPointer)
{
    int i = 0;
    char buf[256];
    int setno, graphno;
    int cx, cy, c1 = 0, c2 = 0, c3 = 0, c4 = 0; //d1,
    double *tx, *ty, *t2, *t3, *t4, *t5;

    //d1 = (int) GetChoice(eblock_type_choice_item);
    cx = (int)GetChoice(eblock_x_choice_item) - 1;
    cy = (int)GetChoice(eblock_y_choice_item);
    if (cx >= 0 && cx >= blockncols)
    {
        errwin("Column for X exceeds the number of columns in block data");
        return;
    }
    if (cy >= blockncols)
    {
        errwin("Column for Y exceeds the number of columns in block data");
        return;
    }
    switch (block_curtype)
    {
    case XY:
        break;
    case XYRT:
    case XYDX:
    case XYDY:
    case XYZ:
        c1 = (int)GetChoice(eblock_e1_choice_item);
        if (c1 >= blockncols)
        {
            errwin("Column for E1 exceeds the number of columns in block data");
            return;
        }
        break;
    case XYDXDX:
    case XYDYDY:
    case XYDXDY:
        c1 = (int)GetChoice(eblock_e1_choice_item);
        c2 = (int)GetChoice(eblock_e2_choice_item);
        if (c1 >= blockncols)
        {
            errwin("Column for E1 exceeds the number of columns in block data");
            return;
        }
        if (c2 >= blockncols)
        {
            errwin("Column for E2 exceeds the number of columns in block data");
            return;
        }
        break;
    case XYHILO:
    case XYBOX:
        c1 = (int)GetChoice(eblock_e1_choice_item);
        c2 = (int)GetChoice(eblock_e2_choice_item);
        c3 = (int)GetChoice(eblock_e3_choice_item);
        if (c1 >= blockncols)
        {
            errwin("Column for E1 exceeds the number of columns in block data");
            return;
        }
        if (c2 >= blockncols)
        {
            errwin("Column for E2 exceeds the number of columns in block data");
            return;
        }
        if (c3 >= blockncols)
        {
            errwin("Column for E3 exceeds the number of columns in block data");
            return;
        }
        break;
    case XYBOXPLOT:
        c1 = (int)GetChoice(eblock_e1_choice_item);
        c2 = (int)GetChoice(eblock_e2_choice_item);
        c3 = (int)GetChoice(eblock_e3_choice_item);
        c4 = (int)GetChoice(eblock_e4_choice_item);
        if (c1 >= blockncols)
        {
            errwin("Column for E1 exceeds the number of columns in block data");
            return;
        }
        if (c2 >= blockncols)
        {
            errwin("Column for E2 exceeds the number of columns in block data");
            return;
        }
        if (c3 >= blockncols)
        {
            errwin("Column for E3 exceeds the number of columns in block data");
            return;
        }
        if (c4 >= blockncols)
        {
            errwin("Column for E4 exceeds the number of columns in block data");
            return;
        }
    }
    setno = -1;
    graphno = (int)GetChoice(eblock_graph_choice_item) - 1;

    if (graphno == -1)
    {
        graphno = cg;
    }
    if (setno == -1)
    {
        setno = nextset(graphno);
    }
    if (setno == -1)
    {
        return;
    }
    if (g[graphno].active == OFF)
    {
        set_graph_active(graphno);
    }
    activateset(graphno, setno);
    settype(graphno, setno, block_curtype);

    tx = (double *)calloc(blocklen, sizeof(double));
    if (tx == NULL)
    {
        errwin("Can't allocate memory for X");
        return;
    }
    ty = (double *)calloc(blocklen, sizeof(double));
    if (ty == NULL)
    {
        cfree(tx);
        errwin("Can't allocate memory for Y");
        return;
    }
    for (i = 0; i < blocklen; i++)
    {
        if (cx == -1)
        {
            tx[i] = i + 1;
        }
        else
        {
            tx[i] = blockdata[cx][i];
        }
        ty[i] = blockdata[cy][i];
    }
    setcol(graphno, tx, setno, blocklen, 0);
    setcol(graphno, ty, setno, blocklen, 1);

    switch (block_curtype)
    {
    case XY:
        sprintf(buf, "Cols %d %d", cx + 1, cy + 1);
        break;
    case XYRT:
    case XYDX:
    case XYDY:
    case XYZ:
        sprintf(buf, "Cols %d %d %d", cx + 1, cy + 1, c1 + 1);
        t2 = (double *)calloc(blocklen, sizeof(double));
        for (i = 0; i < blocklen; i++)
        {
            t2[i] = blockdata[c1][i];
        }
        setcol(graphno, t2, setno, blocklen, 2);
        break;
    case XYDXDX:
    case XYDYDY:
    case XYDXDY:
        sprintf(buf, "Cols %d %d %d %d", cx + 1, cy + 1, c1 + 1, c2 + 1);
        t2 = (double *)calloc(blocklen, sizeof(double));
        t3 = (double *)calloc(blocklen, sizeof(double));
        for (i = 0; i < blocklen; i++)
        {
            t2[i] = blockdata[c1][i];
            t3[i] = blockdata[c2][i];
        }
        setcol(graphno, t2, setno, blocklen, 2);
        setcol(graphno, t3, setno, blocklen, 3);
        break;
    case XYHILO:
    case XYBOX:
        sprintf(buf, "Cols %d %d %d %d %d", cx + 1, cy + 1, c1 + 1, c2 + 1, c3 + 1);
        t2 = (double *)calloc(blocklen, sizeof(double));
        t3 = (double *)calloc(blocklen, sizeof(double));
        t4 = (double *)calloc(blocklen, sizeof(double));
        for (i = 0; i < blocklen; i++)
        {
            t2[i] = blockdata[c1][i];
            t3[i] = blockdata[c2][i];
            t4[i] = blockdata[c3][i];
        }
        setcol(graphno, t2, setno, blocklen, 2);
        setcol(graphno, t3, setno, blocklen, 3);
        setcol(graphno, t4, setno, blocklen, 4);
        break;
    case XYBOXPLOT:
        sprintf(buf, "Cols %d %d %d %d %d %d", cx + 1, cy + 1, c1 + 1, c2 + 1, c3 + 1, c4 + 1);
        t2 = (double *)calloc(blocklen, sizeof(double));
        t3 = (double *)calloc(blocklen, sizeof(double));
        t4 = (double *)calloc(blocklen, sizeof(double));
        t5 = (double *)calloc(blocklen, sizeof(double));
        for (i = 0; i < blocklen; i++)
        {
            t2[i] = blockdata[c1][i];
            t3[i] = blockdata[c2][i];
            t4[i] = blockdata[c3][i];
            t5[i] = blockdata[c4][i];
        }
        setcol(graphno, t2, setno, blocklen, 2);
        setcol(graphno, t3, setno, blocklen, 3);
        setcol(graphno, t4, setno, blocklen, 4);
        setcol(graphno, t5, setno, blocklen, 5);
        break;
    }

    setcomment(graphno, setno, buf);
    updatesetminmax(graphno, setno);
    update_status_popup(NULL, NULL, NULL);
    drawgraph();
}
Exemple #3
0
void flipxy(int gno)
{
    int i, j;
    tickmarks t;
    double *x, *y;

    for (i = 0; i < MAXAXES; i += 2)
    {
        memcpy(&t, &g[gno].t[i], sizeof(tickmarks));
        memcpy(&g[gno].t[i], &g[gno].t[i + 1], sizeof(tickmarks));
        memcpy(&g[gno].t[i + 1], &t, sizeof(tickmarks));
        if (g[gno].t[i].t_op == RIGHT)
        {
            g[gno].t[i].t_op = TOP;
        }
        else if (g[gno].t[i].t_op == LEFT)
        {
            g[gno].t[i].t_op = BOTTOM;
        }
        if (g[gno].t[i].tl_op == RIGHT)
        {
            g[gno].t[i].tl_op = TOP;
        }
        else if (g[gno].t[i].tl_op == LEFT)
        {
            g[gno].t[i].tl_op = BOTTOM;
        }
        if (g[gno].t[i + 1].t_op == TOP)
        {
            g[gno].t[i + 1].t_op = RIGHT;
        }
        else if (g[gno].t[i + 1].t_op == BOTTOM)
        {
            g[gno].t[i + 1].t_op = LEFT;
        }
        if (g[gno].t[i + 1].tl_op == TOP)
        {
            g[gno].t[i + 1].tl_op = RIGHT;
        }
        else if (g[gno].t[i + 1].tl_op == BOTTOM)
        {
            g[gno].t[i + 1].tl_op = LEFT;
        }
    }
    if (g[gno].type == LOGX)
    {
        g[gno].type = LOGY;
    }
    else if (g[gno].type == LOGY)
    {
        g[gno].type = LOGX;
    }
    fswap(&g[gno].w.xg1, &g[gno].w.yg1);
    fswap(&g[gno].w.xg2, &g[gno].w.yg2);
    fswap(&g[gno].dsx, &g[gno].dsy);
    iswap(&g[gno].fx, &g[gno].fy);
    iswap(&g[gno].px, &g[gno].py);
    for (i = 0; i < g[gno].maxplot; i++)
    {
        if (isactive(gno, i))
        {
            x = getx(gno, i); /* TODO really need to just swap pointers */
            y = gety(gno, i);
            for (j = 0; j < getsetlength(gno, i); j++)
            {
                fswap(&x[j], &y[j]);
            }
            updatesetminmax(gno, i);
        }
    }
    update_all(gno);
}