1
{ **********************************************************************
3
**********************************************************************
4
Variables and routines common to PLOT.PAS and WINPLOT.PAS
5
********************************************************************** }
8
XminPixel, YminPixel : Integer; { Pixel coord. of upper left corner }
9
XmaxPixel, YmaxPixel : Integer; { Pixel coord. of lower right corner }
10
FactX, FactY : Float; { Scaling factors }
12
function Xpixel(X : Float) : Integer;
16
P := FactX * (X - XAxis.Min);
17
if Abs(P) > 30000 then
20
Xpixel := Round(P) + XminPixel;
23
function Ypixel(Y : Float) : Integer;
27
P := FactY * (YAxis.Max - Y);
28
if Abs(P) > 30000 then
31
Ypixel := Round(P) + YminPixel;
34
function Xuser(X : Integer) : Float;
36
Xuser := XAxis.Min + (X - XminPixel) / FactX;
39
function Yuser(Y : Integer) : Float;
41
Yuser := YAxis.Max - (Y - YminPixel) / FactY;
44
procedure Interval(X1, X2 : Float; MinDiv, MaxDiv : Integer;
45
var Min, Max, Step : Float);
49
if X1 >= X2 then Exit;
52
if H < 1.0 then R := R - 1.0;
57
if K < MinDiv then Step := 0.5 * Step;
58
if K > MaxDiv then Step := 2.0 * Step;
59
until (K >= MinDiv) and (K <= MaxDiv);
61
Min := Step * Int(X1 / Step);
62
Max := Step * Int(X2 / Step);
63
while Min > X1 do Min := Min - Step;
64
while Max < X2 do Max := Max + Step;
67
procedure AutoScale(Z : PVector; Lbound, Ubound : Integer;
71
Zmin, Zmax, Z1, Z2 : Float;
73
if Axis.Scale = LIN_SCALE then
74
Interval(Min(Z, Lbound, Ubound), Max(Z, Lbound, Ubound),
75
2, 6, Axis.Min, Axis.Max, Axis.Step)
78
Zmin := MAXNUM; Zmax := 0.0;
79
for I := Lbound to Ubound do
83
else if Z^[I] > Zmax then
85
Z1 := Int(Log10(Zmin));
86
Z2 := Int(Log10(Zmax));
87
if Zmin < 1.0 then Z1 := Z1 - 1.0;
88
if Zmax > 1.0 then Z2 := Z2 + 1.0;