Geant4-11
Public Member Functions | Static Public Member Functions | Protected Attributes
vtkInfoCallback Class Reference

#include <G4VtkViewer.hh>

Inheritance diagram for vtkInfoCallback:

Public Member Functions

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

Static Public Member Functions

static vtkInfoCallbackNew ()
 

Protected Attributes

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

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:154
std::chrono::time_point< std::chrono::steady_clock > t1
Definition: G4VtkViewer.hh:153

References t1, and t2.

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 = reinterpret_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 sprintf(this->TextBuff,"camera position : %.1f %.1f %.1f \n"
140 "camera focal point : %.1f %.1f %.1f \n"
141 "view angle : %.1f\n"
142 "distance : %.1f\n"
143 "parallel scale : %.1f\n"
144 "number actors : %i\n"
145 "fps : %.1f",pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, parallelScale, nActors, fps);
146 if(this->TextActor) {
147 this->TextActor->SetInput(this->TextBuff);
148 }
149 }
static const G4double pos
char TextBuff[256]
Definition: G4VtkViewer.hh:152
vtkTextActor * TextActor
Definition: G4VtkViewer.hh:151

References pos, t1, t2, TextActor, and TextBuff.

◆ New()

static vtkInfoCallback * vtkInfoCallback::New ( )
inlinestatic

Definition at line 107 of file G4VtkViewer.hh.

107{ return new vtkInfoCallback; }

References vtkInfoCallback().

◆ SetTextActor()

void vtkInfoCallback::SetTextActor ( vtkTextActor *  txt)
inline

Definition at line 113 of file G4VtkViewer.hh.

113{ this->TextActor = txt; }

References TextActor.

Field Documentation

◆ t1

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

Definition at line 153 of file G4VtkViewer.hh.

Referenced by Execute(), and vtkInfoCallback().

◆ t2

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

Definition at line 154 of file G4VtkViewer.hh.

Referenced by Execute(), and vtkInfoCallback().

◆ TextActor

vtkTextActor* vtkInfoCallback::TextActor
protected

Definition at line 151 of file G4VtkViewer.hh.

Referenced by Execute(), and SetTextActor().

◆ TextBuff

char vtkInfoCallback::TextBuff[256]
protected

Definition at line 152 of file G4VtkViewer.hh.

Referenced by Execute().


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