You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Src/nmNum/nmSubWxs/nmAnalRun.cpp

342 lines
6.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <QMainWindow>
#include "zxSysUtils.h"
#include "zxLogInstance.h"
#include "mModuleDefines.h"
#include "iWxPvtMain.h"
#include "nmWxDataKrog.h"
#include "nmWxDataBasic.h"
#include "ZxDataWell.h"
#include "nmDataAnalInfo.h"
#include "nmDataAnalRun.h"
#include "nmAnalRun.h"
nmAnalRun::nmAnalRun()
{
m_pDataWell = NULL;
m_pDataAnalInfo = NULL;
m_pDataAnalRun = NULL;
m_vecWxDatas.clear();
m_listBasicInfos.clear();
m_bLoaded = false;
}
nmAnalRun::~nmAnalRun()
{
}
void nmAnalRun::init()
{
m_vecWxDatas.clear();
QStringList listPhases;
listPhases << s_Tag_Oil_EN << s_Tag_Gas_EN << s_Tag_Water_EN;
iWxPvtMain* pWx = new iWxPvtMain();
pWx->setPhaseInfos(listPhases);
QString sJobDir = "";
pWx->setJobTag(sJobDir);
pWx->setWizardMode(true);
m_vecWxDatas << new nmWxDataBasic();
m_vecWxDatas << pWx;//new iWxPvtMain();
m_vecWxDatas << new nmWxDataKrog();
// // Basic与PvtMain
connect(m_vecWxDatas[0], SIGNAL(sigParasChanged(QMap<QString,QVariant>&)), \
m_vecWxDatas[1], SLOT(slotParasObtained(QMap<QString,QVariant>&)));
// // Anal标识
connect(m_vecWxDatas[1], SIGNAL(sigGetJogTag(QString&)), \
m_vecWxDatas[0], SLOT(slotGetAnalTag(QString&)));
// connect(m_vecWxDatas[2], SIGNAL(sigGetJogTag(QString&)), \
// m_vecWxDatas[0], SLOT(slotGetAnalTag(QString&)));
foreach (iWxBase* p, m_vecWxDatas)
{
p->setDataWell(m_pDataWell);
}
}
void nmAnalRun::refresh()
{
foreach (iWxBase* p, m_vecWxDatas)
{
p->initUI();
}
if (NULL != m_pDataAnalInfo)
{
((nmWxDataBasic*)m_vecWxDatas[0])->setAnalName(m_pDataAnalInfo->getName());
}
if (NULL != m_pDataAnalRun)
{
QByteArray o = m_pDataAnalRun->getDataBasic();
m_vecWxDatas[0]->loadFromByteArr(o);
o = m_pDataAnalRun->getDataPvt();
m_vecWxDatas[1]->loadFromByteArr(o);
o = m_pDataAnalRun->getDataKrog();
m_vecWxDatas[2]->loadFromByteArr(o);
}
}
void nmAnalRun::onSerialize(ZxSerializer* ser)
{
int n = 0;
foreach (iWxBase* p, m_vecWxDatas)
{
QString sTag = QString("Jun_%1").arg(n++);
ser->push(sTag);
p->onSerialize(ser);
ser->pop();
}
}
void nmAnalRun::onDeserialize(ZxSerializer* ser)
{
int n = 0;
foreach (iWxBase* p, m_vecWxDatas)
{
QString sTag = QString("Jun_%1").arg(n++);
ser->push(sTag);
p->onDeserialize(ser);
ser->pop();
}
}
void nmAnalRun::setDataWell(ZxDataWell* p)
{
m_pDataWell = p;
foreach (iWxBase* p1, m_vecWxDatas)
{
p1->setDataWell(p);
}
}
void nmAnalRun::setDataAnalInfo(nmDataAnalInfo* p)
{
if (NULL == p)
{
return;
}
m_pDataAnalInfo = p;
if (NULL == m_pDataWell)
{
setDataWell(dynamic_cast<ZxDataWell*>(p->getParent()));
}
}
void nmAnalRun::setDataAnalRun(nmDataAnalRun* p)
{
m_pDataAnalRun = p;
}
nmDataAnalInfo* nmAnalRun::getDataAnalInfo()
{
return m_pDataAnalInfo;
}
nmDataAnalRun* nmAnalRun::getDataAnalRun()
{
return m_pDataAnalRun;
}
QString nmAnalRun::getAnalId()
{
if (NULL != m_pDataAnalInfo)
return m_pDataAnalInfo->getCode();
return "";
}
iWxBase* nmAnalRun::getWxDataOf(int n)
{
if (n >= 0 && n < m_vecWxDatas.count())
{
return m_vecWxDatas[n];
}
return NULL;
}
bool nmAnalRun::getBaseInfos(VecVariant &vec, int nColCount)
{
vec.clear();
if (NULL != m_pDataAnalInfo)
{
vec << m_pDataAnalInfo->getName();
vec << m_pDataAnalInfo->getCode();
}
else
{
vec << "";
vec << "";
}
if (m_listBasicInfos.count() == 3)
{
foreach (QString s, m_listBasicInfos)
{
vec << s;
}
}
else
{
vec << "" << "" << "";
}
if (NULL != m_pDataAnalInfo)
{
vec << m_pDataAnalInfo->getRemark();
}
else
{
vec << "";
}
return true;
}
void nmAnalRun::ensureLoaded()
{
if (m_bLoaded)
{
return;
}
init();
refresh();
m_bLoaded = true;
}
void nmAnalRun::setLoaded(bool b)
{
m_bLoaded = b;
}
bool nmAnalRun::saveBasicAsByteArr(QByteArray& v)
{
QString sRoot = this->objectName() + "abc";
ZxXpfDoc xpf(sRoot);
ZxSerializer ser(&xpf, true);
// onSerialize(&ser);
{
QString s1 = "", s2 = "";
double f = SYS_VALUE_INVALID;
bool b = false;
nmWxDataBasic* pBasic = dynamic_cast<nmWxDataBasic*>(getWxDataOf(0));
if (NULL != pBasic)
{
s1 = pBasic->getTestType();
s2 = pBasic->getFluidOption();
f = pBasic->getWellR();
b = pBasic->isPhaseS();
}
ser.write("TestType", s1);
ser.write("FluidOption", s2);
ser.write("WellR", f);
ser.write("SinglePhase", b);
// 只有新建Anal时用到特殊处理
if (m_listBasicInfos.count() == 0)
{
m_listBasicInfos << s1 << s2 << QString("%1").arg(f);
}
}
QDataStream out(&v, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_8);
if (xpf.save(out))
{
return true;
}
else
{
return false;
}
}
bool nmAnalRun::loadLoadFromByteArr(QByteArray& v)
{
if (v.isEmpty() || v.isNull())
{
return false;
}
QDataStream in(&v, QIODevice::ReadOnly);
in.setVersion(QDataStream::Qt_4_8);
QString sRoot = this->objectName() + "abc";
ZxXpfDoc xpf(sRoot);
if (!xpf.load(in))
{
zxLogRunW(tr("Failed to load ByteArray"));
return false;
}
ZxSerializer ser(&xpf, false);
//onDeserialize(&ser);
QString s1 = "", s2 = "";
double f = SYS_VALUE_INVALID;
//bool b = true;
ser.read("TestType", s1);
ser.read("FluidOption", s2);
ser.read("WellR", f);
m_listBasicInfos.clear();
m_listBasicInfos << s1 << s2 << QString("%1").arg(f);
return true;
}
bool nmAnalRun::isPhaseS()
{
nmWxDataBasic* pBasic = dynamic_cast<nmWxDataBasic*>(getWxDataOf(0));
if (NULL != pBasic)
{
return pBasic->isPhaseS();
}
if (m_pDataAnalInfo != NULL)
{
QString s = m_pDataAnalInfo->getRemark();
if (!s.isEmpty())
{
return _isSame(s, s_Tag_Phase_S);
}
}
return true;
}
QString nmAnalRun::getTestType()
{
if (m_listBasicInfos.count() > 0)
{
return m_listBasicInfos.at(0);
}
return "";
}
QString nmAnalRun::getFluidOption()
{
if (m_listBasicInfos.count() > 1)
{
return m_listBasicInfos.at(1);
}
// else
// {
// ensureLoaded();
// nmWxDataBasic* pBasic = dynamic_cast<nmWxDataBasic*>(getWxDataOf(0));
// if (NULL != pBasic)
// {
// return pBasic->getFluidOption();
// }
// }
return "";
}