diff --git a/Bin/Config/Lang/cn/nmNum_cn.qm b/Bin/Config/Lang/cn/nmNum_cn.qm
index fcbffeb3..461b8f77 100644
Binary files a/Bin/Config/Lang/cn/nmNum_cn.qm and b/Bin/Config/Lang/cn/nmNum_cn.qm differ
diff --git a/Bin/Config/Lang/cn/nmNum_cn.ts b/Bin/Config/Lang/cn/nmNum_cn.ts
index 60b82abe..d84bb1c5 100644
--- a/Bin/Config/Lang/cn/nmNum_cn.ts
+++ b/Bin/Config/Lang/cn/nmNum_cn.ts
@@ -2814,6 +2814,15 @@ Reason: %1
The requested result property or frame is invalid.请求的结果属性或帧无效。
The result property range is invalid.结果属性范围无效。
Unable to apply the result property or frame.无法应用结果属性或帧。
+ The color settings no longer match the current result.颜色设置已不再对应当前结果。
+ The color settings are invalid.颜色设置无效。
+ The selected color map is unavailable.所选色带不可用。
+ The manual range must contain two finite increasing values.手工范围必须包含两个有限且递增的数值。
+ Logarithmic scale requires positive property and display ranges.对数色标要求属性范围和显示范围均为正值。
+ Unable to construct the color mapping.无法构造颜色映射。
+ Unable to apply the color settings.无法应用颜色设置。
+ Below min低于最小值
+ Above max高于最大值
nmPebiResultProperty
@@ -2832,6 +2841,7 @@ Reason: %1
nmWxPebiResultControlBar
Display property显示属性
+ Color settings颜色设置
First frame第一帧
Previous frame上一帧
Result time结果时间
@@ -2842,6 +2852,31 @@ Reason: %1
Animation settings动画设置
t = %1 ht = %1 h
+
+ nmWxPebiResultColorScaleSettingsDlg
+ Rainbow彩虹
+ Oil saturation油饱和度
+ Gas saturation气饱和度
+ Water saturation水饱和度
+ The result color settings are unavailable.结果颜色设置不可用。
+ Below minimum color低于最小值颜色
+ Above maximum color高于最大值颜色
+ Logarithmic scale requires a positive property range.对数色标要求属性范围为正值。
+ Logarithmic scale requires a positive minimum.对数色标要求显示最小值为正值。
+ Color settings for current property当前属性的颜色设置
+ Restore property range恢复属性范围
+ Logarithmic scale对数色标
+ Below min低于最小值
+ Above max高于最大值
+ Color map色带
+ Minimum最小值
+ Maximum最大值
+ Unit单位
+ Dimensionless无量纲
+ Minimum and maximum must be finite numbers.最小值和最大值必须是有限数。
+ Minimum must be less than maximum.最小值必须小于最大值。
+ Unable to read the committed color settings.无法读取已提交的颜色设置。
+
nmWxPebiResultAnimationSettingsDlg
Animation settings动画设置
diff --git a/Include/nmNum/nmRender/nmVTKColorMapCatalog.h b/Include/nmNum/nmRender/nmVTKColorMapCatalog.h
new file mode 100644
index 00000000..16a916c6
--- /dev/null
+++ b/Include/nmNum/nmRender/nmVTKColorMapCatalog.h
@@ -0,0 +1,53 @@
+#ifndef NMVTKCOLORMAPCATALOG_H
+#define NMVTKCOLORMAPCATALOG_H
+
+#include "nmRender_global.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+class vtkLookupTable;
+
+/**
+ * @brief 提供可复现的通用 VTK 色带目录。
+ *
+ * 稳定 ID 和 256 个颜色表项不包含 PEBI 属性语义,其他渲染视图也可以复用。
+ * 目录只负责颜色表本身;数值范围、线性/对数模式和越界颜色由调用方设置。
+ */
+class NM_RENDER_EXPORT nmVTKColorMapCatalog
+{
+public:
+ /** @brief 返回固定顺序的全部稳定色带 ID。 */
+ static QStringList getColorMapIds();
+ /** @brief 判断稳定 ID 是否属于本目录。 */
+ static bool contains(const QString& sColorMapId);
+
+ /**
+ * @brief 按归一化位置查询不透明颜色。
+ * @param dPosition 0 对应最小值颜色,1 对应最大值颜色。
+ * @note 查询失败时返回 false,且不修改 oColor。
+ */
+ static bool getColor(const QString& sColorMapId,
+ double dPosition,
+ QColor& oColor);
+ /** @brief 生成界面下拉框或工具按钮使用的固定色带预览图。 */
+ static QPixmap createPreviewPixmap(const QString& sColorMapId,
+ const QSize& oSize);
+
+ /**
+ * @brief 创建包含 256 个固定 RGBA 表项的独立 LookupTable。
+ * @return 未知 ID 返回空智能指针;成功时 Alpha 始终为 1。
+ */
+ static vtkSmartPointer createLookupTable(
+ const QString& sColorMapId);
+
+private:
+ /** @brief 纯静态目录,不允许实例化。 */
+ nmVTKColorMapCatalog();
+};
+
+#endif // NMVTKCOLORMAPCATALOG_H
diff --git a/Include/nmNum/nmRender/nmVTKMeshLayer.h b/Include/nmNum/nmRender/nmVTKMeshLayer.h
index 0a226257..e747d2bc 100644
--- a/Include/nmNum/nmRender/nmVTKMeshLayer.h
+++ b/Include/nmNum/nmRender/nmVTKMeshLayer.h
@@ -61,6 +61,15 @@ public:
ScalarAssociation eAssociation,
double dMinimum,
double dMaximum);
+ /**
+ * @brief 原子提交管线输入、标量数组和完整候选颜色表。
+ * @note 候选 LookupTable 必须已包含范围、色带、比例和越界颜色;失败时
+ * 原输入、Mapper 和活动 LookupTable 均保持不变。
+ */
+ bool setInputConnection(vtkAlgorithmOutput* pInputConnection,
+ const QString& sArrayName,
+ ScalarAssociation eAssociation,
+ vtkLookupTable* pCandidateLookupTable);
/** @brief 解除直接数据或管线连接,并清除当前标量选择。 */
void clearInput();
/** @brief 返回当前直接数据或管线输出数据集的非所有权指针。 */
@@ -99,6 +108,13 @@ public:
ScalarAssociation eAssociation,
double dMinimum,
double dMaximum);
+ /**
+ * @brief 原子提交当前输入的标量数组和完整候选颜色表。
+ * @return 数组和候选颜色表全部有效时返回 true;失败不修改活动状态。
+ */
+ bool setScalarArray(const QString& sArrayName,
+ ScalarAssociation eAssociation,
+ vtkLookupTable* pCandidateLookupTable);
/** @brief 返回当前选中的数组名称。 */
QString getScalarArrayName() const;
/** @brief 返回当前数组来自 CellData 还是 PointData。 */
@@ -111,6 +127,12 @@ public:
/** @brief 返回当前范围是否由调用方显式指定。 */
bool isUsingExplicitScalarRange() const;
+ /**
+ * @brief 原子替换当前标量数组使用的完整颜色表。
+ * @note 成功后 Mapper 与外部 ScalarBar 可以共享同一对象;不主动 Render。
+ */
+ bool setLookupTable(vtkLookupTable* pCandidateLookupTable);
+
/** 以下访问函数均返回图层持有对象的非所有权指针。 */
vtkDataSetMapper* getMapper() const;
vtkActor* getActor() const;
@@ -129,11 +151,19 @@ private:
const QByteArray& aArrayName,
ScalarAssociation eAssociation,
double dDataRange[2]) const;
+ /** @brief 校验候选颜色表的表项、有限范围及 Log10 正下限。 */
+ bool validateLookupTable(vtkLookupTable* pLookupTable,
+ double dRange[2]) const;
/** @brief 提交已经完整验证的数组选择和范围;本函数内部没有失败分支。 */
void applyExplicitScalarState(const QByteArray& aArrayName,
ScalarAssociation eAssociation,
double dMinimum,
double dMaximum);
+ /** @brief 提交已验证的数组选择和候选颜色表;内部没有失败分支。 */
+ void applyLookupTableScalarState(const QByteArray& aArrayName,
+ ScalarAssociation eAssociation,
+ vtkLookupTable* pLookupTable,
+ const double dRange[2]);
/** @brief 对新输入重新应用已经验证的标量模式、名称和自动范围。 */
void applyRetainedScalarState(const double dScalarRange[2]);
/** @brief 从当前数据集解析已记录的数组选择。 */
diff --git a/Include/nmNum/nmRender/nmVTKScalarBarLayer.h b/Include/nmNum/nmRender/nmVTKScalarBarLayer.h
index 2bddc83e..ad8c6284 100644
--- a/Include/nmNum/nmRender/nmVTKScalarBarLayer.h
+++ b/Include/nmNum/nmRender/nmVTKScalarBarLayer.h
@@ -5,8 +5,12 @@
#include
+class vtkActor2D;
class vtkLookupTable;
+class vtkPoints;
+class vtkPropAssembly;
class vtkScalarBarActor;
+class vtkTextActor;
/**
* @brief 通用色标图层。
@@ -16,7 +20,7 @@ class vtkScalarBarActor;
class NM_RENDER_EXPORT nmVTKScalarBarLayer : public nmVTKRenderLayer
{
public:
- /** @brief 创建空色标,并将二维 Actor 注册为本图层主 Prop。 */
+ /** @brief 创建空色标,并将色标及独立二维装饰加入稳定根 Assembly。 */
explicit nmVTKScalarBarLayer(const QString& sLayerId);
/** @brief 先解除 Renderer,再释放外部颜色表的共享引用。 */
virtual ~nmVTKScalarBarLayer();
@@ -31,6 +35,28 @@ public:
/** @brief 返回调用方设置的标题。 */
QString getTitle() const;
+ /** @brief 设置普通刻度格式,例如 %.6g;空格式返回 false。 */
+ bool setLabelFormat(const QString& sFormat);
+ /** @brief 返回调用方最后设置的普通刻度格式。 */
+ QString getLabelFormat() const;
+ /** @brief 设置 0~64 个普通刻度;常量色标使用 0。 */
+ bool setNumberOfLabels(int nLabelCount);
+ /** @brief 返回当前普通刻度数量。 */
+ int getNumberOfLabels() const;
+
+ /** @brief 配置低于显示范围的独立二维色块和说明文字。 */
+ void setBelowRangeSwatch(bool bVisible, const QString& sText);
+ /** @brief 配置高于显示范围的独立二维色块和说明文字。 */
+ void setAboveRangeSwatch(bool bVisible, const QString& sText);
+
+ /**
+ * @brief 显示或隐藏常量属性的唯一业务值。
+ *
+ * 该文字由独立 vtkTextActor 绘制,不启用共享 LUT 的 IndexedLookup,
+ * 因而不会改变网格使用的连续颜色映射语义。
+ */
+ void setConstantValueLabel(bool bVisible, const QString& sText);
+
/** @brief 设置归一化视口坐标中的左下角位置。 */
bool setPosition(double dX, double dY);
/** @brief 设置归一化视口坐标中的宽度和高度。 */
@@ -42,9 +68,30 @@ public:
private:
Q_DISABLE_COPY(nmVTKScalarBarLayer)
+ /** @brief 根据当前色标位置和尺寸同步全部独立二维装饰的位置。 */
+ void updateOverlayLayout();
+ /** @brief 从活动 LookupTable 同步上下越界色块的实际颜色。 */
+ void updateRangeSwatchColors();
+
vtkSmartPointer m_pLookupTable; ///< 共享外部颜色表引用。
- vtkSmartPointer m_pActor; ///< 图层独占的二维色标 Prop。
+ vtkSmartPointer m_pRootAssembly; ///< Scene 挂载的稳定根 Prop。
+ vtkSmartPointer m_pActor; ///< 图层独占的二维色标 Actor。
+ vtkSmartPointer m_pConstantValueActor; ///< 常量属性唯一值文字。
+ vtkSmartPointer m_pBelowRangeSwatchPoints; ///< 下越界色块四角坐标。
+ vtkSmartPointer m_pBelowRangeSwatchActor; ///< 下越界独立色块。
+ vtkSmartPointer m_pBelowRangeTextActor; ///< 下越界说明文字。
+ vtkSmartPointer m_pAboveRangeSwatchPoints; ///< 上越界色块四角坐标。
+ vtkSmartPointer m_pAboveRangeSwatchActor; ///< 上越界独立色块。
+ vtkSmartPointer m_pAboveRangeTextActor; ///< 上越界说明文字。
QString m_sTitle; ///< 保留无损 Qt 标题,避免从 VTK 窄字符串反向解析。
+ QString m_sLabelFormat; ///< 普通刻度的 printf 风格格式字符串。
+ QString m_sConstantValueText; ///< 保留常量值文字,避免从 VTK 反向解析。
+ QString m_sBelowRangeText; ///< 下越界说明文字状态。
+ QString m_sAboveRangeText; ///< 上越界说明文字状态。
+ double m_dPositionX; ///< 色标左下角的归一化视口 X 坐标。
+ double m_dPositionY; ///< 色标左下角的归一化视口 Y 坐标。
+ double m_dWidth; ///< 色标在归一化视口中的宽度。
+ double m_dHeight; ///< 色标在归一化视口中的高度。
};
#endif // NMVTKSCALARBARLAYER_H
diff --git a/Include/nmNum/nmSubWxs/nmPebiResultDisplaySettings.h b/Include/nmNum/nmSubWxs/nmPebiResultDisplaySettings.h
new file mode 100644
index 00000000..e4541f96
--- /dev/null
+++ b/Include/nmNum/nmSubWxs/nmPebiResultDisplaySettings.h
@@ -0,0 +1,51 @@
+#ifndef NMPEBIRESULTDISPLAYSETTINGS_H
+#define NMPEBIRESULTDISPLAYSETTINGS_H
+
+#include "nmSubWxs_global.h"
+
+#include
+#include
+
+/** @brief PEBI 结果颜色比例模式。 */
+enum NM_PEBI_COLOR_SCALE_MODE
+{
+ NM_PebiColorScale_Linear = 0, ///< 线性颜色映射。
+ NM_PebiColorScale_Logarithmic ///< 以 10 为底的对数颜色映射。
+};
+
+/**
+ * @brief 一项结果属性的窗口级显示偏好纯值类型。
+ *
+ * 本类型不持有 VTK 或界面对象。业务范围和 Log 可用性依赖当前快照,统一由
+ * SceneController 校验;这里仅校验枚举、有限数和颜色对象的结构合法性。
+ */
+struct NM_SUB_WXS_EXPORT nmPebiResultDisplaySettings
+{
+ /** @brief 初始化为 Rainbow、Linear、自动范围和关闭越界专用颜色。 */
+ nmPebiResultDisplaySettings();
+
+ /** @brief 返回枚举、数值和颜色是否具备可提交的基本结构。 */
+ bool isStructurallyValid() const;
+ /**
+ * @brief 返回规范化副本。
+ * @note 自动范围固定把手工值归零;越界颜色固定转换为不透明颜色。
+ */
+ nmPebiResultDisplaySettings normalized() const;
+
+ bool operator==(const nmPebiResultDisplaySettings& oOther) const;
+ bool operator!=(const nmPebiResultDisplaySettings& oOther) const;
+
+ QString m_sColorMapId; ///< 通用色带目录中的稳定英文 ID。
+ NM_PEBI_COLOR_SCALE_MODE m_eScaleMode; ///< 线性或 Log10 映射。
+
+ bool m_bHasManualRange; ///< 为 true 时使用下方两个手工上下限。
+ double m_dManualMinimum; ///< 手工显示最小值;自动范围时规范为 0。
+ double m_dManualMaximum; ///< 手工显示最大值;自动范围时规范为 0。
+
+ bool m_bUseBelowRangeColor; ///< 是否显示低于范围值的专用颜色。
+ bool m_bUseAboveRangeColor; ///< 是否显示高于范围值的专用颜色。
+ QColor m_oBelowRangeColor; ///< 低于范围颜色,提交时强制 Alpha=255。
+ QColor m_oAboveRangeColor; ///< 高于范围颜色,提交时强制 Alpha=255。
+};
+
+#endif // NMPEBIRESULTDISPLAYSETTINGS_H
diff --git a/Include/nmNum/nmSubWxs/nmPebiResultSceneController.h b/Include/nmNum/nmSubWxs/nmPebiResultSceneController.h
index 448c4652..40abdcb1 100644
--- a/Include/nmNum/nmSubWxs/nmPebiResultSceneController.h
+++ b/Include/nmNum/nmSubWxs/nmPebiResultSceneController.h
@@ -2,6 +2,7 @@
#define NMPEBIRESULTSCENECONTROLLER_H
#include "nmSubWxs_global.h"
+#include "nmPebiResultDisplaySettings.h"
#include
#include
@@ -14,7 +15,7 @@ class nmWxVTKRenderContainerWidget;
/**
* @brief 将不可变 PEBI 结果快照组合为独立的通用 VTK 场景。
*
- * Scene 拥有 Mesh、ScalarBar 和平面比例网格图层;控制器独占活动
+ * Scene 拥有 Mesh、ScalarBar、平面比例网格和二维井标注图层;控制器独占活动
* RenderAdapter 和快照强引用,并通过稳定 ID 校验所观察的图层身份。
* 外部提前清空业务 Scene 时,控制器会丢弃活动结果而不会解引用旧图层。
*/
@@ -49,14 +50,30 @@ public:
int nFrameIndex,
QString* pError = nullptr);
+ /**
+ * @brief 事务式提交当前属性的颜色、范围、比例和越界颜色设置。
+ * @param sExpectedSnapshotId 对话框打开时记录的快照 ID。
+ * @param sExpectedPropertyId 对话框打开时记录的属性 ID。
+ * @note 身份或设置校验失败时不修改场景且不 Render;相同设置直接成功。
+ */
+ bool applyCurrentDisplaySettings(
+ const QString& sExpectedSnapshotId,
+ const QString& sExpectedPropertyId,
+ const nmPebiResultDisplaySettings& oSettings,
+ QString* pError = nullptr);
+
/** @brief 设置结果网格显隐;偏好跨快照保留。 */
void setMeshVisible(bool bVisible);
- /** @brief 设置色标显隐;阶段 5A 默认隐藏,偏好跨快照保留。 */
+ /** @brief 设置色标显隐;默认显示,偏好跨快照保留。 */
void setScalarBarVisible(bool bVisible);
/** @brief 设置平面比例网格显隐;偏好跨快照保留。 */
void setScaleGridVisible(bool bVisible);
/** @brief 设置单元边线显隐;偏好跨快照保留。 */
void setCellEdgesVisible(bool bVisible);
+ /** @brief 设置二维井位标记显隐;偏好跨快照保留。 */
+ void setWellMarkersVisible(bool bVisible);
+ /** @brief 设置二维井名显隐;偏好跨快照保留。 */
+ void setWellNamesVisible(bool bVisible);
/** @brief 返回当前是否持有可用快照且稳定结果图层仍完整。 */
bool hasSnapshot() const;
@@ -81,6 +98,11 @@ public:
double& dTime) const;
/** @brief 返回快照中的业务范围;常量属性保持 [c,c]。 */
bool getCurrentPropertyRange(double dRange[2]) const;
+ /** @brief 返回用户可见范围;自动常量属性保持业务值 [c,c]。 */
+ bool getCurrentDisplayRange(double dRange[2]) const;
+ /** @brief 返回当前属性最后一次成功提交的规范化显示设置。 */
+ bool getCurrentDisplaySettings(
+ nmPebiResultDisplaySettings& oSettings) const;
/** @brief 返回结果网格显示偏好,不要求当前存在快照。 */
bool isMeshVisible() const;
/** @brief 返回色标显示偏好,不要求当前存在快照。 */
@@ -89,6 +111,10 @@ public:
bool isScaleGridVisible() const;
/** @brief 返回单元边线显示偏好,不要求当前存在快照。 */
bool areCellEdgesVisible() const;
+ /** @brief 返回二维井位标记显示偏好。 */
+ bool areWellMarkersVisible() const;
+ /** @brief 返回二维井名显示偏好。 */
+ bool areWellNamesVisible() const;
private:
Q_DISABLE_COPY(nmPebiResultSceneController)
diff --git a/Include/nmNum/nmSubWxs/nmPebiResultWellAnnotationLayer.h b/Include/nmNum/nmSubWxs/nmPebiResultWellAnnotationLayer.h
new file mode 100644
index 00000000..395d4d1e
--- /dev/null
+++ b/Include/nmNum/nmSubWxs/nmPebiResultWellAnnotationLayer.h
@@ -0,0 +1,69 @@
+#ifndef NMPEBIRESULTWELLANNOTATIONLAYER_H
+#define NMPEBIRESULTWELLANNOTATIONLAYER_H
+
+#include "nmSubWxs_global.h"
+
+#include "nmVTKRenderLayer.h"
+
+#include
+#include
+
+class nmPebiResultSnapshot;
+class vtkPropAssembly;
+
+/**
+ * @brief 显示快照中全部二维井位和井名的业务图层。
+ *
+ * 图层只读取快照冻结的 XY 和井名,不访问 DataManager,不伪造井深或轨迹。
+ * 稳定根 Assembly 始终挂在 Scene 中;新快照通过候选子 Assembly 无失败交换。
+ */
+class NM_SUB_WXS_EXPORT nmPebiResultWellAnnotationLayer
+ : public nmVTKRenderLayer
+{
+public:
+ /** @brief 创建稳定根 Assembly,初始不包含任何快照井标注。 */
+ explicit nmPebiResultWellAnnotationLayer(const QString& sLayerId);
+ /** @brief 先解除 Renderer,再释放活动和候选子 Assembly。 */
+ virtual ~nmPebiResultWellAnnotationLayer();
+
+ /**
+ * @brief 在未挂载候选对象中构造快照全部井位和井名。
+ * @note 失败时活动子 Assembly 完全不变;再次准备会丢弃旧候选。
+ */
+ bool prepareCandidate(
+ const QSharedPointer& pSnapshot);
+ /** @brief 丢弃尚未提交的候选对象,不影响当前画面。 */
+ void discardCandidate();
+ /**
+ * @brief 将已经验证的候选子 Assembly 替换为活动对象。
+ * @note 仅可在 prepareCandidate() 成功后调用;只执行无失败 VTK setter。
+ */
+ void commitCandidate();
+
+ /** @brief 移除活动和候选井标注,稳定根 Assembly 保持不变。 */
+ void clear();
+ /** @brief 返回活动快照是否已有完整井标注子树。 */
+ bool hasActiveAnnotations() const;
+
+ /** @brief 独立设置约 9px 的二维井位标记显隐。 */
+ void setWellMarkersVisible(bool bVisible);
+ /** @brief 独立设置约 12px 的二维井名显隐。 */
+ void setWellNamesVisible(bool bVisible);
+ bool areWellMarkersVisible() const;
+ bool areWellNamesVisible() const;
+
+private:
+ Q_DISABLE_COPY(nmPebiResultWellAnnotationLayer)
+
+ vtkSmartPointer m_pRootAssembly; ///< Scene 挂载的稳定根。
+ vtkSmartPointer m_pActiveSnapshotAssembly; ///< 当前快照子树。
+ vtkSmartPointer m_pActiveMarkerGroup; ///< 当前井位组。
+ vtkSmartPointer m_pActiveNameGroup; ///< 当前井名组。
+ vtkSmartPointer m_pCandidateSnapshotAssembly; ///< 待提交子树。
+ vtkSmartPointer m_pCandidateMarkerGroup; ///< 候选井位组。
+ vtkSmartPointer m_pCandidateNameGroup; ///< 候选井名组。
+ bool m_bWellMarkersVisible; ///< 跨快照保留的井位显隐偏好。
+ bool m_bWellNamesVisible; ///< 跨快照保留的井名显隐偏好。
+};
+
+#endif // NMPEBIRESULTWELLANNOTATIONLAYER_H
diff --git a/Include/nmNum/nmSubWxs/nmWxPebiResultColorScaleSettingsDlg.h b/Include/nmNum/nmSubWxs/nmWxPebiResultColorScaleSettingsDlg.h
new file mode 100644
index 00000000..d676fd38
--- /dev/null
+++ b/Include/nmNum/nmSubWxs/nmWxPebiResultColorScaleSettingsDlg.h
@@ -0,0 +1,117 @@
+#ifndef NMWXPEBIRESULTCOLORSCALESETTINGSDLG_H
+#define NMWXPEBIRESULTCOLORSCALESETTINGSDLG_H
+
+#include "nmSubWxs_global.h"
+#include "nmPebiResultDisplaySettings.h"
+
+#include
+#include
+
+class QCheckBox;
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QToolButton;
+class nmPebiResultSceneController;
+
+/**
+ * @brief Saphir 风格的当前结果属性颜色设置对话框。
+ *
+ * 对话框保存打开时的 Snapshot ID 和 Property ID,每次 Apply/OK 都交给
+ * SceneController 原子复核。Cancel 只丢弃尚未 Apply 的编辑,不回滚已提交状态。
+ */
+class NM_SUB_WXS_EXPORT nmWxPebiResultColorScaleSettingsDlg
+ : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @param pSceneController 非所有权指针,必须比模态对话框生命周期更长。
+ * @param pParent 所属窗口,用于对象树和模态定位。
+ */
+ explicit nmWxPebiResultColorScaleSettingsDlg(
+ nmPebiResultSceneController* pSceneController,
+ QWidget* pParent = nullptr);
+ /** @brief 子控件由 Qt 对象树自动释放,不修改 Scene 生命周期。 */
+ virtual ~nmWxPebiResultColorScaleSettingsDlg();
+
+signals:
+ /** @brief Apply 或 OK 成功提交后发出,供底部按钮刷新色带预览。 */
+ void displaySettingsApplied();
+ /** @brief 转发具体提交错误,供后续组合窗口显示非阻塞提示。 */
+ void operationFailed(const QString& sError);
+
+private slots:
+ /** @brief 提交当前编辑并保持对话框打开。 */
+ void onApplyClicked();
+ /** @brief 提交成功后关闭对话框,失败时保持打开。 */
+ void onOkClicked();
+ /** @brief 恢复快照属性完整范围,不改变色带、Log 或越界颜色。 */
+ void onRestorePropertyRangeClicked();
+ /** @brief 用户编辑任一上下限后显式进入手工范围模式。 */
+ void onManualRangeEdited(const QString& sText);
+ /** @brief 根据复选框同步低于范围颜色按钮状态。 */
+ void onBelowRangeToggled(bool bChecked);
+ /** @brief 根据复选框同步高于范围颜色按钮状态。 */
+ void onAboveRangeToggled(bool bChecked);
+ /** @brief 选择低于范围的不透明专用颜色。 */
+ void onChooseBelowRangeColor();
+ /** @brief 选择高于范围的不透明专用颜色。 */
+ void onChooseAboveRangeColor();
+ /** @brief 范围文字变化后刷新 Log 可用性说明。 */
+ void refreshLogAvailability();
+
+private:
+ Q_DISABLE_COPY(nmWxPebiResultColorScaleSettingsDlg)
+
+ /** @brief 创建全部编辑控件和 Apply/OK/Cancel 按钮。 */
+ void createUi();
+ /** @brief 从 Scene 读取初值并记录不可变的预期身份。 */
+ bool initializeFromScene();
+ /** @brief 将设置和值域写入控件,不触发手工范围编辑状态。 */
+ void populateEditor(const nmPebiResultDisplaySettings& oSettings,
+ const double dVisibleRange[2]);
+ /** @brief 解析编辑值并构造待提交纯值设置。 */
+ bool collectEditedSettings(
+ nmPebiResultDisplaySettings& oSettings,
+ QString& sError) const;
+ /** @brief 执行公共 Apply 逻辑;成功后更新对话框基线。 */
+ bool applyEditor();
+ /** @brief 使用最多 12 位有效数字格式化业务值。 */
+ QString formatValue(double dValue) const;
+ /** @brief 使用 C locale 严格解析有限 double。 */
+ bool parseFiniteValue(const QString& sText, double& dValue) const;
+ /** @brief 更新颜色按钮色块。 */
+ void updateColorButton(QPushButton* pButton,
+ const QColor& oColor);
+ /** @brief 在对话框中显示或清除具体错误。 */
+ void setErrorText(const QString& sError);
+
+ nmPebiResultSceneController* m_pSceneController; ///< 非所有权 Scene 真源。
+ QString m_sExpectedSnapshotId; ///< 打开时捕获的快照稳定 ID。
+ QString m_sExpectedPropertyId; ///< 打开时捕获的属性稳定 ID。
+ QString m_sDisplayUnit; ///< 当前属性默认显示单位,仅用于标签。
+ double m_dPropertyRange[2]; ///< 快照完整业务范围,回退按钮使用。
+ nmPebiResultDisplaySettings m_oBaselineSettings; ///< 最近成功 Apply 的基线。
+ bool m_bManualRangeEdited; ///< 仅用户编辑或已有手工范围时为 true。
+ bool m_bInitialized; ///< Scene 初值是否完整读取成功。
+
+ QComboBox* m_pColorMapCombo; ///< 带渐变预览和稳定 ID 的色带框。
+ QLineEdit* m_pMinimumEdit; ///< 支持科学计数法的最小值文字框。
+ QLineEdit* m_pMaximumEdit; ///< 支持科学计数法的最大值文字框。
+ QLabel* m_pUnitLabel; ///< 当前属性默认显示单位;无量纲时显示“无量纲”。
+ QToolButton* m_pRestoreRangeButton; ///< 恢复完整业务范围按钮。
+ QCheckBox* m_pLogarithmicCheck; ///< Log10 映射开关。
+ QLabel* m_pLogReasonLabel; ///< Log 不可用时的明确原因。
+ QCheckBox* m_pBelowRangeCheck; ///< 低于范围专用颜色开关。
+ QPushButton* m_pBelowColorButton; ///< 低于范围颜色按钮。
+ QCheckBox* m_pAboveRangeCheck; ///< 高于范围专用颜色开关。
+ QPushButton* m_pAboveColorButton; ///< 高于范围颜色按钮。
+ QLabel* m_pErrorLabel; ///< 提交或解析失败说明。
+ QPushButton* m_pApplyButton; ///< 应用但不关闭按钮。
+ QPushButton* m_pOkButton; ///< 应用成功后关闭按钮。
+};
+
+#endif // NMWXPEBIRESULTCOLORSCALESETTINGSDLG_H
diff --git a/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h b/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h
index 8770609a..1c73c9e6 100644
--- a/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h
+++ b/Include/nmNum/nmSubWxs/nmWxPebiResultControlBar.h
@@ -50,6 +50,8 @@ private slots:
void onPropertyIndexChanged(int nIndex);
/** @brief 用户选择时间时提交 itemData 中的零基帧。 */
void onTimeIndexChanged(int nIndex);
+ /** @brief 暂停后打开当前属性的 Saphir 风格颜色设置对话框。 */
+ void onColorSettingsClicked();
/** @brief 响应首帧按钮。 */
void onFirstFrameClicked();
/** @brief 响应上一帧按钮。 */
@@ -66,6 +68,8 @@ private slots:
void refreshFromController();
/** @brief 将控制器错误转发给后续组合窗口。 */
void forwardOperationFailure(const QString& sError);
+ /** @brief 从 Scene 当前设置刷新颜色按钮的色带预览。 */
+ void refreshColorPreview();
private:
Q_DISABLE_COPY(nmWxPebiResultControlBar)
@@ -84,8 +88,12 @@ private:
/** @brief 本控制条独占的 QObject 子对象,负责全部回放业务状态。 */
nmPebiResultPlaybackController* m_pPlaybackController;
+ /** @brief 已渲染属性、帧和显示设置的唯一真源;本控件不拥有。 */
+ nmPebiResultSceneController* m_pSceneController;
/** @brief 属性选择框,条目数据保存稳定英文属性 ID。 */
QComboBox* m_pPropertyCombo;
+ /** @brief 显示当前色带预览并打开颜色设置对话框。 */
+ QToolButton* m_pColorSettingsButton;
/** @brief 跳到第 0 帧的图标按钮。 */
QToolButton* m_pFirstButton;
/** @brief 跳到上一帧的图标按钮。 */
diff --git a/Src/nmNum/nmRender/nmVTKColorMapCatalog.cpp b/Src/nmNum/nmRender/nmVTKColorMapCatalog.cpp
new file mode 100644
index 00000000..25f8c311
--- /dev/null
+++ b/Src/nmNum/nmRender/nmVTKColorMapCatalog.cpp
@@ -0,0 +1,134 @@
+#include "nmVTKColorMapCatalog.h"
+
+#include
+#include
+
+#include
+#include
+
+namespace {
+
+const char* const COLOR_MAP_RAINBOW = "rainbow";
+const char* const COLOR_MAP_OIL_SATURATION = "oil-saturation";
+const char* const COLOR_MAP_GAS_SATURATION = "gas-saturation";
+const char* const COLOR_MAP_WATER_SATURATION = "water-saturation";
+const int COLOR_TABLE_SIZE = 256;
+
+QString stableId(const char* pId)
+{
+ return QString::fromLatin1(pId);
+}
+
+QColor interpolateRgb(const QColor& oStart,
+ const QColor& oEnd,
+ double dPosition)
+{
+ const double dInverse = 1.0 - dPosition;
+ return QColor(qRound(oStart.red() * dInverse +
+ oEnd.red() * dPosition),
+ qRound(oStart.green() * dInverse +
+ oEnd.green() * dPosition),
+ qRound(oStart.blue() * dInverse +
+ oEnd.blue() * dPosition),
+ 255);
+}
+
+}
+
+QStringList nmVTKColorMapCatalog::getColorMapIds()
+{
+ QStringList listIds;
+ listIds << stableId(COLOR_MAP_RAINBOW)
+ << stableId(COLOR_MAP_OIL_SATURATION)
+ << stableId(COLOR_MAP_GAS_SATURATION)
+ << stableId(COLOR_MAP_WATER_SATURATION);
+ return listIds;
+}
+
+bool nmVTKColorMapCatalog::contains(const QString& sColorMapId)
+{
+ return getColorMapIds().contains(sColorMapId);
+}
+
+bool nmVTKColorMapCatalog::getColor(const QString& sColorMapId,
+ double dPosition,
+ QColor& oColor)
+{
+ if(!vtkMath::IsFinite(dPosition) || dPosition < 0.0 ||
+ dPosition > 1.0 || !contains(sColorMapId)) {
+ return false;
+ }
+
+ QColor oCandidate;
+ if(sColorMapId == stableId(COLOR_MAP_RAINBOW)) {
+ // Saphir 风格 Rainbow:色相从蓝色 240 度连续过渡到红色 0 度。
+ oCandidate = QColor::fromHsvF(
+ (1.0 - dPosition) * (240.0 / 360.0),
+ 1.0, 1.0, 1.0);
+ } else if(sColorMapId == stableId(COLOR_MAP_OIL_SATURATION)) {
+ oCandidate = interpolateRgb(
+ QColor(255, 255, 255), QColor(0, 255, 0), dPosition);
+ } else if(sColorMapId == stableId(COLOR_MAP_GAS_SATURATION)) {
+ oCandidate = interpolateRgb(
+ QColor(255, 255, 255), QColor(255, 0, 0), dPosition);
+ } else {
+ oCandidate = interpolateRgb(
+ QColor(255, 255, 255), QColor(0, 0, 255), dPosition);
+ }
+ oCandidate.setAlpha(255);
+ oColor = oCandidate;
+ return true;
+}
+
+QPixmap nmVTKColorMapCatalog::createPreviewPixmap(
+ const QString& sColorMapId,
+ const QSize& oSize)
+{
+ if(!contains(sColorMapId) || oSize.width() <= 0 ||
+ oSize.height() <= 0) {
+ return QPixmap();
+ }
+
+ QPixmap oPixmap(oSize);
+ oPixmap.fill(Qt::transparent);
+ QPainter oPainter(&oPixmap);
+ for(int nX = 0; nX < oSize.width(); ++nX) {
+ QColor oColor;
+ const double dPosition = oSize.width() == 1 ? 0.0 :
+ static_cast(nX) /
+ static_cast(oSize.width() - 1);
+ if(getColor(sColorMapId, dPosition, oColor)) {
+ oPainter.setPen(oColor);
+ oPainter.drawLine(nX, 0, nX, oSize.height() - 1);
+ }
+ }
+ oPainter.setPen(QColor(96, 96, 96));
+ oPainter.drawRect(0, 0, oSize.width() - 1, oSize.height() - 1);
+ oPainter.end();
+ return oPixmap;
+}
+
+vtkSmartPointer
+nmVTKColorMapCatalog::createLookupTable(const QString& sColorMapId)
+{
+ if(!contains(sColorMapId)) {
+ return vtkSmartPointer();
+ }
+
+ vtkSmartPointer pLookupTable =
+ vtkSmartPointer::New();
+ pLookupTable->SetNumberOfTableValues(COLOR_TABLE_SIZE);
+ for(int nIndex = 0; nIndex < COLOR_TABLE_SIZE; ++nIndex) {
+ QColor oColor;
+ const double dPosition = static_cast(nIndex) /
+ static_cast(COLOR_TABLE_SIZE - 1);
+ if(!getColor(sColorMapId, dPosition, oColor)) {
+ return vtkSmartPointer();
+ }
+ pLookupTable->SetTableValue(
+ nIndex,
+ oColor.redF(), oColor.greenF(), oColor.blueF(), 1.0);
+ }
+ pLookupTable->Build();
+ return pLookupTable;
+}
diff --git a/Src/nmNum/nmRender/nmVTKMeshLayer.cpp b/Src/nmNum/nmRender/nmVTKMeshLayer.cpp
index 6b88d376..b6d7bbcf 100644
--- a/Src/nmNum/nmRender/nmVTKMeshLayer.cpp
+++ b/Src/nmNum/nmRender/nmVTKMeshLayer.cpp
@@ -155,6 +155,42 @@ bool nmVTKMeshLayer::setInputConnection(
return true;
}
+bool nmVTKMeshLayer::setInputConnection(
+ vtkAlgorithmOutput* pInputConnection,
+ const QString& sArrayName,
+ ScalarAssociation eAssociation,
+ vtkLookupTable* pCandidateLookupTable)
+{
+ Q_ASSERT(isMeshLayerGuiThread());
+ if(!isMeshLayerGuiThread() || pInputConnection == nullptr ||
+ pInputConnection->GetProducer() == nullptr ||
+ pInputConnection->GetIndex() < 0 || sArrayName.isEmpty()) {
+ return false;
+ }
+
+ vtkAlgorithm* pProducer = pInputConnection->GetProducer();
+ const int nOutputPort = pInputConnection->GetIndex();
+ pProducer->Update(nOutputPort);
+ vtkDataSet* pCandidateDataSet = vtkDataSet::SafeDownCast(
+ pProducer->GetOutputDataObject(nOutputPort));
+ const QByteArray aArrayName = sArrayName.toUtf8();
+ double dDataRange[2] = { 0.0, 0.0 };
+ double dLookupRange[2] = { 0.0, 0.0 };
+ if(validateScalarArray(pCandidateDataSet, aArrayName,
+ eAssociation, dDataRange) == nullptr ||
+ !validateLookupTable(pCandidateLookupTable, dLookupRange)) {
+ return false;
+ }
+
+ // 输入、数组和候选 LUT 已全部验证;以下 VTK setter 均无失败返回值。
+ m_pMapper->SetInputConnection(pInputConnection);
+ m_pInputConnection = pInputConnection;
+ m_pDataSet = nullptr;
+ applyLookupTableScalarState(aArrayName, eAssociation,
+ pCandidateLookupTable, dLookupRange);
+ return true;
+}
+
void nmVTKMeshLayer::clearInput()
{
Q_ASSERT(isMeshLayerGuiThread());
@@ -272,6 +308,32 @@ bool nmVTKMeshLayer::setScalarArray(
return true;
}
+bool nmVTKMeshLayer::setScalarArray(
+ const QString& sArrayName,
+ ScalarAssociation eAssociation,
+ vtkLookupTable* pCandidateLookupTable)
+{
+ Q_ASSERT(isMeshLayerGuiThread());
+ vtkDataSet* pDataSet = getInputDataSet(true);
+ if(!isMeshLayerGuiThread() || sArrayName.isEmpty() ||
+ pDataSet == nullptr || m_pMapper == nullptr) {
+ return false;
+ }
+
+ const QByteArray aArrayName = sArrayName.toUtf8();
+ double dDataRange[2] = { 0.0, 0.0 };
+ double dLookupRange[2] = { 0.0, 0.0 };
+ if(validateScalarArray(pDataSet, aArrayName,
+ eAssociation, dDataRange) == nullptr ||
+ !validateLookupTable(pCandidateLookupTable, dLookupRange)) {
+ return false;
+ }
+
+ applyLookupTableScalarState(aArrayName, eAssociation,
+ pCandidateLookupTable, dLookupRange);
+ return true;
+}
+
bool nmVTKMeshLayer::setScalarArray(
const QString& sArrayName,
ScalarAssociation eAssociation,
@@ -344,6 +406,24 @@ bool nmVTKMeshLayer::isUsingExplicitScalarRange() const
return m_bUsingExplicitScalarRange;
}
+bool nmVTKMeshLayer::setLookupTable(
+ vtkLookupTable* pCandidateLookupTable)
+{
+ Q_ASSERT(isMeshLayerGuiThread());
+ double dLookupRange[2] = { 0.0, 0.0 };
+ if(!isMeshLayerGuiThread() || getSelectedScalarArray() == nullptr ||
+ !validateLookupTable(pCandidateLookupTable, dLookupRange)) {
+ return false;
+ }
+
+ // 候选对象由智能指针共享,Mapper 与 MeshLayer 始终引用同一 LUT。
+ m_pLookupTable = pCandidateLookupTable;
+ m_pMapper->SetLookupTable(m_pLookupTable);
+ m_pMapper->SetScalarRange(dLookupRange);
+ m_bUsingExplicitScalarRange = true;
+ return true;
+}
+
vtkDataSetMapper* nmVTKMeshLayer::getMapper() const
{
return m_pMapper;
@@ -419,6 +499,25 @@ vtkDataArray* nmVTKMeshLayer::validateScalarArray(
? pArray : nullptr;
}
+bool nmVTKMeshLayer::validateLookupTable(
+ vtkLookupTable* pLookupTable,
+ double dRange[2]) const
+{
+ if(pLookupTable == nullptr || dRange == nullptr ||
+ pLookupTable->GetNumberOfTableValues() <= 0) {
+ return false;
+ }
+ const double* pRange = pLookupTable->GetTableRange();
+ if(pRange == nullptr || !vtkMath::IsFinite(pRange[0]) ||
+ !vtkMath::IsFinite(pRange[1]) || pRange[0] >= pRange[1] ||
+ (pLookupTable->GetScale() == VTK_SCALE_LOG10 && pRange[0] <= 0.0)) {
+ return false;
+ }
+ dRange[0] = pRange[0];
+ dRange[1] = pRange[1];
+ return true;
+}
+
void nmVTKMeshLayer::applyExplicitScalarState(
const QByteArray& aArrayName,
ScalarAssociation eAssociation,
@@ -439,6 +538,27 @@ void nmVTKMeshLayer::applyExplicitScalarState(
m_bUsingExplicitScalarRange = true;
}
+void nmVTKMeshLayer::applyLookupTableScalarState(
+ const QByteArray& aArrayName,
+ ScalarAssociation eAssociation,
+ vtkLookupTable* pLookupTable,
+ const double dRange[2])
+{
+ m_aScalarArrayName = aArrayName;
+ m_eScalarAssociation = eAssociation;
+ if(eAssociation == ScalarAssociation_CellData) {
+ m_pMapper->SetScalarModeToUseCellFieldData();
+ } else {
+ m_pMapper->SetScalarModeToUsePointFieldData();
+ }
+ m_pMapper->SelectColorArray(m_aScalarArrayName.constData());
+ m_pLookupTable = pLookupTable;
+ m_pMapper->SetLookupTable(m_pLookupTable);
+ // VTK 7.1 的数组重载要求可写 double*,这里使用双参数重载保留 const 契约。
+ m_pMapper->SetScalarRange(dRange[0], dRange[1]);
+ m_bUsingExplicitScalarRange = true;
+}
+
void nmVTKMeshLayer::applyRetainedScalarState(
const double dScalarRange[2])
{
diff --git a/Src/nmNum/nmRender/nmVTKScalarBarLayer.cpp b/Src/nmNum/nmRender/nmVTKScalarBarLayer.cpp
index 9cec6fcd..33ad8f6a 100644
--- a/Src/nmNum/nmRender/nmVTKScalarBarLayer.cpp
+++ b/Src/nmNum/nmRender/nmVTKScalarBarLayer.cpp
@@ -4,9 +4,19 @@
#include
#include
+#include
+#include
+#include
#include
#include
+#include
+#include
+#include
+#include
+#include
#include
+#include
+#include
namespace {
@@ -18,16 +28,125 @@ bool isScalarBarGuiThread()
pApplication->thread() == QThread::currentThread();
}
+// 独立色块使用归一化视口坐标,避免依赖仅支持 IndexedLookup 的 ScalarBar Annotation。
+vtkSmartPointer createRangeSwatchActor(vtkPoints* pPoints)
+{
+ vtkSmartPointer pPolygons =
+ vtkSmartPointer::New();
+ pPolygons->InsertNextCell(4);
+ pPolygons->InsertCellPoint(0);
+ pPolygons->InsertCellPoint(1);
+ pPolygons->InsertCellPoint(2);
+ pPolygons->InsertCellPoint(3);
+
+ vtkSmartPointer pData =
+ vtkSmartPointer::New();
+ pData->SetPoints(pPoints);
+ pData->SetPolys(pPolygons);
+
+ vtkSmartPointer pViewportCoordinate =
+ vtkSmartPointer::New();
+ pViewportCoordinate->SetCoordinateSystemToNormalizedViewport();
+ vtkSmartPointer pMapper =
+ vtkSmartPointer::New();
+ pMapper->SetInputData(pData);
+ pMapper->SetTransformCoordinate(pViewportCoordinate);
+ pMapper->ScalarVisibilityOff();
+
+ vtkSmartPointer pActor =
+ vtkSmartPointer::New();
+ pActor->SetMapper(pMapper);
+ pActor->GetProperty()->SetDisplayLocationToForeground();
+ pActor->PickableOff();
+ pActor->SetVisibility(0);
+ return pActor;
+}
+
+// 统一独立文本样式,使常量值和越界说明与普通色标刻度保持一致。
+void configureOverlayTextActor(vtkTextActor* pActor)
+{
+ pActor->SetInput("");
+ pActor->SetTextScaleModeToNone();
+ pActor->GetTextProperty()->SetFontSize(11);
+ pActor->GetTextProperty()->BoldOff();
+ pActor->GetTextProperty()->ItalicOff();
+ pActor->GetTextProperty()->ShadowOff();
+ pActor->GetTextProperty()->SetJustificationToLeft();
+ pActor->GetTextProperty()->SetVerticalJustificationToCentered();
+ pActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
+ pActor->PickableOff();
+ pActor->SetVisibility(0);
+}
+
+// 更新矩形四角并显式标记 Points 已修改,Mapper 会在下一次 Render 使用新位置。
+void updateRectangle(vtkPoints* pPoints,
+ double dX, double dY,
+ double dWidth, double dHeight)
+{
+ pPoints->SetPoint(0, dX, dY, 0.0);
+ pPoints->SetPoint(1, dX + dWidth, dY, 0.0);
+ pPoints->SetPoint(2, dX + dWidth, dY + dHeight, 0.0);
+ pPoints->SetPoint(3, dX, dY + dHeight, 0.0);
+ pPoints->Modified();
+}
+
}
nmVTKScalarBarLayer::nmVTKScalarBarLayer(const QString& sLayerId)
: nmVTKRenderLayer(sLayerId),
m_pLookupTable(nullptr),
- m_pActor(vtkSmartPointer::New())
+ m_pRootAssembly(vtkSmartPointer::New()),
+ m_pActor(vtkSmartPointer::New()),
+ m_pConstantValueActor(vtkSmartPointer::New()),
+ m_pBelowRangeSwatchPoints(vtkSmartPointer::New()),
+ m_pBelowRangeSwatchActor(nullptr),
+ m_pBelowRangeTextActor(vtkSmartPointer::New()),
+ m_pAboveRangeSwatchPoints(vtkSmartPointer::New()),
+ m_pAboveRangeSwatchActor(nullptr),
+ m_pAboveRangeTextActor(vtkSmartPointer::New()),
+ m_sLabelFormat(QString::fromLatin1("%.6g")),
+ m_dPositionX(0.0),
+ m_dPositionY(0.0),
+ m_dWidth(0.1),
+ m_dHeight(0.8)
{
Q_ASSERT(isScalarBarGuiThread());
// vtkScalarBarActor 是二维 Prop,仍通过图层基类统一完成挂载和显隐。
- setRenderProp(m_pActor);
+ m_pActor->SetNumberOfLabels(5);
+ m_pActor->SetLabelFormat("%.6g");
+ m_pActor->UnconstrainedFontSizeOn();
+ m_pActor->GetLabelTextProperty()->SetFontSize(11);
+ m_pActor->GetLabelTextProperty()->BoldOff();
+ m_pActor->GetLabelTextProperty()->ItalicOff();
+ m_pActor->GetLabelTextProperty()->ShadowOff();
+ m_pActor->GetTitleTextProperty()->SetFontSize(12);
+ m_pActor->GetTitleTextProperty()->BoldOff();
+ m_pActor->GetTitleTextProperty()->ItalicOff();
+ m_pActor->GetTitleTextProperty()->ShadowOff();
+ m_pActor->DrawAnnotationsOff();
+ m_pActor->DrawBelowRangeSwatchOff();
+ m_pActor->DrawAboveRangeSwatchOff();
+
+ // 这些二维装饰必须独立显示,不能为网格共享 LUT 开启 IndexedLookup。
+ m_pBelowRangeSwatchPoints->SetNumberOfPoints(4);
+ m_pAboveRangeSwatchPoints->SetNumberOfPoints(4);
+ m_pBelowRangeSwatchActor =
+ createRangeSwatchActor(m_pBelowRangeSwatchPoints);
+ m_pAboveRangeSwatchActor =
+ createRangeSwatchActor(m_pAboveRangeSwatchPoints);
+ configureOverlayTextActor(m_pConstantValueActor);
+ configureOverlayTextActor(m_pBelowRangeTextActor);
+ configureOverlayTextActor(m_pAboveRangeTextActor);
+ updateOverlayLayout();
+
+ // 根 Assembly 只在构造时注册,运行期仅更新子 Actor 状态。
+ m_pRootAssembly->AddPart(m_pActor);
+ m_pRootAssembly->AddPart(m_pConstantValueActor);
+ m_pRootAssembly->AddPart(m_pBelowRangeSwatchActor);
+ m_pRootAssembly->AddPart(m_pBelowRangeTextActor);
+ m_pRootAssembly->AddPart(m_pAboveRangeSwatchActor);
+ m_pRootAssembly->AddPart(m_pAboveRangeTextActor);
+ setRenderProp(m_pRootAssembly);
}
nmVTKScalarBarLayer::~nmVTKScalarBarLayer()
@@ -36,6 +155,15 @@ nmVTKScalarBarLayer::~nmVTKScalarBarLayer()
// 先移除二维 Prop,再释放对外部 LookupTable 的共享引用。
detach();
m_pLookupTable = nullptr;
+ m_pAboveRangeTextActor = nullptr;
+ m_pAboveRangeSwatchActor = nullptr;
+ m_pAboveRangeSwatchPoints = nullptr;
+ m_pBelowRangeTextActor = nullptr;
+ m_pBelowRangeSwatchActor = nullptr;
+ m_pBelowRangeSwatchPoints = nullptr;
+ m_pConstantValueActor = nullptr;
+ m_pActor = nullptr;
+ m_pRootAssembly = nullptr;
}
void nmVTKScalarBarLayer::setLookupTable(vtkLookupTable* pLookupTable)
@@ -47,6 +175,7 @@ void nmVTKScalarBarLayer::setLookupTable(vtkLookupTable* pLookupTable)
// 智能指针共享 LookupTable,保证外部释放原指针后色标仍可安全显示。
m_pLookupTable = pLookupTable;
m_pActor->SetLookupTable(pLookupTable);
+ updateRangeSwatchColors();
}
vtkLookupTable* nmVTKScalarBarLayer::getLookupTable() const
@@ -71,6 +200,86 @@ QString nmVTKScalarBarLayer::getTitle() const
return m_sTitle;
}
+bool nmVTKScalarBarLayer::setLabelFormat(const QString& sFormat)
+{
+ Q_ASSERT(isScalarBarGuiThread());
+ if(!isScalarBarGuiThread() || sFormat.isEmpty()) {
+ return false;
+ }
+ m_sLabelFormat = sFormat;
+ const QByteArray aFormat = sFormat.toLatin1();
+ m_pActor->SetLabelFormat(aFormat.constData());
+ return true;
+}
+
+QString nmVTKScalarBarLayer::getLabelFormat() const
+{
+ return m_sLabelFormat;
+}
+
+bool nmVTKScalarBarLayer::setNumberOfLabels(int nLabelCount)
+{
+ Q_ASSERT(isScalarBarGuiThread());
+ if(!isScalarBarGuiThread() || nLabelCount < 0 || nLabelCount > 64) {
+ return false;
+ }
+ m_pActor->SetNumberOfLabels(nLabelCount);
+ return true;
+}
+
+int nmVTKScalarBarLayer::getNumberOfLabels() const
+{
+ return m_pActor != nullptr ? m_pActor->GetNumberOfLabels() : 0;
+}
+
+void nmVTKScalarBarLayer::setBelowRangeSwatch(
+ bool bVisible,
+ const QString& sText)
+{
+ Q_ASSERT(isScalarBarGuiThread());
+ if(!isScalarBarGuiThread()) {
+ return;
+ }
+ m_sBelowRangeText = bVisible ? sText : QString();
+ const QByteArray aText = m_sBelowRangeText.toUtf8();
+ m_pBelowRangeTextActor->SetInput(aText.constData());
+ m_pBelowRangeSwatchActor->SetVisibility(bVisible ? 1 : 0);
+ m_pBelowRangeTextActor->SetVisibility(
+ bVisible && !m_sBelowRangeText.isEmpty() ? 1 : 0);
+}
+
+void nmVTKScalarBarLayer::setAboveRangeSwatch(
+ bool bVisible,
+ const QString& sText)
+{
+ Q_ASSERT(isScalarBarGuiThread());
+ if(!isScalarBarGuiThread()) {
+ return;
+ }
+ m_sAboveRangeText = bVisible ? sText : QString();
+ const QByteArray aText = m_sAboveRangeText.toUtf8();
+ m_pAboveRangeTextActor->SetInput(aText.constData());
+ m_pAboveRangeSwatchActor->SetVisibility(bVisible ? 1 : 0);
+ m_pAboveRangeTextActor->SetVisibility(
+ bVisible && !m_sAboveRangeText.isEmpty() ? 1 : 0);
+}
+
+void nmVTKScalarBarLayer::setConstantValueLabel(
+ bool bVisible,
+ const QString& sText)
+{
+ Q_ASSERT(isScalarBarGuiThread());
+ if(!isScalarBarGuiThread()) {
+ return;
+ }
+
+ m_sConstantValueText = bVisible ? sText : QString();
+ const QByteArray aText = m_sConstantValueText.toUtf8();
+ m_pConstantValueActor->SetInput(aText.constData());
+ m_pConstantValueActor->SetVisibility(
+ bVisible && !m_sConstantValueText.isEmpty() ? 1 : 0);
+}
+
bool nmVTKScalarBarLayer::setPosition(double dX, double dY)
{
Q_ASSERT(isScalarBarGuiThread());
@@ -79,7 +288,10 @@ bool nmVTKScalarBarLayer::setPosition(double dX, double dY)
return false;
}
// vtkScalarBarActor 默认使用归一化视口坐标,位置值由上层布局策略决定。
+ m_dPositionX = dX;
+ m_dPositionY = dY;
m_pActor->SetPosition(dX, dY);
+ updateOverlayLayout();
return true;
}
@@ -91,11 +303,67 @@ bool nmVTKScalarBarLayer::setSize(double dWidth, double dHeight)
return false;
}
// 这里只拒绝非正尺寸,不替业务层限制色标是否超出视口。
+ m_dWidth = dWidth;
+ m_dHeight = dHeight;
m_pActor->SetWidth(dWidth);
m_pActor->SetHeight(dHeight);
+ updateOverlayLayout();
return true;
}
+void nmVTKScalarBarLayer::updateOverlayLayout()
+{
+ // 常量值放在色带右侧的垂直中心,视觉位置与普通刻度标签一致。
+ const double dLabelX = m_dPositionX + m_dWidth + 0.01;
+ const double dLabelY = m_dPositionY + m_dHeight * 0.5;
+ m_pConstantValueActor->GetPositionCoordinate()->SetValue(
+ dLabelX, dLabelY, 0.0);
+
+ // 越界色块位于色带上下两端外侧,避免覆盖连续色带和普通刻度。
+ double dSwatchWidth = m_dWidth * 0.25;
+ if(dSwatchWidth < 0.012) {
+ dSwatchWidth = 0.012;
+ } else if(dSwatchWidth > 0.025) {
+ dSwatchWidth = 0.025;
+ }
+ const double dSwatchHeight = 0.018;
+ const double dSwatchGap = 0.012;
+ const double dTextGap = 0.008;
+ const double dBelowY =
+ m_dPositionY - dSwatchGap - dSwatchHeight;
+ const double dAboveY =
+ m_dPositionY + m_dHeight + dSwatchGap;
+ updateRectangle(m_pBelowRangeSwatchPoints,
+ m_dPositionX, dBelowY,
+ dSwatchWidth, dSwatchHeight);
+ updateRectangle(m_pAboveRangeSwatchPoints,
+ m_dPositionX, dAboveY,
+ dSwatchWidth, dSwatchHeight);
+ m_pBelowRangeTextActor->GetPositionCoordinate()->SetValue(
+ m_dPositionX + dSwatchWidth + dTextGap,
+ dBelowY + dSwatchHeight * 0.5, 0.0);
+ m_pAboveRangeTextActor->GetPositionCoordinate()->SetValue(
+ m_dPositionX + dSwatchWidth + dTextGap,
+ dAboveY + dSwatchHeight * 0.5, 0.0);
+}
+
+void nmVTKScalarBarLayer::updateRangeSwatchColors()
+{
+ if(m_pLookupTable == nullptr) {
+ return;
+ }
+
+ // 读取 LookupTable 的业务颜色属性,不直接访问内部特殊表项索引。
+ const double* pBelowColor = m_pLookupTable->GetBelowRangeColor();
+ const double* pAboveColor = m_pLookupTable->GetAboveRangeColor();
+ m_pBelowRangeSwatchActor->GetProperty()->SetColor(
+ pBelowColor[0], pBelowColor[1], pBelowColor[2]);
+ m_pBelowRangeSwatchActor->GetProperty()->SetOpacity(pBelowColor[3]);
+ m_pAboveRangeSwatchActor->GetProperty()->SetColor(
+ pAboveColor[0], pAboveColor[1], pAboveColor[2]);
+ m_pAboveRangeSwatchActor->GetProperty()->SetOpacity(pAboveColor[3]);
+}
+
vtkScalarBarActor* nmVTKScalarBarLayer::getActor() const
{
return m_pActor;
diff --git a/Src/nmNum/nmSubWxs/nmPebiResultDisplaySettings.cpp b/Src/nmNum/nmSubWxs/nmPebiResultDisplaySettings.cpp
new file mode 100644
index 00000000..cb146b9b
--- /dev/null
+++ b/Src/nmNum/nmSubWxs/nmPebiResultDisplaySettings.cpp
@@ -0,0 +1,90 @@
+#include "nmPebiResultDisplaySettings.h"
+
+#include
+
+#include
+
+#if !defined(_MSC_VER)
+#include
+#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);
+}
diff --git a/Src/nmNum/nmSubWxs/nmPebiResultSceneController.cpp b/Src/nmNum/nmSubWxs/nmPebiResultSceneController.cpp
index 84eefdd5..fffe4004 100644
--- a/Src/nmNum/nmSubWxs/nmPebiResultSceneController.cpp
+++ b/Src/nmNum/nmSubWxs/nmPebiResultSceneController.cpp
@@ -1,9 +1,12 @@
#include "nmPebiResultSceneController.h"
#include "nmPebiResultPropertyCatalog.h"
+#include "nmPebiResultPropertyDisplayText.h"
#include "nmPebiResultSnapshot.h"
#include "nmPebiResultSnapshotRenderAdapter.h"
+#include "nmPebiResultWellAnnotationLayer.h"
+#include "nmVTKColorMapCatalog.h"
#include "nmVTKMeshLayer.h"
#include "nmVTKPlanarScaleGridLayer.h"
#include "nmVTKScalarBarLayer.h"
@@ -11,7 +14,7 @@
#include "nmWxVTKRenderContainerWidget.h"
#include
-#include
+#include
#include
#include
@@ -55,7 +58,23 @@ static const char* const s_pResultSceneTranslationMarkers[] =
QT_TRANSLATE_NOOP("nmPebiResultSceneController",
"The result property range is invalid."),
QT_TRANSLATE_NOOP("nmPebiResultSceneController",
- "Unable to apply the result property or frame.")
+ "Unable to apply the result property or frame."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "The color settings no longer match the current result."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "The color settings are invalid."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "The selected color map is unavailable."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "The manual range must contain two finite increasing values."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "Logarithmic scale requires positive property and display ranges."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "Unable to construct the color mapping."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController",
+ "Unable to apply the color settings."),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController", "Below min"),
+ QT_TRANSLATE_NOOP("nmPebiResultSceneController", "Above max")
};
bool isResultSceneGuiThread()
@@ -98,50 +117,207 @@ bool getFiniteBounds(vtkDataSet* pDataSet, double dBounds[6])
dBounds[4] <= dBounds[5];
}
-bool getDisplayRange(const double dBusinessRange[2],
- double dDisplayRange[2])
+bool getInternalDisplayRange(const double dVisibleRange[2],
+ bool bLogarithmic,
+ double dInternalRange[2])
{
- if(dBusinessRange == nullptr || dDisplayRange == nullptr ||
- !vtkMath::IsFinite(dBusinessRange[0]) ||
- !vtkMath::IsFinite(dBusinessRange[1]) ||
- dBusinessRange[0] > dBusinessRange[1]) {
+ if(dVisibleRange == nullptr || dInternalRange == nullptr ||
+ !vtkMath::IsFinite(dVisibleRange[0]) ||
+ !vtkMath::IsFinite(dVisibleRange[1]) ||
+ dVisibleRange[0] > dVisibleRange[1] ||
+ (bLogarithmic && dVisibleRange[0] <= 0.0)) {
return false;
}
- dDisplayRange[0] = dBusinessRange[0];
- dDisplayRange[1] = dBusinessRange[1];
- if(dBusinessRange[0] < dBusinessRange[1]) {
+ dInternalRange[0] = dVisibleRange[0];
+ dInternalRange[1] = dVisibleRange[1];
+ if(dVisibleRange[0] < dVisibleRange[1]) {
return true;
}
- // VTK 需要非零显示区间;业务层仍保存并返回原始常量范围 [c,c]。
- const double dValue = dBusinessRange[0];
- const double dEpsilon = qMax(1.0, fabs(dValue)) * 1.0e-6;
- double dMinimum = dValue - dEpsilon;
- double dMaximum = dValue + dEpsilon;
- if(!vtkMath::IsFinite(dMinimum)) {
- dMinimum = dValue;
- }
- if(!vtkMath::IsFinite(dMaximum)) {
- dMaximum = dValue;
+ // VTK 不接受零宽范围。常量值只扩展内部 LUT,业务和可见范围仍为 [c,c]。
+ const double dValue = dVisibleRange[0];
+ double dMinimum = 0.0;
+ double dMaximum = 0.0;
+ if(bLogarithmic) {
+ dMinimum = dValue * (1.0 - 1.0e-6);
+ dMaximum = dValue * (1.0 + 1.0e-6);
+ if(!vtkMath::IsFinite(dMinimum) || dMinimum <= 0.0 ||
+ dMinimum >= dValue) {
+ const double dHalfValue = dValue / 2.0;
+ dMinimum = dHalfValue > 0.0 && dHalfValue < dValue
+ ? dHalfValue : dValue;
+ }
+ if(!vtkMath::IsFinite(dMaximum) || dMaximum <= dValue) {
+ const double dTwiceValue = dValue * 2.0;
+ dMaximum = vtkMath::IsFinite(dTwiceValue) &&
+ dTwiceValue > dValue ? dTwiceValue : dValue;
+ }
+ } else if(dValue == 0.0) {
+ dMinimum = -1.0e-6;
+ dMaximum = 1.0e-6;
+ } else {
+ const double dEpsilon = qMax(1.0, fabs(dValue)) * 1.0e-6;
+ dMinimum = dValue - dEpsilon;
+ dMaximum = dValue + dEpsilon;
+ if(!vtkMath::IsFinite(dMinimum) || dMinimum >= dValue) {
+ dMinimum = dValue > 0.0 ? dValue / 2.0 : dValue;
+ }
+ if(!vtkMath::IsFinite(dMaximum) || dMaximum <= dValue) {
+ dMaximum = dValue < 0.0 ? dValue / 2.0 : dValue;
+ }
}
- if(dMinimum >= dMaximum) {
+ if(!vtkMath::IsFinite(dMinimum) || !vtkMath::IsFinite(dMaximum) ||
+ dMinimum >= dMaximum || (bLogarithmic && dMinimum <= 0.0)) {
return false;
}
- dDisplayRange[0] = dMinimum;
- dDisplayRange[1] = dMaximum;
+ dInternalRange[0] = dMinimum;
+ dInternalRange[1] = dMaximum;
return true;
}
-bool getValidatedPropertyRanges(
+struct ResultDisplayCandidate
+{
+ ResultDisplayCandidate()
+ : m_pLookupTable(nullptr),
+ m_bConstantValueLabel(false)
+ {
+ m_dBusinessRange[0] = m_dBusinessRange[1] = 0.0;
+ m_dVisibleRange[0] = m_dVisibleRange[1] = 0.0;
+ m_dInternalRange[0] = 0.0;
+ m_dInternalRange[1] = 1.0;
+ }
+
+ nmPebiResultDisplaySettings m_oSettings;
+ double m_dBusinessRange[2];
+ double m_dVisibleRange[2];
+ double m_dInternalRange[2];
+ vtkSmartPointer m_pLookupTable;
+ QString m_sScalarBarTitle;
+ bool m_bConstantValueLabel;
+};
+
+bool prepareDisplayCandidate(
const QSharedPointer& pSnapshot,
const QString& sPropertyId,
- double dBusinessRange[2],
- double dDisplayRange[2])
+ const nmPebiResultDisplaySettings& oRequestedSettings,
+ ResultDisplayCandidate& oCandidate,
+ QString* pError)
{
- return !pSnapshot.isNull() &&
- pSnapshot->getPropertyRange(sPropertyId, dBusinessRange) &&
- getDisplayRange(dBusinessRange, dDisplayRange);
+ nmPebiResultDisplaySettings oSettings = oRequestedSettings.normalized();
+ if(pSnapshot.isNull() || !pSnapshot->hasProperty(sPropertyId) ||
+ !oSettings.isStructurallyValid()) {
+ if(pError != nullptr) {
+ *pError = controllerText("The color settings are invalid.");
+ }
+ return false;
+ }
+ if(!nmVTKColorMapCatalog::contains(oSettings.m_sColorMapId)) {
+ if(pError != nullptr) {
+ *pError = controllerText("The selected color map is unavailable.");
+ }
+ return false;
+ }
+
+ double dBusinessRange[2] = { 0.0, 0.0 };
+ if(!pSnapshot->getPropertyRange(sPropertyId, dBusinessRange) ||
+ !vtkMath::IsFinite(dBusinessRange[0]) ||
+ !vtkMath::IsFinite(dBusinessRange[1]) ||
+ dBusinessRange[0] > dBusinessRange[1]) {
+ if(pError != nullptr) {
+ *pError = controllerText("The result property range is invalid.");
+ }
+ return false;
+ }
+
+ double dVisibleRange[2] = {
+ dBusinessRange[0], dBusinessRange[1]
+ };
+ if(oSettings.m_bHasManualRange) {
+ if(!vtkMath::IsFinite(oSettings.m_dManualMinimum) ||
+ !vtkMath::IsFinite(oSettings.m_dManualMaximum) ||
+ oSettings.m_dManualMinimum >= oSettings.m_dManualMaximum) {
+ if(pError != nullptr) {
+ *pError = controllerText(
+ "The manual range must contain two finite increasing values.");
+ }
+ return false;
+ }
+ dVisibleRange[0] = oSettings.m_dManualMinimum;
+ dVisibleRange[1] = oSettings.m_dManualMaximum;
+ }
+
+ const bool bLogarithmic =
+ oSettings.m_eScaleMode == NM_PebiColorScale_Logarithmic;
+ if(bLogarithmic &&
+ (dBusinessRange[0] <= 0.0 || dVisibleRange[0] <= 0.0)) {
+ if(pError != nullptr) {
+ *pError = controllerText(
+ "Logarithmic scale requires positive property and display ranges.");
+ }
+ return false;
+ }
+
+ double dInternalRange[2] = { 0.0, 1.0 };
+ vtkSmartPointer pLookupTable =
+ nmVTKColorMapCatalog::createLookupTable(
+ oSettings.m_sColorMapId);
+ if(pLookupTable == nullptr ||
+ !getInternalDisplayRange(dVisibleRange, bLogarithmic,
+ dInternalRange)) {
+ if(pError != nullptr) {
+ *pError = controllerText("Unable to construct the color mapping.");
+ }
+ return false;
+ }
+
+ pLookupTable->SetTableRange(dInternalRange);
+ if(bLogarithmic) {
+ pLookupTable->SetScaleToLog10();
+ } else {
+ pLookupTable->SetScaleToLinear();
+ }
+ const QColor oBelowColor = oSettings.m_oBelowRangeColor;
+ const QColor oAboveColor = oSettings.m_oAboveRangeColor;
+ pLookupTable->SetBelowRangeColor(
+ oBelowColor.redF(), oBelowColor.greenF(),
+ oBelowColor.blueF(), 1.0);
+ pLookupTable->SetAboveRangeColor(
+ oAboveColor.redF(), oAboveColor.greenF(),
+ oAboveColor.blueF(), 1.0);
+ pLookupTable->SetUseBelowRangeColor(
+ oSettings.m_bUseBelowRangeColor ? 1 : 0);
+ pLookupTable->SetUseAboveRangeColor(
+ oSettings.m_bUseAboveRangeColor ? 1 : 0);
+ // VTK 7.1 的上下越界颜色位于特殊表项中,Setter 后必须显式同步。
+ // 不能使用 ForceBuild,否则会覆盖色带目录手工写入的 256 个颜色表项。
+ pLookupTable->BuildSpecialColors();
+ pLookupTable->IndexedLookupOff();
+ pLookupTable->ResetAnnotations();
+
+ const bool bConstantValueLabel =
+ !oSettings.m_bHasManualRange &&
+ dBusinessRange[0] == dBusinessRange[1];
+ QString sTitle =
+ nmPebiResultPropertyDisplayText::getDisplayName(sPropertyId);
+ const QString sUnit =
+ nmPebiResultPropertyDisplayText::getDefaultDisplayUnit(sPropertyId);
+ if(!sUnit.isEmpty()) {
+ sTitle += QString::fromLatin1(" (") + sUnit +
+ QString::fromLatin1(")");
+ }
+
+ oCandidate.m_oSettings = oSettings;
+ oCandidate.m_dBusinessRange[0] = dBusinessRange[0];
+ oCandidate.m_dBusinessRange[1] = dBusinessRange[1];
+ oCandidate.m_dVisibleRange[0] = dVisibleRange[0];
+ oCandidate.m_dVisibleRange[1] = dVisibleRange[1];
+ oCandidate.m_dInternalRange[0] = dInternalRange[0];
+ oCandidate.m_dInternalRange[1] = dInternalRange[1];
+ oCandidate.m_pLookupTable = pLookupTable;
+ oCandidate.m_sScalarBarTitle = sTitle;
+ oCandidate.m_bConstantValueLabel = bConstantValueLabel;
+ return true;
}
QString chooseInitialProperty(
@@ -167,27 +343,6 @@ QString chooseInitialProperty(
return QString();
}
-bool areSnapshotWellsValid(
- const QSharedPointer& pSnapshot)
-{
- if(pSnapshot.isNull()) {
- return false;
- }
- QSet setWellIds;
- for(int nIndex = 0; nIndex < pSnapshot->getWellCount(); ++nIndex) {
- const nmPebiResultWellSnapshot* pWell = pSnapshot->getWellAt(nIndex);
- if(pWell == nullptr || pWell->m_sWellInstanceId.isEmpty() ||
- pWell->m_sWellCode.isEmpty() ||
- !vtkMath::IsFinite(pWell->m_oLocation.x()) ||
- !vtkMath::IsFinite(pWell->m_oLocation.y()) ||
- setWellIds.contains(pWell->m_sWellInstanceId)) {
- return false;
- }
- setWellIds.insert(pWell->m_sWellInstanceId);
- }
- return true;
-}
-
bool validateAdapterOutput(
nmPebiResultSnapshotRenderAdapter* pAdapter,
vtkIdType nExpectedCellCount,
@@ -240,15 +395,17 @@ public:
m_pMeshLayer(nullptr),
m_pScalarBarLayer(nullptr),
m_pScaleGridLayer(nullptr),
+ m_pWellLayer(nullptr),
m_pAdapter(nullptr),
m_nCurrentFrameIndex(-1),
m_bHasPropertyRange(false),
m_bHasBounds(false),
m_bMeshVisible(true),
- // 5C 补齐属性名和单位标题前,避免显示语义不完整的色标。
- m_bScalarBarVisible(false),
+ m_bScalarBarVisible(true),
m_bScaleGridVisible(false),
- m_bCellEdgesVisible(false)
+ m_bCellEdgesVisible(false),
+ m_bWellMarkersVisible(true),
+ m_bWellNamesVisible(true)
{
m_dBusinessRange[0] = 0.0;
m_dBusinessRange[1] = 0.0;
@@ -257,8 +414,6 @@ public:
for(int nIndex = 0; nIndex < 6; ++nIndex) {
m_dBounds[nIndex] = 0.0;
}
- // 5A 固定保留该 ID,井位图层在 5C 才创建。
- Q_UNUSED(RESULT_WELLS_LAYER_ID);
}
nmVTKScene* getScene() const
@@ -273,10 +428,12 @@ public:
if(pScene == nullptr) {
bPointersIntact = m_pMeshLayer == nullptr &&
m_pScalarBarLayer == nullptr &&
- m_pScaleGridLayer == nullptr;
+ m_pScaleGridLayer == nullptr &&
+ m_pWellLayer == nullptr;
m_pMeshLayer = nullptr;
m_pScalarBarLayer = nullptr;
m_pScaleGridLayer = nullptr;
+ m_pWellLayer = nullptr;
return bPointersIntact;
}
@@ -302,6 +459,13 @@ public:
m_pScaleGridLayer = nullptr;
bPointersIntact = false;
}
+ if(m_pWellLayer != nullptr &&
+ pScene->getLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID)) !=
+ m_pWellLayer) {
+ m_pWellLayer = nullptr;
+ bPointersIntact = false;
+ }
return bPointersIntact;
}
@@ -315,6 +479,7 @@ public:
m_pMeshLayer != nullptr &&
m_pScalarBarLayer != nullptr &&
m_pScaleGridLayer != nullptr &&
+ m_pWellLayer != nullptr &&
pScene->getLayer(
QString::fromLatin1(RESULT_MESH_LAYER_ID)) ==
m_pMeshLayer &&
@@ -323,7 +488,10 @@ public:
m_pScalarBarLayer &&
pScene->getLayer(
QString::fromLatin1(RESULT_SCALE_GRID_LAYER_ID)) ==
- m_pScaleGridLayer;
+ m_pScaleGridLayer &&
+ pScene->getLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID)) ==
+ m_pWellLayer;
}
void discardActiveDataIfLayersLost()
@@ -341,11 +509,13 @@ public:
bool ensureBaseLayers(bool& bCreatedMesh,
bool& bCreatedScalarBar,
- bool& bCreatedScaleGrid)
+ bool& bCreatedScaleGrid,
+ bool& bCreatedWells)
{
bCreatedMesh = false;
bCreatedScalarBar = false;
bCreatedScaleGrid = false;
+ bCreatedWells = false;
const bool bPointersIntact = synchronizeLayerPointers();
nmVTKScene* pScene = getScene();
vtkRenderer* pRenderer = m_pContainer != nullptr
@@ -378,7 +548,7 @@ public:
if(pScene->getLayer(QString::fromLatin1(
RESULT_SCALAR_BAR_LAYER_ID)) != nullptr) {
rollbackCreatedLayers(
- bCreatedMesh, false, false);
+ bCreatedMesh, false, false, false);
return false;
}
nmVTKScalarBarLayer* pLayer = new nmVTKScalarBarLayer(
@@ -389,7 +559,7 @@ public:
if(!pScene->addLayer(pLayer)) {
delete pLayer;
rollbackCreatedLayers(
- bCreatedMesh, false, false);
+ bCreatedMesh, false, false, false);
return false;
}
m_pScalarBarLayer = pLayer;
@@ -400,7 +570,7 @@ public:
if(pScene->getLayer(QString::fromLatin1(
RESULT_SCALE_GRID_LAYER_ID)) != nullptr) {
rollbackCreatedLayers(
- bCreatedMesh, bCreatedScalarBar, false);
+ bCreatedMesh, bCreatedScalarBar, false, false);
return false;
}
nmVTKPlanarScaleGridLayer* pLayer =
@@ -410,24 +580,60 @@ public:
if(!pScene->addLayer(pLayer)) {
delete pLayer;
rollbackCreatedLayers(
- bCreatedMesh, bCreatedScalarBar, false);
+ bCreatedMesh, bCreatedScalarBar, false, false);
return false;
}
m_pScaleGridLayer = pLayer;
bCreatedScaleGrid = true;
}
+
+ if(m_pWellLayer == nullptr) {
+ if(pScene->getLayer(QString::fromLatin1(
+ RESULT_WELLS_LAYER_ID)) != nullptr) {
+ rollbackCreatedLayers(
+ bCreatedMesh, bCreatedScalarBar,
+ bCreatedScaleGrid, false);
+ return false;
+ }
+ nmPebiResultWellAnnotationLayer* pLayer =
+ new nmPebiResultWellAnnotationLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID));
+ pLayer->setVisible(false);
+ pLayer->setWellMarkersVisible(m_bWellMarkersVisible);
+ pLayer->setWellNamesVisible(m_bWellNamesVisible);
+ if(!pScene->addLayer(pLayer)) {
+ delete pLayer;
+ rollbackCreatedLayers(
+ bCreatedMesh, bCreatedScalarBar,
+ bCreatedScaleGrid, false);
+ return false;
+ }
+ m_pWellLayer = pLayer;
+ bCreatedWells = true;
+ }
return true;
}
void rollbackCreatedLayers(bool bCreatedMesh,
bool bCreatedScalarBar,
- bool bCreatedScaleGrid)
+ bool bCreatedScaleGrid,
+ bool bCreatedWells)
{
synchronizeLayerPointers();
nmVTKScene* pScene = getScene();
if(pScene == nullptr) {
return;
}
+ if(bCreatedWells && m_pWellLayer != nullptr &&
+ pScene->getLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID)) ==
+ m_pWellLayer) {
+ pScene->removeLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID));
+ }
+ if(bCreatedWells) {
+ m_pWellLayer = nullptr;
+ }
if(bCreatedScaleGrid && m_pScaleGridLayer != nullptr &&
pScene->getLayer(
QString::fromLatin1(RESULT_SCALE_GRID_LAYER_ID)) ==
@@ -460,10 +666,10 @@ public:
}
bool bindMeshAdapter(nmPebiResultSnapshotRenderAdapter* pAdapter,
- const double dDisplayRange[2])
+ vtkLookupTable* pLookupTable)
{
if(m_pMeshLayer == nullptr || pAdapter == nullptr ||
- dDisplayRange == nullptr) {
+ pLookupTable == nullptr) {
return false;
}
@@ -472,7 +678,30 @@ public:
pAdapter->getOutputPort(),
pAdapter->getCurrentScalarArrayName(),
nmVTKMeshLayer::ScalarAssociation_CellData,
- dDisplayRange[0], dDisplayRange[1]);
+ pLookupTable);
+ }
+
+ void applyScalarBarState(const ResultDisplayCandidate& oDisplay)
+ {
+ if(m_pScalarBarLayer == nullptr) {
+ return;
+ }
+ m_pScalarBarLayer->setLookupTable(oDisplay.m_pLookupTable);
+ m_pScalarBarLayer->setTitle(oDisplay.m_sScalarBarTitle);
+ m_pScalarBarLayer->setLabelFormat(QString::fromLatin1("%.6g"));
+ m_pScalarBarLayer->setNumberOfLabels(
+ oDisplay.m_bConstantValueLabel ? 0 : 5);
+ m_pScalarBarLayer->setConstantValueLabel(
+ oDisplay.m_bConstantValueLabel,
+ oDisplay.m_bConstantValueLabel
+ ? QString::number(oDisplay.m_dBusinessRange[0], 'g', 6)
+ : QString());
+ m_pScalarBarLayer->setBelowRangeSwatch(
+ oDisplay.m_oSettings.m_bUseBelowRangeColor,
+ controllerText("Below min"));
+ m_pScalarBarLayer->setAboveRangeSwatch(
+ oDisplay.m_oSettings.m_bUseAboveRangeColor,
+ controllerText("Above max"));
}
void applyLayerVisibility(bool bHasData)
@@ -493,6 +722,11 @@ public:
m_pScaleGridLayer->setVisible(
bHasData && m_bScaleGridVisible);
}
+ if(m_pWellLayer != nullptr) {
+ m_pWellLayer->setWellMarkersVisible(m_bWellMarkersVisible);
+ m_pWellLayer->setWellNamesVisible(m_bWellNamesVisible);
+ m_pWellLayer->setVisible(bHasData);
+ }
if(m_pContainer != nullptr) {
m_pContainer->setRotationCenterPickTarget(
bHasData && m_bMeshVisible && m_pMeshLayer != nullptr
@@ -512,13 +746,17 @@ public:
if(m_pScalarBarLayer != nullptr) {
m_pScalarBarLayer->setLookupTable(nullptr);
m_pScalarBarLayer->setTitle(QString());
+ m_pScalarBarLayer->setNumberOfLabels(5);
+ m_pScalarBarLayer->setBelowRangeSwatch(false, QString());
+ m_pScalarBarLayer->setAboveRangeSwatch(false, QString());
+ m_pScalarBarLayer->setConstantValueLabel(false, QString());
}
applyLayerVisibility(false);
return true;
}
- const bool bMeshRestored = bindMeshAdapter(
- m_pAdapter, m_dDisplayRange);
+ const bool bMeshRestored = m_pMeshLayer->getLookupTable() != nullptr &&
+ bindMeshAdapter(m_pAdapter, m_pMeshLayer->getLookupTable());
bool bGridRestored = !m_bHasBounds;
bool bBoundsRestored = !m_bHasBounds;
if(m_bHasBounds && m_pScaleGridLayer != nullptr) {
@@ -552,10 +790,18 @@ public:
m_pScalarBarLayer->setVisible(false);
m_pScalarBarLayer->setLookupTable(nullptr);
m_pScalarBarLayer->setTitle(QString());
+ m_pScalarBarLayer->setNumberOfLabels(5);
+ m_pScalarBarLayer->setBelowRangeSwatch(false, QString());
+ m_pScalarBarLayer->setAboveRangeSwatch(false, QString());
+ m_pScalarBarLayer->setConstantValueLabel(false, QString());
}
if(m_pScaleGridLayer != nullptr) {
m_pScaleGridLayer->setVisible(false);
}
+ if(m_pWellLayer != nullptr) {
+ m_pWellLayer->setVisible(false);
+ m_pWellLayer->clear();
+ }
delete m_pAdapter;
m_pAdapter = nullptr;
m_pSnapshot.clear();
@@ -564,6 +810,14 @@ public:
m_nCurrentFrameIndex = -1;
m_bHasPropertyRange = false;
m_bHasBounds = false;
+ // clear()保留窗口样式,但任何活动快照相关的手工范围都必须失效。
+ QMap::iterator oIterator =
+ m_mapDisplaySettings.begin();
+ for(; oIterator != m_mapDisplaySettings.end(); ++oIterator) {
+ oIterator.value().m_bHasManualRange = false;
+ oIterator.value().m_dManualMinimum = 0.0;
+ oIterator.value().m_dManualMaximum = 0.0;
+ }
}
void removeOwnedLayers()
@@ -575,6 +829,14 @@ public:
}
// 只删除仍与本控制器记录身份一致的图层,绝不误删同 ID 的外部替代层。
+ if(m_pWellLayer != nullptr &&
+ pScene->getLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID)) ==
+ m_pWellLayer) {
+ pScene->removeLayer(
+ QString::fromLatin1(RESULT_WELLS_LAYER_ID));
+ }
+ m_pWellLayer = nullptr;
if(m_pScaleGridLayer != nullptr &&
pScene->getLayer(
QString::fromLatin1(RESULT_SCALE_GRID_LAYER_ID)) ==
@@ -604,10 +866,13 @@ public:
nmVTKMeshLayer* m_pMeshLayer; ///< Scene 所有。
nmVTKScalarBarLayer* m_pScalarBarLayer; ///< Scene 所有。
nmVTKPlanarScaleGridLayer* m_pScaleGridLayer; ///< Scene 所有。
+ nmPebiResultWellAnnotationLayer* m_pWellLayer; ///< Scene 所有。
nmPebiResultSnapshotRenderAdapter* m_pAdapter; ///< 控制器独占。
QSharedPointer m_pSnapshot;
QStringList m_listAvailablePropertyIds;
QString m_sCurrentPropertyId;
+ /** @brief 按稳定属性 ID 保存的窗口级样式;clear 不删除。 */
+ QMap m_mapDisplaySettings;
int m_nCurrentFrameIndex;
double m_dBusinessRange[2];
double m_dDisplayRange[2];
@@ -618,6 +883,8 @@ public:
bool m_bScalarBarVisible;
bool m_bScaleGridVisible;
bool m_bCellEdgesVisible;
+ bool m_bWellMarkersVisible;
+ bool m_bWellNamesVisible;
};
nmPebiResultSceneController::nmPebiResultSceneController(
@@ -691,15 +958,74 @@ bool nmPebiResultSceneController::setSnapshot(
return false;
}
- double dBusinessRange[2];
- double dDisplayRange[2];
+ // 新快照只继承样式;所有属性的手工范围都在候选表中先清除。
+ QMap mapCandidateSettings =
+ m_pPrivate->m_mapDisplaySettings;
+ QMap::iterator oSettingsIterator =
+ mapCandidateSettings.begin();
+ for(; oSettingsIterator != mapCandidateSettings.end();
+ ++oSettingsIterator) {
+ oSettingsIterator.value().m_bHasManualRange = false;
+ oSettingsIterator.value().m_dManualMinimum = 0.0;
+ oSettingsIterator.value().m_dManualMaximum = 0.0;
+ oSettingsIterator.value() = oSettingsIterator.value().normalized();
+ }
+ const QStringList listCandidatePropertyIds =
+ pSnapshot->getAvailablePropertyIds();
+ QString sDisplayError;
+ for(int nPropertyIndex = 0;
+ nPropertyIndex < listCandidatePropertyIds.size();
+ ++nPropertyIndex) {
+ const QString& sPropertyId =
+ listCandidatePropertyIds[nPropertyIndex];
+ nmPebiResultDisplaySettings oSettings =
+ mapCandidateSettings.value(
+ sPropertyId, nmPebiResultDisplaySettings()).normalized();
+ double dPropertyRange[2] = { 0.0, 0.0 };
+ if(!pSnapshot->getPropertyRange(sPropertyId, dPropertyRange)) {
+ delete pCandidateAdapter;
+ if(pError != nullptr) {
+ *pError = controllerText(
+ "The result property range is invalid.");
+ }
+ return false;
+ }
+ if(oSettings.m_eScaleMode == NM_PebiColorScale_Logarithmic &&
+ dPropertyRange[0] <= 0.0) {
+ // 当前快照不支持原 Log 时永久降级,避免保留不可见的隐藏偏好。
+ oSettings.m_eScaleMode = NM_PebiColorScale_Linear;
+ }
+ mapCandidateSettings.insert(sPropertyId, oSettings);
+
+ // 在触碰活动 Scene 前预检每个可用属性,避免隐藏的无效偏好延迟到切换时。
+ ResultDisplayCandidate oPropertyDisplayCandidate;
+ if(!prepareDisplayCandidate(
+ pSnapshot, sPropertyId, oSettings,
+ oPropertyDisplayCandidate, &sDisplayError)) {
+ delete pCandidateAdapter;
+ if(pError != nullptr) {
+ *pError = sDisplayError;
+ }
+ return false;
+ }
+ }
+
+ ResultDisplayCandidate oDisplayCandidate;
+ if(!prepareDisplayCandidate(
+ pSnapshot, sInitialProperty,
+ mapCandidateSettings.value(sInitialProperty),
+ oDisplayCandidate, &sDisplayError)) {
+ delete pCandidateAdapter;
+ if(pError != nullptr) {
+ *pError = sDisplayError;
+ }
+ return false;
+ }
+
double dBounds[6];
if(pCandidateAdapter->getCurrentScalarArrayName().isEmpty() ||
- !getValidatedPropertyRanges(pSnapshot, sInitialProperty,
- dBusinessRange, dDisplayRange) ||
!validateAdapterOutput(pCandidateAdapter,
- pSnapshot->getResultCellCount(), dBounds) ||
- !areSnapshotWellsValid(pSnapshot)) {
+ pSnapshot->getResultCellCount(), dBounds)) {
delete pCandidateAdapter;
if(pError != nullptr) {
*pError = controllerText(
@@ -711,8 +1037,10 @@ bool nmPebiResultSceneController::setSnapshot(
bool bCreatedMesh = false;
bool bCreatedScalarBar = false;
bool bCreatedScaleGrid = false;
+ bool bCreatedWells = false;
if(!m_pPrivate->ensureBaseLayers(
- bCreatedMesh, bCreatedScalarBar, bCreatedScaleGrid)) {
+ bCreatedMesh, bCreatedScalarBar,
+ bCreatedScaleGrid, bCreatedWells)) {
delete pCandidateAdapter;
if(pError != nullptr) {
*pError = controllerText(
@@ -721,20 +1049,34 @@ bool nmPebiResultSceneController::setSnapshot(
return false;
}
+ if(!m_pPrivate->m_pWellLayer->prepareCandidate(pSnapshot)) {
+ m_pPrivate->rollbackCreatedLayers(
+ bCreatedMesh, bCreatedScalarBar,
+ bCreatedScaleGrid, bCreatedWells);
+ delete pCandidateAdapter;
+ if(pError != nullptr) {
+ *pError = controllerText(
+ "The result render data failed validation.");
+ }
+ return false;
+ }
+
bool bCommitted = m_pPrivate->m_pScaleGridLayer->setBounds(
dBounds[0], dBounds[1], dBounds[2],
dBounds[3], dBounds[4]) &&
m_pPrivate->m_pContainer->setPrimaryViewBounds(dBounds) &&
m_pPrivate->bindMeshAdapter(
- pCandidateAdapter, dDisplayRange);
+ pCandidateAdapter, oDisplayCandidate.m_pLookupTable);
if(!bCommitted) {
+ m_pPrivate->m_pWellLayer->discardCandidate();
const bool bRestored = m_pPrivate->restorePreviousScene();
if(!bRestored) {
// 不允许 Release 构建留下“逻辑有快照、实际无输入”的半恢复状态。
m_pPrivate->releaseActiveData();
}
m_pPrivate->rollbackCreatedLayers(
- bCreatedMesh, bCreatedScalarBar, bCreatedScaleGrid);
+ bCreatedMesh, bCreatedScalarBar,
+ bCreatedScaleGrid, bCreatedWells);
delete pCandidateAdapter;
if(pError != nullptr) {
*pError = controllerText(
@@ -743,23 +1085,30 @@ bool nmPebiResultSceneController::setSnapshot(
return false;
}
+ // prepareCandidate 成功后,commitCandidate 仅交换 Assembly 子项且没有失败分支。
+ m_pPrivate->m_pWellLayer->commitCandidate();
+
nmPebiResultSnapshotRenderAdapter* pPreviousAdapter =
m_pPrivate->m_pAdapter;
m_pPrivate->m_pAdapter = pCandidateAdapter;
m_pPrivate->m_pSnapshot = pSnapshot;
m_pPrivate->m_listAvailablePropertyIds =
- pSnapshot->getAvailablePropertyIds();
+ listCandidatePropertyIds;
m_pPrivate->m_sCurrentPropertyId = sInitialProperty;
+ m_pPrivate->m_mapDisplaySettings = mapCandidateSettings;
m_pPrivate->m_nCurrentFrameIndex = 0;
- m_pPrivate->m_dBusinessRange[0] = dBusinessRange[0];
- m_pPrivate->m_dBusinessRange[1] = dBusinessRange[1];
- m_pPrivate->m_dDisplayRange[0] = dDisplayRange[0];
- m_pPrivate->m_dDisplayRange[1] = dDisplayRange[1];
+ m_pPrivate->m_dBusinessRange[0] =
+ oDisplayCandidate.m_dBusinessRange[0];
+ m_pPrivate->m_dBusinessRange[1] =
+ oDisplayCandidate.m_dBusinessRange[1];
+ m_pPrivate->m_dDisplayRange[0] =
+ oDisplayCandidate.m_dVisibleRange[0];
+ m_pPrivate->m_dDisplayRange[1] =
+ oDisplayCandidate.m_dVisibleRange[1];
copyBounds(dBounds, m_pPrivate->m_dBounds);
m_pPrivate->m_bHasPropertyRange = true;
m_pPrivate->m_bHasBounds = true;
- m_pPrivate->m_pScalarBarLayer->setLookupTable(
- m_pPrivate->m_pMeshLayer->getLookupTable());
+ m_pPrivate->applyScalarBarState(oDisplayCandidate);
m_pPrivate->applyLayerVisibility(true);
// Mapper 已不再引用旧 Producer,此时才允许释放旧 Adapter。
@@ -830,25 +1179,19 @@ bool nmPebiResultSceneController::applyPropertyFrame(
return true;
}
- double dBusinessRange[2];
- double dDisplayRange[2];
- if(!getValidatedPropertyRanges(
- m_pPrivate->m_pSnapshot, sPropertyId,
- dBusinessRange, dDisplayRange)) {
- if(pError != nullptr) {
- *pError = controllerText(
- "The result property range is invalid.");
- }
+ const nmPebiResultDisplaySettings oTargetSettings =
+ m_pPrivate->m_mapDisplaySettings.value(
+ sPropertyId, nmPebiResultDisplaySettings());
+ ResultDisplayCandidate oDisplayCandidate;
+ if(!prepareDisplayCandidate(
+ m_pPrivate->m_pSnapshot, sPropertyId, oTargetSettings,
+ oDisplayCandidate, pError)) {
return false;
}
const QString sPreviousProperty =
m_pPrivate->m_sCurrentPropertyId;
const int nPreviousFrame = m_pPrivate->m_nCurrentFrameIndex;
- const double dPreviousDisplayRange[2] = {
- m_pPrivate->m_dDisplayRange[0],
- m_pPrivate->m_dDisplayRange[1]
- };
bool bApplied = m_pPrivate->m_pAdapter->setPropertyFrame(
sPropertyId, nFrameIndex);
double dCurrentBounds[6];
@@ -860,18 +1203,13 @@ bool nmPebiResultSceneController::applyPropertyFrame(
m_pPrivate->m_pMeshLayer->setScalarArray(
m_pPrivate->m_pAdapter->getCurrentScalarArrayName(),
nmVTKMeshLayer::ScalarAssociation_CellData,
- dDisplayRange[0], dDisplayRange[1]);
+ oDisplayCandidate.m_pLookupTable);
}
if(!bApplied) {
const bool bAdapterRestored =
m_pPrivate->m_pAdapter->setPropertyFrame(
sPreviousProperty, nPreviousFrame);
- const bool bMapperRestored = bAdapterRestored &&
- m_pPrivate->m_pMeshLayer->setScalarArray(
- m_pPrivate->m_pAdapter->getCurrentScalarArrayName(),
- nmVTKMeshLayer::ScalarAssociation_CellData,
- dPreviousDisplayRange[0], dPreviousDisplayRange[1]);
- if(!bMapperRestored) {
+ if(!bAdapterRestored) {
// 极端恢复失败时清空逻辑和 VTK 状态,保证查询结果与实际画面一致。
m_pPrivate->releaseActiveData();
}
@@ -884,11 +1222,87 @@ bool nmPebiResultSceneController::applyPropertyFrame(
m_pPrivate->m_sCurrentPropertyId = sPropertyId;
m_pPrivate->m_nCurrentFrameIndex = nFrameIndex;
- m_pPrivate->m_dBusinessRange[0] = dBusinessRange[0];
- m_pPrivate->m_dBusinessRange[1] = dBusinessRange[1];
- m_pPrivate->m_dDisplayRange[0] = dDisplayRange[0];
- m_pPrivate->m_dDisplayRange[1] = dDisplayRange[1];
+ m_pPrivate->m_mapDisplaySettings.insert(
+ sPropertyId, oDisplayCandidate.m_oSettings);
+ m_pPrivate->m_dBusinessRange[0] =
+ oDisplayCandidate.m_dBusinessRange[0];
+ m_pPrivate->m_dBusinessRange[1] =
+ oDisplayCandidate.m_dBusinessRange[1];
+ m_pPrivate->m_dDisplayRange[0] =
+ oDisplayCandidate.m_dVisibleRange[0];
+ m_pPrivate->m_dDisplayRange[1] =
+ oDisplayCandidate.m_dVisibleRange[1];
m_pPrivate->m_bHasPropertyRange = true;
+ m_pPrivate->applyScalarBarState(oDisplayCandidate);
+ m_pPrivate->m_pContainer->renderView();
+ return true;
+}
+
+bool nmPebiResultSceneController::applyCurrentDisplaySettings(
+ const QString& sExpectedSnapshotId,
+ const QString& sExpectedPropertyId,
+ const nmPebiResultDisplaySettings& oSettings,
+ QString* pError)
+{
+ Q_ASSERT(isResultSceneGuiThread());
+ if(pError != nullptr) {
+ pError->clear();
+ }
+ if(isResultSceneGuiThread() && m_pPrivate != nullptr) {
+ m_pPrivate->discardActiveDataIfLayersLost();
+ }
+
+ // 身份核对和实际提交处在同一个 GUI 线程调用中,旧对话框不能污染新快照。
+ if(!isResultSceneGuiThread() || !hasSnapshot() ||
+ sExpectedSnapshotId.isEmpty() ||
+ sExpectedPropertyId.isEmpty() ||
+ sExpectedSnapshotId != getCurrentSnapshotId() ||
+ sExpectedPropertyId != m_pPrivate->m_sCurrentPropertyId) {
+ if(pError != nullptr) {
+ *pError = controllerText(
+ "The color settings no longer match the current result.");
+ }
+ return false;
+ }
+
+ ResultDisplayCandidate oDisplayCandidate;
+ if(!prepareDisplayCandidate(
+ m_pPrivate->m_pSnapshot,
+ sExpectedPropertyId,
+ oSettings,
+ oDisplayCandidate,
+ pError)) {
+ return false;
+ }
+
+ const nmPebiResultDisplaySettings oCurrentSettings =
+ m_pPrivate->m_mapDisplaySettings.value(
+ sExpectedPropertyId, nmPebiResultDisplaySettings());
+ if(oDisplayCandidate.m_oSettings == oCurrentSettings.normalized()) {
+ return true;
+ }
+
+ // MeshLayer 先完整验证候选 LUT;失败时旧 Mapper 和 ScalarBar 仍共享旧 LUT。
+ if(!m_pPrivate->m_pMeshLayer->setLookupTable(
+ oDisplayCandidate.m_pLookupTable)) {
+ if(pError != nullptr) {
+ *pError = controllerText("Unable to apply the color settings.");
+ }
+ return false;
+ }
+
+ m_pPrivate->m_mapDisplaySettings.insert(
+ sExpectedPropertyId, oDisplayCandidate.m_oSettings);
+ m_pPrivate->m_dBusinessRange[0] =
+ oDisplayCandidate.m_dBusinessRange[0];
+ m_pPrivate->m_dBusinessRange[1] =
+ oDisplayCandidate.m_dBusinessRange[1];
+ m_pPrivate->m_dDisplayRange[0] =
+ oDisplayCandidate.m_dVisibleRange[0];
+ m_pPrivate->m_dDisplayRange[1] =
+ oDisplayCandidate.m_dVisibleRange[1];
+ m_pPrivate->m_bHasPropertyRange = true;
+ m_pPrivate->applyScalarBarState(oDisplayCandidate);
m_pPrivate->m_pContainer->renderView();
return true;
}
@@ -965,13 +1379,52 @@ void nmPebiResultSceneController::setCellEdgesVisible(bool bVisible)
}
}
+void nmPebiResultSceneController::setWellMarkersVisible(bool bVisible)
+{
+ Q_ASSERT(isResultSceneGuiThread());
+ if(!isResultSceneGuiThread() || m_pPrivate == nullptr) {
+ return;
+ }
+ m_pPrivate->discardActiveDataIfLayersLost();
+ if(m_pPrivate->m_bWellMarkersVisible == bVisible) {
+ return;
+ }
+ m_pPrivate->m_bWellMarkersVisible = bVisible;
+ if(m_pPrivate->m_pWellLayer != nullptr) {
+ m_pPrivate->m_pWellLayer->setWellMarkersVisible(bVisible);
+ }
+ if(hasSnapshot()) {
+ m_pPrivate->m_pContainer->renderView();
+ }
+}
+
+void nmPebiResultSceneController::setWellNamesVisible(bool bVisible)
+{
+ Q_ASSERT(isResultSceneGuiThread());
+ if(!isResultSceneGuiThread() || m_pPrivate == nullptr) {
+ return;
+ }
+ m_pPrivate->discardActiveDataIfLayersLost();
+ if(m_pPrivate->m_bWellNamesVisible == bVisible) {
+ return;
+ }
+ m_pPrivate->m_bWellNamesVisible = bVisible;
+ if(m_pPrivate->m_pWellLayer != nullptr) {
+ m_pPrivate->m_pWellLayer->setWellNamesVisible(bVisible);
+ }
+ if(hasSnapshot()) {
+ m_pPrivate->m_pContainer->renderView();
+ }
+}
+
bool nmPebiResultSceneController::hasSnapshot() const
{
return isResultSceneGuiThread() &&
m_pPrivate != nullptr &&
m_pPrivate->m_pAdapter != nullptr &&
!m_pPrivate->m_pSnapshot.isNull() &&
- m_pPrivate->hasOwnedBaseLayers();
+ m_pPrivate->hasOwnedBaseLayers() &&
+ m_pPrivate->m_pWellLayer->hasActiveAnnotations();
}
QString nmPebiResultSceneController::getCurrentSnapshotId() const
@@ -1043,6 +1496,31 @@ bool nmPebiResultSceneController::getCurrentPropertyRange(
return true;
}
+bool nmPebiResultSceneController::getCurrentDisplayRange(
+ double dRange[2]) const
+{
+ if(!hasSnapshot() || dRange == nullptr ||
+ !m_pPrivate->m_bHasPropertyRange) {
+ return false;
+ }
+ dRange[0] = m_pPrivate->m_dDisplayRange[0];
+ dRange[1] = m_pPrivate->m_dDisplayRange[1];
+ return true;
+}
+
+bool nmPebiResultSceneController::getCurrentDisplaySettings(
+ nmPebiResultDisplaySettings& oSettings) const
+{
+ if(!hasSnapshot() ||
+ !m_pPrivate->m_mapDisplaySettings.contains(
+ m_pPrivate->m_sCurrentPropertyId)) {
+ return false;
+ }
+ oSettings = m_pPrivate->m_mapDisplaySettings.value(
+ m_pPrivate->m_sCurrentPropertyId);
+ return true;
+}
+
bool nmPebiResultSceneController::isMeshVisible() const
{
return m_pPrivate != nullptr && m_pPrivate->m_bMeshVisible;
@@ -1062,3 +1540,13 @@ bool nmPebiResultSceneController::areCellEdgesVisible() const
{
return m_pPrivate != nullptr && m_pPrivate->m_bCellEdgesVisible;
}
+
+bool nmPebiResultSceneController::areWellMarkersVisible() const
+{
+ return m_pPrivate != nullptr && m_pPrivate->m_bWellMarkersVisible;
+}
+
+bool nmPebiResultSceneController::areWellNamesVisible() const
+{
+ return m_pPrivate != nullptr && m_pPrivate->m_bWellNamesVisible;
+}
diff --git a/Src/nmNum/nmSubWxs/nmPebiResultWellAnnotationLayer.cpp b/Src/nmNum/nmSubWxs/nmPebiResultWellAnnotationLayer.cpp
new file mode 100644
index 00000000..fec1d8d2
--- /dev/null
+++ b/Src/nmNum/nmSubWxs/nmPebiResultWellAnnotationLayer.cpp
@@ -0,0 +1,250 @@
+#include "nmPebiResultWellAnnotationLayer.h"
+
+#include "nmPebiResultSnapshot.h"
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace {
+
+bool isWellAnnotationGuiThread()
+{
+ QCoreApplication* pApplication = QCoreApplication::instance();
+ return pApplication == nullptr ||
+ pApplication->thread() == QThread::currentThread();
+}
+
+}
+
+nmPebiResultWellAnnotationLayer::nmPebiResultWellAnnotationLayer(
+ const QString& sLayerId)
+ : nmVTKRenderLayer(sLayerId),
+ m_pRootAssembly(vtkSmartPointer::New()),
+ m_pActiveSnapshotAssembly(nullptr),
+ m_pActiveMarkerGroup(nullptr),
+ m_pActiveNameGroup(nullptr),
+ m_pCandidateSnapshotAssembly(nullptr),
+ m_pCandidateMarkerGroup(nullptr),
+ m_pCandidateNameGroup(nullptr),
+ m_bWellMarkersVisible(true),
+ m_bWellNamesVisible(true)
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ // setRenderProp 只在未挂载时可调用,因此根 Assembly 在构造时一次固定。
+ setRenderProp(m_pRootAssembly);
+}
+
+nmPebiResultWellAnnotationLayer::~nmPebiResultWellAnnotationLayer()
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ detach();
+ clear();
+ m_pRootAssembly = nullptr;
+}
+
+bool nmPebiResultWellAnnotationLayer::prepareCandidate(
+ const QSharedPointer& pSnapshot)
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ discardCandidate();
+ if(!isWellAnnotationGuiThread() || pSnapshot.isNull() ||
+ !pSnapshot->isComplete()) {
+ return false;
+ }
+
+ vtkSmartPointer pMarkerPoints =
+ vtkSmartPointer::New();
+ vtkSmartPointer pMarkerVertices =
+ vtkSmartPointer::New();
+ vtkSmartPointer pNamePoints =
+ vtkSmartPointer::New();
+ vtkSmartPointer pWellNames =
+ vtkSmartPointer::New();
+ pWellNames->SetName("WellName");
+
+ QSet setWellIds;
+ for(int nIndex = 0; nIndex < pSnapshot->getWellCount(); ++nIndex) {
+ const nmPebiResultWellSnapshot* pWell = pSnapshot->getWellAt(nIndex);
+ if(pWell == nullptr || pWell->m_sWellInstanceId.isEmpty() ||
+ pWell->m_sWellName.isEmpty() ||
+ !vtkMath::IsFinite(pWell->m_oLocation.x()) ||
+ !vtkMath::IsFinite(pWell->m_oLocation.y()) ||
+ setWellIds.contains(pWell->m_sWellInstanceId)) {
+ discardCandidate();
+ return false;
+ }
+ setWellIds.insert(pWell->m_sWellInstanceId);
+
+ // 保持快照存储顺序;二维 Overlay 不向业务位置写入虚构 Z 值。
+ const vtkIdType nPointId = pMarkerPoints->InsertNextPoint(
+ pWell->m_oLocation.x(), pWell->m_oLocation.y(), 0.0);
+ pMarkerVertices->InsertNextCell(1);
+ pMarkerVertices->InsertCellPoint(nPointId);
+ pNamePoints->InsertNextPoint(
+ pWell->m_oLocation.x(), pWell->m_oLocation.y(), 0.0);
+ const QByteArray aWellName = pWell->m_sWellName.toUtf8();
+ pWellNames->InsertNextValue(aWellName.constData());
+ }
+
+ vtkSmartPointer pSnapshotAssembly =
+ vtkSmartPointer::New();
+ vtkSmartPointer pMarkerGroup =
+ vtkSmartPointer::New();
+ vtkSmartPointer pNameGroup =
+ vtkSmartPointer::New();
+
+ if(pSnapshot->getWellCount() > 0) {
+ vtkSmartPointer pMarkerData =
+ vtkSmartPointer::New();
+ pMarkerData->SetPoints(pMarkerPoints);
+ pMarkerData->SetVerts(pMarkerVertices);
+
+ vtkSmartPointer pWorldCoordinate =
+ vtkSmartPointer::New();
+ pWorldCoordinate->SetCoordinateSystemToWorld();
+ vtkSmartPointer pMarkerMapper =
+ vtkSmartPointer::New();
+ pMarkerMapper->SetInputData(pMarkerData);
+ pMarkerMapper->SetTransformCoordinate(pWorldCoordinate);
+ pMarkerMapper->ScalarVisibilityOff();
+
+ vtkSmartPointer pMarkerActor =
+ vtkSmartPointer::New();
+ pMarkerActor->SetMapper(pMarkerMapper);
+ pMarkerActor->GetProperty()->SetColor(0.12, 0.12, 0.12);
+ pMarkerActor->GetProperty()->SetPointSize(9.0);
+ pMarkerGroup->AddPart(pMarkerActor);
+
+ vtkSmartPointer pNameData =
+ vtkSmartPointer::New();
+ pNameData->SetPoints(pNamePoints);
+ pNameData->GetPointData()->AddArray(pWellNames);
+ vtkSmartPointer pNameMapper =
+ vtkSmartPointer::New();
+ pNameMapper->SetInputData(pNameData);
+ pNameMapper->SetLabelModeToLabelFieldData();
+ pNameMapper->SetFieldDataName("WellName");
+ pNameMapper->SetLabelFormat("%s");
+ pNameMapper->GetLabelTextProperty()->SetFontSize(12);
+ pNameMapper->GetLabelTextProperty()->SetColor(0.10, 0.10, 0.10);
+ pNameMapper->GetLabelTextProperty()->BoldOff();
+ pNameMapper->GetLabelTextProperty()->ItalicOff();
+ pNameMapper->GetLabelTextProperty()->ShadowOff();
+ pNameMapper->GetLabelTextProperty()->SetJustificationToLeft();
+ pNameMapper->GetLabelTextProperty()->SetVerticalJustificationToBottom();
+
+ vtkSmartPointer pNameActor =
+ vtkSmartPointer::New();
+ pNameActor->SetMapper(pNameMapper);
+ // Actor2D 的显示坐标偏移固定为像素,不随相机缩放改变。
+ pNameActor->SetDisplayPosition(7, 6);
+ pNameGroup->AddPart(pNameActor);
+ }
+
+ pMarkerGroup->SetVisibility(m_bWellMarkersVisible ? 1 : 0);
+ pNameGroup->SetVisibility(m_bWellNamesVisible ? 1 : 0);
+ pSnapshotAssembly->AddPart(pMarkerGroup);
+ pSnapshotAssembly->AddPart(pNameGroup);
+
+ // 所有校验和 VTK 对象构造成功后才记录候选;活动子树仍未触碰。
+ m_pCandidateSnapshotAssembly = pSnapshotAssembly;
+ m_pCandidateMarkerGroup = pMarkerGroup;
+ m_pCandidateNameGroup = pNameGroup;
+ return true;
+}
+
+void nmPebiResultWellAnnotationLayer::discardCandidate()
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ m_pCandidateNameGroup = nullptr;
+ m_pCandidateMarkerGroup = nullptr;
+ m_pCandidateSnapshotAssembly = nullptr;
+}
+
+void nmPebiResultWellAnnotationLayer::commitCandidate()
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ Q_ASSERT(m_pCandidateSnapshotAssembly != nullptr);
+
+ if(m_pActiveSnapshotAssembly != nullptr) {
+ m_pRootAssembly->RemovePart(m_pActiveSnapshotAssembly);
+ }
+ m_pActiveSnapshotAssembly = m_pCandidateSnapshotAssembly;
+ m_pActiveMarkerGroup = m_pCandidateMarkerGroup;
+ m_pActiveNameGroup = m_pCandidateNameGroup;
+ m_pRootAssembly->AddPart(m_pActiveSnapshotAssembly);
+ discardCandidate();
+}
+
+void nmPebiResultWellAnnotationLayer::clear()
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ discardCandidate();
+ if(m_pRootAssembly != nullptr &&
+ m_pActiveSnapshotAssembly != nullptr) {
+ m_pRootAssembly->RemovePart(m_pActiveSnapshotAssembly);
+ }
+ m_pActiveNameGroup = nullptr;
+ m_pActiveMarkerGroup = nullptr;
+ m_pActiveSnapshotAssembly = nullptr;
+}
+
+bool nmPebiResultWellAnnotationLayer::hasActiveAnnotations() const
+{
+ return m_pActiveSnapshotAssembly != nullptr;
+}
+
+void nmPebiResultWellAnnotationLayer::setWellMarkersVisible(bool bVisible)
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ if(!isWellAnnotationGuiThread()) {
+ return;
+ }
+ m_bWellMarkersVisible = bVisible;
+ if(m_pActiveMarkerGroup != nullptr) {
+ m_pActiveMarkerGroup->SetVisibility(bVisible ? 1 : 0);
+ }
+ if(m_pCandidateMarkerGroup != nullptr) {
+ m_pCandidateMarkerGroup->SetVisibility(bVisible ? 1 : 0);
+ }
+}
+
+void nmPebiResultWellAnnotationLayer::setWellNamesVisible(bool bVisible)
+{
+ Q_ASSERT(isWellAnnotationGuiThread());
+ if(!isWellAnnotationGuiThread()) {
+ return;
+ }
+ m_bWellNamesVisible = bVisible;
+ if(m_pActiveNameGroup != nullptr) {
+ m_pActiveNameGroup->SetVisibility(bVisible ? 1 : 0);
+ }
+ if(m_pCandidateNameGroup != nullptr) {
+ m_pCandidateNameGroup->SetVisibility(bVisible ? 1 : 0);
+ }
+}
+
+bool nmPebiResultWellAnnotationLayer::areWellMarkersVisible() const
+{
+ return m_bWellMarkersVisible;
+}
+
+bool nmPebiResultWellAnnotationLayer::areWellNamesVisible() const
+{
+ return m_bWellNamesVisible;
+}
diff --git a/Src/nmNum/nmSubWxs/nmWxPebiResultColorScaleSettingsDlg.cpp b/Src/nmNum/nmSubWxs/nmWxPebiResultColorScaleSettingsDlg.cpp
new file mode 100644
index 00000000..c881d570
--- /dev/null
+++ b/Src/nmNum/nmSubWxs/nmWxPebiResultColorScaleSettingsDlg.cpp
@@ -0,0 +1,484 @@
+#include "nmWxPebiResultColorScaleSettingsDlg.h"
+
+#include "nmPebiResultPropertyDisplayText.h"
+#include "nmPebiResultSceneController.h"
+#include "nmVTKColorMapCatalog.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#if !defined(_MSC_VER)
+#include
+#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());
+}
diff --git a/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp b/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp
index cc4a0332..1eefd9cc 100644
--- a/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp
+++ b/Src/nmNum/nmSubWxs/nmWxPebiResultControlBar.cpp
@@ -4,6 +4,8 @@
#include "nmPebiResultPropertyDisplayText.h"
#include "nmPebiResultSceneController.h"
#include "nmWxPebiResultAnimationSettingsDlg.h"
+#include "nmWxPebiResultColorScaleSettingsDlg.h"
+#include "nmVTKColorMapCatalog.h"
#include
#include
@@ -43,7 +45,9 @@ nmWxPebiResultControlBar::nmWxPebiResultControlBar(
QWidget* pParent)
: QWidget(pParent),
m_pPlaybackController(nullptr),
+ m_pSceneController(pSceneController),
m_pPropertyCombo(nullptr),
+ m_pColorSettingsButton(nullptr),
m_pFirstButton(nullptr),
m_pPreviousButton(nullptr),
m_pTimeCombo(nullptr),
@@ -111,6 +115,25 @@ void nmWxPebiResultControlBar::onTimeIndexChanged(int nIndex)
m_pTimeCombo->itemData(nIndex).toInt());
}
+void nmWxPebiResultControlBar::onColorSettingsClicked()
+{
+ if(m_pPlaybackController == nullptr || m_pSceneController == nullptr ||
+ !m_pSceneController->hasSnapshot()) {
+ return;
+ }
+
+ // 打开任何结果设置都属于手动操作;关闭后不自动恢复播放。
+ m_pPlaybackController->pause();
+ nmWxPebiResultColorScaleSettingsDlg oDialog(
+ m_pSceneController, this);
+ connect(&oDialog, SIGNAL(displaySettingsApplied()),
+ this, SLOT(refreshColorPreview()));
+ connect(&oDialog, SIGNAL(operationFailed(QString)),
+ this, SLOT(forwardOperationFailure(QString)));
+ oDialog.exec();
+ refreshColorPreview();
+}
+
void nmWxPebiResultControlBar::onFirstFrameClicked()
{
m_pPlaybackController->selectFirstFrame();
@@ -163,6 +186,8 @@ void nmWxPebiResultControlBar::refreshFromController()
m_sDisplayedSnapshotId.clear();
m_listDisplayedPropertyIds.clear();
m_pPropertyCombo->setEnabled(false);
+ m_pColorSettingsButton->setEnabled(false);
+ m_pColorSettingsButton->setIcon(QIcon());
m_pFirstButton->setEnabled(false);
m_pPreviousButton->setEnabled(false);
m_pNextButton->setEnabled(false);
@@ -202,6 +227,8 @@ void nmWxPebiResultControlBar::refreshFromController()
m_pPropertyCombo->setCurrentIndex(nPropertyIndex);
m_pPropertyCombo->blockSignals(bPropertyBlocked);
m_pPropertyCombo->setEnabled(true);
+ m_pColorSettingsButton->setEnabled(true);
+ refreshColorPreview();
const bool bTimeDependent =
m_pPlaybackController->isPropertyTimeDependent(sPropertyId);
@@ -255,6 +282,19 @@ void nmWxPebiResultControlBar::forwardOperationFailure(
emit operationFailed(sError);
}
+void nmWxPebiResultControlBar::refreshColorPreview()
+{
+ nmPebiResultDisplaySettings oSettings;
+ if(m_pSceneController == nullptr ||
+ !m_pSceneController->getCurrentDisplaySettings(oSettings)) {
+ m_pColorSettingsButton->setIcon(QIcon());
+ return;
+ }
+ m_pColorSettingsButton->setIcon(QIcon(
+ nmVTKColorMapCatalog::createPreviewPixmap(
+ oSettings.m_sColorMapId, QSize(44, 14))));
+}
+
void nmWxPebiResultControlBar::createUi()
{
QHBoxLayout* pLayout = new QHBoxLayout(this);
@@ -268,6 +308,11 @@ void nmWxPebiResultControlBar::createUi()
QSizePolicy::Preferred, QSizePolicy::Fixed);
m_pPropertyCombo->setToolTip(tr("Display property"));
+ m_pColorSettingsButton = createControlButton(
+ this, QString(), tr("Color settings"));
+ m_pColorSettingsButton->setFixedSize(52, 24);
+ m_pColorSettingsButton->setIconSize(QSize(44, 14));
+
m_pFirstButton = createControlButton(
this, QString::fromLatin1("First.png"), tr("First frame"));
m_pPreviousButton = createControlButton(
@@ -289,6 +334,7 @@ void nmWxPebiResultControlBar::createUi()
tr("Animation settings"));
pLayout->addWidget(m_pPropertyCombo);
+ pLayout->addWidget(m_pColorSettingsButton);
pLayout->addWidget(m_pFirstButton);
pLayout->addWidget(m_pPreviousButton);
pLayout->addWidget(m_pTimeCombo, 1);
@@ -299,6 +345,8 @@ void nmWxPebiResultControlBar::createUi()
connect(m_pPropertyCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onPropertyIndexChanged(int)));
+ connect(m_pColorSettingsButton, SIGNAL(clicked()),
+ this, SLOT(onColorSettingsClicked()));
connect(m_pTimeCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onTimeIndexChanged(int)));
connect(m_pFirstButton, SIGNAL(clicked()),
diff --git a/Src4/nmNum/nmRender/nmRender.pro b/Src4/nmNum/nmRender/nmRender.pro
index 3b53f9e6..1a690f0b 100644
--- a/Src4/nmNum/nmRender/nmRender.pro
+++ b/Src4/nmNum/nmRender/nmRender.pro
@@ -16,6 +16,7 @@ include(../../vtk.pri)
INCLUDEPATH += $${wtInclude}/nmNum/nmRender
SOURCES += $${wtSrc}/nmNum/nmRender/nmVTKCameraController.cpp \
+ $${wtSrc}/nmNum/nmRender/nmVTKColorMapCatalog.cpp \
$${wtSrc}/nmNum/nmRender/nmVTKBoundsGridLayer.cpp \
$${wtSrc}/nmNum/nmRender/nmVTKImageExporter.cpp \
$${wtSrc}/nmNum/nmRender/nmVTKInteractionManager.cpp \
@@ -33,6 +34,7 @@ SOURCES += $${wtSrc}/nmNum/nmRender/nmVTKCameraController.cpp \
HEADERS += $${wtInclude}/nmNum/nmRender/nmRender_global.h \
$${wtInclude}/nmNum/nmRender/nmVTKCameraController.h \
+ $${wtInclude}/nmNum/nmRender/nmVTKColorMapCatalog.h \
$${wtInclude}/nmNum/nmRender/nmVTKBoundsGridLayer.h \
$${wtInclude}/nmNum/nmRender/nmVTKImageExporter.h \
$${wtInclude}/nmNum/nmRender/nmVTKInteractionManager.h \