Browse Source

command wrdata

pre-master-46
h_vogt 16 years ago
parent
commit
4068f498c6
  1. 4
      ChangeLog
  2. 37
      src/frontend/com_gnuplot.c
  3. 2
      src/frontend/com_gnuplot.h
  4. 8
      src/frontend/commands.c
  5. 70
      src/frontend/plotting/gnuplot.c
  6. 3
      src/frontend/plotting/gnuplot.h
  7. 11
      src/frontend/plotting/plotit.c
  8. 8
      visualc/vngspice.sln

4
ChangeLog

@ -1,3 +1,7 @@
2010-02-27 Holger Vogt
* command.c, gnuplot.c, gnuplot.h, com_gnuplot.c, com_gnuplot.h, plotit.c:
new command 'wrdata file vecs' for simple tabular printout of data
2010-02-26 Holger Vogt
* vsrc.c, vsrcacct.c, vsrcask.c, vsrcdefs.h, vsrcload.c, vsrcpar.c:
PWL source now has a repeat parameter (r=value) and a delay parameter

37
src/frontend/com_gnuplot.c

@ -30,12 +30,41 @@ com_gnuplot(wordlist *wl)
(void) plotit(wl, fname, "gnuplot");
#if 0
/* Leave temp file sitting around so gnuplot can grab it from
background. */
if (tempf)
(void) unlink(fname);
#endif
if (tempf) {
tfree(fname);
}
return;
}
/* data printout to file plotargs */
void
com_write_simple(wordlist *wl)
{
char *fname = NULL;
bool tempf = FALSE;
if (wl) {
fname = wl->wl_word;
wl = wl->wl_next;
}
if (!wl) {
return;
}
if (cieq(fname, "temp") || cieq(fname, "tmp")) {
fname = smktemp("gp"); /* Is this the correct name ? */
tempf = TRUE;
}
(void) plotit(wl, fname, "writesimple");
/* Leave temp file sitting around so gnuplot can grab it from
background. */
if (tempf) {
tfree(fname);
}
return;
}

2
src/frontend/com_gnuplot.h

@ -2,5 +2,5 @@
#define _COM_GNUPLOT_H
void com_gnuplot(wordlist *wl);
void com_write_simple(wordlist *wl);
#endif

8
src/frontend/commands.c

@ -164,6 +164,10 @@ struct comm spcp_coms[] = {
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, LOTS,
(void (*)()) NULL,
"file plotargs : Send plot to gnuplot." } ,
{ "wrdata", com_write_simple, FALSE, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, LOTS,
(void (*)()) NULL,
"file plotargs : Send plot data to file." } ,
{ "hardcopy", com_hardcopy, FALSE, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS,
(void (*)()) NULL,
@ -576,6 +580,10 @@ struct comm nutcp_coms[] = {
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, LOTS,
(void (*)()) NULL,
"file plotargs : Send plot to gnuplot." } ,
{ "wrdata", com_write_simple, FALSE, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 2, LOTS,
(void (*)()) NULL,
"file plotargs : Send plot data to file." } ,
{ "hardcopy", com_hardcopy, FALSE, FALSE, TRUE,
{ 1, 041000, 041000, 041000 }, E_DEFHMASK, 0, LOTS,
(void (*)()) NULL,

70
src/frontend/plotting/gnuplot.c

@ -172,13 +172,13 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
/* Write out the gnuplot command */
for ( v = vecs; v; v = v->v_link2 ) {
scale = v->v_scale;
if (v->v_name) {
i = i + 2;
if (i > 2) fprintf(file, ",\\\n");
fprintf(file, "\'%s\' using %d:%d with %s lw %d title \"%s\" ",
filename_data, i-1, i, plotstyle, linewidth, v->v_name);
}
scale = v->v_scale;
if (v->v_name) {
i = i + 2;
if (i > 2) fprintf(file, ",\\\n");
fprintf(file, "\'%s\' using %d:%d with %s lw %d title \"%s\" ",
filename_data, i-1, i, plotstyle, linewidth, v->v_name);
}
}
fprintf( file, "\n");
fprintf (file, "set terminal push\n");
@ -222,3 +222,59 @@ ft_gnuplot(double *xlims, double *ylims, char *filename, char *title, char *xlab
return;
}
/* simple printout of data into a file, similar to data table in ft_gnuplot
command: wrsimple file vecs
*/
void
ft_writesimple(double *xlims, double *ylims, char *filename, char *title, char *xlabel, char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype, struct dvec *vecs)
{
FILE *file_data;
struct dvec *v, *scale = NULL;
double xval, yval;
int i, numVecs;
char filename_data[128];
sprintf(filename_data, "%s.data", filename);
/* Sanity checking. */
for ( v = vecs, numVecs = 0; v; v = v->v_link2 ) {
numVecs++;
}
if (numVecs == 0) {
return;
}
/* Open the output data file. */
if (!(file_data = fopen(filename_data, "w"))) {
perror(filename);
return;
}
i = 0;
for ( v = vecs; v; v = v->v_link2 ) {
scale = v->v_scale;
}
/* Write out the data as simple arrays */
for ( i = 0; i < scale->v_length; i++ ) {
for ( v = vecs; v; v = v->v_link2 ) {
scale = v->v_scale;
xval = isreal(scale) ?
scale->v_realdata[i] : realpart(&scale->v_compdata[i]);
yval = isreal(v) ?
v->v_realdata[i] : realpart(&v->v_compdata[i]);
fprintf( file_data, "% e % e ", xval, yval );
}
fprintf( file_data, "\n");
}
(void) fclose( file_data );
return;
}

3
src/frontend/plotting/gnuplot.h

@ -11,6 +11,9 @@ void ft_gnuplot(double *xlims, double *ylims, char *filename, char *title,
struct dvec *vecs);
void ft_writesimple(double *xlims, double *ylims, char *filename, char *title,
char *xlabel, char *ylabel, GRIDTYPE gridtype, PLOTTYPE plottype,
struct dvec *vecs);
#endif

11
src/frontend/plotting/plotit.c

@ -1017,6 +1017,17 @@ plotit(wordlist *wl, char *hcopy, char *devname)
goto quit;
}
if (devname && eq(devname, "writesimple")) {
/* Interface to simple write output */
ft_writesimple(xlims, ylims, hcopy,
title ? title : vecs->v_plot->pl_title,
xlabel ? xlabel : ft_typabbrev(vecs->v_scale->v_type),
ylabel ? ylabel : ft_typabbrev(j),
gtype, ptype, vecs);
rtn = TRUE;
goto quit;
}
#ifdef TCL_MODULE
if (devname && eq(devname, "blt")) {
/* Just send the pairs to Tcl/Tk */

8
visualc/vngspice.sln

@ -25,12 +25,12 @@ Global
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.console_release|Win32.Build.0 = console_release|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.console_release|x64.ActiveCfg = console_release|x64
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.console_release|x64.Build.0 = console_release|x64
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Debug|Win32.ActiveCfg = Release|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Debug|Win32.Build.0 = Release|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Debug|Win32.ActiveCfg = Debug|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Debug|Win32.Build.0 = Debug|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Debug|x64.ActiveCfg = Debug|x64
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Debug|x64.Build.0 = Debug|x64
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Release|Win32.ActiveCfg = Release|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Release|Win32.Build.0 = Release|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Release|Win32.ActiveCfg = Debug|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Release|Win32.Build.0 = Debug|Win32
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Release|x64.ActiveCfg = Release|x64
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.Release|x64.Build.0 = Release|x64
{83E315C7-EDD3-4F6B-AF28-87A92A4FA49A}.release64|Win32.ActiveCfg = release64|x64

Loading…
Cancel
Save