unit Visu_Kurvenunit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,kurve;
type
TVisuKurve =
class(TCustomControl)
private
FCanvas :TCanvas;
FKurven :
Array [1..10]
of TKurve;
FZoom :Real;
FRun :Boolean;
FTimer :TTimer;
FTime :Integer;
FKurvenCount :Integer ;
function GetKurve (
Index: Integer): TKurve;
procedure WriteKurve (
Index: Integer; Value:TKurve);
function GetKurvenCount:Integer;
protected
procedure Paint;
override;
procedure TickEvent(Sender: TObject);
procedure SaveKurveToFile(Filename:
String);
public
property Kurve[
Index:integer] :TKurve
read GetKurve
write WriteKurve;
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property VisuRUN :Boolean
read FRUN
write FRUN;
property RefreshIntervall :Integer
read FTime
write FTime;
property KurvenCount :Integer
read GetKurvenCount;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
MiningComponents', [TVisuKurve]);
end;
constructor TVisuKurve.Create(AOwner: TComponent);
var
i: Integer;
begin
inherited Create(AOwner);
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
// Setting default Values
FCanvas.Brush.Color :=clblack;
Width :=220;
Height :=100;
// Create the Timer for painting
FTimer := TTimer.Create(
nil);
FTimer.Interval := 100;
// Konstant
FTimer.OnTimer := TickEvent;
FKurven[1]:=TKurve.Create('
Kurve 1',width);
for i := 2
to 10
do
begin
FKurven[i]:=TKurve.Create('
Kurve ' + inttostr(i),0);
FKurven[i].Aktiv:=false;
end;
end;
destructor TVisuKurve.Destroy;
begin
Ftimer.Free;
FCanvas.Free;
inherited Destroy;
end;
procedure TVisuKurve.Paint;
var Render:TBitmap;
i,count:Integer;
begin
Render:=Tbitmap.Create;
Render.Width:=Width;Render.Height:=Height;
Render.Canvas.Brush.Color:=FCanvas.Brush.Color;
Render.Canvas.Rectangle(0,0,width,height);
// Über alle instanzierten Objekte
for Count:=1
to 10
do
begin
if FKurven[count].aktiv
then
begin
if FKurven[count].XAchse.Aktiv
then
begin
render.Canvas.Pen.Color:=FKurven[count].XAchse.Color;
case FKurven[count].XAchse.Position
of
Atop :
begin
Render.Canvas.MoveTo(5,5);
render.Canvas.LineTo(width-5,5);
end;
Acenter:
begin
Render.Canvas.MoveTo(5,height
div 2);
render.Canvas.LineTo(width-5,height
div 2);
end;
ABottom:
begin
Render.Canvas.MoveTo(5,height -5);
render.Canvas.LineTo(width-5,height -5);
end;
end;
end;
// Werte auslesen, und als Kurve darstellen
render.Canvas.Pen.Color:=FKurven[count].Farbe;
if FKurven[count].XAchse.Position = Acenter
then
begin
Render.Canvas.MoveTo(5,height
div 2);
for i:= 0
to FKurven[count].Size -1
do
begin
Render.Canvas.LineTo(6+i,height
div 2 - FKurven[count].Wert[i] );
end;
end;
if FKurven[count].XAchse.Position = ABottom
then
begin
Render.Canvas.MoveTo(5,height -5);
for i:= 0
to FKurven[count].Size -1
do
begin
Render.Canvas.LineTo(6+i,height-5 - FKurven[count].Wert[i] );
end;
end;
if FKurven[count].XAchse.Position = ATop
then
begin
Render.Canvas.MoveTo(5,5);
for i:= 0
to FKurven[count].Size -1
do
begin
Render.Canvas.LineTo(6+i,5 + FKurven[count].Wert[i] );
end;
end;
end;
end;
Canvas.Draw(0,0,Render);
Render.Free;
end;
function TVisuKurve.GetKurve(
Index: Integer): TKurve;
begin
Result:=(FKurven[
index]);
//with TAxis (FX) do begin
// result.XAchse.Aktiv:=FKurven[index].XAchse.Aktiv; Fehler linker Seite dar nichts zugewiesen werden.
//end;
end;
function TVisuKurve.GetKurvenCount: Integer;
var
I,j: Integer;
begin
j:=0;
for I := 1
to 10
do
begin
if FKurven[i].Aktiv
then inc(j);
end;
result:=j;
end;
procedure TVisuKurve.WriteKurve(
Index: Integer; Value: TKurve);
begin
FKurven[
index].Assign(Value);
end;
procedure TVisuKurve.SaveKurveToFile(Filename:
String);
begin
//
end;
procedure TVisuKurve.TickEvent(Sender: TObject);
begin
Paint;
end;
end.