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

📄 treeflow.pas

📁 TeeChart 7.0 With Source在Delphi 7.0中的安装
💻 PAS
📖 第 1 页 / 共 4 页
字号:
end;

Function TInputOutputShape.SlantSize(Const R:TRect):Integer;
var tmpSize2 : Integer;
    ISlant   : Double;
begin
  ISlant:=FSlant*0.01;
  result:=Round((R.Right-R.Left)*ISlant);
  if result=0 then result:=1;
  tmpSize2:=Round((R.Bottom-R.Top)*ISlant);
  if tmpSize2>result then result:=tmpSize2;
end;

Function TInputOutputShape.ClickedSlantPoint(x,y:Integer):Boolean;
var tmpSize : Integer;
    tmp     : Integer;
    tmpR    : TRect;
begin
  tmpSize:=Tree.Selected.HandleSize;
  tmpR:=Bounds;
  tmp:=SlantSize(tmpR);
  result:=(Abs(X-(tmpR.Left+tmp))<=tmpSize) and (Abs(Y-tmpR.Top)<=tmpSize);
end;

function TInputOutputShape.GetHandleCursor(x, y: Integer): TCursor;
begin
  result:=inherited GetHandleCursor(x,y);
  if (result=crDefault) and ClickedSlantPoint(x,y) then
     result:=crSizeWE;
end;

Function TInputOutputShape.GetShapePoints(Const R:TRect; Var P:TShapePoints):Integer;
var tmpSize : Integer;
begin
  result:=4;  { <-- has four points }

  { calculate horizontal slant size }
  tmpSize:=SlantSize(R);

  { return points }
  P[0]:=TeePoint(R.Left,R.Bottom);
  P[1]:=TeePoint(R.Left+tmpSize,R.Top);
  P[2]:=TeePoint(R.Right,R.Top);
  P[3]:=TeePoint(R.Right-tmpSize,R.Bottom);
end;

procedure TInputOutputShape.SetSlant(const Value: Double);
begin
  SetDoubleProperty(FSlant,Value);
end;

procedure TInputOutputShape.DrawHandles;
var tmpR : TRect;
begin
  inherited;
  tmpR:=Bounds;
  TTreeAccess(Tree).DrawHandle(Self,rcCustom,tmpR.Left+SlantSize(tmpR),tmpR.Top);
end;

function TInputOutputShape.GetResizingHandle(x, y: Integer): TTreeShapeHandle;
begin
  result:=inherited GetResizingHandle(x,y);
  if (result=rcNone) and ClickedSlantPoint(x,y) then
     result:=rcCustom;
end;

procedure TInputOutputShape.Resize(ACorner: TTreeShapeHandle; DeltaX,
  DeltaY: Integer);
var tmp : Double;
begin
  if ACorner=rcCustom then
  begin
    if DeltaX<>0 then
    begin
      tmp:=SlantSize(Bounds)+DeltaX;
      FSlant:=100.0*(tmp/Width);
      Repaint;
    end;
  end
  else inherited;
end;

{ ManualOperation }
Constructor TManualOperationShape.Create(AOwner:TComponent);
begin
  inherited;
  Brush.Color:=clAqua;
end;

Function TManualOperationShape.GetShapePoints(Const R:TRect; Var P:TShapePoints):Integer;
var tmpSize : Integer;
    tmpSize2: Integer;
begin
  if Style=tssCustom then
  begin
    result:=4;  { <-- has four points }

    { calculate horizontal slant size }
    tmpSize:=(R.Right-R.Left) div 8;
    if tmpSize=0 then tmpSize:=1;
    tmpSize2:=(R.Bottom-R.Top) div 8;
    if tmpSize2>tmpSize then tmpSize:=tmpSize2;

    { return points }
    P[0]:=TeePoint(R.Left+tmpSize,R.Bottom);
    P[1]:=R.TopLeft;
    P[2]:=TeePoint(R.Right,R.Top);
    P[3]:=TeePoint(R.Right-tmpSize,R.Bottom);
  end
  else result:=inherited GetShapePoints(R,P);
end;

{ Select }
Constructor TSelectShape.Create(AOwner:TComponent);
begin
  inherited;
  Brush.Color:=clLime;
end;

Function TSelectShape.GetShapePoints(Const R:TRect; Var P:TShapePoints):Integer;
var tmpSize  : Integer;
    tmpSize2 : Integer;
    tmpYC    : Integer;
begin
  result:=6;  { <-- has four points }

  { calculate vertical center }
  tmpYC:=(R.Top+R.Bottom) div 2;

  { calculate horizontal slant size }
  tmpSize:=(R.Right-R.Left) div 8;
  if tmpSize=0 then tmpSize:=1;
  tmpSize2:=(R.Bottom-R.Top) div 8;
  if tmpSize2>tmpSize then tmpSize:=tmpSize2;

  { return points }
  P[0]:=TeePoint(R.Left,tmpYC);
  P[1]:=TeePoint(R.Left+tmpSize,R.Top);
  P[2]:=TeePoint(R.Right-tmpSize,R.Top);
  P[3]:=TeePoint(R.Right,tmpYC);
  P[4]:=TeePoint(P[2].X,R.Bottom);
  P[5]:=TeePoint(P[1].X,R.Bottom);
end;

Procedure DrawCurves(Const R:TRect; Yc,AStart,ASteps:Integer;
                     Var P:TShapePoints; DoForward:Boolean);
var xc      : Integer;
    XRadius : Integer;
    YRadius : Integer;

  Procedure AddPoint(AIndex:Integer; Angle:Double);
  begin
    P[AIndex]:=TeePoint(xc-Round(XRadius*Sin(Angle)),yc-Round(YRadius*Cos(Angle)));
  end;

Var PiStep : Double;
    tmp    : Double;
    t      : Integer;
begin
  XRadius:=(R.Right-R.Left) div 4;
  YRadius:=(R.Bottom-R.Top) div 4;
  PiStep:=2.0*Pi/3.0/(ASteps-1);

  xc:=R.Right-XRadius;
  tmp:=Pi/3.0;
  for t:=1 to ASteps do
  if DoForward then AddPoint(AStart+t,PiStep*t-tmp)
               else AddPoint(2*ASteps+AStart+1-t,PiStep*t-tmp);

  xc:=R.Left+XRadius;
  tmp:=1.5*Pi;
  for t:=1 to ASteps do
  if DoForward then AddPoint(2*ASteps+AStart+1-t,PiStep*t-tmp)
               else AddPoint(AStart+t,PiStep*t-tmp)
end;

{ TDocumentShape }
constructor TDocumentShape.Create(AOwner: TComponent);
begin
  inherited;
  Brush.Color:=$00FF80FF;
end;

function TDocumentShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
Const Steps=8;
var tmp : Integer;
begin
  result:=3+2*Steps;
  With R do
  begin
    P[0]:=TopLeft;
    P[1]:=TeePoint(Right,Top);
    tmp:=(Bottom-Top) div 8;
    P[2]:=TeePoint(Right,Bottom-Round(tmp+2.0*tmp/3.0));
    DrawCurves(R,Bottom-tmp,2,Steps,P,True);
    P[2+2*Steps]:=TeePoint(Left,Bottom-tmp);
  end;
end;


{ TPunchCardShape }
constructor TPunchCardShape.Create(AOwner: TComponent);
begin
  inherited;
  Brush.Color:=$FF8000;
  FPercentHoriz:=25;
  FPercentVert:=25;
end;

function TPunchCardShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
begin
  result:=5;
  With R do
  begin
    P[0]:=TeePoint(Right,Top);
    P[1]:=BottomRight;
    P[2]:=TeePoint(Left,Bottom);
    P[3]:=TeePoint(Left,Top+Round((Bottom-Top)*FPercentVert*0.01));
    P[4]:=TeePoint(Left+Round((Right-Left)*FPercentHoriz*0.01),Top);
  end;
end;

procedure TPunchCardShape.SetPercentHoriz(const Value: Integer);
begin
  SetIntegerProperty(FPercentHoriz,Value);
end;

procedure TPunchCardShape.SetPercentVert(const Value: Integer);
begin
  SetIntegerProperty(FPercentVert,Value);
end;

{ TPunchTapeShape }
constructor TPunchTapeShape.Create(AOwner: TComponent);
begin
  inherited;
  Brush.Color:=$808080;
end;

function TPunchTapeShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
Const Steps=8;
var tmp : Integer;
begin
  result:=3+4*Steps;
  With R do
  begin
    tmp:=(Bottom-Top) div 8;
    P[0]:=TeePoint(Right,Bottom-Round(tmp+2.0*tmp/3.0));
    DrawCurves(R,Bottom-tmp,0,Steps,P,True);
    P[2*Steps]:=TeePoint(Left,Bottom-tmp);
    P[1+2*Steps]:=TeePoint(Left,Top+tmp);
    DrawCurves(R,Top+tmp,1+2*Steps,Steps,P,False);
    P[2+4*Steps]:=TeePoint(Right,Top+tmp-Round(2.0*tmp/3.0));
  end;
end;

{ TDelayShape }
constructor TDelayShape.Create(AOwner: TComponent);
begin
  inherited;
  Brush.Color:=$C5FCE9;
end;

function TDelayShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
var Angle   : Double;
    xc      : Integer;
    yc      : Integer;
    XRadius : Integer;
    YRadius : Integer;
    t       : Integer;
    tmpOffset : Double;
    tmpStep : Double;
begin
  result:=33;
  With R do
  begin
    P[0]:=TopLeft;
    xc:=Left;
    yc:=(Bottom+Top) div 2;
    XRadius:=Right-Left;
    YRadius:=(Bottom-Top) div 2;
  end;
  tmpOffset:=1.5*pi;
  tmpStep:=Pi/32.0;
  for t:=1 to 32 do
  begin
    Angle:=tmpOffset+t*tmpStep;
    P[t].X:=xc+Round(XRadius*Cos(Angle));
    P[t].Y:=yc+Round(YRadius*Sin(Angle));
  end;
end;

{ TManualInputShape }
constructor TManualInputShape.Create(AOwner: TComponent);
begin
  inherited;
  Brush.Color:=$BEE1FC;
end;

function TManualInputShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
begin
  result:=4;
  With R do
  begin
    P[0]:=TeePoint(Left,(Top+Bottom) div 2);
    P[1]:=TeePoint(Right,Top);
    P[2]:=BottomRight;
    P[3]:=TeePoint(Left,Bottom);
  end;
end;

{ TFlowChartCircleShape }
constructor TFlowChartCircleShape.Create(AOwner: TComponent);
begin
  inherited;
  Style:=tssCircle;
end;

{ TAndShape }
procedure TAndShape.DrawShapeCanvas(ACanvas: TCanvas3D; const R: TRect);
Var xc      : Integer;
    yc      : Integer;
    XRadius : Integer;
    YRadius : Integer;

  Procedure DoLine(Const Angle:Extended);
  Var tmpSin : Extended;
      tmpCos : Extended;
  begin
    SinCos(Angle,tmpSin,tmpCos);
    ACanvas.MoveTo3D(xc+Round(XRadius*tmpCos),yc+Round(YRadius*tmpSin),TeeTreeZ);
    SinCos(Pi+Angle,tmpSin,tmpCos);
    ACanvas.LineTo3D(xc+Round(XRadius*tmpCos),yc+Round(YRadius*tmpSin),TeeTreeZ);
  end;

begin
  inherited;
  With R do
  begin
    xc:=(Left+Right) div 2;
    XRadius:=(Right-Left) div 2;
    yc:=(Top+Bottom) div 2;
    YRadius:=(Bottom-Top) div 2;
  end;
  DoLine(0.25*Pi);
  DoLine((0.5*Pi)+(0.25*Pi));
end;

{ TOrShape }
procedure TOrShape.DrawShapeCanvas(ACanvas: TCanvas3D; const R: TRect);
begin
  inherited;
  With R do
  begin
    ACanvas.HorizLine3D(Left,Right,(Top+Bottom) div 2,TeeTreeZ);
    ACanvas.VertLine3D((Left+Right) div 2,Top,Bottom,TeeTreeZ);
  end;
end;

{ TOnlineStorageShape }
function TOnlineStorageShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
var xc      : Integer;
    yc      : Integer;
    XRadius : Integer;
    YRadius : Integer;
    tmpOffset : Double;
    tmpStep : Double;

  Procedure DrawCurve(AOffset,AFactor:Integer);
  Var t     : Integer;
      Angle : Double;
  begin
    for t:=1 to 16 do
    begin
      Angle:=tmpOffset+t*tmpStep;
      P[AOffset+t].X:=xc-Round(XRadius*Cos(Angle));
      P[AOffset+t].Y:=yc+AFactor*Round(YRadius*Sin(Angle));
    end;
  end;

begin
  result:=33;
  With R do
  begin
    P[0]:=TeePoint(Right,Top);
    xc:=Right;
    yc:=(Bottom+Top) div 2;
    XRadius:=(Right-Left) div 4;
    YRadius:=(Bottom-Top) div 2;
  end;
  tmpOffset:=1.5*pi;
  tmpStep:=Pi/16.0;
  DrawCurve(0,1);
  xc:=R.Left+XRadius;
  DrawCurve(16,-1);
end;

{ TMagneticTapeShape }
procedure TMagneticTapeShape.DrawShapeCanvas(ACanvas: TCanvas3D; const R: TRect);
begin
  inherited;
  With R do
  begin
    ACanvas.MoveTo3D((Left+Right) div 2,Bottom,TeeTreeZ);
    ACanvas.LineTo3D(Right,Bottom,TeeTreeZ);
  end;
end;

{ TPentagonShape }
constructor TPentagonShape.Create(AOwner: TComponent);
begin
  inherited;
  AngleOffset:=18;
end;

function TPentagonShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
begin
  result:=GetPolygonPoints(5,R,P);
end;

{ THexagonShape }
function THexagonShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
begin
  result:=GetPolygonPoints(6,R,P);
end;

{ TOctagonShape }
constructor TOctagonShape.Create(AOwner: TComponent);
begin
  inherited;
  AngleOffset:=22.5;
end;

function TOctagonShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
begin
  result:=GetPolygonPoints(8,R,P);
end;

{ TCrossShape }
constructor TCrossShape.Create(AOwner: TComponent);
begin
  inherited;
  FPercentHoriz:=25;
  FPercentVert:=25;
end;

function TCrossShape.GetShapePoints(const R: TRect;
  var P: TShapePoints): Integer;
var tmpX : Integer;
    tmpY : Integer;
begin
  result:=12;
  With R do
  begin
    tmpX:=Round((Right-Left)*FPercentHoriz*0.01);
    tmpY:=Round((Bottom-Top)*FPercentVert*0.01);
    P[0] :=TeePoint(Left+tmpX,Top);
    P[1] :=TeePoint(Right-tmpX,Top);
    P[2] :=TeePoint(Right-tmpX,Top+tmpY);
    P[3] :=TeePoint(Right,Top+tmpY);
    P[4] :=TeePoint(Right,Bottom-tmpY);
    P[5] :=TeePoint(Right-tmpX,Bottom-tmpY);
    P[6] :=TeePoint(Right-tmpX,Bottom);
    P[7] :=TeePoint(Left+tmpX,Bottom);
    P[8] :=TeePoint(Left+tmpX,Bottom-tmpY);
    P[9] :=TeePoint(Left,Bottom-tmpY);
    P[10]:=TeePoint(Left,Top+tmpY);
    P[11]:=TeePoint(Left+tmpX,Top+tmpY);
  end;
end;

procedure TCrossShape.SetHoriz(const Value: Integer);
begin
  SetIntegerProperty(FPercentHoriz,Value);
end;

procedure TCrossShape.SetVert(const Value: Integer);
begin
  SetIntegerProperty(FPercentVert,Value);
end;

{ TTriangleRectShape }
constructor TTriangleRectShape.Create(AOwner: TComponent);
begin

⌨️ 快捷键说明

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