|
|
#ifndef NMVTKINTERACTIONMANAGER_H
|
|
|
#define NMVTKINTERACTIONMANAGER_H
|
|
|
|
|
|
#include "nmRender_global.h"
|
|
|
|
|
|
#include <vtkSmartPointer.h>
|
|
|
|
|
|
class nmVTKCameraController;
|
|
|
class nmVTKPivotCameraInteractorStyle;
|
|
|
|
|
|
class vtkInteractorStyleTrackballCamera;
|
|
|
class vtkInteractorStyle;
|
|
|
class vtkRenderer;
|
|
|
class vtkRenderWindowInteractor;
|
|
|
|
|
|
/**
|
|
|
* @brief 管理一个 Interactor 的默认 TrackballCamera 交互样式。
|
|
|
*
|
|
|
* 本阶段只定义单一活动交互模式的绑定和解除边界,不包含拾取或轮廓工具。
|
|
|
*/
|
|
|
class NM_RENDER_EXPORT nmVTKInteractionManager
|
|
|
{
|
|
|
public:
|
|
|
/** @brief 创建当前实例独占的默认枢轴 TrackballCamera 样式。 */
|
|
|
explicit nmVTKInteractionManager(
|
|
|
nmVTKCameraController* pCameraController = nullptr);
|
|
|
/** @brief 先解除 InteractorStyle,再释放默认样式。 */
|
|
|
~nmVTKInteractionManager();
|
|
|
|
|
|
/** @brief 绑定非所有权 Interactor 和主 Renderer,并立即安装默认样式。 */
|
|
|
bool bindInteractor(vtkRenderWindowInteractor* pInteractor,
|
|
|
vtkRenderer* pRenderer = nullptr);
|
|
|
/**
|
|
|
* @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 返回当前活动样式的非所有权指针;未安装时返回 nullptr。 */
|
|
|
vtkInteractorStyle* getActiveStyle() const;
|
|
|
/** @brief 缓存状态和 Interactor 实际状态都指向默认样式时返回 true。 */
|
|
|
bool isDefaultInteractionActive() const;
|
|
|
|
|
|
private:
|
|
|
Q_DISABLE_COPY(nmVTKInteractionManager)
|
|
|
|
|
|
vtkRenderWindowInteractor* m_pInteractor; ///< 非所有权指针。
|
|
|
vtkSmartPointer<nmVTKPivotCameraInteractorStyle> m_pDefaultStyle; ///< 当前实例独占。
|
|
|
vtkSmartPointer<vtkInteractorStyle> m_pActiveStyle; ///< 保持当前活动样式的 VTK 引用。
|
|
|
};
|
|
|
|
|
|
#endif // NMVTKINTERACTIONMANAGER_H
|