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/nmRender/nmVTKScene.h

52 lines
1.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef NMVTKSCENE_H
#define NMVTKSCENE_H
#include "nmRender_global.h"
#include <QMap>
#include <QString>
class nmVTKRenderLayer;
class vtkRenderer;
/**
* @brief 管理一个 Renderer 中的通用图层集合。
*
* addLayer 成功后 Scene 接管图层所有权;失败时所有权仍归调用方。
* Scene 的增删操作不自动渲染,由容器在批量修改完成后统一 renderView。
*/
class NM_RENDER_EXPORT nmVTKScene
{
public:
/** @param pRenderer 非所有权指针,必须比 Scene 生命周期更长。 */
explicit nmVTKScene(vtkRenderer* pRenderer);
/** @brief 先清空 Layer 和 Prop再结束 Scene 生命周期。 */
~nmVTKScene();
/**
* @brief 挂载并登记图层。
* @return 图层未被其他 Scene 接管且挂载成功时返回 true。成功后 Scene
* 接管 pLayer失败时调用方仍负责删除 pLayer。
*/
bool addLayer(nmVTKRenderLayer* pLayer);
/** @brief 按稳定 ID 查询图层,返回值为 Scene 所有的非所有权指针。 */
nmVTKRenderLayer* getLayer(const QString& sLayerId) const;
/** @brief 先从 Renderer 移除 Prop再删除指定图层。 */
bool removeLayer(const QString& sLayerId);
/** @brief 清空全部图层;不主动触发 Render。 */
void clear();
/** @brief 返回 Scene 当前拥有的图层数量。 */
int getLayerCount() const;
private:
Q_DISABLE_COPY(nmVTKScene)
/** @brief 析构和公开 clear 共用的实际清理入口。 */
void clearLayers();
vtkRenderer* m_pRenderer; ///< 非所有权指针,由渲染容器持有。
QMap<QString, nmVTKRenderLayer*> m_mapLayers; ///< Scene 独占已加入的图层。
};
#endif // NMVTKSCENE_H