iMSTK
Interactive Medical Simulation Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
imstk::Viewer Class Referenceabstract

Base class for viewer that manages render window and the renderers Creates backend-specific renderers on a per-scene basis. Contains user API to configure the rendering with various backends. More...

#include <imstkViewer.h>

Inheritance diagram for imstk::Viewer:
Inheritance graph
[legend]
Collaboration diagram for imstk::Viewer:
Collaboration graph
[legend]

Public Member Functions

std::shared_ptr< ScenegetActiveScene () const
 Get scene currently being rendered.
 
void setDebugAxesLength (double x, double y, double z)
 Set the length of the debug axes.
 
virtual void setActiveScene (std::shared_ptr< Scene > scene)=0
 Set scene to be rendered.
 
virtual void setRenderingMode (const Renderer::Mode mode)=0
 Setup the current renderer to render what's needed based on the mode chosen.
 
virtual void setSize (int, int)
 Set the render window size.
 
void setSize (Vec2i size)
 
virtual const Vec2i getSize () const
 
virtual Renderer::Mode getRenderingMode () const
 Get the current renderer's mode.
 
std::shared_ptr< RenderergetActiveRenderer () const
 Retrieve the renderer associated with the current scene.
 
virtual void setUseVsync (const bool)
 Set whether to sync frames to the refresh of the monitor.
 
virtual void setWindowTitle (const std::string &title)=0
 Set a string to be the title for the render window.
 
virtual void setInfoLevel (const int level)
 Set the info level, usually means display framerates and other viewer related information.
 
int getInfoLevel () const
 Get the current info level.
 
virtual const int getInfoLevelCount () const
 Get the number of info levels for a viewer, varies on implementation.
 
std::shared_ptr< ScreenCaptureUtilitygetScreenCaptureUtility () const
 access screen shot utility
 
virtual void setBackgroundColors (const Color color1, const Color color2=Color(0.0, 0.0, 0.0), const bool gradientBackground=false)=0
 Set the coloring of the screen background If 'gradientBackground' is false or not supplied color1 will fill the entire background.
 
virtual void processEvents ()=0
 
virtual std::shared_ptr< KeyboardDeviceClientgetKeyboardDevice () const
 Returns the device that emits key events.
 
virtual std::shared_ptr< MouseDeviceClientgetMouseDevice () const
 Returns the device that emits mouse events.
 
double getVisualFps () const
 
- Public Member Functions inherited from imstk::Module
virtual const std::string getTypeName () const =0
 Returns collision detection type string name.
 
 SIGNAL (Module, preUpdate)
 Posted before updateModule is called.
 
 SIGNAL (Module, postUpdate)
 Posted after updateModule is called.
 
 SIGNAL (Module, end)
 Posted when module wants to end.
 
double getDt () const
 Get/Set the time step.
 
void setDt (const double dt)
 
bool getInit () const
 Get whether the module is initialized yet.
 
bool getPaused () const
 Set/Get whether the module is currently paused.
 
void setPaused (const bool paused)
 
void setMuteUpdateEvents (const bool mute)
 Set/Get whether the module should post pre/post update events.
 
bool getMuteUpdateEvents () const
 
ExecutionType getExecutionType () const
 Set/Get the execution type (see imstk::ExecutionType)
 
void setExecutionType (const ExecutionType type)
 
void setSleepDelay (const double ms)
 
double getSleepDelay () const
 
void pause ()
 
void resume ()
 
void init ()
 
void update ()
 
void uninit ()
 
virtual bool initModule ()=0
 
virtual void uninitModule ()
 
- Public Member Functions inherited from imstk::EventObject
template<typename T >
void postEvent (const T &e)
 Emits the event Direct observers will be immediately called, in sync Queued observers will receive the Command in their queue for later execution, reciever must implement doEvent.
 
template<typename T >
void queueEvent (const T &e)
 Queues event directly to this.
 
void doEvent ()
 Do an event, if none exists return.
 
void doAllEvents ()
 Do all the events in the event queue.
 
void foreachEvent (std::function< void(Command cmd)> func)
 Thread safe loop over all event commands, one can implement a custom handler.
 
void rforeachEvent (std::function< void(Command cmd)> func)
 thread safe reverse loop over all event commands, one can implement a custom handler
 
void clearEvents ()
 Removes all events from queue cleans up copies of the event.
 

Protected Member Functions

 Viewer (std::string name)
 
void updateFps ()
 Called before render to push back and measure time.
 
void updateModule () override
 

Protected Attributes

std::unordered_map< std::shared_ptr< Scene >, std::shared_ptr< Renderer > > m_rendererMap
 
std::shared_ptr< Scenem_activeScene
 
std::shared_ptr< Entitym_debugEntity
 
std::shared_ptr< Cameram_debugCamera
 
std::shared_ptr< ScreenCaptureUtilitym_screenCapturer
 Screen shot utility.
 
std::shared_ptr< ViewerConfigm_config
 
int m_infoLevel = 0
 Info level.
 
std::chrono::high_resolution_clock::time_point m_pre
 time point pre-rendering
 
std::chrono::high_resolution_clock::time_point m_post
 time point post-rendering
 
std::chrono::high_resolution_clock::time_point m_lastFpsUpdate
 time point for last framerate display update
 
double m_visualFps = 0.0
 
double m_lastFps = 0.0
 
- Protected Attributes inherited from imstk::Module
std::atomic< bool > m_init = ATOMIC_VAR_INIT(false)
 
std::atomic< bool > m_paused = ATOMIC_VAR_INIT(false)
 
double m_dt = 0.0
 
ExecutionType m_executionType = ExecutionType::PARALLEL
 
bool m_muteUpdateEvents = false
 
double m_sleepDelay = 0.0
 
- Protected Attributes inherited from imstk::EventObject
ParallelUtils::SpinLock eventQueueLock
 
std::deque< CommandeventQueue
 
std::vector< std::pair< std::string, std::vector< Observer > > > queuedObservers
 
std::vector< std::pair< std::string, std::vector< Observer > > > directObservers
 

Additional Inherited Members

- Public Types inherited from imstk::Module
enum  ExecutionType { SEQUENTIAL, PARALLEL, ADAPTIVE }
 Currently 3 execution types are provided. These inform the driver on how it should run.
 
- Public Types inherited from imstk::EventObject
using Observer = std::tuple< bool, std::weak_ptr< EventObject >, std::function< void(Event *)> >
 

Detailed Description

Base class for viewer that manages render window and the renderers Creates backend-specific renderers on a per-scene basis. Contains user API to configure the rendering with various backends.

Definition at line 43 of file imstkViewer.h.


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