|
|
|
|
|
#ifndef NMWXPOSTPROCESSINGANIMATIONWIDGET_H
|
|
|
|
|
|
#define NMWXPOSTPROCESSINGANIMATIONWIDGET_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "nmSubWxs_global.h"
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
#include <QList>
|
|
|
|
|
|
#include <QMap>
|
|
|
|
|
|
|
|
|
|
|
|
class QVBoxLayout;
|
|
|
|
|
|
class QHBoxLayout;
|
|
|
|
|
|
class QFrame;
|
|
|
|
|
|
class QVTKWidget;
|
|
|
|
|
|
class QTimer;
|
|
|
|
|
|
class QLabel;
|
|
|
|
|
|
class QSlider;
|
|
|
|
|
|
class QPushButton;
|
|
|
|
|
|
class QComboBox;
|
|
|
|
|
|
class QEvent;
|
|
|
|
|
|
class QMouseEvent;
|
|
|
|
|
|
class QImage;
|
|
|
|
|
|
class QPrinter;
|
|
|
|
|
|
|
|
|
|
|
|
class nmDataAnalyzeManager;
|
|
|
|
|
|
|
|
|
|
|
|
#include <vtkSmartPointer.h> // 必须包含这个头文件来使用 vtkSmartPointer
|
|
|
|
|
|
|
|
|
|
|
|
// VTK 对象的实际类型声明
|
|
|
|
|
|
class vtkRenderWindow;
|
|
|
|
|
|
class vtkRenderer;
|
|
|
|
|
|
class vtkDataSetMapper;
|
|
|
|
|
|
class vtkActor;
|
|
|
|
|
|
class vtkScalarBarActor;
|
|
|
|
|
|
class vtkLookupTable;
|
|
|
|
|
|
class vtkTextActor;
|
|
|
|
|
|
class vtkUnstructuredGrid;
|
|
|
|
|
|
class vtkImageData;
|
|
|
|
|
|
class vtkUnsignedCharArray;
|
|
|
|
|
|
|
|
|
|
|
|
class vtkTextActor3D; // 用于 3D 文本,可透视变化
|
|
|
|
|
|
class vtkBillboardTextActor3D; // 更好的 3D 文本选项,始终面向相机,保持可读性
|
|
|
|
|
|
class vtkPoints; // 用于存储点的坐标
|
|
|
|
|
|
class vtkPolyData; // 用于存储几何数据 (例如井线)
|
|
|
|
|
|
class vtkPolyDataMapper; // 用于将几何数据映射到图形
|
|
|
|
|
|
class vtkCellArray; // 用于定义线段(将点连接成线)
|
|
|
|
|
|
class vtkThreshold; // 过滤器
|
|
|
|
|
|
|
|
|
|
|
|
class vtkContourWidget; // 绘制多边形轮廓
|
|
|
|
|
|
class vtkObject;
|
|
|
|
|
|
class vtkInteractorStyleTrackballCamera;
|
|
|
|
|
|
class vtkPolygonalSurfacePointPlacer;
|
|
|
|
|
|
class vtkOrientedGlyphContourRepresentation;
|
|
|
|
|
|
class vtkRenderWindowInteractor;
|
|
|
|
|
|
class vtkSelectPolyData;
|
|
|
|
|
|
|
|
|
|
|
|
class nmWxPostprocessingAnimationWidget;
|
|
|
|
|
|
|
|
|
|
|
|
#include <vtkInteractorStyleTrackballCamera.h>
|
|
|
|
|
|
// 自定义交互器
|
|
|
|
|
|
class nmCustomInteractorStyle : public vtkInteractorStyleTrackballCamera
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
static nmCustomInteractorStyle* New();
|
|
|
|
|
|
vtkTypeMacro(nmCustomInteractorStyle, vtkInteractorStyleTrackballCamera);
|
|
|
|
|
|
|
|
|
|
|
|
void SetParent(nmWxPostprocessingAnimationWidget* parent);
|
|
|
|
|
|
|
|
|
|
|
|
virtual void OnLeftButtonDown() override;
|
|
|
|
|
|
//virtual void OnMouseMove() override; // 处理鼠标移动(拖动逻辑)
|
|
|
|
|
|
//virtual void OnLeftButtonUp() override; // 处理鼠标释放(结束拖动)
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
nmWxPostprocessingAnimationWidget* m_parent;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
|
|
// 区域平均压力显示对话框
|
|
|
|
|
|
class nmContourResultDialog : public QDialog
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit nmContourResultDialog(QWidget *parent = nullptr);
|
|
|
|
|
|
// 结果数据展示
|
|
|
|
|
|
void showResult(const QString& message);
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void clearContourRequested();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
QLabel* m_resultLabel;
|
|
|
|
|
|
QPushButton* m_clearButton;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class NM_SUB_WXS_EXPORT nmWxPostprocessingAnimationWidget : public QWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
nmWxPostprocessingAnimationWidget(QWidget* parent = nullptr);
|
|
|
|
|
|
// 析构函数,用于清理资源,尽管 vtkSmartPointer 会自动管理大部分 VTK 对象的内存
|
|
|
|
|
|
~nmWxPostprocessingAnimationWidget();
|
|
|
|
|
|
|
|
|
|
|
|
// 将 VTK 图像数据(vtkImageData)转换为 Qt 的 QImage 对象
|
|
|
|
|
|
QImage createQImage(vtkImageData* imageData);
|
|
|
|
|
|
// 处理单通道图像,灰度图像
|
|
|
|
|
|
QImage createQImage1(int nWidth, int nHeight, vtkUnsignedCharArray* pScalars);
|
|
|
|
|
|
// 处理双通道图像,灰度图像带有 Alpha 透明度
|
|
|
|
|
|
QImage createQImage2(int nWidth, int nHeight, vtkUnsignedCharArray* pScalars);
|
|
|
|
|
|
// 处理三通道图像,RGB 彩色图像
|
|
|
|
|
|
QImage createQImage3(int nWidth, int nHeight, vtkUnsignedCharArray* pScalars);
|
|
|
|
|
|
// 处理四通道图像,RGBA 彩色图像
|
|
|
|
|
|
QImage createQImage4(int nWidth, int nHeight, vtkUnsignedCharArray* pScalars);
|
|
|
|
|
|
|
|
|
|
|
|
// 添加公共访问函数,供自定义交互样式调用
|
|
|
|
|
|
bool isDrawingMode() const;
|
|
|
|
|
|
vtkRenderer* getRenderer() const;
|
|
|
|
|
|
QVTKWidget* getVtkWidget() const;
|
|
|
|
|
|
void addContourPoint(double pos[3]);
|
|
|
|
|
|
|
|
|
|
|
|
vtkContourWidget* getContourWidget() const;
|
|
|
|
|
|
|
|
|
|
|
|
// 创建并配置vtkContourWidget类
|
|
|
|
|
|
void createContourWidget();
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// 事件过滤器,用于捕获来自 m_pVtkWidget 的鼠标事件
|
|
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void initUI();
|
|
|
|
|
|
void initLayout();
|
|
|
|
|
|
void initVTKWidget();
|
|
|
|
|
|
void initOperPannel();
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化井的绘制相关 VTK 对象(井名和井线)
|
|
|
|
|
|
void initWellDrawing();
|
|
|
|
|
|
// 清除所有井相关的绘制 Actor
|
|
|
|
|
|
void clearWellActors();
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化时间步列表,从nmDataAnalyzeManager获取
|
|
|
|
|
|
void initTimeSteps();
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染指定索引时间步的数据
|
|
|
|
|
|
void loadDataForIndex(int index);
|
|
|
|
|
|
|
|
|
|
|
|
// 将VTK渲染内容转换为QImage
|
|
|
|
|
|
QImage getVTKRenderWindowAsImage();
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
// 点击开始播放按钮 (此函数名可能导致混淆,因为它实际上是定时器触发的播放逻辑)
|
|
|
|
|
|
void on_play();
|
|
|
|
|
|
// 启动自动播放 (对应 "start" 按钮)
|
|
|
|
|
|
void on_start();
|
|
|
|
|
|
// 点击停止播放 (对应 "stop" 按钮)
|
|
|
|
|
|
void on_stop();
|
|
|
|
|
|
// 修改当前index (根据你的注释,这个槽函数似乎未被使用,可以考虑删除)
|
|
|
|
|
|
void on_currentIndexChanged();
|
|
|
|
|
|
// 监听模式变化 (例如面模式、面+线模式)
|
|
|
|
|
|
void on_modeChanged(int);
|
|
|
|
|
|
// 监听进度变化 (滑块值改变时触发)
|
|
|
|
|
|
void on_updateProgress(int);
|
|
|
|
|
|
// 监听滑块被拖动(按下鼠标时)
|
|
|
|
|
|
void on_sliderPressed();
|
|
|
|
|
|
|
|
|
|
|
|
// 图片和打印操作的槽函数,
|
|
|
|
|
|
void saveWidgetAsImage(); // 将 m_pVtkWidget 的内容保存为图片文件。
|
|
|
|
|
|
void copyWidgetImage(); // 将 m_pVtkWidget 的内容复制到剪贴板。
|
|
|
|
|
|
void printWidget(); // 打印 m_pVtkWidget 的内容。
|
|
|
|
|
|
void printPreviewWidget(); // 显示 m_pVtkWidget 内容的打印预览。
|
|
|
|
|
|
// 辅助槽函数,负责将部件内容渲染到 QPrinter 以进行打印/预览。
|
|
|
|
|
|
void renderWidgetForPrint(QPrinter *printer);
|
|
|
|
|
|
// 导出动画为视频的槽函数
|
|
|
|
|
|
void exportAnimationAsVideo();
|
|
|
|
|
|
|
|
|
|
|
|
// 数据过滤对话框
|
|
|
|
|
|
void slotShowDataFilterDialog();
|
|
|
|
|
|
// 用于处理和应用过滤设置的槽函数
|
|
|
|
|
|
void slotApplyFilter(bool bEnableFiltering,
|
|
|
|
|
|
bool bEnableAboveMin, double minVal,
|
|
|
|
|
|
bool bEnableBelowMax, double maxVal);
|
|
|
|
|
|
|
|
|
|
|
|
// 开始绘制区域模式
|
|
|
|
|
|
void slotStartDrawPolygon();
|
|
|
|
|
|
// 绘制完成时触发的回调函数
|
|
|
|
|
|
void slotContourFinished();
|
|
|
|
|
|
// 清理轮廓
|
|
|
|
|
|
void slotClearContour();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
// 布局
|
|
|
|
|
|
QVBoxLayout* m_pMainLayout;
|
|
|
|
|
|
QVBoxLayout* m_pFrameLaoyt;
|
|
|
|
|
|
|
|
|
|
|
|
// VTK 渲染控件
|
|
|
|
|
|
QVTKWidget* m_pVtkWidget;
|
|
|
|
|
|
|
|
|
|
|
|
// 存储有序的时间步键
|
|
|
|
|
|
QVector<double> m_vecTimeStepKeys;
|
|
|
|
|
|
|
|
|
|
|
|
int m_nCurrentIndex; // 当前加载的文件索引
|
|
|
|
|
|
bool m_bIsPlaying; // 正在播放中
|
|
|
|
|
|
|
|
|
|
|
|
// 定时器
|
|
|
|
|
|
QTimer* m_pPlayTimer;
|
|
|
|
|
|
|
|
|
|
|
|
// UI 控件
|
|
|
|
|
|
QLabel* m_pProgress; // 显示进度文本
|
|
|
|
|
|
QSlider* m_pSlider; // 进度条滑块
|
|
|
|
|
|
|
|
|
|
|
|
// 显示模式:0:面,1:面+网格
|
|
|
|
|
|
int m_nShowMode;
|
|
|
|
|
|
|
|
|
|
|
|
// 每个 nmWxPostprocessingAnimationWidget 实例将拥有自己独立的 VTK 管道
|
|
|
|
|
|
vtkSmartPointer<vtkRenderer> m_renderer; // VTK 渲染器
|
|
|
|
|
|
vtkSmartPointer<vtkDataSetMapper> m_mapper; // VTK 数据映射器 (将数据映射到几何体)
|
|
|
|
|
|
vtkSmartPointer<vtkActor> m_actor; // VTK 演员 (代表场景中的一个对象)
|
|
|
|
|
|
vtkSmartPointer<vtkScalarBarActor> m_scalarBar; // VTK 颜色条 (显示标量数据的范围和颜色映射)
|
|
|
|
|
|
vtkSmartPointer<vtkLookupTable> m_lookupTable; // VTK 颜色查找表 (定义颜色映射规则)
|
|
|
|
|
|
vtkSmartPointer<vtkTextActor> m_textActor; // VTK 文本演员 (用于显示时间步信息)
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染的基础网格
|
|
|
|
|
|
vtkSmartPointer<vtkUnstructuredGrid> m_pCachedBaseGrid;
|
|
|
|
|
|
|
|
|
|
|
|
// === 新增:用于绘制井的 VTK 对象 (全部使用 vtkActor 指针,因为 vtkTextActor3D/vtkBillboardTextActor3D 都继承自 vtkActor) ===
|
|
|
|
|
|
QMap<QString, vtkSmartPointer<vtkBillboardTextActor3D>> m_mapWellNameActors; // 存储井名称的 vtkBillboardTextActor3D 文本 Actor
|
|
|
|
|
|
QMap<QString, vtkSmartPointer<vtkActor>> m_mapWellLineActors; // 存储井线的 3D Actor
|
|
|
|
|
|
|
|
|
|
|
|
// 阈值过滤器
|
|
|
|
|
|
vtkSmartPointer<vtkThreshold> m_thresholdFilter;
|
|
|
|
|
|
// 用于记录当前过滤状态的成员变量
|
|
|
|
|
|
bool m_bFilteringEnabled;
|
|
|
|
|
|
bool m_bAboveMinEnabled;
|
|
|
|
|
|
double m_dMinValue;
|
|
|
|
|
|
bool m_bBelowMaxEnabled;
|
|
|
|
|
|
double m_dMaxValue;
|
|
|
|
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkContourWidget> m_contourWidget; // 用于用户交互绘制轮廓
|
|
|
|
|
|
vtkSmartPointer<vtkOrientedGlyphContourRepresentation> m_contourRepresentation;
|
|
|
|
|
|
vtkSmartPointer<vtkPolygonalSurfacePointPlacer> m_pointPlacer;
|
|
|
|
|
|
vtkSmartPointer<vtkPolyData> m_polyDataForContour;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_bIsDrawingMode; // 标记是否处于绘制模式
|
|
|
|
|
|
|
|
|
|
|
|
// 交互器
|
|
|
|
|
|
// vtkSmartPointer<nmCustomInteractorStyle> m_trackballStyle;
|
|
|
|
|
|
vtkSmartPointer<vtkInteractorStyleTrackballCamera> m_trackballStyle;
|
|
|
|
|
|
vtkSmartPointer<nmCustomInteractorStyle> m_drawStyle;
|
|
|
|
|
|
|
|
|
|
|
|
// 交互容器
|
|
|
|
|
|
vtkSmartPointer<vtkRenderWindowInteractor> m_interactor;
|
|
|
|
|
|
|
|
|
|
|
|
nmContourResultDialog* m_resultDialog; // 对话框成员变量
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NMWXPOSTPROCESSINGANIMATIONWIDGET_H
|