home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Tex / td187src.lzh / BEZIER.I < prev    next >
Text File  |  1991-12-14  |  27KB  |  688 lines

  1. IMPLEMENTATION MODULE Bezier ;
  2.  
  3. IMPORT mtAppl ;
  4. IMPORT Diverses ;
  5. IMPORT MagicAES ;
  6. IMPORT MagicVDI ;
  7. IMPORT MagicSys ;
  8. IMPORT MathLib0 ;
  9. IMPORT MagicConvert;
  10.  
  11. IMPORT Variablen ;
  12. IMPORT CommonData;
  13. IMPORT HelpModule;
  14. IMPORT Undo;
  15.  
  16. FROM OwnBoxes    IMPORT WaitForDepress, MousePos;
  17. FROM Types       IMPORT TextPosTyp, DrawObjectTyp, CodeAryTyp, ObjectPtrTyp;
  18. FROM BezierCurve IMPORT ComputeBezier;
  19.  
  20. CONST MaxBezPts = 1000;
  21.  
  22. VAR BezierArray : ARRAY [0..2*MaxBezPts+1] OF INTEGER;
  23.     LastMaxX, LastMaxY : INTEGER;     (* Um Ausma₧e bestimmen zu können *)
  24.     LastMinX, LastMinY : INTEGER;
  25. (**
  26. PROCEDURE Max(i1, i2 : INTEGER) : INTEGER;
  27. BEGIN
  28.   IF i1>i2 THEN
  29.     RETURN i1;
  30.    ELSE
  31.     RETURN i2;
  32.   END;
  33. END Max;
  34.  
  35. PROCEDURE Min(i1, i2 : INTEGER) : INTEGER;
  36. BEGIN
  37.   IF i1>i2 THEN
  38.     RETURN i2;
  39.    ELSE
  40.     RETURN i1;
  41.   END;
  42. END Min;
  43. **)
  44.  
  45. PROCEDURE PrepareDraw;
  46. (* Draw-Modus = XOR, Mouse Off, Clipping off *)
  47. VAR dum : INTEGER;
  48. BEGIN
  49.   dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
  50.   MagicVDI.SetClipping ( mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
  51.   IF CommonData.ShowBezLine THEN
  52.     dum := MagicVDI.SetLinewidth(mtAppl.VDIHandle, CommonData.LineWidth);
  53.    ELSE
  54.     dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
  55.     dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 11 * CommonData.LineWidth);
  56.   END;
  57.   Diverses.MouseOff;
  58. END PrepareDraw;
  59.  
  60. PROCEDURE FinishDraw;
  61. (* Draw-Modus = Replace, Mouse On, Clipping off *)
  62. VAR dum : INTEGER;
  63. BEGIN
  64.   dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.REPLACE ) ;
  65.   IF CommonData.ShowBezLine THEN
  66.     dum := MagicVDI.SetLinewidth(mtAppl.VDIHandle, CommonData.LineWidth);
  67.    ELSE
  68.     dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
  69.     dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 1 * 11);
  70.   END;
  71.   MagicVDI.SetClipping ( mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
  72.   Diverses.MouseOn;
  73. END FinishDraw;
  74.  
  75. PROCEDURE BezierCurve();
  76.  
  77. VAR cx, cx2, sx1, sx2, cy, cy2, sy1, sy2, lastx, lasty : INTEGER;
  78.     Points, x , y , dum, picx, picy                    : INTEGER ;
  79.     but                 : BITSET;
  80.     lbut, rbut          : BOOLEAN;
  81.     SurroundRect        : ARRAY [0..3] OF INTEGER;
  82.     xy                  : CodeAryTyp ;
  83.     pkte                : ARRAY [0..5] OF INTEGER;
  84.     i, pos              : INTEGER;
  85.     string              : ARRAY [0..9] OF CHAR;
  86.     FixEndPt,
  87.     FixCtrlPt,
  88.     helptxt             : ARRAY [0..49] OF CHAR;
  89.  
  90. BEGIN
  91.   (* Zunächst den Startpunkt, dann wie bei Line den 2. Punkt holen und
  92.      zum Schlu₧ den dritten Punkt *)
  93.  
  94.   WaitForDepress(sx1, sy1);
  95.  
  96.   pkte[0] := sx1;
  97.   pkte[2] := sx1;
  98.   pkte[1] := sy1;
  99.   pkte[3] := sy1;
  100.   FOR i:=0 TO 3 DO BezierArray[i] := pkte[i]; END;
  101.  
  102.   MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
  103.   dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
  104.   dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
  105.   lastx := sx1; lasty := sy1;
  106.   Diverses.GetHelpText(1, FixEndPt);
  107.   HelpModule.HelpMessage(FixEndPt);
  108. (* Jetzt der 2. Stützpunkt *)
  109.   REPEAT
  110.  
  111.     MousePos (sx2, sy2, picx, picy, lbut, rbut);
  112.     Variablen.Position ( TRUE, sx2, sy2, sx1, sy1 ) ;
  113.     IF (sx2<>sx1) OR (sy2<>sy1) THEN
  114.       IF (sx2<>lastx) OR (sy2<>lasty) THEN (* Flackern vermeiden *)
  115.         PrepareDraw; (* Bereite Ausgabe vor *)
  116.         dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  117.         MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray  ) ;
  118.         ComputeBezier(BezierArray, 1, sx1, sy1, sx1, sy1,
  119.                       pkte[2], pkte[3], LastMinX, LastMinY,
  120.                       LastMaxX, LastMaxY);
  121.         pkte[2] := sx2; pkte[3] := sy2;
  122.         MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray  ) ;
  123.         FinishDraw; (* Zeichnung beendet *)
  124.       END;
  125.     END;
  126.     lastx := sx2; lasty := sy2;
  127.   UNTIL lbut OR rbut;
  128.  
  129.   PrepareDraw; (* Bereite Ausgabe vor *)
  130.   dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  131.   MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray  ) ;
  132.   FinishDraw; (* Zeichnung beendet *)
  133.  
  134.   IF lbut AND NOT rbut THEN
  135.     (* Warten bis Maus losgelassen *)
  136.     REPEAT
  137.       MousePos(cx, cy, picx, picy, lbut, rbut);
  138.     UNTIL NOT (lbut OR rbut);
  139.     lastx := cx;
  140.     lasty := cy;
  141.     IF (sx2<sx1) THEN
  142.       dum := sx2; sx2 := sx1; sx1 := dum;
  143.       dum := sy2; sy2 := sy1; sy1 := dum;
  144.     END;
  145.     ComputeBezier(BezierArray, 20, sx1, sy1, cx, cy, sx2, sy2,
  146.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  147.     pkte[4] := pkte[2];
  148.     pkte[5] := pkte[3];
  149.     pkte[2] := cx;
  150.     pkte[3] := cy;
  151.  
  152.     PrepareDraw; (* Bereite Ausgabe vor *)
  153.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  154.     MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray  ) ;
  155.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  156.     MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  157.     FinishDraw; (* Zeichnung beendet *)
  158.  
  159.     Diverses.GetHelpText(2, FixCtrlPt);
  160.     HelpModule.HelpMessage(FixCtrlPt);
  161.   (* Und nun der Kontrollpunkt *)
  162.     REPEAT
  163.  
  164.       MousePos ( cx, cy, picx, picy, lbut, rbut );
  165.       Variablen.Position (TRUE, cx, cy, sx1, sy1 ) ;
  166.       IF (cx<>sx2) OR (cy<>sy2) THEN
  167.         IF (cx<>lastx) OR (cy<>lasty) THEN
  168.           PrepareDraw; (* Bereite Ausgabe vor *)
  169.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  170.           MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  171.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  172.           MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray  ) ;
  173.           pkte[2] := cx; pkte[3] := cy;
  174.           ComputeBezier(BezierArray, 20, sx1, sy1, cx, cy, sx2, sy2,
  175.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  176.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  177.           MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray  ) ;
  178.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  179.           MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  180.           FinishDraw; (* Zeichnung beendet *)
  181.         END;
  182.       END;
  183.       lastx := cx; lasty := cy;
  184.     UNTIL (lbut OR rbut);
  185.  
  186.     PrepareDraw; (* Bereite Ausgabe vor *)
  187.     dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
  188.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  189.     MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  190.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  191.     MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray  ) ;
  192.     FinishDraw; (* Zeichnung beendet *)
  193.  
  194.     WaitForDepress(lastx, lasty);
  195.     IF (lbut) AND NOT (rbut) THEN
  196.       Diverses.GetHelpText(5, helptxt);
  197.       pos := 0;
  198.       WHILE (helptxt[pos]<>'?') DO
  199.         INC(pos);
  200.       END;
  201.       Points := 50;
  202.       REPEAT
  203.         MousePos(lastx, lasty, picx, picy, lbut, rbut);
  204.       UNTIL NOT (lbut OR rbut);
  205.  
  206.       MagicVDI.Text ( mtAppl.VDIHandle ,
  207.                                CommonData.DYPosx ,
  208.                                CommonData.DYPosy , '     ' ) ;
  209.       PrepareDraw; (* Bereite Ausgabe vor *)
  210.       ComputeBezier(BezierArray, Points, sx1, sy1, cx, cy, sx2, sy2,
  211.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  212.       IF CommonData.ShowBezLine THEN
  213.         dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  214.         MagicVDI.Polyline ( mtAppl.VDIHandle , Points + 1 , BezierArray  ) ;
  215.        ELSE
  216.         MagicVDI.Polymarker ( mtAppl.VDIHandle , Points + 1 , BezierArray  ) ;
  217.       END;
  218.       FinishDraw; (* Zeichnung beendet *)
  219.       MagicConvert.IntToStr(Points, 5, string);
  220.       FOR i:= 0 TO 4 DO
  221.         helptxt[pos+i] := string[i];
  222.       END;
  223.       MagicVDI.Text ( mtAppl.VDIHandle ,
  224.                                CommonData.DXPosx ,
  225.                                CommonData.DXPosy , string ) ;
  226.       HelpModule.HelpMessage(helptxt);
  227.  
  228.       REPEAT
  229.         MousePos(cx2, cy2, picx, picy, lbut, rbut);
  230.         IF (cx2<>lastx) THEN
  231.    (* Bei gedrückter rechter Maustaste ist Schrittweite 10, sonst 1 *)
  232.    (* Bei gedrückter linker & rechter Maustaste ist Schrittweite 100 *)
  233.           cy2 := Points;
  234.           IF lbut AND rbut THEN
  235.             Points := Points + 100 * (cx2-lastx);
  236.           ELSIF rbut AND NOT lbut THEN
  237.             Points := Points +  10 * (cx2-lastx);
  238.           ELSIF NOT (lbut OR rbut) THEN
  239.             Points := Points +   1 * (cx2-lastx);
  240.           END;
  241.           IF Points>MaxBezPts THEN Points := MaxBezPts; END;
  242.           IF Points<1 THEN Points := 1; END;
  243.           IF Points<>cy2 THEN
  244.             PrepareDraw; (* Bereite Ausgabe vor *)
  245.             ComputeBezier(BezierArray, cy2, sx1, sy1, cx, cy, sx2, sy2,
  246.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  247.             IF CommonData.ShowBezLine THEN
  248.               dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  249.               MagicVDI.Polyline ( mtAppl.VDIHandle, cy2 + 1, BezierArray );
  250.              ELSE
  251.               MagicVDI.Polymarker ( mtAppl.VDIHandle, cy2 + 1, BezierArray );
  252.             END;
  253.             ComputeBezier(BezierArray, Points, sx1, sy1, cx, cy, sx2, sy2,
  254.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  255.             IF CommonData.ShowBezLine THEN
  256.               dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  257.               MagicVDI.Polyline ( mtAppl.VDIHandle, Points + 1, BezierArray );
  258.              ELSE
  259.               MagicVDI.Polymarker ( mtAppl.VDIHandle, Points + 1, BezierArray );
  260.             END;
  261.             FinishDraw; (* Zeichnung beendet *)
  262.             MagicConvert.IntToStr(Points, 5, string);
  263.             FOR i:= 0 TO 4 DO
  264.               helptxt[27+i] := string[i];
  265.             END;
  266.             MagicVDI.Text ( mtAppl.VDIHandle ,
  267.                                      CommonData.DXPosx ,
  268.                                      CommonData.DXPosy , string ) ;
  269.             HelpModule.HelpMessage(helptxt);
  270.             (* Nachhinken verhindern, deswegen Mausposition auslesen *)
  271.             MousePos(cx2, cy2, picx, picy, lbut, rbut);
  272.           END;
  273.         END;
  274.         lastx := cx2;
  275.       UNTIL lbut AND NOT rbut;
  276.  
  277.       PrepareDraw; (* Bereite Ausgabe vor *)
  278.       dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.REPLACE ) ;
  279.       ComputeBezier(BezierArray, Points, sx1, sy1, cx, cy, sx2, sy2,
  280.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  281.       IF CommonData.ShowBezLine THEN
  282.         dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  283.         MagicVDI.Polyline ( mtAppl.VDIHandle , Points + 1 , BezierArray  ) ;
  284.        ELSE
  285.         MagicVDI.Polymarker ( mtAppl.VDIHandle , Points + 1 , BezierArray  ) ;
  286.       END;
  287.       FinishDraw; (* Zeichnung beendet *)
  288.  
  289.       FOR dum := 0 TO 9 DO xy [ dum ] := 0 END ;
  290.  
  291.       Variablen.PixToPic ( sx1, sy1, xy [ 1 ] , xy [ 2 ] ) ;
  292.       Variablen.PixToPic ( sx2, sy2, xy [ 5 ] , xy [ 6 ] ) ;
  293.       Variablen.PixToPic ( cx,  cy,  xy [ 3 ] , xy [ 4 ] ) ;
  294.       picx := LastMaxX-LastMinX;
  295.       picy := LastMaxY-LastMinY;
  296.       Variablen.PixToPic ( LastMinX, LastMinY, SurroundRect[0], SurroundRect[1]);
  297.       Variablen.PixToPic ( picx, picy, SurroundRect[2], SurroundRect[3]);
  298.  
  299.       xy [ 3 ] := xy [ 3 ] - xy [ 1 ];
  300.       xy [ 4 ] := xy [ 4 ] - xy [ 2 ];
  301.       xy [ 5 ] := xy [ 5 ] - xy [ 1 ];
  302.       xy [ 6 ] := xy [ 6 ] - xy [ 2 ];
  303.       xy [ 7 ] := Points;
  304.       xy [ 8 ] := CommonData.LineWidth ;
  305.  
  306.       xy [ 0 ] := ORD(Beziercurve);
  307.  
  308.       Undo.PrepareUndo(TRUE);
  309.       Variablen.NewObject ( xy , NIL, NIL, SurroundRect ) ;
  310.     END;
  311.   END;
  312. END BezierCurve;
  313.  
  314. PROCEDURE ZeichneKurven(Pts : INTEGER;
  315.                         PtMode : BOOLEAN;
  316.                         x1, y1, x2, y2, x3, y3 : INTEGER);
  317. VAR dum, px1, px2, px3, px4, py1, py2, py3, py4, x4, y4 : INTEGER;
  318.     mx, MX, my, MY : INTEGER;
  319. BEGIN
  320.   x4 := x2 + (x1 - x2) + (x3 - x2);
  321.   y4 := y2 + (y1 - y2) + (y3 - y2);
  322.   px1 := (x1 + x2) DIV 2; py1 := (y1 + y2) DIV 2;
  323.   px2 := (x1 + x4) DIV 2; py2 := (y1 + y4) DIV 2;
  324.   px3 := (x3 + x4) DIV 2; py3 := (y3 + y4) DIV 2;
  325.   px4 := (x3 + x2) DIV 2; py4 := (y3 + y2) DIV 2;
  326.   ComputeBezier(BezierArray, Pts, px1, py1, x1, y1, px2, py2,
  327.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  328.   MX := LastMaxX;  mx := LastMinX;
  329.   MY := LastMaxY;  my := LastMinY;
  330.   IF PtMode THEN
  331.     dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
  332.   END;
  333.   IF PtMode THEN
  334.    IF CommonData.ShowBezLine THEN
  335.      MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  336.     ELSE
  337.      MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  338.    END;
  339.   ELSE
  340.     MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  341.   END;
  342.   ComputeBezier(BezierArray, Pts, px2, py2, x4, y4, px3, py3,
  343.                   LastMinX, LastMinY, LastMaxX, LastMaxY);
  344.   MX := Diverses.max(MX,LastMaxX);  mx := Diverses.min(mx,LastMinX);
  345.   MY := Diverses.max(MY,LastMaxY);  my := Diverses.min(my,LastMinY);
  346.   IF PtMode THEN
  347.    IF CommonData.ShowBezLine THEN
  348.      MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  349.     ELSE
  350.      MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  351.    END;
  352.   ELSE
  353.     MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  354.   END;
  355.   ComputeBezier(BezierArray, Pts, px3, py3, x3, y3, px4, py4,
  356.                 LastMinX, LastMinY, LastMaxX, LastMaxY);
  357.   MX := Diverses.max(MX,LastMaxX);  mx := Diverses.min(mx,LastMinX);
  358.   MY := Diverses.max(MY,LastMaxY);  my := Diverses.min(my,LastMinY);
  359.   IF PtMode THEN
  360.    IF CommonData.ShowBezLine THEN
  361.      MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  362.     ELSE
  363.      MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  364.    END;
  365.   ELSE
  366.     MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  367.   END;
  368.   ComputeBezier(BezierArray, Pts, px4, py4, x2, y2, px1, py1,
  369.                 LastMinX, LastMinY, LastMaxX, LastMaxY);
  370.   MX := Diverses.max(MX,LastMaxX);  mx := Diverses.min(mx,LastMinX);
  371.   MY := Diverses.max(MY,LastMaxY);  my := Diverses.min(my,LastMinY);
  372.   IF PtMode THEN
  373.    IF CommonData.ShowBezLine THEN
  374.      MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  375.     ELSE
  376.      MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  377.    END;
  378.   ELSE
  379.     MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray  ) ;
  380.   END;
  381.   LastMaxX := MX; LastMinX := mx; LastMaxY := MY; LastMinY := my;
  382. END ZeichneKurven;
  383.  
  384. PROCEDURE BezierEllipse();
  385.  
  386. VAR cx, sx1, sx2, cy, sy1, sy2, lastx, lasty : INTEGER;
  387.     cx2, cy2, x, y, dum, Points, i, pos      : INTEGER;
  388.     picx, picy                               : INTEGER;
  389.     xy                                       : CodeAryTyp ;
  390.     pkte                                     : ARRAY [0..5] OF INTEGER;
  391.     SurroundRect                             : ARRAY [0..3] OF INTEGER;
  392.     string                                   : ARRAY [0..5] OF CHAR;
  393.     Fix1stDiag, DrawRaute, helptxt           : ARRAY [0..49] OF CHAR;
  394.     lbut, rbut                               : BOOLEAN;
  395.  
  396. BEGIN
  397.   (* Zunächst den Startpunkt, dann wie bei Line den 2. Punkt holen und
  398.      zum Schlu₧ den dritten Punkt *)
  399.  
  400.   WaitForDepress(sx1, sy1);
  401.  
  402.   pkte[0] := sx1;
  403.   pkte[2] := sx1;
  404.   pkte[1] := sy1;
  405.   pkte[3] := sy1;
  406.   FOR i:=0 TO 3 DO BezierArray[i] := pkte[i]; END;
  407.  
  408.   Diverses.GetHelpText(4, Fix1stDiag);
  409.   HelpModule.HelpMessage(Fix1stDiag);
  410.   MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
  411.   dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
  412.   dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
  413.   lastx := sx1; lasty := sy1;
  414. (* Jetzt der 2. Stützpunkt *)
  415.   REPEAT
  416.  
  417.     MousePos(sx2, sy2, picx, picy, lbut, rbut);
  418.     Variablen.Position ( TRUE, sx2, sy2, sx1, sy1 ) ;
  419.     IF (sx2<>sx1) OR (sy2<>sy1) THEN
  420.       IF (sx2<>lastx) OR (sy2<>lasty) THEN (* Flackern vermeiden *)
  421.         PrepareDraw; (* Bereite Ausgabe vor *)
  422.         dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  423.         MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray  ) ;
  424.         ComputeBezier(BezierArray, 1, sx1, sy1, sx1, sy1, pkte[2], pkte[3],
  425.                 LastMinX, LastMinY, LastMaxX, LastMaxY);
  426.         pkte[2] := sx2; pkte[3] := sy2;
  427.         MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray  ) ;
  428.         FinishDraw; (* Zeichnung beendet *)
  429.       END;
  430.     END;
  431.     lastx := sx2; lasty := sy2;
  432.   UNTIL lbut OR rbut;
  433.  
  434.   PrepareDraw; (* Bereite Ausgabe vor um letzte Kurve zu löschen *)
  435.   dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  436.   MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray  ) ;
  437.   FinishDraw; (* Zeichnung beendet *)
  438.  
  439.   IF lbut AND NOT rbut THEN
  440.     (* Warten bis Maus losgelassen *)
  441.     REPEAT
  442.       MousePos(cx, cy, picx, picy, lbut, rbut);
  443.     UNTIL NOT (lbut OR rbut);
  444.     IF (sx2<sx1) THEN
  445.       dum := sx2; sx2 := sx1; sx1 := dum;
  446.       dum := sy2; sy2 := sy1; sy1 := dum;
  447.     END;
  448.  
  449.     pkte[0] := sx1; pkte[1] := sy1;
  450.     pkte[4] := sx2; pkte[5] := sy2;
  451.  
  452.     PrepareDraw; (* Bereite Ausgabe vor *)
  453.     pkte [ 2 ] := cx + (sx1 - cx) + (sx2 - cx);
  454.     pkte [ 3 ] := cy + (sy1 - cy) + (sy2 - cy);
  455.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  456.     MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  457.     pkte[2] := cx;   pkte[3] := cy;
  458.     MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  459.  
  460.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  461.     ZeichneKurven(20, FALSE, sx1, sy1, cx, cy, sx2, sy2);
  462.  
  463.     FinishDraw; (* Zeichnung beendet *)
  464.  
  465.     Diverses.GetHelpText(3, DrawRaute);
  466.     HelpModule.HelpMessage(DrawRaute);
  467.   (* Und nun der Kontrollpunkt *)
  468.     REPEAT
  469.  
  470.       lastx := cx; lasty := cy;
  471.  
  472.       MousePos ( cx , cy, picx, picy, lbut, rbut);
  473.       Variablen.Position (TRUE, cx, cy, sx1, sy1 ) ;
  474.       IF (cx<>sx2) OR (cy<>sy2) THEN
  475.         IF (cx<>lastx) OR (cy<>lasty) THEN
  476.           cx2 := cx + (sx1 - cx) + (sx2 - cx);
  477.           cy2 := cy + (sy1 - cy) + (sy2 - cy);
  478.           PrepareDraw; (* Bereite Ausgabe vor *)
  479.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  480.           MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  481.           pkte [ 2 ] := lastx + (sx1 - lastx) + (sx2 - lastx);
  482.           pkte [ 3 ] := lasty + (sy1 - lasty) + (sy2 - lasty);
  483.           MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  484.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  485.           ZeichneKurven(20, FALSE, sx1, sy1, lastx, lasty, sx2, sy2);
  486.           ZeichneKurven(20, FALSE, sx1, sy1, cx, cy, sx2, sy2);
  487.  
  488.           pkte[2] := cx2; pkte[3] := cy2;
  489.           dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  490.           MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  491.           pkte[2] := cx; pkte[3] := cy;
  492.           MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  493.           FinishDraw; (* Zeichnung beendet *)
  494.         END;
  495.       END;
  496.     UNTIL lbut OR rbut;
  497.  
  498.     PrepareDraw; (* Bereite Ausgabe vor *)
  499.     dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
  500.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  501.     MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  502.     pkte[2] := cx2; pkte[3] := cy2;
  503.     MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte  ) ;
  504.  
  505.     dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  506.     ZeichneKurven(20, FALSE, sx1, sy1, cx, cy, sx2, sy2);
  507.  
  508.     FinishDraw; (* Zeichnung beendet *)
  509.     IF lbut AND NOT rbut THEN
  510.       Diverses.GetHelpText(5, helptxt);
  511.       pos := 0;
  512.       WHILE (helptxt[pos]<>'?') DO
  513.         INC(pos);
  514.       END;
  515.  
  516.       Points := 50;
  517.       REPEAT
  518.         MousePos(lastx , lasty, picx, picy, lbut, rbut ) ;
  519.       UNTIL NOT (lbut OR rbut);
  520.  
  521.       MagicVDI.Text ( mtAppl.VDIHandle ,
  522.                                CommonData.DYPosx ,
  523.                                CommonData.DYPosy , '     ' ) ;
  524.       PrepareDraw; (* Bereite Ausgabe vor *)
  525.       ZeichneKurven(Points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
  526.       FinishDraw; (* Zeichnung beendet *)
  527.       MagicConvert.IntToStr(Points, 5, string);
  528.       FOR i:= 0 TO 4 DO
  529.         helptxt[pos+i] := string[i];
  530.       END;
  531.       MagicVDI.Text ( mtAppl.VDIHandle ,
  532.                                CommonData.DXPosx ,
  533.                                CommonData.DXPosy , string ) ;
  534.       HelpModule.HelpMessage(helptxt);
  535.  
  536.       REPEAT
  537.         MousePos(cx2 , cy2, picx, picy, lbut, rbut ) ;
  538.         IF (cx2<>lastx) THEN
  539.    (* Bei gedrückter rechter Maustaste ist Schrittweite 10, sonst 1  *)
  540.    (* Bei gedrückter linker & rechter Maustaste ist Schrittweite 100 *)
  541.           cy2 := Points;
  542.           IF lbut AND rbut THEN
  543.             Points := Points + 100 * (cx2-lastx);
  544.           ELSIF lbut AND NOT rbut THEN
  545.             Points := Points +  10 * (cx2-lastx);
  546.           ELSIF NOT (lbut OR rbut) THEN
  547.             Points := Points +   1 * (cx2-lastx);
  548.           END;
  549.           IF Points>MaxBezPts THEN Points := MaxBezPts; END;
  550.           IF Points<1 THEN Points := 1; END;
  551.           IF cy2<>Points THEN
  552.             PrepareDraw; (* Bereite Ausgabe vor *)
  553.             ZeichneKurven(cy2, TRUE, sx1, sy1, cx, cy, sx2, sy2);
  554.             ZeichneKurven(Points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
  555.             FinishDraw; (* Zeichnung beendet *)
  556.             MagicConvert.IntToStr(Points, 5, string);
  557.             FOR i:= 0 TO 4 DO
  558.               helptxt[27+i] := string[i];
  559.             END;
  560.             HelpModule.HelpMessage(helptxt);
  561.             MagicVDI.Text ( mtAppl.VDIHandle ,
  562.                             CommonData.DXPosx ,
  563.                             CommonData.DXPosy , string ) ;
  564.             (* Nachhinken verhindern, deswegen Mausposition auslesen *)
  565.             MousePos(cx2, cy2, picx, picy, lbut, rbut);
  566.           END;
  567.         END;
  568.         lastx := cx2;
  569.       UNTIL (lbut AND NOT rbut);
  570.  
  571.       PrepareDraw; (* Bereite Ausgabe vor *)
  572.       dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.REPLACE ) ;
  573.       ZeichneKurven(Points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
  574.       FinishDraw; (* Zeichnung beendet *)
  575.  
  576.       Variablen.PixToPic ( LastMinX, LastMinY,
  577.                                   SurroundRect[0], SurroundRect[1]);
  578.       SurroundRect[2] := LastMaxX-LastMinX;
  579.       SurroundRect[3] := LastMaxY-LastMinY;
  580.  
  581.       FOR dum := 0 TO 9 DO xy [ dum ] := 0 END ;
  582.  
  583.       Variablen.PixToPic ( sx1, sy1, xy [ 1 ] , xy [ 2 ] ) ;
  584.       Variablen.PixToPic ( sx2, sy2, xy [ 5 ] , xy [ 6 ] ) ;
  585.       Variablen.PixToPic ( cx,  cy,  xy [ 3 ] , xy [ 4 ] ) ;
  586.  
  587.       xy [ 3 ] := xy [ 3 ] - xy [ 1 ];
  588.       xy [ 4 ] := xy [ 4 ] - xy [ 2 ];
  589.       xy [ 5 ] := xy [ 5 ] - xy [ 1 ];
  590.       xy [ 6 ] := xy [ 6 ] - xy [ 2 ];
  591.       xy [ 7 ] := Points; (* Zahl der Punkte fest *)
  592.       xy [ 8 ] := CommonData.LineWidth ;
  593.  
  594.       xy [ 0 ] := ORD(Bezierellipse);
  595.  
  596.       Undo.PrepareUndo(TRUE);
  597.       Variablen.NewObject ( xy , NIL, NIL, SurroundRect ) ;
  598.     END;
  599.   END;
  600. END BezierEllipse;
  601.  
  602. PROCEDURE Show ( Object : ObjectPtrTyp ) ;
  603.  
  604. VAR sx1 , sy1 , sx2 , sy2 , cx , cy , dum, dum1, dum2 : INTEGER ;
  605.     points : INTEGER;
  606.     draw   : BOOLEAN;
  607.  
  608. BEGIN
  609.  
  610.   points := Object^.Code [ 7 ];
  611.   IF points > MaxBezPts THEN
  612.     points := MaxBezPts;
  613.   END;
  614.  
  615.  
  616.   Variablen.PicToPix ( sx1 , sy1 , Object^.Code [ 1 ] ,
  617.           Object^.Code [ 2 ] ) ;
  618.   dum1 := Object^.Code [ 1 ] + Object^.Code [ 3 ];
  619.   dum2 := Object^.Code [ 2 ] + Object^.Code [ 4 ];
  620.   Variablen.PicToPix ( cx , cy , dum1, dum2);
  621.   dum1 := Object^.Code [ 1 ] + Object^.Code [ 5 ];
  622.   dum2 := Object^.Code [ 2 ] + Object^.Code [ 6 ];
  623.   Variablen.PicToPix ( sx2 , sy2 , dum1, dum2);
  624.  
  625.   IF Object^.SurrDirty THEN
  626.     draw := TRUE;
  627.    ELSE
  628.     draw := Variablen.Visible (Object^.Surround);
  629.   END;
  630.  
  631.   IF draw THEN
  632.     dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
  633.     dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
  634.     IF CommonData.ShowBezLine THEN
  635.       dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
  636.      ELSE
  637.       dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
  638.       dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 11 * Object^.Code[8]);
  639.       dum := MagicVDI.SetMarkercolor(mtAppl.VDIHandle, MagicAES.BLACK);
  640.     END;
  641.     MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle ,
  642.                                 MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
  643.     dum := MagicVDI.SetFillinterior (mtAppl.VDIHandle , MagicVDI.Full ) ;
  644.     dum := MagicVDI.SetFillcolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
  645.     IF VAL(DrawObjectTyp, Object^.Code [ 0 ]) = Beziercurve THEN
  646.       ComputeBezier(BezierArray, points, sx1, sy1, cx, cy, sx2, sy2,
  647.                     LastMinX, LastMinY, LastMaxX, LastMaxY);
  648.       IF CommonData.ShowBezLine THEN
  649.         MagicVDI.Polyline ( mtAppl.VDIHandle , points+1 , BezierArray  ) ;
  650.        ELSE
  651.         MagicVDI.Polymarker ( mtAppl.VDIHandle , points+1 , BezierArray  ) ;
  652.       END;
  653.      ELSE
  654.       ZeichneKurven(points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
  655.     END ;
  656.     IF CommonData.ShowBezLine THEN
  657.       dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
  658.      ELSE
  659.       dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 11 * 1);
  660.     END;
  661.  
  662.     Variablen.PixToPic ( LastMinX, LastMinY,
  663.                                 Object^.Surround[0], Object^.Surround[1]);
  664.     Object^.Surround[2] := Variablen.PicDistance(LastMaxX-LastMinX);
  665.     Object^.Surround[3] := Variablen.PicDistance(LastMaxY-LastMinY);
  666.     Object^.SurrDirty   := FALSE;
  667.   END;
  668. END Show ;
  669.  
  670. PROCEDURE Change ( Object : ObjectPtrTyp;
  671.                    DX, DY : LONGREAL ) ;
  672. VAR newx, newy : INTEGER;
  673.  
  674. BEGIN
  675.   IF DX<>0.0 THEN
  676.     Object^.Code[3] := Diverses.round(MathLib0.real(Object^.Code[3]) * DX);
  677.     Object^.Code[5] := Diverses.round(MathLib0.real(Object^.Code[5]) * DX);
  678.     Object^.SurrDirty := TRUE;
  679.   END;
  680.   IF DY<>0.0 THEN
  681.     Object^.Code[4] := Diverses.round(MathLib0.real(Object^.Code[4]) * DY);
  682.     Object^.Code[6] := Diverses.round(MathLib0.real(Object^.Code[6]) * DY);
  683.     Object^.SurrDirty := TRUE;
  684.   END;
  685. END Change;
  686.  
  687. END Bezier .
  688.