3
Set/get details of graphics style for the get_style, set_style functions.
5
$Id: style.c,v 1.1 2003/09/30 17:32:42 travo Exp $
7
/* Copyright (c) 1996. The Regents of the University of California.
8
All rights reserved. */
14
/* This function is based on raw_style in yorick.
15
If nsys==0, this is a query operation which fills in the input
16
data arrays (if the pointers are non-zero)
17
otherwise, systems is systems[nsys], and the operation is to
18
set the values specified in the data arrays
19
Unless an error occurs, the return value is the number of coordinate
20
systems; for queries the routine must be called twice, first with
21
systems==0 to retrieve the number of systems, then with a large enough
22
systems to hold the returned values. If an error occurs, the function
23
returns -1 instead of the number of coordinate systems. */
24
extern int raw_style(long nsys, int *landscape,
25
GfakeSystem *systems, GeLegendBox *legends);
27
int raw_style(long nsys, int *landscape,
28
GfakeSystem *systems, GeLegendBox *legends)
30
int nsy= GhGetPlotter();
31
Drauing *drawing= (nsy>=0 && nsy<8)? ghDevices[nsy].drawing : 0;
32
GeSystem *sys= drawing? drawing->systems : 0;
36
if (!drawing) return 0;
37
if (landscape) *landscape= drawing->landscape;
38
nsy= drawing->nSystems;
39
if (systems && nsy>0) {
41
for (i=0 ; i<nsy ; i++,sys=(GeSystem *)sys->el.next) {
42
if (systems[i].legend) {
43
char *legend= systems[i].legend;
47
systems[i].legend= p_strcpy(sys->el.legend);
48
systems[i].viewport[0]= sys->trans.viewport.xmin;
49
systems[i].viewport[1]= sys->trans.viewport.xmax;
50
systems[i].viewport[2]= sys->trans.viewport.ymin;
51
systems[i].viewport[3]= sys->trans.viewport.ymax;
52
/* lazy today -- use ANSI struct assignment */
53
systems[i].ticks= sys->ticks;
57
/* lazy today -- use ANSI struct assignment */
58
legends[0]= drawing->legends[0];
59
legends[1]= drawing->legends[1];
64
/* set new style operation */
66
extern void GdKillSystems(void); /* defined in draw.c */
69
if (!landscape || !systems || !legends) return -1;
71
/* don't clobber the current display list(s) unless the
72
number of coordinate systems has changed */
73
nsy= drawing? drawing->nSystems : 0;
74
if (nsy != nsys) GdKillSystems();
76
for (i=0 ; i<nsys ; i++) {
78
gistD.legend= systems[i].legend;
79
vp.xmin= systems[i].viewport[0];
80
vp.xmax= systems[i].viewport[1];
81
vp.ymin= systems[i].viewport[2];
82
vp.ymax= systems[i].viewport[3];
85
/* don't bother with the legend */
86
gistD.trans.viewport.xmin= vp.xmin;
87
gistD.trans.viewport.xmax= vp.xmax;
88
gistD.trans.viewport.ymin= vp.ymin;
89
gistD.trans.viewport.ymax= vp.ymax;
90
/* lazy today -- use ANSI struct assignment */
91
gistD.ticks= systems[i].ticks;
93
} else if (GdNewSystem(&vp, &systems[i].ticks)<0) {
99
if (nsys && nsy==nsys) GdSetSystem(1);
101
for (i=0 ; i<2 ; i++)
102
GdLegendBox(i, legends[i].x, legends[i].y,
103
legends[i].dx, legends[i].dy,
104
&legends[i].textStyle, legends[i].nchars,
105
legends[i].nlines, legends[i].nwrap);
107
GdLandscape(*landscape);