switch to colorarray in graph to string all color data,
one set per each graph. If we are zooming or selecting a cutout, copy the source graph's colors to the new graph. Transfer the old graphs id to the new graph via graph->graphid.
This commit is contained in:
parent
0d4fe21269
commit
f1972850ec
|
|
@ -151,7 +151,6 @@ X11_Init(void)
|
||||||
|
|
||||||
XGCValues gcvalues;
|
XGCValues gcvalues;
|
||||||
|
|
||||||
/* grrr, Xtk forced contortions */
|
|
||||||
char *argv[2];
|
char *argv[2];
|
||||||
int argc = 2;
|
int argc = 2;
|
||||||
|
|
||||||
|
|
@ -245,11 +244,11 @@ initcolors(GRAPH *graph)
|
||||||
if (numdispplanes == 1) {
|
if (numdispplanes == 1) {
|
||||||
/* black and white */
|
/* black and white */
|
||||||
xmaxcolors = 2;
|
xmaxcolors = 2;
|
||||||
DEVDEP(graph).colors[0] = DEVDEP(graph).view->core.background_pixel;
|
graph->colorarray[0] = DEVDEP(graph).view->core.background_pixel;
|
||||||
if (DEVDEP(graph).colors[0] == WhitePixel(display, DefaultScreen(display)))
|
if (graph->colorarray[0] == WhitePixel(display, DefaultScreen(display)))
|
||||||
DEVDEP(graph).colors[1] = BlackPixel(display, DefaultScreen(display));
|
graph->colorarray[1] = BlackPixel(display, DefaultScreen(display));
|
||||||
else
|
else
|
||||||
DEVDEP(graph).colors[1] = WhitePixel(display, DefaultScreen(display));
|
graph->colorarray[1] = WhitePixel(display, DefaultScreen(display));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (numdispplanes < NXPLANES)
|
if (numdispplanes < NXPLANES)
|
||||||
|
|
@ -298,7 +297,7 @@ initcolors(GRAPH *graph)
|
||||||
(void) sprintf(ErrorMessage,
|
(void) sprintf(ErrorMessage,
|
||||||
"can't get color %s\n", colorstring);
|
"can't get color %s\n", colorstring);
|
||||||
externalerror(ErrorMessage);
|
externalerror(ErrorMessage);
|
||||||
DEVDEP(graph).colors[i] = i ? BlackPixel(display,
|
graph->colorarray[i] = i ? BlackPixel(display,
|
||||||
DefaultScreen(display))
|
DefaultScreen(display))
|
||||||
: WhitePixel(display, DefaultScreen(display));
|
: WhitePixel(display, DefaultScreen(display));
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -313,26 +312,24 @@ initcolors(GRAPH *graph)
|
||||||
/* switch the grid and text color depending on 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) {
|
if (tcolor > 92160) {
|
||||||
DEVDEP(graph).colors[1] = BlackPixel(display, DefaultScreen(display));
|
graph->colorarray[1] = BlackPixel(display, DefaultScreen(display));
|
||||||
strncpy(DEVDEP(graph).txtcolor, "black", 15);
|
strncpy(DEVDEP(graph).txtcolor, "black", 15);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEVDEP(graph).colors[1] = WhitePixel(display, DefaultScreen(display));
|
graph->colorarray[1] = WhitePixel(display, DefaultScreen(display));
|
||||||
strncpy(DEVDEP(graph).txtcolor, "white", 15);
|
strncpy(DEVDEP(graph).txtcolor, "white", 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEVDEP(graph).colors[i] = visualcolor.pixel;
|
graph->colorarray[i] = visualcolor.pixel;
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
strncpy(DEVDEP(graph).txtcolor, colorstring, 15);
|
strncpy(DEVDEP(graph).txtcolor, colorstring, 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* MW. Set Beackgroound here */
|
|
||||||
XSetWindowBackground(display, DEVDEP(graph).window, DEVDEP(graph).colors[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = xmaxcolors; i < NUMCOLORS; i++) {
|
for (i = xmaxcolors; i < NUMCOLORS; i++) {
|
||||||
DEVDEP(graph).colors[i] = DEVDEP(graph).colors[i + 1 - xmaxcolors];
|
graph->colorarray[i] = graph->colorarray[i + 1 - xmaxcolors];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -422,6 +419,7 @@ X11_NewViewport(GRAPH *graph)
|
||||||
XSetWindowAttributes w_attrs;
|
XSetWindowAttributes w_attrs;
|
||||||
XGCValues gcvalues;
|
XGCValues gcvalues;
|
||||||
XGCValues gridgcvalues;
|
XGCValues gridgcvalues;
|
||||||
|
GRAPH *pgraph = NULL;
|
||||||
|
|
||||||
static Arg formargs[ ] = {
|
static Arg formargs[ ] = {
|
||||||
{ XtNleft, (XtArgVal) XtChainLeft },
|
{ XtNleft, (XtArgVal) XtChainLeft },
|
||||||
|
|
@ -553,15 +551,34 @@ X11_NewViewport(GRAPH *graph)
|
||||||
XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity,
|
XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity,
|
||||||
&w_attrs);
|
&w_attrs);
|
||||||
|
|
||||||
int linewidth, gridwidth;
|
int linewidth, gridlinewidth;
|
||||||
|
/* If we had a previous graph, e.g. after zooming, we
|
||||||
|
have to set the background color already here, because
|
||||||
|
background is set below */
|
||||||
|
if (graph->mgraphid > 0) {
|
||||||
|
pgraph = FindGraph(graph->mgraphid);
|
||||||
|
}
|
||||||
|
/* get linewidth information from .spiceinit or .control section */
|
||||||
if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0))
|
if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth, 0))
|
||||||
gcvalues.line_width = MW_LINEWIDTH;
|
linewidth = MW_LINEWIDTH;
|
||||||
|
if (linewidth < 0)
|
||||||
|
linewidth = MW_LINEWIDTH;
|
||||||
|
if (pgraph)
|
||||||
|
gcvalues.line_width = graph->graphwidth = pgraph->graphwidth;
|
||||||
else
|
else
|
||||||
gcvalues.line_width = linewidth;
|
gcvalues.line_width = graph->graphwidth = linewidth;
|
||||||
if (!cp_getvar("gridwidth", CP_NUM, &gridwidth, 0))
|
|
||||||
gridgcvalues.line_width = MW_LINEWIDTH;
|
/* get linewidth information from .spiceinit or .control section */
|
||||||
|
if (!cp_getvar("gridwidth", CP_NUM, &gridlinewidth, 0))
|
||||||
|
gridlinewidth = MW_LINEWIDTH;
|
||||||
|
if (gridlinewidth < 0)
|
||||||
|
gridlinewidth = MW_LINEWIDTH;
|
||||||
|
|
||||||
|
if (pgraph)
|
||||||
|
gridgcvalues.line_width = graph->gridwidth = pgraph->gridwidth;
|
||||||
else
|
else
|
||||||
gridgcvalues.line_width = gridwidth;
|
gridgcvalues.line_width = graph->gridwidth = gridlinewidth;
|
||||||
|
|
||||||
gridgcvalues.cap_style = gcvalues.cap_style = CapNotLast;
|
gridgcvalues.cap_style = gcvalues.cap_style = CapNotLast;
|
||||||
gridgcvalues.function = gcvalues.function = GXcopy;
|
gridgcvalues.function = gcvalues.function = GXcopy;
|
||||||
#ifndef HAVE_LIBXFT
|
#ifndef HAVE_LIBXFT
|
||||||
|
|
@ -586,6 +603,15 @@ X11_NewViewport(GRAPH *graph)
|
||||||
initlinestyles();
|
initlinestyles();
|
||||||
initcolors(graph);
|
initcolors(graph);
|
||||||
|
|
||||||
|
/* we have a 'mother' graph and want to get its colors */
|
||||||
|
int i;
|
||||||
|
if(pgraph) {
|
||||||
|
for(i = 0; i < 25; i++)
|
||||||
|
graph->colorarray[i] = pgraph->colorarray[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
XSetWindowBackground(display, DEVDEP(graph).window, graph->colorarray[0]);
|
||||||
|
|
||||||
/* set up cursor */
|
/* set up cursor */
|
||||||
cursor = XCreateFontCursor(display, XC_left_ptr);
|
cursor = XCreateFontCursor(display, XC_left_ptr);
|
||||||
XDefineCursor(display, DEVDEP(graph).window, cursor);
|
XDefineCursor(display, DEVDEP(graph).window, cursor);
|
||||||
|
|
@ -738,7 +764,16 @@ int X11_DefineXft(GRAPH *graph)
|
||||||
|
|
||||||
Colormap cmap = DefaultColormap(display, 0);
|
Colormap cmap = DefaultColormap(display, 0);
|
||||||
XftColor color;
|
XftColor color;
|
||||||
XftColorAllocName(display, DefaultVisual(display, 0), cmap, DEVDEP(graph).txtcolor, &color);
|
XRenderColor rcolor;
|
||||||
|
XColor xxcolor;
|
||||||
|
/* pixel -> XColor -> XftColor */
|
||||||
|
xxcolor.pixel = graph->colorarray[1];
|
||||||
|
XQueryColor(display, cmap, &xxcolor);
|
||||||
|
rcolor.alpha = 65535;
|
||||||
|
rcolor.red = xxcolor.red;
|
||||||
|
rcolor.green = xxcolor.green;
|
||||||
|
rcolor.blue = xxcolor.blue;
|
||||||
|
XftColorAllocValue(display, DefaultVisual(display, 0), cmap, &rcolor, &color);
|
||||||
DEVDEP(graph).color = color;
|
DEVDEP(graph).color = color;
|
||||||
DEVDEP(graph).cmap = cmap;
|
DEVDEP(graph).cmap = cmap;
|
||||||
DEVDEP(graph).draw = XftDrawCreate(
|
DEVDEP(graph).draw = XftDrawCreate(
|
||||||
|
|
@ -803,13 +838,13 @@ X11_SetLinestyle(int linestyleid)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
X11_SetColor(int colorid)
|
X11_SetColor(int colorid, GRAPH *graph)
|
||||||
{
|
{
|
||||||
currentgraph->currentcolor = colorid;
|
currentgraph->currentcolor = colorid;
|
||||||
XSetForeground(display, DEVDEP(currentgraph).gc,
|
XSetForeground(display, DEVDEP(currentgraph).gc,
|
||||||
DEVDEP(currentgraph).colors[colorid]);
|
currentgraph->colorarray[colorid]);
|
||||||
XSetForeground(display, DEVDEP(currentgraph).gridgc,
|
XSetForeground(display, DEVDEP(currentgraph).gridgc,
|
||||||
DEVDEP(currentgraph).colors[colorid]);
|
currentgraph->colorarray[colorid]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1010,12 +1045,12 @@ zoomin(GRAPH *graph)
|
||||||
|
|
||||||
if (!eq(plot_cur->pl_typename, buf2)) {
|
if (!eq(plot_cur->pl_typename, buf2)) {
|
||||||
(void) sprintf(buf,
|
(void) sprintf(buf,
|
||||||
"setplot %s; %s xlimit %.20e %.20e ylimit %.20e %.20e; setplot $curplot\n",
|
"setplot %s; %s xlimit %.20e %.20e ylimit %.20e %.20e sgraphid %d; setplot $curplot\n",
|
||||||
buf2, graph->commandline, fx0, fx1, fy0, fy1);
|
buf2, graph->commandline, fx0, fx1, fy0, fy1, graph->graphid);
|
||||||
} else {
|
} else {
|
||||||
/* set the foreground and background colors to the "calling" window's colors */
|
/* set the foreground and background colors to the "calling" window's colors */
|
||||||
(void) sprintf(buf, "set color0=%s; set color1=%s; %s xlimit %e %e ylimit %e %e\n",
|
(void) sprintf(buf, "%s xlimit %e %e ylimit %e %e sgraphid %d\n",
|
||||||
DEVDEP(graph).bgcolor, DEVDEP(graph).txtcolor, graph->commandline, fx0, fx1, fy0, fy1);
|
graph->commandline, fx0, fx1, fy0, fy1, graph->graphid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* don't use the following if using GNU Readline or BSD EditLine */
|
/* don't use the following if using GNU Readline or BSD EditLine */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue