ngspice/src/frontend/display.c

462 lines
12 KiB
C
Raw Normal View History

2000-04-27 22:03:57 +02:00
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
**********/
#include "ngspice/ngspice.h"
#include "ngspice/graph.h"
#include "ngspice/ftedev.h"
#include "ngspice/fteinput.h"
2012-08-08 18:54:52 +02:00
#include "ngspice/cpdefs.h"
#include "ngspice/ftedefs.h"
2000-04-27 22:03:57 +02:00
#ifdef TCL_MODULE
#include "ngspice/tclspice.h"
#endif
#include "display.h"
src/Makefile.am src/help.c src/main.c src/circuit/Makefile.am src/circuit/ifnewuid.c src/frontend/Makefile.am src/frontend/aspice.c src/frontend/circuits.h src/frontend/com_display.c src/frontend/com_hardcopy.c src/frontend/commands.c src/frontend/commands.h src/frontend/cpitf.c src/frontend/debugcom.c src/frontend/device.c src/frontend/diff.c src/frontend/display.c src/frontend/dotcards.c src/frontend/fourier.c src/frontend/inp.c src/frontend/inpcom.c src/frontend/linear.c src/frontend/misccoms.c src/frontend/mw_coms.c src/frontend/nutinp.c src/frontend/options.c src/frontend/outitf.c src/frontend/parse.c src/frontend/postcoms.c src/frontend/postsc.c src/frontend/rawfile.c src/frontend/resource.c src/frontend/runcoms.c src/frontend/runcoms2.c src/frontend/shyu.c src/frontend/spec.c src/frontend/spiceif.c src/frontend/subckt.c src/frontend/vectors.c src/frontend/where.c src/frontend/plotting/Makefile.am src/frontend/plotting/agraf.c src/frontend/plotting/graf.c src/frontend/plotting/plotcurv.c src/frontend/plotting/plotit.c src/frontend/plotting/x11.c src/frontend/plotting/xgraph.c src/include/Makefile.am src/maths/cmaths/cmath4.c src/misc/terminal.c src/misc/terminal.h src/parser/cshpar.c src/parser/front.c src/parser/front.h src/parser/history.c src/parser/history.h src/parser/modify.c src/parser/var2.c src/parser/var2.h src/parser/variable.c: Refactoring of frontend code. * src/include/ftehelp.h src/include/variable.h: Moved into frontend directory. * src/include/cpdefs.h src/include/cpextern.h src/include/ftedefs.h src/include/plot.h: Updates.
2000-06-27 18:09:02 +02:00
#include "variable.h"
2000-04-27 22:03:57 +02:00
2012-08-08 18:54:52 +02:00
* src/Makefile.am src/main.c src/sconvert.c src/analysis/cktdisto.c src/analysis/cktnoise.c src/analysis/noisean.c: Updates for the new header files. * src/maths/cmaths/cmath1.c src/maths/cmaths/cmath2.c src/maths/cmaths/cmath3.c src/maths/cmaths/cmath4.c: Updates for the new header files. * src/frontend/.cvsignore src/frontend/Makefile.am: Updates for the new files. * src/frontend/agraf.c src/frontend/aspice.c src/frontend/breakp.c src/frontend/breakp2.c src/frontend/circuits.c src/frontend/cpitf.c src/frontend/debugcom.c src/frontend/define.c src/frontend/diff.c src/frontend/dimens.c src/frontend/display.c src/frontend/doplot.c src/frontend/dotcards.c src/frontend/evaluate.c src/frontend/fourier.c src/frontend/graf.c src/frontend/grid.c src/frontend/inp.c src/frontend/inpcom.c src/frontend/interp.c src/frontend/linear.c src/frontend/misccoms.c src/frontend/misccoms.h src/frontend/miscvars.c src/frontend/mw_coms.c src/frontend/newcoms.c src/frontend/nutinp.c src/frontend/options.c src/frontend/outitf.c src/frontend/parse.c src/frontend/plotcurv.c src/frontend/points.c src/frontend/postcoms.c src/frontend/rawfile.c src/frontend/runcoms.c src/frontend/runcoms2.c src/frontend/shyu.c src/frontend/spec.c src/frontend/spiceif.c src/frontend/typesdef.c src/frontend/vectors.c src/frontend/where.c src/frontend/postcoms.c: Updates for the new header files. Some commands have moved into the new files below. * src/frontend/README src/frontend/com_compose.c src/frontend/com_compose.h src/frontend/com_display.c src/frontend/com_display.h src/frontend/com_let.c src/frontend/com_let.h src/frontend/com_setscale.c src/frontend/com_setscale.h src/frontend/commands.c src/frontend/commands.h src/frontend/completion.h src/frontend/streams.h src/frontend/testcommands.c: Separation into different com_* commands. This is a start. The rest of the subdirectory needs doing. * src/include/complex.h src/include/cpdefs.h src/include/cpextern.h src/include/cpstd.h src/include/fteconst.h src/include/ftedata.h src/include/ftedev.h src/include/fteext.h src/include/ftegraph.h src/include/fteparse.h src/include/dvec.h src/include/grid.h src/include/plot.h src/include/pnode.h src/include/sim.h src/include/variable.h src/include/wordlist.h src/include/bool.h: Separation of header files into smaller pieces. This limits recompilation to only the affected source files. The original header files have a warning message embedded to flag obsoleted use. * src/frontend/compose.c src/frontend/compose.h src/frontend/nutctab.c src/frontend/nutctab.h src/frontend/plot5.c src/frontend/plot5.h src/frontend/spcmdtab.c src/frontend/x11.c src/frontend/x11.h src/frontend/xgraph.c src/frontend/xgraph.h: Moved these files into src/frontend/plotting subdirectory. * src/frontend/plotting/.cvsignore src/frontend/plotting/Makefile.am src/frontend/plotting/plot5.c src/frontend/plotting/plot5.h src/frontend/plotting/plotting.c src/frontend/plotting/plotting.h src/frontend/plotting/pvec.c src/frontend/plotting/pvec.h src/frontend/plotting/x11.c src/frontend/plotting/x11.h src/frontend/plotting/xgraph.c src/frontend/plotting/xgraph.h: The new libplotting library with automake and CVS infrastructure.
2000-05-06 16:12:51 +02:00
static void gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny);
2001-02-09 20:46:36 +01:00
static int gen_Input(REQUEST *request, RESPONSE *response);
2000-04-27 22:03:57 +02:00
static int nop(void);
#define NOP ((void *)nop)
2000-04-27 22:03:57 +02:00
static int nodev(void);
#define NODEV ((void *)nodev)
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
#ifndef X_DISPLAY_MISSING
#include "plotting/x11.h"
2000-04-27 22:03:57 +02:00
#endif
#ifdef HAS_WINGUI /* Graphic-IO under MS Windows */
#include "wdisp/windisp.h"
2011-05-21 14:44:27 +02:00
//#include "wdisp/winprint.h"
2002-01-03 23:44:21 +01:00
#endif
2000-04-27 22:03:57 +02:00
#include "plotting/plot5.h"
#include "postsc.h"
#include "hpgl.h"
#include "svg.h"
2000-04-27 22:03:57 +02:00
DISPDEVICE device[] = {
2012-08-08 18:54:52 +02:00
{ "error", 0, 0, 0, 0, 0, 0,
(disp_fn_Init_t *) NOP, (disp_fn_NewViewport_t *) NOP,
(disp_fn_Close_t *) NOP, (disp_fn_Clear_t *) NOP,
(disp_fn_DrawLine_t *) NOP, (disp_fn_Arc_t *) NOP, (disp_fn_Text_t *) NOP,
(disp_fn_DefineColor_t *) NOP, (disp_fn_DefineLinestyle_t *) NOP,
(disp_fn_SetLinestyle_t *) NOP, (disp_fn_SetColor_t *) NOP, (disp_fn_Update_t *) NOP, (disp_fn_Finalize_t *) NOP,
(disp_fn_Track_t *) NOP, (disp_fn_MakeMenu_t *) NOP, (disp_fn_MakeDialog_t *) NOP, gen_Input,
(disp_fn_DatatoScreen_t *) NOP,},
2000-04-27 22:03:57 +02:00
#ifndef X_DISPLAY_MISSING
2012-08-08 18:54:52 +02:00
{ "X11", 0, 0, 1024, 864, 0, 0,
X11_Init, X11_NewViewport,
X11_Close, X11_Clear,
X11_DrawLine, X11_Arc, X11_Text,
X11_DefineColor, X11_DefineLinestyle,
X11_SetLinestyle, X11_SetColor, X11_Update, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, X11_Input,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen,},
2000-04-27 22:03:57 +02:00
#endif
#ifdef HAS_WINGUI /* Graphic-IO under MS Windows */
2012-08-08 18:54:52 +02:00
{ "Windows", 0, 0, 1000, 1000, 0, 0,
WIN_Init, WIN_NewViewport,
WIN_Close, WIN_Clear,
WIN_DrawLine, WIN_Arc, WIN_Text,
WIN_DefineColor, WIN_DefineLinestyle,
WIN_SetLinestyle, WIN_SetColor, WIN_Update, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, gen_Input,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen, }, /* WIN_DiagramReady */
2002-01-03 23:44:21 +01:00
/* Warning: name "WinPrint" do not change! */
2012-08-08 18:54:52 +02:00
{ "WinPrint", 0, 0, 1000, 1000, 0, 0,
WPRINT_Init, WPRINT_NewViewport,
WPRINT_Close, WPRINT_Clear,
WPRINT_DrawLine, WPRINT_Arc, WPRINT_Text,
WPRINT_DefineColor, WPRINT_DefineLinestyle,
WPRINT_SetLinestyle, WPRINT_SetColor, WPRINT_Update, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, (disp_fn_Input_t *) NODEV,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen, }, /* WPRINT_DiagramReady */
2002-01-03 23:44:21 +01:00
#endif
#ifdef TCL_MODULE
2012-08-08 18:54:52 +02:00
{ "Tk", 0, 0, 1024, 864, 0, 0,
sp_Tk_Init, sp_Tk_NewViewport,
sp_Tk_Close, sp_Tk_Clear,
sp_Tk_DrawLine, sp_Tk_Arc, sp_Tk_Text,
sp_Tk_DefineColor, sp_Tk_DefineLinestyle,
sp_Tk_SetLinestyle, sp_Tk_SetColor, sp_Tk_Update, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, (disp_fn_Input_t *) NODEV,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen, },
#endif
2012-08-08 18:54:52 +02:00
{ "plot5", 0, 0, 1000, 1000, 0, 0,
Plt5_Init, Plt5_NewViewport,
Plt5_Close, Plt5_Clear,
Plt5_DrawLine, Plt5_Arc, Plt5_Text,
(disp_fn_DefineColor_t *) NODEV, (disp_fn_DefineLinestyle_t *) NODEV,
Plt5_SetLinestyle, Plt5_SetColor, Plt5_Update, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, (disp_fn_Input_t *) NODEV,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen, },
{ "postscript", 0, 0, 1000, 1000, 0, 0,
PS_Init, PS_NewViewport,
PS_Close, PS_Clear,
PS_DrawLine, PS_Arc, PS_Text,
(disp_fn_DefineColor_t *) NODEV, (disp_fn_DefineLinestyle_t *) NODEV,
PS_SetLinestyle, PS_SetColor, PS_Update, PS_Finalize,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, (disp_fn_Input_t *) NODEV,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen, },
{ "svg", 0, 0, 1000, 1000, 0, 0,
SVG_Init, SVG_NewViewport,
SVG_Close, SVG_Clear,
SVG_DrawLine, SVG_Arc, SVG_Text,
(disp_fn_DefineColor_t*)NODEV, (disp_fn_DefineLinestyle_t*)NODEV,
SVG_SetLinestyle, SVG_SetColor, SVG_Update, SVG_Finalize,
(disp_fn_Track_t*)NODEV, (disp_fn_MakeMenu_t*)NODEV, (disp_fn_MakeDialog_t*)NODEV, (disp_fn_Input_t*)NODEV,
gen_DatatoScreen, },
2012-08-08 18:54:52 +02:00
{ "hpgl", 0, 0, 1000, 1000, 0, 0,
GL_Init, GL_NewViewport,
GL_Close, GL_Clear,
GL_DrawLine, GL_Arc, GL_Text,
(disp_fn_DefineColor_t *) NODEV, (disp_fn_DefineLinestyle_t *) NODEV,
GL_SetLinestyle, GL_SetColor, GL_Update, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, (disp_fn_Input_t *) NODEV,
2012-08-08 18:54:52 +02:00
gen_DatatoScreen, },
{ "PrinterOnly", 0, 0, 24, 80, 0, 0,
(disp_fn_Init_t *) NODEV, (disp_fn_NewViewport_t *) NODEV,
(disp_fn_Close_t *) NOP, (disp_fn_Clear_t *) NODEV,
(disp_fn_DrawLine_t *) NODEV, (disp_fn_Arc_t *) NODEV, (disp_fn_Text_t *) NODEV,
(disp_fn_DefineColor_t *) NODEV, (disp_fn_DefineLinestyle_t *) NODEV,
(disp_fn_SetLinestyle_t *) NODEV, (disp_fn_SetColor_t *) NODEV, (disp_fn_Update_t *) NOP, (disp_fn_Finalize_t*) NOP,
(disp_fn_Track_t *) NODEV, (disp_fn_MakeMenu_t *) NODEV, (disp_fn_MakeDialog_t *) NODEV, gen_Input,
(disp_fn_DatatoScreen_t *) NODEV, },
2000-04-27 22:03:57 +02:00
};
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
DISPDEVICE *dispdev = device + NUMELEMS(device) - 1;
2012-08-08 18:54:52 +02:00
DISPDEVICE *
FindDev(char *name)
2000-04-27 22:03:57 +02:00
{
2012-08-08 18:54:52 +02:00
size_t i;
for (i = 0; i < NUMELEMS(device); i++)
2012-08-08 18:54:52 +02:00
if (strcmp(name, device[i].name) == 0)
return (device + i);
2000-04-27 22:03:57 +02:00
sprintf(ErrorMessage, "Can't find device %s.", name);
internalerror(ErrorMessage);
return (device + 0);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
void
DevInit(void)
{
2012-08-08 18:54:52 +02:00
#ifndef X_DISPLAY_MISSING
2012-08-08 18:54:52 +02:00
char buf[128];
#endif
2000-04-27 22:03:57 +02:00
2012-08-08 18:54:52 +02:00
/* note: do better determination */
2000-04-27 22:03:57 +02:00
2012-08-08 18:54:52 +02:00
/*
dumb tradition that got passed on from gi_interface
to do compile time determination
*/
2000-04-27 22:03:57 +02:00
dispdev = NULL;
#ifndef X_DISPLAY_MISSING
/* determine display type */
if (getenv("DISPLAY") || cp_getvar("display", CP_STRING, buf, sizeof(buf)))
2012-08-08 18:54:52 +02:00
dispdev = FindDev("X11");
2000-04-27 22:03:57 +02:00
#endif
#ifdef HAS_WINGUI
2012-08-08 18:54:52 +02:00
if (!dispdev)
dispdev = FindDev("Windows");
2002-01-03 23:44:21 +01:00
#endif
2000-04-27 22:03:57 +02:00
2012-08-08 18:54:52 +02:00
#ifdef TCL_MODULE
dispdev = FindDev("Tk");
#endif
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
if (!dispdev) {
2012-08-08 18:54:52 +02:00
#if !defined(HAS_WINGUI) && !defined(TCL_MODULE) && !defined(SHARED_MODULE) && (defined(_MSC_VER) || defined(__MINGW32__))
2012-08-08 18:54:52 +02:00
/* console application under MS Windows */
fprintf
(cp_err,
"Warning: no graphics interface!\n"
" You may use command 'gnuplot'\n"
" if GnuPlot is installed.\n");
#elif !defined(X_DISPLAY_MISSING)
2012-08-08 18:54:52 +02:00
externalerror
("no graphics interface;\n"
" please check if X-server is running,\n"
" or ngspice is compiled properly (see INSTALL)");
#endif
2012-08-08 18:54:52 +02:00
dispdev = FindDev("error");
2012-08-08 18:54:52 +02:00
2011-04-27 20:30:15 +02:00
} else if (dispdev->Init()) {
2012-08-08 18:54:52 +02:00
fprintf(cp_err, "Warning: can't initialize display device for graphics.\n");
dispdev = FindDev("error");
2000-04-27 22:03:57 +02:00
}
}
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
/* NewViewport is responsible for filling in graph->viewport */
int
NewViewport(GRAPH *pgraph)
{
2011-04-27 20:30:15 +02:00
return dispdev->NewViewport (pgraph);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DevClose(void)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->Close();
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DevClear(void)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->Clear();
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DevDrawLine(int x1, int y1, int x2, int y2, bool isgrid)
2000-04-27 22:03:57 +02:00
{
dispdev->DrawLine (x1, y1, x2, y2, isgrid);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DevDrawArc(int x0, int y0, int radius, double theta, double delta_theta, bool isgrid)
2000-04-27 22:03:57 +02:00
{
dispdev->DrawArc (x0, y0, radius, theta, delta_theta, isgrid);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void DevDrawText(const char *text, int x, int y, int angle)
2000-04-27 22:03:57 +02:00
{
dispdev->DrawText(text, x, y, angle);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DefineColor(int colorid, double red, double green, double blue)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->DefineColor (colorid, red, green, blue);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DefineLinestyle(int linestyleid, int mask)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->DefineLinestyle (linestyleid, mask);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
SetLinestyle(int linestyleid)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->SetLinestyle (linestyleid);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
SetColor(int colorid)
2000-04-27 22:03:57 +02:00
{
dispdev->SetColor(colorid);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
DevUpdate(void)
2000-04-27 22:03:57 +02:00
{
if (dispdev)
2012-08-08 18:54:52 +02:00
dispdev->Update();
2000-04-27 22:03:57 +02:00
}
void
DevFinalize(void)
{
if (dispdev)
dispdev->Finalize();
}
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
/* note: screen coordinates are relative to window
2012-08-08 18:54:52 +02:00
so need to add viewport offsets */
* src/Makefile.am src/main.c src/sconvert.c src/analysis/cktdisto.c src/analysis/cktnoise.c src/analysis/noisean.c: Updates for the new header files. * src/maths/cmaths/cmath1.c src/maths/cmaths/cmath2.c src/maths/cmaths/cmath3.c src/maths/cmaths/cmath4.c: Updates for the new header files. * src/frontend/.cvsignore src/frontend/Makefile.am: Updates for the new files. * src/frontend/agraf.c src/frontend/aspice.c src/frontend/breakp.c src/frontend/breakp2.c src/frontend/circuits.c src/frontend/cpitf.c src/frontend/debugcom.c src/frontend/define.c src/frontend/diff.c src/frontend/dimens.c src/frontend/display.c src/frontend/doplot.c src/frontend/dotcards.c src/frontend/evaluate.c src/frontend/fourier.c src/frontend/graf.c src/frontend/grid.c src/frontend/inp.c src/frontend/inpcom.c src/frontend/interp.c src/frontend/linear.c src/frontend/misccoms.c src/frontend/misccoms.h src/frontend/miscvars.c src/frontend/mw_coms.c src/frontend/newcoms.c src/frontend/nutinp.c src/frontend/options.c src/frontend/outitf.c src/frontend/parse.c src/frontend/plotcurv.c src/frontend/points.c src/frontend/postcoms.c src/frontend/rawfile.c src/frontend/runcoms.c src/frontend/runcoms2.c src/frontend/shyu.c src/frontend/spec.c src/frontend/spiceif.c src/frontend/typesdef.c src/frontend/vectors.c src/frontend/where.c src/frontend/postcoms.c: Updates for the new header files. Some commands have moved into the new files below. * src/frontend/README src/frontend/com_compose.c src/frontend/com_compose.h src/frontend/com_display.c src/frontend/com_display.h src/frontend/com_let.c src/frontend/com_let.h src/frontend/com_setscale.c src/frontend/com_setscale.h src/frontend/commands.c src/frontend/commands.h src/frontend/completion.h src/frontend/streams.h src/frontend/testcommands.c: Separation into different com_* commands. This is a start. The rest of the subdirectory needs doing. * src/include/complex.h src/include/cpdefs.h src/include/cpextern.h src/include/cpstd.h src/include/fteconst.h src/include/ftedata.h src/include/ftedev.h src/include/fteext.h src/include/ftegraph.h src/include/fteparse.h src/include/dvec.h src/include/grid.h src/include/plot.h src/include/pnode.h src/include/sim.h src/include/variable.h src/include/wordlist.h src/include/bool.h: Separation of header files into smaller pieces. This limits recompilation to only the affected source files. The original header files have a warning message embedded to flag obsoleted use. * src/frontend/compose.c src/frontend/compose.h src/frontend/nutctab.c src/frontend/nutctab.h src/frontend/plot5.c src/frontend/plot5.h src/frontend/spcmdtab.c src/frontend/x11.c src/frontend/x11.h src/frontend/xgraph.c src/frontend/xgraph.h: Moved these files into src/frontend/plotting subdirectory. * src/frontend/plotting/.cvsignore src/frontend/plotting/Makefile.am src/frontend/plotting/plot5.c src/frontend/plotting/plot5.h src/frontend/plotting/plotting.c src/frontend/plotting/plotting.h src/frontend/plotting/pvec.c src/frontend/plotting/pvec.h src/frontend/plotting/x11.c src/frontend/plotting/x11.h src/frontend/plotting/xgraph.c src/frontend/plotting/xgraph.h: The new libplotting library with automake and CVS infrastructure.
2000-05-06 16:12:51 +02:00
static void
2000-04-27 22:03:57 +02:00
gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny)
{
double low, high;
/* note: may want to cache datawindowsize/viewportsize */ /* done */
/* note: think this out---Is 1 part of the viewport? Do we handle
2012-08-08 18:54:52 +02:00
this correctly? */
2000-04-27 22:03:57 +02:00
/* have to handle several types of grids */
/* note: we can't compensate for X's demented y-coordinate system here
2012-08-08 18:54:52 +02:00
since the grid routines use DevDrawLine w/o calling this routine */
2000-04-27 22:03:57 +02:00
if ((graph->grid.gridtype == GRID_LOGLOG) ||
2012-08-08 18:54:52 +02:00
(graph->grid.gridtype == GRID_YLOG))
{
low = mylog10(graph->datawindow.ymin);
high = mylog10(graph->datawindow.ymax);
*screeny = (int)((mylog10(y) - low) / (high - low) * graph->viewport.height
+ 0.5 + graph->viewportyoff);
2000-04-27 22:03:57 +02:00
} else {
2012-08-08 18:54:52 +02:00
*screeny = (int)(((y - graph->datawindow.ymin) / graph->aspectratioy)
+ 0.5 + graph->viewportyoff);
2000-04-27 22:03:57 +02:00
}
if ((graph->grid.gridtype == GRID_LOGLOG) ||
2012-08-08 18:54:52 +02:00
(graph->grid.gridtype == GRID_XLOG))
{
low = mylog10(graph->datawindow.xmin);
high = mylog10(graph->datawindow.xmax);
*screenx = (int)((mylog10(x) - low) / (high - low) * graph->viewport.width
+ 0.5 + graph ->viewportxoff);
2000-04-27 22:03:57 +02:00
} else {
2012-08-08 18:54:52 +02:00
*screenx = (int)((x - graph->datawindow.xmin) / graph->aspectratiox
+ 0.5 + graph ->viewportxoff);
2000-04-27 22:03:57 +02:00
}
}
2012-08-08 18:54:52 +02:00
void
DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->DatatoScreen (graph, x, y, screenx, screeny);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
Input(REQUEST *request, RESPONSE *response)
2000-04-27 22:03:57 +02:00
{
2011-04-27 20:30:15 +02:00
dispdev->Input (request, response);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
2001-02-09 20:46:36 +01:00
static int
2000-04-27 22:03:57 +02:00
gen_Input(REQUEST *request, RESPONSE *response)
{
switch (request->option) {
2012-08-08 18:54:52 +02:00
case char_option:
if (response)
response->option = request->option;
2000-04-27 22:03:57 +02:00
break;
2012-08-08 18:54:52 +02:00
default:
2000-04-27 22:03:57 +02:00
/* just ignore, since we don't want a million error messages */
2012-08-08 18:54:52 +02:00
if (response)
response->option = error_option;
2000-04-27 22:03:57 +02:00
break;
}
2012-08-08 18:54:52 +02:00
return (0);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
/* no operation, do nothing */
static int
nop(void)
2000-04-27 22:03:57 +02:00
{
return (1); /* so NewViewport will fail */
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
static int
nodev(void)
2000-04-27 22:03:57 +02:00
{
sprintf(ErrorMessage,
2012-08-08 18:54:52 +02:00
"This operation is not defined for display type %s.",
dispdev->name);
2000-04-27 22:03:57 +02:00
internalerror(ErrorMessage);
return (1);
2000-04-27 22:03:57 +02:00
}
2012-08-08 18:54:52 +02:00
void
SaveText(GRAPH *graph, char *text, int x, int y)
2000-04-27 22:03:57 +02:00
{
2012-08-08 18:54:52 +02:00
struct _keyed *keyed = TMALLOC(struct _keyed, 1);
2000-04-27 22:03:57 +02:00
if (!graph->keyed) {
2012-08-08 18:54:52 +02:00
graph->keyed = keyed;
2000-04-27 22:03:57 +02:00
} else {
2012-08-08 18:54:52 +02:00
keyed->next = graph->keyed;
graph->keyed = keyed;
2000-04-27 22:03:57 +02:00
}
keyed->text = TMALLOC(char, strlen(text) + 1);
2000-04-27 22:03:57 +02:00
strcpy(keyed->text, text);
keyed->x = x;
keyed->y = y;
keyed->colorindex = graph->currentcolor;
}
2012-08-08 18:54:52 +02:00
2000-04-27 22:03:57 +02:00
/* if given name of a hardcopy device, finds it and switches devices
if given NULL, switches back */
int
DevSwitch(char *devname)
2000-04-27 22:03:57 +02:00
{
static DISPDEVICE *lastdev = NULL;
2012-08-08 18:54:52 +02:00
if (devname) {
if (lastdev) {
internalerror("DevSwitch w/o changing back");
return (1);
}
lastdev = dispdev;
dispdev = FindDev(devname);
if (!strcmp(dispdev->name, "error")) {
internalerror("no hardcopy device");
/* undo */
dispdev = lastdev;
lastdev = NULL;
return (1);
}
dispdev->Init();
2000-04-27 22:03:57 +02:00
} else {
2012-08-08 18:54:52 +02:00
if (dispdev)
dispdev->Close();
2012-08-08 18:54:52 +02:00
dispdev = lastdev;
lastdev = NULL;
2000-04-27 22:03:57 +02:00
}
return (0);
2000-04-27 22:03:57 +02:00
}