#include "nmPebiResultPropertyDisplayText.h" #include "nmPebiResultPropertyCatalog.h" #include #include namespace { /* Qt 4.8 的 lupdate 无法追踪运行时 Catalog 字符串,必须显式登记。 */ static const char* const s_pPropertyTranslationMarkers[] = { QT_TRANSLATE_NOOP("nmPebiResultProperty", "Permeability"), QT_TRANSLATE_NOOP("nmPebiResultProperty", "Porosity"), QT_TRANSLATE_NOOP("nmPebiResultProperty", "Thickness"), QT_TRANSLATE_NOOP("nmPebiResultProperty", "Pressure") }; } QString nmPebiResultPropertyDisplayText::getDisplayName( const QString& sPropertyId) { Q_UNUSED(s_pPropertyTranslationMarkers); nmPebiResultPropertyDescriptor oDescriptor; if(!nmPebiResultPropertyCatalog::findDescriptor( sPropertyId, oDescriptor)) { return QString(); } const QByteArray baSourceText = oDescriptor.m_sDisplayNameSourceText.toLatin1(); return QCoreApplication::translate( "nmPebiResultProperty", baSourceText.constData()); } QString nmPebiResultPropertyDisplayText::getScalarBarTitle( const QString& sPropertyId) { nmPebiResultPropertyDescriptor oDescriptor; if(!nmPebiResultPropertyCatalog::findDescriptor( sPropertyId, oDescriptor)) { return QString(); } // VTK 标题只映射稳定的 ASCII 属性符号,单位始终由 Catalog 唯一提供。 QString sTitle; if(sPropertyId == QString::fromLatin1("pressure")) { sTitle = QString::fromLatin1("p"); } if(sPropertyId == QString::fromLatin1("permeability")) { sTitle = QString::fromLatin1("k"); } if(sPropertyId == QString::fromLatin1("porosity")) { sTitle = QString::fromLatin1("phi"); } if(sPropertyId == QString::fromLatin1("thickness")) { sTitle = QString::fromLatin1("h"); } if(sTitle.isEmpty()) { return QString(); } if(!oDescriptor.m_sDefaultDisplayUnit.isEmpty()) { sTitle += QString::fromLatin1(" ") + oDescriptor.m_sDefaultDisplayUnit; } return sTitle; } QString nmPebiResultPropertyDisplayText::getDefaultDisplayUnit( const QString& sPropertyId) { nmPebiResultPropertyDescriptor oDescriptor; return nmPebiResultPropertyCatalog::findDescriptor( sPropertyId, oDescriptor) ? oDescriptor.m_sDefaultDisplayUnit : QString(); }