|
|
|
|
@ -0,0 +1,484 @@
|
|
|
|
|
#include "nmWxPebiResultColorScaleSettingsDlg.h"
|
|
|
|
|
|
|
|
|
|
#include "nmPebiResultPropertyDisplayText.h"
|
|
|
|
|
#include "nmPebiResultSceneController.h"
|
|
|
|
|
#include "nmVTKColorMapCatalog.h"
|
|
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QColorDialog>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QLocale>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSize>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
|
|
#if !defined(_MSC_VER)
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/* Qt 4.8 lupdate 无法追踪按稳定 ID 选择的运行时色带名称,固定登记源文字。 */
|
|
|
|
|
static const char* const s_pColorDialogTranslationMarkers[] =
|
|
|
|
|
{
|
|
|
|
|
QT_TRANSLATE_NOOP("nmWxPebiResultColorScaleSettingsDlg", "Rainbow"),
|
|
|
|
|
QT_TRANSLATE_NOOP("nmWxPebiResultColorScaleSettingsDlg", "Oil saturation"),
|
|
|
|
|
QT_TRANSLATE_NOOP("nmWxPebiResultColorScaleSettingsDlg", "Gas saturation"),
|
|
|
|
|
QT_TRANSLATE_NOOP("nmWxPebiResultColorScaleSettingsDlg", "Water saturation")
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Qt 4.8 未统一提供 qIsFinite,解析后必须显式拒绝 NaN 和无穷值。
|
|
|
|
|
bool isFiniteEditorValue(double dValue)
|
|
|
|
|
{
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
return _finite(dValue) != 0;
|
|
|
|
|
#else
|
|
|
|
|
return std::isfinite(dValue);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString colorMapDisplayName(const QString& sColorMapId)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(s_pColorDialogTranslationMarkers);
|
|
|
|
|
const char* pSourceText = "Rainbow";
|
|
|
|
|
if(sColorMapId == QString::fromLatin1("oil-saturation")) {
|
|
|
|
|
pSourceText = "Oil saturation";
|
|
|
|
|
} else if(sColorMapId == QString::fromLatin1("gas-saturation")) {
|
|
|
|
|
pSourceText = "Gas saturation";
|
|
|
|
|
} else if(sColorMapId == QString::fromLatin1("water-saturation")) {
|
|
|
|
|
pSourceText = "Water saturation";
|
|
|
|
|
}
|
|
|
|
|
return QCoreApplication::translate(
|
|
|
|
|
"nmWxPebiResultColorScaleSettingsDlg", pSourceText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString resultColorIconPath(const QString& sFileName)
|
|
|
|
|
{
|
|
|
|
|
const QString sApplicationDir = QCoreApplication::applicationDirPath();
|
|
|
|
|
return sApplicationDir.section('/', 0, -2) +
|
|
|
|
|
"/Res/Icon/" + sFileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultColorScaleSettingsDlg::
|
|
|
|
|
nmWxPebiResultColorScaleSettingsDlg(
|
|
|
|
|
nmPebiResultSceneController* pSceneController,
|
|
|
|
|
QWidget* pParent)
|
|
|
|
|
: QDialog(pParent),
|
|
|
|
|
m_pSceneController(pSceneController),
|
|
|
|
|
m_bManualRangeEdited(false),
|
|
|
|
|
m_bInitialized(false),
|
|
|
|
|
m_pColorMapCombo(nullptr),
|
|
|
|
|
m_pMinimumEdit(nullptr),
|
|
|
|
|
m_pMaximumEdit(nullptr),
|
|
|
|
|
m_pUnitLabel(nullptr),
|
|
|
|
|
m_pRestoreRangeButton(nullptr),
|
|
|
|
|
m_pLogarithmicCheck(nullptr),
|
|
|
|
|
m_pLogReasonLabel(nullptr),
|
|
|
|
|
m_pBelowRangeCheck(nullptr),
|
|
|
|
|
m_pBelowColorButton(nullptr),
|
|
|
|
|
m_pAboveRangeCheck(nullptr),
|
|
|
|
|
m_pAboveColorButton(nullptr),
|
|
|
|
|
m_pErrorLabel(nullptr),
|
|
|
|
|
m_pApplyButton(nullptr),
|
|
|
|
|
m_pOkButton(nullptr)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(m_pSceneController != nullptr);
|
|
|
|
|
m_dPropertyRange[0] = 0.0;
|
|
|
|
|
m_dPropertyRange[1] = 0.0;
|
|
|
|
|
createUi();
|
|
|
|
|
m_bInitialized = initializeFromScene();
|
|
|
|
|
m_pApplyButton->setEnabled(m_bInitialized);
|
|
|
|
|
m_pOkButton->setEnabled(m_bInitialized);
|
|
|
|
|
if(!m_bInitialized) {
|
|
|
|
|
setErrorText(tr("The result color settings are unavailable."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultColorScaleSettingsDlg::
|
|
|
|
|
~nmWxPebiResultColorScaleSettingsDlg()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onApplyClicked()
|
|
|
|
|
{
|
|
|
|
|
applyEditor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onOkClicked()
|
|
|
|
|
{
|
|
|
|
|
if(applyEditor()) {
|
|
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onRestorePropertyRangeClicked()
|
|
|
|
|
{
|
|
|
|
|
m_bManualRangeEdited = false;
|
|
|
|
|
m_pMinimumEdit->setText(formatValue(m_dPropertyRange[0]));
|
|
|
|
|
m_pMaximumEdit->setText(formatValue(m_dPropertyRange[1]));
|
|
|
|
|
refreshLogAvailability();
|
|
|
|
|
setErrorText(QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onManualRangeEdited(
|
|
|
|
|
const QString& sText)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(sText);
|
|
|
|
|
m_bManualRangeEdited = true;
|
|
|
|
|
refreshLogAvailability();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onBelowRangeToggled(bool bChecked)
|
|
|
|
|
{
|
|
|
|
|
m_pBelowColorButton->setEnabled(bChecked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onAboveRangeToggled(bool bChecked)
|
|
|
|
|
{
|
|
|
|
|
m_pAboveColorButton->setEnabled(bChecked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onChooseBelowRangeColor()
|
|
|
|
|
{
|
|
|
|
|
QColor oColor = QColorDialog::getColor(
|
|
|
|
|
m_oBaselineSettings.m_oBelowRangeColor, this,
|
|
|
|
|
tr("Below minimum color"));
|
|
|
|
|
if(oColor.isValid()) {
|
|
|
|
|
oColor.setAlpha(255);
|
|
|
|
|
m_oBaselineSettings.m_oBelowRangeColor = oColor;
|
|
|
|
|
updateColorButton(m_pBelowColorButton, oColor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::onChooseAboveRangeColor()
|
|
|
|
|
{
|
|
|
|
|
QColor oColor = QColorDialog::getColor(
|
|
|
|
|
m_oBaselineSettings.m_oAboveRangeColor, this,
|
|
|
|
|
tr("Above maximum color"));
|
|
|
|
|
if(oColor.isValid()) {
|
|
|
|
|
oColor.setAlpha(255);
|
|
|
|
|
m_oBaselineSettings.m_oAboveRangeColor = oColor;
|
|
|
|
|
updateColorButton(m_pAboveColorButton, oColor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::refreshLogAvailability()
|
|
|
|
|
{
|
|
|
|
|
double dMinimum = 0.0;
|
|
|
|
|
const bool bMinimumValid =
|
|
|
|
|
parseFiniteValue(m_pMinimumEdit->text(), dMinimum);
|
|
|
|
|
const bool bPropertyPositive = m_dPropertyRange[0] > 0.0;
|
|
|
|
|
const bool bDisplayPositive = bMinimumValid && dMinimum > 0.0;
|
|
|
|
|
const bool bAvailable = bPropertyPositive && bDisplayPositive;
|
|
|
|
|
if(!bAvailable && m_pLogarithmicCheck->isChecked()) {
|
|
|
|
|
// 禁用前先清除不可提交的 Log 状态,避免用户被锁在失败循环中。
|
|
|
|
|
const bool bSignalsBlocked =
|
|
|
|
|
m_pLogarithmicCheck->blockSignals(true);
|
|
|
|
|
m_pLogarithmicCheck->setChecked(false);
|
|
|
|
|
m_pLogarithmicCheck->blockSignals(bSignalsBlocked);
|
|
|
|
|
}
|
|
|
|
|
m_pLogarithmicCheck->setEnabled(bAvailable);
|
|
|
|
|
if(!bPropertyPositive) {
|
|
|
|
|
m_pLogReasonLabel->setText(
|
|
|
|
|
tr("Logarithmic scale requires a positive property range."));
|
|
|
|
|
} else if(!bDisplayPositive) {
|
|
|
|
|
m_pLogReasonLabel->setText(
|
|
|
|
|
tr("Logarithmic scale requires a positive minimum."));
|
|
|
|
|
} else {
|
|
|
|
|
m_pLogReasonLabel->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::createUi()
|
|
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Color settings for current property"));
|
|
|
|
|
setModal(true);
|
|
|
|
|
|
|
|
|
|
m_pColorMapCombo = new QComboBox(this);
|
|
|
|
|
m_pColorMapCombo->setIconSize(QSize(128, 16));
|
|
|
|
|
m_pColorMapCombo->setMinimumWidth(260);
|
|
|
|
|
const QStringList listColorMapIds =
|
|
|
|
|
nmVTKColorMapCatalog::getColorMapIds();
|
|
|
|
|
for(int nIndex = 0; nIndex < listColorMapIds.size(); ++nIndex) {
|
|
|
|
|
const QString& sId = listColorMapIds[nIndex];
|
|
|
|
|
m_pColorMapCombo->addItem(
|
|
|
|
|
QIcon(nmVTKColorMapCatalog::createPreviewPixmap(
|
|
|
|
|
sId, QSize(128, 16))),
|
|
|
|
|
colorMapDisplayName(sId), sId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_pMinimumEdit = new QLineEdit(this);
|
|
|
|
|
m_pMaximumEdit = new QLineEdit(this);
|
|
|
|
|
m_pUnitLabel = new QLabel(this);
|
|
|
|
|
m_pMinimumEdit->setAlignment(Qt::AlignRight);
|
|
|
|
|
m_pMaximumEdit->setAlignment(Qt::AlignRight);
|
|
|
|
|
m_pRestoreRangeButton = new QToolButton(this);
|
|
|
|
|
m_pRestoreRangeButton->setAutoRaise(true);
|
|
|
|
|
m_pRestoreRangeButton->setFixedSize(24, 24);
|
|
|
|
|
m_pRestoreRangeButton->setIconSize(QSize(16, 16));
|
|
|
|
|
m_pRestoreRangeButton->setIcon(QIcon(resultColorIconPath(
|
|
|
|
|
QString::fromLatin1("Undo.png"))));
|
|
|
|
|
m_pRestoreRangeButton->setToolTip(tr("Restore property range"));
|
|
|
|
|
|
|
|
|
|
QHBoxLayout* pMinimumLayout = new QHBoxLayout();
|
|
|
|
|
pMinimumLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
pMinimumLayout->addWidget(m_pMinimumEdit, 1);
|
|
|
|
|
pMinimumLayout->addWidget(m_pRestoreRangeButton);
|
|
|
|
|
QWidget* pMinimumWidget = new QWidget(this);
|
|
|
|
|
pMinimumWidget->setLayout(pMinimumLayout);
|
|
|
|
|
|
|
|
|
|
m_pLogarithmicCheck = new QCheckBox(tr("Logarithmic scale"), this);
|
|
|
|
|
m_pLogReasonLabel = new QLabel(this);
|
|
|
|
|
m_pLogReasonLabel->setWordWrap(true);
|
|
|
|
|
m_pLogReasonLabel->setStyleSheet(
|
|
|
|
|
QString::fromLatin1("color: #666666;"));
|
|
|
|
|
|
|
|
|
|
m_pBelowRangeCheck = new QCheckBox(tr("Below min"), this);
|
|
|
|
|
m_pBelowColorButton = new QPushButton(this);
|
|
|
|
|
m_pBelowColorButton->setFixedSize(44, 22);
|
|
|
|
|
QHBoxLayout* pBelowLayout = new QHBoxLayout();
|
|
|
|
|
pBelowLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
pBelowLayout->addWidget(m_pBelowRangeCheck);
|
|
|
|
|
pBelowLayout->addWidget(m_pBelowColorButton);
|
|
|
|
|
pBelowLayout->addStretch();
|
|
|
|
|
QWidget* pBelowWidget = new QWidget(this);
|
|
|
|
|
pBelowWidget->setLayout(pBelowLayout);
|
|
|
|
|
|
|
|
|
|
m_pAboveRangeCheck = new QCheckBox(tr("Above max"), this);
|
|
|
|
|
m_pAboveColorButton = new QPushButton(this);
|
|
|
|
|
m_pAboveColorButton->setFixedSize(44, 22);
|
|
|
|
|
QHBoxLayout* pAboveLayout = new QHBoxLayout();
|
|
|
|
|
pAboveLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
pAboveLayout->addWidget(m_pAboveRangeCheck);
|
|
|
|
|
pAboveLayout->addWidget(m_pAboveColorButton);
|
|
|
|
|
pAboveLayout->addStretch();
|
|
|
|
|
QWidget* pAboveWidget = new QWidget(this);
|
|
|
|
|
pAboveWidget->setLayout(pAboveLayout);
|
|
|
|
|
|
|
|
|
|
QFormLayout* pFormLayout = new QFormLayout();
|
|
|
|
|
pFormLayout->addRow(tr("Color map"), m_pColorMapCombo);
|
|
|
|
|
pFormLayout->addRow(tr("Minimum"), pMinimumWidget);
|
|
|
|
|
pFormLayout->addRow(tr("Maximum"), m_pMaximumEdit);
|
|
|
|
|
pFormLayout->addRow(tr("Unit"), m_pUnitLabel);
|
|
|
|
|
pFormLayout->addRow(QString(), m_pLogarithmicCheck);
|
|
|
|
|
pFormLayout->addRow(QString(), m_pLogReasonLabel);
|
|
|
|
|
pFormLayout->addRow(QString(), pBelowWidget);
|
|
|
|
|
pFormLayout->addRow(QString(), pAboveWidget);
|
|
|
|
|
|
|
|
|
|
m_pErrorLabel = new QLabel(this);
|
|
|
|
|
m_pErrorLabel->setWordWrap(true);
|
|
|
|
|
m_pErrorLabel->setStyleSheet(QString::fromLatin1("color: #b42318;"));
|
|
|
|
|
m_pErrorLabel->hide();
|
|
|
|
|
|
|
|
|
|
QDialogButtonBox* pButtonBox = new QDialogButtonBox(
|
|
|
|
|
QDialogButtonBox::Apply | QDialogButtonBox::Ok |
|
|
|
|
|
QDialogButtonBox::Cancel,
|
|
|
|
|
Qt::Horizontal, this);
|
|
|
|
|
m_pApplyButton = pButtonBox->button(QDialogButtonBox::Apply);
|
|
|
|
|
m_pOkButton = pButtonBox->button(QDialogButtonBox::Ok);
|
|
|
|
|
connect(m_pApplyButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onApplyClicked()));
|
|
|
|
|
connect(m_pOkButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onOkClicked()));
|
|
|
|
|
connect(pButtonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(reject()));
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
|
|
|
|
|
pMainLayout->addLayout(pFormLayout);
|
|
|
|
|
pMainLayout->addWidget(m_pErrorLabel);
|
|
|
|
|
pMainLayout->addWidget(pButtonBox);
|
|
|
|
|
setMinimumWidth(420);
|
|
|
|
|
|
|
|
|
|
connect(m_pRestoreRangeButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onRestorePropertyRangeClicked()));
|
|
|
|
|
connect(m_pMinimumEdit, SIGNAL(textEdited(QString)),
|
|
|
|
|
this, SLOT(onManualRangeEdited(QString)));
|
|
|
|
|
connect(m_pMaximumEdit, SIGNAL(textEdited(QString)),
|
|
|
|
|
this, SLOT(onManualRangeEdited(QString)));
|
|
|
|
|
connect(m_pBelowRangeCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onBelowRangeToggled(bool)));
|
|
|
|
|
connect(m_pAboveRangeCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onAboveRangeToggled(bool)));
|
|
|
|
|
connect(m_pBelowColorButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onChooseBelowRangeColor()));
|
|
|
|
|
connect(m_pAboveColorButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onChooseAboveRangeColor()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultColorScaleSettingsDlg::initializeFromScene()
|
|
|
|
|
{
|
|
|
|
|
if(m_pSceneController == nullptr || !m_pSceneController->hasSnapshot()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_sExpectedSnapshotId = m_pSceneController->getCurrentSnapshotId();
|
|
|
|
|
m_sExpectedPropertyId = m_pSceneController->getCurrentPropertyId();
|
|
|
|
|
m_sDisplayUnit = nmPebiResultPropertyDisplayText::getDefaultDisplayUnit(
|
|
|
|
|
m_sExpectedPropertyId);
|
|
|
|
|
m_pUnitLabel->setText(m_sDisplayUnit.isEmpty()
|
|
|
|
|
? tr("Dimensionless") : m_sDisplayUnit);
|
|
|
|
|
double dVisibleRange[2] = { 0.0, 0.0 };
|
|
|
|
|
if(m_sExpectedSnapshotId.isEmpty() || m_sExpectedPropertyId.isEmpty() ||
|
|
|
|
|
!m_pSceneController->getCurrentPropertyRange(m_dPropertyRange) ||
|
|
|
|
|
!m_pSceneController->getCurrentDisplayRange(dVisibleRange) ||
|
|
|
|
|
!m_pSceneController->getCurrentDisplaySettings(
|
|
|
|
|
m_oBaselineSettings)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
populateEditor(m_oBaselineSettings, dVisibleRange);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::populateEditor(
|
|
|
|
|
const nmPebiResultDisplaySettings& oSettings,
|
|
|
|
|
const double dVisibleRange[2])
|
|
|
|
|
{
|
|
|
|
|
const int nColorIndex = m_pColorMapCombo->findData(
|
|
|
|
|
oSettings.m_sColorMapId);
|
|
|
|
|
m_pColorMapCombo->setCurrentIndex(nColorIndex);
|
|
|
|
|
m_pMinimumEdit->setText(formatValue(dVisibleRange[0]));
|
|
|
|
|
m_pMaximumEdit->setText(formatValue(dVisibleRange[1]));
|
|
|
|
|
m_bManualRangeEdited = oSettings.m_bHasManualRange;
|
|
|
|
|
m_pLogarithmicCheck->setChecked(
|
|
|
|
|
oSettings.m_eScaleMode == NM_PebiColorScale_Logarithmic);
|
|
|
|
|
m_pBelowRangeCheck->setChecked(oSettings.m_bUseBelowRangeColor);
|
|
|
|
|
m_pAboveRangeCheck->setChecked(oSettings.m_bUseAboveRangeColor);
|
|
|
|
|
updateColorButton(m_pBelowColorButton, oSettings.m_oBelowRangeColor);
|
|
|
|
|
updateColorButton(m_pAboveColorButton, oSettings.m_oAboveRangeColor);
|
|
|
|
|
onBelowRangeToggled(oSettings.m_bUseBelowRangeColor);
|
|
|
|
|
onAboveRangeToggled(oSettings.m_bUseAboveRangeColor);
|
|
|
|
|
refreshLogAvailability();
|
|
|
|
|
|
|
|
|
|
const QString sUnitSuffix = m_sDisplayUnit.isEmpty()
|
|
|
|
|
? QString() : QString::fromLatin1(" (") +
|
|
|
|
|
m_sDisplayUnit + QString::fromLatin1(")");
|
|
|
|
|
m_pMinimumEdit->setToolTip(tr("Minimum") + sUnitSuffix);
|
|
|
|
|
m_pMaximumEdit->setToolTip(tr("Maximum") + sUnitSuffix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultColorScaleSettingsDlg::collectEditedSettings(
|
|
|
|
|
nmPebiResultDisplaySettings& oSettings,
|
|
|
|
|
QString& sError) const
|
|
|
|
|
{
|
|
|
|
|
sError.clear();
|
|
|
|
|
double dMinimum = 0.0;
|
|
|
|
|
double dMaximum = 0.0;
|
|
|
|
|
if(!parseFiniteValue(m_pMinimumEdit->text(), dMinimum) ||
|
|
|
|
|
!parseFiniteValue(m_pMaximumEdit->text(), dMaximum)) {
|
|
|
|
|
sError = tr("Minimum and maximum must be finite numbers.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 提交值与界面最多 12 位有效数字保持一致,重复 Apply 不产生隐藏精度差异。
|
|
|
|
|
double dCanonicalMinimum = 0.0;
|
|
|
|
|
double dCanonicalMaximum = 0.0;
|
|
|
|
|
if(!parseFiniteValue(formatValue(dMinimum), dCanonicalMinimum) ||
|
|
|
|
|
!parseFiniteValue(formatValue(dMaximum), dCanonicalMaximum)) {
|
|
|
|
|
sError = tr("Minimum and maximum must be finite numbers.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dMinimum = dCanonicalMinimum;
|
|
|
|
|
dMaximum = dCanonicalMaximum;
|
|
|
|
|
if(m_bManualRangeEdited && dMinimum >= dMaximum) {
|
|
|
|
|
sError = tr("Minimum must be less than maximum.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oSettings = m_oBaselineSettings;
|
|
|
|
|
oSettings.m_sColorMapId =
|
|
|
|
|
m_pColorMapCombo->itemData(
|
|
|
|
|
m_pColorMapCombo->currentIndex()).toString();
|
|
|
|
|
oSettings.m_eScaleMode = m_pLogarithmicCheck->isChecked()
|
|
|
|
|
? NM_PebiColorScale_Logarithmic : NM_PebiColorScale_Linear;
|
|
|
|
|
oSettings.m_bHasManualRange = m_bManualRangeEdited;
|
|
|
|
|
oSettings.m_dManualMinimum = m_bManualRangeEdited ? dMinimum : 0.0;
|
|
|
|
|
oSettings.m_dManualMaximum = m_bManualRangeEdited ? dMaximum : 0.0;
|
|
|
|
|
oSettings.m_bUseBelowRangeColor = m_pBelowRangeCheck->isChecked();
|
|
|
|
|
oSettings.m_bUseAboveRangeColor = m_pAboveRangeCheck->isChecked();
|
|
|
|
|
oSettings.m_oBelowRangeColor.setAlpha(255);
|
|
|
|
|
oSettings.m_oAboveRangeColor.setAlpha(255);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultColorScaleSettingsDlg::applyEditor()
|
|
|
|
|
{
|
|
|
|
|
if(!m_bInitialized || m_pSceneController == nullptr) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
nmPebiResultDisplaySettings oSettings;
|
|
|
|
|
QString sError;
|
|
|
|
|
if(!collectEditedSettings(oSettings, sError) ||
|
|
|
|
|
!m_pSceneController->applyCurrentDisplaySettings(
|
|
|
|
|
m_sExpectedSnapshotId, m_sExpectedPropertyId,
|
|
|
|
|
oSettings, &sError)) {
|
|
|
|
|
setErrorText(sError);
|
|
|
|
|
emit operationFailed(sError);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double dVisibleRange[2] = { 0.0, 0.0 };
|
|
|
|
|
nmPebiResultDisplaySettings oCommittedSettings;
|
|
|
|
|
if(!m_pSceneController->getCurrentDisplaySettings(oCommittedSettings) ||
|
|
|
|
|
!m_pSceneController->getCurrentDisplayRange(dVisibleRange)) {
|
|
|
|
|
sError = tr("Unable to read the committed color settings.");
|
|
|
|
|
setErrorText(sError);
|
|
|
|
|
emit operationFailed(sError);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_oBaselineSettings = oCommittedSettings;
|
|
|
|
|
populateEditor(oCommittedSettings, dVisibleRange);
|
|
|
|
|
setErrorText(QString());
|
|
|
|
|
emit displaySettingsApplied();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmWxPebiResultColorScaleSettingsDlg::formatValue(double dValue) const
|
|
|
|
|
{
|
|
|
|
|
return QLocale::c().toString(dValue, 'g', 12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultColorScaleSettingsDlg::parseFiniteValue(
|
|
|
|
|
const QString& sText,
|
|
|
|
|
double& dValue) const
|
|
|
|
|
{
|
|
|
|
|
bool bOk = false;
|
|
|
|
|
const double dCandidate = QLocale::c().toDouble(
|
|
|
|
|
sText.trimmed(), &bOk);
|
|
|
|
|
if(!bOk || !isFiniteEditorValue(dCandidate)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dValue = dCandidate;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::updateColorButton(
|
|
|
|
|
QPushButton* pButton,
|
|
|
|
|
const QColor& oColor)
|
|
|
|
|
{
|
|
|
|
|
if(pButton == nullptr || !oColor.isValid()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pButton->setStyleSheet(QString::fromLatin1(
|
|
|
|
|
"QPushButton { background-color: rgb(%1,%2,%3); border: 1px solid #666; }")
|
|
|
|
|
.arg(oColor.red()).arg(oColor.green()).arg(oColor.blue()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultColorScaleSettingsDlg::setErrorText(
|
|
|
|
|
const QString& sError)
|
|
|
|
|
{
|
|
|
|
|
m_pErrorLabel->setText(sError);
|
|
|
|
|
m_pErrorLabel->setVisible(!sError.isEmpty());
|
|
|
|
|
}
|