You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/nmNum/nmSubWxs/nmVolumeSliceInteraction.h

63 lines
3.4 KiB
C

#ifndef NMVOLUMESLICEINTERACTION_H
#define NMVOLUMESLICEINTERACTION_H
#include "nmSubWxs_global.h"
#include "nmVolumeSliceSettings.h"
#include <QObject>
#include <vtkSmartPointer.h>
class nmWxVTKRenderContainerWidget;
class vtkObject;
class vtkCallbackCommand;
class vtkImplicitPlaneWidget2;
class vtkImplicitPlaneRepresentation;
/** @brief 管理预览平面及 VTK/Qt 事件边界;不持有 Cutter,任何预览均不能触发切片计算。 */
class NM_SUB_WXS_EXPORT nmVolumeSliceInteraction : public QObject
{
Q_OBJECT
public:
/** @brief 绑定生命周期更长的渲染容器;构造时不显示 Widget。 */
explicit nmVolumeSliceInteraction(nmWxVTKRenderContainerWidget* pContainer, QObject* pParent = nullptr);
/** @brief 先禁用 Widget、解除观察者,再释放 VTK 引用。 */
virtual ~nmVolumeSliceInteraction();
/** @brief 为当前数据身份放置预览平面;同一数据的输入更新使用 setPreview。 */
void bind(const QString& sDataId, const double dBounds[6], const nmVolumeSliceSettings& oSettings);
/** @brief 解除数据及 Interactor,并使尚未处理的拖动事件失效。 */
void unbind();
/** @brief 更新有效草稿的位置及方向,非法参数不改变预览。 */
void setPreview(const nmVolumeSliceSettings& oSettings);
/** @brief 控制辅助平面及事件处理;关闭时丢弃排队事件,保持绑定参数。 */
void setEnabled(bool bEnabled);
/** @brief 返回辅助平面的实际启用状态,供测试与界面核对。 */
bool isEnabled() const;
signals:
/** @brief 队列合并后的拖动预览,仅同步参数,不应计算截面。 */
void previewChanged(const QString& sDataId, const nmVolumeSliceSettings& oSettings);
/** @brief 松手后发出一次应用请求;接收者还需核对当前数据身份和模式。 */
void applyRequested(const QString& sDataId, const nmVolumeSliceSettings& oSettings);
private slots:
/** @brief 离开 VTK 回调栈后交付最后一次预览及可选应用请求。 */
void deliverPendingEvent();
private:
Q_DISABLE_COPY(nmVolumeSliceInteraction)
/** @brief VTK 回调只复制数据、安排 Qt 队列,不执行界面槽或切片计算。 */
static void onPlaneEvent(vtkObject* pCaller, unsigned long nEvent, void* pClientData, void* pCallData);
nmWxVTKRenderContainerWidget* m_pContainer; ///< 非所有权,必须在此对象之后销毁。
vtkSmartPointer<vtkImplicitPlaneRepresentation> m_pRepresentation; ///< 独立的预览几何,不与计算平面共享。
vtkSmartPointer<vtkImplicitPlaneWidget2> m_pWidget; ///< 本窗口独占的 VTK 交互 Widget。
vtkSmartPointer<vtkCallbackCommand> m_pCallback; ///< ClientData 指向本对象,析构前解除。
QString m_sDataId; ///< 当前模型身份,防止旧模型拖动事件修改新模型。
nmVolumeSliceSettings m_oPreview; ///< 最近一次有效草稿及显示选项。
nmVolumeSliceSettings m_oPending; ///< 回调复制的最新平面参数。
unsigned int m_nGeneration; ///< 绑定或关闭交互时递增,隔离同一模型的过期事件。
unsigned int m_nPendingGeneration; ///< 排队事件所属交互代次。
bool m_bQueued; ///< 是否已有待执行 Qt 队列槽,避免每次 MouseMove 排队。
bool m_bPendingApply; ///< 最新事件序列是否包含松手应用。
};
#endif // NMVOLUMESLICEINTERACTION_H