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.
nmWTAI-Platform/Src/nmNum/nmData/nmPebiResultPropertyCatalog...

89 lines
3.2 KiB
C++

#include "nmPebiResultPropertyCatalog.h"
namespace {
nmPebiResultPropertyDescriptor makeDescriptor(
const char* pPropertyId,
const char* pDisplayNameSourceText,
const char* pBaseUnit,
NM_PEBI_RESULT_PROPERTY_TIME_TYPE eTimeType,
NM_PEBI_RESULT_PROPERTY_SOURCE eSource,
NM_PEBI_RESULT_PROPERTY_RANGE_POLICY eRangePolicy)
{
nmPebiResultPropertyDescriptor oDescriptor;
oDescriptor.m_sPropertyId = QString::fromLatin1(pPropertyId);
oDescriptor.m_sDisplayNameSourceText =
QString::fromLatin1(pDisplayNameSourceText);
oDescriptor.m_sBaseUnit = QString::fromLatin1(pBaseUnit);
oDescriptor.m_sDefaultDisplayUnit = oDescriptor.m_sBaseUnit;
oDescriptor.m_eTimeType = eTimeType;
oDescriptor.m_eSource = eSource;
oDescriptor.m_eAssociation =
NM_PebiResultPropertyAssociation_CellData;
oDescriptor.m_eRangePolicy = eRangePolicy;
return oDescriptor;
}
}
nmPebiResultPropertyDescriptor::nmPebiResultPropertyDescriptor()
: m_eTimeType(NM_PebiResultProperty_Static),
m_eSource(NM_PebiResultPropertySource_StaticCalculation),
m_eAssociation(NM_PebiResultPropertyAssociation_CellData),
m_eRangePolicy(NM_PebiResultPropertyRange_CurrentArray)
{
}
QList<nmPebiResultPropertyDescriptor>
nmPebiResultPropertyCatalog::descriptors()
{
// 每次返回值副本,避免 VS2010 下函数静态容器的并发初始化问题。
QList<nmPebiResultPropertyDescriptor> listDescriptors;
listDescriptors.append(makeDescriptor(
"permeability", "Permeability", "mD",
NM_PebiResultProperty_Static,
NM_PebiResultPropertySource_StaticCalculation,
NM_PebiResultPropertyRange_CurrentArray));
listDescriptors.append(makeDescriptor(
"porosity", "Porosity", "",
NM_PebiResultProperty_Static,
NM_PebiResultPropertySource_StaticCalculation,
NM_PebiResultPropertyRange_CurrentArray));
listDescriptors.append(makeDescriptor(
"thickness", "Thickness", "m",
NM_PebiResultProperty_Static,
NM_PebiResultPropertySource_StaticCalculation,
NM_PebiResultPropertyRange_CurrentArray));
listDescriptors.append(makeDescriptor(
"pressure", "Pressure", "MPa",
NM_PebiResultProperty_Dynamic,
NM_PebiResultPropertySource_SolverOutput,
NM_PebiResultPropertyRange_AllFrames));
return listDescriptors;
}
bool nmPebiResultPropertyCatalog::findDescriptor(
const QString& sPropertyId,
nmPebiResultPropertyDescriptor& oDescriptor)
{
const QList<nmPebiResultPropertyDescriptor> listDescriptors =
descriptors();
for(int nIndex = 0; nIndex < listDescriptors.size(); ++nIndex) {
if(listDescriptors[nIndex].m_sPropertyId == sPropertyId) {
oDescriptor = listDescriptors[nIndex];
return true;
}
}
// 查询失败时清除调用方旧值,避免把上一次命中的描述误当成当前属性。
oDescriptor = nmPebiResultPropertyDescriptor();
return false;
}
bool nmPebiResultPropertyCatalog::isKnownProperty(
const QString& sPropertyId)
{
nmPebiResultPropertyDescriptor oDescriptor;
return findDescriptor(sPropertyId, oDescriptor);
}