请大家帮加注释,越细越好,最好每句后面都有,多谢大哥们。
请大家帮加注释,越细越好,最好每句后面都有,谢谢大哥们。。。
void __fastcall TForm1::SelRow(TObject *Sender)
{ // 设定选中
int iLine = StringGrid1->Row;
if(iLine<1) return;
int iCol = StringGrid1->Col;
if(iCol!=10) return;
if( Trim(StringGrid1->Cells[1][iLine]).IsEmpty() ) return;
if( Trim(StringGrid1->Cells[10][iLine]).AnsiCompare("√")==0 )
StringGrid1->Cells[10][iLine] = "";
else
StringGrid1->Cells[10][iLine] = "√";
}
//------------------------显示波形图---------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{ //绘制选中编码图
Form2->Width=1020; //再form2窗口宽度
Form2->Height=550; //再form2窗口高度
Form2->Show(); //再form2窗口中显示
Form2->Canvas->Brush->Style=bsClear;
Form2->Canvas->Brush->Color = clWhite;
Form2->Canvas->Pen->Style=bsSolid;
Form2->Canvas->Pen->Width = 2;
Form2->Canvas->Pen->Color = clBlack;
Form2->Canvas->Rectangle(20,10,990,420); // 矩形框坐标
int iLine = 1;
for(int i=1; i<=StringGrid1->Row && iLine<7; i++)
{
if( Trim(StringGrid1->Cells[1][i]).IsEmpty() ) continue;
if( Trim(StringGrid1->Cells[10][i]).AnsiCompare("√")!=0 ) continue;
DoImage(i, iLine++); // 打"√"的绘制波形
}
}
//----------------------------绘制图像-----------------------------------------------
void __fastcall TForm1::DoImage(int iRow, int Nums)
{
int iLine = iRow;
int LowPos = 20 + Nums * 50;
int HighPos = LowPos - 35;
int ud[4];
AnsiString ID = StringGrid1->Cells[1][iLine];
int v1 = 10 * StrToIntDef(StringGrid1->Cells[2][iLine], 0); // 起始码A
int v2 = 10 * StrToFloatDef(StringGrid1->Cells[3][iLine], 0); // 起始码B
ud[0] = StrToIntDef(StringGrid1->Cells[4][iLine], 0); // 用户码1
ud[1] = StrToIntDef(StringGrid1->Cells[5][iLine], 0); // 用户码2
ud[2] = StrToIntDef(StringGrid1->Cells[6][iLine], 0); // 数据码
ud[3] = StrToIntDef(StringGrid1->Cells[7][iLine], 0); // 数据反码
Form2->Canvas->Pen->Width = 1;
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->MoveTo(20,HighPos); // 起始坐标点 经测算,定义1ms宽度为10个像素点
Form2->Canvas->LineTo(20+v1, HighPos); // 起始码A
Form2->Canvas->LineTo(20+v1, LowPos); //
v2=abs(v2); // ??? 此处请思考 【+、- 代表正负电平】
Form2->Canvas->LineTo(20+v1+v2, LowPos); // 起始码B
Form2->Canvas->Pen->Color = clBlack;
Form2->Canvas->LineTo(20+v1+v2, HighPos-5);
Form2->Canvas->LineTo(20+v1+v2, LowPos+5);
int x0=20+v1+v2;
unsigned char udx;
for(int j=0; j<4; j++)
{ udx = (char)ud[j];
for(int i=0; i<8; i++)
{ if( udx & (0x80>>i) )
{ Form2->Canvas->LineTo(x0, HighPos);
Form2->Canvas->LineTo(x0+6, HighPos);
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->LineTo(x0+6, LowPos);
Form2->Canvas->LineTo(x0+6+17, LowPos); // 1 高电平0.56ms,低电平1.69
void __fastcall TForm1::SelRow(TObject *Sender)
{ // 设定选中
int iLine = StringGrid1->Row;
if(iLine<1) return;
int iCol = StringGrid1->Col;
if(iCol!=10) return;
if( Trim(StringGrid1->Cells[1][iLine]).IsEmpty() ) return;
if( Trim(StringGrid1->Cells[10][iLine]).AnsiCompare("√")==0 )
StringGrid1->Cells[10][iLine] = "";
else
StringGrid1->Cells[10][iLine] = "√";
}
//------------------------显示波形图---------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{ //绘制选中编码图
Form2->Width=1020; //再form2窗口宽度
Form2->Height=550; //再form2窗口高度
Form2->Show(); //再form2窗口中显示
Form2->Canvas->Brush->Style=bsClear;
Form2->Canvas->Brush->Color = clWhite;
Form2->Canvas->Pen->Style=bsSolid;
Form2->Canvas->Pen->Width = 2;
Form2->Canvas->Pen->Color = clBlack;
Form2->Canvas->Rectangle(20,10,990,420); // 矩形框坐标
int iLine = 1;
for(int i=1; i<=StringGrid1->Row && iLine<7; i++)
{
if( Trim(StringGrid1->Cells[1][i]).IsEmpty() ) continue;
if( Trim(StringGrid1->Cells[10][i]).AnsiCompare("√")!=0 ) continue;
DoImage(i, iLine++); // 打"√"的绘制波形
}
}
//----------------------------绘制图像-----------------------------------------------
void __fastcall TForm1::DoImage(int iRow, int Nums)
{
int iLine = iRow;
int LowPos = 20 + Nums * 50;
int HighPos = LowPos - 35;
int ud[4];
AnsiString ID = StringGrid1->Cells[1][iLine];
int v1 = 10 * StrToIntDef(StringGrid1->Cells[2][iLine], 0); // 起始码A
int v2 = 10 * StrToFloatDef(StringGrid1->Cells[3][iLine], 0); // 起始码B
ud[0] = StrToIntDef(StringGrid1->Cells[4][iLine], 0); // 用户码1
ud[1] = StrToIntDef(StringGrid1->Cells[5][iLine], 0); // 用户码2
ud[2] = StrToIntDef(StringGrid1->Cells[6][iLine], 0); // 数据码
ud[3] = StrToIntDef(StringGrid1->Cells[7][iLine], 0); // 数据反码
Form2->Canvas->Pen->Width = 1;
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->MoveTo(20,HighPos); // 起始坐标点 经测算,定义1ms宽度为10个像素点
Form2->Canvas->LineTo(20+v1, HighPos); // 起始码A
Form2->Canvas->LineTo(20+v1, LowPos); //
v2=abs(v2); // ??? 此处请思考 【+、- 代表正负电平】
Form2->Canvas->LineTo(20+v1+v2, LowPos); // 起始码B
Form2->Canvas->Pen->Color = clBlack;
Form2->Canvas->LineTo(20+v1+v2, HighPos-5);
Form2->Canvas->LineTo(20+v1+v2, LowPos+5);
int x0=20+v1+v2;
unsigned char udx;
for(int j=0; j<4; j++)
{ udx = (char)ud[j];
for(int i=0; i<8; i++)
{ if( udx & (0x80>>i) )
{ Form2->Canvas->LineTo(x0, HighPos);
Form2->Canvas->LineTo(x0+6, HighPos);
Form2->Canvas->Pen->Color = clRed;
Form2->Canvas->LineTo(x0+6, LowPos);
Form2->Canvas->LineTo(x0+6+17, LowPos); // 1 高电平0.56ms,低电平1.69