#include "zxLogInstance.h" #include "iRibbonXmlCmd.h" #include "nmSubWndMain.h" #include "nmSubWndGrid.h" #include "nmSubWndPostprocessing.h" #include "nmSubWndUtils.h" #include "nmWxNewNormalDlg.h" #include "nmWxParaProperty.h" #include "nmDataDemo.h" #include "ZxDataProject.h" #include "zxSysUtils.h" #ifdef MY_OWN_GRID #include "iSubWndGrid.h" #else #include "nmSubWndDemo.h" #endif #include "nmWxWizard.h" #include "nmWxGridDlg.h" #include "nmCalculationDefine.h" #include "nmDataAnalInfo.h" #include "nmDataAnalRun.h" #include "nmAnalRun.h" #include "nmSubWndUtils.h" iSubWnd* nmSubWndUtils::createSubWnd(iRibbonXmlCmd* pCmdInfo) { if (NULL == pCmdInfo) { return NULL; } return createSubWnd(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo); } iSubWnd* nmSubWndUtils::createSubWnd(QString sID, QString sExt) { iSubWnd* pSubWnd = NULL; // Here is your own codes int nID = sID.toInt(); if (nID == 5001) { // 初始化一个数据类 // TODO,先弹窗做新建分析,再创建subWnd nmWxNewNormalDlg dlg(NULL); if (dlg.exec() == QDialog::Rejected) { // 对话框被用户显式拒绝 // 在这里处理你的逻辑 return nullptr; } // TODO,是否已经建立了新建分析 nmSubWndMain* pSubWndMain = new nmSubWndMain(NULL, sExt); pSubWnd = pSubWndMain; } else if (nID == 5114) { double dGridSize = 0.5; int iGridType = NM_Grid_Triangle; // 网格大小、类型 nmWxGridDlg dlg(&dGridSize, &iGridType); if (dlg.exec() == QDialog::Rejected) { return NULL; } // 网格 nmSubWndGrid* pSubWndGrid = new nmSubWndGrid(NULL, sExt); pSubWnd = pSubWndGrid; } else if (nID == 5116) { // 后处理 nmSubWndPostprocessing* pSubWndPostProcessing = new nmSubWndPostprocessing(NULL, sExt); pSubWnd = pSubWndPostProcessing; } if (NULL != pSubWnd) { // TODO 此处根据需要设置 改变 标识 pSubWnd->setModified(true); } return pSubWnd; } bool nmSubWndUtils::runCmdBySpecial(iRibbonXmlCmd* pCmdInfo) { if (NULL == pCmdInfo) { return false; } return runCmdBySpecial(pCmdInfo->m_sID, pCmdInfo->m_sExtInfo); } bool nmSubWndUtils::runCmdBySpecial(QString sID, QString sExt) { // Here is your own codes if (_isSame(sID, "12345")) { QMessageBox::information(NULL, zxAppID, QObject::tr("I am abc")); return true; } else { return false; } } bool nmSubWndUtils::isEnableOfID_Common(QString sID, QString sName, const bool bLicensed) { // 如果是5001,即 新建PVT if (sID.toInt() == 5001) { return true; } // Here is your own codes if (_isSame(sName, "NmDemo")) { return (bLicensed); } else { return false; } } bool nmSubWndUtils::runCmd_NewAnal() { ZxDataProject* pProject = zxCurProject; Q_ASSERT (NULL != pProject); nmDataAnalInfo* pAnal = new nmDataAnalInfo(); Q_ASSERT (NULL != pAnal); pAnal->setCode(pAnal->getDefaultCode(pProject)); //作为工区子节点 QString sName = tr("New Anal %1").arg(ZxBaseUtil::getSysDateTime()); pAnal->setName(sName); nmAnalRun* pAnalRun = new nmAnalRun(); Q_ASSERT (NULL != pAnalRun); pAnalRun->setDataAnalInfo(pAnal); pAnalRun->init(); pAnalRun->refresh(); pAnalRun->setLoaded(true); // Wizard nmWxWizard* m_pWxWizard = NULL; if (NULL != m_pWxWizard) { delete m_pWxWizard; m_pWxWizard = NULL; } m_pWxWizard = new nmWxWizard(); Q_ASSERT (NULL != m_pWxWizard); m_pWxWizard->setWsm(nmWxWizard::NM_WSM_All); m_pWxWizard->appendSubWx(pAnalRun->getWxDataOf(0)); m_pWxWizard->appendSubWx(pAnalRun->getWxDataOf(1)); m_pWxWizard->appendSubWx(pAnalRun->getWxDataOf(2)); m_pWxWizard->initUI(); Q_ASSERT (NULL != m_pWxWizard); if (m_pWxWizard->exec() != QDialog::Accepted) { // 删除上面新建 delete pAnalRun; pAnalRun = NULL; return false; } /* // 把Anal放入内存并且保存 { bool bPs3Valid = pAnalRun->isPs3Valid(); nmWxDataBasic* pBasic = dynamic_cast(pAnalRun->getWxDataOf(0)); QString sName = pAnal->getName(); if (NULL != pBasic) { sName = pBasic->getAnalName(); QString ss = pBasic->getFluidOption(); pAnal->setAnalType(ss); bool b = pBasic->isPhaseS(); QString sPhase = (b ? s_Tag_Phase_S : s_Tag_Phase_M); if (!b && bPs3Valid) sPhase += QString("(%1)").arg(s_Tag_Phase_PS3); pAnal->setRemark(sPhase); } pAnal->setName(sName); if (NULL != p) { p->setText(0, sName); } { if (NULL != m_pCurDataWell) pAnal->setWellCode(m_pCurDataWell->getCode()); pAnal->setCreator(ZxBaseUtil::getSysUserName()); pAnal->setCreatedTime(ZxBaseUtil::getSysDateTime()); // pAnal->setModifier(ZxBaseUtil::getSysUserName()); // pAnal->setModifiedTime(ZxBaseUtil::getSysDateTime()); // if (NULL != pBasic) // { // sName = pBasic->getAnalName(); // } // pAnal->setAnalType() pProject->appendChild(pAnal); pAnal->save(); //保存入库吗? // 增加AnalRun的处理 { nmDataAnalRun* pDataAnalRun = new nmDataAnalRun(); Q_ASSERT (NULL != pDataAnalRun); pDataAnalRun->setCode(pAnal->getCode()); int n = 0; QByteArray v1; if (pAnalRun->getWxDataOf(n++)->saveAsByteArr(v1)) { pDataAnalRun->setDataBasic(v1); } QByteArray v2; if (pAnalRun->getWxDataOf(n++)->saveAsByteArr(v2)) { pDataAnalRun->setDataPvt(v2); } QByteArray v3; if (pAnalRun->getWxDataOf(n++)->saveAsByteArr(v3)) { pDataAnalRun->setDataKrog(v3); } QByteArray v4; if (pAnalRun->saveBasicAsByteArr(v4)) { pDataAnalRun->setExt1(v4); } pDataAnalRun->setLoaded(true); pDataAnalRun->save(); pAnalRun->setDataAnalRun(pDataAnalRun); } } } // AnalUtils进行管理 { if (NULL != p) { p->setDataObj(pAnalRun->getDataAnalInfo()); } m_vecAnalRuns << pAnalRun; iModuleHelper::setCurAnalRun(pAnalRun, pAnalRun->getAnalId()); if (!bByLeftTree && NULL != m_pMainTreeWxJb) { m_pMainTreeWxJb->refresh(); } }//*/ return true; }