Panda3D
winStatsGraph.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 winStatsGraph.h
10  * @author drose
11  * @date 2003-12-03
12  */
13 
14 #ifndef WINSTATSGRAPH_H
15 #define WINSTATSGRAPH_H
16 
17 #include "pandatoolbase.h"
18 #include "winStatsLabelStack.h"
19 #include "pmap.h"
20 
21 #ifndef WIN32_LEAN_AND_MEAN
22 #define WIN32_LEAN_AND_MEAN 1
23 #endif
24 #include <windows.h>
25 
26 class WinStatsMonitor;
27 
28 /**
29  * This is just an abstract base class to provide a common pointer type for
30  * the various kinds of graphs that may be created for a WinStatsMonitor.
31  */
33 public:
34  // What is the user adjusting by dragging the mouse in a window?
35  enum DragMode {
36  DM_none,
37  DM_scale,
38  DM_left_margin,
39  DM_right_margin,
40  DM_guide_bar,
41  DM_new_guide_bar,
42  DM_sizing,
43  };
44 
45 public:
47  virtual ~WinStatsGraph();
48 
49  virtual void new_collector(int collector_index);
50  virtual void new_data(int thread_index, int frame_number);
51  virtual void force_redraw();
52  virtual void changed_graph_size(int graph_xsize, int graph_ysize);
53 
54  virtual void set_time_units(int unit_mask);
55  virtual void set_scroll_speed(double scroll_speed);
56  void set_pause(bool pause);
57 
59  virtual void clicked_label(int collector_index);
60 
61 protected:
62  void close();
63 
64  void setup_label_stack();
65  void move_label_stack();
66 
67  HBRUSH get_collector_brush(int collector_index);
68 
69  LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
70  virtual LONG graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
71 
72  virtual void additional_window_paint(HDC hdc);
73  virtual void additional_graph_window_paint(HDC hdc);
74  virtual DragMode consider_drag_start(int mouse_x, int mouse_y,
75  int width, int height);
76  virtual void set_drag_mode(DragMode drag_mode);
77 
78  virtual void move_graph_window(int graph_left, int graph_top,
79  int graph_xsize, int graph_ysize);
80 
81 protected:
82  // Table of brushes for our various collectors.
83  typedef pmap<int, HBRUSH> Brushes;
84  Brushes _brushes;
85 
86  WinStatsMonitor *_monitor;
87  HWND _window;
88  HWND _graph_window;
89  WinStatsLabelStack _label_stack;
90 
91  HCURSOR _sizewe_cursor;
92  HCURSOR _hand_cursor;
93 
94  HBITMAP _bitmap;
95  HDC _bitmap_dc;
96 
97  int _graph_left, _graph_top;
98  int _bitmap_xsize, _bitmap_ysize;
99  int _left_margin, _right_margin;
100  int _top_margin, _bottom_margin;
101 
102  COLORREF _dark_color;
103  COLORREF _light_color;
104  COLORREF _user_guide_bar_color;
105  HPEN _dark_pen;
106  HPEN _light_pen;
107  HPEN _user_guide_bar_pen;
108 
109  DragMode _drag_mode;
110  DragMode _potential_drag_mode;
111  int _drag_start_x, _drag_start_y;
112  double _drag_scale_start;
113  int _drag_guide_bar;
114 
115  bool _pause;
116 
117 private:
118  void setup_bitmap(int xsize, int ysize);
119  void release_bitmap();
120  void create_graph_window();
121  static void register_graph_window_class(HINSTANCE application);
122 
123  static LONG WINAPI static_graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
124 
125  static bool _graph_window_class_registered;
126  static const char * const _graph_window_class_name;
127 
128 protected:
129  static DWORD graph_window_style;
130 };
131 
132 #endif
This is just an abstract base class to provide a common pointer type for the various kinds of graphs ...
Definition: winStatsGraph.h:32
void set_pause(bool pause)
Changes the pause flag for the graph.
virtual 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...
virtual 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 ...
virtual void new_collector(int collector_index)
Called whenever a new Collector definition is received from the client.
virtual void clicked_label(int collector_index)
Called when the user single-clicks on a label.
void user_guide_bars_changed()
Called when the user guide bars have been changed.
virtual void new_data(int thread_index, int frame_number)
Called whenever new data arrives.
virtual void force_redraw()
Called when it is necessary to redraw the entire graph.
virtual void changed_graph_size(int graph_xsize, int graph_ysize)
Called when the user has resized the window, forcing a resize of the graph.
A window that contains a stack of labels from bottom to top.
This class represents a connection to a PStatsClient and manages the data exchange with the client.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.