Files
uLib/src/Vtk/vtkViewport.h
2026-03-26 09:50:52 +00:00

96 lines
2.4 KiB
C++

#ifndef ULIB_VTK_VIEWPORT_H
#define ULIB_VTK_VIEWPORT_H
#include "uLibVtkInterface.h"
#include <vector>
#include <map>
namespace uLib { class Object; }
// VTK classes are in the global namespace
class vtkRenderer;
class vtkCornerAnnotation;
class vtkOrientationMarkerWidget;
class vtkCameraOrientationWidget;
class vtkPlaneSource;
class vtkActor;
class vtkAxes;
class vtkNamedColors;
class vtkCellPicker;
class vtkCallbackCommand;
class vtkProp;
class vtk3DWidget;
class vtkRenderWindow;
class vtkRenderWindowInteractor;
class vtkCamera;
namespace uLib {
namespace Vtk {
struct ViewportData;
class vtkHandlerWidget;
/**
* @class Viewport
* @brief Base class for VTK viewports, providing core rendering and prop management.
*/
class Viewport {
public:
Viewport();
virtual ~Viewport();
// Render scene
virtual void Render() = 0;
void Reset();
void ZoomAuto();
void ZoomSelected();
// Puppet / prop management
void AddPuppet(Puppet &prop);
void RemovePuppet(Puppet &prop);
void SelectPuppet(Puppet *prop);
void addProp(vtkProp *prop);
void RemoveProp(vtkProp *prop);
// Widget integration
void AddWidget(vtk3DWidget *widget);
// Direct access to VTK internals
vtkRenderer* GetRenderer();
virtual vtkRenderWindow* GetRenderWindow() = 0;
virtual vtkRenderWindowInteractor* GetInteractor() = 0;
vtkCornerAnnotation* GetAnnotation();
vtkCameraOrientationWidget* GetCameraWidget();
void DisableHandler();
virtual void OnSelectionChanged(Puppet* p) {}
const std::vector<Puppet*>& getPuppets() const { return m_Puppets; }
// Grid control
void SetGridVisible(bool visible);
bool GetGridVisible() const;
enum Axis { X=0, Y, Z };
void SetGridAxis(Axis axis);
Axis GetGridAxis() const { return m_GridAxis; }
protected:
void SetupPipeline(vtkRenderWindowInteractor* iren);
void UpdateGrid();
// Internal puppet registration
void RegisterPuppet(Puppet* p, bool isPart = false);
void UnregisterPuppet(Puppet* p);
void ObserveContext(class vtkObjectsContext* ctx);
struct ViewportData *pv;
Axis m_GridAxis;
std::vector<Puppet*> m_Puppets;
std::map<uLib::Object*, Puppet*> m_ObjectToPuppet;
};
} // namespace Vtk
} // namespace uLib
#endif // ULIB_VTK_VIEWPORT_H