Artifact ce1ee30375e035853ea987c7a1615c1be7afb787:


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