42#pragma GCC diagnostic push
43#pragma GCC diagnostic ignored "-Wextra-semi"
46#include <vtkAutoInit.h>
48#include <vtkCameraOrientationWidget.h>
49#include <vtkImplicitPlaneRepresentation.h>
50#include <vtkImplicitPlaneWidget2.h>
51#include <vtkInteractorStyleTerrain.h>
52#include <vtkInteractorStyleTrackballCamera.h>
57#include <vtkRenderWindow.h>
58#include <vtkRenderWindowInteractor.h>
59#include <vtkRenderer.h>
60#include <vtkTextActor.h>
63#pragma GCC diagnostic pop
79 parallelScale = parallelScaleIn;
80 cameraDistance = cameraDistanceIn;
82 void Execute(vtkObject* caller,
unsigned long,
void*)
override
84 auto ren =
static_cast<vtkRenderer*
>(caller);
85 vtkCamera* cam = ren->GetActiveCamera();
87 auto cp = cam->GetPosition();
88 auto fp = cam->GetFocalPoint();
89 auto ud = cam->GetViewUp();
90 auto ps = cam->GetParallelScale();
91 auto cd = std::sqrt(std::pow(cp[0] - fp[0], 2) + std::pow(cp[1] - fp[1], 2)
92 + std::pow(cp[2] - fp[2], 2));
94 fVP->SetCurrentTargetPoint(
G4Point3D(fp[0], fp[1], fp[2]));
95 fVP->SetViewpointDirection((
G4Point3D(cp[0], cp[1], cp[2]) -
G4Point3D(fp[0], fp[1], fp[2])).unit());
96 fVP->SetUpVector(
G4Vector3D(ud[0], ud[1], ud[2]));
98 if (cam->GetParallelProjection() != 0) {
99 fVP->SetZoomFactor(parallelScale / ps);
102 fVP->SetZoomFactor(cameraDistance / cd);
119 t1 = std::chrono::steady_clock::now();
120 t2 = std::chrono::steady_clock::now();
124 void Execute(vtkObject* caller,
unsigned long,
void*)
override
126 auto ren =
static_cast<vtkRenderer*
>(caller);
127 int nActors = ren->GetActors()->GetNumberOfItems();
128 vtkCamera* cam = ren->GetActiveCamera();
129 if (cam ==
nullptr)
return;
131 double* pos = cam->GetPosition();
132 double* foc = cam->GetFocalPoint();
133 double viewAngle = cam->GetViewAngle();
134 double distance = cam->GetDistance();
137 cam->GetClippingRange(near,far);
138 double parallelScale = cam->GetParallelScale();
141 if (pos ==
nullptr)
return;
144 t2 = std::chrono::steady_clock::now();
147 std::chrono::duration<double> tdiff =
t2 -
t1;
149 float fps = 1.0 / tdiff.count();
153 "camera position : %.1f %.1f %.1f \n"
154 "camera focal point : %.1f %.1f %.1f \n"
155 "view angle : %.1f\n"
157 "clip near/far : %.1f %.1f\n"
158 "parallel scale : %.1f\n"
159 "number actors : %i\n"
161 pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, near, far, parallelScale,
171 std::chrono::time_point<std::chrono::steady_clock>
t1;
172 std::chrono::time_point<std::chrono::steady_clock>
t2;
190 void Execute(vtkObject* caller,
unsigned long,
void*)
override
192 if (this->
plane ==
nullptr) {
193 this->
plane = vtkPlane::New();
200 auto planeWidget =
reinterpret_cast<vtkImplicitPlaneWidget2*
>(caller);
202 reinterpret_cast<vtkImplicitPlaneRepresentation*
>(planeWidget->GetRepresentation());
203 rep->GetPlane(this->
plane);
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
G4Plane3D VtkPlaneToG4Plane3D(vtkPlane *vtkPlane)
VTK_MODULE_INIT(vtkInteractionStyle)
G4GLOB_DLL std::ostream G4cout
void UpdatePlanePipelines(G4String name, G4String type, const G4Plane3D)
vtkNew< vtkCamera > camera
vtkSmartPointer< vtkLight > light
vtkNew< vtkCameraOrientationWidget > camOrientWidget
void DisableCutter(G4String name)
void ExportVRMLScene(G4String)
void AddImageOverlay(const G4String &fileName, const G4double alpha, const G4double imageBottomLeft[2], const G4double worldBottomLeft[2], const G4double imageTopRight[2], const G4double worldTopRight[2], const G4double rot[3], const G4double trans[3])
vtkNew< vtkImplicitPlaneWidget2 > cutterPlaneWidget
vtkNew< vtkGeant4Callback > geant4Callback
void Initialise() override
void SetPolyhedronPipeline(const G4String &t)
void ExportScreenShot(G4String, G4String)
void FinishView() override
void ExportGLTFScene(G4String)
vtkNew< vtkTextActor > infoTextActor
virtual void SetWidgetInteractor(vtkAbstractWidget *widget)
virtual void AddClipperPlaneWidget(const G4Plane3D &plane)
vtkRenderWindowInteractor * renderWindowInteractor
vtkNew< vtkImplicitPlaneRepresentation > cutterPlaneRepresentation
void ExportJSONRenderWindowScene(G4String)
virtual void EnableClipperWidget()
G4VtkViewer(G4VSceneHandler &, const G4String &name)
virtual void AddCameraOrientationWidget()
void ExportFormatStore(G4String fileName, G4String store)
void EnableClipper(const G4Plane3D &plane, G4bool widget)
virtual void AddCutterPlaneWidget(const G4Plane3D &plane)
virtual void EnableCameraOrientationWidget()
vtkNew< vtkInfoCallback > infoCallback
virtual void DisableCutterWidget()
virtual void DisableCameraOrientationWidget()
vtkNew< vtkImplicitPlaneWidget2 > clipperPlaneWidget
vtkNew< vtkRenderer > renderer
void EnableCutter(const G4Plane3D &plane, G4bool bWidget)
void ExportVTPScene(G4String)
vtkNew< vtkImplicitPlaneRepresentation > clipperPlaneRepresentation
virtual void DisableClipperWidget()
void ExportOBJScene(G4String)
void ClearView() override
virtual void EnableCutterWidget()
void AddGeometryOverlay(const G4String &fileName, const G4double colour[3], const G4double alpha, const G4String &representation, const G4double scale[3], const G4double rotation[3], const G4double translation[3])
vtkRenderWindow * _renderWindow
void ExportVTPCutter(G4String fileName)
void SetGeant4ViewParameters(G4ViewParameters *VP)
static vtkGeant4Callback * New()
void Execute(vtkObject *caller, unsigned long, void *) override
void SetVtkInitialValues(G4double parallelScaleIn, G4double cameraDistanceIn)
G4String pipelineToUpdateType
void Execute(vtkObject *caller, unsigned long, void *) override
void SetUpdatePipelineName(G4String nameIn, G4String typeIn)
G4String pipelineToUpdateName
void SetStore(G4VtkStore *storeIn)
static vtkIPWCallback * New()
void SetTextActor(vtkTextActor *txt)
std::chrono::time_point< std::chrono::steady_clock > t2
static vtkInfoCallback * New()
std::chrono::time_point< std::chrono::steady_clock > t1
void Execute(vtkObject *caller, unsigned long, void *) override