7 #include "imstkViewer.h" 8 #include "imstkAxesModel.h" 9 #include "imstkCamera.h" 10 #include "imstkEntity.h" 11 #include "imstkLogger.h" 15 Viewer::Viewer(std::string name) :
16 m_activeScene(nullptr),
17 m_debugEntity(
std::make_shared<Entity>(
"DebugEntity")),
18 m_debugCamera(
std::make_shared<Camera>()),
19 m_screenCapturer(nullptr),
20 m_config(
std::make_shared<ViewerConfig>()),
21 m_lastFpsUpdate(
std::chrono::high_resolution_clock::now()),
25 m_executionType = ExecutionType::SEQUENTIAL;
28 m_debugEntity->addComponent<AxesModel>();
34 m_debugEntity->getComponent<
AxesModel>()->setScale(Vec3d(x, y, z));
37 std::shared_ptr<Renderer>
40 CHECK(m_activeScene !=
nullptr) <<
"no active scene!";
42 return m_rendererMap.at(m_activeScene);
48 CHECK(level < getInfoLevelCount())
49 <<
"There are only " << getInfoLevelCount() <<
" levels and level " << level <<
" was requested";
53 std::shared_ptr<KeyboardDeviceClient>
56 LOG(FATAL) <<
"No KeyboardDeviceClient implemented for Viewer";
60 std::shared_ptr<MouseDeviceClient>
63 LOG(FATAL) <<
"No MouseDeviceClient implemented for Viewer";
71 auto now = std::chrono::high_resolution_clock::now();
72 m_visualFps = 1e6 /
static_cast<double>(std::chrono::duration_cast<std::chrono::microseconds>(now - m_pre).count());
73 m_visualFps = 0.1 * m_visualFps + 0.9 * m_lastFps;
74 m_lastFps = m_visualFps;
79 Viewer::updateModule()
81 this->postEvent(
Event(Module::preUpdate()));
82 this->postEvent(
Event(Module::postUpdate()));
virtual void setInfoLevel(const int level)
Set the info level, usually means display framerates and other viewer related information.
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
virtual std::shared_ptr< MouseDeviceClient > getMouseDevice() const
Returns the device that emits mouse events.
std::shared_ptr< Renderer > getActiveRenderer() const
Retrieve the renderer associated with the current scene.
Defines an axes that should be rendered.
virtual std::shared_ptr< KeyboardDeviceClient > getKeyboardDevice() const
Returns the device that emits key events.
void updateFps()
Called before render to push back and measure time.
void setDebugAxesLength(double x, double y, double z)
Set the length of the debug axes.