100 lines
2.8 KiB
C++
100 lines
2.8 KiB
C++
#ifndef ULIB_VTK_VIEWPORT_H
|
|
#define ULIB_VTK_VIEWPORT_H
|
|
|
|
#include "uLibVtkInterface.h"
|
|
#include <vtkCornerAnnotation.h>
|
|
#include <vtkOrientationMarkerWidget.h>
|
|
#include <vtkRenderer.h>
|
|
#include <vtkSmartPointer.h>
|
|
#include <vtkVersion.h>
|
|
#include <vtkRenderer.h>
|
|
#include <vtkCornerAnnotation.h>
|
|
#include <vtkOrientationMarkerWidget.h>
|
|
#include <vtkCameraOrientationWidget.h>
|
|
#include <vtkNamedColors.h>
|
|
#include <vtkAxes.h>
|
|
#include <vtkAxesActor.h>
|
|
#include <vtkPlaneSource.h>
|
|
#include <vtkActor.h>
|
|
#include <vtkCellPicker.h>
|
|
#include <vector>
|
|
|
|
class vtkProp;
|
|
class vtk3DWidget;
|
|
class vtkRenderWindow;
|
|
class vtkRenderWindowInteractor;
|
|
class vtkCamera;
|
|
|
|
namespace uLib {
|
|
namespace Vtk {
|
|
|
|
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() { return m_Renderer; }
|
|
virtual vtkRenderWindow* GetRenderWindow() = 0;
|
|
virtual vtkRenderWindowInteractor* GetInteractor() = 0;
|
|
vtkCornerAnnotation* GetAnnotation() { return m_Annotation; }
|
|
vtkCameraOrientationWidget* GetCameraWidget(){ return m_CameraWidget; }
|
|
|
|
// 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();
|
|
|
|
vtkSmartPointer<vtkRenderer> m_Renderer;
|
|
vtkSmartPointer<vtkCornerAnnotation> m_Annotation;
|
|
vtkSmartPointer<vtkOrientationMarkerWidget> m_Marker;
|
|
vtkSmartPointer<vtkCameraOrientationWidget> m_CameraWidget;
|
|
|
|
vtkSmartPointer<vtkPlaneSource> m_GridSource;
|
|
vtkSmartPointer<vtkActor> m_GridActor;
|
|
vtkSmartPointer<vtkAxes> m_OriginAxes;
|
|
vtkSmartPointer<vtkActor> m_OriginAxesActor;
|
|
|
|
vtkSmartPointer<vtkNamedColors> m_Colors;
|
|
|
|
Axis m_GridAxis;
|
|
vtkSmartPointer<vtkHandlerWidget> m_HandlerWidget;
|
|
std::vector<Puppet*> m_Puppets;
|
|
vtkSmartPointer<vtkCellPicker> m_Picker;
|
|
};
|
|
|
|
} // namespace Vtk
|
|
} // namespace uLib
|
|
|
|
#endif // ULIB_VTK_VIEWPORT_H
|