Panda3D
winStatsMonitor.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file winStatsMonitor.h
10  * @author drose
11  * @date 2003-12-02
12  */
13 
14 #ifndef WINSTATSMONITOR_H
15 #define WINSTATSMONITOR_H
16 
17 #include "pandatoolbase.h"
18 
19 #include "winStatsGraph.h"
20 #include "pStatMonitor.h"
21 #include "pointerTo.h"
22 #include "pset.h"
23 #include "pvector.h"
24 #include "pmap.h"
25 
26 #ifndef WIN32_LEAN_AND_MEAN
27 #define WIN32_LEAN_AND_MEAN 1
28 #endif
29 #include <windows.h>
30 
31 class WinStatsServer;
32 class WinStatsChartMenu;
33 
34 /**
35  * This class represents a connection to a PStatsClient and manages the data
36  * exchange with the client.
37  */
38 class WinStatsMonitor : public PStatMonitor {
39 public:
40  class MenuDef {
41  public:
42  INLINE MenuDef(int thread_index, int collector_index, bool show_level);
43  INLINE bool operator < (const MenuDef &other) const;
44 
45  int _thread_index;
46  int _collector_index;
47  bool _show_level;
48  };
49 
51  virtual ~WinStatsMonitor();
52 
53  virtual std::string get_monitor_name();
54 
55  virtual void initialized();
56  virtual void got_hello();
57  virtual void got_bad_version(int client_major, int client_minor,
58  int server_major, int server_minor);
59  virtual void new_collector(int collector_index);
60  virtual void new_thread(int thread_index);
61  virtual void new_data(int thread_index, int frame_number);
62  virtual void lost_connection();
63  virtual void idle();
64  virtual bool has_idle();
65 
66  virtual void user_guide_bars_changed();
67 
68  HWND get_window() const;
69  void open_strip_chart(int thread_index, int collector_index, bool show_level);
70  void open_piano_roll(int thread_index);
71 
72  const MenuDef &lookup_menu(int menu_id) const;
73  int get_menu_id(const MenuDef &menu_def);
74 
75  void set_time_units(int unit_mask);
76  void set_scroll_speed(double scroll_speed);
77  void set_pause(bool pause);
78 
79 private:
80  void add_graph(WinStatsGraph *graph);
81  void remove_graph(WinStatsGraph *graph);
82 
83  void create_window();
84  void setup_options_menu();
85  void setup_speed_menu();
86  void setup_frame_rate_label();
87  static void register_window_class(HINSTANCE application);
88 
89  static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
90  LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
91  void handle_menu_command(int menu_id);
92 
94  Graphs _graphs;
95 
97  ChartMenus _chart_menus;
98 
99  typedef pvector<MenuDef> MenuById;
101  MenuById _menu_by_id;
102  MenuByDef _menu_by_def;
103 
104  HWND _window;
105  HMENU _menu_bar;
106  HMENU _options_menu;
107  HMENU _speed_menu;
108  std::string _window_title;
109  int _time_units;
110  double _scroll_speed;
111  bool _pause;
112 
113  static bool _window_class_registered;
114  static const char * const _window_class_name;
115 
116  friend class WinStatsGraph;
117 };
118 
119 #include "winStatsMonitor.I"
120 
121 #endif
WinStatsMonitor::new_thread
virtual void new_thread(int thread_index)
Called whenever a new Thread definition is received from the client.
Definition: winStatsMonitor.cxx:159
WinStatsMonitor::open_piano_roll
void open_piano_roll(int thread_index)
Opens a new piano roll showing the indicated data.
Definition: winStatsMonitor.cxx:273
WinStatsChartMenu
A pulldown menu of charts available for a particular thread.
Definition: winStatsChartMenu.h:31
WinStatsMonitor::lost_connection
virtual void lost_connection()
Called whenever the connection to the client has been lost.
Definition: winStatsMonitor.cxx:188
pvector< WinStatsChartMenu * >
WinStatsMonitor::new_data
virtual void new_data(int thread_index, int frame_number)
Called as each frame's data is made available.
Definition: winStatsMonitor.cxx:173
WinStatsMonitor::has_idle
virtual bool has_idle()
Should be redefined to return true if you want to redefine idle() and expect it to be called.
Definition: winStatsMonitor.cxx:231
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap< MenuDef, int >
WinStatsMonitor::got_hello
virtual void got_hello()
Called when the "hello" message has been received from the client.
Definition: winStatsMonitor.cxx:95
WinStatsMonitor::got_bad_version
virtual void got_bad_version(int client_major, int client_minor, int server_major, int server_minor)
Like got_hello(), this is called when the "hello" message has been received from the client.
Definition: winStatsMonitor.cxx:108
WinStatsMonitor::get_monitor_name
virtual std::string get_monitor_name()
Should be redefined to return a descriptive name for the type of PStatsMonitor this is.
Definition: winStatsMonitor.cxx:75
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
WinStatsGraph
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
Definition: winStatsGraph.h:32
WinStatsMonitor::MenuDef
Definition: winStatsMonitor.h:40
WinStatsMonitor::idle
virtual void idle()
If has_idle() returns true, this will be called periodically to allow the monitor to update its displ...
Definition: winStatsMonitor.cxx:202
WinStatsMonitor::open_strip_chart
void open_strip_chart(int thread_index, int collector_index, bool show_level)
Opens a new strip chart showing the indicated data.
Definition: winStatsMonitor.cxx:259
WinStatsMonitor::get_menu_id
int get_menu_id(const MenuDef &menu_def)
Returns the menu ID that is reserved for the indicated MenuDef properties.
Definition: winStatsMonitor.cxx:300
winStatsGraph.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
WinStatsMonitor::lookup_menu
const MenuDef & lookup_menu(int menu_id) const
Returns the MenuDef properties associated with the indicated menu ID.
Definition: winStatsMonitor.cxx:287
WinStatsMonitor::set_scroll_speed
void set_scroll_speed(double scroll_speed)
Called when the user selects a new scroll speed from the monitor pulldown menu, this should adjust th...
Definition: winStatsMonitor.cxx:351
WinStatsMonitor::get_window
HWND get_window() const
Returns the window handle to the monitor's window.
Definition: winStatsMonitor.cxx:251
WinStatsMonitor::user_guide_bars_changed
virtual void user_guide_bars_changed()
Called when the user guide bars have been changed.
Definition: winStatsMonitor.cxx:239
WinStatsServer
The class that owns the main loop, waiting for client connections.
Definition: winStatsServer.h:23
WinStatsMonitor
This class represents a connection to a PStatsClient and manages the data exchange with the client.
Definition: winStatsMonitor.h:38
WinStatsMonitor::set_time_units
void set_time_units(int unit_mask)
Called when the user selects a new time units from the monitor pulldown menu, this should adjust the ...
Definition: winStatsMonitor.cxx:321
pStatMonitor.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
WinStatsMonitor::new_collector
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
Definition: winStatsMonitor.cxx:137
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
winStatsMonitor.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
WinStatsMonitor::set_pause
void set_pause(bool pause)
Called when the user selects a pause on or pause off option from the menu.
Definition: winStatsMonitor.cxx:392
WinStatsMonitor::initialized
virtual void initialized()
Called after the monitor has been fully set up.
Definition: winStatsMonitor.cxx:87
PStatMonitor
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:39
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset< WinStatsGraph * >