home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari FTP
/
ATARI_FTP_0693.zip
/
ATARI_FTP_0693
/
Tex
/
td187src.lzh
/
BEZIER.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
27KB
|
688 lines
IMPLEMENTATION MODULE Bezier ;
IMPORT mtAppl ;
IMPORT Diverses ;
IMPORT MagicAES ;
IMPORT MagicVDI ;
IMPORT MagicSys ;
IMPORT MathLib0 ;
IMPORT MagicConvert;
IMPORT Variablen ;
IMPORT CommonData;
IMPORT HelpModule;
IMPORT Undo;
FROM OwnBoxes IMPORT WaitForDepress, MousePos;
FROM Types IMPORT TextPosTyp, DrawObjectTyp, CodeAryTyp, ObjectPtrTyp;
FROM BezierCurve IMPORT ComputeBezier;
CONST MaxBezPts = 1000;
VAR BezierArray : ARRAY [0..2*MaxBezPts+1] OF INTEGER;
LastMaxX, LastMaxY : INTEGER; (* Um Ausma₧e bestimmen zu können *)
LastMinX, LastMinY : INTEGER;
(**
PROCEDURE Max(i1, i2 : INTEGER) : INTEGER;
BEGIN
IF i1>i2 THEN
RETURN i1;
ELSE
RETURN i2;
END;
END Max;
PROCEDURE Min(i1, i2 : INTEGER) : INTEGER;
BEGIN
IF i1>i2 THEN
RETURN i2;
ELSE
RETURN i1;
END;
END Min;
**)
PROCEDURE PrepareDraw;
(* Draw-Modus = XOR, Mouse Off, Clipping off *)
VAR dum : INTEGER;
BEGIN
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
MagicVDI.SetClipping ( mtAppl.VDIHandle , CommonData.ClipXY , TRUE) ;
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth(mtAppl.VDIHandle, CommonData.LineWidth);
ELSE
dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 11 * CommonData.LineWidth);
END;
Diverses.MouseOff;
END PrepareDraw;
PROCEDURE FinishDraw;
(* Draw-Modus = Replace, Mouse On, Clipping off *)
VAR dum : INTEGER;
BEGIN
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.REPLACE ) ;
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth(mtAppl.VDIHandle, CommonData.LineWidth);
ELSE
dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 1 * 11);
END;
MagicVDI.SetClipping ( mtAppl.VDIHandle , CommonData.ClipXY , FALSE) ;
Diverses.MouseOn;
END FinishDraw;
PROCEDURE BezierCurve();
VAR cx, cx2, sx1, sx2, cy, cy2, sy1, sy2, lastx, lasty : INTEGER;
Points, x , y , dum, picx, picy : INTEGER ;
but : BITSET;
lbut, rbut : BOOLEAN;
SurroundRect : ARRAY [0..3] OF INTEGER;
xy : CodeAryTyp ;
pkte : ARRAY [0..5] OF INTEGER;
i, pos : INTEGER;
string : ARRAY [0..9] OF CHAR;
FixEndPt,
FixCtrlPt,
helptxt : ARRAY [0..49] OF CHAR;
BEGIN
(* Zunächst den Startpunkt, dann wie bei Line den 2. Punkt holen und
zum Schlu₧ den dritten Punkt *)
WaitForDepress(sx1, sy1);
pkte[0] := sx1;
pkte[2] := sx1;
pkte[1] := sy1;
pkte[3] := sy1;
FOR i:=0 TO 3 DO BezierArray[i] := pkte[i]; END;
MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
lastx := sx1; lasty := sy1;
Diverses.GetHelpText(1, FixEndPt);
HelpModule.HelpMessage(FixEndPt);
(* Jetzt der 2. Stützpunkt *)
REPEAT
MousePos (sx2, sy2, picx, picy, lbut, rbut);
Variablen.Position ( TRUE, sx2, sy2, sx1, sy1 ) ;
IF (sx2<>sx1) OR (sy2<>sy1) THEN
IF (sx2<>lastx) OR (sy2<>lasty) THEN (* Flackern vermeiden *)
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray ) ;
ComputeBezier(BezierArray, 1, sx1, sy1, sx1, sy1,
pkte[2], pkte[3], LastMinX, LastMinY,
LastMaxX, LastMaxY);
pkte[2] := sx2; pkte[3] := sy2;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray ) ;
FinishDraw; (* Zeichnung beendet *)
END;
END;
lastx := sx2; lasty := sy2;
UNTIL lbut OR rbut;
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray ) ;
FinishDraw; (* Zeichnung beendet *)
IF lbut AND NOT rbut THEN
(* Warten bis Maus losgelassen *)
REPEAT
MousePos(cx, cy, picx, picy, lbut, rbut);
UNTIL NOT (lbut OR rbut);
lastx := cx;
lasty := cy;
IF (sx2<sx1) THEN
dum := sx2; sx2 := sx1; sx1 := dum;
dum := sy2; sy2 := sy1; sy1 := dum;
END;
ComputeBezier(BezierArray, 20, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
pkte[4] := pkte[2];
pkte[5] := pkte[3];
pkte[2] := cx;
pkte[3] := cy;
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
FinishDraw; (* Zeichnung beendet *)
Diverses.GetHelpText(2, FixCtrlPt);
HelpModule.HelpMessage(FixCtrlPt);
(* Und nun der Kontrollpunkt *)
REPEAT
MousePos ( cx, cy, picx, picy, lbut, rbut );
Variablen.Position (TRUE, cx, cy, sx1, sy1 ) ;
IF (cx<>sx2) OR (cy<>sy2) THEN
IF (cx<>lastx) OR (cy<>lasty) THEN
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray ) ;
pkte[2] := cx; pkte[3] := cy;
ComputeBezier(BezierArray, 20, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
FinishDraw; (* Zeichnung beendet *)
END;
END;
lastx := cx; lasty := cy;
UNTIL (lbut OR rbut);
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 21 , BezierArray ) ;
FinishDraw; (* Zeichnung beendet *)
WaitForDepress(lastx, lasty);
IF (lbut) AND NOT (rbut) THEN
Diverses.GetHelpText(5, helptxt);
pos := 0;
WHILE (helptxt[pos]<>'?') DO
INC(pos);
END;
Points := 50;
REPEAT
MousePos(lastx, lasty, picx, picy, lbut, rbut);
UNTIL NOT (lbut OR rbut);
MagicVDI.Text ( mtAppl.VDIHandle ,
CommonData.DYPosx ,
CommonData.DYPosy , ' ' ) ;
PrepareDraw; (* Bereite Ausgabe vor *)
ComputeBezier(BezierArray, Points, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , Points + 1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , Points + 1 , BezierArray ) ;
END;
FinishDraw; (* Zeichnung beendet *)
MagicConvert.IntToStr(Points, 5, string);
FOR i:= 0 TO 4 DO
helptxt[pos+i] := string[i];
END;
MagicVDI.Text ( mtAppl.VDIHandle ,
CommonData.DXPosx ,
CommonData.DXPosy , string ) ;
HelpModule.HelpMessage(helptxt);
REPEAT
MousePos(cx2, cy2, picx, picy, lbut, rbut);
IF (cx2<>lastx) THEN
(* Bei gedrückter rechter Maustaste ist Schrittweite 10, sonst 1 *)
(* Bei gedrückter linker & rechter Maustaste ist Schrittweite 100 *)
cy2 := Points;
IF lbut AND rbut THEN
Points := Points + 100 * (cx2-lastx);
ELSIF rbut AND NOT lbut THEN
Points := Points + 10 * (cx2-lastx);
ELSIF NOT (lbut OR rbut) THEN
Points := Points + 1 * (cx2-lastx);
END;
IF Points>MaxBezPts THEN Points := MaxBezPts; END;
IF Points<1 THEN Points := 1; END;
IF Points<>cy2 THEN
PrepareDraw; (* Bereite Ausgabe vor *)
ComputeBezier(BezierArray, cy2, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle, cy2 + 1, BezierArray );
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle, cy2 + 1, BezierArray );
END;
ComputeBezier(BezierArray, Points, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle, Points + 1, BezierArray );
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle, Points + 1, BezierArray );
END;
FinishDraw; (* Zeichnung beendet *)
MagicConvert.IntToStr(Points, 5, string);
FOR i:= 0 TO 4 DO
helptxt[27+i] := string[i];
END;
MagicVDI.Text ( mtAppl.VDIHandle ,
CommonData.DXPosx ,
CommonData.DXPosy , string ) ;
HelpModule.HelpMessage(helptxt);
(* Nachhinken verhindern, deswegen Mausposition auslesen *)
MousePos(cx2, cy2, picx, picy, lbut, rbut);
END;
END;
lastx := cx2;
UNTIL lbut AND NOT rbut;
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.REPLACE ) ;
ComputeBezier(BezierArray, Points, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , Points + 1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , Points + 1 , BezierArray ) ;
END;
FinishDraw; (* Zeichnung beendet *)
FOR dum := 0 TO 9 DO xy [ dum ] := 0 END ;
Variablen.PixToPic ( sx1, sy1, xy [ 1 ] , xy [ 2 ] ) ;
Variablen.PixToPic ( sx2, sy2, xy [ 5 ] , xy [ 6 ] ) ;
Variablen.PixToPic ( cx, cy, xy [ 3 ] , xy [ 4 ] ) ;
picx := LastMaxX-LastMinX;
picy := LastMaxY-LastMinY;
Variablen.PixToPic ( LastMinX, LastMinY, SurroundRect[0], SurroundRect[1]);
Variablen.PixToPic ( picx, picy, SurroundRect[2], SurroundRect[3]);
xy [ 3 ] := xy [ 3 ] - xy [ 1 ];
xy [ 4 ] := xy [ 4 ] - xy [ 2 ];
xy [ 5 ] := xy [ 5 ] - xy [ 1 ];
xy [ 6 ] := xy [ 6 ] - xy [ 2 ];
xy [ 7 ] := Points;
xy [ 8 ] := CommonData.LineWidth ;
xy [ 0 ] := ORD(Beziercurve);
Undo.PrepareUndo(TRUE);
Variablen.NewObject ( xy , NIL, NIL, SurroundRect ) ;
END;
END;
END BezierCurve;
PROCEDURE ZeichneKurven(Pts : INTEGER;
PtMode : BOOLEAN;
x1, y1, x2, y2, x3, y3 : INTEGER);
VAR dum, px1, px2, px3, px4, py1, py2, py3, py4, x4, y4 : INTEGER;
mx, MX, my, MY : INTEGER;
BEGIN
x4 := x2 + (x1 - x2) + (x3 - x2);
y4 := y2 + (y1 - y2) + (y3 - y2);
px1 := (x1 + x2) DIV 2; py1 := (y1 + y2) DIV 2;
px2 := (x1 + x4) DIV 2; py2 := (y1 + y4) DIV 2;
px3 := (x3 + x4) DIV 2; py3 := (y3 + y4) DIV 2;
px4 := (x3 + x2) DIV 2; py4 := (y3 + y2) DIV 2;
ComputeBezier(BezierArray, Pts, px1, py1, x1, y1, px2, py2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
MX := LastMaxX; mx := LastMinX;
MY := LastMaxY; my := LastMinY;
IF PtMode THEN
dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
END;
IF PtMode THEN
IF CommonData.ShowBezLine THEN
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ELSE
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ComputeBezier(BezierArray, Pts, px2, py2, x4, y4, px3, py3,
LastMinX, LastMinY, LastMaxX, LastMaxY);
MX := Diverses.max(MX,LastMaxX); mx := Diverses.min(mx,LastMinX);
MY := Diverses.max(MY,LastMaxY); my := Diverses.min(my,LastMinY);
IF PtMode THEN
IF CommonData.ShowBezLine THEN
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ELSE
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ComputeBezier(BezierArray, Pts, px3, py3, x3, y3, px4, py4,
LastMinX, LastMinY, LastMaxX, LastMaxY);
MX := Diverses.max(MX,LastMaxX); mx := Diverses.min(mx,LastMinX);
MY := Diverses.max(MY,LastMaxY); my := Diverses.min(my,LastMinY);
IF PtMode THEN
IF CommonData.ShowBezLine THEN
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ELSE
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ComputeBezier(BezierArray, Pts, px4, py4, x2, y2, px1, py1,
LastMinX, LastMinY, LastMaxX, LastMaxY);
MX := Diverses.max(MX,LastMaxX); mx := Diverses.min(mx,LastMinX);
MY := Diverses.max(MY,LastMaxY); my := Diverses.min(my,LastMinY);
IF PtMode THEN
IF CommonData.ShowBezLine THEN
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
ELSE
MagicVDI.Polyline ( mtAppl.VDIHandle , Pts+1 , BezierArray ) ;
END;
LastMaxX := MX; LastMinX := mx; LastMaxY := MY; LastMinY := my;
END ZeichneKurven;
PROCEDURE BezierEllipse();
VAR cx, sx1, sx2, cy, sy1, sy2, lastx, lasty : INTEGER;
cx2, cy2, x, y, dum, Points, i, pos : INTEGER;
picx, picy : INTEGER;
xy : CodeAryTyp ;
pkte : ARRAY [0..5] OF INTEGER;
SurroundRect : ARRAY [0..3] OF INTEGER;
string : ARRAY [0..5] OF CHAR;
Fix1stDiag, DrawRaute, helptxt : ARRAY [0..49] OF CHAR;
lbut, rbut : BOOLEAN;
BEGIN
(* Zunächst den Startpunkt, dann wie bei Line den 2. Punkt holen und
zum Schlu₧ den dritten Punkt *)
WaitForDepress(sx1, sy1);
pkte[0] := sx1;
pkte[2] := sx1;
pkte[1] := sy1;
pkte[3] := sy1;
FOR i:=0 TO 3 DO BezierArray[i] := pkte[i]; END;
Diverses.GetHelpText(4, Fix1stDiag);
HelpModule.HelpMessage(Fix1stDiag);
MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
lastx := sx1; lasty := sy1;
(* Jetzt der 2. Stützpunkt *)
REPEAT
MousePos(sx2, sy2, picx, picy, lbut, rbut);
Variablen.Position ( TRUE, sx2, sy2, sx1, sy1 ) ;
IF (sx2<>sx1) OR (sy2<>sy1) THEN
IF (sx2<>lastx) OR (sy2<>lasty) THEN (* Flackern vermeiden *)
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray ) ;
ComputeBezier(BezierArray, 1, sx1, sy1, sx1, sy1, pkte[2], pkte[3],
LastMinX, LastMinY, LastMaxX, LastMaxY);
pkte[2] := sx2; pkte[3] := sy2;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray ) ;
FinishDraw; (* Zeichnung beendet *)
END;
END;
lastx := sx2; lasty := sy2;
UNTIL lbut OR rbut;
PrepareDraw; (* Bereite Ausgabe vor um letzte Kurve zu löschen *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 2 , BezierArray ) ;
FinishDraw; (* Zeichnung beendet *)
IF lbut AND NOT rbut THEN
(* Warten bis Maus losgelassen *)
REPEAT
MousePos(cx, cy, picx, picy, lbut, rbut);
UNTIL NOT (lbut OR rbut);
IF (sx2<sx1) THEN
dum := sx2; sx2 := sx1; sx1 := dum;
dum := sy2; sy2 := sy1; sy1 := dum;
END;
pkte[0] := sx1; pkte[1] := sy1;
pkte[4] := sx2; pkte[5] := sy2;
PrepareDraw; (* Bereite Ausgabe vor *)
pkte [ 2 ] := cx + (sx1 - cx) + (sx2 - cx);
pkte [ 3 ] := cy + (sy1 - cy) + (sy2 - cy);
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
pkte[2] := cx; pkte[3] := cy;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
ZeichneKurven(20, FALSE, sx1, sy1, cx, cy, sx2, sy2);
FinishDraw; (* Zeichnung beendet *)
Diverses.GetHelpText(3, DrawRaute);
HelpModule.HelpMessage(DrawRaute);
(* Und nun der Kontrollpunkt *)
REPEAT
lastx := cx; lasty := cy;
MousePos ( cx , cy, picx, picy, lbut, rbut);
Variablen.Position (TRUE, cx, cy, sx1, sy1 ) ;
IF (cx<>sx2) OR (cy<>sy2) THEN
IF (cx<>lastx) OR (cy<>lasty) THEN
cx2 := cx + (sx1 - cx) + (sx2 - cx);
cy2 := cy + (sy1 - cy) + (sy2 - cy);
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
pkte [ 2 ] := lastx + (sx1 - lastx) + (sx2 - lastx);
pkte [ 3 ] := lasty + (sy1 - lasty) + (sy2 - lasty);
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
ZeichneKurven(20, FALSE, sx1, sy1, lastx, lasty, sx2, sy2);
ZeichneKurven(20, FALSE, sx1, sy1, cx, cy, sx2, sy2);
pkte[2] := cx2; pkte[3] := cy2;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
pkte[2] := cx; pkte[3] := cy;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
FinishDraw; (* Zeichnung beendet *)
END;
END;
UNTIL lbut OR rbut;
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
pkte[2] := cx2; pkte[3] := cy2;
MagicVDI.Polyline ( mtAppl.VDIHandle , 3 , pkte ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
ZeichneKurven(20, FALSE, sx1, sy1, cx, cy, sx2, sy2);
FinishDraw; (* Zeichnung beendet *)
IF lbut AND NOT rbut THEN
Diverses.GetHelpText(5, helptxt);
pos := 0;
WHILE (helptxt[pos]<>'?') DO
INC(pos);
END;
Points := 50;
REPEAT
MousePos(lastx , lasty, picx, picy, lbut, rbut ) ;
UNTIL NOT (lbut OR rbut);
MagicVDI.Text ( mtAppl.VDIHandle ,
CommonData.DYPosx ,
CommonData.DYPosy , ' ' ) ;
PrepareDraw; (* Bereite Ausgabe vor *)
ZeichneKurven(Points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
FinishDraw; (* Zeichnung beendet *)
MagicConvert.IntToStr(Points, 5, string);
FOR i:= 0 TO 4 DO
helptxt[pos+i] := string[i];
END;
MagicVDI.Text ( mtAppl.VDIHandle ,
CommonData.DXPosx ,
CommonData.DXPosy , string ) ;
HelpModule.HelpMessage(helptxt);
REPEAT
MousePos(cx2 , cy2, picx, picy, lbut, rbut ) ;
IF (cx2<>lastx) THEN
(* Bei gedrückter rechter Maustaste ist Schrittweite 10, sonst 1 *)
(* Bei gedrückter linker & rechter Maustaste ist Schrittweite 100 *)
cy2 := Points;
IF lbut AND rbut THEN
Points := Points + 100 * (cx2-lastx);
ELSIF lbut AND NOT rbut THEN
Points := Points + 10 * (cx2-lastx);
ELSIF NOT (lbut OR rbut) THEN
Points := Points + 1 * (cx2-lastx);
END;
IF Points>MaxBezPts THEN Points := MaxBezPts; END;
IF Points<1 THEN Points := 1; END;
IF cy2<>Points THEN
PrepareDraw; (* Bereite Ausgabe vor *)
ZeichneKurven(cy2, TRUE, sx1, sy1, cx, cy, sx2, sy2);
ZeichneKurven(Points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
FinishDraw; (* Zeichnung beendet *)
MagicConvert.IntToStr(Points, 5, string);
FOR i:= 0 TO 4 DO
helptxt[27+i] := string[i];
END;
HelpModule.HelpMessage(helptxt);
MagicVDI.Text ( mtAppl.VDIHandle ,
CommonData.DXPosx ,
CommonData.DXPosy , string ) ;
(* Nachhinken verhindern, deswegen Mausposition auslesen *)
MousePos(cx2, cy2, picx, picy, lbut, rbut);
END;
END;
lastx := cx2;
UNTIL (lbut AND NOT rbut);
PrepareDraw; (* Bereite Ausgabe vor *)
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.REPLACE ) ;
ZeichneKurven(Points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
FinishDraw; (* Zeichnung beendet *)
Variablen.PixToPic ( LastMinX, LastMinY,
SurroundRect[0], SurroundRect[1]);
SurroundRect[2] := LastMaxX-LastMinX;
SurroundRect[3] := LastMaxY-LastMinY;
FOR dum := 0 TO 9 DO xy [ dum ] := 0 END ;
Variablen.PixToPic ( sx1, sy1, xy [ 1 ] , xy [ 2 ] ) ;
Variablen.PixToPic ( sx2, sy2, xy [ 5 ] , xy [ 6 ] ) ;
Variablen.PixToPic ( cx, cy, xy [ 3 ] , xy [ 4 ] ) ;
xy [ 3 ] := xy [ 3 ] - xy [ 1 ];
xy [ 4 ] := xy [ 4 ] - xy [ 2 ];
xy [ 5 ] := xy [ 5 ] - xy [ 1 ];
xy [ 6 ] := xy [ 6 ] - xy [ 2 ];
xy [ 7 ] := Points; (* Zahl der Punkte fest *)
xy [ 8 ] := CommonData.LineWidth ;
xy [ 0 ] := ORD(Bezierellipse);
Undo.PrepareUndo(TRUE);
Variablen.NewObject ( xy , NIL, NIL, SurroundRect ) ;
END;
END;
END BezierEllipse;
PROCEDURE Show ( Object : ObjectPtrTyp ) ;
VAR sx1 , sy1 , sx2 , sy2 , cx , cy , dum, dum1, dum2 : INTEGER ;
points : INTEGER;
draw : BOOLEAN;
BEGIN
points := Object^.Code [ 7 ];
IF points > MaxBezPts THEN
points := MaxBezPts;
END;
Variablen.PicToPix ( sx1 , sy1 , Object^.Code [ 1 ] ,
Object^.Code [ 2 ] ) ;
dum1 := Object^.Code [ 1 ] + Object^.Code [ 3 ];
dum2 := Object^.Code [ 2 ] + Object^.Code [ 4 ];
Variablen.PicToPix ( cx , cy , dum1, dum2);
dum1 := Object^.Code [ 1 ] + Object^.Code [ 5 ];
dum2 := Object^.Code [ 2 ] + Object^.Code [ 6 ];
Variablen.PicToPix ( sx2 , sy2 , dum1, dum2);
IF Object^.SurrDirty THEN
draw := TRUE;
ELSE
draw := Variablen.Visible (Object^.Surround);
END;
IF draw THEN
dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.Line ) ;
dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , CommonData.LineWidth ) ;
ELSE
dum := MagicVDI.SetMarkertype(mtAppl.VDIHandle, MagicVDI.Point);
dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 11 * Object^.Code[8]);
dum := MagicVDI.SetMarkercolor(mtAppl.VDIHandle, MagicAES.BLACK);
END;
MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle ,
MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
dum := MagicVDI.SetFillinterior (mtAppl.VDIHandle , MagicVDI.Full ) ;
dum := MagicVDI.SetFillcolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
IF VAL(DrawObjectTyp, Object^.Code [ 0 ]) = Beziercurve THEN
ComputeBezier(BezierArray, points, sx1, sy1, cx, cy, sx2, sy2,
LastMinX, LastMinY, LastMaxX, LastMaxY);
IF CommonData.ShowBezLine THEN
MagicVDI.Polyline ( mtAppl.VDIHandle , points+1 , BezierArray ) ;
ELSE
MagicVDI.Polymarker ( mtAppl.VDIHandle , points+1 , BezierArray ) ;
END;
ELSE
ZeichneKurven(points, TRUE, sx1, sy1, cx, cy, sx2, sy2);
END ;
IF CommonData.ShowBezLine THEN
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
ELSE
dum := MagicVDI.SetMarkerheight(mtAppl.VDIHandle, 11 * 1);
END;
Variablen.PixToPic ( LastMinX, LastMinY,
Object^.Surround[0], Object^.Surround[1]);
Object^.Surround[2] := Variablen.PicDistance(LastMaxX-LastMinX);
Object^.Surround[3] := Variablen.PicDistance(LastMaxY-LastMinY);
Object^.SurrDirty := FALSE;
END;
END Show ;
PROCEDURE Change ( Object : ObjectPtrTyp;
DX, DY : LONGREAL ) ;
VAR newx, newy : INTEGER;
BEGIN
IF DX<>0.0 THEN
Object^.Code[3] := Diverses.round(MathLib0.real(Object^.Code[3]) * DX);
Object^.Code[5] := Diverses.round(MathLib0.real(Object^.Code[5]) * DX);
Object^.SurrDirty := TRUE;
END;
IF DY<>0.0 THEN
Object^.Code[4] := Diverses.round(MathLib0.real(Object^.Code[4]) * DY);
Object^.Code[6] := Diverses.round(MathLib0.real(Object^.Code[6]) * DY);
Object^.SurrDirty := TRUE;
END;
END Change;
END Bezier .