Geant4 11.1.1
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)
 
virtual void Execute (vtkObject *caller, unsigned long, void *)
 

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 104 of file G4VtkViewer.hh.

Constructor & Destructor Documentation

◆ vtkInfoCallback()

vtkInfoCallback::vtkInfoCallback ( )
inline

Definition at line 109 of file G4VtkViewer.hh.

109 {
110 t1 = std::chrono::steady_clock::now();
111 t2 = std::chrono::steady_clock::now();
112 }
std::chrono::time_point< std::chrono::steady_clock > t2
Definition: G4VtkViewer.hh:155
std::chrono::time_point< std::chrono::steady_clock > t1
Definition: G4VtkViewer.hh:154

Referenced by New().

Member Function Documentation

◆ Execute()

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

Definition at line 115 of file G4VtkViewer.hh.

116 {
117 vtkRenderer *ren = static_cast<vtkRenderer *>(caller);
118 int nActors = ren->GetActors()->GetNumberOfItems();
119 vtkCamera *cam = ren->GetActiveCamera();
120 if(!cam) return;
121
122 double *pos = cam->GetPosition();
123 double *foc = cam->GetFocalPoint();
124 double viewAngle = cam->GetViewAngle();
125 double distance = cam->GetDistance();
126 double parallelScale = cam->GetParallelScale();
127
128 if(!pos) return;
129
130 // Get current time
131 t2 = std::chrono::steady_clock::now();
132
133 // Frame rate calculation
134 std::chrono::duration<double> tdiff = t2-t1;
135 t1 = t2;
136 float fps = 1.0/tdiff.count();
137
138 // String for display
139 snprintf(this->TextBuff,sizeof this->TextBuff,
140 "camera position : %.1f %.1f %.1f \n"
141 "camera focal point : %.1f %.1f %.1f \n"
142 "view angle : %.1f\n"
143 "distance : %.1f\n"
144 "parallel scale : %.1f\n"
145 "number actors : %i\n"
146 "fps : %.1f",pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, parallelScale, nActors, fps);
147 if(this->TextActor) {
148 this->TextActor->SetInput(this->TextBuff);
149 }
150 }
char TextBuff[256]
Definition: G4VtkViewer.hh:153
vtkTextActor * TextActor
Definition: G4VtkViewer.hh:152

◆ New()

static vtkInfoCallback * vtkInfoCallback::New ( )
inlinestatic

Definition at line 107 of file G4VtkViewer.hh.

107{ return new vtkInfoCallback; }

◆ SetTextActor()

void vtkInfoCallback::SetTextActor ( vtkTextActor *  txt)
inline

Definition at line 113 of file G4VtkViewer.hh.

113{ this->TextActor = txt; }

Member Data Documentation

◆ t1

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

Definition at line 154 of file G4VtkViewer.hh.

Referenced by Execute(), and vtkInfoCallback().

◆ t2

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

Definition at line 155 of file G4VtkViewer.hh.

Referenced by Execute(), and vtkInfoCallback().

◆ TextActor

vtkTextActor* vtkInfoCallback::TextActor
protected

Definition at line 152 of file G4VtkViewer.hh.

Referenced by Execute(), and SetTextActor().

◆ TextBuff

char vtkInfoCallback::TextBuff[256]
protected

Definition at line 153 of file G4VtkViewer.hh.

Referenced by Execute().


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