aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/viewDef.spad.pamphlet
blob: 78079747bcff78da2c5f341b996cb6819fc19967 (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
\documentclass{article}
\usepackage{open-axiom}
\begin{document}
\title{\$SPAD/src/algebra viewDef.spad}
\author{James Wen}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{package VIEWDEF ViewDefaultsPackage}
<<package VIEWDEF ViewDefaultsPackage>>=
)abbrev package VIEWDEF ViewDefaultsPackage
++ Author: Jim Wen
++ Date Created: 15 January 1990
++ Date Last Updated:
++ Basic Operations: pointColorDefault, lineColorDefault, axesColorDefault,
++ unitsColorDefault, pointSizeDefault, viewPosDefault, viewSizeDefault,
++ viewDefaults, viewWriteDefault, viewWriteAvailable, var1StepsDefault,
++ var2StepsDefault, tubePointsDefault, tubeRadiusDefault
++ Related Constructors:
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description: ViewportDefaultsPackage describes default and user definable 
++ values for graphics

ViewDefaultsPackage():Exports == Implementation where
  I       ==> Integer
  C       ==> Color
  PAL     ==> Palette
  L       ==> List
  S       ==> String
  E       ==> Expression
  PI      ==> PositiveInteger
  NNI     ==> NonNegativeInteger
  SF      ==> DoubleFloat
  B       ==> Boolean

  writeAvailable ==>  (["PIXMAP","BITMAP","POSTSCRIPT","IMAGE"]::L S)
    -- need not worry about case of letters

  Exports ==> with
    pointColorDefault   :  ()                          -> PAL
      ++ pointColorDefault() returns the default color of points in a 2D 
      ++ viewport.
    pointColorDefault   :  PAL                         -> PAL
      ++ pointColorDefault(p) sets the default color of points in a 2D viewport
      ++ to the palette p.
    lineColorDefault    :  ()                          -> PAL
      ++ lineColorDefault() returns the default color of lines connecting 
      ++ points in a 2D viewport.
    lineColorDefault    :  PAL                         -> PAL
      ++ lineColorDefault(p) sets the default color of lines connecting points
      ++ in a 2D viewport to the palette p.
    axesColorDefault    :  ()                          -> PAL
      ++ axesColorDefault() returns the default color of the axes in a 
      ++ 2D viewport.
    axesColorDefault    :  PAL                         -> PAL
      ++ axesColorDefault(p) sets the default color of the axes in a 2D 
      ++ viewport to the palette p.
    unitsColorDefault   :  ()                          -> PAL
      ++ unitsColorDefault() returns the default color of the unit ticks in 
      ++ a 2D viewport.
    unitsColorDefault   :  PAL                         -> PAL
      ++ unitsColorDefault(p) sets the default color of the unit ticks in 
      ++ a 2D viewport to the palette p.
    pointSizeDefault    :  ()                          -> PI
      ++ pointSizeDefault() returns the default size of the points in 
      ++ a 2D viewport.
    pointSizeDefault    :  PI                          -> PI
      ++ pointSizeDefault(i) sets the default size of the points in a 2D 
      ++ viewport to i.
    viewPosDefault      :  () -> L NNI
      ++ viewPosDefault() returns the default X and Y position of a
      ++ viewport window unless overriden explicityly, newly created
      ++ viewports will have this X and Y coordinate.
    viewPosDefault      :  L NNI -> L NNI
      ++ viewPosDefault([x,y]) sets the default X and Y position of a
      ++ viewport window unless overriden explicityly, newly created
      ++ viewports will have th X and Y coordinates x, y.
    viewSizeDefault : () -> L PI
      ++ viewSizeDefault() returns the default viewport width and height.
    viewSizeDefault : L PI -> L PI
      ++ viewSizeDefault([w,h]) sets the default viewport width to w and height
      ++ to h.
    viewDefaults :  ()                          -> Void
      ++ viewDefaults() resets all the default graphics settings.
    viewWriteDefault  :  ()                          -> L S
      ++ viewWriteDefault() returns the list of things to write in a viewport
      ++ data file; a viewAlone file is always generated.
    viewWriteDefault  :  L S                         -> L S
      ++ viewWriteDefault(l) sets the default list of things to write in a 
      ++ viewport data file to the strings in l; a viewAlone file is always 
      ++ genereated.
    viewWriteAvailable : ()                   -> L S
      ++ viewWriteAvailable() returns a list of available methods for writing,
      ++ such as BITMAP, POSTSCRIPT, etc.
    var1StepsDefault       : () -> PI
      ++ var1StepsDefault() is the current setting for the number of steps to 
      ++ take when creating a 3D mesh in the direction of the first defined 
      ++ free variable (a free variable is considered defined when its 
      ++ range is specified (e.g. x=0..10)).
    var2StepsDefault       : () -> PI
      ++ var2StepsDefault() is the current setting for the number of steps to 
      ++ take when creating a 3D mesh in the direction of the first defined 
      ++ free variable (a free variable is considered defined when its 
      ++ range is specified (e.g. x=0..10)).
    var1StepsDefault       : PI -> PI
      ++ var1StepsDefault(i) sets the number of steps to take when creating a 
      ++ 3D mesh in the direction of the first defined free variable to i
      ++ (a free variable is considered defined when its range is specified 
      ++ (e.g. x=0..10)).
    var2StepsDefault       : PI -> PI
      ++ var2StepsDefault(i) sets the number of steps to take when creating a 
      ++ 3D mesh in the direction of the first defined free variable to i
      ++ (a free variable is considered defined when its range is specified 
      ++ (e.g. x=0..10)).
    tubePointsDefault  : PI -> PI
      ++ tubePointsDefault(i) sets the number of points to use when creating 
      ++ the circle to be used in creating a 3D tube plot to i.
    tubePointsDefault  : () -> PI
      ++ tubePointsDefault() returns the number of points to be used when 
      ++ creating the circle to be used in creating a 3D tube plot.
    tubeRadiusDefault  : Float -> SF   -- current tube.spad asks for SF
      ++ tubeRadiusDefault(r) sets the default radius for a 3D tube plot to r.
    tubeRadiusDefault  : () -> SF
      ++ tubeRadiusDefault() returns the radius used for a 3D tube plot.

  Implementation ==> add

    import Color()
    import Palette()
    --import StringManipulations()

    defaultPointColor : Reference(PAL)  := ref bright red()
    defaultLineColor  : Reference(PAL)  := ref pastel green() --bright blue()
    defaultAxesColor  : Reference(PAL)  := ref dim red()
    defaultUnitsColor : Reference(PAL)  := ref dim yellow()
    defaultPointSize  : Reference(PI)   := ref(3::PI)
    defaultXPos       : Reference(NNI)  := ref(0::NNI)
    defaultYPos       : Reference(NNI)  := ref(0::NNI)
    defaultWidth      : Reference(PI)   := ref(400::PI)
    defaultHeight     : Reference(PI)   := ref(400::PI)
    defaultThingsToWrite : Reference(L S) := ref([]::L S)
    defaultVar1Steps  : Reference(PI)   := ref(27::PI)
    defaultVar2Steps  : Reference(PI)   := ref(27::PI)
    defaultTubePoints : Reference(PI)   := ref(6::PI)
    defaultTubeRadius : Reference(SF)   := ref(convert(0.5)@SF)
    defaultClosed     : Reference(B)    := ref(false)

--%Viewport window dimensions specifications
    viewPosDefault() == [deref defaultXPos,deref defaultYPos]
    viewPosDefault l ==
      #l < 2 => error "viewPosDefault expects a list with two elements"
      [setref(defaultXPos,first l),setref(defaultYPos,last l)]

    viewSizeDefault() == [deref defaultWidth,deref defaultHeight]
    viewSizeDefault l ==
      #l < 2 => error "viewSizeDefault expects a list with two elements"
      [setref(defaultWidth,first l),setref(defaultHeight,last l)]

    viewDefaults ==
      defaultPointColor : Reference(PAL)  := ref bright red()
      defaultLineColor  : Reference(PAL)  := ref pastel green() --bright blue()
      defaultAxesColor  : Reference(PAL)  := ref dim red()
      defaultUnitsColor : Reference(PAL)  := ref dim yellow()
      defaultPointSize  : Reference(PI)   := ref(3::PI)
      defaultXPos       : Reference(NNI)  := ref(0::NNI)
      defaultYPos       : Reference(NNI)  := ref(0::NNI)
      defaultWidth      : Reference(PI)   := ref(400::PI)
      defaultHeight     : Reference(PI)   := ref(427::PI)

--%2D graphical output specifications
    pointColorDefault() == deref defaultPointColor
    pointColorDefault p == setref(defaultPointColor,p)

    lineColorDefault() == deref defaultLineColor
    lineColorDefault p == setref(defaultLineColor,p)

    axesColorDefault() == deref defaultAxesColor
    axesColorDefault p == setref(defaultAxesColor,p)

    unitsColorDefault() == deref defaultUnitsColor
    unitsColorDefault p == setref(defaultUnitsColor,p)

    pointSizeDefault() == deref defaultPointSize
    pointSizeDefault x == setref(defaultPointSize,x)


--%3D specific stuff
    var1StepsDefault() == deref defaultVar1Steps
    var1StepsDefault i == setref(defaultVar1Steps,i)

    var2StepsDefault() == deref defaultVar2Steps
    var2StepsDefault i == setref(defaultVar2Steps,i)

    tubePointsDefault() == deref defaultTubePoints
    tubePointsDefault i == setref(defaultTubePoints,i)

    tubeRadiusDefault() == deref defaultTubeRadius
    tubeRadiusDefault f == setref(defaultTubeRadius,convert(f)@SF)

--%File output stuff
    viewWriteAvailable() == writeAvailable

    viewWriteDefault() == deref defaultThingsToWrite

    viewWriteDefault listOfThings ==
      thingsToWrite : L S := []
      for aTypeOfFile in listOfThings repeat
        if negative?(writeTypeInt := position(upperCase aTypeOfFile,viewWriteAvailable())) then
          sayBrightly(["  > ",concat(aTypeOfFile,
                       " is not a valid file type for writing a viewport")])$Lisp
        else
          thingsToWrite := append(thingsToWrite,[aTypeOfFile])
      setref(defaultThingsToWrite,thingsToWrite)

@
\section{License}
<<license>>=
--Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
--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>>

<<package VIEWDEF ViewDefaultsPackage>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}