diff --git a/src/Makefile.in b/src/Makefile.in index cea16e20..d6cc0a40 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -13,7 +13,7 @@ put /local/install_shares { keys.help xschem.help xschem.tcl break.awk convert_to_verilog2001.awk flatten.awk flatten_tedax.awk flatten_savenodes.awk make_sym.awk make_sym_lcc.awk symgen.awk order_labels.awk sort_labels.awk spice.awk tedax.awk verilog.awk - vhdl.awk hspice_backannotate.tcl add_custom_menu.tcl + vhdl.awk hspice_backannotate.tcl add_custom_menu.tcl create_graph.tcl add_custom_button.tcl change_index.tcl icon.xpm resources.tcl xschemrc ngspice_backannotate.tcl gschemtoxschem.awk traversal.tcl } diff --git a/src/create_graph.tcl b/src/create_graph.tcl new file mode 100644 index 00000000..5683e9ed --- /dev/null +++ b/src/create_graph.tcl @@ -0,0 +1,49 @@ +# +# File: create_graph.tcl +# +# This file is part of XSCHEM, +# a schematic capture and Spice/Vhdl/Verilog netlisting tool for circuit +# simulation. +# Copyright (C) 1998-2022 Stefan Frederik Schippers +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +# procedure to create a graph in an empty xschem window and display waveforms +proc create_graph {rawfile node {analysis tran} {color {4 5 6 7 8 9 10 11 12 13 14}}} { + # clear window if not already empty + xschem clear force + # clear loaded raw file if any + xschem raw_clear + # set current layer to graph layer (grey, layer 2) + xschem set rectcolor 2 + # create a 300x400 rectangle + xschem rect 0 -300 400 0 + # make it a graph + xschem setprop rect 2 0 flags graph + # read a simulation raw file + xschem raw_read $rawfile $analysis + # add nodes to display + xschem setprop rect 2 0 node $node + # set node colors + xschem setprop rect 2 0 color $color + # make xschem display full the graph rectangle + xschem zoom_full + # full zoom graph data on x axis + xschem setprop rect 2 0 fullxzoom + # full zoom graph data on y axis + xschem setprop rect 2 0 fullyzoom +} + diff --git a/src/draw.c b/src/draw.c index 745060ad..e5cf621c 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1872,21 +1872,25 @@ static void set_thick_waves(int what, int wcnt, int wave_col, Graph_ctx *gr) int graph_fullxzoom(xRect *r, Graph_ctx *gr, int dataset) { - int need_redraw = 0; - double xx1, xx2; - int idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", 1)); - int dset = dataset == -1 ? 0 : dataset; - if(idx < 0 ) idx = 0; - xx1 = get_raw_value(dset, idx, 0); - xx2 = get_raw_value(dset, idx, xctx->graph_npoints[dset] -1); - if(gr->logx) { - xx1 = mylog10(xx1); - xx2 = mylog10(xx2); + if( sch_waves_loaded() >= 0) { + int need_redraw = 0; + double xx1, xx2; + int idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", 1)); + int dset = dataset == -1 ? 0 : dataset; + if(idx < 0 ) idx = 0; + xx1 = get_raw_value(dset, idx, 0); + xx2 = get_raw_value(dset, idx, xctx->graph_npoints[dset] -1); + if(gr->logx) { + xx1 = mylog10(xx1); + xx2 = mylog10(xx2); + } + my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); + my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); + need_redraw = 1; + return need_redraw; + } else { + return 0; } - my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "x1", dtoa(xx1))); - my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "x2", dtoa(xx2))); - need_redraw = 1; - return need_redraw; } int graph_fullyzoom(xRect *r, Graph_ctx *gr, int dataset)