Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/gtk-stats/gtkStatsPianoWindow.cxx

Go to the documentation of this file.
00001 // Filename: gtkStatsPianoWindow.cxx
00002 // Created by:  drose (18Jul00)
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 "gtkStatsPianoWindow.h"
00020 #include "gtkStatsPianoRoll.h"
00021 
00022 using Gtk::Menu_Helpers::MenuElem;
00023 using Gtk::Menu_Helpers::SeparatorElem;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: GtkStatsPianoWindow::Constructor
00027 //       Access: Public
00028 //  Description:
00029 ////////////////////////////////////////////////////////////////////
00030 GtkStatsPianoWindow::
00031 GtkStatsPianoWindow(GtkStatsMonitor *monitor, int thread_index,
00032                     int chart_xsize, int chart_ysize) :
00033   GtkStatsWindow(monitor),
00034   _thread_index(thread_index)
00035 {
00036   setup_menu();
00037   layout_window(chart_xsize, chart_ysize);
00038   show();
00039 }
00040 
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: GtkStatsPianoWindow::mark_dead
00044 //       Access: Public, Virtual
00045 //  Description: Called when the client's connection has been lost,
00046 //               this should update the window in some obvious way to
00047 //               indicate that the window is no longer live.
00048 ////////////////////////////////////////////////////////////////////
00049 void GtkStatsPianoWindow::
00050 mark_dead() {
00051   GtkStatsWindow::mark_dead();
00052   _chart->mark_dead();
00053 }
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: GtkStatsPianoWindow::idle
00057 //       Access: Public, Virtual
00058 //  Description:
00059 ////////////////////////////////////////////////////////////////////
00060 void GtkStatsPianoWindow::
00061 idle() {
00062   GtkStatsWindow::idle();
00063   _chart->update();
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: GtkStatsPianoWindow::setup_menu
00068 //       Access: Protected, Virtual
00069 //  Description:
00070 ////////////////////////////////////////////////////////////////////
00071 void GtkStatsPianoWindow::
00072 setup_menu() {
00073   GtkStatsWindow::setup_menu();
00074 
00075   Gtk::Menu *scale_menu = new Gtk::Menu;
00076 
00077   scale_menu->items().push_back
00078     (MenuElem("0.1 Hz",
00079               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 0.1f)));
00080   scale_menu->items().push_back
00081     (MenuElem("1 Hz",
00082               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 1.0f)));
00083   scale_menu->items().push_back
00084     (MenuElem("5 Hz",
00085               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 5.0f)));
00086   scale_menu->items().push_back
00087     (MenuElem("10 Hz",
00088               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 10.0f)));
00089   scale_menu->items().push_back
00090     (MenuElem("20 Hz",
00091               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 20.0f)));
00092   scale_menu->items().push_back
00093     (MenuElem("30 Hz",
00094               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 30.0f)));
00095   scale_menu->items().push_back
00096     (MenuElem("60 Hz",
00097               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 60.0f)));
00098   scale_menu->items().push_back
00099     (MenuElem("120 Hz",
00100               bind(slot(this, &GtkStatsPianoWindow::menu_hscale), 120.0f)));
00101 
00102   _menu->items().push_back(MenuElem("Scale", *manage(scale_menu)));
00103 }
00104 
00105 ////////////////////////////////////////////////////////////////////
00106 //     Function: GtkStatsPianoWindow::menu_new_window
00107 //       Access: Protected, Virtual
00108 //  Description:
00109 ////////////////////////////////////////////////////////////////////
00110 void GtkStatsPianoWindow::
00111 menu_new_window() {
00112   new GtkStatsPianoWindow(_monitor, _thread_index,
00113                           _chart->get_xsize(), _chart->get_ysize());
00114 }
00115 
00116 ////////////////////////////////////////////////////////////////////
00117 //     Function: GtkStatsPianoWindow::menu_hscale
00118 //       Access: Protected
00119 //  Description: Selects a new horizontal scale for the piano roll.
00120 //               This is done from the menu called "Scale".
00121 //
00122 //               The units is in Hz.
00123 ////////////////////////////////////////////////////////////////////
00124 void GtkStatsPianoWindow::
00125 menu_hscale(float hz) {
00126   _chart->set_horizontal_scale(1.0 / hz);
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: GtkStatsPianoWindow::layout_window
00131 //       Access: Public
00132 //  Description:
00133 ////////////////////////////////////////////////////////////////////
00134 void GtkStatsPianoWindow::
00135 layout_window(int chart_xsize, int chart_ysize) {
00136   Gtk::HBox *hbox = new Gtk::HBox;
00137   hbox = new Gtk::HBox;
00138   hbox->show();
00139   _main_box->pack_start(*manage(hbox), true, true, 8);
00140 
00141   Gtk::Table *chart_table = new Gtk::Table(1, 2);
00142   chart_table->show();
00143   hbox->pack_start(*manage(chart_table), true, true, 8);
00144 
00145   Gtk::Frame *frame = new Gtk::Frame;
00146   frame->set_shadow_type(GTK_SHADOW_ETCHED_OUT);
00147   frame->show();
00148   chart_table->attach(*manage(frame), 1, 2, 0, 1);
00149 
00150   _chart = new GtkStatsPianoRoll(_monitor, _thread_index,
00151                                   chart_xsize, chart_ysize);
00152   frame->add(*manage(_chart));
00153 
00154   // We put the labels in a frame, too, so they'll line up vertically.
00155   Gtk::Frame *label_frame = new Gtk::Frame;
00156   label_frame->set_shadow_type(GTK_SHADOW_NONE);
00157   label_frame->show();
00158   label_frame->add(*manage(_chart->get_labels()));
00159 
00160   chart_table->attach(*manage(label_frame), 0, 1, 0, 1,
00161                       0, (GTK_FILL|GTK_EXPAND), 4, 0);
00162 
00163   _chart->show();
00164 }

Generated on Fri May 2 03:20:03 2003 for Panda-Tool by doxygen1.3