File: lxdriv.f

package info (click to toggle)
pgplot5 5.2.2-19%2Bdeb8u1
  • links: PTS
  • area: non-free
  • in suites: jessie
  • size: 7,056 kB
  • ctags: 6,555
  • sloc: fortran: 39,792; ansic: 22,549; objc: 1,534; sh: 1,306; makefile: 386; perl: 234; pascal: 233; tcl: 190; awk: 51; csh: 25
file content (207 lines) | stat: -rw-r--r-- 7,161 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
C*LXDRIV -- PGPLOT driver for LaTeX Picture Environment
C+
      SUBROUTINE LXDRIV(OPCODE,RBUF,NBUF,CHR,LCHR)
      INTEGER OPCODE, NBUF, LCHR
      REAL    RBUF(*)
      CHARACTER*(*) CHR
C
C Supported device:
C  This driver creates a text file containing commands for drawing
C  in the LaTeX picture environment, bracketted by \begin{picture} 
C  and \end{picture}. The file can be included in a LaTeX document.
C
C  If you have the option of including a PostScript file in your
C  LaTeX document, then that will usually give much better results
C  than using this driver, which has very limited capabilities.
C
C Device type code:
C  /LATEX
C
C Default file name:
C  pgplot.tex
C
C Default view surface dimensions:
C  The default picture size is 6 inches by 6 inches (which corresponds 
C  to 1728x1728 units where a unit is 0.25pt = 1/288 inch). The picture
C  size can be changed by using PGPAP in the PGPLOT program.
C
C Resolution:
C  The driver rounds coordinates to multiples of 0.25pt (1/288 inch).
C
C Limitations:
C  The LaTeX picture environment has a very limited set of primitives.
C  In particular, diagonal lines must be composed out of dots. This
C  can lead to very large files. For some graphs (especially with a 
C  lot of shaded areas), the capacity of many LaTeX systems can easily
C  be exceeded.
C
C Author:
C  Written by Grant McIntosh  95/02/14 (gmcint@relay.drev.dnd.ca).
C
C  Revised by T. Pearson 95/06/19.
C  Revised to allow picture size to be adjusted by PGPAP: TJP 97/5/16.
C-----------------------------------------------------------------------
      INTEGER LUN, IXO, IYO, IXPS, IYPS, I, J
      INTEGER INCR, NINC, IER, ISIGN, LENGTH, BX, BY, STATE
      INTEGER GROPTX
      REAL X1, Y1, X2, Y2, DELX, DELY, SLOPE
      CHARACTER*128 MSG
      CHARACTER*(*) DEVNAM
      PARAMETER (DEVNAM='LATEX (LaTeX picture environment)')
      CHARACTER*1   BS
      SAVE LUN, BS, BX, BY, STATE
C-----------------------------------------------------------------------
      GOTO(10,20,30,40,50,60,70,80,90,100,110,120,130,140)OPCODE
      NBUF=-1
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 1, Return device name -------------------------------------
   10 CHR=DEVNAM
      LCHR=LEN(DEVNAM)
      BS=CHAR(92)
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 2, Return physical min and max for plot device, and range
C               of color indices ---------------------------------------
   20 RBUF(1)=0
      RBUF(2)=32767
      RBUF(3)=0
      RBUF(4)=32767
      RBUF(5)=0
      RBUF(6)=1
      NBUF=6
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 3, Return device resolution -------------------------------
   30 RBUF(1)=72./0.25
      RBUF(2)=72./0.25
      RBUF(3)=1.
      NBUF=3
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 4, Return misc device info --------------------------------
   40 CHR='HNNNNNNNNN'
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 5, Return default file name -------------------------------
   50 CHR='pgplot.tex'
      LCHR=10
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 6, Return default physical size of plot -------------------
   60 RBUF(1)=0
      RBUF(2)=BX
      RBUF(3)=0
      RBUF(4)=BY
      NBUF=4
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 7, Return misc defaults -----------------------------------
   70 RBUF(1)=1
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 8, Select plot --------------------------------------------
 80   RETURN
C-----------------------------------------------------------------------
C--- IFUNC = 9, Open workstation ---------------------------------------
 90   CONTINUE
      NBUF=2
C     -- check for concurrent access
      IF (STATE.EQ.1) THEN
         CALL GRWARN('a PGPLOT LaTeX file is already open')
         RBUF(1) = 0
         RBUF(2) = 0
         RETURN
      END IF
      CALL GRGLUN(LUN)
      IER = GROPTX(LUN, CHR(1:LCHR), 'pgplot.tex', 1)
      IF (IER.NE.0) THEN
         MSG = 'Cannot open output file for LaTeX picture: '//
     :         CHR(:LCHR)
         CALL GRWARN(MSG)
         RBUF(1)=0
         RBUF(2)=0
         CALL GRFLUN(LUN)
      ELSE
         RBUF(2)=1
         RBUF(1)=LUN
         STATE=1
         BX=1728
         BY=1728
      END IF
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC=10, Close workstation ---------------------------------------
 100  CLOSE(UNIT=LUN)
      CALL GRFLUN(LUN)
      STATE=0
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC=11, Begin picture -------------------------------------------
  110 CONTINUE
      BX = NINT(RBUF(1))
      BY = NINT(RBUF(2))
      WRITE(LUN,'(A)') BS//'setlength{'//BS//'unitlength}{0.25pt}'
      WRITE(LUN,'(A)') BS//'linethickness{1pt}'
      WRITE(LUN,'(A,I6,A,I6,A)')
     :     BS//'begin{picture}(',BX,',',BY,')(0,0)'
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC=12, Draw line -----------------------------------------------
  120 X1=RBUF(1)
      Y1=RBUF(2)
      X2=RBUF(3)
      Y2=RBUF(4)
      IXO=X1
      IYO=Y1
      IXPS=X2
      IYPS=Y2
C vertical lines
      IF(IXPS.EQ.IXO) THEN
         LENGTH=ABS(IYPS-IYO)
         ISIGN=1
         IF(LENGTH.NE.0) ISIGN=(IYPS-IYO)/LENGTH
         WRITE(LUN,5000) BS,IXO,IYO,BS,ISIGN,LENGTH
 5000    FORMAT(A1,'put(',I4,',',I4,'){',A1,'line(0,',I4,'){',I4,'}}')
         RETURN
      ENDIF
C horizontal lines
      IF(IYPS.EQ.IYO) THEN
         LENGTH=ABS(IXPS-IXO)
         ISIGN=1
         IF(LENGTH.NE.0) ISIGN=(IXPS-IXO)/LENGTH
         WRITE(LUN,5100) BS,IXO,IYO,BS,ISIGN,LENGTH
 5100    FORMAT(A1,'put(',I4,',',I4,'){',A1,'line(',I4,',0){',I4,'}}')
         RETURN
      ENDIF
C other lines
      SLOPE=FLOAT(IYPS-IYO)/FLOAT(IXPS-IXO)
      INCR=1
      IF(IXPS.LT.IXO) INCR=-1
      NINC=MAX(1,ABS(IXPS-IXO))
      DELX=INCR
      DELY=SLOPE*INCR
  125 CONTINUE
      IF(ABS(DELY).GT.1) THEN
         NINC=NINC*2
         DELX=DELX/2.
         DELY=SLOPE*DELX
         GOTO 125
      ENDIF
      WRITE(LUN,5200) BS,IXO,IYO,DELX,DELY,NINC,BS
 5200 FORMAT(A1,'multiput(',I4,',',I4,')(',F8.3,',',F8.3,'){',I4,
     *     '}{',A1,'circle*{1}}')
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC=13, Draw dot ------------------------------------------------
  130 I=NINT(RBUF(1))
      J=NINT(RBUF(2))
      WRITE(LUN,5300) BS,I,J,BS
 5300 FORMAT(A1,'put(',I4,',',I4,'){',A1,'circle*{1}}')
      RETURN
C-----------------------------------------------------------------------
C--- IFUNC=14, End picture ---------------------------------------------
  140 WRITE(LUN,'(A)') BS//'end{picture}'
      RETURN
C-----------------------------------------------------------------------
      END