|
|
#include "zxLogInstance.h"
|
|
|
#include "ZxBaHelper.h"
|
|
|
#include "ZxResolutionHelper.h"
|
|
|
#include "zxSysUtils.h"
|
|
|
#include "ZxPtyDock.h"
|
|
|
#include "iDockBaseWx.h"
|
|
|
#include "ZxMainWindow.h"
|
|
|
|
|
|
#include "ZxSubAxisX.h"
|
|
|
#include "ZxSubAxisY.h"
|
|
|
|
|
|
#include "ZxPlot.h"
|
|
|
#include "ZxObjCurve.h"
|
|
|
#include "ZxSubTitle.h"
|
|
|
#include "tCurvePlotScene.h"
|
|
|
#include "tCurvePlotView.h"
|
|
|
|
|
|
#include "ZxTableView.h"
|
|
|
#include "ZxTableModel.h"
|
|
|
|
|
|
#include "mModuleDefines.h"
|
|
|
|
|
|
#include "ZxDataWell.h"
|
|
|
#include "ZxDataProject.h"
|
|
|
#include "ZxRstJobWnd.h"
|
|
|
#ifdef QT_DEBUG
|
|
|
#include "ZxDataGaugeP.h"
|
|
|
#endif
|
|
|
|
|
|
#ifdef QT_DEBUG
|
|
|
#include "nmXmlHelper.h"
|
|
|
#endif
|
|
|
|
|
|
#include "nmGuiPlot.h"
|
|
|
#include "nmWxParaProperty.h"
|
|
|
#include "nmWxTreeWidget.h"
|
|
|
|
|
|
#include "nmSubWndMain.h"
|
|
|
#include "nmDataDemo.h"
|
|
|
|
|
|
#include "nmDataLogFile.h"
|
|
|
|
|
|
#include "nmWxGridVTKContainerWidget.h"
|
|
|
#include "nmWxSelectWellsDlg.h"
|
|
|
#include "nmWxSelectWellsWidget.h"
|
|
|
#include "nmCalculationSolver.h"
|
|
|
|
|
|
#include "nmObjPointWell.h"
|
|
|
|
|
|
#include "nmWxRCDialog.h"
|
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
nmSubWndMain::nmSubWndMain(QWidget *parent, QString sExt) :
|
|
|
iSubWndBaseAF(parent, sExt)
|
|
|
{
|
|
|
m_pWxPlot = NULL;
|
|
|
m_pWxDockParas = NULL;
|
|
|
m_pWxParas = NULL;
|
|
|
m_pWxDockData1 = NULL;
|
|
|
m_pTableView1 = NULL;
|
|
|
m_pWxDockData2 = NULL;
|
|
|
m_pTableView2 = NULL;
|
|
|
#ifdef QT_DEBUG
|
|
|
m_pWxDockTemp = NULL;
|
|
|
m_pListWxTemp = NULL;
|
|
|
#endif
|
|
|
// 为了后续支持多井提供方便
|
|
|
if(m_pDataWell == NULL) {
|
|
|
m_pDataWell = zxCurWell;
|
|
|
}
|
|
|
m_sMdiWndType = s_MdiType_DataNum;
|
|
|
m_pAnalyzeData = nmDataDemo::getInstance();
|
|
|
setWindowTitle(tr("nmSubWndMain"));
|
|
|
}
|
|
|
|
|
|
nmSubWndMain::~nmSubWndMain()
|
|
|
{
|
|
|
#ifdef QT_DEBUG
|
|
|
// 坚持谁创建谁析构原则,删除(首先需要去除绑定)
|
|
|
if(NULL != m_pWxDockTemp) {
|
|
|
//QObject* pParent = m_pWxDockTemp->parent();
|
|
|
//ZxMainWindow* p = dynamic_cast<ZxMainWindow*>(pParent);
|
|
|
ZxMainWindow* p = m_pMainWindow;
|
|
|
if(NULL != p) {
|
|
|
p->detachOuterDockWx(m_pWxDockTemp);
|
|
|
}
|
|
|
delete m_pWxDockTemp;
|
|
|
m_pWxDockTemp = NULL;
|
|
|
}
|
|
|
#endif
|
|
|
this->setTopDocksVisible(true);
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::configWnd()
|
|
|
{
|
|
|
iSubWndBaseAF::configWnd();
|
|
|
if(NULL != m_pMainWindow) {
|
|
|
disconnect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \
|
|
|
m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)));
|
|
|
connect(this, SIGNAL(sigAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)), \
|
|
|
m_pMainWindow, SLOT(slotAppendDock2Main(iDockBaseWx*, Qt::DockWidgetArea)));
|
|
|
}
|
|
|
initUI();
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::initUI()
|
|
|
{
|
|
|
// iSubWndBaseAF::initUI();
|
|
|
#ifdef QT_DEBUG
|
|
|
// 示例:演示增加Dock并且追加至程序主窗口
|
|
|
initUiTop();
|
|
|
#endif
|
|
|
// 主布局:定义
|
|
|
initUiMain();
|
|
|
// 外围布局,DockWx
|
|
|
{
|
|
|
initUiDockWxs();
|
|
|
initUiDockPtys();
|
|
|
}
|
|
|
#ifdef QT_DEBUG
|
|
|
// 示例:如何加载xml文件
|
|
|
if(_nmXmlHelper->loadXmlDefines()) {
|
|
|
foreach(nmXmlData* pData, *(_nmXmlHelper->getVecNmXmlDataPtrs())) {
|
|
|
Q_ASSERT(NULL != pData);
|
|
|
zxLogRunD(QString("%1: %2").arg(pData->m_sName).arg(pData->m_sAlias));
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
QWidget* nmSubWndMain::initUiMainWx()
|
|
|
{
|
|
|
QSplitter* pSplitter = new QSplitter(Qt::Vertical);
|
|
|
Q_ASSERT(NULL != pSplitter);
|
|
|
nmGuiPlot* pWxPlot = new nmGuiPlot();
|
|
|
m_pWxPlot = pWxPlot;
|
|
|
m_pAnalyzeData->setWxPlot(m_pWxPlot);
|
|
|
{
|
|
|
// 建立信号,以便在此处增加新的工具
|
|
|
connect(pWxPlot, SIGNAL(sigToolbarBuilt(QToolBar*)),
|
|
|
this, SLOT(slotToolbarBuilt(QToolBar*)));
|
|
|
QSize sz = QSize(265, 203);
|
|
|
pWxPlot->initUI("TestGui", sz);
|
|
|
bindChartSignals(pWxPlot);
|
|
|
pSplitter->addWidget(pWxPlot);
|
|
|
}
|
|
|
return pSplitter;
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::initUiDockWxs()
|
|
|
{
|
|
|
// TODO,本Dock的操作
|
|
|
// 基础参数Dock
|
|
|
// {
|
|
|
// m_pWxDockParas = new iDockBaseWx(tr("Parameters"));
|
|
|
// Q_ASSERT (NULL != m_pWxDockParas);
|
|
|
// addDockWidget(Qt::LeftDockWidgetArea, m_pWxDockParas);
|
|
|
// m_pWxParas = new nmWxParaProperty();
|
|
|
// Q_ASSERT (NULL != m_pWxParas);
|
|
|
// m_pWxParas->initUI();
|
|
|
// m_pWxDockParas->setWidget(m_pWxParas);
|
|
|
// m_pWxDockParas->setMinimumWidth(_resoSizeW(200));
|
|
|
// }
|
|
|
// 表格数据Dock
|
|
|
// {
|
|
|
// QStringList listTitles;
|
|
|
// listTitles << tr("Name1");
|
|
|
// iDockBaseWx* pDockWx1 = new iDockBaseWx(tr("Data1"));
|
|
|
// Q_ASSERT (NULL != pDockWx1);
|
|
|
// {
|
|
|
// addDockWidget(Qt::RightDockWidgetArea, pDockWx1);
|
|
|
// m_pWxDockData1 = pDockWx1;
|
|
|
// ZxTableView* pTableView = new ZxTableView();
|
|
|
// Q_ASSERT (NULL != pTableView);
|
|
|
// {
|
|
|
// ZxTableModel* pTableModel = new ZxTableModel(1, 1, listTitles);
|
|
|
// Q_ASSERT (NULL != pTableModel);
|
|
|
// pTableView->setModel(pTableModel);
|
|
|
// pTableView->setMenuMode(ZxTableView::MTM_Edit_Without_Col);
|
|
|
// pTableView->setSelectionBehavior(ZxTableView::SelectRows);
|
|
|
// pTableView->fuzzyUiOfQt5();
|
|
|
// }
|
|
|
// pDockWx1->setWidget(pTableView);
|
|
|
// m_pTableView1 = pTableView;
|
|
|
// }
|
|
|
// iDockBaseWx* pDockWx2 = new iDockBaseWx(tr("Data2"));
|
|
|
// Q_ASSERT (NULL != pDockWx2);
|
|
|
// {
|
|
|
// addDockWidget(Qt::RightDockWidgetArea, pDockWx2);
|
|
|
// tabifyDockWidget(pDockWx1, pDockWx2);
|
|
|
// m_pWxDockData2 = pDockWx2;
|
|
|
// ZxTableView* pTableView = new ZxTableView();
|
|
|
// Q_ASSERT (NULL != pTableView);
|
|
|
// {
|
|
|
// ZxTableModel* pTableModel = new ZxTableModel(1, 1, listTitles);
|
|
|
// Q_ASSERT (NULL != pTableModel);
|
|
|
// pTableView->setModel(pTableModel);
|
|
|
// pTableView->setMenuMode(ZxTableView::MTM_Readonly);
|
|
|
// pTableView->fuzzyUiOfQt5();
|
|
|
// }
|
|
|
// pDockWx2->setWidget(pTableView);
|
|
|
// m_pTableView2 = pTableView;
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::initUiDockPtys()
|
|
|
{
|
|
|
iSubWndBaseAF::initUiDockPtys();
|
|
|
// 属性Dock
|
|
|
{
|
|
|
Q_ASSERT(NULL != m_pDockPty);
|
|
|
m_pDockPty->setMinimumWidth(_resoSizeW(200));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#ifdef QT_DEBUG
|
|
|
// 示例:演示增加Dock并且追加至程序主窗口
|
|
|
void nmSubWndMain::initUiTop()
|
|
|
{
|
|
|
// 隐藏所有Dock
|
|
|
this->setTopDocksVisible(false);
|
|
|
// 创建新的Dock
|
|
|
iDockBaseWx* pDockWx = new iDockBaseWx(tr("TODO:Demo"));
|
|
|
Q_ASSERT(NULL != pDockWx);
|
|
|
// QListWidget* pListWx = new QListWidget();
|
|
|
nmWxTreeWidget* treeWidget = new nmWxTreeWidget(pDockWx, m_pAnalyzeData);
|
|
|
Q_ASSERT(NULL != treeWidget);
|
|
|
pDockWx->setWidget(treeWidget);
|
|
|
// m_pListWxTemp = pListWx;
|
|
|
pDockWx->setMinimumWidth(_resoSizeW(200));
|
|
|
emit sigAppendDock2Main(pDockWx, Qt::LeftDockWidgetArea);
|
|
|
m_pWxDockTemp = pDockWx;
|
|
|
return;
|
|
|
// 基础参数Dock
|
|
|
// {
|
|
|
// iDockBaseWx* pDockWx = new iDockBaseWx(tr("TODO:Demo"));
|
|
|
// Q_ASSERT (NULL != pDockWx);
|
|
|
// QListWidget* pListWx = new QListWidget();
|
|
|
// Q_ASSERT (NULL != pListWx);
|
|
|
// pDockWx->setWidget(pListWx);
|
|
|
// m_pListWxTemp = pListWx;
|
|
|
// pDockWx->setMinimumWidth(_resoSizeW(200));
|
|
|
// emit sigAppendDock2Main(pDockWx, Qt::LeftDockWidgetArea);
|
|
|
// m_pWxDockTemp = pDockWx;
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
void nmSubWndMain::bindChartSignals(iGuiPlot* pWxPlot)
|
|
|
{
|
|
|
nmGuiPlot* p = dynamic_cast<nmGuiPlot*>(pWxPlot);
|
|
|
if(NULL != p) {
|
|
|
connect(p, SIGNAL(sigObjSelChanged(ZxObjBase*, bool)), \
|
|
|
this, SLOT(slotObjSelChanged(ZxObjBase*, bool)));
|
|
|
connect(p, SIGNAL(sigObjPtsChanged(ZxObjBase*)),
|
|
|
this, SLOT(slotObjPtsChanged(ZxObjBase*)));
|
|
|
}
|
|
|
iSubWndBaseAF::bindChartSignals(pWxPlot);
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::runActionOf(QString sAction)
|
|
|
{
|
|
|
if(iSubWnd::runActionOf(sAction)) {
|
|
|
return true;
|
|
|
}
|
|
|
// 数据加载
|
|
|
QString s = sAction;
|
|
|
if(_isSame(s, "LoadP")) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::runCmdBy(QString sName, QString sID)
|
|
|
{
|
|
|
QString s = sName;
|
|
|
int nId = sID.toInt();
|
|
|
switch(nId) {
|
|
|
case 5102:
|
|
|
this->geologicalMapImport();
|
|
|
return true;
|
|
|
/*case 5103:
|
|
|
this->geologicalMapHide();
|
|
|
return true;*/
|
|
|
case 5103:
|
|
|
this->drawPolygonOutline();
|
|
|
return true;
|
|
|
case 5104:
|
|
|
this->drawSquareOutline();
|
|
|
return true;
|
|
|
case 5105:
|
|
|
this->drawRoundOutline();
|
|
|
return true;
|
|
|
case 5106:
|
|
|
this->drawFault();
|
|
|
return true;
|
|
|
case 5107:
|
|
|
this->selectWell();
|
|
|
return true;
|
|
|
case 5108:
|
|
|
this->drawWell();
|
|
|
return true;
|
|
|
case 5109:
|
|
|
this->drawCrack();
|
|
|
return true;
|
|
|
case 5110:
|
|
|
this->drawRegion();
|
|
|
return true;
|
|
|
case 5111:
|
|
|
this->identificationRegion();
|
|
|
return true;
|
|
|
case 5112:
|
|
|
this->geoLayering();
|
|
|
return true;
|
|
|
case 5113:
|
|
|
this->reservoirCharacteristics();
|
|
|
return true;
|
|
|
/*case 5114:
|
|
|
this->generationMesh();
|
|
|
return true;
|
|
|
*/
|
|
|
case 5115:
|
|
|
this->solveAndAnalyze();
|
|
|
return true;
|
|
|
}
|
|
|
if(_isSame(s, "RunGrid")) {
|
|
|
if(NULL != m_pWxPlot) {
|
|
|
//m_pWxPlot->refreshGrid(true);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::checkCmdEnable(bool &b, \
|
|
|
QString sName, int nID, \
|
|
|
bool bLicensed)
|
|
|
{
|
|
|
bool b1 = (NULL != zxCurProject);
|
|
|
bool b2 = (NULL != m_pDataWell);
|
|
|
if(nID >= 5102 && nID <= 5116) { //RunGrid
|
|
|
b = (b1 && b2 && bLicensed && !isReadonly() && NULL != m_pWxPlot);
|
|
|
return true;
|
|
|
}
|
|
|
return iSubWndBaseAF::checkCmdEnable(b, sName, nID, bLicensed);
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::reAdjustToolbar(QToolBar* pToolBar)
|
|
|
{
|
|
|
iSubWndBaseAF::reAdjustToolbar(pToolBar);
|
|
|
m_pPlotToolBar = pToolBar;
|
|
|
// 获取所有动作的列表
|
|
|
// QList<QAction *> actions = m_pPlotToolBar->actions();
|
|
|
// // 隐藏第1个和第2个动作
|
|
|
// if (actions.size() > 0) {
|
|
|
// actions[0]->setVisible(false); // 隐藏第1个动作
|
|
|
// }
|
|
|
// if (actions.size() > 1) {
|
|
|
// actions[1]->setVisible(false); // 隐藏第2个动作
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::firstLoadAndUpdate()
|
|
|
{
|
|
|
iSubWndBaseAF::firstLoadAndUpdate();
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::finalDeals()
|
|
|
{
|
|
|
iSubWndBaseAF::finalDeals();
|
|
|
#ifdef QT_DEBUG
|
|
|
updatePlots();
|
|
|
updateDockWxs();
|
|
|
if(m_pWxDockData1 != NULL) {
|
|
|
Q_ASSERT(NULL != m_pWxDockData1);
|
|
|
m_pWxDockData1->raise();
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::onActivated()
|
|
|
{
|
|
|
#ifdef QT_DEBUG
|
|
|
// 当前窗体激活时,可以做些事情,比如把隐藏的Dock显示出来
|
|
|
if(NULL != m_pWxDockTemp) {
|
|
|
if(!m_pWxDockTemp->isVisible()) {
|
|
|
m_pWxDockTemp->setVisible(true);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
#ifdef QT_DEBUG
|
|
|
|
|
|
void nmSubWndMain::updatePlots()
|
|
|
{
|
|
|
// 里面根据曲线,重新刷了一下坐标轴范围。你屏蔽该函数,即可
|
|
|
// 坐标轴范围会变成背景图的大小
|
|
|
return ;
|
|
|
// 说明:以从当前井获取一条压力数据进行绘图为例
|
|
|
QString sType = iDataModelType::sTypeDataGaugeP;
|
|
|
QString sCodeP = ""; //如果已知压力数据Code,可以直接引用
|
|
|
ZxDataGaugeP* pDataObjP = dynamic_cast<ZxDataGaugeP*>(getDataObjOf(sType, sCodeP));
|
|
|
if(NULL == pDataObjP) {
|
|
|
zxLogRunW(tr("Failed to get data of type '%1'").arg(sType));
|
|
|
return;
|
|
|
}
|
|
|
VecDouble vecX, vecY;
|
|
|
QByteArray ba = pDataObjP->getGaugeDataOf(0);
|
|
|
if(!ZxBaHelper::convertBa2VecXY(vecX, vecY, ba)) {
|
|
|
zxLogRunW(tr("Failed to get x-y data of dataobj '%1'").arg(pDataObjP->getCode()));
|
|
|
return;
|
|
|
}
|
|
|
nmGuiPlot* pWxPlot = m_pWxPlot;
|
|
|
Q_ASSERT(NULL != pWxPlot);
|
|
|
QString sName = tr("CurveName");
|
|
|
ZxObjBase* pObj = pWxPlot->updatePlotObjBy(sName, vecX, vecY, true);
|
|
|
if(NULL != pObj) {
|
|
|
pObj->setLockPos(true); //可以调整属性
|
|
|
// pObj->setReadOnly(true);
|
|
|
pWxPlot->freshAxisScales(true);//刷新坐标轴刻度
|
|
|
// 设置标题+坐标轴等
|
|
|
pWxPlot->setAxisX(tr("Time"), "hr");
|
|
|
pWxPlot->setAxisY(tr("Pressure"), "MPa");
|
|
|
pWxPlot->setAxisXYLog(false, 0);
|
|
|
pWxPlot->setAxisXYLog(false, 1);
|
|
|
pWxPlot->m_pPlot->setLegendVisible(false);
|
|
|
pWxPlot->m_pPlot->getTitle()->setName(tr("Demo"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ZxDataObject* nmSubWndMain::getDataObjOf(QString sType, QString sCode /*= ""*/)
|
|
|
{
|
|
|
ZxDataWell* pDataWell = zxCurWell;
|
|
|
Q_ASSERT(NULL != pDataWell);
|
|
|
ZxDataObject* pDataObj = NULL;
|
|
|
if(!sCode.isEmpty()) {
|
|
|
pDataObj = pDataWell->getChild(sType, sCode);
|
|
|
} else {
|
|
|
ZxDataObjectList vecObjs = pDataWell->getChildren(sType);
|
|
|
if(!vecObjs.isEmpty()) {
|
|
|
pDataObj = vecObjs[0];
|
|
|
}
|
|
|
}
|
|
|
return pDataObj;
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::updateDockWxs()
|
|
|
{
|
|
|
// TODO,刷新Dock内容
|
|
|
return;
|
|
|
// 左侧参数窗体
|
|
|
Q_ASSERT(NULL != m_pWxParas);
|
|
|
QStringList listParas;
|
|
|
listParas << "K" << "S" << "rw" << "Miuo" << "Bo" << "phi";
|
|
|
m_pWxParas->refreshUIs(listParas);
|
|
|
// 表格数据1
|
|
|
Q_ASSERT(NULL != m_pTableView1);
|
|
|
ZxTableModel* pTableModel = m_pTableView1->getModel();
|
|
|
Q_ASSERT(NULL != pTableModel);
|
|
|
QStringList listTitles;
|
|
|
listTitles << tr("Col1") << tr("Col2\n(MPa)");
|
|
|
VVecDouble vvec;
|
|
|
{
|
|
|
VecDouble vec;
|
|
|
vec << 0.2 << 3.4;
|
|
|
vvec << vec;
|
|
|
}
|
|
|
{
|
|
|
VecDouble vec;
|
|
|
vec << 5.6 << 0.456;
|
|
|
vvec << vec;
|
|
|
}
|
|
|
pTableModel->setTitles(listTitles);
|
|
|
pTableModel->setData(vvec);
|
|
|
if(NULL != m_pListWxTemp) {
|
|
|
m_pListWxTemp->clear();
|
|
|
for(int i = 0; i < 10; i++) {
|
|
|
QString sItem = tr("Demo Item %1").arg(i + 1);
|
|
|
QListWidgetItem* pItem = new QListWidgetItem(sItem);
|
|
|
Q_ASSERT(NULL != pItem);
|
|
|
pItem->setIcon(zxLoadIcon("Open"));
|
|
|
m_pListWxTemp->addItem(pItem);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::updateTableByCurve(ZxObjCurve* pObjCurve, ZxTableView* pTableView)
|
|
|
{
|
|
|
Q_ASSERT(NULL != pObjCurve);
|
|
|
Q_ASSERT(NULL != pTableView);
|
|
|
// 刷新表格标题
|
|
|
{
|
|
|
QString sNameX = pObjCurve->getAxisX()->getName();
|
|
|
QString sUnit = pObjCurve->getAxisX()->getUnit();
|
|
|
if(!sUnit.isEmpty()) {
|
|
|
sNameX += QString("\n(%1)").arg(sUnit);
|
|
|
}
|
|
|
QString sNameY = pObjCurve->getAxisY()->getName();
|
|
|
sUnit = pObjCurve->getAxisY()->getUnit();
|
|
|
if(!sUnit.isEmpty()) {
|
|
|
sNameY += QString("\n(%1)").arg(sUnit);
|
|
|
}
|
|
|
QStringList listTitles;
|
|
|
listTitles << sNameX << sNameY;
|
|
|
pTableView->getModel()->setTitles(listTitles);
|
|
|
}
|
|
|
// 刷新表格数据
|
|
|
{
|
|
|
VVecDouble vvec;
|
|
|
QVector<QPointF> vecValues = pObjCurve->getAllValues();
|
|
|
for(int i = 0; i < vecValues.count(); i++) {
|
|
|
VecDouble vec;
|
|
|
vec << vecValues.at(i).x() * 1.0;
|
|
|
vec << vecValues.at(i).y() * 1.0;
|
|
|
vvec << vec;
|
|
|
}
|
|
|
pTableView->getModel()->setData(vvec);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
void nmSubWndMain::slotObjSelChanged(ZxObjBase* p, bool b)
|
|
|
{
|
|
|
#ifdef QT_DEBUG
|
|
|
// 如果选中了一条曲线,则把其数据显示在数据表格2中
|
|
|
ZxObjCurve* pObjCurve = dynamic_cast<ZxObjCurve*>(p);
|
|
|
if(NULL != pObjCurve && b) {
|
|
|
Q_ASSERT(NULL != m_pWxDockData2);
|
|
|
m_pWxDockData2->raise();
|
|
|
updateTableByCurve(pObjCurve, m_pTableView2);
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::slotObjPtsChanged(ZxObjBase* p)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::onSerialize(ZxSerializer* ser)
|
|
|
{
|
|
|
iSubWndBaseAF::onSerialize(ser);
|
|
|
if(NULL != m_pWxPlot) {
|
|
|
m_pWxPlot->setModified(false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::onDeserialize(ZxSerializer* ser)
|
|
|
{
|
|
|
iSubWndBaseAF::onDeserialize(ser);
|
|
|
if(NULL != m_pWxPlot) {
|
|
|
m_pWxPlot->setModified(false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::onDeserialized()
|
|
|
{
|
|
|
if(NULL != m_pWxPlot) {
|
|
|
m_pWxPlot->resetAfterDeserialized();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::loadRss()
|
|
|
{
|
|
|
ZxRstJobWnd* pRstWnd = getRstJobWnd();
|
|
|
Q_ASSERT(NULL != pRstWnd);
|
|
|
// 基础信息
|
|
|
{
|
|
|
QByteArray v = pRstWnd->getDataInfo();
|
|
|
IxSerDes* pSerObj = this;
|
|
|
if(!loadRstInfoFromArr(v, pSerObj)) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
// 图形
|
|
|
if(NULL != m_pWxPlot) {
|
|
|
QByteArray v = pRstWnd->getDataInfo1();
|
|
|
ZxPlot* pPlot = NULL;
|
|
|
loadOnePlot(pPlot, v);
|
|
|
if(NULL != pPlot) {
|
|
|
m_pWxPlot->m_pPlotScene->freshToPlot(pPlot,
|
|
|
m_pWxPlot->m_pPlotView);
|
|
|
m_pWxPlot->m_pPlot = m_pWxPlot->m_pPlotScene->m_pPlot;
|
|
|
pPlot->resetTools(m_pWxPlot->m_pPlotView);
|
|
|
m_pWxPlot->resetAfterDeserialized();
|
|
|
}
|
|
|
m_pWxPlot->runUpdate();
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::saveRss()
|
|
|
{
|
|
|
ZxRstJobWnd* pRstWnd = getRstJobWnd();
|
|
|
if(NULL == pRstWnd) {
|
|
|
return false;
|
|
|
}
|
|
|
// 基础信息
|
|
|
{
|
|
|
QByteArray v;
|
|
|
IxSerDes* pSerObj = this;
|
|
|
if(!saveRstInfoToArr(v, pSerObj)) {
|
|
|
return false;
|
|
|
}
|
|
|
pRstWnd->setDataInfo(v);
|
|
|
}
|
|
|
// 图形
|
|
|
if(NULL != m_pWxPlot) {
|
|
|
ZxPlot* pPlot = m_pWxPlot->m_pPlot;
|
|
|
{
|
|
|
QByteArray v1;
|
|
|
if(saveOnePlot(pPlot, v1)) {
|
|
|
pRstWnd->setDataInfo1(v1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return pRstWnd->save();
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::slotSaveAll()
|
|
|
{
|
|
|
ZxRstJobWnd* pRstWnd = getRstJobWnd();
|
|
|
Q_ASSERT(NULL != pRstWnd);
|
|
|
return saveRss();
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::updateSelectedWells(QList<ZxDataWell *> wellObjList)
|
|
|
{
|
|
|
if(wellObjList.count() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
// setp 1,获取现在画布上所有的井信息
|
|
|
QVector<nmObjPointWell*> pWellPlotList = m_pWxPlot->getWellPlots();
|
|
|
QMap<ZxDataWell*, nmObjPointWell*> pWellDataToPlotMap;
|
|
|
// setp 2,在图元里,不在wellObjList里,是要删除的图元
|
|
|
QVector<nmObjPointWell*> vDeleteWellPlotList;
|
|
|
for(int i = 0; i < pWellPlotList.count(); i++) {
|
|
|
ZxDataWell *pWellData = pWellPlotList[i]->getWellData();
|
|
|
pWellDataToPlotMap.insert(pWellData, pWellPlotList[i]);
|
|
|
if(!wellObjList.contains(pWellData)) {
|
|
|
vDeleteWellPlotList.append(pWellPlotList[i]);
|
|
|
}
|
|
|
}
|
|
|
// TODO 3,在wellObjList 不在 图元pWellPlotDataList里 需要添加
|
|
|
QList<ZxDataWell*> pWellPlotDataList = pWellDataToPlotMap.keys();
|
|
|
QVector<ZxDataWell*> vAddWellPlotList;
|
|
|
for(int i = 0; i < wellObjList.count() ; i++) {
|
|
|
ZxDataWell *pWellData = wellObjList[i];
|
|
|
if(!pWellPlotDataList.contains(pWellData)) {
|
|
|
vAddWellPlotList.append(pWellData);
|
|
|
}
|
|
|
}
|
|
|
// setp 4,将vDeleteWellPlotList中的图元删除
|
|
|
for(int i = 0; i < vDeleteWellPlotList.count() ; i++) {
|
|
|
nmObjPointWell* pWellPlot = vDeleteWellPlotList[i];
|
|
|
m_pWxPlot->m_pPlot->removeObjByName(pWellPlot->getName());
|
|
|
}
|
|
|
// setp 5,将vAddWellPlotList中的井数据,构建图元,添加到画布上
|
|
|
for(int i = 0; i < vAddWellPlotList.count(); i++) {
|
|
|
ZxDataWell* wellObj = vAddWellPlotList[i];
|
|
|
QString sName = tr("nmObj");
|
|
|
QVector<QPointF> points;
|
|
|
points.append(QPointF(wellObj->getLocationX(), wellObj->getLocationY()));
|
|
|
// 构建了图元
|
|
|
nmObjPointWell* pWellPlot = (nmObjPointWell*)m_pWxPlot->appendOneObj(NOT_Point_Well, sName, points);
|
|
|
// 设置图元的井数据
|
|
|
pWellPlot->setWellData(wellObj);
|
|
|
// 移动到正确的位置
|
|
|
pWellPlot->moveToPos(pWellPlot->getPosOf(pWellPlot->getAllPos()));
|
|
|
}
|
|
|
// 添加完毕后,重新渲染
|
|
|
m_pWxPlot->update();
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::setAnalyzeData(nmDataDemo *newAnalyzeData)
|
|
|
{
|
|
|
m_pAnalyzeData = newAnalyzeData;
|
|
|
}
|
|
|
|
|
|
nmDataDemo *nmSubWndMain::analyzeData() const
|
|
|
{
|
|
|
return m_pAnalyzeData;
|
|
|
}
|
|
|
|
|
|
// 地质图导入
|
|
|
void nmSubWndMain::geologicalMapImport()
|
|
|
{
|
|
|
// 打开图片选择弹框
|
|
|
// 打开文件对话框选择图片文件
|
|
|
QString filePath = QFileDialog::getOpenFileName(nullptr, "选择图片文件", "", "Images (*.png *.xpm *.jpg)");
|
|
|
if(!filePath.isEmpty()) {
|
|
|
// 画布 设置背景,并自适应宽高
|
|
|
ZxPlot* pPlot = m_pWxPlot->m_pPlot;
|
|
|
pPlot->setBkImgFile(filePath);
|
|
|
// QImage* pBkImg = pPlot->getBkImg();
|
|
|
// Q_ASSERT (NULL != pBkImg);
|
|
|
// int w = pBkImg->width();
|
|
|
// int h = pBkImg->height();
|
|
|
// pPlot->getMainAxisX()->setRangeMinMax(0, w, true);
|
|
|
// pPlot->getMainAxisY()->setRangeMinMax(0, h, true);
|
|
|
nmDataLogFile::getInstance()->writeLog(filePath);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::geologicalMapHide()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::setTopDocksVisible(bool visible)
|
|
|
{
|
|
|
// 获取主程序所有 Dock 视图
|
|
|
QList<QDockWidget*> dockWidgets = m_pMainWindow->findChildren<QDockWidget*>();
|
|
|
// 遍历所有 Dock 视图并移除位于左侧的
|
|
|
foreach(QDockWidget* dock, dockWidgets) {
|
|
|
if(visible) {
|
|
|
dock->show();
|
|
|
} else {
|
|
|
dock->hide();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawPolygonOutline()
|
|
|
{
|
|
|
// 获取多边形边界的绘制,并模拟触发点击操作
|
|
|
// 目前多边形边界绘制是工具栏的第4个,所以用 3
|
|
|
// QList<QAction *> actions = m_pPlotToolBar->actions();
|
|
|
// if (!actions.isEmpty()) {
|
|
|
// QAction *action = actions[3];
|
|
|
// action->trigger();
|
|
|
// }
|
|
|
this->triggerToolBarAction(NOT_PolygonOutline);
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawSquareOutline()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawRoundOutline()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawFault()
|
|
|
{
|
|
|
this->triggerToolBarAction(NOT_Line_Fault);
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::selectWell()
|
|
|
{
|
|
|
// 先获取已经添加到的界面中井
|
|
|
QStringList wellPlotNameList = m_pWxPlot->getWellNames();
|
|
|
// 先找到所有的井
|
|
|
int wellCount = zxCurProject->getChildrenCount(iDataModelType::sTypeWell);
|
|
|
ZxDataObjectList wellList = zxCurProject->getChildren(iDataModelType::sTypeWell);
|
|
|
nmDataLogFile::getInstance()->writeLog(QString(" %1 %2").arg(wellCount).arg(wellList.size()));
|
|
|
// 井的名字
|
|
|
QStringList wellNames;
|
|
|
// 井的code
|
|
|
QList<QVariant> wellCodes;
|
|
|
// 井的名字到井数据指针的Map
|
|
|
QMap<QString, ZxDataWell*> wellNameToObjMap;
|
|
|
// 数据整理
|
|
|
for(int i = 0; i < wellList.size(); i++) {
|
|
|
ZxDataWell* wellObj = (ZxDataWell*)wellList[i];
|
|
|
nmDataLogFile::getInstance()->writeLog(wellObj->getName() + " " + wellObj->getCode());
|
|
|
wellNames.append(wellObj->getName());
|
|
|
wellCodes.append(wellObj->getCode());
|
|
|
wellNameToObjMap.insert(wellObj->getName(), wellObj);
|
|
|
}
|
|
|
// 展示dialog供选择
|
|
|
nmWxSelectWellsDlg dlg;
|
|
|
nmWxSelectWellsWidget wellListWidget;
|
|
|
wellListWidget.setSelectedItems(wellPlotNameList);
|
|
|
wellListWidget.addItems(wellNames, wellCodes);
|
|
|
dlg.setWidget(&wellListWidget);
|
|
|
if(dlg.exec() == QDialog::Accepted) {
|
|
|
// 用户点击了“确定”按钮
|
|
|
nmDataLogFile::getInstance()->writeLog(" OK ");
|
|
|
QStringList wellNames = wellListWidget.getItems();
|
|
|
QList<ZxDataWell*> selectWellList;
|
|
|
for(int i = 0; i < wellNames.count(); i++) {
|
|
|
selectWellList.append(wellNameToObjMap.value(wellNames[i]));
|
|
|
}
|
|
|
this->updateSelectedWells(selectWellList);
|
|
|
nmDataLogFile::getInstance()->writeLog("===" + wellNames.join(";") + "===");
|
|
|
} else {
|
|
|
// 用户点击了“取消”按钮
|
|
|
nmDataLogFile::getInstance()->writeLog(" Cancel ");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawWell()
|
|
|
{
|
|
|
// 获取多边形边界的绘制,并模拟触发点击操作
|
|
|
// 目前多边形边界绘制是工具栏的第4个,所以用 3
|
|
|
// QList<QAction *> actions = m_pPlotToolBar->actions();
|
|
|
// if (!actions.isEmpty()) {
|
|
|
// QAction *action = actions[0];
|
|
|
// action->trigger();
|
|
|
// }
|
|
|
this->triggerToolBarAction(NOT_Point_Well);
|
|
|
nmDataLogFile::getInstance()->writeLog(" in drawWell ");
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawCrack()
|
|
|
{
|
|
|
this->triggerToolBarAction(NOT_Line_Crack);
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::drawRegion()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::identificationRegion()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::generationMesh()
|
|
|
{
|
|
|
// TODO,还不支持原型边界
|
|
|
// 拿到多边形和点的位置信息
|
|
|
QVector<ZxObjBase*> pObjVec = m_pWxPlot->getObjsByTag("nObjPolygonOutline");
|
|
|
nmDataLogFile::getInstance()->writeLog(" ---------- " + QString::number(pObjVec.count()));
|
|
|
QVector<ZxObjBase*> pWellObjVec = m_pWxPlot->getObjsByTag("nObjPointWell");
|
|
|
nmDataLogFile::getInstance()->writeLog(" ---------- " + QString::number(pWellObjVec.count()));
|
|
|
// 生成geo文件
|
|
|
// 调用gmsh生成vtk文件
|
|
|
// 弹出网格的dialog,渲染文件
|
|
|
if(true) {
|
|
|
QDialog* dlg = new QDialog;
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
|
|
dlg->setLayout(layout);
|
|
|
nmWxGridVTKContainerWidget* gridVTKContainerWidget = new nmWxGridVTKContainerWidget(dlg);
|
|
|
layout->addWidget(gridVTKContainerWidget);
|
|
|
dlg->resize(800, 600);
|
|
|
dlg->show();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::solveAndAnalyze()
|
|
|
{
|
|
|
// vtk文件
|
|
|
QString sFileGrid = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing") + "mesh.vtk";
|
|
|
// 油藏参数文件
|
|
|
QString sFileReservoirParamters = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing") + "par.txt";
|
|
|
// 井数据文件
|
|
|
QString sFileWell = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PreProcessing") + "wells.txt";
|
|
|
// dll路径
|
|
|
QString dllDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/Solver");
|
|
|
// 后处理文件路径
|
|
|
QString postDir = ZxBaseUtil::getDirOf(s_Dir_Temp, "Nm/PostProcessing");
|
|
|
// 调用求解器
|
|
|
nmCalculationSolver solver;
|
|
|
solver.execSolve(sFileGrid, sFileReservoirParamters, sFileWell, dllDir, postDir);
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::triggerToolBarAction(int index)
|
|
|
{
|
|
|
// 获取多边形边界的绘制,并模拟触发点击操作
|
|
|
// 目前多边形边界绘制是工具栏的第4个,所以用 3
|
|
|
QList<QAction *> actions = m_pPlotToolBar->actions();
|
|
|
if(!actions.isEmpty() && index >= 0 && index < actions.count()) {
|
|
|
QAction *action = actions[index];
|
|
|
action->trigger();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool nmSubWndMain::onConfirmClosing()
|
|
|
{
|
|
|
return iSubWndBaseAF::onConfirmClosing();
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::reservoirCharacteristics()
|
|
|
{
|
|
|
// 显示储藏特性的弹窗,设置参数,并保持到文件
|
|
|
nmWxRCDialog* dlg = new nmWxRCDialog;
|
|
|
dlg->exec();
|
|
|
}
|
|
|
|
|
|
void nmSubWndMain::geoLayering()
|
|
|
{
|
|
|
} |