Artifact
4263a010f13fce9ac23c04bbffeefce09d1d227e:
0000: 3b 3b 20 2d 2a 2d 20 6d 6f 64 65 3a 20 53 63 68 ;; -*- mode: Sch
0010: 65 6d 65 3b 20 74 61 62 2d 77 69 64 74 68 3a 20 eme; tab-width:
0020: 32 3b 20 2d 2a 2d 20 3b 3b 0a 0a 3b 3b 20 7b 7b 2; -*- ;;..;; {{
0030: 7b 20 44 61 74 61 20 74 79 70 65 73 0a 0a 28 66 { Data types..(f
0040: 6f 72 65 69 67 6e 2d 64 65 63 6c 61 72 65 0a 09 oreign-declare..
0050: 22 23 69 6e 63 6c 75 64 65 20 3c 69 75 70 2e 68 "#include <iup.h
0060: 3e 5c 6e 22 0a 09 22 23 69 6e 63 6c 75 64 65 20 >\n".."#include
0070: 3c 69 75 70 5f 70 70 6c 6f 74 2e 68 3e 5c 6e 22 <iup_pplot.h>\n"
0080: 29 0a 09 0a 28 69 6e 63 6c 75 64 65 20 22 69 75 )...(include "iu
0090: 70 2d 74 79 70 65 73 2e 73 63 6d 22 29 0a 0a 3b p-types.scm")..;
00a0: 3b 20 7d 7d 7d 0a 0a 3b 3b 20 7b 7b 7b 20 50 50 ; }}}..;; {{{ PP
00b0: 6c 6f 74 20 63 6f 6e 74 72 6f 6c 0a 0a 28 64 65 lot control..(de
00c0: 66 69 6e 65 20 70 70 6c 6f 74 0a 20 20 28 6d 61 fine pplot. (ma
00d0: 6b 65 2d 63 6f 6e 73 74 72 75 63 74 6f 72 2d 70 ke-constructor-p
00e0: 72 6f 63 65 64 75 72 65 0a 20 20 09 28 66 6f 72 rocedure. .(for
00f0: 65 69 67 6e 2d 6c 61 6d 62 64 61 20 6e 6f 6e 6e eign-lambda nonn
0100: 75 6c 6c 2d 69 68 61 6e 64 6c 65 20 22 49 75 70 ull-ihandle "Iup
0110: 50 50 6c 6f 74 22 29 29 29 0a 0a 3b 3b 20 7d 7d PPlot")))..;; }}
0120: 7d 0a 0a 3b 3b 20 7b 7b 7b 20 50 6c 6f 74 74 69 }..;; {{{ Plotti
0130: 6e 67 20 66 75 6e 63 74 69 6f 6e 73 0a 0a 28 64 ng functions..(d
0140: 65 66 69 6e 65 20 63 61 6c 6c 2d 77 69 74 68 2d efine call-with-
0150: 70 70 6c 6f 74 0a 20 20 28 6c 65 74 72 65 63 20 pplot. (letrec
0160: 28 5b 70 70 6c 6f 74 2d 62 65 67 69 6e 20 28 66 ([pplot-begin (f
0170: 6f 72 65 69 67 6e 2d 6c 61 6d 62 64 61 20 76 6f oreign-lambda vo
0180: 69 64 20 22 49 75 70 50 50 6c 6f 74 42 65 67 69 id "IupPPlotBegi
0190: 6e 22 20 6e 6f 6e 6e 75 6c 6c 2d 69 68 61 6e 64 n" nonnull-ihand
01a0: 6c 65 20 62 6f 6f 6c 29 5d 0a 20 20 20 20 20 20 le bool)].
01b0: 20 20 20 20 20 5b 70 70 6c 6f 74 2d 65 6e 64 20 [pplot-end
01c0: 28 66 6f 72 65 69 67 6e 2d 6c 61 6d 62 64 61 20 (foreign-lambda
01d0: 76 6f 69 64 20 22 49 75 70 50 50 6c 6f 74 45 6e void "IupPPlotEn
01e0: 64 22 20 6e 6f 6e 6e 75 6c 6c 2d 69 68 61 6e 64 d" nonnull-ihand
01f0: 6c 65 29 5d 29 0a 20 20 20 20 28 6c 61 6d 62 64 le)]). (lambd
0200: 61 20 28 68 61 6e 64 6c 65 20 70 72 6f 63 20 23 a (handle proc #
0210: 21 6b 65 79 20 5b 78 2d 73 74 72 69 6e 67 3f 20 !key [x-string?
0220: 23 66 5d 29 0a 20 20 20 20 20 20 28 64 79 6e 61 #f]). (dyna
0230: 6d 69 63 2d 77 69 6e 64 0a 20 20 20 20 20 20 20 mic-wind.
0240: 28 6c 61 6d 62 64 61 20 28 29 0a 20 20 20 20 20 (lambda ().
0250: 20 20 20 20 28 70 70 6c 6f 74 2d 62 65 67 69 6e (pplot-begin
0260: 20 68 61 6e 64 6c 65 20 78 2d 73 74 72 69 6e 67 handle x-string
0270: 3f 29 29 0a 20 20 20 20 20 20 20 28 6c 61 6d 62 ?)). (lamb
0280: 64 61 20 28 29 0a 20 20 20 20 20 20 20 20 20 28 da (). (
0290: 70 72 6f 63 20 68 61 6e 64 6c 65 29 29 0a 20 20 proc handle)).
02a0: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 29 0a (lambda ().
02b0: 20 20 20 20 20 20 20 20 20 28 70 70 6c 6f 74 2d (pplot-
02c0: 65 6e 64 20 68 61 6e 64 6c 65 29 29 29 29 29 29 end handle))))))
02d0: 0a 0a 28 64 65 66 69 6e 65 20 70 70 6c 6f 74 2d ..(define pplot-
02e0: 61 64 64 21 0a 20 20 28 6c 65 74 72 65 63 20 28 add!. (letrec (
02f0: 5b 61 70 70 65 6e 64 2f 72 65 61 6c 20 28 66 6f [append/real (fo
0300: 72 65 69 67 6e 2d 6c 61 6d 62 64 61 20 76 6f 69 reign-lambda voi
0310: 64 20 22 49 75 70 50 50 6c 6f 74 41 64 64 22 20 d "IupPPlotAdd"
0320: 6e 6f 6e 6e 75 6c 6c 2d 69 68 61 6e 64 6c 65 20 nonnull-ihandle
0330: 66 6c 6f 61 74 20 66 6c 6f 61 74 29 5d 0a 20 20 float float)].
0340: 20 20 20 20 20 20 20 20 20 5b 61 70 70 65 6e 64 [append
0350: 2f 73 74 72 69 6e 67 20 28 66 6f 72 65 69 67 6e /string (foreign
0360: 2d 6c 61 6d 62 64 61 20 76 6f 69 64 20 22 49 75 -lambda void "Iu
0370: 70 50 50 6c 6f 74 41 64 64 53 74 72 22 20 6e 6f pPPlotAddStr" no
0380: 6e 6e 75 6c 6c 2d 69 68 61 6e 64 6c 65 20 63 2d nnull-ihandle c-
0390: 73 74 72 69 6e 67 20 66 6c 6f 61 74 29 5d 0a 20 string float)].
03a0: 20 20 20 20 20 20 20 20 20 20 5b 69 6e 73 65 72 [inser
03b0: 74 2f 72 65 61 6c 20 28 66 6f 72 65 69 67 6e 2d t/real (foreign-
03c0: 6c 61 6d 62 64 61 20 76 6f 69 64 20 22 49 75 70 lambda void "Iup
03d0: 50 50 6c 6f 74 49 6e 73 65 72 74 22 20 6e 6f 6e PPlotInsert" non
03e0: 6e 75 6c 6c 2d 69 68 61 6e 64 6c 65 20 69 6e 74 null-ihandle int
03f0: 20 69 6e 74 20 66 6c 6f 61 74 20 66 6c 6f 61 74 int float float
0400: 29 5d 0a 20 20 20 20 20 20 20 20 20 20 20 5b 69 )]. [i
0410: 6e 73 65 72 74 2f 73 74 72 69 6e 67 20 28 66 6f nsert/string (fo
0420: 72 65 69 67 6e 2d 6c 61 6d 62 64 61 20 76 6f 69 reign-lambda voi
0430: 64 20 22 49 75 70 50 50 6c 6f 74 49 6e 73 65 72 d "IupPPlotInser
0440: 74 53 74 72 22 20 6e 6f 6e 6e 75 6c 6c 2d 69 68 tStr" nonnull-ih
0450: 61 6e 64 6c 65 20 69 6e 74 20 69 6e 74 20 63 2d andle int int c-
0460: 73 74 72 69 6e 67 20 66 6c 6f 61 74 29 5d 0a 20 string float)].
0470: 20 20 20 20 20 20 20 20 20 20 5b 63 75 72 72 65 [curre
0480: 6e 74 2d 69 6e 64 65 78 20 28 6c 61 6d 62 64 61 nt-index (lambda
0490: 20 28 68 61 6e 64 6c 65 29 20 28 73 74 72 69 6e (handle) (strin
04a0: 67 2d 3e 6e 75 6d 62 65 72 20 28 61 74 74 72 69 g->number (attri
04b0: 62 75 74 65 20 68 61 6e 64 6c 65 20 27 63 75 72 bute handle 'cur
04c0: 72 65 6e 74 29 29 29 5d 29 0a 20 20 20 20 28 6c rent)))]). (l
04d0: 61 6d 62 64 61 20 28 68 61 6e 64 6c 65 20 78 20 ambda (handle x
04e0: 79 20 23 21 6f 70 74 69 6f 6e 61 6c 20 5b 73 61 y #!optional [sa
04f0: 6d 70 6c 65 2d 69 6e 64 65 78 20 23 66 5d 20 5b mple-index #f] [
0500: 69 6e 64 65 78 20 23 66 5d 29 0a 20 20 20 20 20 index #f]).
0510: 20 28 69 66 20 28 73 74 72 69 6e 67 3f 20 78 29 (if (string? x)
0520: 0a 20 20 20 20 20 20 20 20 20 20 28 69 66 20 69 . (if i
0530: 6e 64 65 78 0a 20 20 20 20 20 20 20 20 20 20 20 ndex.
0540: 20 20 20 28 69 6e 73 65 72 74 2f 73 74 72 69 6e (insert/strin
0550: 67 20 68 61 6e 64 6c 65 20 28 6f 72 20 69 6e 64 g handle (or ind
0560: 65 78 20 28 63 75 72 72 65 6e 74 2d 69 6e 64 65 ex (current-inde
0570: 78 20 68 61 6e 64 6c 65 29 29 20 73 61 6d 70 6c x handle)) sampl
0580: 65 2d 69 6e 64 65 78 20 78 20 79 29 0a 20 20 20 e-index x y).
0590: 20 20 20 20 20 20 20 20 20 20 20 28 61 70 70 65 (appe
05a0: 6e 64 2f 73 74 72 69 6e 67 20 68 61 6e 64 6c 65 nd/string handle
05b0: 20 78 20 79 29 29 0a 20 20 20 20 20 20 20 20 20 x y)).
05c0: 20 28 69 66 20 69 6e 64 65 78 0a 20 20 20 20 20 (if index.
05d0: 20 20 20 20 20 20 20 20 20 28 69 6e 73 65 72 74 (insert
05e0: 2f 72 65 61 6c 20 68 61 6e 64 6c 65 20 28 6f 72 /real handle (or
05f0: 20 69 6e 64 65 78 20 28 63 75 72 72 65 6e 74 2d index (current-
0600: 69 6e 64 65 78 20 68 61 6e 64 6c 65 29 29 20 73 index handle)) s
0610: 61 6d 70 6c 65 2d 69 6e 64 65 78 20 78 20 79 29 ample-index x y)
0620: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 . (
0630: 61 70 70 65 6e 64 2f 72 65 61 6c 20 68 61 6e 64 append/real hand
0640: 6c 65 20 78 20 79 29 29 29 29 29 29 0a 0a 28 64 le x y))))))..(d
0650: 65 66 69 6e 65 20 70 70 6c 6f 74 2d 78 2f 79 2d efine pplot-x/y-
0660: 3e 70 69 78 65 6c 2d 78 2f 79 0a 09 28 6c 65 74 >pixel-x/y..(let
0670: 72 65 63 20 28 5b 74 72 61 6e 73 66 6f 72 6d 20 rec ([transform
0680: 28 66 6f 72 65 69 67 6e 2d 6c 61 6d 62 64 61 20 (foreign-lambda
0690: 76 6f 69 64 20 22 49 75 70 50 50 6c 6f 74 54 72 void "IupPPlotTr
06a0: 61 6e 73 66 6f 72 6d 22 20 6e 6f 6e 6e 75 6c 6c ansform" nonnull
06b0: 2d 69 68 61 6e 64 6c 65 20 66 6c 6f 61 74 20 66 -ihandle float f
06c0: 6c 6f 61 74 20 28 63 2d 70 6f 69 6e 74 65 72 20 loat (c-pointer
06d0: 69 6e 74 29 20 28 63 2d 70 6f 69 6e 74 65 72 20 int) (c-pointer
06e0: 69 6e 74 29 29 5d 29 0a 09 09 28 6c 61 6d 62 64 int))])...(lambd
06f0: 61 20 28 68 61 6e 64 6c 65 20 70 70 6c 6f 74 2d a (handle pplot-
0700: 78 20 70 70 6c 6f 74 2d 79 29 0a 09 09 09 28 6c x pplot-y)....(l
0710: 65 74 2d 6c 6f 63 61 74 69 6f 6e 20 28 5b 70 69 et-location ([pi
0720: 78 65 6c 2d 78 20 69 6e 74 20 30 5d 20 5b 70 69 xel-x int 0] [pi
0730: 78 65 6c 2d 79 20 69 6e 74 20 30 5d 29 0a 09 09 xel-y int 0])...
0740: 09 09 28 74 72 61 6e 73 66 6f 72 6d 20 68 61 6e ..(transform han
0750: 64 6c 65 20 70 70 6c 6f 74 2d 78 20 70 70 6c 6f dle pplot-x pplo
0760: 74 2d 79 20 28 6c 6f 63 61 74 69 6f 6e 20 70 69 t-y (location pi
0770: 78 65 6c 2d 78 29 20 28 6c 6f 63 61 74 69 6f 6e xel-x) (location
0780: 20 70 69 78 65 6c 2d 79 29 29 0a 09 09 09 09 28 pixel-y)).....(
0790: 76 61 6c 75 65 73 20 70 69 78 65 6c 2d 78 20 70 values pixel-x p
07a0: 69 78 65 6c 2d 79 29 29 29 29 29 0a 0a 28 64 65 ixel-y)))))..(de
07b0: 66 69 6e 65 20 70 70 6c 6f 74 2d 70 61 69 6e 74 fine pplot-paint
07c0: 2d 74 6f 0a 09 28 66 6f 72 65 69 67 6e 2d 6c 61 -to..(foreign-la
07d0: 6d 62 64 61 20 76 6f 69 64 20 22 49 75 70 50 50 mbda void "IupPP
07e0: 6c 6f 74 50 61 69 6e 74 54 6f 22 20 6e 6f 6e 6e lotPaintTo" nonn
07f0: 75 6c 6c 2d 69 68 61 6e 64 6c 65 20 6e 6f 6e 6e ull-ihandle nonn
0800: 75 6c 6c 2d 63 2d 70 6f 69 6e 74 65 72 29 29 0a ull-c-pointer)).
0810: 0a 3b 3b 20 7d 7d 7d 0a 0a 3b 3b 20 7b 7b 7b 20 .;; }}}..;; {{{
0820: 4c 69 62 72 61 72 79 20 73 65 74 75 70 0a 0a 28 Library setup..(
0830: 66 6f 72 65 69 67 6e 2d 63 6f 64 65 20 22 49 75 foreign-code "Iu
0840: 70 50 50 6c 6f 74 4f 70 65 6e 28 29 3b 22 29 0a pPPlotOpen();").
0850: 0a 3b 3b 20 7d 7d 7d 0a .;; }}}.