Panda3D

winStatsMonitor.h

00001 // Filename: winStatsMonitor.h
00002 // Created by:  drose (02Dec03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef WINSTATSMONITOR_H
00016 #define WINSTATSMONITOR_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "winStatsGraph.h"
00021 #include "pStatMonitor.h"
00022 #include "pointerTo.h"
00023 #include "pset.h"
00024 #include "pvector.h"
00025 #include "pmap.h"
00026 
00027 #include <windows.h>
00028 
00029 class WinStatsServer;
00030 class WinStatsChartMenu;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : WinStatsMonitor
00034 // Description : This class represents a connection to a PStatsClient
00035 //               and manages the data exchange with the client.
00036 ////////////////////////////////////////////////////////////////////
00037 class WinStatsMonitor : public PStatMonitor {
00038 public:
00039   class MenuDef {
00040   public:
00041     INLINE MenuDef(int thread_index, int collector_index, bool show_level);
00042     INLINE bool operator < (const MenuDef &other) const;
00043 
00044     int _thread_index;
00045     int _collector_index;
00046     bool _show_level;
00047   };
00048 
00049   WinStatsMonitor(WinStatsServer *server);
00050   virtual ~WinStatsMonitor();
00051 
00052   virtual string get_monitor_name();
00053 
00054   virtual void initialized();
00055   virtual void got_hello();
00056   virtual void got_bad_version(int client_major, int client_minor,
00057                                int server_major, int server_minor);
00058   virtual void new_collector(int collector_index);
00059   virtual void new_thread(int thread_index);
00060   virtual void new_data(int thread_index, int frame_number);
00061   virtual void lost_connection();
00062   virtual void idle();
00063   virtual bool has_idle();
00064 
00065   virtual void user_guide_bars_changed();
00066 
00067   HWND get_window() const;
00068   void open_strip_chart(int thread_index, int collector_index, bool show_level);
00069   void open_piano_roll(int thread_index);
00070 
00071   const MenuDef &lookup_menu(int menu_id) const;
00072   int get_menu_id(const MenuDef &menu_def);
00073 
00074   void set_time_units(int unit_mask);
00075   void set_scroll_speed(double scroll_speed);
00076   void set_pause(bool pause);
00077   
00078 private:
00079   void add_graph(WinStatsGraph *graph);
00080   void remove_graph(WinStatsGraph *graph);
00081 
00082   void create_window();
00083   void setup_options_menu();
00084   void setup_speed_menu();
00085   void setup_frame_rate_label();
00086   static void register_window_class(HINSTANCE application);
00087 
00088   static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
00089   LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
00090   void handle_menu_command(int menu_id);
00091 
00092   typedef pset<WinStatsGraph *> Graphs;
00093   Graphs _graphs;
00094 
00095   typedef pvector<WinStatsChartMenu *> ChartMenus;
00096   ChartMenus _chart_menus;
00097 
00098   typedef pvector<MenuDef> MenuById;
00099   typedef pmap<MenuDef, int> MenuByDef;
00100   MenuById _menu_by_id;
00101   MenuByDef _menu_by_def;
00102 
00103   HWND _window;
00104   HMENU _menu_bar;
00105   HMENU _options_menu;
00106   HMENU _speed_menu;
00107   string _window_title;
00108   int _time_units;
00109   double _scroll_speed;
00110   bool _pause;
00111 
00112   static bool _window_class_registered;
00113   static const char * const _window_class_name;
00114 
00115   friend class WinStatsGraph;
00116 };
00117 
00118 #include "winStatsMonitor.I"
00119 
00120 #endif
 All Classes Functions Variables Enumerations