Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
vtkInfoCallback Class Reference

#include <G4VtkViewer.hh>

+ Inheritance diagram for vtkInfoCallback:

Public Member Functions

 vtkInfoCallback ()
 
void SetTextActor (vtkTextActor *txt)
 
void Execute (vtkObject *caller, unsigned long, void *) override
 

Static Public Member Functions

static vtkInfoCallbackNew ()
 

Protected Attributes

vtkTextActor * TextActor
 
char TextBuff [256]
 
std::chrono::time_point< std::chrono::steady_clock > t1
 
std::chrono::time_point< std::chrono::steady_clock > t2
 

Detailed Description

Definition at line 112 of file G4VtkViewer.hh.

Constructor & Destructor Documentation

◆ vtkInfoCallback()

vtkInfoCallback::vtkInfoCallback ( )
inline

Definition at line 117 of file G4VtkViewer.hh.

118 {
119 t1 = std::chrono::steady_clock::now();
120 t2 = std::chrono::steady_clock::now();
121 }
std::chrono::time_point< std::chrono::steady_clock > t2
std::chrono::time_point< std::chrono::steady_clock > t1

Referenced by New().

Member Function Documentation

◆ Execute()

void vtkInfoCallback::Execute ( vtkObject * caller,
unsigned long ,
void *  )
inlineoverride

Definition at line 124 of file G4VtkViewer.hh.

125 {
126 auto ren = static_cast<vtkRenderer*>(caller);
127 int nActors = ren->GetActors()->GetNumberOfItems();
128 vtkCamera* cam = ren->GetActiveCamera();
129 if (cam == nullptr) return;
130
131 double* pos = cam->GetPosition();
132 double* foc = cam->GetFocalPoint();
133 double viewAngle = cam->GetViewAngle();
134 double distance = cam->GetDistance();
135 double near;
136 double far;
137 cam->GetClippingRange(near,far);
138 double parallelScale = cam->GetParallelScale();
139
140
141 if (pos == nullptr) return;
142
143 // Get current time
144 t2 = std::chrono::steady_clock::now();
145
146 // Frame rate calculation
147 std::chrono::duration<double> tdiff = t2 - t1;
148 t1 = t2;
149 float fps = 1.0 / tdiff.count();
150
151 // String for display
152 snprintf(this->TextBuff, sizeof this->TextBuff,
153 "camera position : %.1f %.1f %.1f \n"
154 "camera focal point : %.1f %.1f %.1f \n"
155 "view angle : %.1f\n"
156 "distance : %.1f\n"
157 "clip near/far : %.1f %.1f\n"
158 "parallel scale : %.1f\n"
159 "number actors : %i\n"
160 "fps : %.1f",
161 pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, near, far, parallelScale,
162 nActors, fps);
163 if (this->TextActor != nullptr) {
164 this->TextActor->SetInput(this->TextBuff);
165 }
166 }
char TextBuff[256]
vtkTextActor * TextActor

◆ New()

static vtkInfoCallback * vtkInfoCallback::New ( )
inlinestatic

Definition at line 115 of file G4VtkViewer.hh.

115{ return new vtkInfoCallback; }

◆ SetTextActor()

void vtkInfoCallback::SetTextActor ( vtkTextActor * txt)
inline

Definition at line 122 of file G4VtkViewer.hh.

122{ this->TextActor = txt; }

Member Data Documentation

◆ t1

std::chrono::time_point<std::chrono::steady_clock> vtkInfoCallback::t1
protected

Definition at line 171 of file G4VtkViewer.hh.

Referenced by Execute(), and vtkInfoCallback().

◆ t2

std::chrono::time_point<std::chrono::steady_clock> vtkInfoCallback::t2
protected

Definition at line 172 of file G4VtkViewer.hh.

Referenced by Execute(), and vtkInfoCallback().

◆ TextActor

vtkTextActor* vtkInfoCallback::TextActor
protected

Definition at line 169 of file G4VtkViewer.hh.

Referenced by Execute(), and SetTextActor().

◆ TextBuff

char vtkInfoCallback::TextBuff[256]
protected

Definition at line 170 of file G4VtkViewer.hh.

Referenced by Execute().


The documentation for this class was generated from the following file: