#include <osgGtk/ViewerGtk.h>
Public Member Functions | |
ViewerGtk () | |
ViewerGtk (osg::ArgumentParser &arguments) | |
ViewerGtk (const osgViewer::Viewer &viewer, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY) | |
virtual | ~ViewerGtk () |
If running, stops the viewer. | |
virtual bool | isSameKindAs (const osg::Object *object) const |
virtual const char * | libraryName () const |
virtual const char * | className () const |
GraphicsWindowGtk * | setup_viewer_in_gtk_window (int width, int height) |
Sets up this viewer to run in a Gtk window of the specified width and height. | |
virtual int | run () |
Starts the viewer running at the currently set frame interval and priority. | |
int | run_to_frame (int frame_num) |
Runs the viewer until the viewer's OSG frame stamp reaches frame_num. | |
int | run_frames (int frames) |
Runs the viewer until the viewer's OSG frame stamp reaches the current frame stamp + frames. | |
virtual void | stop () |
Stops the viewer from running. | |
bool | is_running () |
True if the viewer is running, false otherwise. | |
double | fps () |
Returns the frames-per-second rate based on the currently set frame interval. | |
void | set_fps (double fps) |
Sets the frames per second update rate. | |
unsigned | frame_interval_ms () |
Returns the frame interval in milliseconds that will be used when the viewer is running. | |
void | set_frame_interval_ms (unsigned interval) |
Sets the frame interval in milliseconds that will be used when the viewer is running. | |
int | run_priority () |
Returns the run priority that will be used when the viewer is running. | |
void | set_run_priority (int priority) |
Sets the run priority that will be used when the viewer is running. | |
double | running_frame_step_rate () |
Returns the frame step rate that will be used when the viewer is running. | |
void | set_running_frame_step_rate (double frame_rate) |
Sets the frame step rate that will be used when the viewer is running. | |
int | get_run_to_frame_number () |
Returns the frame number that the viewer will run to. | |
Protected Member Functions | |
virtual bool | on_run_step () |
void | connect_timer () |
virtual int | run_implementation () |
Static Protected Member Functions | |
static gboolean | on_graphics_window_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data) |
Protected Attributes | |
bool | m_is_running |
unsigned | m_frame_interval |
int | m_run_priority |
double | m_frame_step_rate |
int | m_run_to_frame_number |
guint | m_timeout_source_id |
Static Private Member Functions | |
static gboolean | on_run_step_proxy (gpointer data) |
Proxy callback point that passes the callback to the virtual on_run_step(). |
In particular, the ability to establish this viewer in a gtk graphics window with the convenience method setup_viewer_in_gtk_window().
Also reimplements run() to use the glib timer main loop
osgViewer::ViewerGtk::ViewerGtk | ( | ) |
osgViewer::ViewerGtk::ViewerGtk | ( | osg::ArgumentParser & | arguments | ) |
osgViewer::ViewerGtk::ViewerGtk | ( | const osgViewer::Viewer & | viewer, | |
const osg::CopyOp & | copyop = osg::CopyOp::SHALLOW_COPY | |||
) |
osgViewer::ViewerGtk::~ViewerGtk | ( | ) | [virtual] |
const char * osgViewer::ViewerGtk::className | ( | ) | const [virtual] |
void osgViewer::ViewerGtk::connect_timer | ( | ) | [protected] |
References m_frame_interval, m_run_priority, m_timeout_source_id, and on_run_step_proxy().
Referenced by run_implementation(), set_fps(), set_frame_interval_ms(), and set_run_priority().
double osgViewer::ViewerGtk::fps | ( | ) |
Returns the frames-per-second rate based on the currently set frame interval.
References m_frame_interval.
unsigned osgViewer::ViewerGtk::frame_interval_ms | ( | ) |
Returns the frame interval in milliseconds that will be used when the viewer is running.
References m_frame_interval.
int osgViewer::ViewerGtk::get_run_to_frame_number | ( | ) |
bool osgViewer::ViewerGtk::is_running | ( | ) |
True if the viewer is running, false otherwise.
References m_is_running.
Referenced by set_fps(), set_frame_interval_ms(), set_run_priority(), and ~ViewerGtk().
bool osgViewer::ViewerGtk::isSameKindAs | ( | const osg::Object * | object | ) | const [virtual] |
const char * osgViewer::ViewerGtk::libraryName | ( | ) | const [virtual] |
gboolean osgViewer::ViewerGtk::on_graphics_window_expose_event | ( | GtkWidget * | widget, | |
GdkEventExpose * | event, | |||
gpointer | data | |||
) | [static, protected] |
Referenced by setup_viewer_in_gtk_window().
bool osgViewer::ViewerGtk::on_run_step | ( | ) | [protected, virtual] |
gboolean osgViewer::ViewerGtk::on_run_step_proxy | ( | gpointer | data | ) | [static, private] |
Proxy callback point that passes the callback to the virtual on_run_step().
References on_run_step().
Referenced by connect_timer().
int osgViewer::ViewerGtk::run | ( | ) | [virtual] |
Starts the viewer running at the currently set frame interval and priority.
Runs until stopped
References m_run_to_frame_number, and run_implementation().
int osgViewer::ViewerGtk::run_frames | ( | int | frames | ) |
Runs the viewer until the viewer's OSG frame stamp reaches the current frame stamp + frames.
References m_run_to_frame_number, and run_implementation().
int osgViewer::ViewerGtk::run_implementation | ( | ) | [protected, virtual] |
References connect_timer(), m_is_running, and m_timeout_source_id.
Referenced by run(), run_frames(), and run_to_frame().
int osgViewer::ViewerGtk::run_priority | ( | ) |
int osgViewer::ViewerGtk::run_to_frame | ( | int | frame_num | ) |
Runs the viewer until the viewer's OSG frame stamp reaches frame_num.
References m_run_to_frame_number, and run_implementation().
double osgViewer::ViewerGtk::running_frame_step_rate | ( | ) |
Returns the frame step rate that will be used when the viewer is running.
This is the value that will be passed to osgViewer::Viewer::advance() and controls the rate at which the viewer is advanced.
References m_frame_step_rate.
void osgViewer::ViewerGtk::set_fps | ( | double | fps | ) |
Sets the frames per second update rate.
Since the update interval has a resolution of 1ms, the update interval may not be exactly the same as the set rate.
For example, if set_fps(60) is called the actual update rate will not be 16.66667 ms (1000 ms / 60). Instead, the update rate will be the floor of 1000/60 or 16ms. Thus, the actual frame rate will be 62.5 fps.
References connect_timer(), is_running(), and m_frame_interval.
void osgViewer::ViewerGtk::set_frame_interval_ms | ( | unsigned | interval | ) |
Sets the frame interval in milliseconds that will be used when the viewer is running.
References connect_timer(), is_running(), and m_frame_interval.
void osgViewer::ViewerGtk::set_run_priority | ( | int | priority | ) |
Sets the run priority that will be used when the viewer is running.
References connect_timer(), is_running(), and m_run_priority.
void osgViewer::ViewerGtk::set_running_frame_step_rate | ( | double | frame_rate | ) |
Sets the frame step rate that will be used when the viewer is running.
References m_frame_step_rate.
GraphicsWindowGtk * osgViewer::ViewerGtk::setup_viewer_in_gtk_window | ( | int | width, | |
int | height | |||
) |
Sets up this viewer to run in a Gtk window of the specified width and height.
References osgViewer::GraphicsWindowGtk::gtk_widget(), and on_graphics_window_expose_event().
void osgViewer::ViewerGtk::stop | ( | ) | [virtual] |
Stops the viewer from running.
References m_is_running, and m_timeout_source_id.
Referenced by on_run_step(), and ~ViewerGtk().
unsigned osgViewer::ViewerGtk::m_frame_interval [protected] |
Referenced by connect_timer(), fps(), frame_interval_ms(), set_fps(), and set_frame_interval_ms().
double osgViewer::ViewerGtk::m_frame_step_rate [protected] |
Referenced by on_run_step(), running_frame_step_rate(), and set_running_frame_step_rate().
bool osgViewer::ViewerGtk::m_is_running [protected] |
Referenced by is_running(), run_implementation(), and stop().
int osgViewer::ViewerGtk::m_run_priority [protected] |
Referenced by connect_timer(), run_priority(), and set_run_priority().
int osgViewer::ViewerGtk::m_run_to_frame_number [protected] |
Referenced by get_run_to_frame_number(), on_run_step(), run(), run_frames(), and run_to_frame().
guint osgViewer::ViewerGtk::m_timeout_source_id [protected] |
Referenced by connect_timer(), run_implementation(), and stop().