home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / EXTENDED / UPOLAR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  3.4 KB  |  127 lines

  1. {*********************************************}
  2. { TeeChart Delphi Component Library           }
  3. { Polar Series Type Demo                      }
  4. { Copyright (c) 1995-1996 by David Berneda    }
  5. { All rights reserved                         }
  6. {*********************************************}
  7. unit UPolar;
  8.  
  9. interface
  10.  
  11. uses
  12.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  13.   Forms, Dialogs,TeePolar, ExtCtrls, Teengine, Chart, Series, StdCtrls,
  14.   Buttons, TeeProcs, TeeComma;
  15.  
  16. type
  17.   TPolarForm = class(TForm)
  18.     Chart1: TChart;
  19.     PolarSeries1: TPolarSeries;
  20.     PolarSeries2: TPolarSeries;
  21.     Panel1: TPanel;
  22.     BitBtn2: TBitBtn;
  23.     CheckBox1: TCheckBox;
  24.     Timer1: TTimer;
  25.     CheckBox2: TCheckBox;
  26.     TeeCommander1: TTeeCommander;
  27.     CheckBox3: TCheckBox;
  28.     procedure FormCreate(Sender: TObject);
  29.     procedure BitBtn1Click(Sender: TObject);
  30.     procedure CheckBox1Click(Sender: TObject);
  31.     procedure Timer1Timer(Sender: TObject);
  32.     procedure CheckBox2Click(Sender: TObject);
  33.     procedure PolarSeries1Click(Sender: TChartSeries; ValueIndex: Integer;
  34.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  35.     procedure Chart1AfterDraw(Sender: TObject);
  36.     procedure CheckBox3Click(Sender: TObject);
  37.   private
  38.     { Private declarations }
  39.   public
  40.     { Public declarations }
  41.   end;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}
  46. Uses EditChar,PolarEdi;
  47.  
  48. procedure TPolarForm.FormCreate(Sender: TObject);
  49. begin
  50.   PolarSeries1.FillSampleValues(20);
  51.   PolarSeries1.Cursor:=crTeeHand;
  52.  
  53.   PolarSeries2.FillSampleValues(25);
  54.   PolarSeries2.Cursor:=crTeeHand;
  55. end;
  56.  
  57. procedure TPolarForm.BitBtn1Click(Sender: TObject);
  58. begin
  59.   EditChart(Self,Chart1);
  60. end;
  61.  
  62. procedure TPolarForm.CheckBox1Click(Sender: TObject);
  63. begin
  64.   Timer1.Enabled:=CheckBox1.Checked;
  65. end;
  66.  
  67. procedure TPolarForm.Timer1Timer(Sender: TObject);
  68. begin
  69.   Timer1.Enabled:=False;
  70.  
  71.   { Move Points !!! }
  72.   PolarSeries1.Rotate(5);
  73.   PolarSeries2.Rotate(355);
  74.  
  75.   {  Change Grid Lines and Horizontal Axis Labels }
  76.   With Chart1.BottomAxis do
  77.   if (Increment=0) or (Increment>=90) then
  78.      Increment:=1
  79.   else
  80.      Increment:=Increment+2;
  81.  
  82.   {  Change Grid RINGS and Vertical Axis Labels }
  83.   With Chart1.LeftAxis do
  84.   if (Increment=0) or (Increment>=((Maximum-Minimum)/2.0)) then
  85.      Increment:=((Maximum-Minimum)/20.0)
  86.   else
  87.      Increment:=2.0*Increment;
  88.  
  89.   Timer1.Enabled:=True;
  90. end;
  91.  
  92. procedure TPolarForm.CheckBox2Click(Sender: TObject);
  93. begin
  94.   PolarSeries1.Circled:=CheckBox2.Checked;
  95. end;
  96.  
  97. procedure TPolarForm.PolarSeries1Click(Sender: TChartSeries;
  98.   ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X,
  99.   Y: Integer);
  100. begin
  101.   ShowMessage('You clicked: '+Sender.Name+#13+
  102.               'Angle : '+FloatToStr(Sender.XValue[ValueIndex])+#13+
  103.               'Radius: '+FloatToStr(Sender.YValue[ValueIndex]));
  104. end;
  105.  
  106. procedure TPolarForm.Chart1AfterDraw(Sender: TObject);
  107. begin
  108.   Chart1.Canvas.Brush.Style:=bsClear;  { <-- IMPORTANT (Try without) !!! }
  109.  
  110.   Chart1.Canvas.Pen.Width:= 2;
  111.  
  112.   { Draw a blue ring passing over the 3rd PolarSeries1 Point }
  113.   Chart1.Canvas.Pen.Color:=clBlue;
  114.   With PolarSeries1 do DrawRing( YValue[2], EndZ );
  115.  
  116.   { Draw a green ring passing over the 6th PolarSeries2 Point }
  117.   Chart1.Canvas.Pen.Color:=clGreen;
  118.   With PolarSeries2 do DrawRing( YValue[5], EndZ );
  119. end;
  120.  
  121. procedure TPolarForm.CheckBox3Click(Sender: TObject);
  122. begin
  123.   Chart1.View3D:=CheckBox3.Checked;
  124. end;
  125.  
  126. end.
  127.