#ifndef NMVTKINTERACTIONMANAGER_H #define NMVTKINTERACTIONMANAGER_H #include "nmRender_global.h" #include class vtkInteractorStyleTrackballCamera; class vtkInteractorStyle; class vtkRenderWindowInteractor; /** * @brief 管理一个 Interactor 的默认 TrackballCamera 交互样式。 * * 本阶段只定义单一活动交互模式的绑定和解除边界,不包含拾取或轮廓工具。 */ class NM_RENDER_EXPORT nmVTKInteractionManager { public: /** @brief 创建当前实例独占的默认 TrackballCamera 样式。 */ nmVTKInteractionManager(); /** @brief 先解除 InteractorStyle,再释放默认样式。 */ ~nmVTKInteractionManager(); /** @brief 绑定非所有权 Interactor,并立即安装默认样式。 */ bool bindInteractor(vtkRenderWindowInteractor* pInteractor); /** * @brief 安装并持有一个活动交互样式;传入对象通过 VTK 引用计数共享。 * @return Interactor 和样式均有效时返回 true。 */ bool installInteractionStyle(vtkInteractorStyle* pStyle); /** @brief 将当前 Interactor 恢复为默认 TrackballCamera 样式。 */ bool restoreDefaultInteraction(); /** @brief 清除活动 InteractorStyle,但保留 Interactor 绑定。 */ void clearInteractionStyle(); /** @brief 清除当前 InteractorStyle 并解除 Interactor。 */ void unbindInteractor(); /** @brief 返回当前绑定的 Interactor 非所有权指针。 */ vtkRenderWindowInteractor* getInteractor() const; /** @brief 返回管理器持有的默认样式非所有权指针。 */ vtkInteractorStyleTrackballCamera* getDefaultStyle() const; /** @brief 返回当前活动样式的非所有权指针;未安装时返回 NULL。 */ vtkInteractorStyle* getActiveStyle() const; private: Q_DISABLE_COPY(nmVTKInteractionManager) vtkRenderWindowInteractor* m_pInteractor; ///< 非所有权指针。 vtkSmartPointer m_pDefaultStyle; ///< 当前实例独占。 vtkSmartPointer m_pActiveStyle; ///< 保持当前活动样式的 VTK 引用。 }; #endif // NMVTKINTERACTIONMANAGER_H