|
|
|
|
|
#include "nmPebiResultDisplaySettings.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(_MSC_VER)
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
|
|
// Qt 4.8 未统一提供 qIsFinite,保持值类型不依赖 VTK。
|
|
|
|
|
|
bool isFiniteDisplayValue(double dValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
|
return _finite(dValue) != 0;
|
|
|
|
|
|
#else
|
|
|
|
|
|
return std::isfinite(dValue);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nmPebiResultDisplaySettings::nmPebiResultDisplaySettings()
|
|
|
|
|
|
: m_sColorMapId(QString::fromLatin1("rainbow")),
|
|
|
|
|
|
m_eScaleMode(NM_PebiColorScale_Linear),
|
|
|
|
|
|
m_bHasManualRange(false),
|
|
|
|
|
|
m_dManualMinimum(0.0),
|
|
|
|
|
|
m_dManualMaximum(0.0),
|
|
|
|
|
|
m_bUseBelowRangeColor(false),
|
|
|
|
|
|
m_bUseAboveRangeColor(false),
|
|
|
|
|
|
m_oBelowRangeColor(Qt::black),
|
|
|
|
|
|
m_oAboveRangeColor(Qt::black)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool nmPebiResultDisplaySettings::isStructurallyValid() const
|
|
|
|
|
|
{
|
|
|
|
|
|
const bool bScaleModeValid =
|
|
|
|
|
|
m_eScaleMode == NM_PebiColorScale_Linear ||
|
|
|
|
|
|
m_eScaleMode == NM_PebiColorScale_Logarithmic;
|
|
|
|
|
|
return bScaleModeValid &&
|
|
|
|
|
|
isFiniteDisplayValue(m_dManualMinimum) &&
|
|
|
|
|
|
isFiniteDisplayValue(m_dManualMaximum) &&
|
|
|
|
|
|
m_oBelowRangeColor.isValid() &&
|
|
|
|
|
|
m_oAboveRangeColor.isValid();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nmPebiResultDisplaySettings
|
|
|
|
|
|
nmPebiResultDisplaySettings::normalized() const
|
|
|
|
|
|
{
|
|
|
|
|
|
nmPebiResultDisplaySettings oResult(*this);
|
|
|
|
|
|
if(!oResult.m_bHasManualRange) {
|
|
|
|
|
|
// 自动范围不携带历史手工值,避免相等比较出现不可见差异。
|
|
|
|
|
|
oResult.m_dManualMinimum = 0.0;
|
|
|
|
|
|
oResult.m_dManualMaximum = 0.0;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(oResult.m_oBelowRangeColor.isValid()) {
|
|
|
|
|
|
oResult.m_oBelowRangeColor.setAlpha(255);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(oResult.m_oAboveRangeColor.isValid()) {
|
|
|
|
|
|
oResult.m_oAboveRangeColor.setAlpha(255);
|
|
|
|
|
|
}
|
|
|
|
|
|
return oResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool nmPebiResultDisplaySettings::operator==(
|
|
|
|
|
|
const nmPebiResultDisplaySettings& oOther) const
|
|
|
|
|
|
{
|
|
|
|
|
|
const nmPebiResultDisplaySettings oLeft = normalized();
|
|
|
|
|
|
const nmPebiResultDisplaySettings oRight = oOther.normalized();
|
|
|
|
|
|
return oLeft.m_sColorMapId == oRight.m_sColorMapId &&
|
|
|
|
|
|
oLeft.m_eScaleMode == oRight.m_eScaleMode &&
|
|
|
|
|
|
oLeft.m_bHasManualRange == oRight.m_bHasManualRange &&
|
|
|
|
|
|
oLeft.m_dManualMinimum == oRight.m_dManualMinimum &&
|
|
|
|
|
|
oLeft.m_dManualMaximum == oRight.m_dManualMaximum &&
|
|
|
|
|
|
oLeft.m_bUseBelowRangeColor ==
|
|
|
|
|
|
oRight.m_bUseBelowRangeColor &&
|
|
|
|
|
|
oLeft.m_bUseAboveRangeColor ==
|
|
|
|
|
|
oRight.m_bUseAboveRangeColor &&
|
|
|
|
|
|
oLeft.m_oBelowRangeColor == oRight.m_oBelowRangeColor &&
|
|
|
|
|
|
oLeft.m_oAboveRangeColor == oRight.m_oAboveRangeColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool nmPebiResultDisplaySettings::operator!=(
|
|
|
|
|
|
const nmPebiResultDisplaySettings& oOther) const
|
|
|
|
|
|
{
|
|
|
|
|
|
return !(*this == oOther);
|
|
|
|
|
|
}
|