const qualifier, graph removed from SetColor,
This commit is contained in:
parent
a3a8bc702d
commit
3a72b8e562
|
|
@ -19,11 +19,11 @@ void DevClose(void);
|
|||
void DevClear(void);
|
||||
void DevDrawLine(int x1, int y1, int x2, int y2, bool isgrid);
|
||||
void DevDrawArc(int x0, int y0, int radius, double theta, double delta_theta);
|
||||
void DevDrawText(char *text, int x, int y, int angle);
|
||||
void DevDrawText(const char *text, int x, int y, int angle);
|
||||
void DefineColor(int colorid, double red, double green, double blue);
|
||||
void DefineLinestyle(int linestyleid, int mask);
|
||||
void SetLinestyle(int linestyleid);
|
||||
void SetColor(int colorid, GRAPH* graph);
|
||||
void SetColor(int colorid);
|
||||
void DevUpdate(void);
|
||||
void DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny);
|
||||
void Input(REQUEST *request, RESPONSE *response);
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ int GL_Arc(int x0, int y0, int r, double theta, double delta_theta)
|
|||
}
|
||||
|
||||
|
||||
int GL_Text(char *text, int x, int y, int angle)
|
||||
int GL_Text(const char *text, int x, int y, int angle)
|
||||
{
|
||||
NG_IGNORE(angle);
|
||||
|
||||
|
|
@ -291,9 +291,8 @@ int GL_SetLinestyle(int linestyleid)
|
|||
}
|
||||
|
||||
|
||||
int GL_SetColor(int colorid, GRAPH* graph)
|
||||
int GL_SetColor(int colorid)
|
||||
{
|
||||
NG_IGNORE(graph);
|
||||
fprintf(plotfile, "SP %d;", colorid);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ quote_gnuplot_string(FILE *stream, char *s)
|
|||
fputc('"', stream);
|
||||
|
||||
for (; *s; s++)
|
||||
/* NOTE: The FALLTHROUGH comment is used to suppress a GCC warning
|
||||
* when flag -Wimplicit-fallthrough is present */
|
||||
switch (*s) {
|
||||
case '\n':
|
||||
fputs("\\n", stream);
|
||||
|
|
@ -38,6 +40,7 @@ quote_gnuplot_string(FILE *stream, char *s)
|
|||
case '"':
|
||||
case '\\':
|
||||
fputc('\\', stream);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
fputc(*s, stream);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ void gr_point(struct dvec *dv,
|
|||
return;
|
||||
}
|
||||
}
|
||||
SetColor(dv->v_color, currentgraph);
|
||||
SetColor(dv->v_color);
|
||||
|
||||
switch (currentgraph->plottype) {
|
||||
double *tics;
|
||||
|
|
@ -477,7 +477,7 @@ void drawlegend(GRAPH *graph, int plotno, struct dvec *dv)
|
|||
const int y = graph->absolute.height - graph->fontheight
|
||||
- ((plotno + 2) / 2) * (graph->fontheight);
|
||||
const int i = y + graph->fontheight / 2 + 1;
|
||||
SetColor(dv->v_color, graph);
|
||||
SetColor(dv->v_color);
|
||||
if (graph->plottype == PLOT_POINT) {
|
||||
char buf[16];
|
||||
(void) sprintf(buf, "%c : ", dv->v_linestyle);
|
||||
|
|
@ -487,7 +487,7 @@ void drawlegend(GRAPH *graph, int plotno, struct dvec *dv)
|
|||
SetLinestyle(dv->v_linestyle);
|
||||
DevDrawLine(x, i, x + graph->viewport.width / 20, i, FALSE);
|
||||
}
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
DevDrawText(dv->v_name, x + graph->viewport.width / 20
|
||||
+ graph->fontwidth, y, 0);
|
||||
}
|
||||
|
|
@ -641,7 +641,7 @@ void gr_restoretext(GRAPH *graph)
|
|||
|
||||
/* restore text */
|
||||
for (k = graph->keyed; k; k = k->next) {
|
||||
SetColor(k->colorindex, graph);
|
||||
SetColor(k->colorindex);
|
||||
DevDrawText(k->text, k->x, k->y, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -738,7 +738,7 @@ static int iplot(struct plot *pl, int id)
|
|||
|
||||
for (yt = pl->pl_dvecs->v_type, v = pl->pl_dvecs->v_next; v;
|
||||
v = v->v_next) {
|
||||
if ((v->v_flags & VF_PLOT) && (v->v_type != yt)) {
|
||||
if ((v->v_flags & VF_PLOT) && ((int) v->v_type != yt)) {
|
||||
yt = SV_NOTYPE;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ gr_fixgrid(GRAPH *graph, double xdelta, double ydelta, int xtype, int ytype)
|
|||
if (graph->grid.gridtype == GRID_NONE)
|
||||
graph->grid.gridtype = GRID_LIN;
|
||||
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
SetLinestyle(1);
|
||||
|
||||
if ((graph->data.xmin > graph->data.xmax) ||
|
||||
|
|
@ -132,7 +132,7 @@ void
|
|||
gr_redrawgrid(GRAPH *graph)
|
||||
{
|
||||
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
SetLinestyle(1);
|
||||
/* draw labels */
|
||||
if (graph->grid.xlabel) {
|
||||
|
|
@ -182,10 +182,10 @@ gr_redrawgrid(GRAPH *graph)
|
|||
#ifdef HAS_WINGUI
|
||||
/* x axis centered to graphics on Windows */
|
||||
/* utf-8: figure out the real length of the x label */
|
||||
const int n_byte_wide = 2 * (int)strlen(graph->grid.xlabel) + 1;
|
||||
wchar_t* const wtext = TMALLOC(wchar_t, n_byte_wide);
|
||||
const int n_byte_wide = 2 * (int) strlen(graph->grid.xlabel) + 1;
|
||||
wchar_t * const wtext = TMALLOC(wchar_t, n_byte_wide);
|
||||
int wlen = MultiByteToWideChar(CP_UTF8, 0, graph->grid.xlabel, -1,
|
||||
wtext, n_byte_wide);
|
||||
wtext, n_byte_wide);
|
||||
if (wlen == 0) {
|
||||
fprintf(stderr, "UTF-8 to wide char conversion failed with 0x%x\n", GetLastError());
|
||||
fprintf(stderr, "%s could not be converted\n", graph->grid.xlabel);
|
||||
|
|
@ -223,27 +223,34 @@ gr_redrawgrid(GRAPH *graph)
|
|||
(graph->absolute.height * 3) / 4, 0);
|
||||
} else {
|
||||
|
||||
if (eq(dispdev->name, "postscript"))
|
||||
DevDrawText(graph->grid.ylabel,
|
||||
if (eq(dispdev->name, "postscript")) {
|
||||
DevDrawText(graph->grid.ylabel,
|
||||
graph->fontwidth,
|
||||
/*vertical text, midpoint in y is aligned midpoint of text string */
|
||||
(graph->absolute.height - (int)strlen(graph->grid.ylabel) * graph->fontwidth) / 2, 90);
|
||||
/* vertical text, midpoint in y is aligned midpoint
|
||||
* of text string */
|
||||
(graph->absolute.height - (int) strlen(
|
||||
graph->grid.ylabel) * graph->fontwidth) / 2,
|
||||
90);
|
||||
}
|
||||
#ifdef EXT_ASC
|
||||
else if (eq(dispdev->name, "Windows"))
|
||||
DevDrawText(graph->grid.ylabel,
|
||||
graph->fontwidth,
|
||||
/*vertical text, midpoint in y is aligned midpoint of text string */
|
||||
(graph->absolute.height - (int)strlen(graph->grid.ylabel) * graph->fontwidth) / 2, 90);
|
||||
/* vertical text, midpoint in y is aligned midpoint
|
||||
* of text string */
|
||||
(graph->absolute.height - (int) strlen(
|
||||
graph->grid.ylabel) * graph->fontwidth) / 2,
|
||||
90);
|
||||
#else
|
||||
#ifdef HAS_WINGUI
|
||||
/* Windows and UTF-8: check for string length (in pixels),
|
||||
place vertical text centered in y with respect to grid */
|
||||
else if (eq(dispdev->name, "Windows")) {
|
||||
/* utf-8: figure out the real length of the y label */
|
||||
const int n_byte_wide = 2 * (int)strlen(graph->grid.ylabel) + 1;
|
||||
wchar_t* const wtext = TMALLOC(wchar_t, n_byte_wide);
|
||||
const int n_byte_wide = 2 * (int) strlen(graph->grid.ylabel) + 1;
|
||||
wchar_t * const wtext = TMALLOC(wchar_t, n_byte_wide);
|
||||
int wlen = MultiByteToWideChar(CP_UTF8, 0, graph->grid.ylabel, -1,
|
||||
wtext, n_byte_wide);
|
||||
wtext, n_byte_wide);
|
||||
if (wlen == 0) {
|
||||
fprintf(stderr, "UTF-8 to wide char conversion failed with 0x%x\n", GetLastError());
|
||||
fprintf(stderr, "%s could not be converted\n", graph->grid.ylabel);
|
||||
|
|
@ -1481,7 +1488,7 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d
|
|||
/* Let's be lazy and just draw everything -- we won't get called too
|
||||
* much and the circles get clipped anyway...
|
||||
*/
|
||||
SetColor(18, graph);
|
||||
SetColor(18);
|
||||
|
||||
cliparc((double) (centx + xoffset + radoff - rad),
|
||||
(double) (centy + yoffset), rad, 2*angle,
|
||||
|
|
@ -1495,7 +1502,7 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d
|
|||
M_PI - 2 * angle, centx, centy, maxrad, 0);
|
||||
|
||||
/* Draw the upper and lower circles. */
|
||||
SetColor(19, graph);
|
||||
SetColor(19);
|
||||
aclip = cliparc((double) (centx + xoffset + radoff),
|
||||
(double) (centy + yoffset + irad), irad,
|
||||
(double) (M_PI * 1.5 + 2 * iangle),
|
||||
|
|
@ -1504,7 +1511,7 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d
|
|||
xlab = (int)(centx + xoffset + radoff + irad * cos(aclip));
|
||||
ylab = (int)(centy + yoffset + irad * (1 + sin(aclip)));
|
||||
if ((ylab - gr_ycenter) > graph->fontheight) {
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
adddeglabel(graph, pdeg, xlab, ylab,
|
||||
gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter);
|
||||
/*
|
||||
|
|
@ -1512,7 +1519,7 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d
|
|||
adddeglabel(graph, ndeg, xlab, ylab,
|
||||
gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter);
|
||||
*/
|
||||
SetColor(19, graph);
|
||||
SetColor(19);
|
||||
}
|
||||
}
|
||||
aclip = cliparc((double) (centx + xoffset + radoff),
|
||||
|
|
@ -1523,14 +1530,14 @@ arcset(GRAPH *graph, double rad, double prevrad, double irad, double iprevrad, d
|
|||
if ((aclip >= 0 && aclip < 2*M_PI - M_PI/180) && (pdeg < 359)) {
|
||||
xlab = (int)(centx + xoffset + radoff + irad * cos(aclip));
|
||||
ylab = (int)(centy + yoffset + irad * (sin(aclip) - 1));
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
adddeglabel(graph, ndeg, xlab, ylab,
|
||||
gr_xcenter, gr_ycenter, gr_xcenter, gr_ycenter);
|
||||
SetColor(19, graph);
|
||||
SetColor(19);
|
||||
}
|
||||
|
||||
/* Now toss the labels on... */
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
|
||||
x = centx + xoffset + (int)radoff - 2 * (int)rad -
|
||||
gi_fntwidth * (int) strlen(plab) - 2;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ int Plt5_Arc(int xc, int yc, int radius, double theta, double delta_theta)
|
|||
}
|
||||
|
||||
|
||||
int Plt5_Text(char *text, int x, int y, int angle)
|
||||
int Plt5_Text(const char *text, int x, int y, int angle)
|
||||
{
|
||||
int savedlstyle;
|
||||
NG_IGNORE(angle);
|
||||
|
|
@ -211,10 +211,9 @@ int Plt5_SetLinestyle(int linestyleid)
|
|||
|
||||
/* ARGSUSED */
|
||||
|
||||
int Plt5_SetColor(int colorid, GRAPH *graph)
|
||||
int Plt5_SetColor(int colorid)
|
||||
{
|
||||
NG_IGNORE(colorid);
|
||||
NG_IGNORE(graph);
|
||||
|
||||
/* do nothing */
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -27,18 +27,6 @@ static char *xlabel = NULL, *ylabel = NULL, *title = NULL;
|
|||
#include "ngspice/tclspice.h"
|
||||
#endif
|
||||
|
||||
/* remove the malloced parameters upon ngspice quit */
|
||||
void pl_rempar(void)
|
||||
{
|
||||
txfree(xcompress);
|
||||
txfree(xindices);
|
||||
txfree(xlim);
|
||||
txfree(ylim);
|
||||
txfree(xdelta);
|
||||
txfree(ydelta);
|
||||
txfree(xlabel);
|
||||
txfree(ylabel);
|
||||
}
|
||||
|
||||
static struct dvec *vec_self(struct dvec *v);
|
||||
static struct dvec *vec_scale(struct dvec *v);
|
||||
|
|
@ -48,6 +36,21 @@ static void find_axis_limits(double *lim, bool oneval, bool f_real,
|
|||
double *lims);
|
||||
|
||||
|
||||
/* Remove the malloced parameters upon ngspice quit. These are set to NULL
|
||||
* to allow the function to be used at any time and safely called more than
|
||||
* one time. */
|
||||
void pl_rempar(void)
|
||||
{
|
||||
tfree(xcompress);
|
||||
tfree(xindices);
|
||||
tfree(xlim);
|
||||
tfree(ylim);
|
||||
tfree(xdelta);
|
||||
tfree(ydelta);
|
||||
tfree(xlabel);
|
||||
tfree(ylabel);
|
||||
}
|
||||
|
||||
/* This routine gets parameters from the command line, which are of
|
||||
* the form "name number ..." It returns a pointer to the parameter
|
||||
* values.
|
||||
|
|
@ -286,7 +289,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
|||
struct pnode *pn, *names;
|
||||
struct dvec *d = NULL, *vecs = NULL, *lv, *lastvs = NULL;
|
||||
char *xn;
|
||||
int i, y_type, xt;
|
||||
int i, xt;
|
||||
wordlist *wwl;
|
||||
char *nxlabel = NULL, *nylabel = NULL, *ntitle = NULL;
|
||||
double tstep, tstart, tstop, ttime;
|
||||
|
|
@ -1070,7 +1073,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
|||
}
|
||||
}
|
||||
|
||||
y_type = d ? SV_NOTYPE : vecs->v_type;
|
||||
const int y_type = (int) (d ? SV_NOTYPE : vecs->v_type);
|
||||
|
||||
if (devname && eq(devname, "gnuplot")) {
|
||||
/* Interface to Gnuplot Plot Program */
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
#define ngspice_PLOTIT_H
|
||||
|
||||
bool plotit(wordlist *wl, const char *hcopy, const char *devname);
|
||||
|
||||
void pl_rempar(void);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ static void linear_arc(int x0, int y0, int radius, double theta, double delta_th
|
|||
static void slopelocation(GRAPH *graph, int x0, int y0);
|
||||
static void zoomin(GRAPH *graph);
|
||||
#ifdef HAVE_LIBXFT
|
||||
static int Xget_str_length(char *text, int* wlen, int* wheight, XftFont* gfont, char* name, int fsize);
|
||||
static int Xget_str_length(const char *text, int* wlen, int* wheight, XftFont* gfont, char* name, int fsize);
|
||||
static int X11_DefineXft(GRAPH *graph);
|
||||
#endif
|
||||
//XtEventHandler
|
||||
|
|
@ -237,7 +237,11 @@ initcolors(GRAPH *graph)
|
|||
"yellow", ""
|
||||
};
|
||||
|
||||
XColor visualcolor, exactcolor, bgcolor;
|
||||
XColor visualcolor, exactcolor;
|
||||
|
||||
/* Silence incorrect compiler warning about possibly not being init */
|
||||
XColor bgcolor = {0};
|
||||
|
||||
char buf[BSIZE_SP], colorstring[BSIZE_SP];
|
||||
int xmaxcolors = NUMCOLORS; /* note: can we get rid of this? */
|
||||
|
||||
|
|
@ -273,9 +277,9 @@ initcolors(GRAPH *graph)
|
|||
t3 = copy(tmpstr);
|
||||
if (t1 && t2 && t3) {
|
||||
double c1, c2, c3;
|
||||
c1 = strtol(t1, NULL, 10) / 255.;
|
||||
c2 = strtol(t2, NULL, 10) / 255.;
|
||||
c3 = strtol(t3, NULL, 10) / 255.;
|
||||
c1 = (double) strtol(t1, NULL, 10) / 255.;
|
||||
c2 = (double) strtol(t2, NULL, 10) / 255.;
|
||||
c3 = (double) strtol(t3, NULL, 10) / 255.;
|
||||
c1 = fmax(0., fmin(c1, 1.));
|
||||
c2 = fmax(0., fmin(c2, 1.));
|
||||
c3 = fmax(0., fmin(c3, 1.));
|
||||
|
|
@ -310,7 +314,8 @@ initcolors(GRAPH *graph)
|
|||
/* select grid color according to background color.
|
||||
Empirical selection using the color depth of the background */
|
||||
/* switch the grid and text color depending on background */
|
||||
int tcolor = (int)bgcolor.red + (int)(1.5 * bgcolor.green) + (int)bgcolor.blue;
|
||||
int tcolor = (int) bgcolor.red +
|
||||
(int) (1.5 * bgcolor.green) + (int) bgcolor.blue;
|
||||
if (tcolor > 92160) {
|
||||
graph->colorarray[1] = BlackPixel(display, DefaultScreen(display));
|
||||
strncpy(DEVDEP(graph).txtcolor, "black", 15);
|
||||
|
|
@ -351,7 +356,7 @@ handlekeypressed(Widget w, XtPointer client_data, XEvent *ev, Boolean *continue_
|
|||
/* write it */
|
||||
PushGraphContext(graph);
|
||||
text[nbytes] = '\0';
|
||||
SetColor(1, graph);
|
||||
SetColor(1);
|
||||
DevDrawText(text, keyev->x, graph->absolute.height - keyev->y, 0);
|
||||
/* save it */
|
||||
SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y);
|
||||
|
|
@ -652,7 +657,7 @@ X11_Close(void)
|
|||
int
|
||||
X11_DrawLine(int x1, int y1, int x2, int y2, bool isgrid)
|
||||
{
|
||||
if (DEVDEP(currentgraph).isopen)
|
||||
if (DEVDEP(currentgraph).isopen) {
|
||||
if (isgrid) {
|
||||
XDrawLine(display, DEVDEP(currentgraph).window,
|
||||
DEVDEP(currentgraph).gridgc,
|
||||
|
|
@ -665,6 +670,7 @@ X11_DrawLine(int x1, int y1, int x2, int y2, bool isgrid)
|
|||
x1, currentgraph->absolute.height - y1,
|
||||
x2, currentgraph->absolute.height - y2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -694,25 +700,26 @@ X11_Arc(int x0, int y0, int radius, double theta, double delta_theta)
|
|||
|
||||
/* note: x and y are the LOWER left corner of text */
|
||||
int
|
||||
X11_Text(char *text, int x, int y, int angle)
|
||||
X11_Text(const char *text, int x, int y, int angle)
|
||||
{
|
||||
/* We specify text position by lower left corner, so have to adjust for
|
||||
X11's font nonsense. */
|
||||
|
||||
int wlen = 0, wheight = 0;
|
||||
|
||||
#ifndef HAVE_LIBXFT
|
||||
if (DEVDEP(currentgraph).isopen)
|
||||
XDrawString(display, DEVDEP(currentgraph).window,
|
||||
DEVDEP(currentgraph).gc, x,
|
||||
currentgraph->absolute.height
|
||||
- (y + DEVDEP(currentgraph).font->max_bounds.descent),
|
||||
text, (int) strlen(text));
|
||||
if (DEVDEP(currentgraph).isopen) {
|
||||
if (angle != 0) {
|
||||
fprintf(stderr, " Xft: angles other than 0 are not supported\n");
|
||||
}
|
||||
XDrawString(display, DEVDEP(currentgraph).window,
|
||||
DEVDEP(currentgraph).gc, x,
|
||||
currentgraph->absolute.height
|
||||
- (y + DEVDEP(currentgraph).font->max_bounds.descent),
|
||||
text, (int) strlen(text));
|
||||
}
|
||||
|
||||
/* note: unlike before, we do not save any text here */
|
||||
/* note: unlike before, we do not save any text here */
|
||||
#else
|
||||
/* Draw text */
|
||||
if(angle == 0) {
|
||||
if (angle == 0) {
|
||||
XftDrawStringUtf8(
|
||||
DEVDEP(currentgraph).draw, &DEVDEP(currentgraph).color, DEVDEP(currentgraph).font0,
|
||||
x, currentgraph->absolute.height - y, (FcChar8*)text, strlen(text));
|
||||
|
|
@ -838,7 +845,7 @@ X11_SetLinestyle(int linestyleid)
|
|||
|
||||
|
||||
int
|
||||
X11_SetColor(int colorid, GRAPH *graph)
|
||||
X11_SetColor(int colorid)
|
||||
{
|
||||
currentgraph->currentcolor = colorid;
|
||||
XSetForeground(display, DEVDEP(currentgraph).gc,
|
||||
|
|
@ -1340,7 +1347,7 @@ linear_arc(int x0, int y0, int radius, double theta, double delta_theta)
|
|||
* to measure character string length.
|
||||
* Same as rotation below, but 0° angle */
|
||||
static int
|
||||
Xget_str_length(char *text, int* wlen, int* wheight, XftFont* gfont, char* foname, int fsize) {
|
||||
Xget_str_length(const char *text, int* wlen, int* wheight, XftFont* gfont, char* foname, int fsize) {
|
||||
XGlyphInfo extents;
|
||||
XftFont* hfont = NULL;
|
||||
/* if font name and font size are given */
|
||||
|
|
|
|||
Loading…
Reference in New Issue