home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / oberon / system / kepler2.mod (.txt) < prev    next >
Oberon Text  |  1977-12-31  |  3KB  |  114 lines

  1. Syntax10.Scn.Fnt
  2. MODULE Kepler2;    (* J. Templ, 5.11.90/01.07.93 *)
  3.     IMPORT
  4.         KeplerGraphs, KeplerFrames, Math, Oberon, Texts, Files, Fonts, Display;
  5.     TYPE
  6.         Fraction* = POINTER TO FractionDesc;
  7.         FractionDesc* = RECORD
  8.             (KeplerGraphs.PlanetDesc)
  9.             cnt*, dn*: LONGINT
  10.         END ;
  11.         XY* = POINTER TO XYDesc;
  12.         XYDesc* = RECORD
  13.             (KeplerGraphs.PlanetDesc)
  14.         END ;
  15.         Offset* = POINTER TO OffsetDesc;
  16.         OffsetDesc* = RECORD
  17.             (KeplerGraphs.PlanetDesc)
  18.             dx*, dy*: INTEGER;
  19.         END ;
  20. (* ------------------------------- Fraction ------------------------------- *)
  21.     PROCEDURE (self: Fraction) Calc*;
  22.         VAR x0, x1, y0, y1: INTEGER;
  23.     BEGIN
  24.         x0 := self.c.p[0].x; x1 := self.c.p[1].x; y0 := self.c.p[0].y; y1 := self.c.p[1].y;
  25.         self.x := SHORT(x0 + (x1 - x0) * self.cnt DIV self.dn);
  26.         self.y := SHORT(y0 + (y1 - y0) * self.cnt DIV self.dn)
  27.     END Calc;
  28.     PROCEDURE (self: Fraction) Write* (VAR R: Files.Rider);
  29.     BEGIN
  30.         Files.WriteNum(R, self.cnt);
  31.         Files.WriteNum(R, self.dn);
  32.         self.Write^(R)
  33.     END Write;
  34.     PROCEDURE (self: Fraction) Read* (VAR R: Files.Rider);
  35.     BEGIN
  36.         Files.ReadNum(R, self.cnt);
  37.         Files.ReadNum(R, self.dn);
  38.         self.Read^(R)
  39.     END Read;
  40.     PROCEDURE NewFractions*;
  41.         VAR f: Fraction; c: KeplerGraphs.Constellation; S: Texts.Scanner;
  42.             p0, p1: KeplerGraphs.Star; i: LONGINT;
  43.     BEGIN
  44.         IF KeplerFrames.nofpts >= 2 THEN
  45.             Texts.OpenScanner(S,Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
  46.             IF (S.class = Texts.Int) & (S.i > 0 ) THEN
  47.                 KeplerFrames.ConsumePoint(p0);
  48.                 KeplerFrames.ConsumePoint(p1);
  49.                 i := S.i - 1;
  50.                 WHILE i > 0 DO
  51.                     NEW(f); NEW(c); c.nofpts := 2; f.c := c;
  52.                     c.p[0] := p0; c.p[1] := p1; INC(p0.refcnt); INC(p1.refcnt);
  53.                     f.cnt := SHORT(i); f.dn := SHORT(S.i); f.Calc; 
  54.                     KeplerFrames.Focus.Append(f);
  55.                     KeplerFrames.Focus.FlipSelection(f);
  56.                     DEC(i)
  57.                 END ;
  58.                 DEC(p0.refcnt); DEC(p1.refcnt)
  59.             END
  60.         END
  61.     END NewFractions;
  62. (* ------------------------------- XY ------------------------------- *)
  63.     PROCEDURE (self: XY) Calc*;
  64.     BEGIN
  65.         self.x := self.c.p[0].x;
  66.         self.y := self.c.p[1].y
  67.     END Calc;
  68.     PROCEDURE NewXY*;
  69.         VAR cp: XY; c: KeplerGraphs.Constellation;
  70.     BEGIN
  71.         IF KeplerFrames.nofpts >= 2 THEN
  72.             NEW(cp); NEW(c); c.nofpts := 2;
  73.             KeplerFrames.ConsumePoint(c.p[0]);
  74.             KeplerFrames.ConsumePoint(c.p[1]);
  75.             cp.c := c; cp.Calc;
  76.             KeplerFrames.Focus.Append(cp);
  77.             KeplerFrames.Focus.FlipSelection(cp)
  78.         END
  79.     END NewXY;
  80. (* ------------------------------- Offset ------------------------------- *)
  81.     PROCEDURE (self: Offset) Calc*;
  82.     BEGIN
  83.         self.x := self.c.p[0].x + self.dx;
  84.         self.y := self.c.p[0].y + self.dy
  85.     END Calc;
  86.     PROCEDURE (self: Offset) Read* (VAR R: Files.Rider);
  87.         VAR t: LONGINT;
  88.     BEGIN
  89.         Files.ReadNum(R, t); self.dx := SHORT(t);
  90.         Files.ReadNum(R, t); self.dy := SHORT(t);
  91.         self.Read^(R)
  92.     END Read;
  93.     PROCEDURE (self: Offset) Write* (VAR R: Files.Rider);
  94.     BEGIN
  95.         Files.WriteNum(R, self.dx);
  96.         Files.WriteNum(R, self.dy);
  97.         self.Write^(R)
  98.     END Write;
  99.     PROCEDURE NewOffset*;
  100.         VAR p0, p1: KeplerGraphs.Star;
  101.             offset: Offset;
  102.     BEGIN
  103.         IF KeplerFrames.nofpts > 1 THEN
  104.             KeplerFrames.ConsumePoint(p0);
  105.             KeplerFrames.GetPoint(p1);
  106.             NEW(offset); NEW(offset.c);
  107.             offset.c.p[0] := p0; offset.c.nofpts := 1;
  108.             offset.dx := p1.x - p0.x; offset.dy := p1.y - p0.y; offset.Calc;
  109.             KeplerFrames.Focus.Append(offset);
  110.             KeplerFrames.Focus.FlipSelection(offset)
  111.         END
  112.     END NewOffset;
  113. END Kepler2.
  114.