680 lines
20 KiB
C++
680 lines
20 KiB
C++
#include "formwell.h"
|
||
#include "ui_formwell.h"
|
||
#include "CallManage.h"
|
||
#include "qtColorSchemeComboBox.h"
|
||
#include "geometryutils.h"
|
||
#include "mainwindowcurve.h"
|
||
|
||
extern int g_iOneWidth; //道宽
|
||
//extern int m_iY1;
|
||
//extern int m_iY2;
|
||
extern double g_dPixelPerCm;//每厘米像素数
|
||
|
||
extern int g_iShow; //显示刻度
|
||
//井+道名
|
||
FormWell::FormWell(QWidget *parent, QString strWellName) :
|
||
QWidget(parent),
|
||
ui(new Ui::FormWell)
|
||
{
|
||
ui->setupUi(this);
|
||
m_parent = parent;
|
||
m_strWellName = strWellName;
|
||
|
||
//
|
||
ui->tableWidget->verticalHeader()->hide(); //行
|
||
//ui->tableWidget->horizontalHeader()->hide();//列
|
||
int rowcount = 3; //总行数
|
||
ui->tableWidget->setRowCount(rowcount); //动态设置行数
|
||
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
||
ui->tableWidget->horizontalHeader()->setFixedHeight(3);
|
||
|
||
ui->tableWidget->setStyleSheet( "QTableView::item:selected {color:#57595B; background:#E4E4E4;}");
|
||
|
||
// 假设你的类中有一个槽函数:onTableRowsInserted(QModelIndex parent, int first, int last)
|
||
//connect(ui->tableWidget->model(), &QAbstractItemModel::columnsInserted,
|
||
// this, &FormWell::onTableColumnsInserted);
|
||
// 设置右键菜单策略
|
||
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||
// 连接信号和槽
|
||
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||
|
||
//关联信号槽
|
||
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack(QString, QString, QString, QString, QString,int)), this, SLOT(s_NewTrack(QString, QString, QString, QString, QString,int)));
|
||
//关联信号槽
|
||
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack_No_Line(QString, QString, QString)), this, SLOT(s_NewTrack_No_Line(QString, QString, QString)));
|
||
|
||
connect(CallManage::getInstance(), SIGNAL(sig_NewTrack_No_Line(QString, QJsonObject, QJsonObject)), this, SLOT(slot_NewTrack_No_Line(QString, QJsonObject, QJsonObject)));
|
||
|
||
//曲线选中,置顶
|
||
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString, int, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString, int, QString)));
|
||
|
||
connect(CallManage::getInstance(), SIGNAL(sig_NewCol(QStringList)), this, SLOT(s_NewCol(QStringList)));
|
||
|
||
connect(CallManage::getInstance(), SIGNAL(sig_ChangeCross(QString, QString)),
|
||
this, SLOT(s_ChangeCross(QString, QString)));
|
||
|
||
connect(CallManage::getInstance(), SIGNAL(sig_ReplotFinished(QString)),
|
||
this, SLOT(s_ReplotFinished(QString)));
|
||
|
||
|
||
QtColorTableData::getInstance()->LoadScheme();
|
||
}
|
||
|
||
FormWell::~FormWell()
|
||
{
|
||
delete ui;
|
||
}
|
||
|
||
int FormWell::insertColumn(int nw)
|
||
{
|
||
auto table = ui->tableWidget;
|
||
int ncolCount = table->columnCount();
|
||
table->insertColumn(ncolCount);
|
||
table->setColumnWidth(ncolCount, nw);
|
||
|
||
table->setHorizontalHeaderItem(ncolCount, new QTableWidgetItem(""));
|
||
// ncolCount = table->columnCount();
|
||
return ncolCount;
|
||
}
|
||
|
||
QVector<QWidget *> FormWell::new_track(QStringList listdt, QString strTrackName)
|
||
{
|
||
QVector<QWidget *> vec;
|
||
QString strUuid = listdt.at(0);
|
||
QString strWellName = listdt.at(1);
|
||
QString strSlfName = listdt.at(2);
|
||
QString strLineName = listdt.at(3);
|
||
QString strType = listdt.at(4);
|
||
int nW = listdt.at(5).toInt();
|
||
|
||
//判断当前井是否与自己同名
|
||
if(strUuid != m_strUuid || strWellName != m_strWellName)
|
||
{
|
||
return vec;
|
||
}
|
||
|
||
if(nW <= 0)
|
||
nW = g_iOneWidth;
|
||
|
||
//增加1列
|
||
int columnCount = this->insertColumn(nW);
|
||
|
||
if(strTrackName.length() <= 0)
|
||
{
|
||
//道名
|
||
strTrackName = "道" + QString::number(columnCount+1);
|
||
if(strType == "depthObject")
|
||
strTrackName = "深度";
|
||
else if(strType == "roseObject")
|
||
strTrackName = "玫瑰图";
|
||
else if(strType == "dcaObject")
|
||
strTrackName = "DCA检测";
|
||
else if(strType == "tdtObject")
|
||
strTrackName = "TDT";
|
||
}
|
||
|
||
FormTrack *formTrack = nullptr;
|
||
//总行数
|
||
for(int i = 0; i< 3; i++)
|
||
{
|
||
if(i==0)
|
||
{
|
||
//设置高度
|
||
ui->tableWidget->setRowHeight(i, 100);
|
||
//
|
||
FormTrackTop* trackTop= new FormTrackTop(this, strSlfName, strWellName, strTrackName);
|
||
// if ("curveObject" == strType)
|
||
// trackTop->setFixedWidth(nW/2);
|
||
vec << trackTop;
|
||
trackTop->m_strUuid = m_strUuid;
|
||
trackTop->m_nTrackW = nW / static_cast<int>(g_dPixelPerCm);
|
||
ui->tableWidget->setCellWidget(i, columnCount, trackTop);
|
||
}
|
||
else if(i==1)
|
||
{
|
||
//设置高度
|
||
ui->tableWidget->setRowHeight(i, 300);
|
||
|
||
//曲线名称栏
|
||
formTrack = new FormTrack(this, strWellName, strTrackName);
|
||
// if ("curveObject" == strType)
|
||
// formTrack->setFixedWidth(nW / 2);
|
||
vec << formTrack;
|
||
formTrack->m_strUuid = m_strUuid;
|
||
formTrack->show();
|
||
ui->tableWidget->setCellWidget(i, columnCount, formTrack);
|
||
}
|
||
else if(i==2)
|
||
{
|
||
double dHight = 0;
|
||
dHight = (m_iY2-m_iY1)*100.0/(double)m_iScale * g_dPixelPerCm;
|
||
if(g_iShow==1)
|
||
{
|
||
//显示刻度
|
||
dHight = dHight+30;
|
||
}
|
||
if(dHight>32767)
|
||
{
|
||
dHight = 32767;
|
||
}
|
||
|
||
//设置高度
|
||
ui->tableWidget->setRowHeight(i, (int)dHight);//7582
|
||
//曲线绘制栏
|
||
FormDraw *formDraw = new FormDraw(this, strWellName, strTrackName);
|
||
vec << formDraw;
|
||
formDraw->m_iY1 = m_iY1;
|
||
formDraw->m_iY2 = m_iY2;
|
||
formDraw->m_strUuid = m_strUuid;
|
||
formDraw->m_strSlfName = strSlfName;
|
||
formDraw->m_formTrack = formTrack;
|
||
formDraw->m_iScale = m_iScale;
|
||
formDraw->m_nTrackW = nW;
|
||
|
||
ui->tableWidget->setCellWidget(i, columnCount, formDraw);
|
||
}
|
||
}
|
||
m_mapFormDraw.insert(formTrack->getTrackUuid(), vec);
|
||
return vec;
|
||
}
|
||
|
||
int FormWell::getTableWidgetColumn(QString strTrackUuid)
|
||
{
|
||
int nret = -1;
|
||
int nColCount = ui->tableWidget->columnCount();
|
||
for (int i = 0; i < nColCount; i++)
|
||
{
|
||
FormTrack* pTrack = qobject_cast<FormTrack*>(ui->tableWidget->cellWidget(1, i));
|
||
if (pTrack && pTrack->getTrackUuid() == strTrackUuid)
|
||
{
|
||
nret = i;
|
||
break;
|
||
}
|
||
}
|
||
return nret;
|
||
}
|
||
|
||
void FormWell::s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iTableType, QString strFormInfoType)
|
||
{
|
||
if(m_strUuid == strUuid &&
|
||
m_strWellName == strWellName &&
|
||
iTableType==2)
|
||
{
|
||
//
|
||
}
|
||
else {
|
||
//选中了曲线置顶
|
||
//取消表格选中状态
|
||
ui->tableWidget->clearSelection();
|
||
}
|
||
}
|
||
|
||
void FormWell::s_ChangeCross(QString strUuid, QString strTrackUuid)
|
||
{
|
||
const QVector<QWidget*>& vecWgt = m_mapFormDraw.value(strTrackUuid);
|
||
if (vecWgt.size() <= 2)
|
||
return;
|
||
|
||
FormDraw *formDraw = qobject_cast<FormDraw*>(vecWgt.at(2));
|
||
if (formDraw == NULL || formDraw->m_curv == NULL)
|
||
return;
|
||
|
||
formDraw->crossTrackSetting();
|
||
return;
|
||
}
|
||
|
||
void FormWell::s_ReplotFinished(QString strUuid)
|
||
{
|
||
if (m_strUuid != strUuid)
|
||
return;
|
||
|
||
int newColCount = ui->tableWidget->columnCount();
|
||
for (int i = 0; i < newColCount; i++)
|
||
{
|
||
FormDraw *formDraw = qobject_cast<FormDraw*>(ui->tableWidget->cellWidget(2, i));
|
||
if (formDraw == NULL)
|
||
continue;
|
||
|
||
formDraw->crossTrackSetting();
|
||
}
|
||
}
|
||
|
||
void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType,int nW)
|
||
{
|
||
QStringList listdt;
|
||
listdt << strUuid;
|
||
listdt << strWellName;
|
||
listdt << m_strSlfName;
|
||
listdt << strLineName;
|
||
listdt << strType;
|
||
listdt << QString::number(nW);
|
||
|
||
QVector<QWidget*> vecWgt = new_track(listdt);
|
||
if(vecWgt.size() <= 0)
|
||
return;
|
||
|
||
QString strTrackName = "道";
|
||
FormTrackTop *formTop = qobject_cast<FormTrackTop*>(vecWgt.at(0));
|
||
if(formTop)
|
||
{
|
||
strTrackName = formTop->m_strTrackName;
|
||
}
|
||
|
||
if(strLineName!="")
|
||
{
|
||
if(strType=="curveObject")
|
||
{
|
||
//新建曲线
|
||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="waveObject")
|
||
{
|
||
//新建波列
|
||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="tableObject")
|
||
{
|
||
//新建表格曲线
|
||
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="depthObject")
|
||
{
|
||
qDebug() << "新建深度";
|
||
//新建曲线
|
||
emit CallManage::getInstance()->sig_AddDepth(m_strUuid, strSlfName, strWellName, strTrackName, strLineName, nW);
|
||
}
|
||
else if(strType=="ganzhuangtuObject")
|
||
{
|
||
//新建杆状图
|
||
emit CallManage::getInstance()->sig_AddGanZhuangTu(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="JyktObject")
|
||
{
|
||
//新建井眼垮塌矢量图
|
||
emit CallManage::getInstance()->sig_AddJykt(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="DenvObject")
|
||
{
|
||
//新建井斜方位图
|
||
emit CallManage::getInstance()->sig_AddDenv(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="DrawImageObject")
|
||
{
|
||
//图像 成图
|
||
emit CallManage::getInstance()->sig_AddDrawImage(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="SantuyibiaoObject")
|
||
{
|
||
//斜井三图一表
|
||
emit CallManage::getInstance()->sig_AddSantuyibiao(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="CrackObject")
|
||
{
|
||
//裂缝
|
||
emit CallManage::getInstance()->sig_AddCrack(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="JiegutextObject")
|
||
{
|
||
//气测/FMT/射孔/文本
|
||
emit CallManage::getInstance()->sig_AddJiegutext(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="LogfaceObject")
|
||
{
|
||
//沉积相
|
||
emit CallManage::getInstance()->sig_AddLogface(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="MCalsObject")
|
||
{
|
||
//多臂井径
|
||
emit CallManage::getInstance()->sig_AddMCals(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
else if(strType=="TubingstringObject")
|
||
{
|
||
//套管组件
|
||
emit CallManage::getInstance()->sig_AddTubingstring(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
void FormWell::s_NewTrack_No_Line(QString strUuid, QString strWellName, QString strTrackName)
|
||
{
|
||
QStringList listdt;
|
||
listdt << strUuid;
|
||
listdt << strWellName;
|
||
listdt << m_strSlfName;
|
||
listdt << strTrackName;
|
||
listdt << "";
|
||
listdt << "0";
|
||
|
||
QVector<QWidget*> vecWgt = new_track(listdt);
|
||
if(vecWgt.size() <= 0)
|
||
return;
|
||
|
||
FormTrackTop *formTop = qobject_cast<FormTrackTop*>(vecWgt.at(0));
|
||
if(formTop)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
void FormWell::slot_NewTrack_No_Line(QString strUuid, QJsonObject topObj, QJsonObject infoObj)
|
||
{
|
||
QString strWellName="";
|
||
QString strTrackName="";
|
||
if (topObj.contains("WellName"))
|
||
{
|
||
QJsonValue value = topObj.value("WellName");
|
||
if (value.isString()) {
|
||
strWellName = value.toString();
|
||
qDebug() << "WellName:" << strWellName;
|
||
}
|
||
}
|
||
if (topObj.contains("TrackName"))
|
||
{
|
||
QJsonValue value = topObj.value("TrackName");
|
||
if (value.isString()) {
|
||
strTrackName = value.toString();
|
||
}
|
||
}
|
||
|
||
int nW = 0;
|
||
if (topObj.contains("TrackW"))
|
||
{
|
||
QJsonValue value = topObj.value("TrackW");
|
||
nW = value.toInt();
|
||
}
|
||
|
||
QStringList listdt;
|
||
listdt << strUuid;
|
||
listdt << strWellName;
|
||
listdt << m_strSlfName;
|
||
listdt << "";
|
||
listdt << "";
|
||
listdt << QString::number(nW * static_cast<int>(g_dPixelPerCm));
|
||
|
||
QVector<QWidget*> vecWgt = new_track(listdt, strTrackName);
|
||
if(vecWgt.size() <= 0)
|
||
return;
|
||
|
||
FormTrackTop *formTop = qobject_cast<FormTrackTop*>(vecWgt.at(0));
|
||
if(formTop)
|
||
{
|
||
formTop->setTrackTopPropert(topObj);
|
||
}
|
||
// FormTrack *formTrack = qobject_cast<FormTrack*>(vecWgt.at(1));
|
||
// if (formTrack)
|
||
// {
|
||
// formTrack->setTrackPropert(infoObj);
|
||
// }
|
||
FormDraw *formDraw = qobject_cast<FormDraw*>(vecWgt.at(2));
|
||
if (formDraw)
|
||
{
|
||
formDraw->setDrawPropert(infoObj);
|
||
}
|
||
}
|
||
|
||
int FormWell::setColWidth(int iCurrentCol, int iWidth)
|
||
{
|
||
int iNewWidth = iWidth * static_cast<int>(g_dPixelPerCm);
|
||
//设置列宽
|
||
ui->tableWidget->setColumnWidth(iCurrentCol, iNewWidth);
|
||
|
||
auto topWidget = ui->tableWidget->cellWidget(0, iCurrentCol);
|
||
if(topWidget)
|
||
{
|
||
FormTrackTop *formTop = qobject_cast<FormTrackTop*>(topWidget);//获得widget
|
||
if(formTop)
|
||
{
|
||
formTop->m_nTrackW = iWidth;
|
||
}
|
||
}
|
||
auto myWidget = ui->tableWidget->cellWidget(2, iCurrentCol);
|
||
if(myWidget)
|
||
{
|
||
//
|
||
FormDraw *formDraw = qobject_cast<FormDraw*>(myWidget);//获得widget
|
||
if(formDraw)
|
||
{
|
||
formDraw->setColWidth(iNewWidth);
|
||
}
|
||
}
|
||
|
||
//计算井宽
|
||
int iWellWidth = 0;
|
||
int columnCount = ui->tableWidget->columnCount();//总列数
|
||
for(int i=0; i<columnCount; i++)
|
||
{
|
||
iWellWidth += ui->tableWidget->columnWidth(i);
|
||
}
|
||
return iWellWidth;
|
||
}
|
||
|
||
void FormWell::setRowHeight(double dHight, QProgressBar *progressBar, int iSplit)
|
||
{
|
||
//设置高度
|
||
ui->tableWidget->setRowHeight(2, (int)dHight);//7582
|
||
|
||
ui->tableWidget->m_iScale = m_iScale;
|
||
ui->tableWidget->m_strUuid = m_strUuid;
|
||
|
||
|
||
int iBeginValue = progressBar->value();
|
||
//
|
||
int columnCount = ui->tableWidget->columnCount();//总列数
|
||
int iSplitWell = iSplit / columnCount;
|
||
for(int i=0; i<columnCount; i++)
|
||
{
|
||
if( ui->tableWidget->cellWidget(1, i) != nullptr )
|
||
{
|
||
auto myWidget = ui->tableWidget->cellWidget(2, i);
|
||
if(myWidget)
|
||
{
|
||
//
|
||
FormDraw *formDraw = (FormDraw*)myWidget;//获得widget
|
||
if(formDraw)
|
||
{
|
||
//progressBar->setValue(iBeginValue+ i*iSplitWell); // 更新进度条的值
|
||
formDraw->m_iY1 = m_iY1;
|
||
formDraw->m_iY2 = m_iY2;
|
||
formDraw->m_iScale = m_iScale;
|
||
formDraw->setRowHeight(dHight, progressBar, iSplitWell);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
QTimer::singleShot(100, this, [=]() {
|
||
this->s_ReplotFinished(m_strUuid);
|
||
});
|
||
}
|
||
//
|
||
//void FormWell::onTableColumnsInserted(const QModelIndex &parent, int first, int last)
|
||
//{
|
||
// // 当行被插入时,此函数被自动调用
|
||
// int newRowCount = ui->tableWidget->rowCount();
|
||
// int newColCount = ui->tableWidget->columnCount();
|
||
// qDebug() << "表格行数已变化!新的行数为:" << newRowCount << " 列:"<< newColCount;
|
||
// qDebug() << "新插入的行范围是从:" << first << " 到 " << last;
|
||
// for (int i = 0; i < newColCount; i++)
|
||
// {
|
||
// FormDraw *formDraw = qobject_cast<FormDraw*>(ui->tableWidget->cellWidget(2, i));
|
||
// if (formDraw == NULL)
|
||
// continue;
|
||
//
|
||
// formDraw->crossTrackSetting();
|
||
// }
|
||
//}
|
||
|
||
void FormWell::s_NewCol(QStringList listdt)
|
||
{
|
||
QVector<QWidget*> vecWgt = new_track(listdt);
|
||
if(vecWgt.size() <= 0)
|
||
return;
|
||
|
||
FormDraw *formDraw = qobject_cast<FormDraw*>(vecWgt.at(2));
|
||
if(formDraw == nullptr)
|
||
return;
|
||
QJsonObject obj;
|
||
formDraw->setDrawData(listdt, obj);
|
||
|
||
}
|
||
|
||
QJsonObject FormWell::makeJson()
|
||
{
|
||
//
|
||
QString slffilename=QString("");
|
||
int ind=m_strSlfName.lastIndexOf('\\');
|
||
int ind2=m_strSlfName.lastIndexOf('/');
|
||
if(ind2>ind) ind=ind2;
|
||
if(ind>-1) {
|
||
slffilename=m_strSlfName.mid(ind+1);
|
||
}
|
||
|
||
// 创建根对象
|
||
QJsonObject rootObj;
|
||
//
|
||
rootObj["WellName"] = m_strWellName;
|
||
rootObj["SlfName"] = slffilename;
|
||
|
||
// 创建JSON数组并填充数据
|
||
QJsonArray subcaseArray;
|
||
//
|
||
int columnCount = ui->tableWidget->columnCount();//总列数
|
||
for(int i=0; i<columnCount; i++)
|
||
{
|
||
QJsonObject formTrackObj;
|
||
formTrackObj["id"] = i;
|
||
if( ui->tableWidget->cellWidget(0, i) != nullptr )
|
||
{
|
||
auto myWidget = ui->tableWidget->cellWidget(0, i);
|
||
FormTrackTop* fromTop = qobject_cast<FormTrackTop*>(myWidget);
|
||
if(fromTop)
|
||
{
|
||
QJsonObject jobj = fromTop->makeJson();
|
||
formTrackObj["topinfo"] = jobj;
|
||
}
|
||
}
|
||
|
||
if( ui->tableWidget->cellWidget(1, i) != nullptr )
|
||
{
|
||
auto myWidget = ui->tableWidget->cellWidget(1, i);
|
||
FormTrack *formTrack = qobject_cast<FormTrack*>(myWidget); //获得widget
|
||
if(formTrack)
|
||
{
|
||
//options
|
||
formTrackObj["info"] = formTrack->makeJson();
|
||
}
|
||
}
|
||
subcaseArray.append(formTrackObj);
|
||
}
|
||
rootObj["formTracks"]=subcaseArray;
|
||
|
||
return rootObj;
|
||
}
|
||
|
||
QStringList FormWell::getLineList(QString strWellName, QString strTrackName)
|
||
{
|
||
QStringList listLine;
|
||
if(strWellName != m_strWellName)
|
||
{
|
||
return listLine;
|
||
}
|
||
//
|
||
int columnCount = ui->tableWidget->columnCount();//总列数
|
||
for(int i=0; i<columnCount; i++)
|
||
{
|
||
if( ui->tableWidget->cellWidget(1, i) != nullptr )
|
||
{
|
||
auto myWidget = ui->tableWidget->cellWidget(1, i);
|
||
//
|
||
FormTrack *formTrack = (FormTrack*)myWidget;//获得widget
|
||
if(formTrack)
|
||
{
|
||
QStringList listTemp = formTrack->getLineList(strWellName, strTrackName);
|
||
if(listTemp.size()>0)
|
||
{
|
||
listLine.append(listTemp);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return listLine;
|
||
}
|
||
|
||
void FormWell::slotContextMenu(QPoint pos)
|
||
{
|
||
//
|
||
int columnCount = ui->tableWidget->columnCount();//总列数
|
||
if(columnCount<1)
|
||
{
|
||
return;
|
||
}
|
||
//当前列
|
||
int iCurrentCol = ui->tableWidget->currentColumn();
|
||
if(iCurrentCol < 0)
|
||
{
|
||
return;
|
||
}
|
||
//当前行
|
||
int iCurrentRow = ui->tableWidget->currentRow();
|
||
if(iCurrentRow == 0)
|
||
{
|
||
QMenu menu(ui->tableWidget);
|
||
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中道", this, &FormWell::slotDeleteSelectTrack);
|
||
menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||
}
|
||
}
|
||
|
||
void FormWell::slotDeleteSelectTrack()
|
||
{
|
||
//当前列
|
||
int iCurrentCol = ui->tableWidget->currentColumn();
|
||
if(iCurrentCol < 0)
|
||
{
|
||
return;
|
||
}
|
||
//当前行
|
||
int iCurrentRow = ui->tableWidget->currentRow();
|
||
if(iCurrentRow == 0)
|
||
{
|
||
ui->tableWidget->removeColumn(iCurrentCol);
|
||
resizeWindow();
|
||
}
|
||
}
|
||
|
||
void FormWell::resizeWindow()
|
||
{
|
||
QRect rect = this->rect();
|
||
int tempWidth = 0;
|
||
int tempHight = 0;
|
||
|
||
for(int i=0; i<ui->tableWidget->columnCount(); i++)
|
||
{
|
||
tempWidth += ui->tableWidget->columnWidth(i);
|
||
tempWidth += 1;
|
||
}
|
||
//
|
||
for(int j=0; j<ui->tableWidget->rowCount(); j++)
|
||
{
|
||
tempHight += ui->tableWidget->rowHeight(j);
|
||
tempHight += 1;
|
||
}
|
||
|
||
//调整大小
|
||
if(rect.width()>tempWidth)
|
||
{
|
||
ui->tableWidget->setGeometry((rect.width()-tempWidth)/2, 2, tempWidth, tempHight);
|
||
}
|
||
else
|
||
{
|
||
ui->tableWidget->setGeometry(0, 2, tempWidth, tempHight);
|
||
}
|
||
|
||
// m_parent = parent;
|
||
|
||
MainWindowCurve *parent = (MainWindowCurve *)m_parent;
|
||
parent->resizeItem(m_strWellName, tempWidth, tempHight);
|
||
}
|