Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/framework/pandaFramework.h

Go to the documentation of this file.
00001 // Filename: pandaFramework.h
00002 // Created by:  drose (02Apr02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PANDAFRAMEWORK_H
00020 #define PANDAFRAMEWORK_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "windowFramework.h"
00025 
00026 #include "nodePath.h"
00027 #include "eventHandler.h"
00028 #include "graphicsPipe.h"
00029 #include "graphicsEngine.h"
00030 #include "graphicsWindow.h"
00031 #include "pointerTo.h"
00032 
00033 #include "pvector.h"
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : PandaFramework
00037 // Description : This class serves to provide a high-level framework
00038 //               for basic applications that use Panda in simple ways
00039 //               (like opening a window to view models, etc.).
00040 ////////////////////////////////////////////////////////////////////
00041 class EXPCL_FRAMEWORK PandaFramework {
00042 public:
00043   PandaFramework();
00044   virtual ~PandaFramework();
00045 
00046   void open_framework(int &argc, char **&argv);
00047   void close_framework();
00048 
00049   GraphicsPipe *get_default_pipe();
00050   INLINE GraphicsEngine *get_graphics_engine();
00051   INLINE const NodePath &get_data_root() const;
00052   INLINE EventHandler &get_event_handler();
00053 
00054   INLINE void set_window_title(const string &title);
00055   virtual void get_default_window_props(WindowProperties &props);
00056 
00057   WindowFramework *open_window(GraphicsPipe *pipe = NULL);
00058   WindowFramework *open_window(const WindowProperties &props,
00059                    GraphicsPipe *pipe = NULL);
00060 
00061   INLINE int get_num_windows() const;
00062   INLINE WindowFramework *get_window(int n) const;
00063   int find_window(const GraphicsWindow *win) const;
00064   int find_window(const WindowFramework *wf) const;
00065   void close_window(int n);
00066   INLINE void close_window(WindowFramework *wf);
00067   void close_all_windows();
00068   bool all_windows_closed() const;
00069 
00070   const NodePath &get_models();
00071 
00072   void report_frame_rate(ostream &out) const;
00073   void reset_frame_rate();
00074 
00075   void set_wireframe(bool enable);
00076   void set_texture(bool enable);
00077   void set_two_sided(bool enable);
00078   void set_lighting(bool enable);
00079   void set_background_type(WindowFramework::BackgroundType type);
00080 
00081   INLINE bool get_wireframe() const;
00082   INLINE bool get_texture() const;
00083   INLINE bool get_two_sided() const;
00084   INLINE bool get_lighting() const;
00085   INLINE WindowFramework::BackgroundType get_background_type() const;
00086 
00087   static int hide_collision_solids(NodePath node);
00088   static int show_collision_solids(NodePath node);
00089 
00090   void set_highlight(const NodePath &node);
00091   void clear_highlight();
00092   INLINE bool has_highlight() const;
00093   INLINE const NodePath &get_highlight() const;
00094 
00095   void enable_default_keys();
00096 
00097   virtual bool do_frame();
00098   void main_loop();
00099 
00100   INLINE void set_exit_flag();
00101   INLINE void clear_exit_flag();
00102 
00103 protected:
00104   virtual PT(WindowFramework) make_window_framework();
00105   virtual void make_default_pipe();
00106   virtual void do_enable_default_keys();
00107 
00108   static void event_esc(CPT_Event, void *data);
00109   static void event_f(CPT_Event, void *data);
00110   static void event_w(CPT_Event, void *data);
00111   static void event_t(CPT_Event, void *data);
00112   static void event_b(CPT_Event, void *data);
00113   static void event_i(CPT_Event, void *data);
00114   static void event_l(CPT_Event, void *data);
00115   static void event_c(CPT_Event, void *data);
00116   static void event_C(CPT_Event, void *data);
00117   static void event_B(CPT_Event, void *data);
00118   static void event_L(CPT_Event, void *data);
00119   static void event_h(CPT_Event, void *data);
00120   static void event_arrow_up(CPT_Event, void *data);
00121   static void event_arrow_down(CPT_Event, void *data);
00122   static void event_arrow_left(CPT_Event, void *data);
00123   static void event_arrow_right(CPT_Event, void *data);
00124   static void event_S(CPT_Event, void *data);
00125   static void event_comma(CPT_Event, void *data);
00126   static void event_window_event(CPT_Event, void *data);
00127 
00128 
00129 private:
00130   bool _is_open;
00131   bool _made_default_pipe;
00132 
00133   string _window_title;
00134 
00135   PT(GraphicsPipe) _default_pipe;
00136   GraphicsEngine _engine;
00137 
00138   NodePath _data_root;
00139   EventHandler _event_handler;
00140 
00141   typedef pvector< PT(WindowFramework) > Windows;
00142   Windows _windows;
00143 
00144   NodePath _models;
00145 
00146   // For counting frame rate.
00147   double _start_time;
00148   int _frame_count;
00149 
00150   bool _wireframe_enabled;
00151   bool _texture_enabled;
00152   bool _two_sided_enabled;
00153   bool _lighting_enabled;
00154   WindowFramework::BackgroundType _background_type;
00155 
00156   NodePath _highlight;
00157 
00158   bool _default_keys_enabled;
00159 
00160   bool _exit_flag;
00161 };
00162 
00163 #include "pandaFramework.I"
00164 
00165 #endif

Generated on Fri May 2 00:38:53 2003 for Panda by doxygen1.3