summaryrefslogtreecommitdiff
path: root/ipl/mprogs/alcview.icn
blob: 85a007afea6b8b003a653dcbc9298ed43dd4b030 (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
###########################################################################
#
#	File:     alcview.icn
#
#	Subject:  Program to display allocation events in various ways
#
#	Author:   Ralph E. Griswold
#
#	Date:     February 16, 1998
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program maps allocation events into colors and provides various
#  abstract visualizations of them.
#
#  Several visualizations are available:
#
#       beacon		blinking light
#	curves		random closed curves
#	haystack*	randomly oriented lines
#	nova*		radiating lines
#	pinwheel	revolving sequence of sectors in a circle
#	polygons	random polygons
#	splatter*	randomly placed dots
#	strip		scrolling strip of vertical lines
#	symplat		as splatter, but in symmetric pattern
#	vortex*		expanding/contracting square vortex
#	web*		random walk
#
#  The visualizations marked with asterisks use the size information. The
#  others do not.
#
#  In terms of the monitoring framework terminology, this program
#  provides abstract visualizations for in an event space consisting
#  of category/size pairs -- 2CS -- in which the categories are colors.
#
#  The interface controls provide for:
#
#	control of the display speed
#	pausing the display
#	resetting the display
#	setting the period between automatic resetting
#	changing the view
#	
############################################################################
#
#  Requires:  MT Icon, event monitoring, Version 9 graphics
#
############################################################################
#
#  Links: colormap, evinit,  interact, viewpack, vsetup
#
############################################################################
#
#  Includes:  evdefs.icn
#
############################################################################

link colormap
link evinit
link interact
link viewpack
link vsetup

$include "evdefs.icn"

global color
global vidgets
global viewer
global root
global pane
global state
global reset			# vidget for resetting callback
global snap
global name
global point
global count			# drawing count
global done
global default_color		# default in case of bad color specification
global draw			# drawing procedure for visualization
global width
global height
global period			# automatic resetting count
global refresh			# resetting switch

#  Prevent linker from deleting procedures that are not explicitly referenced.
invocable "beacon"
invocable "curves"
invocable "haystack"
invocable "nova"
invocable "pinwheel"
invocable "polygons"
invocable "splatter"
invocable "strip"
invocable "symsplat"
invocable "vortex"
invocable "web"

#  Main procedure

procedure main(args)

   init(args)

   display()

end

#  Initialization

procedure init(args)

   EvInit(args) | stop("*** cannot load SP.")

   vidgets := ui()

   root := vidgets["root"]
   reset := vidgets["reset"]

   state := &null

   width :=  vidgets["pane"].uw
   height :=  vidgets["pane"].uh

   default_color := "black"

   refresh := period := -1
   count := 0
   done := &null

   viewer := "symsplat"

   color := colormap()

   draw := proc(viewer) | stop("*** internal inconsistency")

   pane := Clone("dx=" || vidgets["pane"].ux, "dy=" || vidgets["pane"].uy,
      "bg=" || default_color)
   Clip(pane, 0, 0, width, height)

   reset_cb()

end

#  Display driver

procedure display()

   repeat {
      if period = 0 then reset_cb()
      while (*Pending() > 0) | \state do
         ProcessEvent(root, , shortcuts)
      EvGet(AllocMask) | exit()
      draw(pane, color[&eventcode], &eventvalue)
      period -:= 1
      }

end

#  Callbacks

procedure quit_cb()

   exit()

end

procedure snapshot_cb()

   snapshot(pane, 0, 0, width, height)
   
   return

end

procedure period_cb()

   repeat {
      if TextDialog("Reset period (negative value disables _
          automatic resetting:",  , refresh, 6) == "Cancel" then fail
      if refresh := period := integer(dialog_value[1]) then return
      else {
         Notice("Invalid period specification.")
         next
         }
      }

end
   
procedure reset_cb()

   EraseArea(pane, 0, 0, width, height)

   period := refresh

   return

end

procedure view_cb()
   static views

   initial {
      views := [
         "beacon",
         "curves",
         "haystack",
         "nova",
         "pinwheel",
         "polygons",
         "splatter",
         "strip",
         "symsplat",
         "vortex",
         "web"
         ]
      }

   if SelectDialog("Select viewer:", views, viewer) == "Cancel" then fail
   viewer := dialog_value
   draw := proc(viewer) | 
      return FailNotice("Internal inconsistency; viewer not found.")
   reset_cb()

   return

end

procedure shortcuts(e)

   if &meta then
      case map(e) of {
         "q":  exit()
         "r":  reset_cb()
         }

end

#===<<vib:begin>>===	modify using vib; do not remove this marker line
procedure ui_atts()
   return ["size=311,210", "bg=pale gray"]
end

procedure ui(win, cbk)
return vsetup(win, cbk,
   [":Sizer:::0,0,311,210:",],
   ["period:Button:regular::11,96,91,20:reset period",period_cb],
   ["quit:Button:regular::34,19,42,20:quit",quit_cb],
   ["reset:Button:regular::34,55,42,20:reset",reset_cb],
   ["view:Button:regular::15,133,84,20:select view",view_cb],
   ["pane:Rect:grooved::113,9,190,190:",],
   )
end
#===<<vib:end>>===	end of section maintained by vib