⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teesmith.pas

📁 Delphi TeeChartPro.6.01的源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      begin
        if (Angle=0) or (Angle=180) then Dec(Y,tmpHeight div 2)
        else
        if (Angle>0) and (Angle<180) then Dec(Y,tmpHeight);
        if (Angle=90) or (Angle=270) then TextAlign:=ta_Center
        else
             if (Angle>90) and (Angle<270) then TextAlign:=ta_Right
                                           else TextAlign:=ta_Left;

        tmpWidth:=TextWidth('0') div 2;

        if Angle=0 then Inc(x,tmpWidth) else
        if Angle=180 then Dec(x,tmpWidth);

        BackMode:=cbmTransparent;
        TextOut3D(X,Y,EndZ,tmpSt);
      end;
    end;
  end;

var X1,X2,X3,X4,
    Y1,Y2,Y3,Y4 : Integer;
    HalfXSize,
    HalfYSize  : Integer;
    InvValue   : Double;
begin
  if Value <> 0 then
  With ParentChart.Canvas do
  begin
    InvValue := 1/Value;
    ZToPos(0,Value,X4,Y4); // Endpos
    if ShowLabel then DrawXCircleLabel(Value,X4,Y4);
    ZToPos(100,Value,X3,Y3); // Startpos
    // ellipse bounding points
    HalfXSize := Round(InvValue*XRadius);
    HalfYSize := Round(InvValue*YRadius);
    X1 := CircleRect.Right - HalfXSize;
    X2 := CircleRect.Right + HalfXSize;
    Y1 := CircleYCenter;
    Y2 := Y1-2*HalfYSize;
    if (not ParentChart.View3D) or ParentChart.View3DOptions.Orthogonal then
       Arc(X1,Y1,X2,Y2,X4,Y4,X3,Y3);
    ZToPos(0,-Value,X4,Y4); // Endpos
    if (not ParentChart.View3D) or ParentChart.View3DOptions.Orthogonal then
       Arc(X1,Y1,X2,Y1+2*HalfYSize,X3,Y3,X4,Y4);
    if ShowLabel then DrawXCircleLabel(-Value,X4,Y4);
  end
  else
  begin { special case then reactance is zero }
    X1 := CircleRect.Left;
    X2 := CircleRect.Right;
    Y1 := CircleYCenter;
    ParentChart.Canvas.LineWithZ(X1,Y1,X2,Y1,MiddleZ);
    if ShowLabel then DrawXCircleLabel(0,X1,Y1);
  end;
end;

Procedure TSmithSeries.AddSampleValues(NumValues:Integer);
var t : Integer;
Begin
  for t:=0 to NumValues-1 do
      AddPoint( 6.5*t/NumValues,(System.Random(t)+3.8)/NumValues);
end;

{ NOTE : the assumption is all points are normalized by Z0 }
function TSmithSeries.AddPoint(Const Resist,React: Double; Const ALabel: String; AColor: TColor): Integer;
begin
  result:=AddXY(Resist,React,ALabel,AColor);
end;

function TSmithSeries.CalcXPos(ValueIndex: Integer): Integer;
var DummyY : Integer;
begin
  ZToPos(XValues.Value[ValueIndex],YValues.Value[ValueIndex],Result,DummyY);
end;

function TSmithSeries.CalcYPos(ValueIndex: Integer): Integer;
var DummyX : Integer;
begin
  ZToPos(XValues.Value[ValueIndex],YValues.Value[ValueIndex],DummyX,Result);
end;

Function TSmithSeries.Clicked(X,Y:Integer):Integer;
var t : Integer;
begin
  if Assigned(ParentChart) then ParentChart.Canvas.Calculate2DPosition(X,Y,StartZ);

  result:=inherited Clicked(X,Y);

  if (result=TeeNoPointClicked) and
     (FirstValueIndex>-1) and (LastValueIndex>-1) then

    if FPointer.Visible then
    for t:=FirstValueIndex to LastValueIndex do
        if (Abs(CalcXPos(t)-X)<FPointer.HorizSize) and
           (Abs(CalcYPos(t)-Y)<FPointer.VertSize) then
        begin
          result:=t;
          break;
        end;
end;

procedure TSmithSeries.DoBeforeDrawValues;

  procedure DrawXCircleGrid;
  const DefaultX: Array [0..11] of Double =
        (0,0.1,0.3,0.5,0.8,1,1.5,2,3,5,7,10);
  var i : Integer;
  begin
    with ParentChart.Canvas do
    begin
      Brush.Style:=bsClear;
      AssignVisiblePen(CCirclePen);
      BackMode:=cbmTransparent;
    end;
    for i := 0 to High(DefaultX) do DrawXCircle(DefaultX[i],MiddleZ,CLabels);
  end;

  procedure DrawRCircleGrid;
  const DefaultR: Array [0..6] of Double =
        (0,0.2,0.5,1,2,5,10);
  var i : Integer;
  begin
    with ParentChart.Canvas do
    begin
      Brush.Style:=bsClear;
      AssignVisiblePen(RCirclePen);
      BackMode:=cbmTransparent;
    end;
    for i := 0 to High(DefaultR) do DrawRCircle(DefaultR[i],MiddleZ,RLabels);
  end;

  procedure DrawAxis;
  begin
    if GetVertAxis.Visible then DrawXCircleGrid;
    if GetHorizAxis.Visible then DrawRCircleGrid;
  end;

  Procedure DrawCircle;
  var tmpX,
      tmpY : Integer;
  begin
    With ParentChart.Canvas do
    Begin
      if not Self.HasBackColor then Brush.Style:=bsClear
      else
      begin
        Brush.Style:=bsSolid;
        Brush.Color:=CalcCircleBackColor;
      end;

      AssignVisiblePen(CirclePen);
      tmpX:=CircleWidth div 2;
      tmpY:=CircleHeight div 2;
      EllipseWithZ( CircleXCenter-tmpX,CircleYCenter-tmpY,
                    CircleXCenter+tmpX,CircleYCenter+tmpY, EndZ);

      if CircleGradient.Visible then
         DrawCircleGradient;
    end;
  end;

var t   : Integer;
    tmp : Integer;
    First : Boolean;
Begin
  First:=False;

  With ParentChart do
  for t:=0 to SeriesCount-1 do
  if (Series[t].Active) and (Series[t] is Self.ClassType) then
  begin
    if Series[t]=Self then
    begin
      if Not First then
      begin
         if CLabels then
         begin
           With ChartRect do
           begin
             tmp:=Canvas.FontHeight+2;
             Inc(Top,tmp);
             Dec(Bottom,tmp);
             tmp:=Canvas.TextWidth('360');
             Inc(Left,tmp);
             Dec(Right,tmp);
           end;
         end;
      end;
      break;
    end;
    First:=True;
  end;

  inherited;

  First:=False;
  With ParentChart do
  for t:=0 to SeriesCount-1 do
  if (Series[t].Active) and (Series[t] is Self.ClassType) then
  begin
    if Series[t]=Self then
    begin
      if not First then
      begin
        DrawCircle;
        if Axes.Visible and Axes.Behind then
           DrawAxis;
      end;
      break;
    end;
    First:=True;
  end;
end;

class function TSmithSeries.GetEditorClass: String;
begin
  result:='TSmithSeriesEdit';
end;

procedure TSmithSeries.SetCirclePen(Const Value: TChartPen);
begin
  FCirclePen.Assign(Value);
end;

function TSmithSeries.GetXCircleLabel(Const Reactance: Double): String;
begin
  Result:=FloatToStr(Reactance)+FImagSymbol;
end;

function TSmithSeries.GetCLabels: Boolean;
begin
  result:=GetVertAxis.Labels;
end;

function TSmithSeries.GetCPen: TChartPen;
begin
  result:=GetVertAxis.Grid;
end;

function TSmithSeries.GetRLabels: Boolean;
begin
  result:=GetHorizAxis.Labels;
end;

function TSmithSeries.GetRPen: TChartPen;
begin
  result:=GetHorizAxis.Grid;
end;

function TSmithSeries.GetCLabelsFont: TTeeFont;
begin
  result:=GetVertAxis.LabelsFont;
end;

function TSmithSeries.GetRLabelsFont: TTeeFont;
begin
  result:=GetHorizAxis.LabelsFont;
end;

procedure TSmithSeries.SetCLabelsFont(const Value: TTeeFont);
begin
  GetVertAxis.LabelsFont:=Value;
end;

procedure TSmithSeries.SetRLabelsFont(const Value: TTeeFont);
begin
  GetHorizAxis.LabelsFont:=Value;
end;

procedure TSmithSeries.SetImagSymbol(const Value: String);
begin
  SetStringProperty(FImagSymbol,Value);
end;

procedure TSmithSeries.PrepareForGallery(IsEnabled: Boolean); { 5.02 }
begin
  inherited;
  With ParentChart do
  begin
    Chart3DPercent:=5;
    RightAxis.Labels:=False;
    TopAxis.Labels:=False;
    With View3DOptions do
    begin
      Orthogonal:=False;
      Elevation:=360;
      Zoom:=90;
    end;
  end;
end;

initialization
  RegisterTeeSeries(TSmithSeries,@TeeMsg_GallerySmith,@TeeMsg_GalleryExtended,2);
finalization
  UnRegisterTeeSeries([TSmithSeries]);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -