⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pointreport.cpp

📁 光学仪器的控制系统 用于教学和科研的仪器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
           sprintf(temp,"%1.4f",Form1->toa(tempdata * 100));
           StringGrid1->Cells[2][StringGrid1->RowCount-1]=temp;
           sprintf(temp,"%3.2f",tempdata*100);
           StringGrid1->Cells[3][StringGrid1->RowCount-1]=temp;
           Dpoint[StrToInt(StringGrid1->Cells[0][StringGrid1->RowCount-1])].WaveLength=StrToFloat(StringGrid1->Cells[1][StringGrid1->RowCount-1]);
           Dpoint[StrToInt(StringGrid1->Cells[0][StringGrid1->RowCount-1])].abs=StrToFloat(StringGrid1->Cells[2][StringGrid1->RowCount-1]);
           Dpoint[StrToInt(StringGrid1->Cells[0][StringGrid1->RowCount-1])].tran=StrToFloat(StringGrid1->Cells[3][StringGrid1->RowCount-1]);
           if(StringGrid1->Cells[3][StringGrid1->RowCount-1]!="")
              {
                StringGrid1->RowCount++;
                StringGrid1->Cells[0][StringGrid1->RowCount-1]=StringGrid1->RowCount-1;
              //StringGrid1->Cells[4][StringGrid1->RowCount-1]=StringGrid1->RowCount+1;
              }
           }
         }
      }
      else
         if(StringGrid1->Cells[1][StringGrid1->RowCount-1]!="")
            {
             char temp[10];
             float tempdata;
             tempdata=Form1->pp2*Form1->tas(2)*Form1->tbb();
             sprintf(temp,"%1.4f",Form1->toa(tempdata * 100));
             StringGrid1->Cells[2][StringGrid1->RowCount-1]=temp;
             sprintf(temp,"%3.2f",tempdata*100);
             StringGrid1->Cells[3][StringGrid1->RowCount-1]=temp;
             Dpoint[StrToInt(StringGrid1->Cells[0][StringGrid1->RowCount-1])].WaveLength=StrToFloat(StringGrid1->Cells[1][StringGrid1->RowCount-1]);
             Dpoint[StrToInt(StringGrid1->Cells[0][StringGrid1->RowCount-1])].abs=StrToFloat(StringGrid1->Cells[2][StringGrid1->RowCount-1]);
             Dpoint[StrToInt(StringGrid1->Cells[0][StringGrid1->RowCount-1])].tran=StrToFloat(StringGrid1->Cells[3][StringGrid1->RowCount-1]);
             if(StringGrid1->Cells[3][StringGrid1->RowCount-1]!="")
                {
                 StringGrid1->RowCount++;
                 StringGrid1->Col = 1;
                 StringGrid1->Row = StringGrid1->RowCount - 1;
                 StringGrid1->Options<<goEditing;

                 StringGrid1->Cells[0][StringGrid1->RowCount-1]=StringGrid1->RowCount-1;
                 Button4->Enabled=false;
                 StringGrid1->Cells[1][StringGrid1->RowCount-1]="";
                 StringGrid1->Cells[2][StringGrid1->RowCount-1]="";
                 StringGrid1->Cells[3][StringGrid1->RowCount-1]="";
                 //StringGrid1->Cells[4][StringGrid1->RowCount-1]=StringGrid1->RowCount+1;
                 //StringGrid1->Options<<goRowSelect;
                 // StringGrid1->Options>>goRowSelect;
                 //Button4->SetFocus(); 
                }
            }

/*if(StringGrid1->Cells[2][StringGrid1->RowCount-1]!=""&&StringGrid1->Cells[6][StringGrid1->RowCount-1]!="")
    if(Form1->mcs!=(StrToInt(StringGrid1->Cells[5][StringGrid1->RowCount-1])*Form1->wnd0))
      {
        bWaveRight=false;
        Button7Click(Sender);
        if(bWaveRight)
          {
           if(StringGrid1->Cells[5][StringGrid1->RowCount-1]!="")
           {
           char temp[10];
           sprintf(temp,"%1.4f",Form1->toa(Form1->tas(2)));
           StringGrid1->Cells[6][StringGrid1->RowCount-1]=temp;
           sprintf(temp,"%3.2f",Form1->tas(2));
           StringGrid1->Cells[7][StringGrid1->RowCount-1]=temp;
           Dpoint[StrToInt(StringGrid1->Cells[4][StringGrid1->RowCount-1])].WaveLength=StrToFloat(StringGrid1->Cells[5][StringGrid1->RowCount-1]);
           Dpoint[StrToInt(StringGrid1->Cells[4][StringGrid1->RowCount-1])].abs=StrToFloat(StringGrid1->Cells[6][StringGrid1->RowCount-1]);
           Dpoint[StrToInt(StringGrid1->Cells[4][StringGrid1->RowCount-1])].tran=StrToFloat(StringGrid1->Cells[7][StringGrid1->RowCount-1]);
           if(StringGrid1->Cells[6][StringGrid1->RowCount-1]!="")
               {
                  StringGrid1->RowCount++;
                  StringGrid1->Cells[0][StringGrid1->RowCount-1]=StringGrid1->RowCount;
                  StringGrid1->Cells[4][StringGrid1->RowCount-1]=StringGrid1->RowCount+1;
               }
           }
         }
      }
      else
         if(StringGrid1->Cells[5][StringGrid1->RowCount-1]!="")
            {
             char temp[10];
             sprintf(temp,"%1.4f",Form1->toa(Form1->tas(2)));
             StringGrid1->Cells[2][StringGrid1->RowCount-1]=temp;
             sprintf(temp,"%3.2f",Form1->tas(2));
             StringGrid1->Cells[3][StringGrid1->RowCount-1]=temp;
             Dpoint[StrToInt(StringGrid1->Cells[4][StringGrid1->RowCount-1])].WaveLength=StrToFloat(StringGrid1->Cells[1][StringGrid1->RowCount-1]);
             Dpoint[StrToInt(StringGrid1->Cells[4][StringGrid1->RowCount-1])].abs=StrToFloat(StringGrid1->Cells[2][StringGrid1->RowCount-1]);
             Dpoint[StrToInt(StringGrid1->Cells[4][StringGrid1->RowCount-1])].tran=StrToFloat(StringGrid1->Cells[3][StringGrid1->RowCount-1]);
             if(StringGrid1->Cells[6][StringGrid1->RowCount-1]!="")
                   {
                     StringGrid1->RowCount++;
                     StringGrid1->Cells[0][StringGrid1->RowCount-1]=StringGrid1->RowCount;
                     StringGrid1->Cells[4][StringGrid1->RowCount-1]=StringGrid1->RowCount+1;
                   }
            }
     */
}
//---------------------------------------------------------------------------

void __fastcall TfmDpoint::StringGrid1KeyPress(TObject *Sender, char &Key)
{
 TEdit *fEdit=(TEdit *)Sender;
 if(Key=='.'&&!SetPoint(fEdit->Text)||bKey)
 Key=0;
}
//---------------------------------------------------------------------------

void __fastcall TfmDpoint::StringGrid1KeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
  if(Key==8||(Key>=48&&Key<=57)||(Key>=96&&Key<=105))//数字0~9 小键盘上的0~9 以及backspace
   bKey=false;
  else
   bKey=true;
  if(Key==46) //Del
   {
     if(Row != (StringGrid1->RowCount-1))
         DelData(Row);
     //Label1->Caption=Col;
     //Label2->Caption=Row;
   }
 // if(Key==13)
  // Button4Click(Sender); 
}
//---------------------------------------------------------------------------
bool TfmDpoint::SetPoint(AnsiString tt)
  {
     char *str;
     str=tt.c_str();
     int Length=tt.Length();
     int sum=0;
     for(int i=0;i<Length;i++)
       {
         if(str[i]=='.')
         sum++;
       }
     if(sum==0)
     return true;
     else
     return false;
  }

void __fastcall TfmDpoint::Button7Click(TObject *Sender)
{
/* if(Button7->Caption=="暂停")
   {
       bstop=true;
       MenuEnable();
       Button7->Caption="继续";
   }
*/
  int wn2=StrToFloat(StringGrid1->Cells[1][StringGrid1->RowCount-1]);
  int iwns0, iwne0;

  iwns0 = Form1->wns0;
  iwne0 = Form1->wne0;

  if(wn2<iwns0 || wn2 > iwne0)
  {
       ShowMessage("波长超出范围");
  }

  if(Button7->Caption=="定点检索")
     Button7->Caption="检索中";

      bRun = true;
      if(Thread1!=NULL)
        DeleteThread();
      CreatThread();

      Thread1->SetFun((ExecFun) waverevise);
      bstop=false;  // 按下Stop 按纽
      Thread1->Resume();
      //Button7->Caption="暂停";
}
//---------------------------------------------------------------------------
void TfmDpoint::dely(int tt)
{

    Form1->dely(tt);

}
//---------------------------------------------------------------------------
void __fastcall TfmDpoint::N2Click(TObject *Sender)
{
  for(int i=0;i<100;i++)
  {
    Dpoint[i].WaveLength=0;
    Dpoint[i].abs=0;
    Dpoint[i].tran=0;
  }

  for(int i=1;i<StringGrid1->RowCount;i++)
    for(int j=0;j<4;j++)
      StringGrid1->Cells[j][i]="0";

  StringGrid1->RowCount=2;
  StringGrid1->Cells[0][1]=1;

  //StringGrid1->Cells[4][1]=2;
}
//---------------------------------------------------------------------------



void __fastcall TfmDpoint::Edit3Change(TObject *Sender)
{
bModify=true;        
}
//---------------------------------------------------------------------------

void __fastcall TfmDpoint::Timer1Timer(TObject *Sender)
{
  SYSTEMTIME time;
  GetLocalTime(&time);
  Str="";
  Str=IntToStr(time.wYear); Str+="-";
  Str+=IntToStr(time.wMonth); Str+="-";
  Str+=IntToStr(time.wDay); Str+=" ";
  Label6->Caption=Str;
  Str="";
  Str+=IntToStr(time.wHour); Str+=":";
  Str+=IntToStr(time.wMinute);// Str+=":";
  //Str+=IntToStr(Form1->ptc.dattim[6]);
  Label9->Caption=Str;
  Str="";
}
//---------------------------------------------------------------------------
void waverevise(void)
{
  fmDpoint->func_waverevise();
}
//------------------------------------------------------
void TfmDpoint::func_waverevise()
{
  bool bConvert=false;
  int wac=40;
  int wnd0;
  wnd0=Form1->wnd0;
  float wns0=Form1->wns0;
  float wne0=Form1->wne0;

  int n1,n2,ss;
//StringGrid1->Cells[1][StringGrid1->RowCount]="100";
//if(StringGrid1->Cells[5][StringGrid1->RowCount-1]=="")
  if(StringGrid1->Cells[1][StringGrid1->RowCount-1]!=""&&bModify&&(StringGrid1->Cells[3][StringGrid1->RowCount-1]=="0"||StringGrid1->Cells[3][StringGrid1->RowCount-1]==""))
  {
    MenuDisable();
    float wn2=StrToFloat(StringGrid1->Cells[1][StringGrid1->RowCount-1]);
    if(wn2>=wns0&&wn2<=wne0)
    {
      n1=wns0*(float)wnd0;
      n2=wne0*(float)wnd0;
      ss=wn2*wnd0;
      if(ss>=n1&&ss<=n2)
      {
          while(mcs>ss-Form1->wavemove)
          {
              while(mcs>(ss-wnd0*10)-(Form1->wavemove))
              {
                  if(bstop)
                  {bRun = false; goto gotownend;}

                  Form1->mczf(0,1);
                  dely(wac);
                  mcs--;
                  wn=mcs+Form1->wavemove;

                  ReFreshWn();
                  bConvert=true;
              }
          }
          if(bConvert)
          {
          	dely(5000);
            bConvert=false;
          }

          while(mcs < ss - Form1->wavemove)
          {
              if(bstop)
              {bRun = false; goto gotownend;}

              Form1->mczf(1,1);
              dely(30);
              mcs++;
              wn=mcs+Form1->wavemove;
              Form1->wn=wn;

              ReFreshWn();
          }
          Form1->ChangLamp_set(wn);         //设置光源状态
          dely(500);
          Form1->filter_set();              //换滤光片的波长
          dely(800);

          bWaveRight=true;

          Button7->Caption="定点检索";
          if(bstop==false)
          {
              Button4->Enabled=true;
          }
          else
          {
              Button4->Enabled=false;
          }
          MenuEnable();
      }
      else
      {
          ShowMessage("波长应该在"+FloatToStr(wns0)+"~"+FloatToStr(wne0)+"之间");
          Button7->Caption="定点检索";
      }
    }
  }
  else
  {
      ShowMessage("请输入您要检索的波长值("+FloatToStr(wns0)+"~"+FloatToStr(wne0)+")");
      Button7->Caption="定点检索";
      //
  }
//===========================================================================
if(StringGrid1->Cells[5][StringGrid1->RowCount-1]!=""&&bModify&&StringGrid1->Cells[2][StringGrid1->RowCount-1]!="")
 {
   MenuDisable();
   int wn2=StrToInt(StringGrid1->Cells[5][StringGrid1->RowCount-1]);
   if(wn2>=wns0&&wn2<=wne0)
     {
      n1=wns0*(float)wnd0;
      n2=wne0*(float)wnd0;
      ss=wn2*wnd0;
      if(ss>=n1&&ss<=n2)
       {
            while(mcs>ss-Form1->wavemove)
            {
                while(mcs>(ss - wnd0*10 - Form1->wavemove))
                 {
                 	if(bstop)
                 	{
                    	bRun = false;
                        goto gotownend;
                    }
                  	Form1->mczf(0,1);
                  	dely(wac);
                  	mcs--;
                  	wn=mcs + Form1->wavemove;
                  	ReFreshWn();
                  //Label4->Caption=mcs;
                  //Label4->Repaint();
                  	bConvert=true;
                 }
                 if(bConvert)
                 {
                 	dely(5000);
                    bConvert=false;
                 }
             }
             while(mcs<ss - Form1->wavemove)
              {
                if(bstop)
                {
                	bRun = false;
                    goto gotownend;
                }
                Form1->mczf(1,1);
                dely(wac);
                mcs++;
                wn=mcs + Form1->wavemove;
                //Form1->ReFreshWn();
                ReFreshWn();
                //Label4->Caption=mcs;
                //Label4->Repaint();
              }
             bWaveRight=true;
             Form1->mcs=mcs;
             Button7->Caption="定点检索";
             MenuEnable();
           }
       }
      else
       {
           ShowMessage("波长应该在"+FloatToStr(wns0)+"~"+FloatToStr(wne0)+"之间");
       }
 }
else
   if(!(StringGrid1->Cells[2][StringGrid1->RowCount-1]=="0"||StringGrid1->Cells[2][StringGrid1->RowCount-1]==""))
     {
        ShowMessage("请按序号进行定点测量");
     }

gotownend:
     MenuEnable();
     bRun = false;

     int mcstogo;
     mcstogo = StrToFloat(StringGrid1->Cells[1][StringGrid1->RowCount-1]) * Form1->wnd0 + 0.5;


     if(mcstogo == wn)
     {
         StringGrid1->Options>>goEditing;
         Button4->Enabled = true;
     }
     else
     {
         StringGrid1->Options<<goEditing;
         Button4->Enabled = false;
     }
     return;
}
//------------------------------------------------------------
void TfmDpoint::CreatThread(void)
{// 创建线程
 if(Thread1==NULL)
 { Thread1=new ThreadE(true);
   Thread1->Priority=tpNormal;
 }
}
//---------------------------------------------------------------------------
void TfmDpoint::DeleteThread(void)
{// 删除线程
 if(Thread1!=NULL)
 { Thread1->Terminate();
   Thread1->WaitFor();
   delete Thread1;
   Thread1=NULL;
 }
}
//------------------------------------------------------------------
void TfmDpoint::MenuDisable()
{
Button1->Enabled=false;
Button2->Enabled=false;
Button3->Enabled=false;
Button4->Enabled=false;
Button5->Enabled=false;
Button7->Enabled=false;
}
//-----------------------------------------------------------------
void TfmDpoint::MenuEnable()
{
Button1->Enabled=true;
Button2->Enabled=true;
Button3->Enabled=true;
Button4->Enabled=true;
Button5->Enabled=true;
Button7->Enabled=true;
}


void __fastcall TfmDpoint::Button5Click(TObject *Sender)
{
 int XMax,YMax;
 int iCurrentTop;
 int iBlankHeight;   //行距离
 TPrinter *print;
 int PixelsPerInchX, PixelsPerInchY;
 double PixelsPerCmX;
 double PixelsPerCmY;
 int pw,ph;
 float fPageWidth,fPageHeight;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -