📄 unit16.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include "clipbrd.hpp"
#include "Unit16.h"
#include "Unit11.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormDataTable *FormDataTable;
//---------------------------------------------------------------------------
__fastcall TFormDataTable::TFormDataTable(TComponent* Owner)
: TForm(Owner)
{
m_bShow = false;
}
//---------------------------------------------------------------------------
void __fastcall TFormDataTable::FormCreate(TObject *Sender)
{
StringGrid1->ColWidths[0]=30;
StringGrid1->ColWidths[1]=59;
StringGrid1->Cells[0][0]="序号";
StringGrid1->Cells[1][0]="波长";
StringGrid1->Cells[2][0]="测量值";
StringGrid1->Cells[3][0]="样品";
StringGrid1->Cells[4][0]="参比";
StringGrid1->Cells[5][0]="暗电流";
pfDataTC=Form1->tc; // pfDataTC 指针 ,指向tc
fWns=200; // 数据起始波长 ptc.wns
iCount=15; // 一共有15个数据(默认)
fStep=1.0; // 间隔为1nm(默认)
}
//---------------------------------------------------------------------------
void __fastcall TFormDataTable::FormShow(TObject *Sender)
{//
char s[20];
float temp;
float XX[28500],YY[28500];//MM[28500],NN[28500];
m_bShow = true;
if(iCount!=0)
StringGrid1->RowCount=iCount+2;//StringGrid1->RowCount行数
else StringGrid1->RowCount=1;
for(int i=0;i<=iCount;i++)
{
temp=fWns+i*fStep;//得到波长
XX[i] = temp;
temp=pfDataTC[i];//对应的测量值
switch(Form1->csd[1])
{
case 1:
break;
case 2:temp = Form1->toa(temp);
break;
case 3:
break;
}
YY[i] = temp;
/*
StringGrid1->Cells[0][i+1]=IntToStr(i);
temp=fWns+i*fStep;//得到波长
sprintf(s,"%3.2f",temp);
StringGrid1->Cells[1][i+1]=s;
temp=pfDataTC[i];//对应的测量值
switch(Form1->csd[1])
{case 1:sprintf(s,"%3.2f",temp);
break;
case 2:sprintf(s,"%1.4f",Form1->toa(temp));
break;
case 3:sprintf(s,"%4.1f",temp);
break;
}
//sprintf(s,"%3.1f",temp);
StringGrid1->Cells[2][i+1]=s;
*/
}
ShowData(XX, YY, iCount);
}
//---------------------------------------------------------------------------
void __fastcall TFormDataTable::BTOKClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void TFormDataTable::CopyToTClipboard(TStringGrid *sgTemp)
{//把sgTemp中被选中的部分复制到剪贴板中
int StartRow,EndRow,StartCol,EndCol;
String sTemp;
StartRow=sgTemp->Selection.Top;
EndRow=sgTemp->Selection.Bottom;
StartCol=sgTemp->Selection.Left;
EndCol=sgTemp->Selection.Right;
TClipboard *cbText=Clipboard(); // 剪贴板指针
cbText->AsText="";
for(int i=StartRow;i<=EndRow;i++)
{
for(int j=StartCol;j<=EndCol;j++)
{
sTemp+=sgTemp->Cells[j][i];
if(j!=EndCol) sTemp+="\t";
}
if(i!=EndRow) sTemp+="\r\n";
}
cbText->AsText=sTemp;
}
void __fastcall TFormDataTable::Copy2Click(TObject *Sender)
{//点击了PMCopy1->Copy1
CopyToTClipboard(StringGrid1);
}
//---------------------------------------------------------------------------
void __fastcall TFormDataTable::CopyAll2Click(TObject *Sender)
{
//点击了PMCopy1->CopyAll1
TGridRect grTemp;
grTemp.Top=0;
grTemp.Left=0;
grTemp.Right=StringGrid1->ColCount-1;
grTemp.Bottom=StringGrid1->RowCount-1;
StringGrid1->Selection=grTemp;
CopyToTClipboard(StringGrid1);
}
//---------------------------------------------------------------------------
void TFormDataTable::ShowData(float X[], float Y[], int Num)
{
char s[20];
float temp;
if(Num != 0) StringGrid1->RowCount = Num + 1;//StringGrid1->RowCount行数
else StringGrid1->RowCount = 1;
for(int i = 0; i < Num; i++)
{
StringGrid1->Cells[0][i + 1] = IntToStr(i + 1);
temp = X[i];//得到波长
sprintf(s, "%3.3f", temp);
StringGrid1->Cells[1][i + 1] = s;
temp = Y[i];//对应的测量值
sprintf(s,"%3.3f",temp);
StringGrid1->Cells[2][i + 1] = s;
temp = Form1->ts[i];
sprintf(s,"%3.3f",temp);
StringGrid1->Cells[3][i + 1] = s;
temp = Form1->tr[i];
sprintf(s,"%3.3f",temp);
StringGrid1->Cells[4][i + 1] = s;
temp = Form1->td[i];
sprintf(s,"%3.3f",temp);
StringGrid1->Cells[5][i + 1] = s;
}
if(Num > 0)
{
cbPrintData->Enabled = true;
}
else
{
cbPrintData->Checked = false;
cbPrintData->Enabled = false;
}
udJG->Max = Num == 0 ? Num : Num - 1;
udJG->Position = (udJG->Max - udJG->Min) / 10;
cbPrintDataClick(NULL);
//Show();
}
//---------------------------------------------------------------------------
void __fastcall TFormDataTable::cbPrintDataClick(TObject *Sender)
{
if((cbPrintData->Enabled) && (m_bShow) )
{
FormPrntSetting->PrintData(cbPrintData->Checked);
}
else
{
FormPrntSetting->PrintData(false);
}
udJG->Enabled = (cbPrintData->Enabled && cbPrintData->Checked);
}
//---------------------------------------------------------------------------
void __fastcall TFormDataTable::FormClose(TObject *Sender,
TCloseAction &Action)
{
m_bShow = false;
FormPrntSetting->PrintData(false);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -