525 lines
21 KiB
C++
525 lines
21 KiB
C++
#pragma warning( push , 0 )
|
||
#include <QList>
|
||
#include <QStandardItemModel>
|
||
#include <QDialog>
|
||
#include "CreateResoultStructDlg.h"
|
||
#include <QFileDialog>
|
||
#pragma warning( pop )
|
||
|
||
CCreateResoultStructDlg::CCreateResoultStructDlg()
|
||
:m_pDialog( NULL )
|
||
{
|
||
QStringList MenuTypea;
|
||
MenuTypea<<("RESULT")<<("CoreLith")<<("CoreOil")<<("Corecolor")<<("Corecolor")<<("GujingOrder");
|
||
DataTypea<<("INT")<<("SHORT")<<("LONG")<<("FLOAT")<<("DOUBLE")<<("STRING")<<
|
||
("CHAR")<<("UNSIGNED CHAR")<<("UNSIGNED SHORT")<<("UNSIGNED INT")<<("UNSIGNED LONG")<<("转换型");
|
||
GetValueModeStr=GetSimilarCurves("ValueMode");
|
||
GetValueModeStr.insert(0,"");
|
||
ZDType=GetSimilarCurves("FieldType");//字段类型
|
||
student_model=NULL;
|
||
m_pDialog = new Ui_CreateResoultStruct();
|
||
m_pDialog->setupUi( this );
|
||
for(int i=0;i<GetValueModeStr.size();i++) m_pDialog->comboBox->addItem(GetValueModeStr[i]);
|
||
for(int i=0;i<DataTypea.size();i++) m_pDialog->comboBox_2->addItem(DataTypea[i]);
|
||
for(int i=0;i<MenuTypea.size();i++) m_pDialog->comboBox_3->addItem(MenuTypea[i]);
|
||
m_pListTableInf=NULL;
|
||
m_pDialog->radioButton_2->setChecked(true);
|
||
m_pDialog->btn_Ok->setIcon(QIcon( ::GetImagePath() + "icon/OK.png" ));
|
||
// m_pDialog->btn_Cancel->setIcon(QIcon( ::GetImagePath() + "icon/Cancel.png" ));
|
||
connect( m_pDialog->btn_Ok,SIGNAL(clicked()),this,SLOT(slotOnOkBtnClicked()) );
|
||
// connect( m_pDialog->btn_Cancel,SIGNAL(clicked()),this,SLOT(slotOnCancelBtnClicked()));
|
||
|
||
connect(m_pDialog->tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slottableViewClicked(const QModelIndex &)));
|
||
|
||
connect( m_pDialog->pushButton,SIGNAL(clicked()),this,SLOT(slotAddClicked()));
|
||
connect( m_pDialog->pushButton_5,SIGNAL(clicked()),this,SLOT(slotLoadTempClicked()));
|
||
connect( m_pDialog->pushButton_2,SIGNAL(clicked()),this,SLOT(slotMoveLeftClicked()));
|
||
connect( m_pDialog->pushButton_3,SIGNAL(clicked()),this,SLOT(slotMoveRightClicked()));
|
||
connect( m_pDialog->pushButton_4,SIGNAL(clicked()),this,SLOT(slotDeleteClicked()));
|
||
connect( m_pDialog->pushButton_6,SIGNAL(clicked()),this,SLOT(slotSaveTempClicked()));
|
||
}
|
||
|
||
CCreateResoultStructDlg::~CCreateResoultStructDlg()
|
||
{
|
||
|
||
}
|
||
void CCreateResoultStructDlg::slottableViewClicked(const QModelIndex &ind)
|
||
{
|
||
if(!m_pListTableInf) return;
|
||
QModelIndex im=ind;//m_pDialog->tableView->currentIndex();
|
||
if(im.isValid()) {
|
||
int index=im.row();
|
||
if(index<0) return;
|
||
if(index>=m_pListTableInf->Table_Field_Num) return;
|
||
m_pDialog->lineEdit->setText(m_pListTableInf->Table_Field[index].Name);
|
||
m_pDialog->lineEdit_2->setText(m_pListTableInf->Table_Field[index].HZName);
|
||
// QString FieldUnit=m_pDialog->lineEdit_3->setText(m_pListTableInf->Table_Field[index].);
|
||
m_pDialog->lineEdit_5->setText(QString(m_pListTableInf->Table_Field[index].Length));
|
||
m_pDialog->comboBox_2->setCurrentIndex(m_pListTableInf->Table_Field[index].RepCode-1);
|
||
if(m_pListTableInf->Type[index]==0) {
|
||
m_pDialog->radioButton_2->setChecked(true);
|
||
m_pDialog->radioButton->setChecked(false);
|
||
m_pDialog->radioButton_3->setChecked(false);
|
||
}
|
||
else if(m_pListTableInf->Type[index]==1) {
|
||
m_pDialog->radioButton_2->setChecked(false);
|
||
m_pDialog->radioButton->setChecked(true);
|
||
m_pDialog->radioButton_3->setChecked(false);
|
||
}
|
||
else if(m_pListTableInf->Type[index]==2) {
|
||
m_pDialog->radioButton_2->setChecked(false);
|
||
m_pDialog->radioButton->setChecked(false);
|
||
m_pDialog->radioButton_3->setChecked(true);
|
||
}
|
||
//取值方式
|
||
int FieldValType=m_pListTableInf->GetValueMode[index];
|
||
m_pDialog->comboBox->setCurrentIndex(FieldValType);
|
||
}
|
||
}
|
||
void CCreateResoultStructDlg::Init(struct LIST_TABLE_INF* pListTableInf)
|
||
{
|
||
m_pListTableInf=pListTableInf;
|
||
// m_pDialog->tableView->clear();
|
||
student_model = new QStandardItemModel();
|
||
student_model->setHorizontalHeaderItem(0, new QStandardItem("字段名"));
|
||
student_model->setHorizontalHeaderItem(1, new QStandardItem("中文名"));
|
||
student_model->setHorizontalHeaderItem(2, new QStandardItem("单位"));
|
||
student_model->setHorizontalHeaderItem(3, new QStandardItem("数据类型"));
|
||
student_model->setHorizontalHeaderItem(4, new QStandardItem("字节长度"));
|
||
student_model->setHorizontalHeaderItem(5, new QStandardItem("小数位数或类型名"));
|
||
student_model->setHorizontalHeaderItem(6, new QStandardItem("数据来源"));
|
||
student_model->setHorizontalHeaderItem(7, new QStandardItem("重定向名"));
|
||
student_model->setHorizontalHeaderItem(8, new QStandardItem("取值方式"));
|
||
m_pDialog->tableView->setModel(student_model);
|
||
SetTableView();
|
||
m_pDialog->lineEdit_9->setText(QString::number(m_pListTableInf->lstm));
|
||
m_pDialog->checkBox->setChecked(m_pListTableInf->m_Mode);
|
||
m_pDialog->checkBox_2->setChecked(m_pListTableInf->IsHB);
|
||
m_pDialog->checkBox_3->setChecked(!m_pListTableInf->m_Flag);
|
||
m_pDialog->lineEdit_6->setText(m_pListTableInf->m_TableName);
|
||
QString text;
|
||
for(int i=0;i<m_pListTableInf->SPVALNUM;i++) {
|
||
QString cs=m_pListTableInf->SPVAL[i];
|
||
cs.remove("\r");
|
||
cs.remove("\n");
|
||
text+=cs;
|
||
text+="\n";
|
||
}
|
||
m_pDialog->textEdit_2->setText(text);
|
||
m_pDialog->textEdit->setText(m_pListTableInf->m_CurveName);
|
||
QString path,fname;
|
||
GetWellNameAndPath(filename,fname,path);
|
||
m_pDialog->lineEdit_4->setText(fname);
|
||
}
|
||
void CCreateResoultStructDlg::slotOnOkBtnClicked()
|
||
{
|
||
slotSaveTempClicked();
|
||
this->accept();
|
||
}
|
||
|
||
void CCreateResoultStructDlg::slotOnCancelBtnClicked()
|
||
{
|
||
this->reject();
|
||
}
|
||
|
||
void CCreateResoultStructDlg::slotMoveLeftClicked()
|
||
{
|
||
QModelIndex im=m_pDialog->tableView->currentIndex();
|
||
int index=im.row();
|
||
if(index<1) return;
|
||
Slf_TABLE_FIELD Table_Field;
|
||
memmove(&Table_Field,&m_pListTableInf->Table_Field[index-1],sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Table_Field[index-1],&m_pListTableInf->Table_Field[index],sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Table_Field[index],&Table_Field,sizeof(Slf_TABLE_FIELD));
|
||
|
||
char Formate[116];
|
||
memmove(&Formate,&m_pListTableInf->Format[index-1],116);
|
||
memmove(&m_pListTableInf->Format[index-1],&m_pListTableInf->Format[index],116);
|
||
memmove(&m_pListTableInf->Format[index],&Formate,116);
|
||
char ZdIndex[116];
|
||
memmove(&ZdIndex,&m_pListTableInf->ZdIndex[index-1],116);
|
||
memmove(&m_pListTableInf->ZdIndex[index-1],&m_pListTableInf->ZdIndex[index],116);
|
||
memmove(&m_pListTableInf->ZdIndex[index],&ZdIndex,116);
|
||
BYTE type;
|
||
memmove(&type,&m_pListTableInf->Type[index-1],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->Type[index-1],&m_pListTableInf->Type[index],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->Type[index],&type,sizeof(BYTE));
|
||
BYTE ValueMode=m_pListTableInf->GetValueMode[index-1];
|
||
memmove(&m_pListTableInf->GetValueMode[index-1],&m_pListTableInf->GetValueMode[index],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->GetValueMode[index],&ValueMode,sizeof(BYTE));
|
||
char RenName[116];
|
||
memmove(&m_pListTableInf->RenName[index-1],&m_pListTableInf->RenName[index],116);
|
||
memmove(&m_pListTableInf->RenName[index],&RenName,116);
|
||
|
||
SetTableViewRec(index-1);
|
||
SetTableViewRec(index);
|
||
if(index>0)
|
||
{
|
||
QModelIndex ind=m_pDialog->tableView->model()->index(index-1,0);
|
||
m_pDialog->tableView->setCurrentIndex(ind);
|
||
}
|
||
}
|
||
void CCreateResoultStructDlg::slotMoveRightClicked()
|
||
{
|
||
QModelIndex im=m_pDialog->tableView->currentIndex();
|
||
int index=im.row();
|
||
if(index<0) return;
|
||
Slf_TABLE_FIELD Table_Field;
|
||
char Formate[116];
|
||
char ZdIndex[116];
|
||
BYTE type;
|
||
memmove(&Formate,&m_pListTableInf->Format[index+1],116);
|
||
memmove(&Table_Field,&m_pListTableInf->Table_Field[index+1],sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Table_Field[index+1],&m_pListTableInf->Table_Field[index],sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Table_Field[index],&Table_Field,sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Format[index+1],&m_pListTableInf->Format[index],116);
|
||
memmove(&m_pListTableInf->Format[index],&Formate,116);
|
||
memmove(&ZdIndex,&m_pListTableInf->ZdIndex[index+1],116);
|
||
memmove(&type,&m_pListTableInf->Type[index+1],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->ZdIndex[index+1],&m_pListTableInf->ZdIndex[index],116);
|
||
memmove(&m_pListTableInf->Type[index+1],&m_pListTableInf->Type[index],sizeof(BYTE));
|
||
|
||
memmove(&m_pListTableInf->ZdIndex[index],&ZdIndex,116);
|
||
memmove(&m_pListTableInf->Type[index],&type,sizeof(BYTE));
|
||
BYTE ValueMode=m_pListTableInf->GetValueMode[index+1];
|
||
memmove(&m_pListTableInf->GetValueMode[index+1],&m_pListTableInf->GetValueMode[index],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->GetValueMode[index],&ValueMode,sizeof(BYTE));
|
||
char RenName[116];
|
||
memmove(&m_pListTableInf->RenName[index+1],&m_pListTableInf->RenName[index],116);
|
||
memmove(&m_pListTableInf->RenName[index],&RenName,116);
|
||
SetTableViewRec(index+1);
|
||
SetTableViewRec(index);
|
||
if(index<m_pDialog->tableView->model()->rowCount())
|
||
{
|
||
QModelIndex ind=m_pDialog->tableView->model()->index(index+1,0);
|
||
m_pDialog->tableView->setCurrentIndex(ind);
|
||
}
|
||
}
|
||
void CCreateResoultStructDlg::slotDeleteClicked()
|
||
{
|
||
QModelIndex im=m_pDialog->tableView->currentIndex();
|
||
int index=im.row();
|
||
if(index<0) return;
|
||
for(int i=index;i<m_pListTableInf->Table_Field_Num;i++) {
|
||
memmove(&m_pListTableInf->Table_Field[i],&m_pListTableInf->Table_Field[i+1],sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Format[i],&m_pListTableInf->Format[i+1],116);
|
||
memmove(&m_pListTableInf->ZdIndex[i],&m_pListTableInf->ZdIndex[i+1],116);
|
||
memmove(&m_pListTableInf->Type[i],&m_pListTableInf->Type[i+1],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->GetValueMode[i],&m_pListTableInf->GetValueMode[i+1],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->RenName[i],&m_pListTableInf->RenName[i+1],116);
|
||
}
|
||
student_model->removeRows(0,m_pListTableInf->Table_Field_Num);
|
||
m_pListTableInf->Table_Field_Num--;
|
||
if(m_pListTableInf->Table_Field_Num<0) m_pListTableInf->Table_Field_Num=0;
|
||
SetTableView();
|
||
}
|
||
void CCreateResoultStructDlg::slotAddClicked()
|
||
{
|
||
int RepSize[12]={0,
|
||
sizeof(int),
|
||
sizeof(short),
|
||
sizeof(long long),
|
||
sizeof(float),
|
||
sizeof(double),
|
||
sizeof(char),
|
||
sizeof(char),
|
||
sizeof(unsigned char),
|
||
sizeof(unsigned short),
|
||
sizeof(unsigned int),
|
||
sizeof(unsigned int)
|
||
};
|
||
QString Field=m_pDialog->lineEdit->text();
|
||
Field=Field.toUpper();
|
||
if(Field.isEmpty()) {
|
||
AfxMessageBox("字段名不能为空!");
|
||
return;
|
||
}
|
||
QModelIndex im=m_pDialog->tableView->currentIndex();
|
||
int index=im.row();
|
||
if(index<0) {
|
||
index=m_pListTableInf->Table_Field_Num;
|
||
for(int i=0;i<m_pListTableInf->Table_Field_Num;i++) {
|
||
if(Field.compare(m_pListTableInf->Table_Field[i].Name)==0) {
|
||
AfxMessageBox("字段名已存在!");
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
if(QMessageBox::information(NULL,QObject::tr("当前位置插入或替换"),QObject::tr("插入?"),QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) {
|
||
Slf_TABLE_FIELD Table_Field;
|
||
for(int i=m_pListTableInf->Table_Field_Num;i>index;i--) {
|
||
memmove(&m_pListTableInf->Table_Field[i],&m_pListTableInf->Table_Field[i-1],sizeof(Slf_TABLE_FIELD));
|
||
memmove(&m_pListTableInf->Format[i],&m_pListTableInf->Format[i-1],116);
|
||
memmove(&m_pListTableInf->ZdIndex[i],&m_pListTableInf->ZdIndex[i-1],116);
|
||
memmove(&m_pListTableInf->Type[i],&m_pListTableInf->Type[i-1],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->GetValueMode[i],&m_pListTableInf->GetValueMode[i-1],sizeof(BYTE));
|
||
memmove(&m_pListTableInf->RenName[i],&m_pListTableInf->RenName[i-1],116);
|
||
}
|
||
}
|
||
}
|
||
QString FieldHZ=m_pDialog->lineEdit_2->text();
|
||
FieldHZ=FieldHZ.toUpper();
|
||
QString FieldUnit=m_pDialog->lineEdit_3->text();
|
||
QString FieldLength=m_pDialog->lineEdit_5->text();
|
||
|
||
if(m_pDialog->comboBox_2->currentText()!="STRING"&&m_pDialog->comboBox_2->currentText()!="转换型")
|
||
{
|
||
char buf[100];
|
||
sprintf(buf,"%d",RepSize[m_pDialog->comboBox_2->currentIndex()+1]);
|
||
FieldLength=buf;
|
||
}
|
||
QString FieldType;
|
||
if(m_pDialog->radioButton_2->isChecked()) {
|
||
FieldType="字段";
|
||
}
|
||
else if(m_pDialog->radioButton->isChecked()){
|
||
FieldType="曲线";
|
||
}
|
||
else {
|
||
FieldType="岩心";
|
||
}
|
||
strcpy(m_pListTableInf->TableName[index],"");
|
||
m_pListTableInf->Type[index]=ZDType.indexOf(FieldType);
|
||
|
||
if(m_pListTableInf->Type[index]==255) strcpy(m_pListTableInf->TableName[index],FieldType.toStdString().c_str());
|
||
// if(m_pListTableInf->Type[index]<0) m_pListTableInf->Type[index]=1;
|
||
//取值方式
|
||
QString FieldValType=m_pDialog->comboBox->currentText();
|
||
m_pListTableInf->GetValueMode[index]=GetValueModeStr.indexOf(FieldValType);
|
||
if(m_pListTableInf->GetValueMode[index]<=0||m_pListTableInf->GetValueMode[index]>=GetValueModeStr.size())m_pListTableInf->GetValueMode[index]=3;//如果没有指定取值方式,则取平均值
|
||
strcpy(m_pListTableInf->m_CurveName,"GR POR");
|
||
strcpy(m_pListTableInf->RenName[index],Field.toStdString().c_str());
|
||
strcpy(m_pListTableInf->Table_Field[index].Name,Field.toStdString().c_str());
|
||
strcpy(m_pListTableInf->Table_Field[index].HZName,FieldHZ.toStdString().c_str());
|
||
m_pListTableInf->Table_Field[index].Length=FieldLength.toFloat();
|
||
m_pListTableInf->Table_Field[index].RepCode=m_pDialog->comboBox_2->currentIndex()+1;
|
||
if(GetValueModeStr[m_pDialog->comboBox_2->currentIndex()]=="MENU")
|
||
{
|
||
m_pListTableInf->Table_Field[index].RepCode=6;
|
||
strcpy(m_pListTableInf->ZdIndex[index],m_pDialog->comboBox_3->currentText().toStdString().c_str());
|
||
if(strlen(m_pListTableInf->ZdIndex[index])==0) strcpy(m_pListTableInf->ZdIndex[index],"RESULT");
|
||
}
|
||
else {
|
||
strcpy(m_pListTableInf->ZdIndex[index],m_pDialog->lineEdit_8->text().toStdString().c_str());
|
||
if(strlen(m_pListTableInf->ZdIndex[index])==0) strcpy(m_pListTableInf->ZdIndex[index],"0");
|
||
if(!isdigit(m_pListTableInf->ZdIndex[index][0])) {
|
||
strcpy(m_pListTableInf->TableName[index],m_pListTableInf->ZdIndex[index]);
|
||
strcpy(m_pListTableInf->ZdIndex[index],"0");
|
||
}
|
||
}
|
||
m_pListTableInf->Table_Field[index].Reserved=0;
|
||
m_pListTableInf->Table_Field_Num++;
|
||
SetTableView();
|
||
}
|
||
void CCreateResoultStructDlg::SetTableView()
|
||
{
|
||
for(int i=0;i<m_pListTableInf->Table_Field_Num;i++) {
|
||
SetTableViewRec(i);
|
||
}
|
||
}
|
||
void CCreateResoultStructDlg::SetTableViewRec(int i)
|
||
{
|
||
QString text=m_pListTableInf->Table_Field[i].Name;
|
||
student_model->setItem(i, 0, new QStandardItem(text));
|
||
|
||
QString hz;
|
||
hz=m_pListTableInf->Table_Field[i].HZName;
|
||
student_model->setItem(i, 1, new QStandardItem(hz));
|
||
|
||
QString Unit="NULL";
|
||
student_model->setItem(i, 2, new QStandardItem(Unit));
|
||
|
||
QString Type;
|
||
if(m_pListTableInf->Table_Field[i].RepCode<1) m_pListTableInf->Table_Field[i].RepCode=1;
|
||
Type=DataTypea[m_pListTableInf->Table_Field[i].RepCode-1];
|
||
student_model->setItem(i, 3, new QStandardItem(Type));
|
||
|
||
// QString Length;
|
||
char buf[100];
|
||
sprintf(buf,"%d",m_pListTableInf->Table_Field[i].Length);
|
||
student_model->setItem(i, 4, new QStandardItem(buf));
|
||
|
||
student_model->setItem(i, 5, new QStandardItem(m_pListTableInf->ZdIndex[i]));
|
||
|
||
QString valfrom;
|
||
valfrom=ZDType[m_pListTableInf->Type[i]];
|
||
student_model->setItem(i, 6, new QStandardItem(valfrom));
|
||
|
||
QString RName;
|
||
RName=m_pListTableInf->RenName[i];
|
||
student_model->setItem(i, 7, new QStandardItem(RName));
|
||
QString ValueMode=GetValueModeStr[m_pListTableInf->GetValueMode[i]];
|
||
if(valfrom=="字段"&&ValueMode=="平均值") ValueMode="NULL";
|
||
student_model->setItem(i, 8, new QStandardItem(ValueMode));
|
||
}
|
||
void CCreateResoultStructDlg::slotLoadTempClicked()
|
||
{
|
||
QString path=GetTemplatePath();
|
||
QString m_ModelName=path;
|
||
int pos=m_ModelName.lastIndexOf('\\');
|
||
if(pos<0) pos=m_ModelName.length();
|
||
m_ModelName=m_ModelName.left(pos);
|
||
// m_ModelName+=+"\\"+m_ParFileName;
|
||
QString strTplFilter="(*.lst)";
|
||
|
||
QString defaultTempleteFile=QFileDialog::getOpenFileName(NULL,QObject::tr("选择模板"),path,strTplFilter);
|
||
FILE *fp=fopen(defaultTempleteFile.toStdString().c_str(),"rt");
|
||
if(fp)
|
||
{
|
||
char buf[1000];
|
||
QString cs;
|
||
student_model->removeRows(0,m_pListTableInf->Table_Field_Num);
|
||
fscanf(fp,"%s",m_pListTableInf->m_TableName);
|
||
fscanf(fp,"%d %d %d ",&m_pListTableInf->Table_Field_Num,
|
||
&m_pListTableInf->m_Mode,
|
||
&m_pListTableInf->m_Flag
|
||
);
|
||
buf[0]=0;
|
||
fgets(buf,1000,fp);
|
||
cs=buf;
|
||
cs.remove("\r\n");
|
||
cs.remove("\r");
|
||
cs.remove("\n");
|
||
strcpy(m_pListTableInf->m_CurveName,cs.toStdString().c_str());
|
||
char ss[10][32];
|
||
strcpy(ss[1],"");
|
||
strcpy(ss[2],"");
|
||
for(int i=0;i<m_pListTableInf->Table_Field_Num;i++)
|
||
{
|
||
strcpy(m_pListTableInf->TableName[i],"");
|
||
fscanf(fp,"%s %s %s %s %s %s %s %s %s %s",ss[0],m_pListTableInf->Table_Field[i].Name,m_pListTableInf->Table_Field[i].HZName,ss[3],ss[4],ss[5],ss[6],ss[7],ss[8],ss[9]);
|
||
//数值类型
|
||
m_pListTableInf->Table_Field[i].RepCode=DataTypea.indexOf(ss[4])+1;
|
||
//字段长度
|
||
sscanf(ss[5],"%d",&m_pListTableInf->Table_Field[i].Length);
|
||
m_pListTableInf->Table_Field[i].Reserved=0;
|
||
strcpy(m_pListTableInf->ZdIndex[i],ss[6]);
|
||
if(!isdigit(ss[6][0])&&stricmp(ss[9],"MENU"))
|
||
{
|
||
strcpy(m_pListTableInf->TableName[i],ss[6]);
|
||
strcpy(m_pListTableInf->ZdIndex[i],"0");
|
||
}
|
||
//字段类型
|
||
m_pListTableInf->Type[i]=ZDType.indexOf(ss[7]);
|
||
if(m_pListTableInf->Type[i]==255) strcpy(m_pListTableInf->TableName[i],ss[7]);
|
||
// if(m_pListTableInf->Type[i]<0) m_pListTableInf->Type[i]=1;
|
||
//重定向名
|
||
strcpy(m_pListTableInf->RenName[i],ss[8]);
|
||
//取值方式
|
||
m_pListTableInf->GetValueMode[i]=GetValueModeStr.indexOf(ss[9]);
|
||
if(m_pListTableInf->GetValueMode[i]<=0||m_pListTableInf->GetValueMode[i]>=GetValueModeStr.size())m_pListTableInf->GetValueMode[i]=3;//如果没有指定取值方式,则取平均值
|
||
}
|
||
fscanf(fp," %d %d %d\n",&m_pListTableInf->lstm,&m_pListTableInf->IsHB,m_pListTableInf->IsFC);
|
||
fscanf(fp," %s\n",&m_pListTableInf->m_TableType);
|
||
fscanf(fp," %s\n",&m_pListTableInf->m_TableSpFIELD);
|
||
if(!m_pListTableInf->m_TableType[0]) strcpy(m_pListTableInf->m_TableType,"TOTALVAL");
|
||
if(!m_pListTableInf->m_TableSpFIELD[0]) strcpy(m_pListTableInf->m_TableSpFIELD,"RESULTNO");
|
||
m_pListTableInf->SPVALNUM=0;
|
||
while(!feof(fp))
|
||
{
|
||
buf[0]=0;
|
||
fgets(buf,1000,fp);
|
||
cs=buf;
|
||
cs.remove("\r");
|
||
cs.remove("\n");
|
||
cs.trimmed();
|
||
if(!cs.isEmpty()&&m_pListTableInf->SPVALNUM<100)
|
||
{
|
||
strcpy(m_pListTableInf->SPVAL[m_pListTableInf->SPVALNUM],cs.toStdString().c_str());
|
||
m_pListTableInf->SPVALNUM++;
|
||
}
|
||
}
|
||
fclose(fp);
|
||
}
|
||
else
|
||
{
|
||
strcpy(m_pListTableInf->m_CurveName,"GR");
|
||
m_pListTableInf->m_Mode=0;//取值模式选择:0-每条曲线按各自给定取值方式取值,1-按给定曲线的极值点深度取值
|
||
m_pListTableInf->m_Flag=1;
|
||
m_pListTableInf->IsHB=1;
|
||
}
|
||
SetTableView();
|
||
}
|
||
void CCreateResoultStructDlg::slotSaveTempClicked()
|
||
{
|
||
m_pListTableInf->lstm=m_pDialog->lineEdit_9->text().toInt();
|
||
m_pListTableInf->IsHB=m_pDialog->checkBox_2->checkState();
|
||
m_pListTableInf->m_Mode=m_pDialog->checkBox->checkState();
|
||
m_pListTableInf->m_Flag=!m_pDialog->checkBox_3->checkState();
|
||
m_pListTableInf->IsFC=0;
|
||
QString ttabname=m_pDialog->lineEdit_6->text();
|
||
if(ttabname.isEmpty()) {
|
||
AfxMessageBox("输出成果表名不能为空!");
|
||
return;
|
||
}
|
||
QString tt=m_pDialog->lineEdit_4->text();
|
||
if(tt.isEmpty()) {
|
||
AfxMessageBox("输出模板文件名不能为空!");
|
||
return;
|
||
}
|
||
QString path=GetTemplatePath();
|
||
tt=tt.toLower();
|
||
if(tt.indexOf(".lst")<0) tt+=+".lst";
|
||
QString defaultTempleteFile=path+tt;
|
||
FILE *fp=fopen(defaultTempleteFile.toStdString().c_str(),"wt");
|
||
if(fp)
|
||
{
|
||
fprintf(fp,"%s\n",ttabname.toStdString().c_str());
|
||
fprintf(fp,"%d %d %d ",m_pListTableInf->Table_Field_Num,
|
||
m_pListTableInf->m_Mode,
|
||
m_pListTableInf->m_Flag);
|
||
QString cs=m_pDialog->textEdit->toPlainText();
|
||
cs.replace("\r\n"," ");
|
||
cs.replace("\r"," ");
|
||
cs.replace("\n"," ");
|
||
fprintf(fp,"%s\n",cs.toStdString().c_str());
|
||
|
||
for(int i=0;i<m_pListTableInf->Table_Field_Num;i++) {
|
||
QString text=m_pListTableInf->Table_Field[i].Name;
|
||
fprintf(fp,"%d %s",i,text.toStdString().c_str());
|
||
QString hz;
|
||
hz=m_pListTableInf->Table_Field[i].HZName;
|
||
fprintf(fp," %s",hz.toStdString().c_str());
|
||
|
||
QString Unit="NULL";
|
||
fprintf(fp," %s",Unit.toStdString().c_str());
|
||
|
||
QString Type;
|
||
if(m_pListTableInf->Table_Field[i].RepCode<1) m_pListTableInf->Table_Field[i].RepCode=1;
|
||
Type=DataTypea[m_pListTableInf->Table_Field[i].RepCode-1];
|
||
fprintf(fp," %s",Type.toStdString().c_str());
|
||
|
||
// QString Length;
|
||
char buf[100];
|
||
sprintf(buf,"%d",m_pListTableInf->Table_Field[i].Length);
|
||
fprintf(fp," %s",buf);
|
||
|
||
fprintf(fp," %s",m_pListTableInf->ZdIndex[i]);
|
||
|
||
QString valfrom;
|
||
valfrom=ZDType[m_pListTableInf->Type[i]];
|
||
fprintf(fp," %s",valfrom.toStdString().c_str());
|
||
|
||
QString RName;
|
||
RName=m_pListTableInf->RenName[i];
|
||
fprintf(fp," %s",RName.toStdString().c_str());
|
||
QString ValueMode=GetValueModeStr[m_pListTableInf->GetValueMode[i]];
|
||
|
||
if(valfrom=="字段"&&ValueMode=="平均值") ValueMode="NULL";
|
||
fprintf(fp," %s\n",ValueMode.toStdString().c_str());
|
||
}
|
||
fprintf(fp," %d %d %d\n",m_pListTableInf->lstm,m_pListTableInf->IsHB,m_pListTableInf->IsFC);
|
||
fprintf(fp,"%s\n",m_pListTableInf->m_TableType);
|
||
fprintf(fp,"%s\n",m_pListTableInf->m_TableSpFIELD);
|
||
cs=m_pDialog->textEdit_2->toPlainText();
|
||
/* cs.replace("\r\n"," ");
|
||
cs.replace("\r"," ");
|
||
cs.replace("\n"," ");
|
||
*/
|
||
fprintf(fp,"%s\n",cs.toStdString().c_str());
|
||
fclose(fp);
|
||
}
|
||
AfxMessageBox("保存完成!");
|
||
}
|