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