From f4fb26c7869f363e64280d5faaffb5bee5ab8194 Mon Sep 17 00:00:00 2001 From: ask Date: Fri, 21 Jun 2013 13:22:14 +0000 Subject: [PATCH] TAChart: Add TChartPen.EffVisible helper function git-svn-id: trunk@41781 - --- components/tachart/tacustomseries.pas | 2 +- components/tachart/tafuncseries.pas | 22 ++++++++-------------- components/tachart/tagraph.pas | 2 +- components/tachart/talegend.pas | 4 ++-- components/tachart/tatextelements.pas | 3 +-- components/tachart/tatypes.pas | 6 ++++++ 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/components/tachart/tacustomseries.pas b/components/tachart/tacustomseries.pas index 6197ebfb56..38d86d896b 100644 --- a/components/tachart/tacustomseries.pas +++ b/components/tachart/tacustomseries.pas @@ -732,7 +732,7 @@ end; function TChartSeries.GetGraphPoint(AIndex: Integer): TDoublePoint; begin Result.X := GetGraphPointX(AIndex); - Result.Y := GetGraphPointY(AIndex);; + Result.Y := GetGraphPointY(AIndex); if IsRotated then Exchange(Result.X, Result.Y); end; diff --git a/components/tachart/tafuncseries.pas b/components/tachart/tafuncseries.pas index 7c2c71d1b5..a1d2e9bf7b 100644 --- a/components/tachart/tafuncseries.pas +++ b/components/tachart/tafuncseries.pas @@ -424,7 +424,7 @@ var begin inherited Draw(ADrawer, ARect); with FFramePen do - pw := IfThen(Visible and (Style <> psClear), (Width + 1) div 2, 0); + pw := IfThen(EffVisible, (Width + 1) div 2, 0); w := ARect.Right - ARect.Left - 2 * pw; if w <= 0 then exit; for x := ARect.Left + pw to ARect.Right - pw do begin @@ -1013,17 +1013,15 @@ procedure TCubicSplineSeries.Draw(ADrawer: IChartDrawer); end; procedure DrawSpline(ASpline: TSpline); - var - p: TChartPen; begin if ASpline.FIsUnorderedX then begin if not IsUnorderedVisible then exit; - p := BadDataPen; + ADrawer.Pen := BadDataPen; end - else - p := Pen; - if not p.Visible or (p.Style = psClear) then exit; - ADrawer.Pen := p; + else begin + if not Pen.EffVisible then exit; + ADrawer.Pen := Pen; + end; with TDrawFuncHelper.Create(Self, ASpline.FIntervals, @ASpline.Calculate, Step) do try DrawFunction(ADrawer); @@ -1113,16 +1111,12 @@ end; function TCubicSplineSeries.IsFewPointsVisible: Boolean; begin - Result := - (csoDrawFewPoints in Options) and - BadDataPen.Visible and (BadDataPen.Style <> psClear); + Result := (csoDrawFewPoints in Options) and BadDataPen.EffVisible; end; function TCubicSplineSeries.IsUnorderedVisible: Boolean; begin - Result := - (csoDrawUnorderedX in Options) and - BadDataPen.Visible and (BadDataPen.Style <> psClear); + Result := (csoDrawUnorderedX in Options) and BadDataPen.EffVisible; end; procedure TCubicSplineSeries.PrepareCoeffs; diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index baf2587a12..7af5fcf7d0 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -551,7 +551,7 @@ end; function TChart.ClipRectWithoutFrame(AZPosition: TChartDistance): TRect; begin Result := FClipRect; - if (AZPosition > 0) or not Frame.Visible or (Frame.Style = psClear) then exit; + if (AZPosition > 0) or not Frame.EffVisible then exit; Result.Left += (Frame.Width + 1) div 2; Result.Top += (Frame.Width + 1) div 2; Result.Bottom -= Frame.Width div 2; diff --git a/components/tachart/talegend.pas b/components/tachart/talegend.pas index a6241d22f6..d61e45f956 100644 --- a/components/tachart/talegend.pas +++ b/components/tachart/talegend.pas @@ -567,7 +567,7 @@ var FItems[i].Draw(drawer, r); OffsetRect(r, 0, FItemSize.Y + Spacing); end; - if GridHorizontal.Visible and (GridHorizontal.Style <> psClear) then begin + if GridHorizontal.EffVisible then begin drawer.Pen := GridHorizontal; drawer.SetBrushParams(bsClear, clTAColor); for i := 1 to FRowCount - 1 do begin @@ -575,7 +575,7 @@ var drawer.Line(FBounds.Left, y, FBounds.Right, y); end; end; - if GridVertical.Visible and (GridVertical.Style <> psClear) then begin + if GridVertical.EffVisible then begin drawer.Pen := GridVertical; drawer.SetBrushParams(bsClear, clTAColor); for i := 1 to FColCount - 1 do begin diff --git a/components/tachart/tatextelements.pas b/components/tachart/tatextelements.pas index ba11393429..16cb3d7cc4 100644 --- a/components/tachart/tatextelements.pas +++ b/components/tachart/tatextelements.pas @@ -410,8 +410,7 @@ end; function TChartTextElement.IsMarginRequired: Boolean; begin - with GetFrame do - Result := (GetLabelBrush.Style <> bsClear) or (Style <> psClear) and Visible; + Result := (GetLabelBrush.Style <> bsClear) or GetFrame.EffVisible; end; function TChartTextElement.MeasureLabel( diff --git a/components/tachart/tatypes.pas b/components/tachart/tatypes.pas index 7822579e91..4d59e385d6 100644 --- a/components/tachart/tatypes.pas +++ b/components/tachart/tatypes.pas @@ -52,6 +52,7 @@ type constructor Create; override; public procedure Assign(ASource: TPersistent); override; + function EffVisible: Boolean; inline; published property Visible: Boolean read FVisible write SetVisible default true; end; @@ -274,6 +275,11 @@ begin SetPropDefaults(Self, ['Color', 'Style', 'Visible']); end; +function TChartPen.EffVisible: Boolean; +begin + Result := Visible and (Style <> psClear); +end; + procedure TChartPen.SetVisible(AValue: Boolean); begin FVisible := AValue;