home *** CD-ROM | disk | FTP | other *** search
- {*********************************************}
- { TeeChart Delphi Component Library }
- { Contour Series Demo }
- { Copyright (c) 1995-1998 by David Berneda }
- { All rights reserved }
- {*********************************************}
- unit ucontou;
- {$P-}
-
- interface
-
- uses
- WinProcs,WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- TeEngine, TeeSurfa, TeeProcs, Chart, TeeComma, StdCtrls, ExtCtrls;
-
- type
- TContourForm = class(TForm)
- Panel1: TPanel;
- Memo1: TMemo;
- Button1: TButton;
- CheckBox1: TCheckBox;
- TeeCommander1: TTeeCommander;
- Chart1: TChart;
- ContourSeries: TContourSeries;
- CheckBox2: TCheckBox;
- SurfaceSeries: TSurfaceSeries;
- CheckBox3: TCheckBox;
- Panel2: TPanel;
- ScrollBar1: TScrollBar;
- CheckBox4: TCheckBox;
- CheckBox5: TCheckBox;
- procedure CheckBox1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure CheckBox2Click(Sender: TObject);
- procedure ContourSeriesGetLevel(Sender: TContourSeries; LevelIndex: Integer;
- var Value: Double; var Color: TColor);
- procedure CheckBox3Click(Sender: TObject);
- procedure ScrollBar1Change(Sender: TObject);
- procedure CheckBox4Click(Sender: TObject);
- procedure CheckBox5Click(Sender: TObject);
- private
- { Private declarations }
- Function RandomXYZ(x,z:Integer):Double;
- public
- { Public declarations }
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TContourForm.CheckBox1Click(Sender: TObject);
- begin
- With Chart1.View3DOptions do
- if CheckBox1.Checked then { 2D }
- begin
- Rotation:=0;
- Elevation:=270;
- end
- else { 3D }
- begin
- Rotation:=317;
- Elevation:=342;
- end;
-
- { In 2D view (from top), we should hide the Left axis }
- Chart1.LeftAxis.Visible:=not CheckBox1.Checked;
- end;
-
- procedure TContourForm.Button1Click(Sender: TObject);
- begin
- Close;
- end;
-
- Function TContourForm.RandomXYZ(x,z:Integer):Double;
-
- Function ToAngle(Value:Integer):Double;
- begin
- result:=((Value+10)*18.0)*Pi/180.0;
- end;
-
- begin
- result:=(500.0*(Sin(ToAngle(x)) + Sqr(Cos(ToAngle(z)))));
- end;
-
- procedure TContourForm.FormCreate(Sender: TObject);
- var x,z:Integer;
- begin
- { First we add XYZ points to the Contour series... }
- With ContourSeries do
- begin
- Clear; { We add values from 0 to 1000. 21x21 cells = 441 }
- for x:= -10 to 10 do
- for z:= -10 to 10 do
- AddXYZ( x, RandomXYZ(x,z) ,z, '', clTeeColor);
- end;
-
- { Then we specify how many "contour levels" we want }
- ContourSeries.NumLevels:=10;
-
- { We specify the Y levels position to the "middle" }
- With ContourSeries do
- YPosition:=(YValues.MaxValue+YValues.MinValue)/2.0;
-
- ScrollBar1.Position:=1000-Round(ContourSeries.YPosition);
-
- { We can set some Chart properties to improve aspect }
- Chart1.Chart3DPercent:=100;
-
- { We can also use a Surface series... }
- SurfaceSeries.AssignValues(ContourSeries);
- end;
-
- procedure TContourForm.CheckBox2Click(Sender: TObject);
- begin
- ContourSeries.ColorEachPoint:=CheckBox2.Checked;
- end;
-
- procedure TContourForm.ContourSeriesGetLevel(Sender: TContourSeries;
- LevelIndex: Integer; var Value: Double; var Color: TColor);
- begin
- { Here we specify the 10 Level values }
- Case LevelIndex of
- 0: Value:=0;
- 1: Value:=100;
- 2: Value:=200;
- 3: Value:=300;
- 4: Value:=400;
- 5: Value:=500;
- 6: Value:=600;
- 7: Value:=700;
- 8: Value:=800;
- 9: Value:=900;
- end;
- { We can also specify here the exact Color for each level.
- For example:
-
- if Value=500 then Color:=clRed;
- }
- end;
-
- procedure TContourForm.CheckBox3Click(Sender: TObject);
- begin
- SurfaceSeries.Active:=CheckBox3.Checked; { show / hide surface }
- end;
-
- procedure TContourForm.ScrollBar1Change(Sender: TObject);
- begin
- { We don't want each Level to have automatic Y position }
- ContourSeries.YPositionLevel:=False;
-
- { Force the Level Y position }
- ContourSeries.YPosition:=1000-ScrollBar1.Position;
- end;
-
- procedure TContourForm.CheckBox4Click(Sender: TObject);
- begin
- { Turn on / off the automatic Y level positions }
- ContourSeries.YPositionLevel:=CheckBox4.Checked;
- end;
-
- procedure TContourForm.CheckBox5Click(Sender: TObject);
- Var tmp:TBrushStyle;
- begin
- { Show / hide Chart Walls using the Brush style }
- if CheckBox5.Checked then tmp:=bsSolid
- else tmp:=bsClear;
- With Chart1 do
- begin
- LeftWall.Brush.Style :=tmp;
- BottomWall.Brush.Style :=tmp;
- BackWall.Brush.Style :=tmp;
- end;
- end;
-
- end.
-