diff --git a/src/callback.c b/src/callback.c index a4b9a3b4..8a0028e4 100644 --- a/src/callback.c +++ b/src/callback.c @@ -184,7 +184,6 @@ void start_wire(double mx, double my) static int waves_callback(int event, int mx, int my, KeySym key, int button, int aux, int state) { Graph_ctx *gr; - char s[30]; const char *val; int i, need_all_redraw = 0, need_redraw = 0, dataset = 0; double xx1, xx2, yy1, yy2; @@ -248,9 +247,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } else if(event == -3 && button == Button1) { if(!edit_wave_attributes(1, i, gr)) { - char s[30]; - my_snprintf(s, S(s), "%d", i); - tclvareval("graph_edit_properties ", s, NULL); + tclvareval("graph_edit_properties ", itoa(i), NULL); } } /* x cursor1 toggle */ @@ -367,10 +364,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int if(fabs(xctx->my_double_save - xctx->mousey_snap) > fabs(gr->dcy * delta) * delta_threshold) { yy1 = gr->ypos1 + (xctx->my_double_save - xctx->mousey_snap) / gr->dcy; yy2 = gr->ypos2 + (xctx->my_double_save - xctx->mousey_snap) / gr->dcy; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1424, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1425, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", s)); + my_strdup(1424, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", dtoa(yy1))); + my_strdup(1425, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", dtoa(yy2))); xctx->my_double_save = xctx->mousey_snap; need_redraw = 1; } @@ -380,10 +375,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int if(fabs(xctx->my_double_save - xctx->mousey_snap) > fabs(gr->cy * delta) * delta_threshold) { yy1 = gr->gy1 + (xctx->my_double_save - xctx->mousey_snap) / gr->cy; yy2 = gr->gy2 + (xctx->my_double_save - xctx->mousey_snap) / gr->cy; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1435, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1437, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1435, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1437, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); xctx->my_double_save = xctx->mousey_snap; need_redraw = 1; } @@ -397,10 +390,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int if(fabs(xctx->mx_double_save - xctx->mousex_snap) > fabs(gr->cx * delta) * delta_threshold) { xx1 = gr->gx1 + (xctx->mx_double_save - xctx->mousex_snap) / gr->cx; xx2 = gr->gx2 + (xctx->mx_double_save - xctx->mousex_snap) / gr->cx; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1410, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1411, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1410, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1411, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -414,20 +405,16 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int delta = gr->posh * 0.05; yy1 = gr->ypos1 + delta; yy2 = gr->ypos2 + delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1456, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1457, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", s)); + my_strdup(1456, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", dtoa(yy1))); + my_strdup(1457, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", dtoa(yy2))); need_redraw = 1; } else { delta = gr->gh/ gr->divy; delta_threshold = 1.0; yy1 = gr->gy1 + delta * delta_threshold; yy2 = gr->gy2 + delta * delta_threshold; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1420, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1421, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1420, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1421, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); need_redraw = 1; } } @@ -437,10 +424,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int delta_threshold = 0.05; xx1 = gr->gx1 - delta * delta_threshold; xx2 =gr->gx2 - delta * delta_threshold; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1428, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1429, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1428, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1429, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -456,10 +441,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = delta * 0.2; yy2 = gr->gy2 + var * b / delta; yy1 = gr->gy1 - var * a / delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1451, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1448, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1451, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1448, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); need_redraw = 1; } } else { @@ -467,10 +450,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int delta_threshold = 0.05; xx1 = gr->gx1 - delta * delta_threshold; xx2 = gr->gx2 - delta * delta_threshold; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1395, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1396, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1395, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1396, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -482,20 +463,16 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int delta = gr->posh * 0.05; yy1 = gr->ypos1 - delta; yy2 = gr->ypos2 - delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1416, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1417, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", s)); + my_strdup(1416, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", dtoa(yy1))); + my_strdup(1417, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", dtoa(yy2))); need_redraw = 1; } else { delta = gr->gh / gr->divy; delta_threshold = 1.0; yy1 = gr->gy1 - delta * delta_threshold; yy2 = gr->gy2 - delta * delta_threshold; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1458, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1434, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1458, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1434, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); need_redraw = 1; } } @@ -505,10 +482,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int delta_threshold = 0.05; xx1 = gr->gx1 + delta * delta_threshold; xx2 = gr->gx2 + delta * delta_threshold; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1397, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1398, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1397, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1398, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -524,10 +499,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = delta * 0.2; yy2 = gr->gy2 - var * b / delta; yy1 = gr->gy1 + var * a / delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1433, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1439, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1433, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1439, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); need_redraw = 1; } } else { @@ -535,10 +508,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int delta_threshold = 0.05; xx1 = gr->gx1 + delta * delta_threshold; xx2 = gr->gx2 + delta * delta_threshold; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1430, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1431, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1430, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1431, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -553,10 +524,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = delta * 0.05; yy2 = gr->ypos2 + var * b / delta; yy1 = gr->ypos1 - var * a / delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1461, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1459, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", s)); + my_strdup(1461, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", dtoa(yy1))); + my_strdup(1459, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", dtoa(yy2))); need_redraw = 1; } else { @@ -567,10 +536,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = delta * 0.2; yy2 = gr->gy2 + var * b / delta; yy1 = gr->gy1 - var * a / delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1460, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1438, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1460, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1438, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); need_redraw = 1; } } @@ -579,10 +546,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = 0.2 * gr->gw; xx2 = gr->gx2 + var * (1 - zoom_m); xx1 = gr->gx1 - var * zoom_m; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1399, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1400, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1399, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1400, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -593,10 +558,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = 0.2 * gr->gw; xx2 = gr->gx2 + var * (1 - zoom_m); xx1 = gr->gx1 - var * zoom_m; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1418, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1432, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1418, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1432, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -612,10 +575,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = delta * 0.05; yy2 = gr->ypos2 - var * b / delta; yy1 = gr->ypos1 + var * a / delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1447, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1436, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", s)); + my_strdup(1447, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", dtoa(yy1))); + my_strdup(1436, &r->prop_ptr, subst_token(r->prop_ptr, "ypos2", dtoa(yy2))); need_redraw = 1; } else { double m = G_Y(xctx->mousey); @@ -625,10 +586,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = delta * 0.2; yy2 = gr->gy2 - var * b / delta; yy1 = gr->gy1 + var * a / delta; - my_snprintf(s, S(s), "%g", yy1); - my_strdup(1419, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", yy2); - my_strdup(1444, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1419, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(yy1))); + my_strdup(1444, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(yy2))); need_redraw = 1; } } @@ -637,10 +596,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = 0.2 * gr->gw; xx2 = gr->gx2 - var * (1 - zoom_m); xx1 = gr->gx1 + var * zoom_m; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1449, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1450, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1449, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1450, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -651,10 +608,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int double var = 0.2 * gr->gw; xx2 = gr->gx2 - var * (1 - zoom_m); xx1 = gr->gx1 + var * zoom_m; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1445, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1446, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1445, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1446, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -686,10 +641,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int min = floor_to_n_digits(min, 2); max = ceil_to_n_digits(max, 2); my_free(1427, &node); - my_snprintf(s, S(s), "%g", min); - my_strdup(1422, &r->prop_ptr, subst_token(r->prop_ptr, "y1", s)); - my_snprintf(s, S(s), "%g", max); - my_strdup(1423, &r->prop_ptr, subst_token(r->prop_ptr, "y2", s)); + my_strdup(1422, &r->prop_ptr, subst_token(r->prop_ptr, "y1", dtoa(min))); + my_strdup(1423, &r->prop_ptr, subst_token(r->prop_ptr, "y2", dtoa(max))); need_redraw = 1; } else { my_strdup(1497, &r->prop_ptr, subst_token(r->prop_ptr, "ypos1", @@ -703,10 +656,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int if(r->sel || !(r->flags & 2) || i == xctx->graph_master) { xx1 = get_raw_value(dataset, 0, 0); xx2 = get_raw_value(dataset, 0, xctx->graph_npoints[dataset] -1); - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1409, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1412, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1409, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1412, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -725,10 +676,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int p = (xctx->mousex_snap - ddx) / ccx; xx1 = p - delta / 2.0; xx2 = p + delta / 2.0; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1442, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1443, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1442, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1443, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -750,10 +699,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int xx2 = G_X(xctx->mousex_snap); if(xx2 < xx1) { tmp = xx1; xx1 = xx2; xx2 = tmp; } if(xx1 == xx2) xx2 += 1e-6; - my_snprintf(s, S(s), "%g", xx1); - my_strdup(1440, &r->prop_ptr, subst_token(r->prop_ptr, "x1", s)); - my_snprintf(s, S(s), "%g", xx2); - my_strdup(1441, &r->prop_ptr, subst_token(r->prop_ptr, "x2", s)); + my_strdup(1440, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(1441, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); need_redraw = 1; } } @@ -1719,15 +1666,12 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, char *tool_name = NULL; char str[200]; - - if(xctx->semaphore >= 2) break; - tcleval("winfo exists .graphdialog"); if(tclresult()[0] == '1') tool = XSCHEM_GRAPH; else if(xctx->graph_lastsel >=0 && - xctx->rects[2] > xctx->graph_lastsel && - xctx->rect[2][xctx->graph_lastsel].flags & 1) { + xctx->rects[GRIDLAYER] > xctx->graph_lastsel && + xctx->rect[GRIDLAYER][xctx->graph_lastsel].flags & 1) { tool = XSCHEM_GRAPH; } tcleval("info exists sim"); diff --git a/src/draw.c b/src/draw.c index f53dc13c..15845356 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1776,7 +1776,6 @@ static void draw_graph_grid(Graph_ctx *gr) { double deltax, startx, deltay, starty, wx,wy, dash_sizex, dash_sizey; int j, k; - char lab[30]; double mark_size = gr->marginy/10.0; /* calculate dash length for grid lines */ @@ -1813,8 +1812,7 @@ static void draw_graph_grid(Graph_ctx *gr) drawline(GRIDLAYER, ADD, W_X(wx), W_Y(gr->gy2), W_X(wx), W_Y(gr->gy1), dash_sizey); drawline(GRIDLAYER, ADD, W_X(wx), W_Y(gr->gy1), W_X(wx), W_Y(gr->gy1) + mark_size, 0); /* axis marks */ /* X-axis labels */ - my_snprintf(lab, S(lab), "%g", wx * gr->unitx); - draw_string(3, NOW, lab, 0, 0, 1, 0, W_X(wx), gr->y2 + mark_size + 5 * gr->txtsizex, + draw_string(3, NOW, dtoa(wx * gr->unitx), 0, 0, 1, 0, W_X(wx), gr->y2 + mark_size + 5 * gr->txtsizex, gr->txtsizex, gr->txtsizex); } /* first and last vertical box delimiters */ @@ -1837,8 +1835,7 @@ static void draw_graph_grid(Graph_ctx *gr) drawline(GRIDLAYER, ADD, W_X(gr->gx1), W_Y(wy), W_X(gr->gx2), W_Y(wy), dash_sizex); drawline(GRIDLAYER, ADD, W_X(gr->gx1) - mark_size, W_Y(wy), W_X(gr->gx1), W_Y(wy), 0); /* axis marks */ /* Y-axis labels */ - my_snprintf(lab, S(lab), "%g", wy * gr->unity); - draw_string(3, NOW, lab, 0, 1, 0, 1, gr->x1 - mark_size - 5 * gr->txtsizey, W_Y(wy), + draw_string(3, NOW, dtoa(wy * gr->unity), 0, 1, 0, 1, gr->x1 - mark_size - 5 * gr->txtsizey, W_Y(wy), gr->txtsizey, gr->txtsizey); } } @@ -2253,7 +2250,7 @@ int edit_wave_attributes(int what, int i, Graph_ctx *gr) double xt2 = gr->x1 - 20 * gr->txtsizelab; double s1 = DIG_NWAVES; /* 1/DIG_NWAVES waveforms fit in graph if unscaled vertically */ double s2 = DIG_SPACE; /* (DIG_NWAVES - DIG_SPACE) spacing between traces */ - double yt1 = s1 * (double)(n_nodes - wcnt) * gr->gh - (gr->gy1 - gr->gh * 0.1) * s2; + double yt1 = s1 * (double)(n_nodes - wcnt) * gr->gh - gr->gy1 * s2; double yt2 = yt1 + s1 * gr->gh; if(yt1 <= gr->ypos2 && yt1 >= gr->ypos1) { double tmp = DW_Y(yt1); diff --git a/src/editprop.c b/src/editprop.c index 475dcb48..e06722e9 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -261,6 +261,53 @@ size_t my_strdup2(int id, char **dest, const char *src) /* 20150409 duplicates a return 0; } +char *itoa(int i) +{ + static char s[30]; + my_snprintf(s, S(s), "%d", i); + return s; +} + +char *dtoa(double i) +{ + static char s[50]; + my_snprintf(s, S(s), "%g", i); + return s; +} + +size_t my_mstrcat(int id, char **str, const char *add, ...) +{ + va_list args; + const char *append_str; + size_t s, a; + + if(add == NULL) return 0; + s = 0; + if(*str != NULL) s = strlen(*str); + va_start(args, add); + append_str = add; + do { + if( *str != NULL) { + if(append_str[0]=='\0') continue; + a = strlen(append_str) + 1; + my_realloc(id, str, s + a ); + memcpy(*str + s, append_str, a); + s += a - 1; + dbg(3,"my_mstrcat(%d,): reallocated string %s\n", id, *str); + } else { + if(append_str[0] == '\0') continue; + a = strlen(append_str) + 1; + *str = my_malloc(id, a); + memcpy(*str, append_str, a); + dbg(3,"my_mstrcat(%d,): allocated string %s\n", id, *str); + s = a - 1; + } + append_str = va_arg(args, const char *); + } while(append_str); + va_end(args); + return s; +} + size_t my_strcat(int id, char **str, const char *append_str) { size_t s, a; @@ -1115,57 +1162,61 @@ void update_symbol(const char *result, int x) void change_elem_order(void) { - xInstance tmpinst; - xRect tmpbox; - xWire tmpwire; - char tmp_txt[50]; /* overflow safe */ - int c, new_n; + xInstance tmpinst; + xRect tmpbox; + xWire tmpwire; + char tmp_txt[50]; /* overflow safe */ + int c, new_n; - rebuild_selected_array(); - if(xctx->lastsel==1) + rebuild_selected_array(); + if(xctx->lastsel==1) + { + my_snprintf(tmp_txt, S(tmp_txt), "%d",xctx->sel_array[0].n); + tclsetvar("retval",tmp_txt); + xctx->semaphore++; + tcleval("text_line {Object Sequence number} 0"); + xctx->semaphore--; + if(strcmp(tclgetvar("rcode"),"") ) { - my_snprintf(tmp_txt, S(tmp_txt), "%d",xctx->sel_array[0].n); - tclsetvar("retval",tmp_txt); - xctx->semaphore++; - tcleval("text_line {Object Sequence number} 0"); - xctx->semaphore--; - if(strcmp(tclgetvar("rcode"),"") ) - { xctx->push_undo(); set_modify(1); xctx->prep_hash_inst=0; xctx->prep_net_structs=0; xctx->prep_hi_structs=0; - } - sscanf(tclgetvar("retval"), "%d",&new_n); + } + sscanf(tclgetvar("retval"), "%d",&new_n); - if(xctx->sel_array[0].type==ELEMENT) - { + if(xctx->sel_array[0].type==ELEMENT) + { if(new_n>=xctx->instances) new_n=xctx->instances-1; tmpinst=xctx->inst[new_n]; xctx->inst[new_n]=xctx->inst[xctx->sel_array[0].n]; xctx->inst[xctx->sel_array[0].n]=tmpinst; dbg(1, "change_elem_order(): selected element %d\n", xctx->sel_array[0].n); - } - else if(xctx->sel_array[0].type==xRECT) - { + } + else if(xctx->sel_array[0].type==xRECT) + { c=xctx->sel_array[0].col; if(new_n>=xctx->rects[c]) new_n=xctx->rects[c]-1; tmpbox=xctx->rect[c][new_n]; xctx->rect[c][new_n]=xctx->rect[c][xctx->sel_array[0].n]; xctx->rect[c][xctx->sel_array[0].n]=tmpbox; dbg(1, "change_elem_order(): selected element %d\n", xctx->sel_array[0].n); - } - else if(xctx->sel_array[0].type==WIRE) - { + if(c == GRIDLAYER) { + if(xctx->graph_lastsel == new_n) xctx->graph_lastsel = xctx->sel_array[0].n; + else if(xctx->graph_lastsel == xctx->sel_array[0].n) xctx->graph_lastsel = new_n; + } + } + else if(xctx->sel_array[0].type==WIRE) + { if(new_n>=xctx->wires) new_n=xctx->wires-1; tmpwire=xctx->wire[new_n]; xctx->wire[new_n]=xctx->wire[xctx->sel_array[0].n]; xctx->wire[xctx->sel_array[0].n]=tmpwire; dbg(1, "change_elem_order(): selected element %d\n", xctx->sel_array[0].n); - } - xctx->need_reb_sel_arr = 1; } + xctx->need_reb_sel_arr = 1; + } } /* x=0 use tcl text widget x=1 use vim editor x=2 only view data */ diff --git a/src/hilight.c b/src/hilight.c index 01b5f39e..302972fb 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -918,7 +918,7 @@ static void send_net_to_graph(char **s, int simtype, const char *node) c = get_color(xctx->hilight_color); expanded_tok = expandlabel(tok, &tok_mult); for(k=1; k<=tok_mult; k++) { - my_strdup(1498, &t, find_nth(expanded_tok, ',', k)); + my_strdup(1503, &t, find_nth(expanded_tok, ',', k)); my_strdup2(1499, &p, xctx->sch_path[xctx->currsch]+1); if(simtype == 0 ) { /* spice */ dbg(1, "%s%s color=%d\n", strtolower(p), strtolower(t), c); diff --git a/src/scheduler.c b/src/scheduler.c index 975d12d1..09e8c5d3 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -302,6 +302,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg { cmd_found = 1; unselect_all(); + xctx->graph_lastsel = xctx->rects[GRIDLAYER]; storeobject(-1, xctx->mousex_snap-400, xctx->mousey_snap-200, xctx->mousex_snap+400, xctx->mousey_snap+200, xRECT, GRIDLAYER, SELECTED, "flags=graph\n" @@ -796,9 +797,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg { cmd_found = 1; if(!strcmp(argv[2],"backlayer")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%d",BACKLAYER); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(BACKLAYER), TCL_VOLATILE); } else if(!strcmp(argv[2],"bbox_hilighted")) { xRect boundbox; @@ -815,14 +814,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, res, TCL_VOLATILE); } else if(!strcmp(argv[2],"cadlayers")) { - char s[30]; /* overflow safe 20161212 */ - my_snprintf(s, S(s), "%d", cadlayers); - Tcl_SetResult(interp, s, TCL_VOLATILE); + Tcl_SetResult(interp, itoa(cadlayers), TCL_VOLATILE); } else if(!strcmp(argv[2], "case_insensitive")) { - char s[30]; - my_snprintf(s, S(s), "%d", xctx->case_insensitive); - Tcl_SetResult(interp, s, TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->case_insensitive), TCL_VOLATILE); } else if(!strcmp(argv[2], "color_ps")) { if( color_ps != 0 ) @@ -840,19 +835,13 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, xctx->current_win_path, TCL_VOLATILE); } else if(!strcmp(argv[2],"currsch")) { - char s[30]; - my_snprintf(s, S(s), "%d",xctx->currsch); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->currsch),TCL_VOLATILE); } else if(!strcmp(argv[2],"debug_var")) { - char s[30]; - my_snprintf(s, S(s), "%d",debug_var); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(debug_var),TCL_VOLATILE); } else if(!strcmp(argv[2],"draw_window")) { - char s[30]; - my_snprintf(s, S(s), "%d",xctx->draw_window); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->draw_window),TCL_VOLATILE); } else if(!strcmp(argv[2],"flat_netlist")) { if( xctx->flat_netlist != 0 ) @@ -861,14 +850,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, "0",TCL_STATIC); } else if(!strcmp(argv[2],"graph_lastsel")) { - char s[30]; - my_snprintf(s, S(s), "%d",xctx->graph_lastsel); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->graph_lastsel),TCL_VOLATILE); } else if(!strcmp(argv[2],"gridlayer")) { - char s[30]; - my_snprintf(s, S(s), "%d",GRIDLAYER); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(GRIDLAYER),TCL_VOLATILE); } else if(!strcmp(argv[2],"help")) { if( help != 0 ) @@ -877,20 +862,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, "0",TCL_STATIC); } else if(!strcmp(argv[2],"instances")) { - char s[30]; - my_snprintf(s, S(s), "%d",xctx->instances); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->instances), TCL_VOLATILE); } else if(!strcmp(argv[2],"lastsel")) { - char s[30]; rebuild_selected_array(); - my_snprintf(s, S(s), "%d", xctx->lastsel); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->lastsel),TCL_VOLATILE); } else if(!strcmp(argv[2],"line_width")) { - char s[40]; - my_snprintf(s, S(s), "%g", xctx->lw); - Tcl_SetResult(interp, s, TCL_VOLATILE); + Tcl_SetResult(interp, dtoa(xctx->lw), TCL_VOLATILE); } else if(!strcmp(argv[2],"netlist_name")) { Tcl_SetResult(interp, xctx->netlist_name, TCL_VOLATILE); @@ -923,29 +902,19 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, "0",TCL_STATIC); } else if(!strcmp(argv[2],"ntabs")) { - char s[30]; - my_snprintf(s, S(s), "%d",new_schematic("ntabs", NULL, NULL)); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(new_schematic("ntabs", NULL, NULL)),TCL_VOLATILE); } else if(!strcmp(argv[2],"pinlayer")) { - char s[30]; - my_snprintf(s, S(s), "%d",PINLAYER); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(PINLAYER),TCL_VOLATILE); } else if(!strcmp(argv[2],"rectcolor")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%d",xctx->rectcolor); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->rectcolor),TCL_VOLATILE); } else if(!strcmp(argv[2],"sellayer")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%d",SELLAYER); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(SELLAYER),TCL_VOLATILE); } else if(!strcmp(argv[2],"semaphore")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%d",xctx->semaphore); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(xctx->semaphore),TCL_VOLATILE); } #ifndef __unix__ else if(!strcmp(argv[2], "temp_dir")) { @@ -986,9 +955,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, "0",TCL_STATIC); } else if(!strcmp(argv[2],"textlayer")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%d",TEXTLAYER); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(TEXTLAYER), TCL_VOLATILE); } else if(!strcmp(argv[2],"top_path")) { Tcl_SetResult(interp, xctx->top_path, TCL_VOLATILE); @@ -999,14 +966,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, top_path,TCL_VOLATILE); } else if(!strcmp(argv[2],"version")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%s",XSCHEM_VERSION); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, XSCHEM_VERSION, TCL_VOLATILE); } else if(!strcmp(argv[2],"wirelayer")) { - char s[30]; /* overflow safe 20161122 */ - my_snprintf(s, S(s), "%d",WIRELAYER); - Tcl_SetResult(interp, s,TCL_VOLATILE); + Tcl_SetResult(interp, itoa(WIRELAYER), TCL_VOLATILE); } else if(!strcmp(argv[2],"xorigin")) { char s[128]; @@ -1149,10 +1112,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(!strcmp(argv[1],"get_tok_size") ) { - char s[30]; - cmd_found = 1; - my_snprintf(s, S(s), "%d", (int)xctx->get_tok_size); - Tcl_SetResult(interp, s, TCL_VOLATILE); + Tcl_SetResult(interp, itoa((int)xctx->get_tok_size), TCL_VOLATILE); } else if(!strcmp(argv[1],"globals")) @@ -1364,35 +1324,29 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg { /* xschem instance_nodemap [instance_name] */ char *pins = NULL; - int p, i, no_of_pins; + int p, no_of_pins; int inst = -1; cmd_found = 1; prepare_netlist_structs(0); - if(argc>=3) inst = get_instance(argv[2]); - for(i=0;iinstances;i++) { - if(inst>=0 && i != inst) continue; - my_strcat(573, &pins, "{ {"); - my_strcat(574, &pins, xctx->inst[i].instname); - my_strcat(575, &pins, "} "); - no_of_pins= (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]; - for(p=0;pinst[i].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr,"name",0); - if(!pin[0]) pin = "--ERROR--"; - if(argc>=4 && strcmp(argv[3], pin)) continue; - my_strcat(576, &pins, "{ "); - my_strcat(655, &pins, "{"); - my_strcat(662, &pins, pin); - my_strcat(663, &pins, "} {"); - my_strcat(664, &pins, xctx->inst[i].node[p] ? xctx->inst[i].node[p] : ""); - my_strcat(665, &pins, "} "); - my_strcat(1155, &pins, "} "); + if(argc > 2) { + inst = get_instance(argv[2]); + if(inst >=0) { + my_mstrcat(573, &pins, "{ {", xctx->inst[inst].instname, "} ", NULL); + no_of_pins= (xctx->inst[inst].ptr+ xctx->sym)->rects[PINLAYER]; + for(p=0;pinst[inst].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr,"name",0); + if(!pin[0]) pin = "--ERROR--"; + if(argc>=4 && strcmp(argv[3], pin)) continue; + my_mstrcat(576, &pins, "{ {", pin, "} {", + xctx->inst[inst].node[p] ? xctx->inst[inst].node[p] : "", "} } ", NULL); + } + my_strcat(1188, &pins, "} "); } - my_strcat(1188, &pins, "} "); + Tcl_SetResult(interp, pins, TCL_VOLATILE); + my_free(1189, &pins); } - Tcl_SetResult(interp, pins, TCL_VOLATILE); - my_free(1189, &pins); } else if(!strcmp(argv[1],"instance_pin_coord")) @@ -1474,9 +1428,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg const char *pin; pin = get_tok_value((xctx->inst[i].ptr+ xctx->sym)->rect[PINLAYER][p].prop_ptr,"name",0); if(!pin[0]) pin = "--ERROR--"; - my_strcat(376, &pins, "{"); - my_strcat(523, &pins, pin); - my_strcat(533, &pins, "}"); + my_mstrcat(376, &pins, "{", pin, "}", NULL); if(p< no_of_pins-1) my_strcat(377, &pins, " "); } Tcl_SetResult(interp, pins, TCL_VOLATILE); @@ -1505,7 +1457,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg xRect *rct; short flip, rot; double x0,y0, pinx0, piny0; - char num[40]; char *pins = NULL; int p, i, no_of_pins; @@ -1529,10 +1480,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg if(!pin[0]) pin = "--ERROR--"; if(xctx->inst[i].node[p] && !strcmp(xctx->inst[i].node[p], argv[2]) && !IS_LABEL_SH_OR_PIN( (xctx->inst[i].ptr+xctx->sym)->type )) { - my_strcat(534, &pins, "{ {"); - my_strcat(535, &pins, xctx->inst[i].instname); - my_strcat(536, &pins, "} {"); - my_strcat(537, &pins, pin); + my_mstrcat(534, &pins, "{ {", xctx->inst[i].instname, "} {", pin, NULL); pinx0 = (rct[p].x1+rct[p].x2)/2; piny0 = (rct[p].y1+rct[p].y2)/2; @@ -1540,13 +1488,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg pinx0 += x0; piny0 += y0; - my_strcat(538, &pins, "} {"); - my_snprintf(num, S(num), "%g", pinx0); - my_strcat(539, &pins, num); - my_strcat(540, &pins, "} {"); - my_snprintf(num, S(num), "%g", piny0); - my_strcat(541, &pins, num); - my_strcat(542, &pins, "} } "); + my_mstrcat(538, &pins, "} {", dtoa(pinx0), "} {", dtoa(piny0), "} } ", NULL); } } } @@ -2433,9 +2375,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg for(n=0; n < xctx->lastsel; n++) { if(xctx->sel_array[n].type == ELEMENT) { i = xctx->sel_array[n].n; - my_strcat(1191, &res, "{"); - my_strcat(1192, &res, xctx->inst[i].instname); - my_strcat(645, &res, "}"); + my_mstrcat(645, &res, "{", xctx->inst[i].instname, "}", NULL); if(n < xctx->lastsel-1) my_strcat(646, &res, " "); } } @@ -2783,13 +2723,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(argv[1][0] == 't') { if(!strcmp(argv[1],"test")) { - char s[30]; - int c; cmd_found = 1; - c = xctx->strcmp("aaa","AAA"); - my_snprintf(s, S(s), "%d", c); - - Tcl_AppendResult(interp, s, NULL); + Tcl_ResetResult(interp); } else if(!strcmp(argv[1],"toggle_colorscheme")) diff --git a/src/select.c b/src/select.c index 83d2e2ef..7e2efd92 100644 --- a/src/select.c +++ b/src/select.c @@ -215,6 +215,7 @@ static void del_rect_line_arc_poly(void) { if(xctx->rect[c][i].sel == SELECTED) { + if(c == GRIDLAYER) xctx->graph_lastsel = -1; /* invalidate last selected graph */ j++; bbox(ADD, xctx->rect[c][i].x1, xctx->rect[c][i].y1, xctx->rect[c][i].x2, xctx->rect[c][i].y2); my_free(928, &xctx->rect[c][i].prop_ptr); @@ -826,7 +827,8 @@ void select_box(int c, int i, unsigned short select_mode, int fast) if(select_mode) { if(select_mode==SELECTED) { xctx->rect[c][i].sel = select_mode; - if(xctx->rect[c][i].flags & 1) xctx->graph_lastsel = i; /* remember last selected graph */ + /* remember last selected graph */ + if(c == GRIDLAYER && (xctx->rect[c][i].flags & 1)) xctx->graph_lastsel = i; } else { xctx->rect[c][i].sel |= select_mode; } diff --git a/src/xschem.h b/src/xschem.h index 99586eda..64960610 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1314,6 +1314,9 @@ extern void my_realloc(int id, void *ptr,size_t size); extern void *my_calloc(int id, size_t nmemb, size_t size); extern void my_free(int id, void *ptr); extern size_t my_strcat(int id, char **, const char *); +extern size_t my_mstrcat(int id, char **str, const char *append_str, ...); +extern char *itoa(int i); +extern char *dtoa(double i); extern double my_round(double a); extern double round_to_n_digits(double x, int n); extern double floor_to_n_digits(double x, int n); diff --git a/src/xschem.tcl b/src/xschem.tcl index 52f4ceab..a8e30cc2 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1304,9 +1304,10 @@ proc graph_edit_wave {n n_wave} { if {[lindex $col $i] eq {}} { lappend col $graph_sel_color} incr i } + # remove excess colors set col [lrange $col 0 [expr {$i - 1}]] set graph_sel_color [lindex $col $graph_sel_wave] - xschem setprop rect 2 $graph_selected color $col fastundo + xschem setprop rect 2 $graph_selected color $col fast xschem draw_graph $graph_selected # puts "graph: $graph_selected , wave: $n_wave, n_nodes: $n_nodes" # puts " node: $node, col: $col" @@ -1332,11 +1333,13 @@ proc graph_edit_wave {n n_wave} { # get selected text from a text widget: # -# .graphdialog.center.right.text1 get \ -# [.graphdialog.center.right.text1 index sel.first] \ -# [.graphdialog.center.right.text1 index sel.last] +# .graphdialog.center.right.text1 get sel.first sel.last # +# see if a selection is present: +# .graphdialog.center.right.text1 tag ranges sel # +# replace selected text: +# .graphdialog.center.right.text1 replace sel.first sel.last BUS # @@ -1471,7 +1474,7 @@ proc graph_change_wave_color {{wave {}}} { set index [string range $tag 1 end] set col [xschem getprop rect 2 $graph_selected color] set col [lreplace $col $index $index $graph_sel_color] - xschem setprop rect 2 $graph_selected color $col fastundo + xschem setprop rect 2 $graph_selected color $col fast graph_update_nodelist xschem draw_graph $graph_selected } @@ -1479,7 +1482,7 @@ proc graph_change_wave_color {{wave {}}} { } else { set col [xschem getprop rect 2 $graph_selected color] set col [lreplace $col $wave $wave $graph_sel_color] - xschem setprop rect 2 $graph_selected color $col fastundo + xschem setprop rect 2 $graph_selected color $col fast xschem draw_graph $graph_selected } } @@ -1516,7 +1519,7 @@ proc graph_update_nodelist {} { } else { set col {} } - xschem setprop rect 2 $graph_selected color $col fastundo + xschem setprop rect 2 $graph_selected color $col fast } proc fill_graph_listbox {} { @@ -1528,9 +1531,9 @@ proc fill_graph_listbox {} { proc graph_edit_properties {n} { global graph_bus graph_sort graph_digital graph_selected colors graph_sel_color - global graph_unlocked graph_schname graph_unitx graph_unity - global graph_divx graph_divy graph_subdivx graph_subdivy + global graph_unlocked graph_schname + xschem push_undo set geom {} if { [winfo exists .graphdialog]} { set geom [winfo geometry .graphdialog] @@ -1616,9 +1619,9 @@ proc graph_edit_properties {n} { xschem setprop rect 2 $graph_selected y2 [.graphdialog.top.max get] fast xschem setprop rect 2 $graph_selected node $node fast if {$graph_unlocked} { - xschem setprop rect 2 $graph_selected flags {graph,unlocked} fastundo + xschem setprop rect 2 $graph_selected flags {graph,unlocked} fast } else { - xschem setprop rect 2 $graph_selected flags {graph} fastundo + xschem setprop rect 2 $graph_selected flags {graph} fast } destroy .graphdialog xschem draw_graph $graph_selected @@ -1638,9 +1641,9 @@ proc graph_edit_properties {n} { xschem setprop rect 2 $graph_selected y2 [.graphdialog.top.max get] fast xschem setprop rect 2 $graph_selected node $node fast if {$graph_unlocked} { - xschem setprop rect 2 $graph_selected flags {graph,unlocked} fastundo + xschem setprop rect 2 $graph_selected flags {graph,unlocked} fast } else { - xschem setprop rect 2 $graph_selected flags {graph} fastundo + xschem setprop rect 2 $graph_selected flags {graph} fast } xschem draw_graph $graph_selected } @@ -1659,66 +1662,81 @@ proc graph_edit_properties {n} { # top2 frame label .graphdialog.top2.labunitx -text {X units} - spinbox .graphdialog.top2.unitx -values {p n u m 1 k M G} -width 2 -textvar graph_unitx \ + spinbox .graphdialog.top2.unitx -values {p n u m 1 k M G} -width 2 \ -command { - xschem setprop rect 2 $graph_selected unitx $graph_unitx + xschem setprop rect 2 $graph_selected unitx [.graphdialog.top2.unitx get] xschem draw_graph $graph_selected } label .graphdialog.top2.labunity -text { Y units} - spinbox .graphdialog.top2.unity -values {p n u m 1 k M G} -width 2 -textvar graph_unity \ + spinbox .graphdialog.top2.unity -values {p n u m 1 k M G} -width 2 \ -command { - xschem setprop rect 2 $graph_selected unity $graph_unity + xschem setprop rect 2 $graph_selected unity [.graphdialog.top2.unity get] xschem draw_graph $graph_selected } label .graphdialog.top2.labdivx -text { X div.} - entry .graphdialog.top2.divx -textvariable graph_divx -width 2 + entry .graphdialog.top2.divx -width 2 bind .graphdialog.top2.divx { - xschem setprop rect 2 $graph_selected divx $graph_divx + xschem setprop rect 2 $graph_selected divx [.graphdialog.top2.divx get] xschem draw_graph $graph_selected } label .graphdialog.top2.labdivy -text { Y div.} - entry .graphdialog.top2.divy -textvariable graph_divy -width 2 + entry .graphdialog.top2.divy -width 2 bind .graphdialog.top2.divy { - xschem setprop rect 2 $graph_selected divy $graph_divy + xschem setprop rect 2 $graph_selected divy [.graphdialog.top2.divy get] xschem draw_graph $graph_selected } label .graphdialog.top2.labsubdivx -text { X subdiv.} - entry .graphdialog.top2.subdivx -textvariable graph_subdivx -width 2 + entry .graphdialog.top2.subdivx -width 2 bind .graphdialog.top2.subdivx { - xschem setprop rect 2 $graph_selected subdivx $graph_subdivx + xschem setprop rect 2 $graph_selected subdivx [.graphdialog.top2.subdivx get] xschem draw_graph $graph_selected } label .graphdialog.top2.labsubdivy -text { Y subdiv.} - entry .graphdialog.top2.subdivy -textvariable graph_subdivy -width 2 + entry .graphdialog.top2.subdivy -width 2 bind .graphdialog.top2.subdivy { - xschem setprop rect 2 $graph_selected subdivy $graph_subdivy + xschem setprop rect 2 $graph_selected subdivy [.graphdialog.top2.subdivy get] xschem draw_graph $graph_selected } + label .graphdialog.top2.labdset -text { Dataset} + entry .graphdialog.top2.dset -width 4 + bind .graphdialog.top2.dset { + xschem setprop rect 2 $graph_selected dataset [.graphdialog.top2.dset get] + xschem draw_graph $graph_selected + } + + .graphdialog.top2.dset insert 0 [xschem getprop rect 2 $graph_selected dataset] set graph_divx [xschem getprop rect 2 $graph_selected divx] if {$graph_divx eq {}} { set graph_divx 5} + .graphdialog.top2.divx insert 0 $graph_divx set graph_divy [xschem getprop rect 2 $graph_selected divy] if {$graph_divy eq {}} { set graph_divy 5} + .graphdialog.top2.divy insert 0 $graph_divy set graph_subdivx [xschem getprop rect 2 $graph_selected subdivx] if {$graph_subdivx eq {}} { set graph_subdivx 1} + .graphdialog.top2.subdivx insert 0 $graph_subdivx set graph_subdivy [xschem getprop rect 2 $graph_selected subdivy] if {$graph_subdivy eq {}} { set graph_subdivy 1} + .graphdialog.top2.subdivy insert 0 $graph_subdivy set graph_unitx [xschem getprop rect 2 $graph_selected unitx] if {$graph_unitx eq {}} { set graph_unitx 1} + .graphdialog.top2.unitx set $graph_unitx set graph_unity [xschem getprop rect 2 $graph_selected unity] if {$graph_unity eq {}} { set graph_unity 1} + .graphdialog.top2.unity set $graph_unity pack .graphdialog.top2.labunitx .graphdialog.top2.unitx \ .graphdialog.top2.labunity .graphdialog.top2.unity -side left pack .graphdialog.top2.labdivx .graphdialog.top2.divx \ .graphdialog.top2.labdivy .graphdialog.top2.divy \ .graphdialog.top2.labsubdivx .graphdialog.top2.subdivx \ - .graphdialog.top2.labsubdivy .graphdialog.top2.subdivy -side left + .graphdialog.top2.labsubdivy .graphdialog.top2.subdivy \ + .graphdialog.top2.labdset .graphdialog.top2.dset -side left # top frame @@ -1730,7 +1748,7 @@ proc graph_edit_properties {n} { checkbutton .graphdialog.top.dig -text {Digital} -variable graph_digital -indicatoron 1 \ -command { if { [xschem get schname] eq $graph_schname } { - xschem setprop rect 2 $graph_selected digital $graph_digital fastundo + xschem setprop rect 2 $graph_selected digital $graph_digital fast xschem draw_graph $graph_selected } } @@ -4463,10 +4481,9 @@ set tctx::global_list { edit_prop_pos edit_prop_size editprop_sympath edit_symbol_prop_new_sel enable_dim_bg enable_stretch en_hilight_conn_inst filetmp flat_netlist fullscreen gaw_fd gaw_tcp_address globfilter - graph_bus graph_digital graph_divx graph_divy + graph_bus graph_digital graph_sel_color graph_schname graph_selected graph_sel_wave graph_sort - graph_subdivx graph_subdivy - graph_unitx graph_unity graph_unlocked + graph_unlocked hide_empty_graphs hide_symbols hsize hspice_netlist incr_hilight infowindow_text INITIALINSTDIR INITIALLOADDIR INITIALPROPDIR INITIALTEXTDIR input_line_cmd input_line_data launcher_default_program light_colors line_width local_netlist_dir @@ -5457,12 +5474,6 @@ set_ne to_pdf {ps2pdf} set_ne graph_bus 0 set_ne graph_selected {} set_ne graph_schname {} -set_ne graph_unitx 1 -set_ne graph_unity 1 -set_ne graph_divx 5 -set_ne graph_divy 5 -set_ne graph_subdivx 1 -set_ne graph_subdivy 1 # user clicked this wave set_ne graph_sel_wave {} # flag to force simulation stop (Esc key pressed) diff --git a/xschem_library/ngspice/solar_panel.sch b/xschem_library/ngspice/solar_panel.sch index f254e31a..e5962895 100644 --- a/xschem_library/ngspice/solar_panel.sch +++ b/xschem_library/ngspice/solar_panel.sch @@ -68,26 +68,6 @@ x1=9.15065e-06 x2=0.000197012 divx=8 node="i(vsw)" color=12 unitx=m} -B 2 100 80 900 480 {flags=graph -y1=0 -y2=20 -ypos1=1.24368 -ypos2=18.7373 -divy=5 -subdivy=1 -unity=1 -x1=9.15065e-06 -x2=0.000197012 -divx=5 -subdivx=1 -node="led -panel -src -sw" -color="7 8 9 10" -dataset=0 -unitx=u -digital=1} B 18 45 -850 300 -665 {} A 5 300 -850 5.590169943749475 243.434948822922 360 {fill=true} P 7 6 375 -665 320 -821.25 315 -835 302.5 -850 290 -855 45 -865 {} diff --git a/xschem_library/rom8k/rom2_ctrl.sch b/xschem_library/rom8k/rom2_ctrl.sch index 795f2fe3..382b0d0e 100644 --- a/xschem_library/rom8k/rom2_ctrl.sch +++ b/xschem_library/rom8k/rom2_ctrl.sch @@ -8,39 +8,48 @@ B 2 580 -140 1200 -30 {flags=graph y1 = 0 y2 = 1.6 divy = 2 -x1=1.11978e-07 -x2=2.09815e-07 +x1=1.14083e-07 +x2=1.90664e-07 divx=8 comm="example of using tcl to replace the path with $path variable automatically" -node="v(xctrl.ldcp_ref) -v(xctrl.ldprechref)" -color="12 11"} +node="xctrl.ldcp_ref +xctrl.ldprechref" +color="12 11" +digital=0 +ypos1=-0.0691204 +ypos2=0.68559} B 2 580 -280 1200 -140 {flags=graph y1 = 0 y2 = 1.6 divy = 2 -x1=1.36438e-07 -x2=2.34275e-07 +x1=1.14083e-07 +x2=1.90664e-07 divx=8 comm="example of using tcl to replace the path with $path variable automatically" -node="v(xctrl.ldcp_ref) -v(xctrl.ldcpb)" -color="12 11"} +node="xctrl.ldcp_ref +xctrl.ldcpb" +color="12 11" +digital=0 +ypos1=0.071147 +ypos2=1.0465} B 2 580 -400 1200 -280 {flags=graph y1 = 0 y2 = 1.6 divy = 2 -x1=1.11978e-07 -x2=2.09815e-07 +x1=1.14083e-07 +x2=1.90664e-07 divx=8 comm="example of using tcl to replace the path with $path variable automatically" -node="v(xctrl.ldcp_ref) -v(xctrl.ldouti) -v(xctrl.ldoutib)" -color="12 5 11"} +node="xctrl.ldcp_ref +xctrl.ldouti +xctrl.ldoutib" +color="12 5 11" +digital=1 +ypos1=0.1572 +ypos2=0.829851} N 360 -670 500 -670 {lab=LDCPB} N 240 -760 250 -760 {lab=LDCPB} N 240 -760 240 -670 {lab=LDCPB}