~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/xplt/src/gist/style.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   STYLE.C
 
3
   Set/get details of graphics style for the get_style, set_style  functions.
 
4
 
 
5
   $Id: style.c,v 1.1 2003/09/30 17:32:42 travo Exp $
 
6
 */
 
7
/*    Copyright (c) 1996.  The Regents of the University of California.
 
8
                    All rights reserved.  */
 
9
 
 
10
#include "hlevel.h"
 
11
#include "pstdlib.h"
 
12
#include "style.h"
 
13
 
 
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);
 
26
 
 
27
int raw_style(long nsys, int *landscape,
 
28
              GfakeSystem *systems, GeLegendBox *legends)
 
29
{
 
30
  int nsy= GhGetPlotter();
 
31
  Drauing *drawing= (nsy>=0 && nsy<8)? ghDevices[nsy].drawing : 0;
 
32
  GeSystem *sys= drawing? drawing->systems : 0;
 
33
 
 
34
  if (!nsys) {
 
35
    /* query operation */
 
36
    if (!drawing) return 0;
 
37
    if (landscape) *landscape= drawing->landscape;
 
38
    nsy= drawing->nSystems;
 
39
    if (systems && nsy>0) {
 
40
      int i;
 
41
      for (i=0 ; i<nsy ; i++,sys=(GeSystem *)sys->el.next) {
 
42
        if (systems[i].legend) {
 
43
          char *legend= systems[i].legend;
 
44
          systems[i].legend= 0;
 
45
          p_free(legend);
 
46
        }
 
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;
 
54
      }
 
55
    }
 
56
    if (legends) {
 
57
      /* lazy today -- use ANSI struct assignment */
 
58
      legends[0]= drawing->legends[0];
 
59
      legends[1]= drawing->legends[1];
 
60
    }
 
61
    return nsy;
 
62
 
 
63
  } else {
 
64
    /* set new style operation */
 
65
    int i;
 
66
    extern void GdKillSystems(void);  /* defined in draw.c */
 
67
    GpBox vp;
 
68
 
 
69
    if (!landscape || !systems || !legends) return -1;
 
70
 
 
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();
 
75
 
 
76
    for (i=0 ; i<nsys ; i++) {
 
77
      gistD.hidden= 0;
 
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];
 
83
      if (nsy==nsys) {
 
84
        GdSetSystem(i+1);
 
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;
 
92
        GdSetPort();
 
93
      } else if (GdNewSystem(&vp, &systems[i].ticks)<0) {
 
94
        gistD.legend= 0;
 
95
        return -1;
 
96
      }
 
97
      gistD.legend= 0;
 
98
    }
 
99
    if (nsys && nsy==nsys) GdSetSystem(1);
 
100
 
 
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);
 
106
 
 
107
    GdLandscape(*landscape);
 
108
 
 
109
    return (int)nsys;
 
110
  }
 
111
}
 
112