📄 teepoin3.pas
字号:
var t : Integer;
Begin
for t:=1 to NumValues do
AddXYZ( RandomValue(100), RandomValue(100), RandomValue(100));
end;
Procedure TPoint3DSeries.SetDepthSize(Const Value:Double);
begin
SetDoubleProperty(FDepthSize,Value);
end;
Function TPoint3DSeries.MaxZValue:Double;
begin
result:=ZValues.MaxValue+FDepthSize;
end;
Procedure TPoint3DSeries.DrawMark( ValueIndex:Integer; Const St:String;
APosition:TSeriesMarkPosition);
begin
CalcZPositions(ValueIndex);
if FPointer.Visible then Marks.ZPosition:=MiddleZ
else Marks.ZPosition:=StartZ;
Marks.ApplyArrowLength(APosition);
inherited;
end;
Procedure TPoint3DSeries.Assign(Source:TPersistent);
begin
if Source is TPoint3DSeries then
With TPoint3DSeries(Source) do
begin
Self.Pointer :=FPointer;
Self.FDepthSize:=FDepthSize;
Self.BaseLine :=BaseLine;
end;
inherited;
end;
class Function TPoint3DSeries.GetEditorClass:String;
Begin
result:='TPoint3DSeriesEditor'; { <-- dont translate ! }
end;
Procedure TPoint3DSeries.PrepareForGallery(IsEnabled:Boolean);
begin
inherited;
LinePen.Color:=clNavy;
ParentChart.View3DOptions.Zoom:=60;
end;
Function TPoint3DSeries.Clicked(x,y:Integer):Integer;
var t : Integer;
tmpX : Integer;
tmpY : Integer;
OldX : Integer;
OldY : Integer;
begin
OldX:=X;
OldY:=Y;
result:=inherited Clicked(x,y);
if result=TeeNoPointClicked then
if FPointer.Visible then
for t:=0 to Count-1 do
begin
tmpX:=CalcXPos(t);
tmpY:=CalcYPos(t);
X:=OldX;
Y:=OldY;
if Assigned(ParentChart) then
ParentChart.Canvas.Calculate2DPosition(X,Y,CalcZPos(t));
if (Abs(tmpX-X)<FPointer.HorizSize) and { <-- Canvas.Zoom? }
(Abs(tmpY-Y)<FPointer.VertSize) then
begin
if Assigned(FOnClickPointer) then FOnClickPointer(Self,t,OldX,OldY);
result:=t;
break;
end;
end;
end;
procedure TPoint3DSeries.SetParentChart(const Value: TCustomAxisPanel);
begin
inherited;
if Assigned(Value) then { 5.01 }
FPointer.ParentChart:=Value;
end;
class procedure TPoint3DSeries.CreateSubGallery(
AddSubChart: TChartSubGalleryProc);
begin
inherited;
AddSubChart(TeeMsg_NoPoint);
AddSubChart(TeeMsg_Lines);
AddSubChart(TeeMsg_NoLine);
AddSubChart(TeeMsg_Colors);
AddSubChart(TeeMsg_Marks);
AddSubChart(TeeMsg_Hollow);
AddSubChart(TeeMsg_NoBorder);
if SubGalleryStyles then
begin
AddSubChart(TeeMsg_Point2D);
AddSubChart(TeeMsg_Triangle);
AddSubChart(TeeMsg_Star);
AddSubChart(TeeMsg_Circle);
AddSubChart(TeeMsg_DownTri);
AddSubChart(TeeMsg_Cross);
AddSubChart(TeeMsg_Diamond);
end;
end;
class procedure TPoint3DSeries.SetSubGallery(ASeries: TChartSeries;
Index: Integer);
begin
With TPoint3DSeries(ASeries) do
Case Index of
1: Pointer.Hide;
2: BaseLine.Visible:=True;
3: Pen.Hide;
4: ColorEachPoint:=True;
5: Marks.Visible:=True;
6: Pointer.Brush.Style:=bsClear;
7: Pointer.Pen.Hide;
8: Pointer.Draw3D:=False;
9: Pointer.Style:=psTriangle;
10: Pointer.Style:=psStar;
11: Pointer.Style:=psCircle;
12: Pointer.Style:=psDownTriangle;
13: Pointer.Style:=psCross;
14: Pointer.Style:=psDiamond;
else inherited;
end;
end;
procedure TPoint3DSeries.SetBaseLine(const Value: TChartHiddenPen);
begin
FBaseLine.Assign(Value);
end;
function TPoint3DSeries.GetDepthSize(ValueIndex: Integer): Integer;
begin
result:=ParentChart.DepthAxis.CalcSizeValue(FDepthSize) div 2;
end;
{ TBubble3DSeries }
Constructor TBubble3DSeries.Create(AOwner: TComponent);
begin
inherited;
FRadiusValues:=TChartValueList.Create(Self,TeeMsg_ValuesBubbleRadius); { <-- radius storage }
TPointerAccess(Pointer).AllowChangeSize:=False;
Pointer.Style:=psCircle;
ColorEachPoint:=True;
LinePen.Visible:=False;
end;
function TBubble3DSeries.AddBubble(const AX, AY, AZ, ARadius: Double;
const AXLabel: String; AColor: TColor): Integer;
begin
RadiusValues.TempValue:=ARadius;
result:=AddXYZ(AX,AY,AZ,AXLabel,AColor);
end;
procedure TBubble3DSeries.AddSampleValues(NumValues: Integer;
OnlyMandatory: Boolean);
Var t : Integer;
s : TSeriesRandomBounds;
Begin
s:=RandomBounds(NumValues);
with s do
for t:=1 to NumValues do { some sample values to see something in design mode }
Begin
AddBubble( tmpX, { X }
RandomValue(Round(DifY)), { Y }
RandomValue(200), { Z }
(DifY/15.0)+Round(DifY/(10+RandomValue(15))) { <- Radius }
);
tmpX:=tmpX+StepX;
end;
end;
Function TBubble3DSeries.GetDepthSize(ValueIndex:Integer):Integer;
begin
result:=ParentChart.DepthAxis.CalcSizeValue(RadiusValues.Value[ValueIndex]);
end;
procedure TBubble3DSeries.DrawValue(ValueIndex: Integer);
var tmpSize : Integer;
begin
tmpSize:=GetVertAxis.CalcSizeValue(RadiusValues.Value[ValueIndex]);
TPointerAccess(Pointer).ChangeHorizSize(tmpSize);
TPointerAccess(Pointer).ChangeVertSize(tmpSize);
inherited;
end;
function TBubble3DSeries.IsValidSourceOf(Value: TChartSeries): Boolean;
begin // Only 3D Bubbles can be assigned to 3D Bubbles
result:=Value is TBubble3DSeries;
end;
procedure TBubble3DSeries.SetRadiusValues(Value: TChartValueList);
begin
SetChartValueList(FRadiusValues,Value);
end;
function TBubble3DSeries.ApplyRadius(const Value: Double;
AList: TChartValueList; Increment: Boolean): Double;
var t : Integer;
begin
result:=Value;
for t:=0 to Count-1 do
if Increment then
result:=Math.Max(result,AList.Value[t]+RadiusValues.Value[t])
else
result:=Math.Min(result,AList.Value[t]-RadiusValues.Value[t]);
end;
function TBubble3DSeries.MaxYValue: Double;
begin
result:=ApplyRadius(inherited MaxYValue,YValues,True);
end;
function TBubble3DSeries.MaxZValue: Double;
begin
result:=ApplyRadius(inherited MaxZValue,ZValues,True);
end;
function TBubble3DSeries.MinYValue: Double;
begin
result:=ApplyRadius(inherited MinYValue,YValues,False);
end;
function TBubble3DSeries.MinZValue: Double;
begin
result:=ApplyRadius(inherited MinZValue,ZValues,False);
end;
class Function TBubble3DSeries.SubGalleryStyles:Boolean;
begin
result:=False;
end;
procedure TBubble3DSeries.CalcZPositions(ValueIndex: Integer);
var tmp : Integer;
begin
if Pointer.Draw3D and ParentChart.Canvas.SupportsFullRotation then
inherited
else
begin
StartZ:=CalcZPos(ValueIndex);
tmp:=Math.Max(1,GetDepthSize(ValueIndex));
MiddleZ:=StartZ+tmp;
EndZ:=MiddleZ+tmp;
end;
end;
procedure TBubble3DSeries.PrepareForGallery(IsEnabled: Boolean);
begin
inherited;
Pointer.Gradient.Visible:=True;
end;
initialization
RegisterTeeSeries(TPoint3DSeries, {$IFNDEF CLR}@{$ENDIF}TeeMsg_GalleryPoint3D,
{$IFNDEF CLR}@{$ENDIF}TeeMsg_Gallery3D,1);
RegisterTeeSeries(TBubble3DSeries, {$IFNDEF CLR}@{$ENDIF}TeeMsg_GalleryBubble3D,
{$IFNDEF CLR}@{$ENDIF}TeeMsg_Gallery3D,1);
finalization
UnRegisterTeeSeries([TPoint3DSeries,TBubble3DSeries]);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -