Commit 4a71ee2c authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

Merge branch 'DisplayFractionalFPS' into 'master'

ENH: Display fractional FPS

See merge request !311
parents 045d054e 98f1dfa6
Pipeline #139005 passed with stage
in 0 seconds
......@@ -169,8 +169,8 @@ public:
///
/// \brief Set/Get the FPS
///
void setFPS(const size_t fps) { m_fps = fps; }
size_t getFPS() { return m_fps; }
void setFPS(const double fps) { m_fps = fps; }
double getFPS() { return m_fps; }
protected:
......@@ -184,7 +184,7 @@ protected:
std::vector<std::shared_ptr<SolverBase>> m_solvers; ///> List of non-linear solvers
std::vector<std::shared_ptr<SceneObjectControllerBase>> m_objectControllers; ///> List of controllers
size_t m_fps = 0;
double m_fps = 0.0;
bool m_isInitialized = false;
};
......
......@@ -67,6 +67,13 @@ VTKInteractorStyle::SetCurrentRenderer(vtkRenderer* ren)
this->CurrentRenderer->AddActor2D(m_fpsActor);
}
// Cross-platform sprintf
#if defined(_WIN32) || defined(_WIN64)
# define IMSTK_SPRINT sprintf_s
#else
# define IMSTK_SPRINT sprintf
#endif
void
VTKInteractorStyle::OnTimer()
{
......@@ -94,12 +101,24 @@ VTKInteractorStyle::OnTimer()
std::string fpsPhysicalStr;
if (m_simManager->getStatus() != SimulationStatus::PAUSED)
{
fpsPhysicalStr = "P: " + std::to_string((int)m_simManager->getActiveScene()->getFPS());
char buff[32];
auto fps = m_simManager->getActiveScene()->getFPS();
if(fps < 4.0)
{
IMSTK_SPRINT(buff, "%.2f", fps);
}
else
{
IMSTK_SPRINT(buff, "%d", static_cast<int>(fps));
}
fpsPhysicalStr = "P: " + std::string(buff);
}
else
{
fpsPhysicalStr = "P: PAUSED";
}
m_fpsActor->SetInput((fpsVisualStr + std::string(" | ") + fpsPhysicalStr).c_str());
m_lastFpsUpdate = now;
}
......
......@@ -181,7 +181,7 @@ SceneManager::runModule()
}
}
m_scene->setFPS((size_t)(1./wwt.getTimeElapsed(StopWatch::TimeUnitType::seconds)));
m_scene->setFPS(1./wwt.getTimeElapsed(StopWatch::TimeUnitType::seconds));
}
void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment