plotpanel: Clip curve outside the drawing area defined by the axes.

git-svn-id: trunk@56334 -
This commit is contained in:
wp 2017-11-06 23:28:11 +00:00
parent 565c1544e4
commit d3268fe1b4

View File

@ -1168,6 +1168,8 @@ procedure TCanvasPlotter.PlotFunction(ACanvas: TCanvas);
Var Var
POX,PX,PXW,PY,POY,PEY,PYH,PLX,PLY : Integer; // Pixel units POX,PX,PXW,PY,POY,PEY,PYH,PLX,PLY : Integer; // Pixel units
X,Y,XI,YI,YO : TPlotFloat; // Plot units X,Y,XI,YI,YO : TPlotFloat; // Plot units
R: TRect;
clp: Boolean;
begin begin
// X-origin in pixels. // X-origin in pixels.
@ -1196,35 +1198,44 @@ begin
ACanvas.Pen.Width := FPlotLineWidth; ACanvas.Pen.Width := FPlotLineWidth;
PLX:=POX; PLX:=POX;
PLY:=POY; PLY:=POY;
For PX:=0 to PXW do R := ACanvas.ClipRect;
begin clp := ACanvas.Clipping;
try ACanvas.ClipRect := Rect(POX, FYAxis.TopMargin, PXW + POX, POY);
Y:=CalcFunction(X); ACanvas.Clipping := true;
PY:=POY-Trunc((Y-YO)*YI); try
except For PX:=0 to PXW do
// Catch math calculation exceptions.
On E : EMathError do
begin
PY:=PEY+1;
end;
On E : EIntError do
begin
PY:=PEY+1;
end;
On E : Exception do
Raise;
end;
If (PX>0) and (PY>=PEY) and (PY<=POY) then
begin begin
// Writeln(Format('(%f,%f) -> (%d,%d)',[X,Y,PX+Pox,PY])); try
// ACanvas.Pixels[PX+Pox,PY]:=PlotColor; Y:=CalcFunction(X);
ACanvas.Line(Pox+PLX,PLY,POX+PX,PY); PY:=POY-Trunc((Y-YO)*YI);
except
// Catch math calculation exceptions.
On E : EMathError do
begin
PY:=PEY+1;
end;
On E : EIntError do
begin
PY:=PEY+1;
end;
On E : Exception do
Raise;
end; end;
PLX:=PX; If (PX>0) and (PY>=PEY) and (PY<=POY) then
PLY:=PY; begin
X:=X+XI; // Writeln(Format('(%f,%f) -> (%d,%d)',[X,Y,PX+Pox,PY]));
// ACanvas.Pixels[PX+Pox,PY]:=PlotColor;
ACanvas.Line(Pox+PLX,PLY,POX+PX,PY);
end;
PLX:=PX;
PLY:=PY;
X:=X+XI;
end; end;
finally
ACanvas.ClipRect := R;
ACanvas.Clipping := clp;
end;
end; end;
function TCanvasPlotter.GetHDimension: Integer; function TCanvasPlotter.GetHDimension: Integer;