
(/VERSIONCHECK 2) 

(DEFUN |VIEW2D;checkViewport| (|viewport| $)
  (PROG (|i|)
    (RETURN
     (SEQ (|sockSendInt| |$ViewportServer| (QVELT |viewport| 0))
          (LETT |i| (|sockGetInt| |$ViewportServer|) |VIEW2D;checkViewport|)
          (EXIT
           (COND
            ((< |i| 0)
             (SEQ (QSETVELT |viewport| 0 0)
                  (EXIT (|error| "This viewport has already been closed!"))))
            ('T 'T))))))) 

(DEFUN |VIEW2D;doOptions| (|v| $)
  (QSETVELT |v| 3 (SPADCALL (QVELT |v| 7) "FriCAS2D" (QREFELT $ 21)))) 

(PUT '|VIEW2D;options;$L;3| '|SPADreplace|
     '(XLAM (|viewport|) (QVELT |viewport| 7))) 

(DEFUN |VIEW2D;options;$L;3| (|viewport| $) (QVELT |viewport| 7)) 

(DEFUN |VIEW2D;options;$L$;4| (|viewport| |opts| $)
  (SEQ (QSETVELT |viewport| 7 |opts|) (EXIT |viewport|))) 

(DEFUN |VIEW2D;putGraph;$GiPiV;5| (|viewport| |aGraph| |which| $)
  (SEQ
   (COND
    ((OR (< 9 |which|) (< |which| 1))
     (|error|
      "Trying to put a graph with a negative index or too big an index")))
   (EXIT
    (SPADCALL (QVELT |viewport| 1) |which| (CONS 0 |aGraph|) (QREFELT $ 27))))) 

(DEFUN |VIEW2D;getGraph;$PiGi;6| (|viewport| |which| $)
  (PROG (#1=#:G726)
    (RETURN
     (SEQ
      (COND
       ((OR (< 9 |which|) (< |which| 1))
        (|error|
         "Trying to get a graph with a negative index or too big an index")))
      (EXIT
       (COND
        ((QEQCAR (SPADCALL (QVELT |viewport| 1) |which| (QREFELT $ 31)) 1)
         (|error| "Graph is undefined!"))
        ('T
         (PROG2
             (LETT #1# (SPADCALL (QVELT |viewport| 1) |which| (QREFELT $ 31))
                   |VIEW2D;getGraph;$PiGi;6|)
             (QCDR #1#)
           (|check-union| (QEQCAR #1# 0) (|GraphImage|) #1#))))))))) 

(PUT '|VIEW2D;graphStates;$V;7| '|SPADreplace|
     '(XLAM (|viewport|) (QVELT |viewport| 2))) 

(DEFUN |VIEW2D;graphStates;$V;7| (|viewport| $) (QVELT |viewport| 2)) 

(PUT '|VIEW2D;graphs;$V;8| '|SPADreplace|
     '(XLAM (|viewport|) (QVELT |viewport| 1))) 

(DEFUN |VIEW2D;graphs;$V;8| (|viewport| $) (QVELT |viewport| 1)) 

(PUT '|VIEW2D;key;$I;9| '|SPADreplace|
     '(XLAM (|viewport|) (QVELT |viewport| 0))) 

(DEFUN |VIEW2D;key;$I;9| (|viewport| $) (QVELT |viewport| 0)) 

(DEFUN |VIEW2D;dimensions;$2Nni2PiV;10|
       (|viewport| |ViewX| |ViewY| |ViewWidth| |ViewHeight| $)
  (SEQ (QSETVELT |viewport| 4 (CONS |ViewX| |ViewY|))
       (EXIT (QSETVELT |viewport| 5 (CONS |ViewWidth| |ViewHeight|))))) 

(DEFUN |VIEW2D;move;$2NniV;11| (|viewport| |xLoc| |yLoc| $)
  (PROG (#1=#:G747 #2=#:G746)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (QSETVELT |viewport| 4 (CONS |xLoc| |yLoc|))
            (EXIT
             (COND
              ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
               (PROGN
                (LETT #1#
                      (SEQ
                       (EXIT
                        (SEQ (|sockSendInt| |$ViewportServer| 3)
                             (|sockSendInt| |$ViewportServer| 102)
                             (EXIT
                              (COND
                               ((|VIEW2D;checkViewport| |viewport| $)
                                (PROGN
                                 (LETT #2#
                                       (SEQ
                                        (|sockSendInt| |$ViewportServer|
                                                       |xLoc|)
                                        (|sockSendInt| |$ViewportServer|
                                                       |yLoc|)
                                        (EXIT
                                         (|sockGetInt| |$ViewportServer|)))
                                       . #3=(|VIEW2D;move;$2NniV;11|))
                                 (GO #2#)))))))
                       #2# (EXIT #2#))
                      . #3#)
                (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;update;$GiPiV;12| (|viewport| |graph| |slot| $)
  (PROG (#1=#:G752 #2=#:G751)
    (RETURN
     (SEQ
      (EXIT
       (COND
        ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
         (PROGN
          (LETT #1#
                (SEQ
                 (EXIT
                  (SEQ (|sockSendInt| |$ViewportServer| 3)
                       (|sockSendInt| |$ViewportServer| 106)
                       (EXIT
                        (COND
                         ((|VIEW2D;checkViewport| |viewport| $)
                          (PROGN
                           (LETT #2#
                                 (SEQ
                                  (|sockSendInt| |$ViewportServer|
                                                 (SPADCALL |graph|
                                                           (QREFELT $ 41)))
                                  (|sockSendInt| |$ViewportServer| |slot|)
                                  (EXIT (|sockGetInt| |$ViewportServer|)))
                                 . #3=(|VIEW2D;update;$GiPiV;12|))
                           (GO #2#)))))))
                 #2# (EXIT #2#))
                . #3#)
          (GO #1#)))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;resize;$2PiV;13| (|viewport| |xSize| |ySize| $)
  (PROG (#1=#:G758 #2=#:G757)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (QSETVELT |viewport| 5 (CONS |xSize| |ySize|))
            (EXIT
             (COND
              ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
               (PROGN
                (LETT #1#
                      (SEQ
                       (EXIT
                        (SEQ (|sockSendInt| |$ViewportServer| 3)
                             (|sockSendInt| |$ViewportServer| 103)
                             (EXIT
                              (COND
                               ((|VIEW2D;checkViewport| |viewport| $)
                                (PROGN
                                 (LETT #2#
                                       (SEQ
                                        (|sockSendInt| |$ViewportServer|
                                                       |xSize|)
                                        (|sockSendInt| |$ViewportServer|
                                                       |ySize|)
                                        (EXIT
                                         (|sockGetInt| |$ViewportServer|)))
                                       . #3=(|VIEW2D;resize;$2PiV;13|))
                                 (GO #2#)))))))
                       #2# (EXIT #2#))
                      . #3#)
                (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;translate;$Pi2FV;14|
       (|viewport| |graphIndex| |xTranslateF| |yTranslateF| $)
  (PROG (#1=#:G763 #2=#:G762 |yTranslate| |xTranslate|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |xTranslate| (SPADCALL |xTranslateF| (QREFELT $ 12))
              . #3=(|VIEW2D;translate;$Pi2FV;14|))
        (LETT |yTranslate| (SPADCALL |yTranslateF| (QREFELT $ 12)) . #3#)
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 2
                  |xTranslate|)
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 3
                  |yTranslate|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 0)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendFloat| |$ViewportServer|
                                                     |xTranslate|)
                                    (|sockSendFloat| |$ViewportServer|
                                                     |yTranslate|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;scale;$Pi2FV;15| (|viewport| |graphIndex| |xScaleF| |yScaleF| $)
  (PROG (#1=#:G768 #2=#:G767 |yScale| |xScale|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |xScale| (SPADCALL |xScaleF| (QREFELT $ 12))
              . #3=(|VIEW2D;scale;$Pi2FV;15|))
        (LETT |yScale| (SPADCALL |yScaleF| (QREFELT $ 12)) . #3#)
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 0
                  |xScale|)
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 1
                  |yScale|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 1)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendFloat| |$ViewportServer|
                                                     |xScale|)
                                    (|sockSendFloat| |$ViewportServer|
                                                     |yScale|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;viewport2D;$;16| ($)
  (VECTOR 0 (SPADCALL 9 (CONS 1 "undefined") (QREFELT $ 48))
          (SPADCALL 9 (MOVEVEC (MAKE-VEC 12) (QREFELT $ 17)) (QREFELT $ 49))
          "FriCAS2D"
          (CONS (SPADCALL (SPADCALL (QREFELT $ 51)) 1 (QREFELT $ 52))
                (SPADCALL (SPADCALL (QREFELT $ 51)) 2 (QREFELT $ 52)))
          (CONS (SPADCALL (SPADCALL (QREFELT $ 54)) 1 (QREFELT $ 55))
                (SPADCALL (SPADCALL (QREFELT $ 54)) 2 (QREFELT $ 55)))
          (LIST 0) NIL)) 

(DEFUN |VIEW2D;makeViewport2D;GiL$;17| (|g| |opts| $)
  (PROG (|viewport|)
    (RETURN
     (SEQ
      (LETT |viewport| (SPADCALL (QREFELT $ 56))
            |VIEW2D;makeViewport2D;GiL$;17|)
      (SPADCALL (QVELT |viewport| 1) 1 (CONS 0 |g|) (QREFELT $ 27))
      (QSETVELT |viewport| 7 |opts|)
      (EXIT (SPADCALL |viewport| (QREFELT $ 57))))))) 

(DEFUN |VIEW2D;makeViewport2D;2$;18| (|viewportDollar| $)
  (PROG (|hueShade| |gs| |g| |i| |viewport|)
    (RETURN
     (SEQ
      (LETT |viewport| |viewportDollar| . #1=(|VIEW2D;makeViewport2D;2$;18|))
      (|VIEW2D;doOptions| |viewport| $)
      (|sayBrightly|
       (LIST "   FriCAS2D data being transmitted to the viewport manager..."))
      (|sockSendInt| |$ViewportServer| 3) (|sockSendInt| |$ViewportServer| -1)
      (|sockSendString| |$ViewportServer| (QVELT |viewport| 3))
      (|sockSendInt| |$ViewportServer| (QCAR (QVELT |viewport| 4)))
      (|sockSendInt| |$ViewportServer| (QCDR (QVELT |viewport| 4)))
      (|sockSendInt| |$ViewportServer| (QCAR (QVELT |viewport| 5)))
      (|sockSendInt| |$ViewportServer| (QCDR (QVELT |viewport| 5)))
      (|sockSendInt| |$ViewportServer| (QCAR (QVELT |viewport| 6)))
      (SEQ (LETT |i| 1 . #1#) G190 (COND ((QSGREATERP |i| 9) (GO G191)))
           (SEQ
            (LETT |g|
                  (SPADCALL (SPADCALL |viewport| (QREFELT $ 36)) |i|
                            (QREFELT $ 31))
                  . #1#)
            (EXIT
             (COND ((QEQCAR |g| 1) (|sockSendInt| |$ViewportServer| 0))
                   ('T
                    (SEQ
                     (|sockSendInt| |$ViewportServer|
                                    (SPADCALL (QCDR |g|) (QREFELT $ 41)))
                     (LETT |gs|
                           (SPADCALL (SPADCALL |viewport| (QREFELT $ 35)) |i|
                                     (QREFELT $ 44))
                           . #1#)
                     (|sockSendFloat| |$ViewportServer| (QVELT |gs| 0))
                     (|sockSendFloat| |$ViewportServer| (QVELT |gs| 1))
                     (|sockSendFloat| |$ViewportServer| (QVELT |gs| 2))
                     (|sockSendFloat| |$ViewportServer| (QVELT |gs| 3))
                     (|sockSendInt| |$ViewportServer| (QVELT |gs| 4))
                     (|sockSendInt| |$ViewportServer| (QVELT |gs| 5))
                     (|sockSendInt| |$ViewportServer| (QVELT |gs| 6))
                     (|sockSendInt| |$ViewportServer| (QVELT |gs| 7))
                     (LETT |hueShade|
                           (+
                            (SPADCALL (SPADCALL (QVELT |gs| 8) (QREFELT $ 60))
                                      (QREFELT $ 61))
                            (* (SPADCALL (QVELT |gs| 8) (QREFELT $ 62))
                               (SPADCALL (QREFELT $ 63))))
                           . #1#)
                     (|sockSendInt| |$ViewportServer| |hueShade|)
                     (|sockSendInt| |$ViewportServer| (QVELT |gs| 9))
                     (LETT |hueShade|
                           (+
                            (SPADCALL (SPADCALL (QVELT |gs| 10) (QREFELT $ 60))
                                      (QREFELT $ 61))
                            (* (SPADCALL (QVELT |gs| 10) (QREFELT $ 62))
                               (SPADCALL (QREFELT $ 63))))
                           . #1#)
                     (|sockSendInt| |$ViewportServer| |hueShade|)
                     (EXIT
                      (|sockSendInt| |$ViewportServer| (QVELT |gs| 11))))))))
           (LETT |i| (QSADD1 |i|) . #1#) (GO G190) G191 (EXIT NIL))
      (QSETVELT |viewport| 0 (|sockGetInt| |$ViewportServer|))
      (EXIT |viewport|))))) 

(DEFUN |VIEW2D;graphState;$Pi4Df4IPIPIV;19|
       (|viewport| |num| |sX| |sY| |dX| |dY| |Points| |Lines| |Spline| |Axes|
        |AxesColor| |Units| |UnitsColor| |Showing| $)
  (SPADCALL (QVELT |viewport| 2) |num|
            (VECTOR |sX| |sY| |dX| |dY| |Points| |Lines| |Spline| |Axes|
                    |AxesColor| |Units| |UnitsColor| |Showing|)
            (QREFELT $ 64))) 

(DEFUN |VIEW2D;title;$SV;20| (|viewport| |Title| $)
  (PROG (#1=#:G804 #2=#:G803)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (QSETVELT |viewport| 3 |Title|)
            (EXIT
             (COND
              ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
               (PROGN
                (LETT #1#
                      (SEQ
                       (EXIT
                        (SEQ (|sockSendInt| |$ViewportServer| 3)
                             (|sockSendInt| |$ViewportServer| 104)
                             (EXIT
                              (COND
                               ((|VIEW2D;checkViewport| |viewport| $)
                                (PROGN
                                 (LETT #2#
                                       (SEQ
                                        (|sockSendString| |$ViewportServer|
                                                          |Title|)
                                        (EXIT
                                         (|sockGetInt| |$ViewportServer|)))
                                       . #3=(|VIEW2D;title;$SV;20|))
                                 (GO #2#)))))))
                       #2# (EXIT #2#))
                      . #3#)
                (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;reset;$V;21| (|viewport| $)
  (PROG (#1=#:G809 #2=#:G808)
    (RETURN
     (SEQ
      (EXIT
       (COND
        ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
         (PROGN
          (LETT #1#
                (SEQ
                 (EXIT
                  (SEQ (|sockSendInt| |$ViewportServer| 3)
                       (|sockSendInt| |$ViewportServer| 100)
                       (EXIT
                        (COND
                         ((|VIEW2D;checkViewport| |viewport| $)
                          (PROGN
                           (LETT #2#
                                 (SEQ (|sockSendInt| |$ViewportServer| 5)
                                      (EXIT (|sockGetInt| |$ViewportServer|)))
                                 . #3=(|VIEW2D;reset;$V;21|))
                           (GO #2#)))))))
                 #2# (EXIT #2#))
                . #3#)
          (GO #1#)))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;axes;$PiSV;22| (|viewport| |graphIndex| |onOff| $)
  (PROG (#1=#:G814 #2=#:G813 |status|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (COND
         ((EQUAL |onOff| "on") (LETT |status| 1 . #3=(|VIEW2D;axes;$PiSV;22|)))
         ('T (LETT |status| 0 . #3#)))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 7
                  |status|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 8)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendInt| |$ViewportServer| |status|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;axes;$PiPV;23| (|viewport| |graphIndex| |color| $)
  (PROG (#1=#:G819 #2=#:G818 |hueShade|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 8
                  |color|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 112)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (LETT |hueShade|
                                          (+
                                           (SPADCALL
                                            (SPADCALL |color| (QREFELT $ 60))
                                            (QREFELT $ 61))
                                           (* (SPADCALL |color| (QREFELT $ 62))
                                              (SPADCALL (QREFELT $ 63))))
                                          . #3=(|VIEW2D;axes;$PiPV;23|))
                                    (|sockSendInt| |$ViewportServer|
                                                   |hueShade|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;units;$PiSV;24| (|viewport| |graphIndex| |onOff| $)
  (PROG (#1=#:G824 #2=#:G823 |status|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (COND
         ((EQUAL |onOff| "on")
          (LETT |status| 1 . #3=(|VIEW2D;units;$PiSV;24|)))
         ('T (LETT |status| 0 . #3#)))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 9
                  |status|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 9)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendInt| |$ViewportServer| |status|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;units;$PiPV;25| (|viewport| |graphIndex| |color| $)
  (PROG (#1=#:G829 #2=#:G828 |hueShade|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44))
                  10 |color|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 113)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (LETT |hueShade|
                                          (+
                                           (SPADCALL
                                            (SPADCALL |color| (QREFELT $ 60))
                                            (QREFELT $ 61))
                                           (* (SPADCALL |color| (QREFELT $ 62))
                                              (SPADCALL (QREFELT $ 63))))
                                          . #3=(|VIEW2D;units;$PiPV;25|))
                                    (|sockSendInt| |$ViewportServer|
                                                   |hueShade|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;connect;$PiSV;26| (|viewport| |graphIndex| |onOff| $)
  (PROG (#1=#:G834 #2=#:G833 |status|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (COND
         ((EQUAL |onOff| "on")
          (LETT |status| 1 . #3=(|VIEW2D;connect;$PiSV;26|)))
         ('T (LETT |status| 0 . #3#)))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 5
                  |status|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 3)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendInt| |$ViewportServer| |status|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;points;$PiSV;27| (|viewport| |graphIndex| |onOff| $)
  (PROG (#1=#:G839 #2=#:G838 |status|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (COND
         ((EQUAL |onOff| "on")
          (LETT |status| 1 . #3=(|VIEW2D;points;$PiSV;27|)))
         ('T (LETT |status| 0 . #3#)))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 4
                  |status|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 2)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendInt| |$ViewportServer| |status|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;region;$PiSV;28| (|viewport| |graphIndex| |onOff| $)
  (PROG (#1=#:G844 #2=#:G843 |status|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (COND
         ((EQUAL |onOff| "on")
          (LETT |status| 1 . #3=(|VIEW2D;region;$PiSV;28|)))
         ('T (LETT |status| 0 . #3#)))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44)) 6
                  |status|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 4)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendInt| |$ViewportServer| |status|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;show;$PiSV;29| (|viewport| |graphIndex| |onOff| $)
  (PROG (#1=#:G849 #2=#:G848 |status|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((< 9 |graphIndex|)
          (|error| "Referring to a graph with too big an index")))
        (COND
         ((EQUAL |onOff| "on") (LETT |status| 1 . #3=(|VIEW2D;show;$PiSV;29|)))
         ('T (LETT |status| 0 . #3#)))
        (QSETVELT (SPADCALL (QVELT |viewport| 2) |graphIndex| (QREFELT $ 44))
                  11 |status|)
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 105)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   |graphIndex|)
                                    (|sockSendInt| |$ViewportServer| |status|)
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #3#)
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #3#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;controlPanel;$SV;30| (|viewport| |onOff| $)
  (PROG (#1=#:G855 #2=#:G854)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (COND
         ((EQUAL |onOff| "on")
          (PROGN (RPLACA #3=(QVELT |viewport| 6) 1) (QCAR #3#)))
         ('T (PROGN (RPLACA #4=(QVELT |viewport| 6) 0) (QCAR #4#))))
        (EXIT
         (COND
          ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
           (PROGN
            (LETT #1#
                  (SEQ
                   (EXIT
                    (SEQ (|sockSendInt| |$ViewportServer| 3)
                         (|sockSendInt| |$ViewportServer| 6)
                         (EXIT
                          (COND
                           ((|VIEW2D;checkViewport| |viewport| $)
                            (PROGN
                             (LETT #2#
                                   (SEQ
                                    (|sockSendInt| |$ViewportServer|
                                                   (QCAR (QVELT |viewport| 6)))
                                    (EXIT (|sockGetInt| |$ViewportServer|)))
                                   . #5=(|VIEW2D;controlPanel;$SV;30|))
                             (GO #2#)))))))
                   #2# (EXIT #2#))
                  . #5#)
            (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;close;$V;31| (|viewport| $)
  (PROG (#1=#:G860 #2=#:G859)
    (RETURN
     (SEQ
      (EXIT
       (COND
        ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
         (PROGN
          (LETT #1#
                (SEQ
                 (EXIT
                  (SEQ (|sockSendInt| |$ViewportServer| 3)
                       (|sockSendInt| |$ViewportServer| 7)
                       (EXIT
                        (COND
                         ((|VIEW2D;checkViewport| |viewport| $)
                          (PROGN
                           (LETT #2#
                                 (SEQ (|sockGetInt| |$ViewportServer|)
                                      (EXIT (QSETVELT |viewport| 0 0)))
                                 . #3=(|VIEW2D;close;$V;31|))
                           (GO #2#)))))))
                 #2# (EXIT #2#))
                . #3#)
          (GO #1#)))))
      #1# (EXIT #1#))))) 

(DEFUN |VIEW2D;coerce;$Of;32| (|viewport| $)
  (COND
   ((EQL (SPADCALL |viewport| (QREFELT $ 37)) 0)
    (SPADCALL
     (LIST "Closed or Undefined TwoDimensionalViewport: "
           (SPADCALL (QVELT |viewport| 3) (QREFELT $ 79)))
     (QREFELT $ 81)))
   ('T
    (SPADCALL
     (LIST "TwoDimensionalViewport: "
           (SPADCALL (QVELT |viewport| 3) (QREFELT $ 79)))
     (QREFELT $ 81))))) 

(DEFUN |VIEW2D;write;$3S;33| (|viewport| |Filename| |aThingToWrite| $)
  (SPADCALL |viewport| |Filename| (LIST |aThingToWrite|) (QREFELT $ 84))) 

(DEFUN |VIEW2D;write;$2S;34| (|viewport| |Filename| $)
  (SPADCALL |viewport| |Filename| (SPADCALL (QREFELT $ 86)) (QREFELT $ 84))) 

(DEFUN |VIEW2D;write;$SLS;35| (|viewport| |Filename| |thingsToWrite| $)
  (PROG (#1=#:G872 #2=#:G871 |writeTypeInt| #3=#:G874 |aTypeOfFile| |m| |avail|
         |stringToSend|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ (LETT |stringToSend| "" . #4=(|VIEW2D;write;$SLS;35|))
            (EXIT
             (COND
              ((NULL (EQL (SPADCALL |viewport| (QREFELT $ 37)) 0))
               (PROGN
                (LETT #1#
                      (SEQ
                       (EXIT
                        (SEQ (|sockSendInt| |$ViewportServer| 3)
                             (|sockSendInt| |$ViewportServer| 110)
                             (EXIT
                              (COND
                               ((|VIEW2D;checkViewport| |viewport| $)
                                (PROGN
                                 (LETT #2#
                                       (SEQ
                                        (|sockSendString| |$ViewportServer|
                                                          |Filename|)
                                        (LETT |m|
                                              (SPADCALL
                                               (LETT |avail|
                                                     (SPADCALL (QREFELT $ 88))
                                                     . #4#)
                                               (QREFELT $ 89))
                                              . #4#)
                                        (SEQ (LETT |aTypeOfFile| NIL . #4#)
                                             (LETT #3# |thingsToWrite| . #4#)
                                             G190
                                             (COND
                                              ((OR (ATOM #3#)
                                                   (PROGN
                                                    (LETT |aTypeOfFile|
                                                          (CAR #3#) . #4#)
                                                    NIL))
                                               (GO G191)))
                                             (SEQ
                                              (LETT |writeTypeInt|
                                                    (-
                                                     (SPADCALL
                                                      (SPADCALL |aTypeOfFile|
                                                                (QREFELT $ 90))
                                                      |avail| (QREFELT $ 91))
                                                     |m|)
                                                    . #4#)
                                              (EXIT
                                               (COND
                                                ((< |writeTypeInt| 0)
                                                 (|sayBrightly|
                                                  (LIST "  > "
                                                        (SPADCALL
                                                         (STRCONC |aTypeOfFile|
                                                                  " is not a valid file type for writing a 2D viewport")
                                                         (QREFELT $ 79)))))
                                                ('T
                                                 (|sockSendInt|
                                                  |$ViewportServer|
                                                  (+ |writeTypeInt| 1))))))
                                             (LETT #3# (CDR #3#) . #4#)
                                             (GO G190) G191 (EXIT NIL))
                                        (|sockSendInt| |$ViewportServer| 0)
                                        (|sockGetInt| |$ViewportServer|)
                                        (EXIT |Filename|))
                                       . #4#)
                                 (GO #2#)))))))
                       #2# (EXIT #2#))
                      . #4#)
                (GO #1#)))))))
      #1# (EXIT #1#))))) 

(DEFUN |TwoDimensionalViewport| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G876)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|TwoDimensionalViewport|)
                . #3=(|TwoDimensionalViewport|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|TwoDimensionalViewport|
                         (LIST
                          (CONS NIL (CONS 1 (|TwoDimensionalViewport;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|TwoDimensionalViewport|))))))))))) 

(DEFUN |TwoDimensionalViewport;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|TwoDimensionalViewport|) . #1=(|TwoDimensionalViewport|))
      (LETT $ (GETREFV 95) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|TwoDimensionalViewport| NIL (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6
                (|Record| (|:| |key| (|Integer|))
                          (|:| |graphsField|
                               (|Vector| (|Union| (|GraphImage|) "undefined")))
                          (|:| |graphStatesField|
                               (|Vector|
                                (|Record| (|:| |scaleX| (|DoubleFloat|))
                                          (|:| |scaleY| (|DoubleFloat|))
                                          (|:| |deltaX| (|DoubleFloat|))
                                          (|:| |deltaY| (|DoubleFloat|))
                                          (|:| |points| (|Integer|))
                                          (|:| |connect| (|Integer|))
                                          (|:| |spline| (|Integer|))
                                          (|:| |axes| (|Integer|))
                                          (|:| |axesColor| (|Palette|))
                                          (|:| |units| (|Integer|))
                                          (|:| |unitsColor| (|Palette|))
                                          (|:| |showing| (|Integer|)))))
                          (|:| |title| (|String|))
                          (|:| |moveTo|
                               (|Record| (|:| X (|NonNegativeInteger|))
                                         (|:| Y (|NonNegativeInteger|))))
                          (|:| |size|
                               (|Record| (|:| X (|PositiveInteger|))
                                         (|:| Y (|PositiveInteger|))))
                          (|:| |flags| (|Record| (|:| |showCP| (|Integer|))))
                          (|:| |optionsField| (|List| (|DrawOption|)))))
      (QSETREFV $ 17
                (VECTOR
                 (SPADCALL (SPADCALL 9 -1 10 (QREFELT $ 10)) (QREFELT $ 12))
                 (SPADCALL (SPADCALL 9 -1 10 (QREFELT $ 10)) (QREFELT $ 12))
                 0.0 0.0 1 1 0 1 (SPADCALL (QREFELT $ 15)) 0
                 (SPADCALL (QREFELT $ 16)) 1))
      $)))) 

(MAKEPROP '|TwoDimensionalViewport| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL '|Rep| (|Integer|) (|PositiveInteger|)
              (|Float|) (0 . |float|) (|DoubleFloat|) (7 . |convert|)
              (|Palette|) (|ViewDefaultsPackage|) (12 . |axesColorDefault|)
              (16 . |unitsColorDefault|) '|defaultGS| (|String|)
              (|List| (|DrawOption|)) (|DrawOptionFunctions0|) (20 . |title|)
              |VIEW2D;options;$L;3| |VIEW2D;options;$L$;4| (26 . |One|)
              (|Union| 29 '"undefined") (|Vector| 25) (30 . |setelt|) (|Void|)
              (|GraphImage|) |VIEW2D;putGraph;$GiPiV;5| (37 . |elt|)
              |VIEW2D;getGraph;$PiGi;6|
              (|Record| (|:| |scaleX| 11) (|:| |scaleY| 11) (|:| |deltaX| 11)
                        (|:| |deltaY| 11) (|:| |points| 7) (|:| |connect| 7)
                        (|:| |spline| 7) (|:| |axes| 7) (|:| |axesColor| 13)
                        (|:| |units| 7) (|:| |unitsColor| 13)
                        (|:| |showing| 7))
              (|Vector| 33) |VIEW2D;graphStates;$V;7| |VIEW2D;graphs;$V;8|
              |VIEW2D;key;$I;9| (|NonNegativeInteger|)
              |VIEW2D;dimensions;$2Nni2PiV;10| |VIEW2D;move;$2NniV;11|
              (43 . |key|) |VIEW2D;update;$GiPiV;12| |VIEW2D;resize;$2PiV;13|
              (48 . |elt|) |VIEW2D;translate;$Pi2FV;14|
              |VIEW2D;scale;$Pi2FV;15| (54 . |Zero|) (58 . |new|) (64 . |new|)
              (|List| 38) (70 . |viewPosDefault|) (74 . |elt|) (|List| 8)
              (80 . |viewSizeDefault|) (84 . |elt|) |VIEW2D;viewport2D;$;16|
              |VIEW2D;makeViewport2D;2$;18| |VIEW2D;makeViewport2D;GiL$;17|
              (|Color|) (90 . |hue|) (95 . |hue|) (100 . |shade|)
              (105 . |numberOfHues|) (109 . |setelt|)
              |VIEW2D;graphState;$Pi4Df4IPIPIV;19| |VIEW2D;title;$SV;20|
              |VIEW2D;reset;$V;21| |VIEW2D;axes;$PiSV;22|
              |VIEW2D;axes;$PiPV;23| |VIEW2D;units;$PiSV;24|
              |VIEW2D;units;$PiPV;25| |VIEW2D;connect;$PiSV;26|
              |VIEW2D;points;$PiSV;27| |VIEW2D;region;$PiSV;28|
              |VIEW2D;show;$PiSV;29| |VIEW2D;controlPanel;$SV;30|
              |VIEW2D;close;$V;31| (|OutputForm|) (116 . |coerce|) (|List| $)
              (121 . |hconcat|) |VIEW2D;coerce;$Of;32| (|List| 18)
              |VIEW2D;write;$SLS;35| |VIEW2D;write;$3S;33|
              (126 . |viewWriteDefault|) |VIEW2D;write;$2S;34|
              (130 . |viewWriteAvailable|) (134 . |minIndex|)
              (139 . |upperCase|) (144 . |position|) (|List| (|Point| 11))
              (|SingleInteger|) (|Boolean|))
           '#(~= 150 |write| 156 |viewport2D| 176 |update| 180 |units| 187
              |translate| 201 |title| 209 |show| 215 |scale| 222 |resize| 230
              |reset| 237 |region| 242 |putGraph| 249 |points| 256 |options|
              263 |move| 274 |makeViewport2D| 281 |latex| 292 |key| 297 |hash|
              302 |graphs| 307 |graphStates| 312 |graphState| 317
              |getPickedPoints| 335 |getGraph| 340 |dimensions| 346
              |controlPanel| 355 |connect| 361 |coerce| 368 |close| 373 |axes|
              378 = 392)
           'NIL
           (CONS (|makeByteWordVec2| 1 '(0 0 0))
                 (CONS '#(|SetCategory&| |BasicType&| NIL)
                       (CONS
                        '#((|SetCategory|) (|BasicType|) (|CoercibleTo| 78))
                        (|makeByteWordVec2| 94
                                            '(3 9 0 7 7 8 10 1 9 11 0 12 0 14
                                              13 15 0 14 13 16 2 20 18 19 18 21
                                              0 9 0 24 3 26 25 0 7 25 27 2 26
                                              25 0 7 31 1 29 7 0 41 2 34 33 0 7
                                              44 0 9 0 47 2 26 0 38 25 48 2 34
                                              0 38 33 49 0 14 50 51 2 50 38 0 7
                                              52 0 14 53 54 2 53 8 0 7 55 1 13
                                              59 0 60 1 59 7 0 61 1 13 7 0 62 0
                                              59 8 63 3 34 33 0 7 33 64 1 18 78
                                              0 79 1 78 0 80 81 0 14 83 86 0 14
                                              83 88 1 83 7 0 89 1 18 0 0 90 2
                                              83 7 18 0 91 2 0 94 0 0 1 3 0 18
                                              0 18 18 85 3 0 18 0 18 83 84 2 0
                                              18 0 18 87 0 0 0 56 3 0 28 0 29 8
                                              42 3 0 28 0 8 18 70 3 0 28 0 8 13
                                              71 4 0 28 0 8 9 9 45 2 0 28 0 18
                                              66 3 0 28 0 8 18 75 4 0 28 0 8 9
                                              9 46 3 0 28 0 8 8 43 1 0 28 0 67
                                              3 0 28 0 8 18 74 3 0 28 0 29 8 30
                                              3 0 28 0 8 18 73 1 0 19 0 22 2 0
                                              0 0 19 23 3 0 28 0 38 38 40 2 0 0
                                              29 19 58 1 0 0 0 57 1 0 18 0 1 1
                                              0 7 0 37 1 0 93 0 1 1 0 26 0 36 1
                                              0 34 0 35 14 0 28 0 8 11 11 11 11
                                              7 7 7 7 13 7 13 7 65 1 0 92 0 1 2
                                              0 29 0 8 32 5 0 28 0 38 38 8 8 39
                                              2 0 28 0 18 76 3 0 28 0 8 18 72 1
                                              0 78 0 82 1 0 28 0 77 3 0 28 0 8
                                              18 68 3 0 28 0 8 13 69 2 0 94 0 0
                                              1)))))
           '|lookupComplete|)) 

(MAKEPROP '|TwoDimensionalViewport| 'NILADIC T) 
