diff --git a/components/tachart/tageometry.pas b/components/tachart/tageometry.pas index 14f9cb77c4..e6b31e1f05 100644 --- a/components/tachart/tageometry.pas +++ b/components/tachart/tageometry.pas @@ -65,6 +65,7 @@ operator *(const A: TPoint; AMultiplier: Integer): TPoint; inline; operator *(const A, B: TPoint): TPoint; inline; operator *(const A, B: TDoublePoint): TDoublePoint; overload; inline; operator /(const A, B: TDoublePoint): TDoublePoint; overload; inline; +operator = (const A, B: TDoublePoint): Boolean; overload; inline; operator <= (const A, B: TDoublePoint): Boolean; overload; inline; operator :=(const APoint: TPoint): TSize; inline; operator :=(const ASize: TSize): TPoint; inline; @@ -429,6 +430,11 @@ begin Result.Y := A.Y / B.Y; end; +operator = (const A, B: TDoublePoint): Boolean; +begin + Result := (A.X = B.X) and (A.Y = B.Y); +end; + operator <= (const A, B: TDoublePoint): Boolean; begin Result := (A.X <= B.X) and (A.Y <= B.Y); diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index df4ef97e36..403f2df9bf 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -136,6 +136,7 @@ type TChartBeforeDrawEvent = procedure ( ASender: TChart; ACanvas: TCanvas; const ARect: TRect; var ADoDefaultDrawing: Boolean) of object; + TChartEvent = procedure (ASender: TChart) of object; TChartPaintEvent = procedure ( ASender: TChart; const ARect: TRect; var ADoDefaultDrawing: Boolean) of object; @@ -176,6 +177,8 @@ type FDrawer: IChartDrawer; FIsZoomed: Boolean; FOffset: TDoublePoint; // Coordinates transformation + FOnExtentChanged: TChartEvent; + FPrevLogicalExtent: TDoubleRect; FProportional: Boolean; FReticuleMode: TReticuleMode; FReticulePos: TPoint; @@ -212,6 +215,7 @@ type procedure SetOnBeforeDrawBackWall(AValue: TChartBeforeDrawEvent); procedure SetOnChartPaint(AValue: TChartPaintEvent); procedure SetOnDrawReticule(AValue: TDrawReticuleEvent); + procedure SetOnExtentChanged(AValue: TChartEvent); procedure SetProportional(AValue: Boolean); procedure SetReticuleMode(const AValue: TReticuleMode); procedure SetReticulePos(const AValue: TPoint); @@ -324,6 +328,7 @@ type read FOnBeforeDrawBackWall write SetOnBeforeDrawBackWall; property OnDrawReticule: TDrawReticuleEvent read FOnDrawReticule write SetOnDrawReticule; + property OnExtentChanged: TChartEvent read FOnExtentChanged write SetOnExtentChanged; published property Align; @@ -362,7 +367,7 @@ var implementation uses - Clipbrd, Dialogs, GraphMath, LCLProc, LResources, Math, Types; + Clipbrd, Dialogs, GraphMath, LCLProc, LResources, Math, TAGeometry, Types; function CompareZPosition(AItem1, AItem2: Pointer): Integer; begin @@ -543,6 +548,8 @@ begin FBuiltinToolset := OnInitBuiltinTools(Self); FActiveToolIndex := -1; + + FPrevLogicalExtent := EmptyExtent; end; procedure TChart.DeleteSeries(ASeries: TBasicChartSeries); @@ -674,6 +681,15 @@ begin for i := 0 to SeriesCount - 1 do Series[i].AfterDraw; + + if + (FPrevLogicalExtent.a <> FLogicalExtent.a) or + (FPrevLogicalExtent.b <> FLogicalExtent.b) + then begin + if Assigned(OnExtentChanged) then + OnExtentChanged(Self); + FPrevLogicalExtent := FLogicalExtent; + end; end; procedure TChart.DrawBackWall(ADrawer: IChartDrawer); @@ -1163,6 +1179,12 @@ begin Invalidate; end; +procedure TChart.SetOnExtentChanged(AValue: TChartEvent); +begin + if FOnExtentChanged = AValue then exit; + FOnExtentChanged := AValue; +end; + procedure TChart.SetProportional(AValue: Boolean); begin if FProportional = AValue then exit;