|
|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
#include "nmWxPebiResultViewWidget.h"
|
|
|
|
|
|
|
|
|
|
#include "iUnitGroup.h"
|
|
|
|
|
#include "iUnitHelper.h"
|
|
|
|
|
#include "nmDataAnalyzeManager.h"
|
|
|
|
|
#include "nmFFmpegVideoWriter.h"
|
|
|
|
|
#include "nmPebiResultAnimationExporter.h"
|
|
|
|
|
#include "nmPebiResultDisplaySettings.h"
|
|
|
|
|
#include "nmPebiResultPlaybackController.h"
|
|
|
|
|
#include "nmPebiResultPropertyCatalog.h"
|
|
|
|
|
#include "nmPebiResultPropertyDisplayText.h"
|
|
|
|
|
#include "nmPebiResultSceneController.h"
|
|
|
|
|
#include "nmPebiResultSnapshot.h"
|
|
|
|
|
#include "nmVTKMeshLayer.h"
|
|
|
|
|
@ -15,15 +19,21 @@
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QAtomicInt>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QLocale>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QProgressDialog>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSize>
|
|
|
|
|
#include <QSizePolicy>
|
|
|
|
|
#include <QThread>
|
|
|
|
|
@ -33,6 +43,12 @@
|
|
|
|
|
#include <vtkCamera.h>
|
|
|
|
|
#include <vtkRenderer.h>
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
#if !defined(_MSC_VER)
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
QAtomicInt g_nPebiAnimationExportActive(0);
|
|
|
|
|
@ -61,6 +77,15 @@ void setActionCheckedWithoutSignal(QAction* pAction, bool bChecked)
|
|
|
|
|
pAction->blockSignals(bBlocked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isFiniteFilterEditorValue(double dValue)
|
|
|
|
|
{
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
|
return _finite(dValue) != 0;
|
|
|
|
|
#else
|
|
|
|
|
return std::isfinite(dValue);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AnimationExportGuard
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
@ -102,6 +127,524 @@ private:
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultFilterSettingsDlg::nmWxPebiResultFilterSettingsDlg(
|
|
|
|
|
nmPebiResultSceneController* pSceneController,
|
|
|
|
|
nmWxPebiResultControlBar* pControlBar,
|
|
|
|
|
QWidget* pParent)
|
|
|
|
|
: iDlgBase(pParent),
|
|
|
|
|
m_pSceneController(pSceneController),
|
|
|
|
|
m_pControlBar(pControlBar),
|
|
|
|
|
m_nExpectedBindingRevision(0),
|
|
|
|
|
m_nExpectedDisplayFrameIndex(-1),
|
|
|
|
|
m_pUnitGroup(nullptr),
|
|
|
|
|
m_bInitialized(false),
|
|
|
|
|
m_pEnableCheck(nullptr),
|
|
|
|
|
m_pPropertyCombo(nullptr),
|
|
|
|
|
m_pMinimumCheck(nullptr),
|
|
|
|
|
m_pMinimumEdit(nullptr),
|
|
|
|
|
m_pMaximumCheck(nullptr),
|
|
|
|
|
m_pMaximumEdit(nullptr),
|
|
|
|
|
m_pUnitCombo(nullptr),
|
|
|
|
|
m_pApplyButton(nullptr),
|
|
|
|
|
m_pOkButton(nullptr)
|
|
|
|
|
{
|
|
|
|
|
createUi();
|
|
|
|
|
m_bInitialized = initializeFromScene();
|
|
|
|
|
if(!m_bInitialized) {
|
|
|
|
|
m_pApplyButton->setEnabled(false);
|
|
|
|
|
m_pOkButton->setEnabled(false);
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
this, tr("Filtering settings"),
|
|
|
|
|
tr("Unable to read the current result filter settings."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultFilterSettingsDlg::~nmWxPebiResultFilterSettingsDlg()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultFilterSettingsDlg::createUi()
|
|
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Filtering settings"));
|
|
|
|
|
setModal(true);
|
|
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
|
|
|
|
|
|
|
|
m_pEnableCheck = new QCheckBox(tr("Enable filtering"), this);
|
|
|
|
|
m_pPropertyCombo = new QComboBox(this);
|
|
|
|
|
m_pPropertyCombo->setSizeAdjustPolicy(
|
|
|
|
|
QComboBox::AdjustToContentsOnFirstShow);
|
|
|
|
|
m_pPropertyCombo->setMinimumWidth(220);
|
|
|
|
|
|
|
|
|
|
m_pMinimumCheck = new QCheckBox(tr("Above min (>=)"), this);
|
|
|
|
|
m_pMinimumEdit = new QLineEdit(this);
|
|
|
|
|
m_pMinimumEdit->setAlignment(Qt::AlignRight);
|
|
|
|
|
m_pMaximumCheck = new QCheckBox(tr("Below max (<=)"), this);
|
|
|
|
|
m_pMaximumEdit = new QLineEdit(this);
|
|
|
|
|
m_pMaximumEdit->setAlignment(Qt::AlignRight);
|
|
|
|
|
m_pUnitCombo = new QComboBox(this);
|
|
|
|
|
m_pUnitCombo->setMinimumWidth(80);
|
|
|
|
|
m_pUnitCombo->setMaximumWidth(140);
|
|
|
|
|
m_pUnitCombo->hide();
|
|
|
|
|
m_pMinimumEdit->setMinimumWidth(150);
|
|
|
|
|
m_pMaximumEdit->setMinimumWidth(150);
|
|
|
|
|
|
|
|
|
|
QGridLayout* pFieldsLayout = new QGridLayout();
|
|
|
|
|
pFieldsLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
pFieldsLayout->setHorizontalSpacing(8);
|
|
|
|
|
pFieldsLayout->setVerticalSpacing(6);
|
|
|
|
|
pFieldsLayout->addWidget(m_pEnableCheck, 0, 0, 1, 3);
|
|
|
|
|
QLabel* pPropertyLabel = new QLabel(tr("Filter on"), this);
|
|
|
|
|
pPropertyLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
|
pFieldsLayout->addWidget(pPropertyLabel, 1, 0);
|
|
|
|
|
pFieldsLayout->addWidget(m_pPropertyCombo, 1, 1, 1, 2);
|
|
|
|
|
pFieldsLayout->addWidget(m_pMinimumCheck, 2, 0);
|
|
|
|
|
pFieldsLayout->addWidget(m_pMinimumEdit, 2, 1);
|
|
|
|
|
pFieldsLayout->addWidget(m_pUnitCombo, 2, 2, 2, 1,
|
|
|
|
|
Qt::AlignVCenter);
|
|
|
|
|
pFieldsLayout->addWidget(m_pMaximumCheck, 3, 0);
|
|
|
|
|
pFieldsLayout->addWidget(m_pMaximumEdit, 3, 1);
|
|
|
|
|
pFieldsLayout->setColumnStretch(1, 1);
|
|
|
|
|
|
|
|
|
|
// 普通布局不受平台按钮顺序策略影响,始终保持应用、确定、取消。
|
|
|
|
|
QHBoxLayout* pButtonLayout = new QHBoxLayout();
|
|
|
|
|
pButtonLayout->addStretch();
|
|
|
|
|
m_pApplyButton = new QPushButton(tr("Apply"), this);
|
|
|
|
|
m_pOkButton = new QPushButton(tr("OK"), this);
|
|
|
|
|
QPushButton* pCancelButton = new QPushButton(tr("Cancel"), this);
|
|
|
|
|
const QSize oFooterIconSize(16, 16);
|
|
|
|
|
m_pOkButton->setIcon(QIcon(resultViewIconPath("OK.png")));
|
|
|
|
|
pCancelButton->setIcon(QIcon(resultViewIconPath("Cancel.png")));
|
|
|
|
|
m_pOkButton->setIconSize(oFooterIconSize);
|
|
|
|
|
pCancelButton->setIconSize(oFooterIconSize);
|
|
|
|
|
m_pApplyButton->setMinimumWidth(72);
|
|
|
|
|
m_pOkButton->setMinimumWidth(72);
|
|
|
|
|
pCancelButton->setMinimumWidth(72);
|
|
|
|
|
m_pApplyButton->setAutoDefault(false);
|
|
|
|
|
m_pOkButton->setDefault(true);
|
|
|
|
|
pCancelButton->setAutoDefault(false);
|
|
|
|
|
pButtonLayout->setContentsMargins(4, 2, 4, 5);
|
|
|
|
|
pButtonLayout->setSpacing(6);
|
|
|
|
|
pButtonLayout->addWidget(m_pApplyButton);
|
|
|
|
|
pButtonLayout->addWidget(m_pOkButton);
|
|
|
|
|
pButtonLayout->addWidget(pCancelButton);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* pMainLayout = new QVBoxLayout(this);
|
|
|
|
|
pMainLayout->setContentsMargins(12, 10, 12, 0);
|
|
|
|
|
pMainLayout->setSpacing(8);
|
|
|
|
|
pMainLayout->addLayout(pFieldsLayout);
|
|
|
|
|
pMainLayout->addLayout(pButtonLayout);
|
|
|
|
|
setMinimumWidth(430);
|
|
|
|
|
|
|
|
|
|
connect(m_pApplyButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onApplyClicked()));
|
|
|
|
|
connect(m_pOkButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(onOkClicked()));
|
|
|
|
|
connect(pCancelButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(reject()));
|
|
|
|
|
connect(m_pPropertyCombo, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(onPropertyChanged(int)));
|
|
|
|
|
connect(m_pUnitCombo, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(onDisplayUnitChanged(int)));
|
|
|
|
|
connect(m_pEnableCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(refreshEditorEnabledState()));
|
|
|
|
|
connect(m_pMinimumCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(refreshEditorEnabledState()));
|
|
|
|
|
connect(m_pMaximumCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(refreshEditorEnabledState()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::initializeFromScene()
|
|
|
|
|
{
|
|
|
|
|
if(m_pSceneController == nullptr || m_pControlBar == nullptr ||
|
|
|
|
|
!m_pSceneController->hasSnapshot()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_nExpectedBindingRevision =
|
|
|
|
|
m_pSceneController->getSnapshotBindingRevision();
|
|
|
|
|
m_sExpectedSnapshotId = m_pSceneController->getCurrentSnapshotId();
|
|
|
|
|
m_sExpectedDisplayPropertyId =
|
|
|
|
|
m_pSceneController->getCurrentPropertyId();
|
|
|
|
|
m_nExpectedDisplayFrameIndex =
|
|
|
|
|
m_pSceneController->getCurrentFrameIndex();
|
|
|
|
|
if(m_nExpectedBindingRevision == 0 ||
|
|
|
|
|
m_sExpectedSnapshotId.isEmpty() ||
|
|
|
|
|
m_sExpectedDisplayPropertyId.isEmpty() ||
|
|
|
|
|
m_nExpectedDisplayFrameIndex < 0 ||
|
|
|
|
|
!m_pSceneController->getFilterSettings(m_oBaselineSettings)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool bSignalsBlocked = m_pPropertyCombo->blockSignals(true);
|
|
|
|
|
const QStringList listPropertyIds =
|
|
|
|
|
m_pSceneController->getAvailablePropertyIds();
|
|
|
|
|
for(int nIndex = 0; nIndex < listPropertyIds.size(); ++nIndex) {
|
|
|
|
|
const QString& sPropertyId = listPropertyIds[nIndex];
|
|
|
|
|
double dRange[2] = { 0.0, 0.0 };
|
|
|
|
|
if(!m_pSceneController->getPropertyRange(sPropertyId, dRange)) {
|
|
|
|
|
m_pPropertyCombo->blockSignals(bSignalsBlocked);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_mapPropertyRanges.insert(
|
|
|
|
|
sPropertyId, qMakePair(dRange[0], dRange[1]));
|
|
|
|
|
QString sDisplayName =
|
|
|
|
|
nmPebiResultPropertyDisplayText::getDisplayName(sPropertyId);
|
|
|
|
|
if(sDisplayName.isEmpty()) {
|
|
|
|
|
sDisplayName = sPropertyId;
|
|
|
|
|
}
|
|
|
|
|
m_pPropertyCombo->addItem(sDisplayName, sPropertyId);
|
|
|
|
|
}
|
|
|
|
|
m_pPropertyCombo->blockSignals(bSignalsBlocked);
|
|
|
|
|
if(m_pPropertyCombo->count() <= 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_oBaselineSettings.m_sPropertyId.isEmpty() ||
|
|
|
|
|
!m_mapPropertyRanges.contains(
|
|
|
|
|
m_oBaselineSettings.m_sPropertyId)) {
|
|
|
|
|
m_oBaselineSettings.m_sPropertyId =
|
|
|
|
|
m_sExpectedDisplayPropertyId;
|
|
|
|
|
const QPair<double, double> oRange =
|
|
|
|
|
m_mapPropertyRanges.value(
|
|
|
|
|
m_oBaselineSettings.m_sPropertyId);
|
|
|
|
|
m_oBaselineSettings.m_bMinimumEnabled = true;
|
|
|
|
|
m_oBaselineSettings.m_dMinimum = oRange.first;
|
|
|
|
|
m_oBaselineSettings.m_bMaximumEnabled = true;
|
|
|
|
|
m_oBaselineSettings.m_dMaximum = oRange.second;
|
|
|
|
|
}
|
|
|
|
|
return populateSettings(m_oBaselineSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::initializeUnitEditor(
|
|
|
|
|
const QString& sPropertyId)
|
|
|
|
|
{
|
|
|
|
|
nmPebiResultPropertyDescriptor oDescriptor;
|
|
|
|
|
if(!nmPebiResultPropertyCatalog::findDescriptor(
|
|
|
|
|
sPropertyId, oDescriptor)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool bSignalsBlocked = m_pUnitCombo->blockSignals(true);
|
|
|
|
|
m_pUnitCombo->clear();
|
|
|
|
|
m_pUnitGroup = nullptr;
|
|
|
|
|
m_sBaseUnit = oDescriptor.m_sBaseUnit;
|
|
|
|
|
m_sDisplayUnit = oDescriptor.m_sDefaultDisplayUnit.isEmpty()
|
|
|
|
|
? m_sBaseUnit : oDescriptor.m_sDefaultDisplayUnit;
|
|
|
|
|
if(m_sBaseUnit.isEmpty()) {
|
|
|
|
|
m_sDisplayUnit.clear();
|
|
|
|
|
m_pUnitCombo->setEnabled(false);
|
|
|
|
|
m_pUnitCombo->hide();
|
|
|
|
|
m_pUnitCombo->blockSignals(bSignalsBlocked);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_pUnitGroup = iUnitHelper::getUnitGroupByUnit(m_sBaseUnit);
|
|
|
|
|
QStringList listUnits;
|
|
|
|
|
if(m_pUnitGroup != nullptr &&
|
|
|
|
|
m_pUnitGroup->indexOf(m_sBaseUnit) >= 0) {
|
|
|
|
|
listUnits = m_pUnitGroup->getAllUnitNames();
|
|
|
|
|
}
|
|
|
|
|
const bool bHasUnitGroup = !listUnits.isEmpty() &&
|
|
|
|
|
listUnits.contains(m_sBaseUnit);
|
|
|
|
|
if(!bHasUnitGroup) {
|
|
|
|
|
m_pUnitGroup = nullptr;
|
|
|
|
|
listUnits.clear();
|
|
|
|
|
listUnits.append(m_sBaseUnit);
|
|
|
|
|
m_sDisplayUnit = m_sBaseUnit;
|
|
|
|
|
} else if(!listUnits.contains(m_sDisplayUnit)) {
|
|
|
|
|
m_sDisplayUnit = m_sBaseUnit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_pUnitCombo->addItems(listUnits);
|
|
|
|
|
m_pUnitCombo->setCurrentIndex(
|
|
|
|
|
m_pUnitCombo->findText(m_sDisplayUnit));
|
|
|
|
|
m_pUnitCombo->setEnabled(bHasUnitGroup);
|
|
|
|
|
m_pUnitCombo->show();
|
|
|
|
|
m_pUnitCombo->blockSignals(bSignalsBlocked);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::populateSettings(
|
|
|
|
|
const nmPebiResultFilterSettings& oSettings)
|
|
|
|
|
{
|
|
|
|
|
const bool bPropertySignalsBlocked =
|
|
|
|
|
m_pPropertyCombo->blockSignals(true);
|
|
|
|
|
const int nPropertyIndex = m_pPropertyCombo->findData(
|
|
|
|
|
oSettings.m_sPropertyId);
|
|
|
|
|
if(nPropertyIndex < 0 ||
|
|
|
|
|
!initializeUnitEditor(oSettings.m_sPropertyId)) {
|
|
|
|
|
m_pPropertyCombo->blockSignals(bPropertySignalsBlocked);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_pPropertyCombo->setCurrentIndex(nPropertyIndex);
|
|
|
|
|
m_pPropertyCombo->blockSignals(bPropertySignalsBlocked);
|
|
|
|
|
|
|
|
|
|
double dDisplayMinimum = 0.0;
|
|
|
|
|
double dDisplayMaximum = 0.0;
|
|
|
|
|
if(!convertUnitValue(
|
|
|
|
|
oSettings.m_dMinimum, m_sBaseUnit,
|
|
|
|
|
m_sDisplayUnit, dDisplayMinimum) ||
|
|
|
|
|
!convertUnitValue(
|
|
|
|
|
oSettings.m_dMaximum, m_sBaseUnit,
|
|
|
|
|
m_sDisplayUnit, dDisplayMaximum)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_pEnableCheck->setChecked(oSettings.m_bEnabled);
|
|
|
|
|
m_pMinimumCheck->setChecked(oSettings.m_bMinimumEnabled);
|
|
|
|
|
m_pMaximumCheck->setChecked(oSettings.m_bMaximumEnabled);
|
|
|
|
|
m_pMinimumEdit->setText(formatValue(dDisplayMinimum));
|
|
|
|
|
m_pMaximumEdit->setText(formatValue(dDisplayMaximum));
|
|
|
|
|
refreshEditorEnabledState();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultFilterSettingsDlg::onApplyClicked()
|
|
|
|
|
{
|
|
|
|
|
applyEditor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultFilterSettingsDlg::onOkClicked()
|
|
|
|
|
{
|
|
|
|
|
if(applyEditor()) {
|
|
|
|
|
accept();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultFilterSettingsDlg::onPropertyChanged(int nIndex)
|
|
|
|
|
{
|
|
|
|
|
if(nIndex >= 0 &&
|
|
|
|
|
!setPropertyRange(
|
|
|
|
|
m_pPropertyCombo->itemData(nIndex).toString())) {
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
this, tr("Filtering settings"),
|
|
|
|
|
tr("Unable to convert the filter limits "
|
|
|
|
|
"to the selected unit."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultFilterSettingsDlg::onDisplayUnitChanged(int nIndex)
|
|
|
|
|
{
|
|
|
|
|
if(nIndex < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const QString sNewUnit = m_pUnitCombo->itemText(nIndex);
|
|
|
|
|
if(sNewUnit == m_sDisplayUnit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double dOldDisplayMinimum = 0.0;
|
|
|
|
|
double dOldDisplayMaximum = 0.0;
|
|
|
|
|
double dBaseMinimum = 0.0;
|
|
|
|
|
double dBaseMaximum = 0.0;
|
|
|
|
|
double dNewDisplayMinimum = 0.0;
|
|
|
|
|
double dNewDisplayMaximum = 0.0;
|
|
|
|
|
const bool bConverted =
|
|
|
|
|
parseFiniteValue(
|
|
|
|
|
m_pMinimumEdit->text(), dOldDisplayMinimum) &&
|
|
|
|
|
parseFiniteValue(
|
|
|
|
|
m_pMaximumEdit->text(), dOldDisplayMaximum) &&
|
|
|
|
|
convertUnitValue(
|
|
|
|
|
dOldDisplayMinimum, m_sDisplayUnit,
|
|
|
|
|
m_sBaseUnit, dBaseMinimum) &&
|
|
|
|
|
convertUnitValue(
|
|
|
|
|
dOldDisplayMaximum, m_sDisplayUnit,
|
|
|
|
|
m_sBaseUnit, dBaseMaximum) &&
|
|
|
|
|
convertUnitValue(
|
|
|
|
|
dBaseMinimum, m_sBaseUnit,
|
|
|
|
|
sNewUnit, dNewDisplayMinimum) &&
|
|
|
|
|
convertUnitValue(
|
|
|
|
|
dBaseMaximum, m_sBaseUnit,
|
|
|
|
|
sNewUnit, dNewDisplayMaximum);
|
|
|
|
|
if(!bConverted) {
|
|
|
|
|
const bool bSignalsBlocked = m_pUnitCombo->blockSignals(true);
|
|
|
|
|
m_pUnitCombo->setCurrentIndex(
|
|
|
|
|
m_pUnitCombo->findText(m_sDisplayUnit));
|
|
|
|
|
m_pUnitCombo->blockSignals(bSignalsBlocked);
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
this, tr("Filtering settings"),
|
|
|
|
|
tr("Unable to convert the filter limits "
|
|
|
|
|
"to the selected unit."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_sDisplayUnit = sNewUnit;
|
|
|
|
|
m_pMinimumEdit->setText(formatValue(dNewDisplayMinimum));
|
|
|
|
|
m_pMaximumEdit->setText(formatValue(dNewDisplayMaximum));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultFilterSettingsDlg::refreshEditorEnabledState()
|
|
|
|
|
{
|
|
|
|
|
const bool bEnabled = m_pEnableCheck->isChecked();
|
|
|
|
|
m_pPropertyCombo->setEnabled(bEnabled);
|
|
|
|
|
m_pMinimumCheck->setEnabled(bEnabled);
|
|
|
|
|
m_pMaximumCheck->setEnabled(bEnabled);
|
|
|
|
|
m_pMinimumEdit->setEnabled(
|
|
|
|
|
bEnabled && m_pMinimumCheck->isChecked());
|
|
|
|
|
m_pMaximumEdit->setEnabled(
|
|
|
|
|
bEnabled && m_pMaximumCheck->isChecked());
|
|
|
|
|
m_pUnitCombo->setEnabled(
|
|
|
|
|
bEnabled && m_pUnitGroup != nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::collectSettings(
|
|
|
|
|
nmPebiResultFilterSettings& oSettings,
|
|
|
|
|
QString& sError) const
|
|
|
|
|
{
|
|
|
|
|
sError.clear();
|
|
|
|
|
const int nPropertyIndex = m_pPropertyCombo->currentIndex();
|
|
|
|
|
if(nPropertyIndex < 0) {
|
|
|
|
|
sError = tr("A filter property must be selected.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
oSettings.m_bEnabled = m_pEnableCheck->isChecked();
|
|
|
|
|
oSettings.m_sPropertyId =
|
|
|
|
|
m_pPropertyCombo->itemData(nPropertyIndex).toString();
|
|
|
|
|
oSettings.m_bMinimumEnabled = m_pMinimumCheck->isChecked();
|
|
|
|
|
oSettings.m_bMaximumEnabled = m_pMaximumCheck->isChecked();
|
|
|
|
|
// 复选框只控制边界是否参与筛选;未启用边界的编辑值仍需保留,
|
|
|
|
|
// 避免重新打开对话框时退回设置对象的默认 0。
|
|
|
|
|
double dDisplayMinimum = 0.0;
|
|
|
|
|
double dDisplayMaximum = 0.0;
|
|
|
|
|
if(!parseFiniteValue(
|
|
|
|
|
m_pMinimumEdit->text(), dDisplayMinimum) ||
|
|
|
|
|
!parseFiniteValue(
|
|
|
|
|
m_pMaximumEdit->text(), dDisplayMaximum)) {
|
|
|
|
|
sError = tr("Filter limits must be finite numbers.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(!convertUnitValue(
|
|
|
|
|
dDisplayMinimum, m_sDisplayUnit,
|
|
|
|
|
m_sBaseUnit, oSettings.m_dMinimum) ||
|
|
|
|
|
!convertUnitValue(
|
|
|
|
|
dDisplayMaximum, m_sDisplayUnit,
|
|
|
|
|
m_sBaseUnit, oSettings.m_dMaximum)) {
|
|
|
|
|
sError = tr(
|
|
|
|
|
"Unable to convert the filter limits "
|
|
|
|
|
"to the selected unit.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(oSettings.m_bMinimumEnabled &&
|
|
|
|
|
oSettings.m_bMaximumEnabled &&
|
|
|
|
|
oSettings.m_dMinimum > oSettings.m_dMaximum) {
|
|
|
|
|
sError = tr("The minimum filter limit cannot exceed the maximum.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::applyEditor()
|
|
|
|
|
{
|
|
|
|
|
nmPebiResultPlaybackController* pPlaybackController =
|
|
|
|
|
m_pControlBar == nullptr ? nullptr :
|
|
|
|
|
m_pControlBar->getPlaybackController();
|
|
|
|
|
if(!m_bInitialized || m_pSceneController == nullptr ||
|
|
|
|
|
m_pControlBar == nullptr || pPlaybackController == nullptr ||
|
|
|
|
|
pPlaybackController->isPlaying() ||
|
|
|
|
|
m_pControlBar->isExportInProgress()) {
|
|
|
|
|
const QString sError = tr(
|
|
|
|
|
"Filtering is unavailable during playback or export.");
|
|
|
|
|
QMessageBox::warning(this, tr("Filtering settings"), sError);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmPebiResultFilterSettings oSettings;
|
|
|
|
|
QString sError;
|
|
|
|
|
if(!collectSettings(oSettings, sError) ||
|
|
|
|
|
!m_pSceneController->applyFilterSettings(
|
|
|
|
|
m_nExpectedBindingRevision,
|
|
|
|
|
m_sExpectedSnapshotId,
|
|
|
|
|
m_sExpectedDisplayPropertyId,
|
|
|
|
|
m_nExpectedDisplayFrameIndex,
|
|
|
|
|
oSettings, &sError)) {
|
|
|
|
|
if(sError.isEmpty()) {
|
|
|
|
|
sError = tr("Unable to apply the filter settings.");
|
|
|
|
|
}
|
|
|
|
|
QMessageBox::warning(this, tr("Filtering settings"), sError);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_oBaselineSettings = oSettings;
|
|
|
|
|
emit filterSettingsApplied();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::setPropertyRange(
|
|
|
|
|
const QString& sPropertyId)
|
|
|
|
|
{
|
|
|
|
|
if(!m_mapPropertyRanges.contains(sPropertyId) ||
|
|
|
|
|
!initializeUnitEditor(sPropertyId)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const QPair<double, double> oRange =
|
|
|
|
|
m_mapPropertyRanges.value(sPropertyId);
|
|
|
|
|
double dDisplayMinimum = 0.0;
|
|
|
|
|
double dDisplayMaximum = 0.0;
|
|
|
|
|
if(!convertUnitValue(
|
|
|
|
|
oRange.first, m_sBaseUnit,
|
|
|
|
|
m_sDisplayUnit, dDisplayMinimum) ||
|
|
|
|
|
!convertUnitValue(
|
|
|
|
|
oRange.second, m_sBaseUnit,
|
|
|
|
|
m_sDisplayUnit, dDisplayMaximum)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_pMinimumCheck->setChecked(true);
|
|
|
|
|
m_pMaximumCheck->setChecked(true);
|
|
|
|
|
m_pMinimumEdit->setText(formatValue(dDisplayMinimum));
|
|
|
|
|
m_pMaximumEdit->setText(formatValue(dDisplayMaximum));
|
|
|
|
|
refreshEditorEnabledState();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmWxPebiResultFilterSettingsDlg::formatValue(double dValue) const
|
|
|
|
|
{
|
|
|
|
|
return QLocale::c().toString(dValue, 'g', 12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::parseFiniteValue(
|
|
|
|
|
const QString& sText,
|
|
|
|
|
double& dValue) const
|
|
|
|
|
{
|
|
|
|
|
bool bOk = false;
|
|
|
|
|
const double dCandidate = QLocale::c().toDouble(
|
|
|
|
|
sText.trimmed(), &bOk);
|
|
|
|
|
if(!bOk || !isFiniteFilterEditorValue(dCandidate)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dValue = dCandidate;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiResultFilterSettingsDlg::convertUnitValue(
|
|
|
|
|
double dSourceValue,
|
|
|
|
|
const QString& sSourceUnit,
|
|
|
|
|
const QString& sDestinationUnit,
|
|
|
|
|
double& dDestinationValue) const
|
|
|
|
|
{
|
|
|
|
|
if(!isFiniteFilterEditorValue(dSourceValue)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(sSourceUnit == sDestinationUnit) {
|
|
|
|
|
dDestinationValue = dSourceValue;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if(sSourceUnit.isEmpty() || sDestinationUnit.isEmpty() ||
|
|
|
|
|
m_pUnitGroup == nullptr ||
|
|
|
|
|
m_pUnitGroup->indexOf(sSourceUnit) < 0 ||
|
|
|
|
|
m_pUnitGroup->indexOf(sDestinationUnit) < 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int nDigit = 12;
|
|
|
|
|
double dCandidate = 0.0;
|
|
|
|
|
if(!m_pUnitGroup->convert(
|
|
|
|
|
sSourceUnit, dSourceValue,
|
|
|
|
|
sDestinationUnit, dCandidate, nDigit) ||
|
|
|
|
|
!isFiniteFilterEditorValue(dCandidate)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
dDestinationValue = dCandidate;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultViewWidget::nmWxPebiResultViewWidget(
|
|
|
|
|
nmDataAnalyzeManager* pDataManager,
|
|
|
|
|
QWidget* pParent)
|
|
|
|
|
@ -114,6 +657,7 @@ nmWxPebiResultViewWidget::nmWxPebiResultViewWidget(
|
|
|
|
|
m_pScalarBarAction(nullptr),
|
|
|
|
|
m_pScaleGridAction(nullptr),
|
|
|
|
|
m_pWellNamesAction(nullptr),
|
|
|
|
|
m_pFilterAction(nullptr),
|
|
|
|
|
m_bObservedSnapshotCurrent(false),
|
|
|
|
|
m_bObservedStateValid(false),
|
|
|
|
|
m_bSynchronizing(false),
|
|
|
|
|
@ -225,6 +769,8 @@ void nmWxPebiResultViewWidget::appendContextMenuActions(QMenu* pMenu)
|
|
|
|
|
if(pMenu == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pMenu->addAction(m_pFilterAction);
|
|
|
|
|
pMenu->addSeparator();
|
|
|
|
|
pMenu->addAction(m_pScalarBarAction);
|
|
|
|
|
pMenu->addAction(m_pScaleGridAction);
|
|
|
|
|
pMenu->addAction(m_pWellNamesAction);
|
|
|
|
|
@ -266,6 +812,27 @@ void nmWxPebiResultViewWidget::onViewportSizeChanged(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onShowFilterSettings()
|
|
|
|
|
{
|
|
|
|
|
nmPebiResultPlaybackController* pPlaybackController =
|
|
|
|
|
m_pControlBar == nullptr ? nullptr :
|
|
|
|
|
m_pControlBar->getPlaybackController();
|
|
|
|
|
if(m_pSceneController == nullptr || m_pControlBar == nullptr ||
|
|
|
|
|
pPlaybackController == nullptr ||
|
|
|
|
|
!m_pSceneController->hasSnapshot() ||
|
|
|
|
|
pPlaybackController->isPlaying() ||
|
|
|
|
|
m_pControlBar->isExportInProgress()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiResultFilterSettingsDlg oDialog(
|
|
|
|
|
m_pSceneController, m_pControlBar, this);
|
|
|
|
|
connect(&oDialog, SIGNAL(filterSettingsApplied()),
|
|
|
|
|
this, SLOT(onControlOperationSucceeded()));
|
|
|
|
|
oDialog.exec();
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::onExportAnimationRequested()
|
|
|
|
|
{
|
|
|
|
|
nmPebiResultPlaybackController* pPlaybackController =
|
|
|
|
|
@ -302,11 +869,23 @@ void nmWxPebiResultViewWidget::onExportAnimationRequested()
|
|
|
|
|
m_pSceneController->getCurrentPropertyId();
|
|
|
|
|
const nmVTKMeshLayer::DisplayMode eFrozenMeshDisplayMode =
|
|
|
|
|
m_pSceneController->getMeshDisplayMode();
|
|
|
|
|
nmPebiResultDisplaySettings oFrozenDisplaySettings;
|
|
|
|
|
nmPebiResultFilterSettings oFrozenFilterSettings;
|
|
|
|
|
if(!m_pSceneController->getCurrentDisplaySettings(
|
|
|
|
|
oFrozenDisplaySettings) ||
|
|
|
|
|
!m_pSceneController->getFilterSettings(
|
|
|
|
|
oFrozenFilterSettings)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const int nFrozenFilterFrameIndex =
|
|
|
|
|
m_pSceneController->getFilterFrameIndex();
|
|
|
|
|
const int nFrameCount = pFrozenSnapshot->getPropertyFrameCount(
|
|
|
|
|
sFrozenPropertyId);
|
|
|
|
|
if(nFrozenBindingRevision == 0 || sFrozenSnapshotId.isEmpty() ||
|
|
|
|
|
sFrozenPropertyId.isEmpty() || nFrameCount <= 1 ||
|
|
|
|
|
!nmVTKMeshLayer::isValidDisplayMode(eFrozenMeshDisplayMode) ||
|
|
|
|
|
(oFrozenFilterSettings.m_bEnabled &&
|
|
|
|
|
nFrozenFilterFrameIndex < 0) ||
|
|
|
|
|
!m_pSceneController->isPropertyTimeDependent(sFrozenPropertyId)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -344,11 +923,23 @@ void nmWxPebiResultViewWidget::onExportAnimationRequested()
|
|
|
|
|
tr("The displayed result changed before export started."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
nmPebiResultDisplaySettings oCurrentDisplaySettings;
|
|
|
|
|
nmPebiResultFilterSettings oCurrentFilterSettings;
|
|
|
|
|
if(!m_pSceneController->getCurrentDisplaySettings(
|
|
|
|
|
oCurrentDisplaySettings) ||
|
|
|
|
|
oCurrentDisplaySettings != oFrozenDisplaySettings ||
|
|
|
|
|
!m_pSceneController->getFilterSettings(oCurrentFilterSettings) ||
|
|
|
|
|
oCurrentFilterSettings != oFrozenFilterSettings ||
|
|
|
|
|
m_pSceneController->getFilterFrameIndex() !=
|
|
|
|
|
nFrozenFilterFrameIndex) {
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
this, tr("Export Animation"),
|
|
|
|
|
tr("The displayed result changed before export started."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmPebiResultDisplaySettings oDisplaySettings;
|
|
|
|
|
vtkRenderer* pRenderer = m_pRenderContainer->getRenderer();
|
|
|
|
|
if(!m_pSceneController->getCurrentDisplaySettings(oDisplaySettings) ||
|
|
|
|
|
pRenderer == nullptr || pRenderer->GetActiveCamera() == nullptr) {
|
|
|
|
|
if(pRenderer == nullptr || pRenderer->GetActiveCamera() == nullptr) {
|
|
|
|
|
QMessageBox::warning(
|
|
|
|
|
this, tr("Export Animation"),
|
|
|
|
|
tr("Unable to freeze the current result display."));
|
|
|
|
|
@ -358,8 +949,10 @@ void nmWxPebiResultViewWidget::onExportAnimationRequested()
|
|
|
|
|
nmPebiResultAnimationExporter::Request oRequest;
|
|
|
|
|
oRequest.m_pSnapshot = pFrozenSnapshot;
|
|
|
|
|
oRequest.m_sPropertyId = sFrozenPropertyId;
|
|
|
|
|
oRequest.m_oDisplaySettings = oDisplaySettings;
|
|
|
|
|
oRequest.m_oDisplaySettings = oFrozenDisplaySettings;
|
|
|
|
|
oRequest.m_eMeshDisplayMode = eFrozenMeshDisplayMode;
|
|
|
|
|
oRequest.m_oFilterSettings = oFrozenFilterSettings;
|
|
|
|
|
oRequest.m_nFilterFrameIndex = nFrozenFilterFrameIndex;
|
|
|
|
|
oRequest.m_oExportSettings = oSettingsDialog.getSettings();
|
|
|
|
|
oRequest.m_sTargetFilePath = oSettingsDialog.getTargetFilePath();
|
|
|
|
|
oRequest.m_bScalarBarVisible =
|
|
|
|
|
@ -487,6 +1080,10 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
m_pWellNamesAction = new QAction(
|
|
|
|
|
QIcon(resultViewIconPath("NmShowWellNames.png")),
|
|
|
|
|
tr("Well Names"), this);
|
|
|
|
|
m_pFilterAction = new QAction(
|
|
|
|
|
QIcon(resultViewIconPath("NmFilter.png")),
|
|
|
|
|
tr("Data Filtering..."), this);
|
|
|
|
|
m_pFilterAction->setToolTip(m_pFilterAction->text());
|
|
|
|
|
|
|
|
|
|
QAction* const pBusinessActions[] = {
|
|
|
|
|
m_pScalarBarAction, m_pScaleGridAction, m_pWellNamesAction
|
|
|
|
|
@ -523,6 +1120,7 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
if(pFrontAction != nullptr) m_pToolBar->addAction(pFrontAction);
|
|
|
|
|
if(pPickCenterAction != nullptr) m_pToolBar->addAction(pPickCenterAction);
|
|
|
|
|
m_pToolBar->addSeparator();
|
|
|
|
|
m_pToolBar->addAction(m_pFilterAction);
|
|
|
|
|
for(int nIndex = 0; nIndex < 3; ++nIndex) {
|
|
|
|
|
m_pToolBar->addAction(pBusinessActions[nIndex]);
|
|
|
|
|
}
|
|
|
|
|
@ -536,6 +1134,8 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
this, SLOT(onScaleGridToggled(bool)));
|
|
|
|
|
connect(m_pWellNamesAction, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onWellNamesToggled(bool)));
|
|
|
|
|
connect(m_pFilterAction, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(onShowFilterSettings()));
|
|
|
|
|
connect(m_pRenderContainer, SIGNAL(contextMenuAboutToShow(QMenu*)),
|
|
|
|
|
this, SLOT(appendContextMenuActions(QMenu*)));
|
|
|
|
|
|
|
|
|
|
@ -557,6 +1157,12 @@ void nmWxPebiResultViewWidget::createUi()
|
|
|
|
|
this, SLOT(onControlOperationSucceeded()));
|
|
|
|
|
connect(m_pControlBar, SIGNAL(exportAnimationRequested()),
|
|
|
|
|
this, SLOT(onExportAnimationRequested()));
|
|
|
|
|
connect(m_pControlBar, SIGNAL(exportInProgressChanged(bool)),
|
|
|
|
|
this, SLOT(synchronizeBusinessActions()));
|
|
|
|
|
if(m_pControlBar->getPlaybackController() != nullptr) {
|
|
|
|
|
connect(m_pControlBar->getPlaybackController(), SIGNAL(stateChanged()),
|
|
|
|
|
this, SLOT(synchronizeBusinessActions()));
|
|
|
|
|
}
|
|
|
|
|
pMainLayout->addWidget(m_pControlBar);
|
|
|
|
|
|
|
|
|
|
synchronizeBusinessActions();
|
|
|
|
|
@ -702,6 +1308,16 @@ void nmWxPebiResultViewWidget::synchronizeBusinessActions()
|
|
|
|
|
m_pScalarBarAction->setEnabled(bEnabled);
|
|
|
|
|
m_pScaleGridAction->setEnabled(bEnabled);
|
|
|
|
|
m_pWellNamesAction->setEnabled(bEnabled);
|
|
|
|
|
nmPebiResultPlaybackController* pPlaybackController =
|
|
|
|
|
m_pControlBar == nullptr ? nullptr :
|
|
|
|
|
m_pControlBar->getPlaybackController();
|
|
|
|
|
const bool bFilterEnabled = bEnabled &&
|
|
|
|
|
pPlaybackController != nullptr &&
|
|
|
|
|
!pPlaybackController->isPlaying() &&
|
|
|
|
|
!m_pControlBar->isExportInProgress();
|
|
|
|
|
if(m_pFilterAction != nullptr) {
|
|
|
|
|
m_pFilterAction->setEnabled(bFilterEnabled);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiResultViewWidget::refreshStatusBar()
|
|
|
|
|
|