home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / TeeChartPro / TeeChart5Delphi5Eval.exe / %MAINDIR% / Examples / Features / Surface_Irregular.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-09-10  |  2.7 KB  |  118 lines

  1. {$I TeeDefs.inc}
  2. unit Surface_Irregular;
  3.  
  4. { The SurfaceSeries can now accept XYZ floating point values.
  5.  
  6.   The "grid" of cells defined by X and Z dimensions is still
  7.   used, but now the X and Z values do not need to be rounded
  8.   integers.
  9.  
  10.   To distinguish between a normal integer "grid" and this new
  11.   code, the following property must be set to TRUE:
  12.  
  13.     SurfaceSeries1.IrregularGrid:=True;
  14.  
  15.     This must be done before adding points to the series.
  16.  
  17. }
  18. interface
  19.  
  20. uses
  21.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  22.   Base, ExtCtrls, TeeProcs, TeEngine, Chart, StdCtrls, TeeSurfa, TeeTools;
  23.  
  24. type
  25.   TSurfaceFloat = class(TBaseForm)
  26.     CheckBox1: TCheckBox;
  27.     Series1: TSurfaceSeries;
  28.     CheckBox2: TCheckBox;
  29.     ChartTool1: TRotateTool;
  30.     procedure FormCreate(Sender: TObject);
  31.     procedure CheckBox1Click(Sender: TObject);
  32.     procedure CheckBox2Click(Sender: TObject);
  33.   private
  34.     { Private declarations }
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39. implementation
  40.  
  41. {$R *.DFM}
  42.  
  43. procedure TSurfaceFloat.FormCreate(Sender: TObject);
  44. Var x,z : Integer;
  45.     y   : Double;
  46.     xval,
  47.     zval : Array[0..9] of Double;
  48. begin
  49.   inherited;
  50.  
  51.   Series1.IrregularGrid:=True;   { <---------- VERY IMPORTANT !!! }
  52.  
  53.   Series1.GetVertAxis.SetMinMax(-2,2);  { axis scale for Y values }
  54.  
  55.   { Arrays of X and Z values with sample points... }
  56.   { The values have floating point decimals and define
  57.     an irregular grid }
  58.  
  59.   xval[0]:=0.1;
  60.   xval[1]:=0.2;
  61.   xval[2]:=0.3;
  62.   xval[3]:=0.5;
  63.   xval[4]:=0.8;
  64.   xval[5]:=1.1;
  65.   xval[6]:=1.5;
  66.   xval[7]:=2.0;
  67.   xval[8]:=2.2;
  68.   xval[9]:=3.0;
  69.  
  70.   zval[0]:=0.5;
  71.   zval[1]:=0.6;
  72.   zval[2]:=0.7;
  73.   zval[3]:=0.75;
  74.   zval[4]:=0.8;
  75.   zval[5]:=1.1;
  76.   zval[6]:=1.5;
  77.   zval[7]:=2.0;
  78.   zval[8]:=2.2;
  79.   zval[9]:=5.6;
  80.  
  81.   { Now add all "Y" points... }
  82.   Series1.Clear;
  83.  
  84.   { An irregular grid of 10 x 10 cells }
  85.   Series1.NumXValues:=10;
  86.   Series1.NumZValues:=10;
  87.  
  88.   for x:=0 to 9 do  { = 10 rows }
  89.     for z:=0 to 9 do  { = 10 columns }
  90.     begin
  91.       y:=Sin(z*Pi/10.0)*Cos(x*Pi/5.0);  { example Y value }
  92.       Series1.AddXYZ(Xval[x],Y,Zval[z] {$IFNDEF D4},'',clTeeColor{$ENDIF});
  93.     end;
  94. end;
  95.  
  96. procedure TSurfaceFloat.CheckBox1Click(Sender: TObject);
  97. begin
  98.   Series1.IrregularGrid:=CheckBox1.Checked
  99. end;
  100.  
  101. procedure TSurfaceFloat.CheckBox2Click(Sender: TObject);
  102. begin
  103.   if CheckBox2.Checked then
  104.   begin
  105.     Chart1.View3DOptions.Elevation:=270;
  106.     Chart1.View3DOptions.Rotation:=360;
  107.   end
  108.   else
  109.   begin
  110.     Chart1.View3DOptions.Elevation:=345;
  111.     Chart1.View3DOptions.Rotation:=345;
  112.   end;
  113. end;
  114.  
  115. initialization
  116.   RegisterClass(TSurfaceFloat);
  117. end.
  118.