mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 07:59:28 +02:00
TAChart: Make LogicalExtent settable property as a more general replacement for Pan method
git-svn-id: trunk@24350 -
This commit is contained in:
parent
fafe56406f
commit
8cc81d308a
@ -147,6 +147,7 @@ type
|
|||||||
FFrame: TChartPen;
|
FFrame: TChartPen;
|
||||||
FGraphBrush: TBrush;
|
FGraphBrush: TBrush;
|
||||||
FLegend: TChartLegend;
|
FLegend: TChartLegend;
|
||||||
|
FLogicalExtent: TDoubleRect;
|
||||||
FMargins: TChartMargins;
|
FMargins: TChartMargins;
|
||||||
FOnDrawReticule: TDrawReticuleEvent;
|
FOnDrawReticule: TDrawReticuleEvent;
|
||||||
FSeries: TChartSeriesList;
|
FSeries: TChartSeriesList;
|
||||||
@ -159,7 +160,6 @@ type
|
|||||||
FClipRect: TRect;
|
FClipRect: TRect;
|
||||||
FCurrentExtent: TDoubleRect;
|
FCurrentExtent: TDoubleRect;
|
||||||
FIsZoomed: Boolean;
|
FIsZoomed: Boolean;
|
||||||
FLogicalExtent: TDoubleRect;
|
|
||||||
FOffset: TDoublePoint; // Coordinates transformation
|
FOffset: TDoublePoint; // Coordinates transformation
|
||||||
FReticuleMode: TReticuleMode;
|
FReticuleMode: TReticuleMode;
|
||||||
FReticulePos: TPoint;
|
FReticulePos: TPoint;
|
||||||
@ -185,6 +185,7 @@ type
|
|||||||
procedure SetFrame(Value: TChartPen);
|
procedure SetFrame(Value: TChartPen);
|
||||||
procedure SetGraphBrush(Value: TBrush);
|
procedure SetGraphBrush(Value: TBrush);
|
||||||
procedure SetLegend(Value: TChartLegend);
|
procedure SetLegend(Value: TChartLegend);
|
||||||
|
procedure SetLogicalExtent(const AValue: TDoubleRect);
|
||||||
procedure SetMargins(AValue: TChartMargins);
|
procedure SetMargins(AValue: TChartMargins);
|
||||||
procedure SetReticuleMode(const AValue: TReticuleMode);
|
procedure SetReticuleMode(const AValue: TReticuleMode);
|
||||||
procedure SetReticulePos(const AValue: TPoint);
|
procedure SetReticulePos(const AValue: TPoint);
|
||||||
@ -228,7 +229,6 @@ type
|
|||||||
procedure CopyToClipboardBitmap;
|
procedure CopyToClipboardBitmap;
|
||||||
procedure DeleteSeries(ASeries: TBasicChartSeries);
|
procedure DeleteSeries(ASeries: TBasicChartSeries);
|
||||||
procedure PaintOnCanvas(ACanvas: TCanvas; ARect: TRect);
|
procedure PaintOnCanvas(ACanvas: TCanvas; ARect: TRect);
|
||||||
procedure Pan(const ADelta: TPoint);
|
|
||||||
procedure SaveToBitmapFile(const AFileName: String); inline;
|
procedure SaveToBitmapFile(const AFileName: String); inline;
|
||||||
procedure SaveToFile(AClass: TRasterImageClass; const AFileName: String);
|
procedure SaveToFile(AClass: TRasterImageClass; const AFileName: String);
|
||||||
function SaveToImage(AClass: TRasterImageClass): TRasterImage;
|
function SaveToImage(AClass: TRasterImageClass): TRasterImage;
|
||||||
@ -249,6 +249,7 @@ type
|
|||||||
property ChartWidth: Integer read GetChartWidth;
|
property ChartWidth: Integer read GetChartWidth;
|
||||||
property ClipRect: TRect read FClipRect;
|
property ClipRect: TRect read FClipRect;
|
||||||
property CurrentExtent: TDoubleRect read FCurrentExtent;
|
property CurrentExtent: TDoubleRect read FCurrentExtent;
|
||||||
|
property LogicalExtent: TDoubleRect read FLogicalExtent write SetLogicalExtent;
|
||||||
property ReticulePos: TPoint read FReticulePos write SetReticulePos;
|
property ReticulePos: TPoint read FReticulePos write SetReticulePos;
|
||||||
property SeriesCount: Integer read GetSeriesCount;
|
property SeriesCount: Integer read GetSeriesCount;
|
||||||
property XGraphMax: Double read FCurrentExtent.b.X;
|
property XGraphMax: Double read FCurrentExtent.b.X;
|
||||||
@ -481,21 +482,6 @@ begin
|
|||||||
Series[i].AfterDraw;
|
Series[i].AfterDraw;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChart.Pan(const ADelta: TPoint);
|
|
||||||
var
|
|
||||||
d: TDoublePoint;
|
|
||||||
begin
|
|
||||||
d.X := -ADelta.X / FScale.X;
|
|
||||||
d.Y := -ADelta.Y / FScale.Y;
|
|
||||||
with FLogicalExtent do begin
|
|
||||||
a += d;
|
|
||||||
b += d;
|
|
||||||
end;
|
|
||||||
FIsZoomed := true;
|
|
||||||
FCurrentExtent := FLogicalExtent;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TChart.PrepareLegend(
|
procedure TChart.PrepareLegend(
|
||||||
ACanvas: TCanvas; out ALegendItems: TChartLegendItems; out ARect: TRect);
|
ACanvas: TCanvas; out ALegendItems: TChartLegendItems; out ARect: TRect);
|
||||||
var
|
var
|
||||||
@ -914,6 +900,14 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChart.SetLogicalExtent(const AValue: TDoubleRect);
|
||||||
|
begin
|
||||||
|
FLogicalExtent := AValue;
|
||||||
|
FIsZoomed := true;
|
||||||
|
FCurrentExtent := FLogicalExtent;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChart.SetMargins(AValue: TChartMargins);
|
procedure TChart.SetMargins(AValue: TChartMargins);
|
||||||
begin
|
begin
|
||||||
FMargins.Assign(AValue);
|
FMargins.Assign(AValue);
|
||||||
|
@ -610,14 +610,22 @@ end;
|
|||||||
procedure TPanDragTool.MouseMove(APoint: TPoint);
|
procedure TPanDragTool.MouseMove(APoint: TPoint);
|
||||||
var
|
var
|
||||||
d: TPoint;
|
d: TPoint;
|
||||||
|
dd: TDoublePoint;
|
||||||
|
ext: TDoubleRect;
|
||||||
begin
|
begin
|
||||||
d := APoint - FOrigin;
|
d := APoint - FOrigin;
|
||||||
|
FOrigin := APoint;
|
||||||
|
|
||||||
if not (pdLeft in Directions) then d.X := Max(d.X, 0);
|
if not (pdLeft in Directions) then d.X := Max(d.X, 0);
|
||||||
if not (pdRight in Directions) then d.X := Min(d.X, 0);
|
if not (pdRight in Directions) then d.X := Min(d.X, 0);
|
||||||
if not (pdUp in Directions) then d.Y := Max(d.Y, 0);
|
if not (pdUp in Directions) then d.Y := Max(d.Y, 0);
|
||||||
if not (pdDown in Directions) then d.Y := Min(d.Y, 0);
|
if not (pdDown in Directions) then d.Y := Min(d.Y, 0);
|
||||||
FChart.Pan(d);
|
|
||||||
FOrigin := APoint;
|
dd := FChart.ImageToGraph(d) - FChart.ImageToGraph(Point(0, 0));
|
||||||
|
ext := FChart.LogicalExtent;
|
||||||
|
ext.a += dd;
|
||||||
|
ext.b += dd;
|
||||||
|
FChart.LogicalExtent := ext;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPanDragTool.MouseUp(APoint: TPoint);
|
procedure TPanDragTool.MouseUp(APoint: TPoint);
|
||||||
|
Loading…
Reference in New Issue
Block a user