void __fastcall TFormDistr::DrawDistr(TObject *Sender)
{
try
{
b = edit_B->Text.ToDouble();//b = (*edit_B).Text.ToDouble();
c = edit_C->Text.ToDouble();
d = edit_D->Text.ToDouble();
}
catch(...)
{
Application->MessageBox("请重新输入数字!","输入错误",MB_ICONERROR);
return;
} TCanvas *canvas;
DrawGrid();
canvas = Image1->Canvas;
(canvas->Pen)->Style = psSolid; // prepare to Draw gram
canvas->Pen->Color = clGreen;
canvas->MoveTo(0,Image1->Height/5); int i;
double x,scale,f;
scale = tb_Scale->Position;
if ((tb_Scale->Position % 2)==0)
scale = pow(10,scale/2);
else
scale = pow(10,(scale-1)/2) * 5;
lbScale->Caption = scale;
if(!d)d=1;
if(!c)c=1; // 左隶属函数
if (rb_left->Checked)
{
Label_A->Left = Image1->Width * 0.2 ;
// 逐点绘制
for(i = 0; i < Image1->Width; i++)
{
x = double ( a + scale * double(GRID_COL) * (double(i) / Image1->Width - 0.2 ) );
f = FunctionSelector(a, b, c, d, x, FFunctionID);
f = Image1->Height - f * Image1->Height*(GRID_ROW-1)/GRID_ROW;
if (i==0)
canvas->MoveTo(i,f);
else
canvas->LineTo(i,f);
}
}
// 右隶属函数
if (rb_right->Checked)
{
Label_A->Left = Image1->Width * 0.8 ;
// 逐点绘制
for(i = 0; i < Image1->Width; i++)
{
x = double(a + scale * GRID_COL * ( double(i) / Image1->Width - 0.8 ));
f = FunctionSelector(a, b, c, d, x, FFunctionID);
f = Image1->Height - f * Image1->Height*(GRID_ROW-1)/GRID_ROW;
if (i==0)
canvas->MoveTo(i,f);
else
canvas->LineTo(i,f);
}
} // 中间隶属函数
if (rb_middle->Checked)
{
Label_A->Left = Image1->Width * 0.5;
// 逐点绘制
for(i = 0; i < Image1->Width; i++)
{
x = double(a + scale * double(GRID_COL) * ( double(i) / Image1->Width - 0.5 ));
f = FunctionSelector(a, b, c, d, x, FFunctionID);
f = Image1->Height - f * Image1->Height*(GRID_ROW-1)/GRID_ROW;
if (i==0)
canvas->MoveTo(i,f);
else
canvas->LineTo(i,f);
}
}
}
{
try
{
b = edit_B->Text.ToDouble();//b = (*edit_B).Text.ToDouble();
c = edit_C->Text.ToDouble();
d = edit_D->Text.ToDouble();
}
catch(...)
{
Application->MessageBox("请重新输入数字!","输入错误",MB_ICONERROR);
return;
} TCanvas *canvas;
DrawGrid();
canvas = Image1->Canvas;
(canvas->Pen)->Style = psSolid; // prepare to Draw gram
canvas->Pen->Color = clGreen;
canvas->MoveTo(0,Image1->Height/5); int i;
double x,scale,f;
scale = tb_Scale->Position;
if ((tb_Scale->Position % 2)==0)
scale = pow(10,scale/2);
else
scale = pow(10,(scale-1)/2) * 5;
lbScale->Caption = scale;
if(!d)d=1;
if(!c)c=1; // 左隶属函数
if (rb_left->Checked)
{
Label_A->Left = Image1->Width * 0.2 ;
// 逐点绘制
for(i = 0; i < Image1->Width; i++)
{
x = double ( a + scale * double(GRID_COL) * (double(i) / Image1->Width - 0.2 ) );
f = FunctionSelector(a, b, c, d, x, FFunctionID);
f = Image1->Height - f * Image1->Height*(GRID_ROW-1)/GRID_ROW;
if (i==0)
canvas->MoveTo(i,f);
else
canvas->LineTo(i,f);
}
}
// 右隶属函数
if (rb_right->Checked)
{
Label_A->Left = Image1->Width * 0.8 ;
// 逐点绘制
for(i = 0; i < Image1->Width; i++)
{
x = double(a + scale * GRID_COL * ( double(i) / Image1->Width - 0.8 ));
f = FunctionSelector(a, b, c, d, x, FFunctionID);
f = Image1->Height - f * Image1->Height*(GRID_ROW-1)/GRID_ROW;
if (i==0)
canvas->MoveTo(i,f);
else
canvas->LineTo(i,f);
}
} // 中间隶属函数
if (rb_middle->Checked)
{
Label_A->Left = Image1->Width * 0.5;
// 逐点绘制
for(i = 0; i < Image1->Width; i++)
{
x = double(a + scale * double(GRID_COL) * ( double(i) / Image1->Width - 0.5 ));
f = FunctionSelector(a, b, c, d, x, FFunctionID);
f = Image1->Height - f * Image1->Height*(GRID_ROW-1)/GRID_ROW;
if (i==0)
canvas->MoveTo(i,f);
else
canvas->LineTo(i,f);
}
}
}
解决方案 »
- FTP上传时遇到#号出BUG!
- 问个C#的正则问题
- c#中的javascript重定向问题
- 小妹在线求助!
- 关于文本空间,请问如何让滚动条自动下拉
- 如何在接口中定义一个Object类型的属性成员,在实现的结构中再定义其具体类型
- dataSet 的数据更新问题
- 【求助】WPF C#如何访问<Window.Resources>中DataTemplate里的控件
- 有没有软件可以阅读 .chm 文件
- 谢谢!!因为我想动态地在一个空白的form上添加1个label,1个txtbox,请问:不用控件用代码怎么实现?
- asp.net无法访问所请求的资源
- FormView新增记录的时候默认某一栏为当前日期时间
我建议把复杂的C++函数包装成DLL的API,然后在C#里调用。