📄 teepolargrid.pas
字号:
tmpX:=360-tmpX;
CalcXYPosition(tmpX,tmpY,XRadius,P[3].x,yy);
CalcXYPosition(tmpX,tmpY,YRadius,xx,P[3].y);
tmpX:=(XValues[ValueIndex]-tmpOff+1)*tmpInc;
if ClockWiseLabels then
tmpX:=360-tmpX;
CalcXYPosition(tmpX,tmpY,XRadius,P[2].x,yy);
CalcXYPosition(tmpX,tmpY,YRadius,xx,P[2].y);
end
else
begin
P[3].X:=CircleXCenter;
P[3].Y:=CircleYCenter;
P[2]:=P[3];
end;
end;
type
TPaletteAccess=class(TCustom3DPaletteSeries);
function TPolarGridSeries.GetCellColor(const Value:TChartValue):TColor;
begin
result:=TPaletteAccess(I3D).GetValueColorValue(Value);
end;
procedure TPolarGridSeries.DrawValue(ValueIndex: Integer);
var tmpColor : TColor;
tmpBlend : TTeeBlend;
P : TFourPoints;
begin
tmpColor:=InternalColor(ValueIndex);
if (tmpColor<>clNone) or (TreatNulls=tnIgnore) then
begin
if tmpColor=clTeeColor then
if (not ColorEachPoint) and (I3D.UseColorRange or I3D.UsePalette) then
tmpColor:=GetCellColor(CellValues[ValueIndex])
else
tmpColor:=GetValueColor(ValueIndex);
CellPolygon(ValueIndex,P);
with ParentChart.Canvas do
begin
AssignVisiblePen(Self.Pen);
Brush.Color:=tmpColor;
if Transparency<>0 then
tmpBlend:=BeginBlending(RectFromPolygon(P,Length(P)),Transparency)
else
tmpBlend:=nil;
if ParentChart.View3D then
PolygonWithZ(P,MiddleZ)
else
Polygon(P);
if Assigned(tmpBlend) then
EndBlending(tmpBlend);
end;
end;
end;
class function TPolarGridSeries.GetEditorClass: String;
begin
result:='TPolarGridEditor';
end;
procedure TPolarGridSeries.DoBeforeDrawChart;
begin
I3D.BeginUpdate;
I3D.Clear;
I3D.AddXYZ(0,CellValues.MinValue,0);
I3D.AddXYZ(0,CellValues.MaxValue,0);
I3D.Color:=Color;
TPaletteAccess(I3D).DoBeforeDrawChart;
I3D.EndUpdate;
AngleIncrement:=360.0/NumSectors;
inherited;
end;
function TPolarGridSeries.CountLegendItems: Integer;
begin
result:=I3D.CountLegendItems;
end;
function TPolarGridSeries.LegendItemColor(LegendIndex: Integer): TColor;
begin
result:=I3D.LegendItemColor(LegendIndex);
end;
function TPolarGridSeries.LegendString(LegendIndex: Integer;
LegendTextStyle: TLegendTextStyle): String;
begin
result:=I3D.LegendString(LegendIndex,LegendTextStyle);
end;
procedure TPolarGridSeries.SetPalette(const Value: TGridColorPalette);
begin
FPalette.Assign(Value);
end;
procedure TPolarGridSeries.SetValues(const Value: TChartValueList);
begin
FValues.Assign(Value);
end;
function TPolarGridSeries.GetCircleLabel(const Angle: Double;
Index: Integer): String;
begin
if (Index>0) and ClockWiseLabels then
Index:=NumSectors-Index;
result:=IntToStr(Index);
end;
Procedure TPolarGridSeries.DrawPolarCircle(HalfWidth,HalfHeight,Z:Integer);
var P : TPoint;
tmp : Double;
t : Integer;
tmpOff : TChartValue;
begin
if Centered then tmpOff:=0.5
else tmpOff:=0;
tmp:=PiDegree*AngleIncrement;
AngleToPos(tmpOff*tmp,HalfWidth,HalfHeight,P.X,P.Y);
With ParentChart.Canvas do
begin
MoveTo3D(P.X,P.Y,Z);
for t:=0 to NumSectors do
begin
AngleToPos((t+tmpOff)*tmp,HalfWidth,HalfHeight,P.X,P.Y);
LineTo3D(P.X,P.Y,Z);
end;
end;
end;
procedure TPolarGridSeries.DoAfterDrawValues;
begin
ParentChart.Canvas.AssignVisiblePen(CirclePen);
DrawPolarCircle(CircleWidth div 2,CircleHeight div 2,EndZ);
inherited;
end;
procedure TPolarGridSeries.SetCentered(const Value: Boolean);
begin
SetBooleanProperty(FCentered,Value);
end;
function TPolarGridSeries.Clicked(x, y: Integer): Integer;
var t : Integer;
P : TFourPoints;
tmp : TPoint;
begin
result:=TeeNoPointClicked;
if Count>0 then
begin
if Assigned(ParentChart) then
ParentChart.Canvas.Calculate2DPosition(X,Y,StartZ);
tmp.X:=X;
tmp.Y:=Y;
for t:=0 to Count-1 do
if not IsNull(t) then
begin
CellPolygon(t,P);
if PointInPolygon(tmp,P) then
begin
result:=t;
break;
end;
end;
end;
end;
{ TSpecialChart }
procedure TSpecialChart.Invalidate;
begin
if Assigned(ILink) then
ILink.Repaint;
end;
{ TGridColorPalette }
function TGridColorPalette.GetEndColor: TColor;
begin
result:=IPalette.EndColor;
end;
function TGridColorPalette.GetLegendEvery: Integer;
begin
result:=IPalette.LegendEvery;
end;
function TGridColorPalette.GetMidColor: TColor;
begin
result:=IPalette.MidColor;
end;
function TGridColorPalette.GetPalette: TCustom3DPalette;
begin
result:=IPalette.Palette;
end;
function TGridColorPalette.GetPaletteMin: Double;
begin
result:=IPalette.PaletteMin;
end;
function TGridColorPalette.GetPaletteStep: Double;
begin
result:=IPalette.PaletteStep;
end;
function TGridColorPalette.GetPaletteSteps: Integer;
begin
result:=IPalette.PaletteSteps;
end;
function TGridColorPalette.GetPaletteStyle: TTeePaletteStyle;
begin
result:=IPalette.PaletteStyle;
end;
function TGridColorPalette.GetStartColor: TColor;
begin
result:=IPalette.StartColor;
end;
function TGridColorPalette.GetUseColorRange: Boolean;
begin
result:=IPalette.UseColorRange;
end;
function TGridColorPalette.GetUsePalette: Boolean;
begin
result:=IPalette.UsePalette;
end;
function TGridColorPalette.GetUsePaletteMin: Boolean;
begin
result:=IPalette.UsePaletteMin;
end;
procedure TGridColorPalette.SetEndColor(const Value: TColor);
begin
IPalette.EndColor:=Value;
end;
procedure TGridColorPalette.SetLegendEvery(const Value: Integer);
begin
IPalette.LegendEvery:=Value;
end;
procedure TGridColorPalette.SetMidColor(const Value: TColor);
begin
IPalette.MidColor:=Value;
end;
procedure TGridColorPalette.SetPalette(const Value: TCustom3DPalette);
begin
IPalette.Palette:=Value;
end;
procedure TGridColorPalette.SetPaletteMin(const Value: Double);
begin
IPalette.PaletteMin:=Value;
end;
procedure TGridColorPalette.SetPaletteStep(const Value: Double);
begin
IPalette.PaletteStep:=Value;
end;
procedure TGridColorPalette.SetPaletteSteps(const Value: Integer);
begin
IPalette.PaletteSteps:=Value;
end;
procedure TGridColorPalette.SetPaletteStyle(const Value: TTeePaletteStyle);
begin
IPalette.PaletteStyle:=Value;
end;
procedure TGridColorPalette.SetStartColor(const Value: TColor);
begin
IPalette.StartColor:=Value;
end;
procedure TGridColorPalette.SetUseColorRange(const Value: Boolean);
begin
IPalette.UseColorRange:=Value;
end;
procedure TGridColorPalette.SetUsePalette(const Value: Boolean);
begin
IPalette.UsePalette:=Value;
end;
procedure TGridColorPalette.SetUsePaletteMin(const Value: Boolean);
begin
IPalette.UsePaletteMin:=Value;
end;
procedure TPolarGridEditor.FormShow(Sender: TObject);
var I3DEditor : TGrid3DSeriesEditor;
begin
inherited;
CBCentered.Top:=CBClose.Top;
CBClose.Hide;
// CBClockWise.Hide;
I3DEditor:=TGrid3DSeriesEditor.Create(nil);
I3DEditor.Panel1.Hide;
if Assigned(Polar) then
begin
AddFormTo(I3DEditor,TabPalette,TPolarGridSeries(Polar).I3D);
CBCentered.Checked:=TPolarGridSeries(Polar).Centered;
end;
end;
procedure TPolarGridEditor.CBCenteredClick(Sender: TObject);
begin
TPolarGridSeries(Polar).Centered:=CBCentered.Checked;
end;
initialization
RegisterTeeSeries(TPolarGridSeries, {$IFNDEF CLR}@{$ENDIF}TeeMsg_PolarGridSeries,
{$IFNDEF CLR}@{$ENDIF}TeeMsg_Gallery3D,1);
RegisterClass(TPolarGridEditor);
finalization
UnRegisterTeeSeries([TPolarGridSeries]);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -