927 lines
35 KiB
C++
927 lines
35 KiB
C++
#include "qtprojectwidgets.h"
|
||
#include <QMessageBox>
|
||
#include <QMenu>
|
||
#include <QFileDialog>
|
||
#include <QDebug>
|
||
#include <QFuture>
|
||
#include <QtConcurrent/QtConcurrent>
|
||
#include <functional> // 需要包含这个头文件来使用 std::bind
|
||
#include <QMainWindow>
|
||
#include "MainWindow.h"
|
||
#include "InDefTableDlg.h"
|
||
#include "qtcommonclass.h"
|
||
#include "CallManage.h"
|
||
//
|
||
#include "geometryutils.h"
|
||
#include "LogIO.h"
|
||
#include "WellLogProjectDialog.h"
|
||
#include "WellLogRoundDialog.h"
|
||
#include "WellLogDialog.h"
|
||
#include "WellDialog.h"
|
||
#include "ObjectGenralFactory.h"
|
||
#include "ImportdataDialog.h"
|
||
#include "CDataOutput.h"
|
||
#include "DataManagger.h"
|
||
|
||
extern QString g_prjname;
|
||
extern void AppendConsole(Priority priority, const QString &output);
|
||
|
||
QtProjectWidgets::QtProjectWidgets(QWidget *parent)
|
||
: QWidget(parent)
|
||
, ui(new Ui::QtProjectWidgetsClass())
|
||
{
|
||
ui->setupUi(this);
|
||
//
|
||
QFont font("微软雅黑", 12, QFont::Bold, false);
|
||
QColor _fontColor = QColor(220, 220, 220);
|
||
QtCommonClass *qtCommon = new QtCommonClass(this);
|
||
qtCommon->setButtonIconWithText(ui->btnFind, ":/image/find.png", "", font, _fontColor);
|
||
|
||
//initTreeWidget("", "wwer");
|
||
|
||
connect(ui->btnFind, &QPushButton::clicked, this, [ = ]()
|
||
{
|
||
qDebug()<<"btnFind clicked";
|
||
AppendConsole(PAI_INFO, "btnFind clicked...");
|
||
|
||
//emit CallManage::getInstance()->sig_Find();
|
||
});
|
||
|
||
//关联信号槽,新建评估工程
|
||
connect(CallManage::getInstance(), SIGNAL(sig_NewProject()), this, SLOT(s_NewProject()));
|
||
//关联信号槽,打开评估工程
|
||
connect(CallManage::getInstance(), SIGNAL(sig_OpenProject(QString)), this, SLOT(s_OpenProject(QString)));
|
||
|
||
//初始化树形控件中的右键菜单
|
||
initMenu();
|
||
|
||
//为树 tree 创建信号槽,鼠标press时会触发对应的信号。
|
||
connect(ui->treeWidget, &QTreeWidget::itemPressed, this, &QtProjectWidgets::onItemClicked);
|
||
//connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &QtProjectWidgets::onItemChanged);
|
||
}
|
||
|
||
QtProjectWidgets::~QtProjectWidgets()
|
||
{
|
||
delete ui;
|
||
}
|
||
|
||
//初始化树图控件
|
||
void QtProjectWidgets::initTreeWidget(QString fullPath, QString strProjectName)
|
||
{
|
||
ui->treeWidget->setColumnCount(1); //设置列数
|
||
ui->treeWidget->setHeaderHidden(true); // 隐藏表头
|
||
ui->treeWidget->clear();//清理数据
|
||
|
||
QTreeWidgetItem *itemRoot = new QTreeWidgetItem();
|
||
itemRoot->setText(0, strProjectName);
|
||
itemRoot->setData(0, Qt::UserRole, "root"); // 存储额外数据,如ID
|
||
|
||
//
|
||
QIcon icon;
|
||
icon.addPixmap(QPixmap(":/image/left_folder.png"), QIcon::Selected); //选中时的状态
|
||
icon.addPixmap(QPixmap(":/image/left_folder.png"), QIcon::Normal); //未选中是的状态
|
||
itemRoot->setIcon(0, icon);
|
||
// 这是一个根节点
|
||
ui->treeWidget->addTopLevelItem(itemRoot);
|
||
|
||
//展开树图
|
||
ui->treeWidget->expandAll();
|
||
}
|
||
|
||
//初始化树图控件
|
||
void QtProjectWidgets::s_initTreeWidget(QString strName)
|
||
{
|
||
//
|
||
ui->treeWidget->setColumnCount(1); //设置列数
|
||
ui->treeWidget->setHeaderHidden(true); // 隐藏表头
|
||
ui->treeWidget->clear();//清理数据
|
||
|
||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||
item->setText(0, strName);
|
||
item->setData(0, Qt::UserRole, "root"); // 存储额外数据,如ID
|
||
//item->setData(0, Qt::UserRole + 1, evaluationInfo.guid); // 存储额外数据,如ID
|
||
//
|
||
QIcon icon;
|
||
icon.addPixmap(QPixmap(":/image/left_folder.png"), QIcon::Selected);
|
||
icon.addPixmap(QPixmap(":/image/left_folder.png"), QIcon::Normal);
|
||
item->setIcon(0, icon);
|
||
// 这是一个根节点
|
||
ui->treeWidget->addTopLevelItem(item);
|
||
|
||
//获取根节点
|
||
QTreeWidgetItem *parent = ui->treeWidget->topLevelItem(0);
|
||
|
||
//指标体系
|
||
QTreeWidgetItem *itemIndex = new QTreeWidgetItem();
|
||
itemIndex->setText(0, "井组");
|
||
itemIndex->setData(0, Qt::UserRole, "indexsys"); // 存储额外数据,如ID
|
||
//
|
||
itemIndex->setIcon(0, icon);
|
||
parent->addChild(itemIndex);//添加一级子节点
|
||
|
||
//评估任务
|
||
QTreeWidgetItem *itemTask = new QTreeWidgetItem();
|
||
itemTask->setText(0, ("数据分析"));
|
||
itemTask->setData(0, Qt::UserRole, "task"); // 存储额外数据,如ID
|
||
//
|
||
itemTask->setIcon(0, icon);
|
||
parent->addChild(itemTask);//添加一级子节点
|
||
|
||
//展开树图
|
||
ui->treeWidget->expandItem(parent);
|
||
}
|
||
|
||
//加载指标体系--树图节点
|
||
void QtProjectWidgets::s_loadTreeWidget(QString fileFull)
|
||
{
|
||
//
|
||
ui->treeWidget->setColumnCount(1); //设置列数
|
||
ui->treeWidget->setHeaderHidden(true); // 隐藏表头
|
||
ui->treeWidget->clear();//清理数据
|
||
|
||
//
|
||
QFileInfo fileinfo;
|
||
fileinfo = QFileInfo(fileFull);
|
||
//
|
||
QString fileName = fileinfo.fileName();
|
||
QString fileNameOnly = "";
|
||
if(fileName.right(4)==".wwl")
|
||
{
|
||
fileNameOnly = fileName.left(fileName.size()-strlen(".wwl"));
|
||
}
|
||
else {
|
||
return;
|
||
}
|
||
g_prjname = fileNameOnly;
|
||
|
||
//
|
||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||
item->setText(0, g_prjname);
|
||
item->setData(0, Qt::UserRole, "root"); // 存储额外数据,如ID
|
||
//item->setData(0, Qt::UserRole + 1, evaluationInfo.guid); // 存储额外数据,如ID
|
||
//
|
||
QIcon icon;
|
||
icon.addPixmap(QPixmap(":/image/left_folder.png"), QIcon::Selected);
|
||
icon.addPixmap(QPixmap(":/image/left_folder.png"), QIcon::Normal);
|
||
item->setIcon(0, icon);
|
||
// 这是一个根节点
|
||
ui->treeWidget->addTopLevelItem(item);
|
||
|
||
//获取根节点
|
||
QTreeWidgetItem *parent = ui->treeWidget->topLevelItem(0);
|
||
|
||
//井组
|
||
QTreeWidgetItem *itemIndex = new QTreeWidgetItem();
|
||
itemIndex->setText(0, ("井组"));
|
||
itemIndex->setData(0, Qt::UserRole, "wells"); // 存储额外数据,如ID
|
||
//
|
||
itemIndex->setIcon(0, icon);
|
||
parent->addChild(itemIndex);//添加一级子节点
|
||
//数据导入
|
||
loadIndexSysTree(itemIndex, fileFull, g_prjname);
|
||
|
||
//数据分析
|
||
QTreeWidgetItem *itemTask = new QTreeWidgetItem();
|
||
itemTask->setText(0, ("数据分析"));
|
||
itemTask->setData(0, Qt::UserRole, "dataAnalyze"); // 存储额外数据,如ID
|
||
//
|
||
itemTask->setIcon(0, icon);
|
||
parent->addChild(itemTask);//添加一级子节点
|
||
//数据导入
|
||
//loadTaskTree(itemTask);
|
||
|
||
//展开树图
|
||
ui->treeWidget->expandItem(parent);
|
||
}
|
||
|
||
void QtProjectWidgets::loadIndexSysTree(QTreeWidgetItem *parent, QString fileFull, QString prjname)
|
||
{
|
||
//Logdata
|
||
QString folderPath;
|
||
folderPath = GetLogdataPath();
|
||
folderPath = folderPath + prjname;
|
||
folderPath = folderPath + "/";
|
||
//
|
||
QDir dir;
|
||
if (!dir.exists(folderPath)) { // 如果目录不存在,则创建它。
|
||
if (!dir.mkpath(folderPath)) { // mkpath 尝试创建所有必需的中间目录。
|
||
qDebug() << "Failed to create directory:" << folderPath;
|
||
} else {
|
||
qDebug() << "Directory created:" << folderPath;
|
||
}
|
||
}
|
||
|
||
//-------------------
|
||
QStringList listFolders;
|
||
QFileInfo mfi(folderPath);
|
||
if(!mfi.isDir())
|
||
{
|
||
//井文件 *.wwl
|
||
if(!mfi.isFile())
|
||
{
|
||
return;
|
||
}
|
||
//listFiles.append(folderPath);
|
||
}
|
||
else
|
||
{
|
||
//井目录
|
||
//取当前当前目录内容
|
||
QDir dir(folderPath);
|
||
dir.setFilter(QDir::Dirs |QDir::NoDotAndDotDot |QDir::Files | QDir::NoSymLinks);
|
||
QFileInfoList list = dir.entryInfoList();
|
||
int file_count = list.count();
|
||
if(file_count <= 0)//判断目录是否为空,空目录返回
|
||
{
|
||
return;
|
||
}
|
||
//取当前目录内容,符合后缀文件
|
||
QStringList string_list;
|
||
for(int i=0; i<list.size();i++)
|
||
{
|
||
QFileInfo file_info = list.at(i);
|
||
if(file_info.isDir())
|
||
{
|
||
//#JPH-307
|
||
QString absolute_file_path = file_info.absoluteFilePath();
|
||
if(absolute_file_path.at(absolute_file_path.length()-1)==' ') {
|
||
dir.rmdir(absolute_file_path);
|
||
continue;
|
||
}
|
||
listFolders.append(absolute_file_path);
|
||
}
|
||
}
|
||
}
|
||
QStringList wellfiles;
|
||
foreach(QString wellFolder, listFolders )
|
||
{
|
||
QFileInfo w(wellFolder);//#JPH-307
|
||
if(w.isDir())
|
||
{
|
||
chakan(wellFolder, wellfiles, "*.well");
|
||
}
|
||
}
|
||
|
||
QStringList wellNames;
|
||
foreach(QString wellFile1, wellfiles )
|
||
{
|
||
QString filename=wellFile1;
|
||
//----------------
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(filename.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
QString aa=filename+"文件打开失败,请检查!";
|
||
qDebug() << aa;
|
||
//AppendConsole(pai::log::PAI_ERROR,aa);
|
||
//return;
|
||
continue;
|
||
}
|
||
//
|
||
QString wellname="";
|
||
Slf_FILE_MESSAGE mssage;
|
||
logio->GetFileMessage(mssage);
|
||
wellname=mssage.WellName;
|
||
wellname=wellname.toUpper();
|
||
if (wellname.isEmpty()||wellname.length()>64||wellname.indexOf('&')>-1)
|
||
{
|
||
//辨别井名是否有效,无效则采用文件名
|
||
QFileInfo fileInfo(filename);
|
||
QString strWellName = fileInfo.completeBaseName();
|
||
strWellName=strWellName.toUpper();
|
||
//
|
||
wellname=strWellName.toStdString().c_str();
|
||
int len=strlen(strWellName.toStdString().c_str());
|
||
if(len>sizeof(mssage.WellName)) len=sizeof(mssage.WellName);
|
||
strncpy(mssage.WellName,strWellName.toStdString().c_str(),len);
|
||
mssage.WellName[len]=0;
|
||
logio->SetFileMessage(mssage);
|
||
}
|
||
wellname=wellname.toUpper();
|
||
|
||
//查找是否已经存在该井和井次
|
||
if(wellNames.contains(wellname))
|
||
{
|
||
delete logio;
|
||
continue;
|
||
}
|
||
wellNames.append(wellname);
|
||
|
||
//挂接到树
|
||
//井名称
|
||
QTreeWidgetItem *itemIndex = new QTreeWidgetItem();
|
||
itemIndex->setText(0, wellname);
|
||
itemIndex->setData(0, Qt::UserRole, "wellname"); // 存储额外数据,如ID
|
||
itemIndex->setData(0, Qt::UserRole + 1, wellFile1); // 存储额外数据,项目名
|
||
//
|
||
QIcon icon;
|
||
icon.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Selected);
|
||
icon.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Normal);
|
||
itemIndex->setIcon(0, icon);
|
||
//
|
||
parent->addChild(itemIndex);//添加一级子节点
|
||
//关闭logio
|
||
delete logio;
|
||
|
||
//加载*.slf
|
||
QStringList slffiles;
|
||
QString pathTmp=GetLogdataPath();
|
||
pathTmp+=prjname+"/#"+wellname;
|
||
chakan(pathTmp, slffiles, "*.slf");
|
||
foreach(QString slfFile1, slffiles )
|
||
{
|
||
loadWellTree(itemIndex, slfFile1, wellname);
|
||
}
|
||
}
|
||
}
|
||
|
||
void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, QString parentWellname)
|
||
{
|
||
//表格数据
|
||
QTreeWidgetItem *itemSheet = new QTreeWidgetItem();
|
||
itemSheet->setText(0, "表格数据");
|
||
itemSheet->setData(0, Qt::UserRole, "Sheet"); // 存储额外数据,如ID
|
||
//itemSheet->setData(0, Qt::UserRole + 1, indexSysInfo.at(1).toString()); // 存储额外数据,如ID
|
||
//
|
||
QIcon iconSheet;
|
||
iconSheet.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Selected);
|
||
iconSheet.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Normal);
|
||
itemSheet->setIcon(0, iconSheet);
|
||
|
||
|
||
//参数卡
|
||
QTreeWidgetItem *itemParameterCard = new QTreeWidgetItem();
|
||
itemParameterCard->setText(0, "参数卡");
|
||
itemParameterCard->setData(0, Qt::UserRole, "ParameterCard"); // 存储额外数据,如ID
|
||
//itemParameterCard->setData(0, Qt::UserRole + 1, indexSysInfo.at(1).toString()); // 存储额外数据,如ID
|
||
//
|
||
QIcon iconParameterCard;
|
||
iconParameterCard.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Selected);
|
||
iconParameterCard.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Normal);
|
||
itemParameterCard->setIcon(0, iconParameterCard);
|
||
|
||
//曲线
|
||
QTreeWidgetItem *itemCurve = new QTreeWidgetItem();
|
||
itemCurve->setText(0, "曲线");
|
||
itemCurve->setData(0, Qt::UserRole, "Curve"); // 存储额外数据,如ID
|
||
//itemAddLog->setData(0, Qt::UserRole + 1, indexSysInfo.at(1).toString()); // 存储额外数据,如ID
|
||
//
|
||
QIcon iconCurve;
|
||
iconCurve.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Selected);
|
||
iconCurve.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Normal);
|
||
itemCurve->setIcon(0, iconCurve);
|
||
|
||
//波列数据
|
||
QTreeWidgetItem *itemWave = new QTreeWidgetItem();
|
||
itemWave->setText(0, "波列数据");
|
||
itemWave->setData(0, Qt::UserRole, "Wave"); // 存储额外数据,如ID
|
||
//itemWave->setData(0, Qt::UserRole + 1, indexSysInfo.at(1).toString()); // 存储额外数据,如ID
|
||
//
|
||
QIcon iconWave;
|
||
iconWave.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Selected);
|
||
iconWave.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Normal);
|
||
itemWave->setIcon(0, iconWave);
|
||
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(fileFull.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
QString aa=fileFull+"文件打开失败,请检查!";
|
||
qDebug() << aa;
|
||
//AppendConsole(pai::log::PAI_ERROR,aa);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
Slf_FILE_MESSAGE mssage;
|
||
logio->GetFileMessage(mssage);
|
||
|
||
if(parent->text(0) != QString(mssage.WellName))
|
||
{
|
||
delete logio;
|
||
return;
|
||
}
|
||
QString wellname=mssage.Item;
|
||
if (wellname.isEmpty()||wellname.length()>64||wellname.indexOf('&')>-1)
|
||
{
|
||
QFileInfo fileinfo;
|
||
fileinfo = QFileInfo(fileFull);
|
||
wellname = fileinfo.completeBaseName();
|
||
}
|
||
// if(wellname != parentWellname)
|
||
// {
|
||
// //井次名称不一致
|
||
// qDebug() << "井次名称不一致";
|
||
// delete logio;
|
||
// return;
|
||
// }
|
||
//井次名称
|
||
QTreeWidgetItem *itemwell = new QTreeWidgetItem();
|
||
itemwell->setText(0, wellname);
|
||
itemwell->setData(0, Qt::UserRole, "wellItem"); // 存储额外数据,如ID
|
||
itemwell->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||
//
|
||
QIcon iconwell;
|
||
iconwell.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Selected);
|
||
iconwell.addPixmap(QPixmap(":/image/left_index.png"), QIcon::Normal);
|
||
itemwell->setIcon(0, iconwell);
|
||
|
||
parent->addChild(itemwell);//添加一级子节点
|
||
|
||
|
||
// int nObjectCount = logio-> GetWisObjectCount();
|
||
// int nSlfCount = logio-> GetSlfObjectCount();
|
||
// Slf_TABLE_ENTRY *pEntry = new Slf_TABLE_ENTRY[nSlfCount];
|
||
// logio-> GetAllSlfObjectEntry(pEntry,nSlfCount);
|
||
|
||
char* curvename=new char[65];
|
||
curvename[64]='\0';
|
||
char* aliasname=new char[65];
|
||
aliasname[64]='\0';
|
||
//
|
||
int nSlfCount = logio->GetObjectCount();
|
||
for(int i = 0; i< nSlfCount; i++)
|
||
{
|
||
logio->GetObjectName(i,curvename,NULL,aliasname);
|
||
if(!logio->IsObject(i)) {
|
||
logio->DiscardObject(i);
|
||
continue;
|
||
};
|
||
if(logio->GetObjectStatus(i)!=OBJECT_NORMAL)
|
||
{
|
||
continue;
|
||
}
|
||
short curvetype=logio->GetObjectType(i);
|
||
//
|
||
short Attribute=0,SubAttribute=0;
|
||
logio->GetObjectAttribute(i,&Attribute,&SubAttribute);
|
||
|
||
QString strCurveName = QString::fromLocal8Bit(curvename);
|
||
if(curvetype>CARD_OBJECT || 0 == curvetype)
|
||
{
|
||
qDebug() << "strCurveName: " << strCurveName;
|
||
//表格数据-》树图
|
||
QTreeWidgetItem *itemSheetChild = new QTreeWidgetItem();
|
||
itemSheetChild->setText(0, strCurveName);
|
||
itemSheetChild->setData(0, Qt::UserRole, "tableObject"); // 存储额外数据,如ID
|
||
itemSheetChild->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||
itemSheetChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||
itemSheetChild->setIcon(0, iconSheet);
|
||
//在创建的每个节点下,加上下面代码
|
||
// itemSheetChild->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsDragEnabled); //设置树形控件子项的属性
|
||
// itemSheetChild->setCheckState(0, Qt::Unchecked);//也可以是其他状态
|
||
|
||
if (0 == itemSheet->childCount())
|
||
{
|
||
itemwell->addChild(itemSheet);//添加一级子节点
|
||
}
|
||
itemSheet->addChild(itemSheetChild);
|
||
}
|
||
else if(CURVE_OBJECT == curvetype)
|
||
{
|
||
//判断曲线有效性
|
||
Slf_CURVE acurveinfo;
|
||
logio->GetCurveInfo(i,&acurveinfo);
|
||
if(acurveinfo.DepLevel!=0&&(acurveinfo.EndDepth-acurveinfo.StartDepth>0))
|
||
{
|
||
if(acurveinfo.MaxValue==acurveinfo.MinValue||acurveinfo.MaxValue==-99999||acurveinfo.MaxValue==-9999||acurveinfo.MinValue==999999||acurveinfo.MinValue==999999||acurveinfo.MinValue==99999||acurveinfo.MinValue==99999||acurveinfo.MinValue==-9999){
|
||
int curveindex=logio->OpenSlfTable(i,-1);
|
||
if(curveindex>-1)
|
||
{
|
||
MyDataTypeEnum vVdl;
|
||
DWORD count=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
DWORD len=count*acurveinfo.CodeLen;
|
||
acurveinfo.MinValue=99999999;
|
||
acurveinfo.MaxValue=-99999999;
|
||
if(acurveinfo.CodeLen==8) acurveinfo.MinValue=99999999;
|
||
vVdl.vchar=new char[len];
|
||
len=logio->ReadCurve(curveindex, acurveinfo.StartDepth,count,(void *)vVdl.vchar);
|
||
if(!len) {
|
||
QString cs;
|
||
char buf[1000];
|
||
sprintf(buf,"%s %f-%f",acurveinfo.Name,acurveinfo.StartDepth,acurveinfo.EndDepth);
|
||
cs=buf;
|
||
int flag = QMessageBox::warning(NULL,"提示",QString(cs+"\n曲线信息异常!删除该曲线可能需要较长时间,建议复制正常曲线等信息到新文件,然后删除此文件。是否此时直接将该曲线删除?"),QMessageBox::Yes,QMessageBox::No);
|
||
if(flag==QMessageBox::Yes) logio->DiscardObject(i);
|
||
delete vVdl.vchar;
|
||
continue;
|
||
}
|
||
for(int kk=0;kk<count;kk=kk+10)
|
||
{
|
||
float buf[200];
|
||
buf[0]=0;
|
||
float temp=logio->GetData(acurveinfo.RepCode,&vVdl.vchar[kk*acurveinfo.CodeLen],buf);
|
||
if(_isnan(temp)||!_finite(temp)) continue;
|
||
|
||
if(acurveinfo.MaxValue<temp) if(temp!=-9999.0&&temp!=-999.25&&temp!=-99999.0)acurveinfo.MaxValue=temp;
|
||
if(acurveinfo.MinValue>temp) if(temp!=-9999.0&&temp!=-999.25&&temp!=-99999.0)acurveinfo.MinValue=temp;
|
||
}
|
||
logio->SetCurveInfo(curveindex,&acurveinfo);
|
||
delete vVdl.vchar;
|
||
}
|
||
}
|
||
}
|
||
else if(acurveinfo.DepLevel==0||acurveinfo.StartDepth<-100000||acurveinfo.StartDepth>100000)
|
||
{
|
||
QString cs;
|
||
char buf[1000];
|
||
sprintf(buf,"%s %f-%f",acurveinfo.Name,acurveinfo.StartDepth,acurveinfo.EndDepth);
|
||
cs=buf;
|
||
int flag = QMessageBox::warning(NULL,"提示",QString(cs+"\n曲线信息异常!删除该曲线可能需要较长时间,建议复制正常曲线等信息到新文件,然后删除此文件。是否此时直接将该曲线删除?"),QMessageBox::Yes,QMessageBox::No);
|
||
if(flag==QMessageBox::Yes) logio->DiscardObject(i);
|
||
continue;
|
||
}
|
||
|
||
//曲线-》树图
|
||
QTreeWidgetItem *itemCurveLog = new QTreeWidgetItem();
|
||
itemCurveLog->setText(0, strCurveName);
|
||
itemCurveLog->setData(0, Qt::UserRole, "curveObject"); // 存储额外数据,如ID
|
||
itemCurveLog->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||
itemCurveLog->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||
itemCurveLog->setIcon(0, iconSheet);
|
||
//在创建的每个节点下,加上下面代码(check框)
|
||
// itemCurveLog->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsDragEnabled); //设置树形控件子项的属性
|
||
// itemCurveLog->setCheckState(0, Qt::Unchecked);//也可以是其他状态
|
||
if (0 == itemCurve->childCount())
|
||
{
|
||
itemwell->addChild(itemCurve);//添加一级子节点
|
||
}
|
||
itemCurve->addChild(itemCurveLog);
|
||
}
|
||
else if(CARD_OBJECT == curvetype)
|
||
{
|
||
//参数卡-》树图
|
||
QTreeWidgetItem *itemCardChild = new QTreeWidgetItem();
|
||
itemCardChild->setText(0, strCurveName);
|
||
itemCardChild->setIcon(0, iconSheet);
|
||
if (0 == itemParameterCard->childCount())
|
||
{
|
||
itemwell->addChild(itemParameterCard);//添加一级子节点
|
||
}
|
||
itemParameterCard->addChild(itemCardChild);
|
||
}
|
||
else if(WAVE_OBJECT == curvetype)
|
||
{
|
||
//波列-》树图
|
||
QTreeWidgetItem *itemWaveChild = new QTreeWidgetItem();
|
||
itemWaveChild->setText(0, strCurveName);
|
||
itemWaveChild->setData(0, Qt::UserRole, "waveObject"); // 存储额外数据,如ID
|
||
itemWaveChild->setData(0, Qt::UserRole + 1, fileFull); // 存储额外数据,井次文件路径
|
||
itemWaveChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||
itemWaveChild->setIcon(0, iconSheet);
|
||
if (0 == itemWave->childCount())
|
||
{
|
||
itemwell->addChild(itemWave);//添加一级子节点
|
||
}
|
||
itemWave->addChild(itemWaveChild);
|
||
}
|
||
}
|
||
delete []curvename;
|
||
delete []aliasname;
|
||
delete logio;
|
||
//delete []pEntry;
|
||
}
|
||
}
|
||
|
||
//初始化树形控件中的右键菜单
|
||
void QtProjectWidgets::initMenu()
|
||
{
|
||
//根节点(项目名称)-右键菜单
|
||
_menuRoot = new QMenu(ui->treeWidget);
|
||
initRootTreeMenu(_menuRoot, ui->treeWidget);
|
||
|
||
//曲线对象-右键菜单
|
||
_menuCurveObject = new QMenu(ui->treeWidget);
|
||
initCurveObjectTreeMenu(_menuCurveObject, ui->treeWidget);
|
||
|
||
//表格对象-右键菜单
|
||
_menuTableObject = new QMenu(ui->treeWidget);
|
||
initTableObjectTreeMenu(_menuTableObject, ui->treeWidget);
|
||
|
||
_menuWellName = new QMenu(ui->treeWidget);
|
||
initWellNameTreeMenu(_menuWellName, ui->treeWidget);
|
||
|
||
_menuSlfName = new QMenu(ui->treeWidget);
|
||
initSlfNameTreeMenu(_menuSlfName, ui->treeWidget);
|
||
|
||
// //评估方案-右键菜单
|
||
// _menuEvaluate = new QMenu(ui->treeWidget);
|
||
// initEvaluateTreeMenu(_menuEvaluate, ui->treeWidget);
|
||
|
||
}
|
||
|
||
//初始化根节点(项目名称)-右键菜单
|
||
void QtProjectWidgets::initRootTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
||
{
|
||
m_action_New = new QAction("新建项目", treeWidget);
|
||
m_action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(m_action_New, SIGNAL(triggered(bool)), this, SLOT(onNewProject(bool)));
|
||
menu->addAction(m_action_New);
|
||
|
||
//
|
||
m_action_Open = new QAction("打开项目", treeWidget);
|
||
m_action_Open->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(m_action_Open, SIGNAL(triggered(bool)), this, SLOT(onOpenProject(bool)));
|
||
menu->addAction(m_action_Open);
|
||
|
||
}
|
||
|
||
//初始化曲线对象(AC、BS...)-右键菜单
|
||
void QtProjectWidgets::initCurveObjectTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
||
{
|
||
m_action_ShowCurve = new QAction("数据查看", treeWidget);
|
||
m_action_ShowCurve->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(m_action_ShowCurve, SIGNAL(triggered(bool)), this, SLOT(onShowCurve(bool)));
|
||
menu->addAction(m_action_ShowCurve);
|
||
}
|
||
|
||
//初始化表格对象-右键菜单
|
||
void QtProjectWidgets::initTableObjectTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
||
{
|
||
QAction* action_TableObject = new QAction("数据查看", treeWidget);
|
||
action_TableObject->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(action_TableObject, SIGNAL(triggered(bool)), this, SLOT(onShowTable(bool)));
|
||
menu->addAction(action_TableObject);
|
||
}
|
||
|
||
//初始化根节点(井名称)-右键菜单
|
||
void QtProjectWidgets::initWellNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
||
{
|
||
QAction* action_New = new QAction("导入数据", treeWidget);
|
||
action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onImportSingleWellLogData()));
|
||
menu->addAction(action_New);
|
||
|
||
action_New = new QAction("导入离散数据", treeWidget);
|
||
action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onImportSlfTable()));
|
||
menu->addAction(action_New);
|
||
|
||
action_New = new QAction("编辑井基本信息", treeWidget);
|
||
action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onEditWelllogRound()));
|
||
menu->addAction(action_New);
|
||
|
||
action_New = new QAction("输出数据", treeWidget);
|
||
action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onOutWellLogRound()));
|
||
menu->addAction(action_New);
|
||
}
|
||
|
||
//初始化根节点(井次名称)-右键菜单
|
||
void QtProjectWidgets::initSlfNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
||
{
|
||
QAction* action_New = new QAction("编辑测井信息", treeWidget);
|
||
action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
|
||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onWelllogInformation()));
|
||
menu->addAction(action_New);
|
||
}
|
||
|
||
//新建项目
|
||
void QtProjectWidgets::onNewProject(bool checked)
|
||
{
|
||
s_NewProject();
|
||
}
|
||
|
||
//打开项目
|
||
void QtProjectWidgets::onOpenProject(bool checked)
|
||
{
|
||
emit CallManage::getInstance()->sig_Open();
|
||
}
|
||
|
||
void QtProjectWidgets::s_NewProject()
|
||
{
|
||
ui->treeWidget->clear();//清理数据
|
||
emit CallManage::getInstance()->sig_CloseProject();//关闭tab页
|
||
|
||
// 创建对话框
|
||
CWellLogProjectDialog* dialog = new CWellLogProjectDialog();
|
||
dialog->Init();
|
||
int result = dialog->exec();//对话框
|
||
if (result == QDialog::Accepted) {
|
||
// 处理用户点击了确定按钮的逻辑
|
||
qDebug() << "Accepted=" << dialog->m_strNewName;
|
||
//加载左侧树图
|
||
QString strProjectFolder = GetProjectFolder();
|
||
QString strProjectFile = strProjectFolder + dialog->m_strNewName;
|
||
strProjectFile += ".wwl";
|
||
s_loadTreeWidget(strProjectFile);
|
||
}
|
||
else if (result == QDialog::Rejected) {
|
||
// 处理用户点击了取消按钮的逻辑
|
||
qDebug() << "Rejected=";
|
||
}
|
||
else {
|
||
// 处理其他情况的逻辑
|
||
qDebug() << "other=";
|
||
}
|
||
}
|
||
|
||
void QtProjectWidgets::s_OpenProject(QString fileFull)
|
||
{
|
||
ui->treeWidget->clear();//清理数据
|
||
emit CallManage::getInstance()->sig_CloseProject();//关闭tab页
|
||
|
||
s_loadTreeWidget(fileFull);
|
||
}
|
||
|
||
//数据查看
|
||
void QtProjectWidgets::onShowCurve(bool checked)
|
||
{
|
||
emit CallManage::getInstance()->sig_ShowCurve(m_strSlfName, m_strCurveObjectName);
|
||
}
|
||
|
||
//表格数据查看
|
||
void QtProjectWidgets::onShowTable(bool checked)
|
||
{
|
||
emit CallManage::getInstance()->sig_ShowTable(m_strSlfName, m_strCurveObjectName);
|
||
}
|
||
|
||
//编辑测井信息
|
||
void QtProjectWidgets::onWelllogInformation()
|
||
{
|
||
emit CallManage::getInstance()->sig_WelllogInformation(m_strSlfName, m_strCurveObjectName);
|
||
}
|
||
|
||
void QtProjectWidgets::onEditWelllogRound()
|
||
{
|
||
QTreeWidgetItem *wellItem = *ui->treeWidget->selectedItems().begin();
|
||
|
||
QString strTreeTag = wellItem->data(0, Qt::UserRole + 1).toString();
|
||
|
||
//WellLogDialog* wdia = new WellLogDialog();
|
||
//CWellLogRoundDialog* wdia = new CWellLogRoundDialog();
|
||
MyWelllogRound WelllogRound;
|
||
WelllogRound.LoadMeesge(strTreeTag);
|
||
CWellDialog* wdia = new CWellDialog();
|
||
wdia->wellLR = WelllogRound;
|
||
wdia->Init();
|
||
if ( wdia->exec() == QDialog::Accepted )
|
||
{
|
||
// if(strWelllogRoundName != "")
|
||
// {
|
||
// pWelllogRound->setObjectName(strWelllogRoundName);
|
||
// }
|
||
QMessageBox::information(this,"2",strTreeTag);
|
||
}
|
||
|
||
//QMessageBox::information(this,"1",strTreeTag);
|
||
}
|
||
|
||
void QtProjectWidgets::onImportSingleWellLogData()
|
||
{
|
||
MainWindow* pMainWindow = nullptr;
|
||
|
||
foreach (QWidget *w, qApp->topLevelWidgets())
|
||
{
|
||
if (QMainWindow* mainWin = qobject_cast<QMainWindow*>(w))
|
||
{
|
||
pMainWindow = dynamic_cast<MainWindow *>(mainWin);
|
||
}
|
||
}
|
||
|
||
if (pMainWindow)
|
||
{
|
||
// InterfaceWidget *pInterfaceWidget = new InterfaceWidget();//中间工作区
|
||
// pMainWindow->m_centerWidgets->addTab(pInterfaceWidget, "导入数据");
|
||
pai::datamodel::LoadAllPlugin("windows");
|
||
QStringList listFiles;//=GetFileNames("选择数据文件",fileSuffix,QFileDialog::ExistingFiles);
|
||
QString file_name = QFileDialog::getOpenFileName(this,tr("打开测井数据文件"), "","*.txt", 0);
|
||
// listFiles.append(QString("D:/LogPlus/OutData/jph-307.txt"));
|
||
listFiles.append(file_name);
|
||
DiDepthProgress DepthProgress;
|
||
ConvertorManager::GetInstance().LoadAllConvertorPlugin();
|
||
ConvertorManager &pManager=ConvertorManager::GetInstance();
|
||
pManager.all=0;
|
||
QVector<QString>vSuffix=pManager.GetSupportFileExtensions();
|
||
QString fileSuffix("数据文件(");
|
||
QVector<IConvertor*> vConvertor=pManager.GetSupportConvertors(listFiles[0], &DepthProgress);
|
||
// if (vConvertor.empty()) return ;
|
||
if (vConvertor.empty())
|
||
{
|
||
QMessageBox::information(NULL,"无法识别的文件",listFiles[0]);
|
||
return ;
|
||
}
|
||
QTreeWidgetItem *wellItem = *ui->treeWidget->selectedItems().begin();
|
||
|
||
QString wellname = wellItem->text(0);
|
||
QString wellroundname = wellname;
|
||
ImportDataDialog *pDialog = new ImportDataDialog(NULL,wellname,wellroundname);
|
||
QTreeWidgetItem rootItem = *ui->treeWidget->topLevelItem(0);
|
||
pDialog->SetProjectname(rootItem.text(0));
|
||
pDialog->DisplayFileInformationAreaData(vConvertor,listFiles[0]);
|
||
if ( pDialog->exec() == QDialog::Accepted )
|
||
return ;
|
||
}
|
||
}
|
||
|
||
void QtProjectWidgets::onImportSlfTable()
|
||
{
|
||
// CInDefTableDlg InDefTableDlg(0);
|
||
// InDefTableDlg.exec();
|
||
CDataManagger *magr=new CDataManagger();
|
||
int CurItemType=-1;
|
||
CurItemType = 1;
|
||
QTreeWidgetItem *wellItem = *ui->treeWidget->selectedItems().begin();
|
||
|
||
QString wellname = wellItem->text(0);
|
||
QString wellroundname = wellname;
|
||
|
||
QString folderPath = GetLogdataPath();
|
||
folderPath = folderPath + g_prjname;
|
||
folderPath = folderPath + "/" + "#" + wellname + "/" + wellroundname + ".slf";
|
||
//QMessageBox::information(NULL,"标题",folderPath);
|
||
QStringList namelist;//=GetSelWellRound();
|
||
magr->dataInTable(CurItemType,wellname,folderPath);
|
||
}
|
||
|
||
void QtProjectWidgets::onOutWellLogRound()
|
||
{
|
||
QTreeWidgetItem *wellItem = *ui->treeWidget->selectedItems().begin();
|
||
|
||
QString wellname = wellItem->text(0);
|
||
QString wellroundname = wellname;
|
||
|
||
QString folderPath = GetLogdataPath();
|
||
folderPath = folderPath + g_prjname;
|
||
folderPath = folderPath + "/" + "#" + wellname + "/" + wellroundname + ".slf";
|
||
QStringList namelist;//=GetSelWellRound();
|
||
namelist<<folderPath;
|
||
QStringList curvelist;//=GetSelCurve();
|
||
CDataOutPut* moutPut=new CDataOutPut();
|
||
if(!moutPut)return;
|
||
moutPut->outWellLogRound(namelist,curvelist);
|
||
delete moutPut;
|
||
moutPut=NULL;
|
||
}
|
||
|
||
//点击树图节点
|
||
void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index)
|
||
{
|
||
QMenu *popMenu = NULL;
|
||
QString strTreeTag = item->data(0, Qt::UserRole).toString();
|
||
if (strTreeTag == "root")
|
||
{
|
||
//根节点(项目名称)-右键菜单
|
||
popMenu = _menuRoot;
|
||
}
|
||
else if (strTreeTag == "curveObject"){
|
||
//曲线对象(AC、BS...)-右键菜单
|
||
popMenu = _menuCurveObject;
|
||
m_strCurveObjectName = item->text(0);
|
||
m_strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||
}
|
||
else if (strTreeTag == "tableObject")
|
||
{
|
||
//表格对象
|
||
popMenu = _menuTableObject;
|
||
m_strCurveObjectName = item->text(0);
|
||
m_strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||
}
|
||
else if (strTreeTag == "wellname")
|
||
{
|
||
//根节点(项目名称)-右键菜单
|
||
popMenu = _menuWellName;
|
||
}
|
||
else if (strTreeTag == "wellItem")
|
||
{
|
||
//根节点(项目名称)-右键菜单
|
||
popMenu = _menuSlfName;
|
||
m_strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||
}
|
||
|
||
//
|
||
if (qApp->mouseButtons() == Qt::RightButton) // 只针对鼠标右键,弹出菜单
|
||
{
|
||
if (NULL == popMenu)
|
||
{
|
||
return;
|
||
}
|
||
popMenu->exec(QCursor::pos());
|
||
}
|
||
}
|
||
|
||
//勾选/不勾选树图节点
|
||
void QtProjectWidgets::onItemChanged(QTreeWidgetItem* item, int index)
|
||
{
|
||
// qDebug() << "QtProjectWidgets onItemChanged";
|
||
// QString strTreeTag = item->data(0, Qt::UserRole).toString();
|
||
// if (strTreeTag == "curveObject" || strTreeTag == "tableObject"){
|
||
// //曲线对象(AC、BS...) || 表格对象
|
||
// m_strCurveObjectName = item->text(0);
|
||
// m_strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||
// //
|
||
// bool bCkecked = false;
|
||
// if(item->checkState(0) == Qt::Checked)
|
||
// {
|
||
// bCkecked = true;
|
||
// }
|
||
// //曲线("*.slf", "AC", "curveObject", true)
|
||
// //表格("*.slf“, "LAYER_DATA", "tableObject", false)
|
||
// //(m_strSlfName, m_strCurveObjectName, strTreeTag, bCkecked)
|
||
|
||
// //插件测试(信号槽)
|
||
// emit CallManage::getInstance()->sig_testPlugin(m_strCurveObjectName);
|
||
// }
|
||
}
|