HistogramH and HistogramV graph modes

This commit is contained in:
stefan schippers 2024-12-09 17:25:40 +01:00
parent 2a7ee749ba
commit 8bb69b65e9
3 changed files with 78 additions and 21 deletions

View File

@ -2733,24 +2733,55 @@ static void draw_graph_points(int idx, int first, int last,
poly_npoints++;
}
set_thick_waves(1, wcnt, wave_col, gr);
for(x = 0; x < 2; x++) {
Drawable w;
int offset = 0, size;
XPoint *pt = point;
if(x == 0 && xctx->draw_window) w = xctx->window;
else if(x == 1 && xctx->draw_pixmap) w = xctx->save_pixmap;
else continue;
while(1) {
pt = point + offset;
size = poly_npoints - offset;
if(size > MAX_POLY_POINTS) size = MAX_POLY_POINTS;
/* dbg(0, "draw_graph_points(): drawing from %d, size %d\n", offset, size);*/
XDrawLines(display, w, xctx->gc[wave_col], pt, size, CoordModeOrigin);
if(offset + size >= poly_npoints) break;
offset += MAX_POLY_POINTS -1; /* repeat last point on next iteration */
if(digital || gr->mode == 0) { /* Line */
for(x = 0; x < 2; x++) {
Drawable w;
int offset = 0, size;
XPoint *pt = point;
if(x == 0 && xctx->draw_window) w = xctx->window;
else if(x == 1 && xctx->draw_pixmap) w = xctx->save_pixmap;
else continue;
while(1) {
pt = point + offset;
size = poly_npoints - offset;
if(size > MAX_POLY_POINTS) size = MAX_POLY_POINTS;
/* dbg(0, "draw_graph_points(): drawing from %d, size %d\n", offset, size);*/
XDrawLines(display, w, xctx->gc[wave_col], pt, size, CoordModeOrigin);
if(offset + size >= poly_npoints) break;
offset += MAX_POLY_POINTS -1; /* repeat last point on next iteration */
}
}
/*XDrawLines(display, xctx->window, xctx->gc[wave_col], point, poly_npoints, CoordModeOrigin);*/
}
else if(gr->mode == 1) { /* HistoV */
int y2 = (int)Y_TO_SCREEN(gr->y2);
for(x = 0; x < 2; x++) {
Drawable w;
if(x == 0 && xctx->draw_window) w = xctx->window;
else if(x == 1 && xctx->draw_pixmap) w = xctx->save_pixmap;
else continue;
for(p = 0; p < poly_npoints; p++) {
if(point[p].y != y2) {
XDrawLine(display, w, xctx->gc[wave_col], point[p].x, point[p].y, point[p].x, y2);
}
}
}
}
else if(gr->mode == 2) { /* HistoH */
int x1 = (int)X_TO_SCREEN(gr->x1);
for(x = 0; x < 2; x++) {
Drawable w;
if(x == 0 && xctx->draw_window) w = xctx->window;
else if(x == 1 && xctx->draw_pixmap) w = xctx->save_pixmap;
else continue;
for(p = 0; p < poly_npoints; p++) {
if(point[p].x != x1) {
XDrawLine(display, w, xctx->gc[wave_col], 0, point[p].y, point[p].x, point[p].y);
}
}
}
}
set_thick_waves(0, wcnt, wave_col, gr);
/* } else dbg(1, "skipping wave: %s\n", raw->names[idx]); */
for(p=0;p<cadlayers; ++p) {
@ -2916,6 +2947,12 @@ void setup_graph_data(int i, int skip, Graph_ctx *gr)
val = get_tok_value(r->prop_ptr,"legend", 0);
if(val[0]) gr->legend = atoi(val);
/* draw mode (0: Line, 1: Histo. Default: Line) */
val = get_tok_value(r->prop_ptr,"mode", 0);
if(!strcmp(val, "HistoV")) gr->mode = 1;
else if(!strcmp(val, "HistoH")) gr->mode = 2;
else gr->mode = 0;
/* get x/y range, grid info etc */
val = get_tok_value(r->prop_ptr,"unitx", 0);
gr->unitx_suffix = val[0];

View File

@ -857,11 +857,11 @@ typedef struct
typedef struct {
int digital;
int legend; /* display graph legend */
double rx1, ry1, rx2, ry2, rw, rh; /* container rectangle */
double rx1, ry1, rx2, ry2, rw, rh; /* container rectangle, xschem coordinates */
double sx1, sy1, sx2, sy2; /* screen coordinates of above */
/* graph box (smaller than rect container due to margins) */
/* graph box (smaller than rect container due to margins) in xschem coordinates*/
double x1, y1, x2, y2, w, h;
/* the following are the x1,x2, y1, y2 rectangle attributes */
/* the following are the x1, x2, y1, y2 rectangle attributes */
double gx1, gy1, gx2, gy2, gw, gh;
double master_gx1, master_gx2, master_gw, master_cx;
/* y area range for digital graphs */
@ -881,6 +881,7 @@ typedef struct {
double unitx, unity;
int unitx_suffix; /* 'n' or 'u' or 'M' or 'k' ... */
int unity_suffix;
int mode; /* default:0 0:Line, 1:HistoV, 2:HistoH */
double txtsizelab, digtxtsizelab, txtsizey, txtsizex;
int dataset;
int hilight_wave; /* wave index */

View File

@ -2972,6 +2972,15 @@ proc graph_edit_properties {n} {
entry .graphdialog.top2.sweep -width 10
entry_replace_selection .graphdialog.top2.sweep
label .graphdialog.top2.labmode -text {Mode}
spinbox .graphdialog.top2.mode -values {Line HistoV HistoH} -width 6 \
-command {
graph_push_undo
xschem setprop rect 2 $graph_selected mode [.graphdialog.top2.mode get]
xschem draw_graph $graph_selected
}
# bind .graphdialog.top2.sweep <KeyRelease> {
# graph_push_undo
# xschem setprop rect 2 $graph_selected sweep [.graphdialog.top2.sweep get]
@ -2989,29 +2998,39 @@ proc graph_edit_properties {n} {
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
set graph_mode [xschem getprop rect 2 $graph_selected mode]
if {$graph_mode eq {}} { set graph_mode Line}
.graphdialog.top2.mode set $graph_mode
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 \
.graphdialog.top2.labsweep -side left
.graphdialog.top2.labsubdivy .graphdialog.top2.subdivy -side left
pack .graphdialog.top2.labmode .graphdialog.top2.mode .graphdialog.top2.labsweep -side left
pack .graphdialog.top2.sweep -side left -fill x -expand yes
# top frame