-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathEQUATIONFORMS
2141 lines (1789 loc) · 103 KB
/
EQUATIONFORMS
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(DEFINE-FILE-INFO READTABLE "INTERLISP" PACKAGE "INTERLISP")
(FILECREATED "18-Apr-88 14:00:00" {ERINYES}<LISPUSERS>LYRIC>EQUATIONFORMS.;2 102911
changes to%: (VARS EQUATIONFORMSCOMS)
(FNS EQ.SumGroup EQ.IntegralGroup EQ.MakeNSItem)
previous date%: "30-Apr-87 10:52:34" |{IE:PARC:XEROX}<LISP>LYRIC>LISPUSERS>EQUATIONFORMS.;1|)
(* "
Copyright (c) 1986, 1987, 1988 by Xerox Corporation. All rights reserved.
")
(PRETTYCOMPRINT EQUATIONFORMSCOMS)
(RPAQQ EQUATIONFORMSCOMS
[
(* ;;; "ATTACHEDBOX module: Part 1 of 5")
(* ;
"Utility functions to manipulate attached regions")
(* ;; "These functions use two sets of coords: global coords in which positions are given w.r.t. the lower left corner of a box, and side coords in which positions are given w.r.t. a particular side of the box. For the side coords, the origin is at the point on the side closest to the l.l. corner of the box, the x-axis points along the side toward the other end, and the y-axis points away from the box region")
(FNS AB.RealPosition AB.PointPos AB.SidePosition AB.PlaceRegion AB.AdjustToLL AB.OppositeSide
AB.RegionToBox AB.BoxToRegion AB.RelativePos AB.BiggerRegion AB.Check AB.PositionRegion
AB.Position2Regions)
(* ;;; "EQGROUP module: Part 2 of 5")
(* ; "group equation functions")
(FNS EQ.Group EQ.GroupCreate EQ.Make.group)
(* ; "set up data definitions")
[P (EQIO.AddType 'group 'EQ.Group 1 '(objectProps (enclosureKind NIL enclosureSide NIL)
pieceNames
("item")
wholeEditFn EQ.EnclosureEdit initialPropFn
EQ.GroupCreate]
(* ;;; "specific enclosure data")
(RECORDS EQ.EnclosureData)
(FNS EQ.AddEnclosure EQ.GetEnclosureData)
(* ; "set up data for enclosures")
(P (EQ.AddEnclosure 'angles (FUNCTION EQ.angles)
"< angle brackets >")
(EQ.AddEnclosure 'bars (FUNCTION EQ.bars)
"| bars |")
(EQ.AddEnclosure 'braces (FUNCTION EQ.braces)
"{ braces }")
(EQ.AddEnclosure 'brackets (FUNCTION EQ.brackets)
"[ brackets ]")
(EQ.AddEnclosure 'parentheses (FUNCTION EQ.parentheses)
"( parentheses )")
(EQIO.TypeProp 'group 'defaultEnclosure 'brackets))
(* ;;; "general enclosure functions")
(FNS EQ.enclosure EQ.EnclosureCreate EQ.EnclosureEdit EQ.EnclosureKind EQ.EnclosureSide)
(* ;;; "enclosure form functions")
(FNS EQ.angles EQ.bars EQ.braces EQ.brackets EQ.parentheses EQ.enclosureForm
EQ.enclosureWidth)
(* ;;; "enclosure drawing functions")
(FNS EQ.DrawAngles EQ.DrawBars EQ.DrawBraces EQ.DrawBrackets EQ.DrawParentheses)
(* ;;; "EQMATRIX module: Part 3 of 5")
(* ; "matrix equation functions")
(FNS EQ.Matrix EQ.Make.matrix EQ.layout EQ.MatrixAdd EQ.MatrixChanged EQ.MatrixCreate
EQ.MatrixDelete EQ.MatrixEdit EQ.MatrixGetMenu EQ.MatrixSelect)
(INITVARS (EQ.Matrix.MaxPieces 100))
(GLOBALVARS EQ.Matrix.MaxPieces)
[P (EQIO.AddType 'matrix 'EQ.Matrix 1
'(objectProps (rows 1 columns 1 enclosureKind NIL enclosureSide NIL)
variable? T wholeEditFn EQ.MatrixEdit specialSelectFn EQ.MatrixSelect
initialPropFn EQ.MatrixCreate changeFn EQ.MatrixChanged]
(* ;;; "EQNFORMS module: Part 4 of 5")
(* ; "fraction")
(FNS EQ.Fraction EQ.Make.fraction)
(* ;;; "sum group")
(FNS EQ.SumGroup EQ.Make.sum EQ.Make.product EQ.Make.union EQ.Make.intersection)
(* ;;; "integral group")
(FNS EQ.IntegralGroup EQ.Make.integral EQ.Make.lineIntegral)
(* ;;; "super- and sub- scripts")
(FNS EQ.Script EQ.Make.sub/superscripts)
(* ;;; "max/min/limit etc")
(FNS EQ.MaxMin EQ.Make.max/min)
(* ;;; "utilities")
(FNS EQ.StreamSize EQ.UseNS? EQ.MakeNSItem)
(GLOBALVARS EQ.UseNSChars EQ.NSChars)
(* ;
"EQ.UseNSChars = NIL to use press fonts for display")
[INITVARS EQ.UseNSChars (EQ.NSChars '(SUM ((CLASSIC 24)
9814)
PRODUCT
((CLASSIC 24)
9811)
SUM
((MODERN 30)
61306)
PRODUCT
((MODERN 30)
61307)
INTERSECTION
((MODERN 30)
61270)
UNION
((MODERN 30)
61271)
INTEGRAL
((MODERN 30)
61301)
LINEINTEGRAL
((MODERN 30)
61302]
[P [EQIO.AddType 'fraction 'EQ.Fraction 2 '(pieceNames ("numerator" "denominator"]
[EQIO.AddType 'sum 'EQ.SumGroup 3 '(initialData (-2 -2 0)
pieceNames
("index" "limit" "summand"]
[EQIO.AddType 'product 'EQ.SumGroup 3 '(initialData (-2 -2 0)
pieceNames
("index" "limit" "factor"]
[EQIO.AddType 'union 'EQ.SumGroup 3 '(initialData (-2 -2 0)
pieceNames
("index" "limit" "set"]
[EQIO.AddType 'intersection 'EQ.SumGroup 3 '(initialData (-2 -2 0)
pieceNames
("index" "limit" "set"]
[EQIO.AddType 'integral 'EQ.IntegralGroup 3 '(initialData (-2 -2 0)
pieceNames
("lower limit" "upper limit"
"integrand"]
(EQIO.AddType 'lineIntegral 'EQ.IntegralGroup 3 '(initialData (-2 -2 0)
pieceNames
("lower limit" "upper limit"
"integrand")
menuLabel "line integral"))
[EQIO.AddType 'sub/superscripts 'EQ.Script 5 '(initialData (0 -1 -1 -1 -1)
pieceNames
("main value" "right subscript"
"right superscript"
"left subscript"
"left superscript"]
(EQIO.AddType 'max/min 'EQ.MaxMin 3 '(initialData (0 -2 0)
pieceNames
("function" "index" "value")
menuLabel "max min limit"]
(* ;;; "EQROOT module: Part 5 of 5")
(FNS EQ.Root EQ.Make.root)
(FNS EQ.DrawRadicalSign)
(P (EQIO.AddType 'root 'EQ.Root 2 '(pieceNames ("radicand" "index")
initialData
(0 -1])
(* ;;; "ATTACHEDBOX module: Part 1 of 5")
(* ; "Utility functions to manipulate attached regions")
(* ;;
"These functions use two sets of coords: global coords in which positions are given w.r.t. the lower left corner of a box, and side coords in which positions are given w.r.t. a particular side of the box. For the side coords, the origin is at the point on the side closest to the l.l. corner of the box, the x-axis points along the side toward the other end, and the y-axis points away from the box region"
)
(DEFINEQ
(AB.RealPosition
[LAMBDA (pos box side) (* THH " 8-May-85 11:31")
(* returns position of pt. relative to l.l.
corner of box given position relative to specified side of box)
(SELECTQ side
((top bottom)
[create POSITION
XCOORD _ (fetch XCOORD of pos)
YCOORD _ (COND
((EQ side 'top)
(PLUS (fetch YSIZE of box)
(fetch YCOORD of pos)))
(T (MINUS (fetch YCOORD of pos])
((left right)
[create POSITION
YCOORD _ (fetch XCOORD of pos)
XCOORD _ (COND
((EQ side 'right)
(PLUS (fetch XSIZE of box)
(fetch YCOORD of pos)))
(T (MINUS (fetch YCOORD of pos])
NIL])
(AB.PointPos
[LAMBDA (box side pt) (* THH " 8-May-85 11:34")
(* returns position of pt relative to side --
pt is an atom specifying relative position along the side)
(PROG [(horizSide (OR (EQ side 'top)
(EQ side 'bottom]
(RETURN (create POSITION
XCOORD _ (SELECTQ pt
(low (* lower end of side)
0)
(display (* display pt of side)
(COND
(horizSide 0)
(T (fetch YDESC of box))))
(center (* center of side)
(IQUOTIENT (COND
(horizSide (fetch XSIZE of box))
(T (fetch YSIZE of box)))
2))
(high (* upper end of side)
(COND
(horizSide (fetch XSIZE of box))
(T (fetch YSIZE of box))))
NIL)
YCOORD _ 0])
(AB.SidePosition
[LAMBDA (pos box side) (* THH " 8-May-85 11:32")
(* returns position of pt rel. to side given position rel.
to l.l. corner of box)
(SELECTQ side
((top bottom)
[create POSITION
XCOORD _ (fetch XCOORD of pos)
YCOORD _ (COND
((EQ side 'top)
(DIFFERENCE (fetch YCOORD of pos)
(fetch YSIZE of box)))
(T (MINUS (fetch YCOORD of pos])
((left right)
[create POSITION
XCOORD _ (fetch YCOORD of pos)
YCOORD _ (COND
((EQ side 'right)
(DIFFERENCE (fetch XCOORD of pos)
(fetch XSIZE of box)))
(T (MINUS (fetch XCOORD of pos])
NIL])
(AB.PlaceRegion
[LAMBDA (mainBox side mainPt addBox addPt gap shift) (* THH "10-May-85 16:51")
(* returns placed region relative to l.l.
corner of main box when addBox is placed as specified)
(PROG ((posMainPt (AB.PointPos mainBox side mainPt))
(opposite (AB.OppositeSide side))
posAddPt posSide)
(SETQ posAddPt (create POSITION
XCOORD _ (PLUS (fetch XCOORD of posMainPt)
shift)
YCOORD _ (PLUS (fetch YCOORD of posMainPt)
gap)))
(SETQ posSide (AB.PointPos addBox opposite addPt))
(replace XCOORD of posSide with (DIFFERENCE (fetch XCOORD of posAddPt)
(fetch XCOORD of posSide)))
(replace YCOORD of posSide with (fetch YCOORD of posAddPt))
(SETQ posSide (AB.AdjustToLL (AB.RealPosition posSide mainBox side)
addBox side))
(RETURN (create REGION
LEFT _ (fetch XCOORD of posSide)
BOTTOM _ (fetch YCOORD of posSide)
WIDTH _ (fetch XSIZE of addBox)
HEIGHT _ (fetch YSIZE of addBox])
(AB.AdjustToLL
[LAMBDA (pos addBox side) (* THH "10-May-85 14:58")
(* gets position of l.l. corner of addBox w.r.t.
l.l of main box given pos of side opposite side of main box)
(SELECTQ side
((top right)
NIL)
(left (replace XCOORD of pos with (DIFFERENCE (fetch XCOORD of pos)
(fetch XSIZE of addBox))))
(bottom (replace YCOORD of pos with (DIFFERENCE (fetch YCOORD of pos)
(fetch YSIZE of addBox))))
NIL)
pos])
(AB.OppositeSide
[LAMBDA (side) (* THH " 8-May-85 14:11")
(SELECTQ side
(top 'bottom)
(bottom 'top)
(left 'right)
(right 'left)
NIL])
(AB.RegionToBox
[LAMBDA (region displayYPos) (* thh%: "13-May-85 10:16")
(* returns image box corresponding to region whose y display position, relative
to (0,0) is given by displayYPos)
(COND
((NOT displayYPos)
(SETQ displayYPos 0)))
(create IMAGEBOX
XSIZE _ (fetch WIDTH of region)
YSIZE _ (fetch HEIGHT of region)
YDESC _ (DIFFERENCE displayYPos (fetch BOTTOM of region))
XKERN _ 0])
(AB.BoxToRegion
[LAMBDA (box cornerXPos cornerYPos) (* thh%: "13-May-85 09:54")
(* returns region corresponding to image box whose l.l.
corner is positioned at cornerXPos, cornerYPos --
if cornerYPos is NIL then cornerXPos should be a position)
[COND
((NOT cornerYPos)
(SETQ cornerYPos (fetch YCOORD of cornerXPos))
(SETQ cornerXPos (fetch XCOORD of cornerXPos]
(create REGION
LEFT _ cornerXPos
BOTTOM _ cornerYPos
WIDTH _ (fetch XSIZE of box)
HEIGHT _ (fetch YSIZE of box])
(AB.RelativePos
[LAMBDA (region bigRegion yShift) (* thh%: "13-May-85 10:27")
(* returns relative position of l.l. of region w.r.t.
l.l. of bigRegion)
(create POSITION
XCOORD _ (DIFFERENCE (fetch LEFT of region)
(fetch LEFT of bigRegion))
YCOORD _ (PLUS (DIFFERENCE (fetch BOTTOM of region)
(fetch BOTTOM of bigRegion))
yShift])
(AB.BiggerRegion
[LAMBDA (region extra) (* THH "23-May-85 14:03")
(* creates a region that has extra
space all around)
(* extra should be nonnegative)
(COND
((OR (NOT extra)
(ZEROP extra))
region)
(T (create REGION
LEFT _ (DIFFERENCE (fetch LEFT of region)
extra)
BOTTOM _ (DIFFERENCE (fetch BOTTOM of region)
extra)
WIDTH _ (PLUS (fetch WIDTH of region)
(TIMES 2 extra))
HEIGHT _ (PLUS (fetch HEIGHT of region)
(TIMES 2 extra])
(AB.Check
[LAMBDA (region regionList side clear) (* THH "23-May-85 14:02")
(* moves region away from side if it overlaps any regions in regionList)
(COND
((NOT clear)
(SETQ clear 0)))
[COND
((GREATERP clear 0)
(SETQ regionList (for r in regionList collect (AB.BiggerRegion r clear]
(* must go through list repeatedly since moving region could cause it to
overlap previous regions)
[repeatwhile overlap bind overlap
do (SETQ overlap NIL)
(for r in regionList do (COND
((REGIONSINTERSECTP region r)
(SETQ overlap T)
(SELECTQ side
(top (replace BOTTOM of region
with (PLUS (fetch BOTTOM of r)
(fetch HEIGHT of r))))
(bottom (replace BOTTOM of region
with (DIFFERENCE (fetch BOTTOM of r)
(fetch HEIGHT of region))))
(left (replace LEFT of region
with (DIFFERENCE (fetch LEFT of r)
(fetch WIDTH of region))))
(right (replace LEFT of region
with (PLUS (fetch LEFT of r)
(fetch WIDTH of r))))
(SHOULDNT]
region])
(AB.PositionRegion
[LAMBDA (mainBox addedRegions side mainPt addBox addPt gap shift clear)
(* thh%: " 9-Jan-86 10:00")
(* positions addBox next to side of mainBox so that addPt on the added box is
at the specified relative position to the mainPt on the main box, then moves
addBox away from mainBox if necessary to avoid being within distance clear of
added regions on other sides as specified in addedRegions.
Returns (region newAddedRegions) where region is region of added box w.r.t.
l.l. corner of mainBox and newAddedRegions includes this new box to prevent
future additions from overlapping it)
(PROG ((place (AB.Check (AB.PlaceRegion mainBox side mainPt addBox addPt gap shift)
addedRegions side clear)))
(RETURN (CONS place addedRegions])
(AB.Position2Regions
[LAMBDA (mainBox addedRegions side highBox highPt lowBox lowPt highGap lowGap highShift lowShift
clear) (* thh%: " 9-Jan-86 10:00")
(* positions highBox and lowBox next to side on mainBox --
moves the boxes apart if they are closer than clear apart, and moves them away
from mainBox if they overlap previous regions as specfied by addedRegions)
(* returns (highRegion lowRegion newAddedRegions) where regions are w.r.t.
l.l. corner of mainBox and newAddedRegions includes the added regions)
(PROG (placeHigh placeLow)
(SETQ placeHigh (AB.PlaceRegion mainBox side 'high highBox highPt highGap highShift))
(SETQ placeLow (AB.PlaceRegion mainBox side 'low lowBox lowPt lowGap lowShift))
(COND
((NOT clear)
(SETQ clear 0)))
[COND
((REGIONSINTERSECTP placeHigh (AB.BiggerRegion placeLow clear))
(* move regions apart)
(PROG (shift totalSize) (* if the two added regions overlap
then separate them)
(SELECTQ side
((top bottom)
(SETQ shift (DIFFERENCE (PLUS (fetch LEFT of placeLow)
(fetch WIDTH of placeLow)
clear)
(fetch LEFT of placeHigh)))
[COND
((GREATERP shift 0)
(SETQ totalSize (PLUS (fetch WIDTH of placeLow)
(fetch WIDTH of placeHigh)))
[add (fetch LEFT of placeLow)
(MINUS (FIX (PLUS 0.5 (FQUOTIENT (TIMES shift
(fetch WIDTH
of placeLow))
totalSize]
(add (fetch LEFT of placeHigh)
(FIX (PLUS 0.5 (FQUOTIENT (TIMES shift (fetch WIDTH
of placeHigh))
totalSize])
((left right)
(SETQ shift (DIFFERENCE (PLUS (fetch BOTTOM of placeLow)
(fetch HEIGHT of placeLow)
clear)
(fetch BOTTOM of placeHigh)))
[COND
((GREATERP shift 0)
(SETQ totalSize (PLUS (fetch HEIGHT of placeLow)
(fetch HEIGHT of placeHigh)))
[add (fetch BOTTOM of placeLow)
(MINUS (FIX (PLUS 0.5 (FQUOTIENT (TIMES shift
(fetch HEIGHT
of placeLow))
totalSize]
(add (fetch BOTTOM of placeHigh)
(FIX (PLUS 0.5 (FQUOTIENT (TIMES shift (fetch HEIGHT
of placeHigh))
totalSize])
(SHOULDNT]
(SETQ placeLow (AB.Check placeLow addedRegions side clear))
(SETQ placeHigh (AB.Check placeHigh addedRegions side clear))
(RETURN (CONS placeHigh (CONS placeLow addedRegions])
)
(* ;;; "EQGROUP module: Part 2 of 5")
(* ; "group equation functions")
(DEFINEQ
(EQ.Group
[LAMBDA (eqnObj imageStream draw?) (* THH "12-Jul-85 08:24")
(* form function for group --
one argument with enclosure)
(LET ((innerBox (FS.Box (EQIO.EqnData eqnObj 1)
imageStream))
enclose pos)
(SETQ enclose (EQ.enclosure innerBox eqnObj imageStream draw?))
(SETQ pos (CDR enclose))
(add (fetch YCOORD of pos)
(fetch YDESC of innerBox))
(EQIO.MakeSpec (CAR enclose)
(LIST (EQIO.MakeDataSpec pos])
(EQ.GroupCreate
[LAMBDA NIL (* thh%: " 1-Jul-85 14:57")
(EQ.EnclosureCreate T])
(EQ.Make.group
[LAMBDA (data enclosureKind enclosureSide fontSpec) (* thh%: " 9-Jan-86 10:24")
(EQN.Make 'group (LIST data)
fontSpec
(LIST 'enclosureKind enclosureKind 'enclosureSide enclosureSide])
)
(* ; "set up data definitions")
(EQIO.AddType 'group 'EQ.Group 1 '(objectProps (enclosureKind NIL enclosureSide NIL)
pieceNames
("item")
wholeEditFn EQ.EnclosureEdit initialPropFn EQ.GroupCreate))
(* ;;; "specific enclosure data")
(DECLARE%: EVAL@COMPILE
(RECORD EQ.EnclosureData (formFn label))
)
(DEFINEQ
(EQ.AddEnclosure
[LAMBDA (kind formFn label) (* THH "12-Jul-85 08:18")
(* adds data for new form of enclosure)
(LET ((enclosures (EQIO.TypeProp 'group 'enclosures))
(newValue (create EQ.EnclosureData
formFn _ formFn
label _ label)))
[COND
(enclosures (LISTPUT enclosures kind newValue))
(T (SETQ enclosures (LIST kind newValue]
(EQIO.TypeProp 'group 'enclosures enclosures)
(EQIO.TypeProp 'group 'kindMenu NIL])
(EQ.GetEnclosureData
[LAMBDA (kind) (* THH "12-Jul-85 08:19")
(LISTGET (EQIO.TypeProp 'group 'enclosures)
kind])
)
(* ; "set up data for enclosures")
(EQ.AddEnclosure 'angles (FUNCTION EQ.angles)
"< angle brackets >")
(EQ.AddEnclosure 'bars (FUNCTION EQ.bars)
"| bars |")
(EQ.AddEnclosure 'braces (FUNCTION EQ.braces)
"{ braces }")
(EQ.AddEnclosure 'brackets (FUNCTION EQ.brackets)
"[ brackets ]")
(EQ.AddEnclosure 'parentheses (FUNCTION EQ.parentheses)
"( parentheses )")
(EQIO.TypeProp 'group 'defaultEnclosure 'brackets)
(* ;;; "general enclosure functions")
(DEFINEQ
(EQ.enclosure
[LAMBDA (innerBox eqnObj imageStream draw?) (* THH "12-Jul-85 08:32")
(* returns (outerBox . pos) where outerBox is box with enclosures and pos is
position of l.l. corner of inner box wrt l.l.
corner of outer box)
(* if draw? is non-NIL, draws the
enclosures)
(LET [[kind (OR (EQIO.EqnProperty eqnObj 'enclosureKind)
(EQIO.TypeProp 'group 'defaultEnclosure]
(which (EQIO.EqnProperty eqnObj 'enclosureSide]
(COND
([NOT (OR (EQ which 'left)
(EQ which 'right]
(SETQ which NIL)))
(LET [(formFn (fetch (EQ.EnclosureData formFn) of (EQ.GetEnclosureData kind]
(COND
(formFn
(* note%: use of kind arg allows same formFn to be used for different
enclosures)
(APPLY* formFn innerBox imageStream draw? which kind))
(T
(* no enclosure so outer box is same as inner box)
(CONS innerBox (create POSITION
XCOORD _ 0
YCOORD _ 0])
(EQ.EnclosureCreate
[LAMBDA (getWhich?) (* thh%: " 1-Jul-85 14:46")
(* returns prop list describing
desired enclosure)
(* if getWhich? is non-NIL also asks for side specification for enclosure)
(LET ((kind (EQ.EnclosureKind))
which)
(COND
(getWhich? (SETQ which (EQ.EnclosureSide))
(LIST 'enclosureKind kind 'enclosureSide which))
(T (LIST 'enclosureKind kind])
(EQ.EnclosureEdit
[LAMBDA (eqnObj) (* thh%: " 1-Jul-85 14:55")
(* allows type of enclosure to be
changed)
(* returns non-NIL if object changed)
(LET ((editMenu (EQIO.TypeProp 'group 'editMenu))
newValue)
(COND
((NOT (type? MENU editMenu))
[SETQ editMenu (create MENU
CENTERFLG _ T
TITLE _ "change what?"
ITEMS _ '(("symbol" 'kind)
("which side" 'side]
(EQIO.TypeProp 'group 'editMenu editMenu)))
(SELECTQ (MENU editMenu)
(kind (COND
((SETQ newValue (EQ.EnclosureKind))
(EQIO.EqnProperty eqnObj 'enclosureKind newValue)
T)
(T NIL)))
(side (COND
((SETQ newValue (EQ.EnclosureSide))
(EQIO.EqnProperty eqnObj 'enclosureSide newValue)
T)
(T NIL)))
NIL])
(EQ.EnclosureKind
[LAMBDA NIL (* THH "12-Jul-85 08:39")
(* gets desired kind of enclosure)
(LET [(kindMenu (EQIO.TypeProp 'group 'kindMenu]
(COND
((NOT (type? MENU kindMenu))
(SETQ kindMenu (create MENU
CENTERFLG _ T
ITEMS _ [LET [(enclosures (EQIO.TypeProp 'group 'enclosures]
(while enclosures bind kind data
collect (SETQ kind (CAR enclosures))
(SETQ data (CADR enclosures))
(SETQ enclosures (CDDR enclosures))
(LIST (fetch (EQ.EnclosureData label)
of data)
(KWOTE kind]
TITLE _ "enclosures"))
(EQIO.TypeProp 'group 'kindMenu kindMenu)))
(MENU kindMenu])
(EQ.EnclosureSide
[LAMBDA NIL (* thh%: " 1-Jul-85 14:48")
(* gets desired side for enclosure)
(LET [(whichMenu (EQIO.TypeProp 'group 'whichMenu]
(COND
((NOT (type? MENU whichMenu))
(SETQ whichMenu (create MENU
ITEMS _ '(left right both)
TITLE _ "Which side?"))
(EQIO.TypeProp 'group 'whichMenu whichMenu)))
(MENU whichMenu])
)
(* ;;; "enclosure form functions")
(DEFINEQ
(EQ.angles
[LAMBDA (innerBox imageStream draw? which) (* ; "Edited 21-Apr-87 09:00 by thh:")
(LET ((size (EQ.StreamSize imageStream))
Hgap Hex Vgap Vex width height descent spacing overlap)
(SETQ Hex size)
(SETQ Vgap size)
(SETQ Vex Hex)
(SETQ height (PLUS (fetch YSIZE of innerBox)
(TIMES 2 Vgap)))
(SETQ width (EQ.enclosureWidth size height))
(SETQ Hgap (MAX (TIMES 3 size)
(IQUOTIENT height 5)))
[SETQ spacing (PLUS (fetch XSIZE of innerBox)
(TIMES 2 (PLUS Hgap width]
(SETQ descent (PLUS (fetch YDESC of innerBox)
Vgap))
(SETQ overlap (MAX (TIMES 2 size)
(IQUOTIENT (PLUS Hgap width)
2)))
(* * draw angle brackets if requested)
(COND
(draw? (EQ.DrawAngles height descent spacing Hex width overlap imageStream which)))
(* * determine outer box and position of inner box)
(EQ.enclosureForm spacing Hex height Vex descent width NIL Hgap Vgap])
(EQ.bars
[LAMBDA (innerBox imageStream draw? which) (* ; "Edited 21-Apr-87 09:00 by thh:")
(LET ((size (EQ.StreamSize imageStream))
Hgap Hex Vgap Vex width height descent spacing)
(SETQ Hgap (TIMES 2 size))
(SETQ Hex size)
(SETQ Vgap Hgap)
(SETQ Vex Hex)
(SETQ height (PLUS (fetch YSIZE of innerBox)
(TIMES 2 Vgap)))
(SETQ width (EQ.enclosureWidth size height))
[SETQ spacing (PLUS (fetch XSIZE of innerBox)
(TIMES 2 (PLUS Hgap width]
(SETQ descent (PLUS (fetch YDESC of innerBox)
Vgap))
(* * draw bars if requested)
(COND
(draw? (EQ.DrawBars height descent spacing Hex width imageStream which)))
(* * determine outer box and position of inner box)
(EQ.enclosureForm spacing Hex height Vex descent width NIL Hgap Vgap])
(EQ.braces
[LAMBDA (innerBox imageStream draw? which) (* ; "Edited 21-Apr-87 09:01 by thh:")
(LET ((size (EQ.StreamSize imageStream))
Hgap Hex Vgap Vex width height descent spacing overlap point space extra)
(SETQ Vgap (TIMES 3 size))
(SETQ Hex size)
(SETQ Vex Hex)
(SETQ height (PLUS (fetch YSIZE of innerBox)
(TIMES 2 Vgap)))
(SETQ width (EQ.enclosureWidth size height))
(add height (TIMES 2 width))
(SETQ descent (PLUS (fetch YDESC of innerBox)
Vgap width))
(SETQ Hgap (MAX (TIMES 4 size)
(IQUOTIENT height 5)))
[SETQ spacing (PLUS (fetch XSIZE of innerBox)
(TIMES 2 (PLUS Hgap width]
(SETQ overlap (PLUS Hgap width))
(SETQ point (PLUS size (IQUOTIENT overlap 2)))
(SETQ space (IQUOTIENT overlap 2))
(SETQ extra space)
(* * draw braces if requested)
(COND
(draw? (EQ.DrawBraces height descent spacing Hex width overlap extra point space
imageStream which)))
(* * determine outer box and position of inner box)
(EQ.enclosureForm spacing Hex height Vex descent width T Hgap Vgap])
(EQ.brackets
[LAMBDA (innerBox imageStream draw? which) (* ; "Edited 21-Apr-87 09:02 by thh:")
(LET ((size (EQ.StreamSize imageStream))
Hgap Hex Vgap Vex width height descent spacing overlap)
(SETQ Hgap (TIMES 3 size))
(SETQ Hex size)
(SETQ Vgap Hgap)
(SETQ Vex Hex)
(SETQ height (PLUS (fetch YSIZE of innerBox)
(TIMES 2 Vgap)))
(SETQ width (EQ.enclosureWidth size height))
(add height (TIMES 2 width))
[SETQ spacing (PLUS (fetch XSIZE of innerBox)
(TIMES 2 (PLUS Hgap width]
(SETQ descent (PLUS (fetch YDESC of innerBox)
Vgap width))
(SETQ overlap (MAX (TIMES 3 size)
(PLUS Hgap width)))
(* * draw brackets if requested)
(COND
(draw? (EQ.DrawBrackets height descent spacing Hex width overlap imageStream which)))
(* * determine outer box and position of inner box)
(EQ.enclosureForm spacing Hex height Vex descent width T Hgap Vgap])
(EQ.parentheses
[LAMBDA (innerBox imageStream draw? which) (* ; "Edited 21-Apr-87 09:03 by thh:")
(LET ((size (EQ.StreamSize imageStream))
Hgap Hex Vgap Vex width height descent spacing overlap)
(SETQ Vgap (TIMES 2 size))
(SETQ Hex size)
(SETQ Vex Hex)
(SETQ height (PLUS (fetch YSIZE of innerBox)
(TIMES 2 Vgap)))
(SETQ width (EQ.enclosureWidth size height))
(add height (TIMES 2 width))
(SETQ descent (PLUS (fetch YDESC of innerBox)
Vgap width))
(SETQ Hgap (MAX (TIMES 2 size)
(IQUOTIENT height 8)))
[SETQ spacing (PLUS (fetch XSIZE of innerBox)
(TIMES 2 (PLUS Hgap width]
(SETQ overlap (MAX (TIMES 3 size)
(IQUOTIENT (PLUS Hgap width)
2)))
(* * draw braces if requested)
(COND
(draw? (EQ.DrawParentheses height descent spacing Hex width overlap imageStream which)))
(* * determine outer box and position of inner box)
(EQ.enclosureForm spacing Hex height Vex descent width T Hgap Vgap])
(EQ.enclosureForm
[LAMBDA (spacing Hex height Vex descent width verticalWidth? Hgap Vgap)
(* ; "Edited 21-Apr-87 08:59 by thh:")
(* computes outer box and position of inner box from parameters --
verticalWidth? non-NIL means enclosure wraps under the box)
(CONS (create IMAGEBOX
XSIZE _ (PLUS spacing (TIMES 2 Hex))
YSIZE _ (PLUS height (TIMES 2 Vex))
YDESC _ (PLUS descent Vex)
XKERN _ 0)
(create POSITION
XCOORD _ (PLUS Hgap width Hex)
YCOORD _ (PLUS Vgap (COND
(verticalWidth? width)
(T 0))
Vex])
(EQ.enclosureWidth
[LAMBDA (size height) (* THH "16-Jul-85 09:15")
(MAX size (IQUOTIENT height 100])
)
(* ;;; "enclosure drawing functions")
(DEFINEQ
(EQ.DrawAngles
[LAMBDA (height descent spacing xShift width overlap imageStream which)
(* thh%: "19-Aug-85 09:49")
(* draws specified angle brackets on
imageStream)
(LET ((halfWidth (IQUOTIENT width 2))
(halfWidth1 (IQUOTIENT (SUB1 width)
2))
(lowerX (PLUS (DSPXPOSITION NIL imageStream)
xShift))
(lowerY (DIFFERENCE (DSPYPOSITION NIL imageStream)
descent))
top middle left right)
(SETQ top (PLUS lowerY (SUB1 height)))
(SETQ middle (PLUS lowerY (IQUOTIENT (SUB1 height)
2)))
(* * left angle bracket)
(COND
((NOT (EQ which 'right))
(SETQ left (PLUS lowerX overlap halfWidth))
(DRAWLINE left lowerY (PLUS lowerX halfWidth)
middle width NIL imageStream)
(DRAWLINE (PLUS lowerX halfWidth)
middle left top width NIL imageStream)))
(* * right angle bracket)
(COND
((NOT (EQ which 'left))
[SETQ right (PLUS lowerX (SUB1 spacing)
(MINUS (PLUS overlap halfWidth1]
(DRAWLINE right lowerY (PLUS lowerX (SUB1 spacing)
(MINUS halfWidth1))
middle width NIL imageStream)
(DRAWLINE (PLUS lowerX (SUB1 spacing)
(MINUS halfWidth1))
middle right top width NIL imageStream])
(EQ.DrawBars
[LAMBDA (height descent spacing xShift width imageStream which)
(* thh%: "19-Aug-85 09:53")
(* draws specified vertical bar on
imageStream)
(PROG ((halfWidth (IQUOTIENT width 2))
(halfWidth1 (IQUOTIENT (SUB1 width)
2))
(lowerX (PLUS (DSPXPOSITION NIL imageStream)
xShift))
(lowerY (DIFFERENCE (DSPYPOSITION NIL imageStream)
descent)))
(* * left bar)
(COND
((NOT (EQ which 'right))
(MOVETO (PLUS lowerX halfWidth1)
lowerY imageStream)
(RELDRAWTO 0 (SUB1 height)
width NIL imageStream)))
(* * right bar)
(COND
((NOT (EQ which 'left))
(MOVETO (DIFFERENCE (PLUS lowerX spacing)
halfWidth)
lowerY imageStream)
(RELDRAWTO 0 (SUB1 height)
width NIL imageStream])
(EQ.DrawBraces
[LAMBDA (height descent spacing xShift width overlap extra point space imageStream which)
(* THH "16-Jul-85 09:20")
(* draws specified brace on
imageStream)
(LET ((halfWidth (IQUOTIENT width 2))
(halfWidth1 (IQUOTIENT (SUB1 width)
2))
(lowerX (PLUS (DSPXPOSITION NIL imageStream)
xShift))
(lowerY (DIFFERENCE (DSPYPOSITION NIL imageStream)
descent))
top middle left1 left2 right1 right2)
(SETQ top (PLUS lowerY (SUB1 height)))
(SETQ middle (PLUS lowerY (IQUOTIENT (SUB1 height)
2)))
(* * left brace)
(COND
((NOT (EQ which 'right))
(SETQ left1 (PLUS lowerX (SUB1 overlap)))
(SETQ left2 (PLUS lowerX (SUB1 point)))
(DRAWCURVE (LIST (create POSITION
XCOORD _ left1