跪求各位控件开发大师!!!(200分)

  • 主题发起人 主题发起人 gutnc
  • 开始时间 开始时间
G

gutnc

Unregistered / Unconfirmed
GUEST, unregistred user!
这个控件在程序运行时根据不同的数据能够显示两条曲线
(主要是根据不同的采集数据动态的画出),
就像一个采集版所采集的数据以实时波形显示一样,
他们各有个的刻度值,波峰值和波谷值

真诚的希望大师们帮一下忙!
分不够 在加!
希望能够提供qq号码,好向给你请教!!
 
我可以帮你,白天时间不多。你留一个QQ,我可以加你
 
我想你说的是不是chart?
 
给你一个简单的用PaintBox实现的例子:
//-----------------------------------------------------------------------
TMyCurve = class
private
Fv1: array[0..100] of integer;
Fv2: array[0..100] of integer;
FMaxValue: integer;
FEnabled: boolean;
FPaintBox: TPaintBox;
procedure SetPaintBox(value: TPaintBox);
procedure PaintBoxPaint(Sender: TObject);

procedure SetV1(i: integer; value: integer);
function GetV1(i: integer): integer;
procedure SetV2(i: integer; value: integer);
function GetV2(i: integer): integer;

procedure DrawCoordinate;
procedure DrawCurve;
public
procedure Repaint;

property PaintBox: TPaintBox read FPaintBox write SetPaintBox;
property Enabled: boolean read FEnabled write FEnabled;
property MaxValue: integer read FMaxValue write FMaxValue;
property V1[i:integer]: integer read GetV1 write SetV1;
property V2[i:integer]: integer read GetV2 write SetV2;
end;

procedure TMyCurve.SetPaintBox(value: TPaintBox);
begin
if FPaintBox <> value then
begin
FPaintBox := value;
if FPaintBox <> nil then
begin
with FPaintBox do
OnPaint := PaintBoxPaint;
end;
end;
end;

procedure TMyCurve.Repaint;
begin
PaintBoxPaint(nil);
end;

procedure TMyCurve.PaintBoxPaint(Sender: TObject);
begin
if (FPaintBox = nil) or (FEnabled = false) then
exit;

with FPaintBox.Canvas do
begin
with Brush do
begin
Color := clYellow;
Style := bsSolid;
end;
FillRect(Bounds(0,0,FPaintBox.Width,FPaintBox.Height));
end;

DrawCoordinate;

DrawCurve;
end;

procedure TMyCurve.DrawCoordinate;
var
dx, dy: real;
i: integer;
begin
with FPaintBox.Canvas do
begin
with Pen do
begin
Color := clNavy;
Style := psDot;
Width := 1;
end;
Brush.Style := bsClear;

dx := (FPaintBox.Width - 20) / 10;
dy := (FPaintBox.Height - 20) / 10;

for i := 0 to 10 do
begin
MoveTo(10 + Round(i * dx), 10);
LineTo(10 + Round(i * dx), FPaintBox.Height - 10);

MoveTo(10, 10 + Round(i * dy));
LineTo(FPaintBox.Width - 10, Round(10 + i * dy));
end;
end;
end;

procedure TMyCurve.DrawCurve;
var
dx, dy: real;
i: integer;
begin
if FMaxValue < 2 then
exit;

dx := (FPaintBox.Width - 20) / 100;
dy := (FPaintBox.Height - 20) / FMaxValue; // MaxValue = 500

with FPaintBox.Canvas do
begin
with Pen do
begin
Color := clRed; //
Style := psSolid;
Width := 2;
end;
Brush.Style := bsClear;

// 第一条曲线
MoveTo(10, Round(FPaintBox.Height - 10 - FV1[0] * dy));
for i := 1 to 99 do
begin
LineTo(10 + Round(i * dx), Round(FPaintBox.Height - 10 - FV1 * dy));
end;

// 第二条曲线
Pen.Color := clLime;
MoveTo(10, Round(FPaintBox.Height - 10 - FV2[0] * dy));
for i := 1 to 99 do
begin
LineTo(10 + Round(i * dx), Round(FPaintBox.Height - 10 - FV2 * dy));
end;
end;
end;

procedure TMyCurve.SetV1(i: integer; value: integer);
begin
if (i >= 0) and (i < 100) then
begin
FV1 := value;
Repaint;
end;
end;

function TMyCurve.GetV1(i: integer): integer;
begin
if (i >= 0) and (i < 100) then
Result := FV1
else
Result := 0;
end;

procedure TMyCurve.SetV2(i: integer; value: integer);
begin
if (i >= 0) and (i < 100) then
begin
FV2 := value;
Repaint;
end;
end;

function TMyCurve.GetV2(i: integer): integer;
begin
if (i >= 0) and (i < 100) then
Result := FV2
else
Result := 0;
end;

//-------------------------------------------------------------------------
应用
procedure TForm1.FormCreate(Sender: TObject);
begin
FCurve := TMyCurve.Create;
with FCurve do
begin
PaintBox := PaintBox1;
Enabled := true;
end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
FCurve.Destroy;
end;

// 画正弦曲线
procedure TForm1.Button2Click(Sender: TObject);
var
i, x1, x2: integer;
begin
Randomize;
x1 := Random(50);
x2 := Random(50);
with FCurve do
begin
MaxValue := 500;
Enabled := false;

for i := 0 to 99 do
begin
V1 := Round(sin((i + x1)/ 100 * 2 * Pi) * 250 + 250);
V2 := Round(sin((i + x2)/ 100 * 2 * Pi) * 200 + 250);
end;

Enabled := true;
Repaint;
end;
end;

// 动态性能图
procedure TForm1.Button3Click(Sender: TObject);
begin
if Timer1.Enabled then
begin
Timer1.Enabled := false;
Timer2.Enabled := false
end else
begin
Randomize;
FCurve.MaxValue := 500;
Timer1.Enabled := true;
Timer2.Enabled := true;
end;
end;

// 更新曲线1,时间间隔1000ms
procedure TForm1.Timer1Timer(Sender: TObject);
var
i: integer;
begin
with FCurve do
begin
MaxValue := 500;
Enabled := false;

for i := 1 to 99 do
V1[i - 1] := V1;

V1[99] := Random(500);
Enabled := true;
Repaint;
end;
end;

// 更新曲线2, 时间间隔500ms
procedure TForm1.Timer2Timer(Sender: TObject);
var
i: integer;
begin
with FCurve do
begin
MaxValue := 500;
Enabled := false;

for i := 1 to 99 do
V2[i - 1] := V2;

V2[99] := Random(500);
Enabled := true;
Repaint;
end;
end;
 
TeeChart下载
http://www.51delphi.com/delphi/soft,绝对可以实现你的功能

 
以上几位仁兄可能还不太明白我的意思!
我需要的控件是:这个控件上能够实现两条曲线的显示,
而画这两条曲线的数据来源假定是通过数据采集板得来的,这些数据都是延续的
为此,可能需要定义一个二维数组,用以保通过采集版采集而来的数据存着两条波形曲线上的数据,然后再通过这个数组的数据实时的,动态的画出这两条曲线
我的qq是:25175215

 
你说的功能用TeeChart完全可以实现,TeeChart的特点就是显示实时数据。
(我以为你要学习自己做画曲线的组件呢)
 
后退
顶部