00001 // Filename: gtkStats.cxx 00002 // Created by: drose (14Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "gtkStats.h" 00020 #include "gtkStatsMainWindow.h" 00021 00022 #include <pStatServer.h> 00023 #include <config_pstats.h> 00024 00025 #include <signal.h> 00026 00027 GtkStatsMainWindow *GtkStats::_main_window = NULL; 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: GtkStats::Constructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 GtkStats:: 00035 GtkStats() { 00036 set_program_description 00037 ("This is a fancy GUI PStats server that listens on a TCP port for a " 00038 "connection from a PStatClient in a Panda player. It will then " 00039 "draw strip charts illustrating the performance stats as reported " 00040 "by the player."); 00041 00042 add_option 00043 ("p", "port", 0, 00044 "Specify the TCP port to listen for connections on. By default, this " 00045 "is taken from the pstats-host Config variable.", 00046 &GtkStats::dispatch_int, NULL, &_port); 00047 00048 _port = pstats_port; 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: GtkStats::run 00053 // Access: Public 00054 // Description: 00055 //////////////////////////////////////////////////////////////////// 00056 void GtkStats:: 00057 run() { 00058 new GtkStatsMainWindow(_port); 00059 00060 main_loop(); 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: GtkStats::quit 00065 // Access: Public, Static 00066 // Description: Call this to cleanly shut down the program. 00067 //////////////////////////////////////////////////////////////////// 00068 void GtkStats:: 00069 quit() { 00070 if (_main_window != (GtkStatsMainWindow *)NULL) { 00071 _main_window->destruct(); 00072 } 00073 Gtk::Main::quit(); 00074 } 00075 00076 00077 int main(int argc, char *argv[]) { 00078 GtkStats prog; 00079 prog.parse_command_line(argc, argv); 00080 prog.run(); 00081 return 0; 00082 }