00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the osgGTK library. * 00006 * * 00007 * The osgGTK library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The osgGTK library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef OSGVIEWERVIEWERGTK_H 00020 #define OSGVIEWERVIEWERGTK_H 00021 00022 #include <osgViewer/Viewer> 00023 #include <osgGtk/GraphicsWindowGtk.h> 00024 00069 namespace osgViewer 00070 { 00071 00082 class ViewerGtk : public Viewer 00083 { 00084 public: 00085 ViewerGtk(); 00086 00087 ViewerGtk ( osg::ArgumentParser& arguments ); 00088 00089 ViewerGtk ( const osgViewer::Viewer& viewer, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY ); 00090 00092 virtual ~ViewerGtk(); 00093 00094 virtual bool isSameKindAs(const osg::Object* object) const; 00095 00096 virtual const char* libraryName() const; 00097 00098 virtual const char* className() const; 00099 00101 GraphicsWindowGtk* setup_viewer_in_gtk_window(int width, int height); 00102 00108 virtual int run(); 00109 00111 int run_to_frame(int frame_num); 00112 00114 int run_frames(int frames); 00115 00117 virtual void stop(); 00118 00120 bool is_running(); 00121 00123 double fps(); 00124 00135 void set_fps(double fps); 00136 00138 unsigned frame_interval_ms(); 00139 00141 void set_frame_interval_ms(unsigned interval); 00142 00144 int run_priority(); 00145 00147 void set_run_priority( int priority ); 00148 00154 double running_frame_step_rate(); 00155 00157 void set_running_frame_step_rate(double frame_rate); 00158 00160 int get_run_to_frame_number(); 00161 00162 protected: 00163 bool m_is_running; 00164 unsigned m_frame_interval; 00165 int m_run_priority; 00166 double m_frame_step_rate; 00167 int m_run_to_frame_number; 00168 guint m_timeout_source_id; 00169 00170 static gboolean on_graphics_window_expose_event(GtkWidget* widget, GdkEventExpose* event, gpointer data); 00171 00172 virtual bool on_run_step(); 00173 00174 void connect_timer(); 00175 00176 virtual int run_implementation(); 00177 00178 private: 00179 00181 static gboolean on_run_step_proxy(gpointer data); 00182 00183 }; 00184 00185 } 00186 00187 #endif