Panda3D
|
00001 // Filename: gtkStatsGraph.h 00002 // Created by: drose (16Jan06) 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 GTKSTATSGRAPH_H 00016 #define GTKSTATSGRAPH_H 00017 00018 #include "pandatoolbase.h" 00019 #include "gtkStatsLabelStack.h" 00020 #include "pmap.h" 00021 00022 #include <gtk/gtk.h> 00023 00024 class GtkStatsMonitor; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : GtkStatsGraph 00028 // Description : This is just an abstract base class to provide a 00029 // common pointer type for the various kinds of graphs 00030 // that may be created for a GtkStatsMonitor. 00031 //////////////////////////////////////////////////////////////////// 00032 class GtkStatsGraph { 00033 public: 00034 // What is the user adjusting by dragging the mouse in a window? 00035 enum DragMode { 00036 DM_none, 00037 DM_scale, 00038 DM_guide_bar, 00039 DM_new_guide_bar, 00040 DM_sizing, 00041 }; 00042 00043 public: 00044 GtkStatsGraph(GtkStatsMonitor *monitor); 00045 virtual ~GtkStatsGraph(); 00046 00047 virtual void new_collector(int collector_index); 00048 virtual void new_data(int thread_index, int frame_number); 00049 virtual void force_redraw(); 00050 virtual void changed_graph_size(int graph_xsize, int graph_ysize); 00051 00052 virtual void set_time_units(int unit_mask); 00053 virtual void set_scroll_speed(double scroll_speed); 00054 void set_pause(bool pause); 00055 00056 void user_guide_bars_changed(); 00057 virtual void clicked_label(int collector_index); 00058 00059 protected: 00060 void close(); 00061 GdkGC *get_collector_gc(int collector_index); 00062 00063 virtual void additional_graph_window_paint(); 00064 virtual DragMode consider_drag_start(int graph_x, int graph_y); 00065 virtual void set_drag_mode(DragMode drag_mode); 00066 00067 virtual gboolean handle_button_press(GtkWidget *widget, int graph_x, int graph_y, 00068 bool double_click); 00069 virtual gboolean handle_button_release(GtkWidget *widget, int graph_x, int graph_y); 00070 virtual gboolean handle_motion(GtkWidget *widget, int graph_x, int graph_y); 00071 00072 protected: 00073 // Table of GC's for our various collectors. 00074 typedef pmap<int, GdkGC *> Brushes; 00075 Brushes _brushes; 00076 00077 GtkStatsMonitor *_monitor; 00078 GtkWidget *_parent_window; 00079 GtkWidget *_window; 00080 GtkWidget *_graph_window; 00081 GtkWidget *_graph_hbox; 00082 GtkWidget *_graph_vbox; 00083 GtkWidget *_hpaned; 00084 GtkWidget *_scale_area; 00085 GtkStatsLabelStack _label_stack; 00086 00087 GdkCursor *_hand_cursor; 00088 00089 GdkPixmap *_pixmap; 00090 GdkGC *_pixmap_gc; 00091 int _pixmap_xsize, _pixmap_ysize; 00092 00093 /* 00094 COLORREF _dark_color; 00095 COLORREF _light_color; 00096 COLORREF _user_guide_bar_color; 00097 HPEN _dark_pen; 00098 HPEN _light_pen; 00099 HPEN _user_guide_bar_pen; 00100 */ 00101 00102 DragMode _drag_mode; 00103 DragMode _potential_drag_mode; 00104 int _drag_start_x, _drag_start_y; 00105 double _drag_scale_start; 00106 int _drag_guide_bar; 00107 00108 bool _pause; 00109 00110 static const GdkColor rgb_white; 00111 static const GdkColor rgb_light_gray; 00112 static const GdkColor rgb_dark_gray; 00113 static const GdkColor rgb_black; 00114 static const GdkColor rgb_user_guide_bar; 00115 00116 private: 00117 void setup_pixmap(int xsize, int ysize); 00118 void release_pixmap(); 00119 00120 static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, 00121 gpointer data); 00122 static void window_destroy(GtkWidget *widget, gpointer data); 00123 static gboolean graph_expose_callback(GtkWidget *widget, 00124 GdkEventExpose *event, gpointer data); 00125 static gboolean configure_graph_callback(GtkWidget *widget, 00126 GdkEventConfigure *event, gpointer data); 00127 00128 protected: 00129 static gboolean button_press_event_callback(GtkWidget *widget, 00130 GdkEventButton *event, 00131 gpointer data); 00132 static gboolean button_release_event_callback(GtkWidget *widget, 00133 GdkEventButton *event, 00134 gpointer data); 00135 static gboolean motion_notify_event_callback(GtkWidget *widget, 00136 GdkEventMotion *event, 00137 gpointer data); 00138 }; 00139 00140 #endif 00141