unit20.cpp
来自「光学仪器的控制系统 用于教学和科研的仪器」· C++ 代码 · 共 2,372 行 · 第 1/5 页
CPP
2,372 行
StringGrid1->Cells[3][row] = gs;
//sprintf(gs, "%1.3f", nd);
FNFloatToStr(gs, 1, m_NDJD, nd);
StringGrid1->Cells[4][row] = gs;
if(!IsFloat(StringGrid1->Cells[5][row]))
{
StringGrid1->Cells[5][row] = gs;
}
//sprintf(gs, "%1.3f", );
FNFloatToStr(gs, 1, m_NDJD, nd - StringGrid1->Cells[5][row].ToDouble());
StringGrid1->Cells[6][row] = gs;
//StringGrid1->Options >> goEditing;
//StringGrid1->Options >> goAlwaysShowEditor;
//StringGrid1->Options << goRowSelect;
DrawWorkQX();
/*
CommonDrawPoint(Image1->Canvas,
XL, XH, YL, YH,
xgd, nd, row - m_StdParaCount,
Wx00, Wx11, Wy00, Wy11,
Wx0, Wx1, Wy0, Wy1,
clBlue, true);
*/
NewItem();
m_bAmend = true;
if(m_bStdCompl)
SelectGridCell(StringGrid1, 0, StringGrid1->RowCount - 1);
}
/*
char ts[80];
float t;
Form1->set_tmode();
String Str;
Str=FloatToStr(Form1->mcs/Form1->wnd0);
Str+=" nm";
labelCurBC->Caption=Str;
t=Form1->tas(1);
if(Form1->csd[1]!=3)
t=Form1->pp2*t*Form1->tbb()*100.0;
t=Form1->toa(t);
exampleabs=t;
sprintf(ts,"%3.5f",t);
labelXGD->Caption=ts;
sprintf(ts,"%3.5f",Ra*t+Rb);
labelND->Caption=ts;
examplechroma=Ra*t+Rb;
if(t>XH) XH=t;
float temp;
temp=Ra*t+Rb;
if(temp>YH)
YH=temp;
DrawQX();
int wx,wy;
wx=Left+(Right-Left)*(t-0.0)/(XH-XL);
if(wx<Left)
wx=Left;
else if(wx>Right)
wx=Right;
wy=Top+(Bottom-Top)*(YH-Ra*t+Rb)/(YH-YL);
if(wy<Top) wy=Top;
else if(wy>Bottom) wy=Bottom;
Image1->Canvas->Pen->Color=clRed;
Image1->Canvas->Ellipse(wx-2,wy-2,wx+2,wy+2);
Image1->Canvas->Pen->Color=clBlack;
*/
/* if(bCeLiang==false)
{
bCeLiang=true;
btnCeLiang->Caption="停止测量";
Timer1->Enabled=true;
}
else
{
bCeLiang=false;
btnCeLiang->Caption="测量";
Timer1->Enabled=false;
if(Form1->csd[1]==3) Form1->set_emode();
} */
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::Timer1Timer(TObject *Sender)
{
float xgd, nd;
char gs[80];
AnsiString Str;
xgd = Form1->tas(1);
if(Form1->csd[1] != 3)
xgd = Form1->pp2 * xgd * Form1->tbb() * 100.0;
xgd = Form1->toa(xgd);
FNFloatToStr(gs, 1, m_XGDJD, xgd);
labelXGD->Caption = gs;
if(m_bStdCompl)
{
labelND->Enabled = true;
nd = Ra * xgd + Rb;
FNFloatToStr(gs, 1, m_NDJD, nd);
Str = gs;
switch(m_CurNDUnit)
{
case 0: Str += " (ug/ml)"; break;
case 1: Str += " (ng/ml)"; break;
case 2: Str += " (pg/ml)"; break;
}
labelND->Caption = Str;
}
else
{
labelND->Enabled = false;
}
//btnAddItem->Enabled = CheckForNewItem();
/*char ts[80];
float t;
String Str;
Str=FloatToStr(Form1->mcs/Form1->wnd0);
Str+=" nm";
labelCurBC->Caption=Str;
t=Form1->tas(1);
if(Form1->csd[1]!=3)
t=Form1->pp2*t*Form1->tbb()*100.0;
t=Form1->toa(t);
sprintf(ts,"%3.5f",t);
labelXGD->Caption=ts;
sprintf(ts,"%3.5f",Ra*t+Rb);
labelND->Caption=ts;
int wx,wy;
wx=Left+(Right-Left)*(t-0.0)/(XH-XL);
if(wx<Left) wx=Left;
else if(wx>Right) wx=Right;
wy=Top+(Bottom-Top)*(YH-Ra*t+Rb)/(YH-YL);
if(wy<Top) wy=Top;
else if(wy>Bottom) wy=Bottom;
Image1->Canvas->Pen->Color=clRed;
Image1->Canvas->Ellipse(wx-2,wy-2,wx+2,wy+2);
Image1->Canvas->Pen->Color=clBlack; */
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::FormClose(TObject *Sender, TCloseAction &Action)
{
m_bReadData = false;
m_bFirstActive = false;
if(Timer1->Enabled==true)
{
bCeLiang=false;
btnCeLiang->Caption="测量";
Timer1->Enabled=false;
if(Form1->csd[1]==3) Form1->set_emode();
}
}
//---------------------------------------------------------------------------
void TFormXGD::standardwork()
{
int times=0;
AnsiString Astr;
FormInData->StringGrid1->Options<<goEditing;
float s=0.0;
char ch[50];
char ts[10];
FormInData->Show();
while(times<20)
{
Astr="请将标准样品"+IntToStr(times+1)+"放入样品池内";
strcpy(ch,Astr.c_str());
if(Application->MessageBox(ch,"提示",MB_OKCANCEL)==IDOK)
{
String str="";
while(str.IsEmpty())
str=InputBox("工作曲线绘制","请输入该标准样品的浓度","");
//if(str.IsEmpty())
str=IsNumber(str);
s=Form1->tas(1);
s=Form1->pp2*s*Form1->tbb()*100.0;
s=Form1->toa(s);
sprintf(ts,"%3.5f",s);
FormInData->StringGrid1->Cells[1][times+1]=str;
//sprintf(ts,"%3.5f",str);
FormInData->StringGrid1->Cells[2][times+1]=ts;
//ShowMessage(str);
times++;
}
else
{
if(Application->MessageBox("是否结束标准样品的测量","结束提示",MB_YESNO)==IDYES)
{
if(Application->MessageBox("是否有坏点删除","标准点编辑",MB_YESNO)==IDYES)
{
AnsiString anstr;
int ixuhao;
FormInData->StringGrid1->Options<<goEditing;
//FormInData->StringGrid1->Options<<goEditing;
FormInData->StringGrid1->Options<<goRowSelect;
//FormInData->StringGrid1->Refresh();
FormInData->ActiveControl=FormInData->btnOK;
break;
}
else
{
//FormInData->StringGrid1->Options>>goEditing;
FormInData->StringGrid1->Options>>goRowSelect;
FormInData->StringGrid1->Options>>goEditing;
//FormInData->StringGrid1->Refresh();
FormInData->ActiveControl=FormInData->btnOK;
break;
}
}
}
}
}
void __fastcall TFormXGD::N1Click(TObject *Sender)
{
if(bshowworkline)
{
bshowworkline=false;
DrawQX();
}
else
{
bshowworkline=true;
DrawQX();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::N2Click(TObject *Sender)
{
if(bshowexpoint)
{
bshowexpoint=false;
DrawQX();
}
else
{
bshowexpoint=true;
if(exampleabs>XH) XH=exampleabs;
//float temp;
//exampechroma=Ra*t+Rb;
if(examplechroma>YH)
YH=examplechroma;
DrawQX();
int wx,wy;
wx=Left+(Right-Left)*(exampleabs-0.0)/(XH-XL);
if(wx<Left)
wx=Left;
else if(wx>Right)
wx=Right;
wy=Top+(Bottom-Top)*(YH-examplechroma)/(YH-YL);
if(wy<Top) wy=Top;
else if(wy>Bottom) wy=Bottom;
Image1->Canvas->Pen->Color=clRed;
Image1->Canvas->Ellipse(wx-2,wy-2,wx+2,wy+2);
Image1->Canvas->Pen->Color=clBlack;
}
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::N3Click(TObject *Sender)
{
if(bshowsapoint)
{
bshowsapoint=false;
DrawQX();
}
else
{
bshowsapoint=true;
DrawQX();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::PopupMenu1Popup(TObject *Sender)
{
if(bshowworkline)
N1->Checked=true;
else
N1->Checked=false;
if(bshowexpoint)
N2->Checked=true;
else
N2->Checked=false;
if(bshowsapoint)
N3->Checked=true;
else
N3->Checked=false;
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::imgPutuMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
// if(Button == mbLeft)
// {
// m_bMouseLeftDown = true;
// imgPutuMouseMove(Sender, Shift, X, Y);
// }
this->ActiveControl = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::imgPutuMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
// if(Button == mbLeft)
// {
// m_bMouseLeftDown = false;
// }
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::imgPutuMouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
float wns, wne;
float ptc_wns, ptc_wne;
int interval;
int wnd0;
wns = Form1->wns;
wne = Form1->wne;
ptc_wns = Form1->ptc.wns;
ptc_wne = Form1->ptc.wne;
interval = Form1->itl[Form1->ptc.interval];
wnd0 = Form1->wnd0;
/*
if((m_bMouseLeftDown==true)&&(m_bReadData==true))
{
m_Rdi= ((X-m_Wx0)*(wne-wns)/(m_Wx1 - m_Wx0)+wns-ptc_wns)
*(float)wnd0/(float)interval;
GetDataPutu(m_Rdi);
}
*/
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(m_bReadData)
{
if(Key == 37)//LEFT
{
GetDataPutu(m_Rdi - 1);
}
if(Key == 39)//RIGHT
{
GetDataPutu(m_Rdi + 1);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::FormActivate(TObject *Sender)
{
TSize sz;
StringGrid1->Canvas->Font = StringGrid1->Font;
sz = StringGrid1->Canvas->TextExtent("2004-07-19 17:20:23");
StringGrid1->ColWidths[8] = sz.cx + 1;
this->ActiveControl = NULL;
if(m_bFirstActive)
{
m_bFirstActive = false;
InitPara();
}
}
//---------------------------------------------------------------------------
void To_GotoWn(void)
{// 波长检索
FormXGD->GotoWn();
}
void TFormXGD::GotoWn()
{// 波长检索
int n1,n2,ss;
float wntogo;
float wns0;
float wne0;
int wnd0;
char gs[80];
int mcs, wn, wac;
wns0 = Form1->wns0;
wne0 = Form1->wne0;
wnd0 = Form1->wnd0;
wntogo = m_WntoGo;
mcs = Form1->mcs;
wn = Form1->wn;
wac = Form1->wac;
n1=wns0*(float)wnd0;
n2=wne0*(float)wnd0;
ss=wntogo*wnd0;
if((ss >= n1) && (ss <= n2))
{
sprintf(gs,"正在进行波长检索%3.1f nm,请稍候...", wntogo);
StatusBar1->Panels->Items[0]->Text = gs;
StatusBar1->Repaint();
while(mcs > ss && !m_bStop)
{
while(mcs>(ss - wnd0*10) && !m_bStop)
{
Form1->mczf(0,1);
mcs = Form1->mcs;
wn = Form1->wn;
if(!(wn%wnd0))
{
FNFloatToStr(gs, 1, 3, (float)wn/(float)wnd0);
labelCurBC->Caption = gs;
labelCurBC->Caption = labelCurBC->Caption + " nm";
labelCurBC->Repaint();
}
}
Form1->dely(5000);
}
while(mcs < ss && !m_bStop)
{
Form1->mczf(1,1);
mcs = Form1->mcs;
wn = Form1->wn;
if(!(wn%wnd0))
{
FNFloatToStr(gs, 1, 3, (float)wn/(float)wnd0);
labelCurBC->Caption = gs;
labelCurBC->Caption = labelCurBC->Caption + " nm";
labelCurBC->Repaint();
}
}
}
//labelCurBC->Caption = FloatToStr((float)mcs/(float)wnd0)+" nm";
FNFloatToStr(gs, 1, 3, (float)mcs/(float)wnd0);
labelCurBC->Caption = gs;
labelCurBC->Caption = labelCurBC->Caption + " nm";
labelCurBC->Repaint();
Form1->ChangLamp_set(Form1->wn);
EnableMenuItems();
StatusBar1->Panels->Items[0]->Text="请选择操作...";
StatusBar1->Repaint();
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TFormXGD::btnGotoWnClick(TObject *Sender)
{
InputBoChang->ShowModal(); // 显示输入波长窗口
if(InputBoChang->ifOk==true)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?