aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/drawopt.spad.pamphlet
blob: 2b5b0dce5126b432e364bbcb8ba1892cddd45c9d (plain)
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
\documentclass{article}
\usepackage{open-axiom}
\begin{document}
\title{src/algebra drawopt.spad}
\author{Stephen M. Watt, Jim Wen}
\maketitle

\begin{abstract}
\end{abstract}
\tableofcontents
\eject

\section{domain DROPT DrawOption}

<<domain DROPT DrawOption>>=
)abbrev domain DROPT DrawOption
++ Author: Stephen Watt
++ Date Created: 1 March 1990
++ Date Last Updated: 31 Oct 1990, Jim Wen
++ Basic Operations: adaptive, clip, title, style, toScale, coordinates,
++ pointColor, curveColor, colorFunction, tubeRadius, range, ranges,
++ var1Steps, var2Steps, tubePoints, unit
++ Related Constructors:
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description: DrawOption allows the user to specify defaults for the 
++ creation and rendering of plots.

DrawOption(): Exports == Implementation where 
 RANGE ==> List Segment Float
 UNIT  ==> List Float
 PAL   ==> Palette
 POINT ==> Point(DoubleFloat)
 SEG   ==> Segment Float
 SF     ==> DoubleFloat
 SPACE3 ==> ThreeSpace(DoubleFloat)
 VIEWPT ==> Record( theta:SF, phi:SF, scale:SF, scaleX:SF, scaleY:SF, scaleZ:SF, deltaX:SF, deltaY:SF )

 Exports ==> SetCategory with
  adaptive : Boolean -> %
    ++ adaptive(b) turns adaptive 2D plotting on if b is true, or off if b is
    ++ false. This option is expressed in the form \spad{adaptive == b}.
  clip : Boolean -> %
    ++ clip(b) turns 2D clipping on if b is true, or off if b is false. This option
    ++ is expressed in the form \spad{clip == b}.
  viewpoint : VIEWPT -> %
    ++ viewpoint(vp) creates a viewpoint data structure corresponding to the list
    ++ of values.  The values are interpreted as [theta, phi, scale, scaleX, scaleY,
    ++ scaleZ, deltaX, deltaY].  This option is expressed in the form 
    ++ \spad{viewpoint == ls}.
  title  : String -> %
    ++ title(s) specifies a title for a plot by the indicated string s. This option
    ++ is expressed in the form \spad{title == s}.
  style  : String -> %
    ++ style(s) specifies the drawing style in which the graph will be plotted
    ++ by the indicated string s. This option is expressed in the form \spad{style == s}.
  toScale : Boolean -> %
    ++ toScale(b) specifies whether or not a plot is to be drawn to scale;
    ++ if b is true it is drawn to scale, if b is false it is not. This option
    ++ is expressed in the form \spad{toScale == b}.

  clip : List SEG -> %
    ++ clip([l]) provides ranges for user-defined clipping as specified
    ++ in the list l. This option is expressed in the form \spad{clip == [l]}.
  coordinates : (POINT -> POINT) -> % 
    ++ coordinates(p) specifies a change of coordinate systems of point p. 
    ++ This option is expressed in the form \spad{coordinates == p}.
  pointColor : Float -> %
    ++ pointColor(v) specifies a color, v, for 2D graph points. This option
    ++ is expressed in the form \spad{pointColor == v}.
  pointColor : PAL -> %
    ++ pointColor(p) specifies a color index for 2D graph points from the spadcolors
    ++ palette p. This option is expressed in the form \spad{pointColor == p}.
  curveColor : Float -> %
    ++ curveColor(v) specifies a color, v, for 2D graph curves. This option is expressed
    ++ in the form \spad{curveColor == v}.
  curveColor : PAL -> %
    ++ curveColor(p) specifies a color index for 2D graph curves from the 
    ++ spadcolors palette p. This option is expressed in the form \spad{curveColor ==p}.
  colorFunction : (SF -> SF) -> %
    ++ colorFunction(f(z)) specifies the color based upon the z-component of 
    ++ three dimensional plots. This option is expressed in the form \spad{colorFunction == f(z)}.
  colorFunction : ((SF,SF) -> SF) -> %
    ++ colorFunction(f(u,v)) specifies the color for three dimensional plots
    ++ as a function based upon the two parametric variables. This option is expressed
    ++ in the form \spad{colorFunction == f(u,v)}.
  colorFunction : ((SF,SF,SF) -> SF) -> %
    ++ colorFunction(f(x,y,z)) specifies the color for three dimensional 
    ++ plots as a function of x, y, and z coordinates. This option is expressed in the
    ++ form \spad{colorFunction == f(x,y,z)}.
  tubeRadius : Float -> %
    ++ tubeRadius(r) specifies a radius, r, for a tube plot around a 3D curve;
    ++ is expressed in the form \spad{tubeRadius == 4}.
  range : List SEG -> %
    ++ range([l]) provides a user-specified range l. This option is expressed in the
    ++ form \spad{range == [l]}.
  range : List Segment Fraction Integer -> %
    ++ range([i]) provides a user-specified range i. This option is expressed in the
    ++ form \spad{range == [i]}.

  ranges : RANGE -> %
    ++ ranges(l) provides a list of user-specified ranges l. This option is expressed
    ++ in the form \spad{ranges == l}.
  space : SPACE3 -> %
    ++ space specifies the space into which we will draw.  If none is given
    ++ then a new space is created.
  var1Steps : PositiveInteger -> %
    ++ var1Steps(n) indicates the number of subdivisions, n, of the first 
    ++ range variable. This option is expressed in the form \spad{var1Steps == n}.
  var2Steps : PositiveInteger -> %
    ++ var2Steps(n) indicates the number of subdivisions, n,  of the second 
    ++ range variable. This option is expressed in the form \spad{var2Steps == n}.
  tubePoints : PositiveInteger -> %
    ++ tubePoints(n) specifies the number of points, n, defining the circle
    ++ which creates the tube around a 3D curve, the default is 6. This option is 
    ++ expressed in the form \spad{tubePoints == n}.
  coord : (POINT->POINT) -> %
    ++ coord(p) specifies a change of coordinates of point p. This option is expressed
    ++ in the form \spad{coord == p}.
  unit   : UNIT -> %
    ++ unit(lf) will mark off the units according to the indicated list lf.
    ++ This option is expressed in the form \spad{unit == [f1,f2]}.
  option : (List %, Symbol) -> Union(Any, "failed")
    ++ option() is not to be used at the top level; 
    ++ option determines internally which drawing options are indicated in 
    ++ a draw command.
  option?: (List %, Symbol) -> Boolean
    ++ option?() is not to be used at the top level;
    ++ option? internally returns true for drawing options which are 
    ++ indicated in a draw command, or false for those which are not.
 Implementation ==> add
  import AnyFunctions1(String)
  import AnyFunctions1(Segment Float)
  import AnyFunctions1(VIEWPT)
  import AnyFunctions1(List Segment Float)
  import AnyFunctions1(List Segment Fraction Integer)
  import AnyFunctions1(List Integer)
  import AnyFunctions1(PositiveInteger)
  import AnyFunctions1(Boolean)
  import AnyFunctions1(RANGE)
  import AnyFunctions1(UNIT)
  import AnyFunctions1(Float)
  import AnyFunctions1(POINT -> POINT)
  import AnyFunctions1(SF -> SF)
  import AnyFunctions1((SF,SF) -> SF)
  import AnyFunctions1((SF,SF,SF) -> SF)
  import AnyFunctions1(POINT)
  import AnyFunctions1(PAL)
  import AnyFunctions1(SPACE3)

  Rep := Record(keyword:Symbol, value:Any)

  length:List SEG -> NonNegativeInteger
  -- these lists will become tuples in a later version
  length tup == # tup

  lengthR:List Segment Fraction Integer -> NonNegativeInteger
  -- these lists will become tuples in a later version
  lengthR tup == # tup

  lengthI:List Integer -> NonNegativeInteger
  -- these lists will become tuples in a later version
  lengthI tup == # tup

  viewpoint vp == ['viewpoint, vp::Any]

  title s == ['title, s::Any]
  style s == ['style, s::Any]
  toScale b == ['toScale, b::Any]
  clip(b:Boolean) == ['clipBoolean, b::Any]
  adaptive b == ['adaptive, b::Any]

  pointColor(x:Float) == ['pointColorFloat, x::Any]
  pointColor(c:PAL) == ['pointColorPalette, c::Any]
  curveColor(x:Float) == ['curveColorFloat, x::Any]
  curveColor(c:PAL) == ['curveColorPalette, c::Any]
  colorFunction(f:SF -> SF) == ['colorFunction1, f::Any]
  colorFunction(f:(SF,SF) -> SF) == ['colorFunction2, f::Any]
  colorFunction(f:(SF,SF,SF) -> SF) == ['colorFunction3, f::Any]
  clip(tup:List SEG) == 
    length tup > 3 =>
      error "clip: at most 3 segments may be specified"
    ['clipSegment, tup::Any]
  coordinates f == ['coordinates, f::Any]
  tubeRadius x == ['tubeRadius, x::Any]
  range(tup:List Segment Float) == 
    ((n := length tup) > 3) =>
      error "range: at most 3 segments may be specified"
    n < 2 =>
      error "range: at least 2 segments may be specified"
    ['rangeFloat, tup::Any]
  range(tup:List Segment Fraction Integer) == 
    ((n := lengthR tup) > 3) =>
      error "range: at most 3 segments may be specified"
    n < 2 =>
      error "range: at least 2 segments may be specified"
    ['rangeRat, tup::Any]

  ranges s               == ['ranges, s::Any]
  space s                == ['space, s::Any]
  var1Steps s            == ['var1Steps, s::Any]
  var2Steps s            == ['var2Steps, s::Any]
  tubePoints s           == ['tubePoints, s::Any]
  coord s                == ['coord, s::Any]
  unit s                 == ['unit, s::Any]
  coerce(x:%):OutputForm == x.keyword::OutputForm = x.value::OutputForm
  x:% = y:%              == x.keyword = y.keyword and x.value = y.value

  option?(l, s) ==
    for x in l repeat
      x.keyword = s => return true
    false

  option(l, s) ==
    for x in l repeat
      x.keyword = s => return(x.value)
    "failed"

@

\section{package DROPT1 DrawOptionFunctions1}

<<package DROPT1 DrawOptionFunctions1>>=
import Type
import Symbol
import List DrawOption
)abbrev package DROPT1 DrawOptionFunctions1
++ This package \undocumented{}
DrawOptionFunctions1(S:Type): Exports == Implementation where
 RANGE ==> List Segment Float
 UNIT  ==> List Float
 PAL   ==> Palette
 POINT ==> Point(DoubleFloat)
 SEG   ==> Segment Float
 SF     ==> DoubleFloat
 SPACE3 ==> ThreeSpace(DoubleFloat)
 VIEWPT ==> Record( theta:SF, phi:SF, scale:SF, scaleX:SF, scaleY:SF, scaleZ:SF, deltaX:SF, deltaY:SF )
 
 Exports ==> with
  option: (List DrawOption, Symbol) -> Union(S, "failed")
    ++ option(l,s) determines whether the indicated drawing option, s,
    ++ is contained in the list of drawing options, l, which is defined
    ++ by the draw command.
 Implementation ==> add
  import DrawOption
  option(l, s) ==
    (u := option(l, s)@Union(Any, "failed")) case "failed" => "failed"
    retract(u::Any)$AnyFunctions1(S)

@
\section{package DROPT0 DrawOptionFunctions0}
<<package DROPT0 DrawOptionFunctions0>>=
)abbrev package DROPT0 DrawOptionFunctions0
-- The functions here are not in DrawOptions since they are not
-- visible to the interpreter.
++ This package \undocumented{}
DrawOptionFunctions0(): Exports == Implementation where
 RANGE ==> List Segment Float
 UNIT  ==> List Float
 PAL   ==> Palette
 POINT ==> Point(DoubleFloat)
 SEG   ==> Segment Float
 SF     ==> DoubleFloat
 SPACE3 ==> ThreeSpace(DoubleFloat)
 VIEWPT ==> Record( theta:SF, phi:SF, scale:SF, scaleX:SF, scaleY:SF, scaleZ:SF, deltaX:SF, deltaY:SF )

 Exports ==> with
  adaptive: (List DrawOption, Boolean) -> Boolean
    ++ adaptive(l,b) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{adaptive}.
    ++ If the option does not exist the value, b is returned.
  clipBoolean: (List DrawOption, Boolean) -> Boolean
    ++ clipBoolean(l,b) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{clipBoolean}.
    ++ If the option does not exist the value, b is returned.
  viewpoint: (List DrawOption, VIEWPT) -> VIEWPT
    ++ viewpoint(l,ls) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{viewpoint}.
    ++ IF the option does not exist, the value ls is returned.
  title: (List DrawOption, String) -> String
    ++ title(l,s) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{title}.
    ++ If the option does not exist the value, s is returned.
  style: (List DrawOption, String) -> String
    ++ style(l,s) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{style}.
    ++ If the option does not exist the value, s is returned.
  toScale: (List DrawOption, Boolean) -> Boolean
    ++ toScale(l,b) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{toScale}.
    ++ If the option does not exist the value, b is returned.

  pointColorPalette: (List DrawOption,PAL) -> PAL
    ++ pointColorPalette(l,p) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{pointColorPalette}.
    ++ If the option does not exist the value, p is returned.
  curveColorPalette: (List DrawOption,PAL) -> PAL
    ++ curveColorPalette(l,p) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{curveColorPalette}.
    ++ If the option does not exist the value, p is returned.

  ranges: (List DrawOption, RANGE) -> RANGE
    ++ ranges(l,r) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{ranges}.
    ++ If the option does not exist the value, r is returned.
  var1Steps: (List DrawOption, PositiveInteger) -> PositiveInteger
    ++ var1Steps(l,n) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{var1Steps}.
    ++ If the option does not exist the value, n is returned.
  var2Steps: (List DrawOption, PositiveInteger) -> PositiveInteger
    ++ var2Steps(l,n) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{var2Steps}.
    ++ If the option does not exist the value, n is returned.
  space: (List DrawOption) -> SPACE3
    ++ space(l) takes a list of draw options, l, and checks to see
    ++ if it contains the option \spad{space}.  If the the option
    ++ doesn't exist, then an empty space is returned.
  tubePoints : (List DrawOption, PositiveInteger) -> PositiveInteger
    ++ tubePoints(l,n) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{tubePoints}.
    ++ If the option does not exist the value, n is returned.
  tubeRadius : (List DrawOption, Float) -> Float
    ++ tubeRadius(l,n) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{tubeRadius}.
    ++ If the option does not exist the value, n is returned.
  coord: (List DrawOption, (POINT->POINT)) -> (POINT->POINT)
    ++ coord(l,p) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{coord}.
    ++ If the option does not exist the value, p is returned.
  units: (List DrawOption, UNIT) -> UNIT
    ++ units(l,u) takes the list of draw options, l, and checks
    ++ the list to see if it contains the option \spad{unit}.
    ++ If the option does not exist the value, u is returned.

 Implementation ==> add
  adaptive(l,s) ==
    (u := option(l,'adaptive)$DrawOptionFunctions1(Boolean))
      case "failed" => s
    u::Boolean

  clipBoolean(l,s) ==
    (u := option(l,'clipBoolean)$DrawOptionFunctions1(Boolean))
      case "failed" => s
    u::Boolean

  title(l, s) ==
    (u := option(l,'title)$DrawOptionFunctions1(String))
      case "failed" => s
    u::String

  viewpoint(l, vp) ==
    (u := option(l,'viewpoint)$DrawOptionFunctions1(VIEWPT))
      case "failed" => vp
    u::VIEWPT

  style(l, s) ==
    (u := option(l,'style)$DrawOptionFunctions1(String))
      case "failed" => s
    u::String

  toScale(l,s) ==
    (u := option(l,'toScale)$DrawOptionFunctions1(Boolean))
      case "failed" => s
    u::Boolean

  pointColorPalette(l,s) ==
    (u := option(l,'pointColorPalette)$DrawOptionFunctions1(PAL))
      case "failed" => s
    u::PAL

  curveColorPalette(l,s) ==
    (u := option(l,'curveColorPalette)$DrawOptionFunctions1(PAL))
      case "failed" => s
    u::PAL



  ranges(l, s) ==
    (u := option(l,'ranges)$DrawOptionFunctions1(RANGE))
      case "failed" => s
    u::RANGE

  space(l) ==
    (u := option(l,'space)$DrawOptionFunctions1(SPACE3))
      case "failed" => create3Space()$SPACE3
    u::SPACE3

  var1Steps(l,s) ==
    (u := option(l,'var1Steps)$DrawOptionFunctions1(PositiveInteger))
      case "failed" => s
    u::PositiveInteger

  var2Steps(l,s) ==
    (u := option(l,'var2Steps)$DrawOptionFunctions1(PositiveInteger))
      case "failed" => s
    u::PositiveInteger

  tubePoints(l,s) ==
    (u := option(l,'tubePoints)$DrawOptionFunctions1(PositiveInteger))
      case "failed" => s
    u::PositiveInteger

  tubeRadius(l,s) ==
    (u := option(l,'tubeRadius)$DrawOptionFunctions1(Float))
      case "failed" => s
    u::Float

  coord(l,s) ==
    (u := option(l,'coord)$DrawOptionFunctions1(POINT->POINT))
      case "failed" => s
    u::(POINT->POINT)

  units(l,s) ==
    (u := option(l,'unit)$DrawOptionFunctions1(UNIT))
      case "failed" => s
    u::UNIT

@
\section{License}
<<license>>=
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--All rights reserved.
--Copyright (C) 2007-2009, Gabriel Dos Reis.
--All rights reserved.
--
--Redistribution and use in source and binary forms, with or without
--modification, are permitted provided that the following conditions are
--met:
--
--    - Redistributions of source code must retain the above copyright
--      notice, this list of conditions and the following disclaimer.
--
--    - Redistributions in binary form must reproduce the above copyright
--      notice, this list of conditions and the following disclaimer in
--      the documentation and/or other materials provided with the
--      distribution.
--
--    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
--      names of its contributors may be used to endorse or promote products
--      derived from this software without specific prior written permission.
--
--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
--IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
--TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
--PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
--OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
--EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
--PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
--PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
--LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
--NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@
<<*>>=
<<license>>

<<domain DROPT DrawOption>>
<<package DROPT1 DrawOptionFunctions1>>
<<package DROPT0 DrawOptionFunctions0>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}