Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

HistoDisplay.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // HistoDisplay.C
00004 // Tetsuo Arisawa, 1999 0715
00005 // 
00006 //
00007 // modified by Hans Wenzel to make it work within 
00008 // CDF environment 
00009 // modified by Frank Hartmann
00010 // to allow socket connection to DisplayServer
00011 // modified by  Koji Ikado 
00012 // to display member pictures
00013 //
00014 // Version 1.5 1999 11/18 Tetsuo.Arisawa 
00015 //  TCanvas in addition to TH1F* can be read and drawn. 
00016 // Version 1.51 2000 2/17 T.A
00017 //  TH1F are drawn maintaining original options as being sent.
00018 //  GXW are replaced by ViratualX for the new ROOT version (by Hans).
00019 //  GetDirPath are modified to match new YMON histo names.
00020 //  Canvas Window Resize is tuned by 0.844.( Do not know why.)
00021 // Version 1.52 2000 3/  T.A
00022 //  Any histograms which inherits from TH1, (not TH1F any more)
00023 //  can be handled. For example TProfile are included.
00024 //  (Now objects which inherit from TH1 or TCanvas are displayed.)
00025 //  Canvas Window Resize is 1, not 0.844 any more.
00026 // Version 1.53 2000 3/21 Koji Ikado
00027 //  "Choose File" button & "Clear" button are added.
00028 // Version 1.55 2000 3/24 T.A
00029 //  Added a button to zero histograms.
00030 //  Currently the no of entries are cleared but not other staticsics
00031 //  as mean or rms. Waiting new version of ROOT in CDF. (v2.23.*)
00032 //  Also the codes of drawing are improved.
00033 // Version 1.56 2000 3/25 T.A
00034 //  Added a button to draw a bin-content histogram of a selected histogram. 
00035 //  Requested by LBNL, ANL (Young-Kee Kim, Larry Noodleman, Greg Veramendi). 
00036 //  Control buttons work much better with abling and disabling.
00037 // Version 1.561 2000 4/01 T.A
00038 //  Some TCanvas were not be drawn such as from YMon.cc.
00039 // (ROOT v2.22.06. KCC_3_3. ). Now fixed.
00040 // Version 1.57 2000 4/19 Koji Ikado
00041 //  Functions of help windows from menu bar are modified.
00042 //  Some "WARNING" message windows are added.
00043 // Version 1.58 2000 4/19 T.A
00044 //  Removing automatical resizing and clearing of canvas settings.
00045 //  Allowing to set additional delay time (msec) for  automatical update.
00046 // Version 1.581 2000 4/28 T.A
00047 //  Histogram control buttons (zero, unzero, content) are separated.
00048 // Version 1.582 2000 5/12 T.A & K.I
00049 //  Layout is changed. Debugged for displaying canvas. 
00050 //  Status bar is added(K.I).
00051 // Version 1.583 2000 6/01 T.A
00052 //  Debugged status bar implimentation errors and modified.
00053 //  Errors at closing file with the stop or exit button are fixed.
00054 //  Quit clone of TH1. Delete TList. BinContentHisto modified.
00055 // Version 1.584 2000 6/05 H.S
00056 //  modified socket connection part to work with the new server
00057 // Version 1.59 2000 6/02 T.A
00058 //  Changed so that everything on a canvas is updated automatically.
00059 //  But the only one input source is allowed now.
00060 //  Statistics of subtracted hists are modified
00061 //  for newer version than ROOT v2.23.12.
00062 // Version 1.60 2000 6/8 T.A
00063 //  Changed UpdateHistoList.
00064 // Version 1.61 2000 6/9 T.A
00065 // Version 1.62 2000 6/16 T.A
00066 //  CObject, CHistogram class is added.
00067 // Version 1.63 2000 8/03 T.A
00068 //  Debugged. But if you open hsimple.map after SVXMon.root
00069 //  segmentation fault occurs. If inverse the order, no error.
00070 // Version 1.64 2000 8/25 T.A
00071 //  Debugged. Canvas Update works fine. Draw option is taken from input.
00072 //  Tries several times if it failed to receive an object from a socket.
00073 //  Button to clear currently active pad is added.
00074 // Version 1.641 2000 8/28 T.A
00075 //  Minor change for removing unnecessary Clear().
00076 // Version 1.642 2000 9/1 T.A
00077 //  With updated CHistogram and CObject. Better memory management.
00078 // Version 1.643 2000 9/5 T.A
00079 //  Recursive pad clear is added for memory leak till the ROOT
00080 //  is updated. 
00081 // Version 1.644 2000 9/6 T.A
00082 //  Fixed to draw after reconnection. Current pad is stored.
00083 // Version 1.645 2000 9/9 T.A
00084 //  Recursive pad clear is debugged. Current pad update is modified.
00085 // Version 1.65 2000 9/9 T.A, Wolfgang and Hartmut,  
00086 //  As suggested by Philip Canal, modified
00087 //  error handling of socket connection,
00088 //  update method of histogram maintaining changes by users on canvas.   
00089 // Version 1.651 2000 9/15 T.A
00090 //  Pad update restoring changing by users on canvas.
00091 //  More attributes of pad or canvas are copied from the original 
00092 //  input.
00093 // Version 1.652 2000 9/21 T.A
00094 //  Debugged so that histo in pad from static file can be drawn normally.
00095 //  DrawHisto is divided for TList and TObject draw.
00096 //  Double click on List Tree draws an object. 
00097 //  ContentHisto is drawn for histo in selected pad.
00098 // Version 1.653 2000 9/24 T.A
00099 //  Testing to avoid segmentation fault that occurs 
00100 //  when canvas is clicked while painting. (Igor pointed out.)
00101 // Version 1.66 2000 9/29 T.A
00102 //  TConsumerInfo is read from input and ListTree is made based on it.
00103 //  Layout changes of main frame after its' resize look better now.
00104 //  ( Fixed according to suggestion by Igor. )
00105 // Version 1.661 2000 10/02 T.A
00106 //  TConsumerInfo can be read from text file "ConsumerInfo.txt"
00107 //  so that users can control what to be read from the inputs.
00108 //  Buttons Start and Open are not disabled.
00109 //  After the input connection closed, "Open" and "Start" able to update histos.
00110 //  More precautions for cases where gPad !=0 with no opened canvases.
00111 // Version 1.7 2000 10/06
00112 //  Slide Show canvas is implemented.
00113 //  CDF Consumer Display Canvas names and titles are changed with numbers.
00114 // Version 1.71 2000 10/06
00115 //  Debugging so that others than TH1 or TPad can be updated.
00116 //  Socket becomes the default, not TFile for input.
00117 // Version 1.72 2000 10/08
00118 //  ListTree Item shows tips or a title of the object when mouse is on it.
00119 //  ( For above ROOT v2.25/03 )
00120 // Version 1.8 2000 10/13
00121 //  Timer is added.
00122 // Version 1.81 2000 10/13
00123 //  Print function is being added. 
00124 // Version 1.82 2000 10/27
00125 //  Canvas name and title (which is dispayed on the top of the GUI canvas)
00126 //  are dynamically changed according to the objects on the display.
00127 // Version 1.83 2000 10/28
00128 //  GUI Canvas is resized when a consumer canvas is displayed
00129 //  duplicating its size. ( deactivated 2000/11/3. )
00130 //  Quit to draw additional pad to draw consumer objects on it.
00131 // Version 1.831 2000 11/3
00132 //  Histogram axis labels are redrawn by update
00133 //  because axis labels may be changed.
00134 //  ( Some consumer put run no and no of events on the x axis label.)
00135 // Version 1.832 2000/12/08
00136 //  For ROOT 2.26.00 and for EGCS
00137 // Version 1.84 2001/01/19
00138 //  Popup a current canvas for slide show.
00139 //  Cleaned up code for slide update.
00140 // Version 1.85 2001/01/31
00141 //  Slide show on one window.
00142 // Version 1.852 2001/02/09
00143 //  Slide show with timer update.
00144 //  Slide shows resume on a canvas where the slide show was shown,
00145 //  not on a current active canvas.
00146 //  Actions of Pause and Update buttons are rearranged.
00147 //  Cleared the use of varible Running:
00148 //  Running = kTRUE means some timer is running.
00149 //  By inserting Running = kFALSE, you can interrupped all timers.
00150 //  Change default and min frequencies to 5sec and 800msec. (Wolfgang requests)
00151 //  Included ServerProtocol.hh.
00152 // Version 1.853 2001/02/11
00153 //  Changed the Update Timer.
00154 //  A pad where update timer started is continued to be updated
00155 //  even after current active pad are changed.
00156 // Version 1.854 2001/02/20
00157 //  Debugged error which occured when you start slide show without a canvas
00158 //  window. 
00159 // Version 1.855 2001/02/22
00160 //  Debugged that drawing option of objects in consumer canvases are
00161 //  reproduced when they are displayed. Especially overlaid histos
00162 //  are shown properly.
00163 // Version 1.86 2001/03/08
00164 //  ListTree updates. Redraw ListTree with new TConsumerInfo.
00165 // Version 1.87 2001/03/12
00166 //  Removing buttons. start, exit.
00167 // Version 1.88 2001/03/26
00168 //  Objects are not fetched from inputobj ( e.g. socket )
00169 //  when open button is clicked
00170 //  because it consumes long time.
00171 //  Reading object is done each time when you tried to 
00172 //  draw a List Tree item one by one.
00173 //  Refresh is added to the List Tree menu item.
00174 // Version 1.9 2001/03/28
00175 //  PopUp warning/error slide show starts when new TConsumerInfo
00176 //  that contains warning or error folder.
00177 //  Debugged so that you can reconnect to the same socket
00178 //  by pushing "open" button.
00179 // Version 1.91 2001/04/06
00180 //  Debugged so that canvases are drawn without bad X11 window allocation.
00181 //---------------------------------------------------------------------
00182 // the following lines are a work around for a "known" bug in the IRIX6_2
00183 // unistd.h header file
00184 #include <sys/types.h>
00185 #if defined( OSF1 )
00186 #include <unistd.h>
00187 #else
00188 #include <sys/unistd.h>
00189 #endif
00190 //
00191 // IRIXX 6.2 bug fix 
00192 //
00193 #if defined( IRIX6_2 )
00194 #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE_EXTENDED==1)
00195      static pid_t vfork (void);
00196 #define __vfork vfork
00197 #endif   
00198 #endif
00199 // end of work around 
00200 //---------------------------------------------------------------------
00201 extern "C" {
00202 #include <unistd.h>
00203 }
00204 
00205 #ifdef ROOT_2_22
00206 #include "TGXW.h"
00207 #define gVirtualX gGXW
00208 #else
00209 #include "TVirtualX.h"
00210 #endif
00211 
00212 #include <TROOT.h> //gROOT 
00213 #include <TStyle.h> //gStyle
00214 #include <TApplication.h>
00215 #include <TGClient.h>
00216 
00217 #include <TString.h>
00218 #include <TRegexp.h>
00219 
00220 #include <TGMenu.h>
00221 
00222 //#include <TGToolBar.h> //TGHorizontal3DLine
00223 #ifndef ROOT_2_24
00224 #include <TG3DLine.h> //TGHorizontal3DLine //2000/12/08 v2.26
00225 #else
00226 #include <TGSplitter.h> //TGHorizontal3DLine //2000/12/04 v2.25.03
00227 #endif
00228 
00229 #include <TRootHelpDialog.h> 
00230 #include <HelpText.h> //gHelpAbout, gHelpCanvas
00231 #include <TGTextView.h>
00232 
00233 #include <TGLabel.h>
00234 #include <TGTextEntry.h> //GContext_t
00235 #include <TGLayout.h> //TGLayoutHints
00236 #include <TGButton.h> //TGPictureButton, TGCheckButton
00237 
00238 #include <TFile.h>
00239 class TMapRec;
00240 // needed by KCC 4.0 to correct problem in root v2_24_04c: 
00241 // (Thanks Chris.)
00242 class TGStatusBarPart; 
00243 #include <TMapFile.h> //TMapFile, TMapRec
00244 
00245 #include <TList.h>
00246 
00247 #include <TCollection.h> // TIter
00248 #include <TKey.h>
00249 #include <TObject.h>
00250 #include <TH1.h>
00251 #include <TClass.h> // TH1F;;Class()
00252 
00253 #include <TGListTree.h>
00254 
00255 #include <TGWindow.h>
00256 #include <TGCanvas.h>
00257 #include <TCanvas.h>
00258 #include <TTimer.h>
00259 #include <TSystem.h> // TProcessEventTimer
00260 #include <TVirtualPad.h> //gPad
00261 
00262 #include <TGFileDialog.h> //TGFileInfo
00263 #include <TGMsgBox.h>
00264 
00265 #include <TGFrame.h>
00266 #include <TGStatusBar.h>
00267 
00268 
00269 #include <string.h>
00270 #include <iostream>
00271 #include <stdio.h>
00272 #include <stdlib.h>
00273 #include <cmath>
00274 #include <cstring>
00275 
00276 #include <TUrl.h>
00277 
00278 #include <TFrame.h>
00279 
00280 #include <TTimer.h>
00281 #include <TGTextEditDialogs.h> // TGPrintDialog
00282 //#include <Consumer/TGTextEditDialogs.hh> // TGPrintDialog
00283 
00284 
00285 #include <fstream>
00286 #include <ctype.h>
00287 
00288 //#include "Consumer/HistoDisplay.hh"
00289 #include "HistoDisplay.h"
00290 //#include "ConsumerFramework/HistoDisplay.hh"
00291 #include "HistoDisplay.h"
00292 //#include "Consumer/HistoDisplayHelpText.hh" //gHelpHistoDisplay
00293 #include "HistoDisplayHelpText.h" //gHelpHistoDisplay
00294 //#include "Consumer/HistoDisplayPhoto.hh"
00295 #include "HistoDisplayPhoto.h"
00296 //#include "Consumer/ConsumerList.hh"
00297 #include "ConsumerList.h"
00298 
00299 #include <TSocket.h>
00300 #include <TMessage.h>
00301 #include <strstream>
00302 //#include "Consumer/TConsumerInfo.hh"
00303 #include "TConsumerInfo.h"
00304 
00305 //#include "Consumer/CObject.hh"
00306 #include "CObject.h"
00307 //#include "Consumer/CHistogram.hh"
00308 #include "CHistogram.h"
00309 
00310 //using std::string;
00311 #include "ServerProtocol.h"
00312 
00313 using std::cout;
00314 using std::endl;
00315 using std::ends;
00316 
00317 using std::cerr;
00318 using std::ostrstream;
00319 using std::max;
00320 
00321 enum HistoDisplayMessageTypes {
00322   kM_MENU_FILE_NEWGUI,
00323   kM_MENU_FILE_NEWCANVAS,
00324   kM_MENU_FILE_NEWSLIDE,
00325   kM_MENU_FILE_CLOSE,
00326   kM_MENU_FILE_EXIT,
00327   kM_MENU_LISTTREE_SORTTREE,
00328   kM_MENU_LISTTREE_SORTFOLDER,
00329   kM_MENU_LISTTREE_DELETE,
00330   kM_MENU_LISTTREE_CLEAR,
00331   kM_MENU_LISTTREE_REFRESH,
00332   /*
00333   kM_MENU_CONNECT_MON1,
00334   kM_MENU_CONNECT_MON2,
00335   kM_MENU_CONNECT_MON3,
00336   kM_MENU_CONNECT_MON4,
00337   kM_MENU_CONNECT_MON5,
00338   */
00339   kM_MENU_CONNECT_STATUS,
00340   kM_MENU_HELP_GUI,
00341   kM_MENU_HELP_ROOT,
00342   kM_MENU_HELP_CANVAS,
00343   kM_PICTBUTTON,
00344   kM_RABUTTON_MFILE,
00345   kM_RABUTTON_RFILE,
00346   kM_RABUTTON_SOCKET,
00347   kM_BUTTON_FILENAME,
00348   kM_BUTTON_CHOOSEFILE,
00349   kM_BUTTON_CLEARFILENAME,
00350   //kM_BUTTON_START,
00351   kM_BUTTON_PAUSE,
00352   kM_BUTTON_CLEAR,
00353   kM_BUTTON_PRINT,
00354   kM_BUTTON_RESTART,
00355   kM_BUTTON_ZERO,
00356   kM_BUTTON_UNZERO,
00357   kM_BUTTON_CONTENT,
00358   kM_BUTTON_STOP,
00359   kM_BUTTON_CANVAS,
00360   //kM_BUTTON_EXIT,
00361   kM_CHBUTTON_AUTOUPDATE,
00362   kM_CHBUTTON_SLIDEUPDATE,
00363   kM_TEXTENTRY_FILENAME,
00364   kM_TEXTENTRY_MONITORNAME,
00365   kM_TEXTENTRY_FREQUENCY
00366 };
00367 
00368 
00369 /*
00370 enum EInputTypes {
00371   kTMapFile,
00372   kTFile,
00373   kTSocket
00374 };
00375 */
00376 
00377 
00378 // slide show starts when following names are included in 
00379 // TGListTreeItem name.
00380 const char *kSlideShowFolder = "slide";
00381 
00382 const char *kWarningFolder = "warning";
00383 const char *kErrorFolder = "error";
00384 const char *kWarningErrorCanvasName = "WarningErrorCanvas";
00385 const char *kWarningErrorCanvasTitle = "Warning/Error Canvas";
00386 
00387 
00388 ClassImp(HistoDisplay)
00389   //ClassImp(HistoDisplayUpdateTimer)
00390 
00391 
00392 
00393 HistoDisplay::HistoDisplay( const TGWindow *p, UInt_t w, UInt_t h,
00394                             const char *socketserver, Int_t port)
00395 : TGMainFrame(p, w, h)
00396 , consumerlist(new ConsumerList("http://www-b0.fnal.gov:8000/consumer/consumer_status.html"))
00397 {
00398   //
00399   // hjw
00400   // first check if the enevironment is set correctly:
00401   //
00402   char *c_ptr;
00403   c_ptr = getenv("CONSUMER_ICONS");
00404     if(c_ptr==NULL){
00405       cout<<"Unix logical CONSUMER_ICONS is not set, will not be able to load all icons"<<endl;
00406     }
00407 
00408     gStyle->SetPalette(1); //By Greg.
00409 
00410   gClient->GetColorByName("LightYellow",LightYellow);
00411   gClient->GetColorByName("Red",Red);
00412   gClient->GetColorByName("Green",Green);
00413 
00414 
00415 
00416 
00417 
00418 
00419   fsocketserver=socketserver;
00420   fport=port;
00421 
00422 
00423   MakeMenuBar();
00424 
00425   fMainFrame =
00426     new TGCompositeFrame(this, 200, 400, kVerticalFrame); 
00427 
00428   fMainFrameLayout =
00429     //new TGLayoutHints( kLHintsCenterX | kLHintsCenterY, 1, 1, 1, 1); 
00430     new TGLayoutHints( kLHintsCenterX | kLHintsCenterY |
00431                        kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1); 
00432 
00433   char fTitle[] = "MINOS Online Monitoring Display ";
00434   MakeTitleFrame(fTitle);
00435 
00436   MakeInputFrame();
00437 
00438   MakeTGListTreeFrame();
00439 
00440   MakeStatusBar();
00441 
00442   AddFrame(fMainFrame,fMainFrameLayout); 
00443 
00444   SetWindowName(" MINOS Online Monitoring Main Frame");
00445   Resize(GetDefaultSize());
00446   Layout();
00447 
00448   MapSubwindows();
00449   MapWindow();
00450 
00451 
00452   fSelectedItem = 0; // to prevent segmentation fault
00453   //InputObj = 0;
00454 
00455   fHistoList = new TList();
00456   fDisplayedList = new TList();
00457   //fDisplayedList = new CList();
00458 
00459 
00460   SlideShowUpdate = kFALSE;
00461   fSlideCanvasList = new TList();
00462 
00463   CanvasName = "MINOSDisplayCanvas"; 
00464   CanvasTitle = "MINOS Online Monitoring Display Canvas ";
00465   CanvasNumber = 0;
00466 
00467 
00468   //fUpdateTimer = new TTimer( this, 100, kTRUE );
00469   fUpdateTimer = new HistoDisplayUpdateTimer( this, 100, kTRUE );
00470   fSlideTimer = new HistoDisplaySlideTimer( this, 2000, kTRUE );
00471 
00472   Running = kFALSE;
00473 
00474   fPrinter = 0;
00475   fPrinterCommand = 0;
00476 
00477 
00478 }
00479 
00480 
00481 void HistoDisplay::MakeMenuBar()
00482 {
00483   // File Menu --
00484   fFileMenu = new TGPopupMenu( fClient->GetRoot() );
00485   fNewCascadeMenu = new TGPopupMenu( fClient->GetRoot() );
00486   fNewCascadeMenu->AddEntry( "&GUI", kM_MENU_FILE_NEWGUI );
00487   fNewCascadeMenu->AddEntry( "&Canvas", kM_MENU_FILE_NEWCANVAS );
00488   //fNewCascadeMenu->AddEntry( "&Slide Show Canvas", kM_MENU_FILE_NEWSLIDE );
00489   fNewCascadeMenu->AddEntry( "&Auto-Update Canvas", kM_MENU_FILE_NEWSLIDE );
00490   fFileMenu->AddPopup( "&New", fNewCascadeMenu );
00491   fFileMenu->AddSeparator();
00492   fFileMenu->AddEntry( "&Close", kM_MENU_FILE_CLOSE );
00493   fFileMenu->AddEntry( "&Exit", kM_MENU_FILE_EXIT );
00494   //--
00495 
00496   // List Tree --
00497   fListTreeMenu = new TGPopupMenu( fClient->GetRoot() );
00498   fSortCascadeMenu = new TGPopupMenu( fClient->GetRoot() );
00499   fSortCascadeMenu->AddEntry( "&Tree", kM_MENU_LISTTREE_SORTTREE );
00500   fSortCascadeMenu->AddEntry( "In &Folder", kM_MENU_LISTTREE_SORTFOLDER );
00501   fListTreeMenu->AddPopup( "&Sort", fSortCascadeMenu );
00502   fListTreeMenu->AddSeparator();
00503   fListTreeMenu->AddEntry( "&Delete", kM_MENU_LISTTREE_DELETE );
00504   fListTreeMenu->AddEntry( "&Clear", kM_MENU_LISTTREE_CLEAR );
00505   fListTreeMenu->AddEntry( "&Refresh", kM_MENU_LISTTREE_REFRESH );
00506   //--
00507 
00508   // Connection Menu --
00509   fConnectMenu = new TGPopupMenu( fClient->GetRoot() );
00510   fConnectMenu->AddLabel( "CDF Monitors");
00511   fConnectMenu->AddSeparator();
00512   /*
00513   fConnectMenu->AddEntry( "&YMON", kM_MENU_CONNECT_MON1 );
00514   fConnectMenu->AddEntry( "&TRIGMON", kM_MENU_CONNECT_MON2 );
00515   fConnectMenu->AddEntry( "&LUMMON", kM_MENU_CONNECT_MON3 );
00516   fConnectMenu->AddEntry( "&PHYSMON", kM_MENU_CONNECT_MON4 );
00517   fConnectMenu->AddEntry( "&SPY", kM_MENU_CONNECT_MON5 );
00518   */
00519   fConnectMenu->AddSeparator();
00520   fConnectMenu->AddEntry( "&Status", kM_MENU_CONNECT_STATUS );
00521   //--
00522 
00523   // Help Menu --
00524   fHelpMenu = new TGPopupMenu( fClient->GetRoot() );
00525   fHelpMenu->AddEntry( "&About This GUI", kM_MENU_HELP_GUI );
00526   fHelpMenu->AddSeparator();
00527   fHelpMenu->AddEntry( "&About ROOT", kM_MENU_HELP_ROOT );
00528   fHelpMenu->AddEntry( "&About Canvas", kM_MENU_HELP_CANVAS );
00529   //--
00530 
00531   // Associate Menu Commands --
00532   fFileMenu->Associate(this);
00533   fNewCascadeMenu->Associate(this);
00534   fListTreeMenu->Associate(this);
00535   fSortCascadeMenu->Associate(this);
00536   fConnectMenu->Associate(this);
00537   fHelpMenu->Associate(this);
00538   //--
00539 
00540   // Create Menu Bar --
00541   fMenuBar = new TGMenuBar( this, 1, 1, kHorizontalFrame );
00542   fMenuBarLayout = 
00543     new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX,
00544                        0, 0, 1, 1);
00545   fMenuBarItemLayout =
00546     new TGLayoutHints( kLHintsTop | kLHintsLeft, 0, 4, 0, 0 );
00547   fMenuBarHelpLayout =
00548     new TGLayoutHints( kLHintsTop | kLHintsRight );
00549 
00550   fMenuBar->AddPopup( "&File", fFileMenu, fMenuBarItemLayout );
00551   fMenuBar->AddPopup( "&List Tree", fListTreeMenu, fMenuBarItemLayout );
00552   fMenuBar->AddPopup( "&Connection", fConnectMenu, fMenuBarItemLayout );
00553   fMenuBar->AddPopup( "&Help", fHelpMenu, fMenuBarHelpLayout );
00554 
00555   AddFrame( fMenuBar, fMenuBarLayout );
00556   //--
00557 
00558   // Separator --
00559   fMenuBarSeparator = new TGHorizontal3DLine( this );
00560   fMenuBarSeparatorLayout =
00561     new TGLayoutHints( kLHintsTop | kLHintsExpandX );
00562   AddFrame( fMenuBarSeparator, fMenuBarSeparatorLayout );
00563   //--
00564 }
00565 
00566 
00567 void HistoDisplay::CloseMenuBar()
00568 {
00569   delete fNewCascadeMenu;
00570   delete fFileMenu;
00571   delete fSortCascadeMenu;
00572   delete fListTreeMenu;
00573   delete fConnectMenu;
00574   delete fHelpMenu;
00575   delete fMenuBarItemLayout;
00576   delete fMenuBarHelpLayout;
00577   delete fMenuBar;
00578   delete fMenuBarLayout;
00579 
00580   delete fMenuBarSeparator;
00581   delete fMenuBarSeparatorLayout;
00582   delete consumerlist;
00583 }
00584 
00585 
00586 
00587 void HistoDisplay::MakeTitleFrame(const char *fTitle)
00588 {
00589    // Title Frame with logo picture --
00590 
00591    fTitleFrame = new TGCompositeFrame(fMainFrame,200,40,kHorizontalFrame);
00592    fTitleFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX,
00593                                          0, 0, 0, 0);
00594    FontStruct_t labelfont;
00595    labelfont = gClient->GetFontByName(
00596               "-*-times-bold-r-*-*-24-*-*-*-*-*-*-*");
00597    GCValues_t   gval;
00598    gval.fMask = kGCForeground | kGCFont;
00599    gval.fFont = gVirtualX->GetFontHandle(labelfont);
00600    gClient->GetColorByName("red", gval.fForeground);
00601    fTextGC = gVirtualX->CreateGC(gClient->GetRoot()->GetId(), &gval);
00602 
00603    fTitleLabel       = new TGLabel(fTitleFrame, fTitle , fTextGC, labelfont);
00604    fTitleLabelLayout = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 40, 10, 20, 20);
00605    fTitleFrame->AddFrame(fTitleLabel, fTitleLabelLayout);
00606 
00607    fPicBut = 
00608      new TGPictureButton( fTitleFrame,
00609                           gClient-> GetPicture("${CONSUMER_ICONS}/minos.xpm"),
00610                           kM_PICTBUTTON);
00611    fPictLayout = new TGLayoutHints(kLHintsTop | kLHintsRight
00612                                    //,0,0,0,0);
00613                                    ,0,4,4,0);
00614    fPicBut->Associate(this);
00615    fTitleFrame->AddFrame(fPicBut, fPictLayout);
00616 
00617    fMainFrame->
00618      AddFrame(fTitleFrame,fTitleFrameLayout);
00619    //--
00620 }
00621 
00622 
00623 void HistoDisplay::CloseTitleFrame()
00624 {
00625   gVirtualX->DeleteGC(fTextGC);
00626   delete fTitleLabel;
00627   delete fTitleLabelLayout;
00628   delete fPicBut;
00629   delete fPictLayout;
00630   delete fTitleFrame;
00631   delete fTitleFrameLayout;
00632 }
00633 
00634 
00635 
00636 void HistoDisplay::MakeInputFrame()
00637 {
00638   // Input stream Frame --
00639 
00640   fFileNameFrame =
00641     //new TGGroupFrame(fMainFrame, "Input Stream", kVerticalFrame);
00642     new TGGroupFrame(fMainFrame, "Add Input Stream", kVerticalFrame);
00643   fFileNameFrameLayout =
00644     //new TGLayoutHints( kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
00645     new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX
00646                        , 4, 4, 2, 2);
00647 
00648   // Radio Buttons --
00649   fRaButMFile =
00650     new TGRadioButton(fFileNameFrame,
00651                        "Memory Map File", kM_RABUTTON_MFILE);
00652   fRaButRFile =
00653     new TGRadioButton(fFileNameFrame, 
00654                        "Other ROOT File", kM_RABUTTON_RFILE);
00655   fRaButSocket =
00656     new TGRadioButton(fFileNameFrame,
00657                        "Socket Connection", kM_RABUTTON_SOCKET);
00658   fRaButLayout =
00659     new TGLayoutHints(kLHintsTop | kLHintsLeft, 2,2,2,2);
00660 
00661   fRaButMFile->Associate(this);
00662   fRaButRFile->Associate(this);
00663   fRaButSocket->Associate(this);
00664 
00665   fFileNameFrame->AddFrame(fRaButMFile, fRaButLayout);
00666   fFileNameFrame->AddFrame(fRaButRFile, fRaButLayout);
00667   fFileNameFrame->AddFrame(fRaButSocket, fRaButLayout);
00668 
00669   fRaButMFile->SetState(kButtonUp);
00670   //fRaButRFile->SetState(kButtonDown);
00671   fRaButRFile->SetState(kButtonUp);
00672   //fRaButSocket->SetState(kButtonUp);
00673   fRaButSocket->SetState(kButtonDown);
00674 
00675   /*
00676   RaButMFileOn = kFALSE;
00677   RaButRFileOn = kTRUE;
00678   RaButSocketOn = kFALSE;
00679 
00680   MFileOpen = kFALSE;
00681   RFileOpen = kFALSE;
00682   sockOpen = kFALSE;
00683   */
00684   //InputOpen = kFALSE;
00685   //--
00686 
00687 
00688   // File Name --
00689   fFileNameLayout =
00690     new TGLayoutHints( kLHintsTop | kLHintsLeft, 3,3,2,2);
00691 
00692   // Label --
00693   fFileNameLabel = 
00694     new TGLabel( fFileNameFrame, "Name of File / Socket Server:Port" );
00695   fFileNameFrame->
00696     AddFrame( fFileNameLabel, fFileNameLayout );
00697 
00698   //--
00699 
00700   // File Name Text Buffer --
00701   fFileOpenFrame =
00702     new TGCompositeFrame(fFileNameFrame, 60, 20, kHorizontalFrame);
00703   fFileOpenFrameLayout =
00704     new TGLayoutHints( kLHintsTop | kLHintsLeft, 2,2,2,2);
00705 
00706   fFileNameTextEntry =
00707     new TGTextEntry( fFileOpenFrame, 
00708                      fFileNameBuffer = new TGTextBuffer(320),
00709                      kM_TEXTENTRY_FILENAME );
00710   char sstext[80];
00711  
00712 
00713   sprintf(sstext,"%s:%d",fsocketserver,fport);
00714  
00715 
00716   fFileNameBuffer->AddText(0,sstext);
00717   fFileNameTextEntry->
00718     Resize(340,fFileNameTextEntry->GetDefaultHeight());
00719   fFileOpenFrame->
00720     AddFrame( fFileNameTextEntry, fFileNameLayout );
00721 
00722   fReadFileButton =
00723     new TGTextButton(fFileOpenFrame,"Open", kM_BUTTON_FILENAME);
00724   fReadFileButton->Associate(this);
00725 
00726   fReadFileButton->SetToolTipText("Open local/remote file or socket.");
00727 
00728   //gClient->GetColorByName("LightYellow",LightYellow);
00729   fReadFileButton->ChangeBackground(Red);
00730   //  cout << "Button changed to red\n";
00731   fFileOpenFrame->
00732     AddFrame( fReadFileButton, fFileNameLayout );
00733 
00734   fFileNameFrame->
00735     AddFrame( fFileOpenFrame, fFileOpenFrameLayout );
00736   //--
00737 
00738 
00739   // Choose File, Clear buttons. --
00740   fFileNameButtonFrame =
00741     new TGCompositeFrame(fFileNameFrame, 60, 70, kHorizontalFrame);
00742 
00743   fFileNameButtonFrameLayout =
00744     //new TGLayoutHints( kLHintsTop | kLHintsLeft, 2,2,2,2);
00745     new TGLayoutHints( kLHintsTop | kLHintsLeft, 2,2,2,0);
00746 
00747   fFileNameButtonLayout =
00748     new TGLayoutHints( kLHintsLeft, 3,3,2,2);
00749 
00750 
00751   fChooseFileButton =
00752     new TGTextButton(fFileNameButtonFrame,"Choose File",
00753                      kM_BUTTON_CHOOSEFILE);
00754   fChooseFileButton->SetToolTipText("Choose Local file");
00755 
00756   fChooseFileButton->Associate(this);
00757 
00758   fFileNameButtonFrame->
00759     AddFrame( fChooseFileButton,
00760               //new TGLayoutHints(kLHintsTop | kLHintsCenterX, 3,5,2,2));
00761               new TGLayoutHints(kLHintsTop | kLHintsCenterX, 3,5,2,0));
00762 
00763   fChooseFileButton->ChangeBackground(LightYellow);
00764 
00765 
00766   fClearFileNameButton =
00767     new TGTextButton(fFileNameButtonFrame,"     Clear    ",
00768                      kM_BUTTON_CLEARFILENAME);
00769 
00770   fClearFileNameButton->SetToolTipText("Clear Input Source Name");
00771 
00772   fClearFileNameButton->Associate(this);
00773 
00774   fFileNameButtonFrame->
00775     AddFrame( fClearFileNameButton, 
00776               //new TGLayoutHints(kLHintsTop | kLHintsRight, 3,5,2,2));
00777               new TGLayoutHints(kLHintsTop | kLHintsRight, 3,5,2,0));
00778 
00779   fClearFileNameButton->ChangeBackground(LightYellow);
00780 
00781 
00782   fFileNameFrame->
00783     AddFrame( fFileNameButtonFrame, fFileNameButtonFrameLayout );
00784   //--
00785 
00786 
00787 
00788   fMainFrame->
00789     AddFrame( fFileNameFrame, fFileNameFrameLayout  );
00790   //--
00791 }
00792 
00793 
00794 void HistoDisplay::CloseInputFrame()
00795 {
00796   delete fRaButMFile;
00797   delete fRaButRFile;
00798   delete fRaButSocket;
00799   delete fRaButLayout;
00800 
00801   delete fFileNameLabel; 
00802   delete fFileNameTextEntry;
00803   delete fReadFileButton;
00804   delete fFileOpenFrame;
00805   delete fFileOpenFrameLayout;
00806 
00807   delete   fChooseFileButton;
00808   delete   fClearFileNameButton;
00809   delete   fFileNameButtonFrame;
00810   delete   fFileNameButtonLayout;
00811   delete   fFileNameButtonFrameLayout;
00812 
00813   delete fFileNameLayout;
00814   delete fFileNameFrame;
00815   delete fFileNameFrameLayout;
00816 }
00817 
00818 
00819 
00820 void HistoDisplay::MakeTGListTreeFrame()
00821 {
00822   fListTreeMainFrame =
00823     new TGCompositeFrame(fMainFrame,200,300,kVerticalFrame);
00824   fListTreeMainFrameLayout =
00825     //new TGLayoutHints( kLHintsTop | kLHintsExpandX, 5, 5, 5, 5);
00826     new TGLayoutHints( kLHintsTop | kLHintsLeft |
00827                        kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5);
00828 
00829 
00830   // MonitorName --
00831   fMonitorNameLayout =
00832     new TGLayoutHints( kLHintsTop | kLHintsLeft, 2,2,2,2);
00833   //new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX,
00834   //           2, 200, 2, 2);
00835 
00836   fMonitorNameLabel =
00837     new TGLabel( fListTreeMainFrame,
00838                  // " Location in List Tree " );
00839          " Consumer Name in \"ConsumerInfo.txt\" ( Optional User Control )" );
00840   fListTreeMainFrame->
00841     AddFrame( fMonitorNameLabel, fMonitorNameLayout );
00842 
00843   fMonitorNameTextEntry = 
00844     new TGTextEntry( fListTreeMainFrame,
00845                      fMonitorNameBuffer = new TGTextBuffer(256),
00846                      kM_TEXTENTRY_MONITORNAME );
00847   fMonitorNameTextEntry->
00848     Resize(260, fMonitorNameTextEntry->GetDefaultHeight());
00849 
00850   fListTreeMainFrame->
00851     AddFrame( fMonitorNameTextEntry, fMonitorNameLayout );
00852   //--
00853 
00854 
00855 
00856   // Make List Tree Frame --
00857 
00858   fHistoListFrame =
00859     new TGCompositeFrame(fListTreeMainFrame, 220, 300, kHorizontalFrame);
00860   fHistoListFrameLayout =
00861     new TGLayoutHints( kLHintsTop | kLHintsLeft |
00862                        kLHintsExpandX | kLHintsExpandY,
00863     //new TGLayoutHints( kLHintsTop | kLHintsCenterX,
00864                        1, 1, 1, 1); 
00865 
00866 
00867   // Make List Tree --
00868   fTGCanvas =
00869     new TGCanvas(fHistoListFrame, 210, 300, kSunkenFrame | kDoubleBorder);
00870   fTGCanvasLayout =
00871     //new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandY);
00872     new TGLayoutHints( kLHintsTop | kLHintsLeft |
00873                        kLHintsExpandX | kLHintsExpandY );
00874   // , 2, 2, 2, 2); 
00875 
00876   fHistoListTree = new TGListTree(fTGCanvas->GetViewPort()
00877                                   , 210, 300, kHorizontalFrame);
00878   fHistoListTree->Associate(this);
00879   fTGCanvas->SetContainer(fHistoListTree);
00880 
00881   //tmp 2000/12/08
00882   fHistoListTree->SetAutoTips();
00883 
00884 
00885   fHistoListFrame->AddFrame(fTGCanvas,fTGCanvasLayout);
00886   //--
00887 
00888 
00889   // Button Frame of List Tree --
00890   fListButtonFrame =
00891     new TGCompositeFrame(fHistoListFrame, 100, 300,
00892                          kVerticalFrame );
00893   fListButtonFrameLayout = 
00894     //    new TGLayoutHints(kLHintsRight | kLHintsCenterY, 10, 10, 10, 10);
00895     //new TGLayoutHints( kLHintsCenterY, 2, 2, 5, 5);
00896     new TGLayoutHints( kLHintsRight | kLHintsCenterY |
00897                        kLHintsExpandX , 2, 2, 5, 5);
00898 
00899 
00900 
00901   // AutoUpdate Check Button --
00902   fChButtonAutoUpdate = 
00903     new TGCheckButton(fListButtonFrame, "Update Automatically",
00904               kM_CHBUTTON_AUTOUPDATE);
00905   //fChButtonAutoUpdateLayout =
00906   //new TGLayoutHints( kLHintsTop | kLHintsCenterX,5,5,15,25);
00907   fChButtonAutoUpdateLayout =
00908     new TGLayoutHints( kLHintsTop | kLHintsLeft,5,2,2,2);
00909   fChButtonAutoUpdate->Associate(this);
00910   fListButtonFrame->
00911     AddFrame( fChButtonAutoUpdate, fChButtonAutoUpdateLayout );
00912   fChButtonAutoUpdate->SetState(kButtonDown);
00913   AutoUpdate = kTRUE;
00914   //--
00915 
00916 
00917   // Slide Show Check Button --
00918   fChButtonSlideUpdate = 
00919     //new TGCheckButton(fListButtonFrame, "Update Slide Show Canvases",
00920     new TGCheckButton(fListButtonFrame, "Update Multi Canvases",
00921               kM_CHBUTTON_SLIDEUPDATE);
00922   fChButtonSlideUpdate->Associate(this);
00923   fListButtonFrame->
00924     AddFrame( fChButtonSlideUpdate, fChButtonAutoUpdateLayout );
00925   fChButtonSlideUpdate->SetState(kButtonUp);
00926   SlideShowUpdate = kFALSE;
00927   //--
00928 
00929 
00930   // Update Frequency --
00931   fFrequencyFrame = 
00932     new TGCompositeFrame(fListButtonFrame, 100, 50,
00933                          kHorizontalFrame );
00934   fFrequencyFrameLayout = 
00935     //    new TGLayoutHints(kLHintsRight | kLHintsCenterY, 10, 10, 10, 10);
00936     new TGLayoutHints( kLHintsTop | kLHintsLeft );
00937 
00938   fFrequencyLabel =
00939     //new TGLabel( fListButtonFrame, "Update Delay (msec)" );
00940     new TGLabel( fFrequencyFrame, "Update Delay (msec)" );
00941   //fListButtonFrame->
00942   fFrequencyFrame->
00943     AddFrame( fFrequencyLabel, fChButtonAutoUpdateLayout);
00944 
00945 
00946 
00947   fFrequencyTextEntry =
00948     //new TGTextEntry( fListButtonFrame,
00949     new TGTextEntry( fFrequencyFrame,
00950                      fFrequencyTextBuffer = new TGTextBuffer(40),
00951                      kM_TEXTENTRY_FREQUENCY );
00952   //fFrequencyTextBuffer->AddText(0,  "0");
00953   fFrequencyTextBuffer->AddText(0,  "3000");
00954 
00955   fFrequencyTextEntry->
00956     Resize( 50, fFrequencyTextEntry->GetDefaultHeight() );
00957 
00958   //fListButtonFrame->
00959   fFrequencyFrame->
00960     AddFrame( fFrequencyTextEntry, fChButtonAutoUpdateLayout);
00961 
00962   fListButtonFrame->
00963     AddFrame(fFrequencyFrame, fFrequencyFrameLayout);
00964 
00965   //--
00966 
00967 
00968   // Control Buttons --
00969 
00970   fControlButtonFrame =
00971     new TGCompositeFrame( fListButtonFrame, 200, 300,
00972                           kHorizontalFrame );
00973   fControlButtonFrameLayout =
00974     new TGLayoutHints( kLHintsCenterX | kLHintsCenterY, 5,5,5,5);
00975 
00976 
00977 
00978   // List Tree Control Buttons --
00979   fButtonFrame =
00980     new TGCompositeFrame(fControlButtonFrame, 90, 300,
00981                          kVerticalFrame | kFixedWidth );
00982   fButtonFrameLayout = 
00983     new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 10, 10, 10);
00984 
00985   fButtonLayout =
00986     new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX,
00987                       //5, 5, 5, 5);
00988                       5, 5, 2, 2);
00989   /*
00990   fStartHistoButton =
00991     new TGTextButton(fButtonFrame, "&Start", kM_BUTTON_START);
00992   fStartHistoButton->Associate(this);
00993   fStartHistoButton->SetToolTipText("Start Monitoring");
00994   */
00995 
00996   fRestartHistoButton =
00997     new TGTextButton(fButtonFrame, "&Update", kM_BUTTON_RESTART);
00998   fRestartHistoButton->Associate(this);
00999   fRestartHistoButton->SetToolTipText("Update Current Pad");
01000 
01001   fPauseHistoButton = 
01002     new TGTextButton(fButtonFrame, "&Pause", kM_BUTTON_PAUSE); 
01003   fPauseHistoButton->Associate(this);
01004   fPauseHistoButton->SetToolTipText("Pause Updating Current Pad");
01005 
01006   fClearHistoButton = 
01007     new TGTextButton(fButtonFrame, "&Clear", kM_BUTTON_CLEAR); 
01008   fClearHistoButton->Associate(this);
01009   fClearHistoButton->SetToolTipText("Clear Current Pad");
01010 
01011   fPrintHistoButton = 
01012     new TGTextButton(fButtonFrame, "&Print", kM_BUTTON_PRINT); 
01013   fPrintHistoButton->Associate(this);
01014   //fPrintHistoButton->SetToolTipText("Print Current Canvas");
01015   fPrintHistoButton->SetToolTipText("Print Current Pad");
01016 
01017   fStopHistoButton = 
01018     new TGTextButton(fButtonFrame, "&Reset", kM_BUTTON_STOP);
01019   fStopHistoButton->Associate(this);
01020   fStopHistoButton->SetToolTipText("Reset All");
01021 
01022   fNewCanvasButton = 
01023     new TGTextButton(fButtonFrame, "&New Canvas", kM_BUTTON_CANVAS);
01024   fNewCanvasButton->Associate(this);
01025   fNewCanvasButton->SetToolTipText("Draw new canvas");
01026 
01027   /*
01028   fExitButton =
01029     new TGTextButton(fButtonFrame, "&Exit", kM_BUTTON_EXIT); 
01030   fExitButton->Associate(this);
01031   fExitButton->SetToolTipText("Exit from this GUI");
01032   */
01033 
01034   //fButtonFrame->AddFrame(fStartHistoButton, fButtonLayout);
01035   fButtonFrame->AddFrame(fRestartHistoButton, fButtonLayout);
01036   fButtonFrame->AddFrame(fPauseHistoButton, fButtonLayout);
01037   fButtonFrame->AddFrame(fClearHistoButton, fButtonLayout);
01038   fButtonFrame->AddFrame(fPrintHistoButton, fButtonLayout);
01039   fButtonFrame->AddFrame(fStopHistoButton, fButtonLayout);
01040   fButtonFrame->AddFrame(fNewCanvasButton, fButtonLayout);
01041   //fButtonFrame->AddFrame(fExitButton, fButtonLayout);
01042 
01043   //tmp
01044   //fStartHistoButton->SetState(kButtonDisabled);
01045   fPauseHistoButton->SetState(kButtonDisabled);
01046   //fClearHistoButton->SetState(kButtonDisabled);
01047   //fPrintHistoButton->SetState(kButtonDisabled);
01048   //fRestartHistoButton->SetState(kButtonDisabled);
01049   //fStopHistoButton->SetState(kButtonDisabled);
01050 
01051   //Pausing = kFALSE;
01052 
01053   //gClient->GetColorByName("LightYellow",LightYellow);
01054 
01055   //fStartHistoButton->ChangeBackground(LightYellow);
01056   fPauseHistoButton->ChangeBackground(LightYellow);
01057   fClearHistoButton->ChangeBackground(LightYellow);
01058   fPrintHistoButton->ChangeBackground(LightYellow);
01059   fRestartHistoButton->ChangeBackground(LightYellow);
01060   fStopHistoButton->ChangeBackground(LightYellow);
01061   fNewCanvasButton->ChangeBackground(LightYellow);
01062   //fExitButton->ChangeBackground(LightYellow);
01063 
01064 
01065   fControlButtonFrame->
01066     AddFrame(fButtonFrame, fButtonFrameLayout);
01067   //--
01068 
01069 
01070   // Histogram Control Buttons --
01071   fHistoButtonGFrame
01072     = new TGGroupFrame(fControlButtonFrame, "Histogram",
01073                        kVerticalFrame );
01074 
01075   fHistoButtonGFrameLayout = 
01076     //    new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 2, 2);
01077     new TGLayoutHints(kLHintsRight | kLHintsCenterY, 10, 10, 10, 10);
01078 
01079 
01080   fHistoButtonFrame =
01081     new TGCompositeFrame(fHistoButtonGFrame, 50, 30,
01082                          kVerticalFrame | kFixedWidth );
01083 
01084 
01085   fHistoButtonFrameLayout = 
01086     //new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX,
01087     new TGLayoutHints(kLHintsRight | kLHintsCenterY); 
01088   //                 , 1, 1, 1, 1);
01089 
01090   fHistoButtonLayout =
01091     new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX,
01092                       1, 1, 5, 5);
01093 
01094   fZeroHistoButton = 
01095     new TGTextButton(fHistoButtonFrame, "&Zero", kM_BUTTON_ZERO);
01096   fZeroHistoButton->Associate(this);
01097   fZeroHistoButton->SetToolTipText("Reset selected Histograms");
01098 
01099   fUnZeroHistoButton = 
01100     new TGTextButton(fHistoButtonFrame, "&Restore", kM_BUTTON_UNZERO);
01101   fUnZeroHistoButton->Associate(this);
01102   fUnZeroHistoButton
01103     ->SetToolTipText("Back before reseting selected Histograms");
01104 
01105 
01106   fContentHistoButton = 
01107     new TGTextButton(fHistoButtonFrame, "&Content", kM_BUTTON_CONTENT);
01108   fContentHistoButton->Associate(this);
01109   fContentHistoButton
01110     ->SetToolTipText("Draw Bin-Content Histo of a Selected Item");
01111 
01112 
01113   fHistoButtonFrame->AddFrame(fZeroHistoButton, fHistoButtonLayout);
01114   fHistoButtonFrame->AddFrame(fUnZeroHistoButton, fHistoButtonLayout);
01115   fHistoButtonFrame->AddFrame(fContentHistoButton, fHistoButtonLayout);
01116 
01117   //fZeroHistoButton->SetState(kButtonDisabled);
01118   //fUnZeroHistoButton->SetState(kButtonDisabled);
01119   //fContentHistoButton->SetState(kButtonDisabled);
01120 
01121   fZeroHistoButton->ChangeBackground(LightYellow);
01122   fUnZeroHistoButton->ChangeBackground(LightYellow);
01123   fContentHistoButton->ChangeBackground(LightYellow);
01124 
01125 
01126   fHistoButtonGFrame->
01127     AddFrame(fHistoButtonFrame, fHistoButtonFrameLayout);
01128 
01129   fControlButtonFrame->
01130     AddFrame(fHistoButtonGFrame, fHistoButtonGFrameLayout);
01131 
01132   //--
01133 
01134 
01135   fListButtonFrame->
01136     AddFrame(fControlButtonFrame, fControlButtonFrameLayout);
01137 
01138 
01139   fHistoListFrame->
01140     AddFrame(fListButtonFrame, fListButtonFrameLayout);
01141 
01142 
01143   fListTreeMainFrame->
01144     AddFrame(fHistoListFrame,fHistoListFrameLayout);
01145 
01146   //--
01147 
01148   fMainFrame->
01149     AddFrame(fListTreeMainFrame,fListTreeMainFrameLayout);
01150 
01151   //--
01152 
01153 }
01154 
01155 
01156 
01157 void HistoDisplay::CloseTGListTreeFrame()
01158 {
01159   delete fMonitorNameLayout;
01160   delete fMonitorNameLabel;
01161   delete fMonitorNameBuffer;
01162   delete fMonitorNameTextEntry;
01163 
01164   delete fHistoListTree;
01165   delete fTGCanvas;
01166   delete fTGCanvasLayout;
01167 
01168   delete fChButtonAutoUpdate;
01169   delete fChButtonSlideUpdate;
01170   delete fChButtonAutoUpdateLayout;
01171 
01172 
01173   delete fFrequencyLabel;
01174   delete fFrequencyTextBuffer;
01175   delete fFrequencyTextEntry;
01176   delete fFrequencyFrame;
01177   delete fFrequencyFrameLayout;
01178 
01179   //delete fStartHistoButton;
01180   delete fPauseHistoButton;
01181   delete fRestartHistoButton;
01182   delete fClearHistoButton;
01183   delete fPrintHistoButton;
01184   delete fStopHistoButton;
01185   //delete fExitButton;
01186 
01187   delete fButtonLayout;
01188 
01189   delete fButtonFrame;
01190   delete fButtonFrameLayout;
01191 
01192 
01193 
01194   delete fZeroHistoButton;
01195   delete fUnZeroHistoButton;
01196   delete fContentHistoButton;
01197 
01198   delete fHistoButtonLayout;
01199 
01200   delete fHistoButtonFrame;
01201   delete fHistoButtonFrameLayout;
01202   delete fHistoButtonGFrame;
01203   delete fHistoButtonGFrameLayout;
01204 
01205 
01206   delete fControlButtonFrame;
01207   delete fControlButtonFrameLayout;
01208 
01209 
01210   delete fListButtonFrame;
01211   delete fListButtonFrameLayout;
01212 
01213   delete fHistoListFrame;
01214   delete fHistoListFrameLayout;
01215 
01216   delete fListTreeMainFrame;
01217   delete fListTreeMainFrameLayout;
01218 }
01219 
01220 void HistoDisplay::MakeStatusBar()
01221 {
01222   Int_t parts[] = {20, 80};
01223   fStatusBar = new TGStatusBar(fMainFrame, 50, 10, kHorizontalFrame);
01224   fStatusBar->SetParts(parts, 2);
01225   fMainFrame->AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom| kLHintsExpandX));
01226 }
01227 
01228 void HistoDisplay::CloseStatusBar()
01229 {
01230   delete fStatusBar;
01231 }
01232 
01233 
01234 
01235 
01236 
01237 //TObject *HistoDisplay::OpenFile( const char *filename )
01238 TObject *HistoDisplay::OpenFile( const char *filename,
01239                                  EInputTypes inputtype,
01240                                  Option_t *option )
01241 {
01242   //cout << " In OpenFile " << endl;
01243 
01244   TObject *InputObj = 0;
01245 
01246   if ( inputtype == kTMapFile ) {
01247     TObject *obj =gROOT->GetListOfMappedFiles()->FindObject(filename) ;
01248     TMapFile *MFile = 0;
01249     if ( obj ) {
01250       MFile = (TMapFile*)obj;
01251     }
01252     else {
01253       //TMapFile::SetMapAddress(0x40c0000);
01254       MFile = TMapFile::Create(filename, option);
01255     }
01256 
01257     if ( MFile &&
01258          MFile->IsFolder() &&
01259          (MFile->IsA() == TMapFile::Class())  ) {
01260       //MFile->ls();
01261       //InputOpen = kTRUE;
01262       InputObj = MFile;
01263     }
01264     else {
01265       cout << " Error Opening " << filename << endl;
01266       if ( MFile ) MFile->Close();
01267       //InputOpen = kFALSE;
01268     }
01269   } //if ( inputtype == kTMapFile )
01270 
01271   else if ( inputtype == kTFile ) {
01272     TObject *obj = gROOT->GetListOfFiles()->FindObject(filename);
01273     TFile *RFile = 0;
01274     if ( obj ) {
01275       RFile = (TFile*)obj;
01276     }
01277     else {
01278       RFile = TFile::Open(filename, option);
01279     }
01280     if ( RFile &&
01281          RFile->IsOpen()  &&
01282          RFile->IsFolder() &&
01283          !(RFile->IsZombie()) &&
01284          (RFile->IsA() == TFile::Class()) &&
01285          (RFile->IsA() != TMapFile::Class())  ) {
01286       //RFile->ls();
01287       //InputOpen = kTRUE;
01288       InputObj = RFile;
01289     }
01290     else {
01291       cout << " Error Opening " << filename << endl;
01292       if ( RFile ) RFile->Close();
01293       //InputOpen = kFALSE;
01294     }
01295   } //else if ( inputtype == kTFile ) 
01296 
01297 
01298   else if ( inputtype == kTSocket ) {
01299 
01300     TSocket *sock = 0;
01301     //TObject *obj =gROOT->GetListOfSockets()->FindObject(filename);
01302     //if ( obj ) sock = (TSocket*)obj;
01303     //else {
01304 
01305     sock = (TSocket*)gROOT->GetListOfSockets()->FindObject(filename);
01306     //while ( sock && !sock->IsValid() ) {
01307     while ( sock ) {
01308       sock->Close();
01309       sock = (TSocket*)gROOT->GetListOfSockets()->FindObject(filename);
01310     }//while ( sock && !sock->IsValid() ) 
01311 
01312     if ( !sock ) {
01313       TUrl url(filename);
01314       sock = new TSocket(url.GetHost(),url.GetPort());
01315       //cout << " Socket Server Name = " << url.GetHost() << endl;
01316       //cout << " port = " << url.GetPort() << endl;
01317     } //if ( !sock ) 
01318 
01319     sock->SetName( filename );
01320 
01321     if ( sock && sock->IsValid() ) {
01322       cout << " Socket Server = " << filename << endl;
01323       //InputOpen = kTRUE;
01324       InputObj = sock;
01325     }
01326     else {
01327       cout << " Error Opening " << filename << endl;
01328       if ( sock ) sock->Close();
01329       //InputOpen = kFALSE;
01330     }
01331   } //else if ( inputtype == kTSocket ) {
01332 
01333 
01334   return InputObj;
01335 
01336 }
01337 
01338 
01339 
01340 TObject *HistoDisplay::CloseFile( const char *filename,
01341                                   EInputTypes inputtype )
01342 {
01343   //cout << " In CloseFile " << endl;
01344 
01345   TObject *obj = 0;
01346 
01347   if ( inputtype == kTMapFile ) {
01348 
01349     while( ( obj = gROOT->GetListOfMappedFiles()->FindObject(filename) ) )
01350       ( (TMapFile*)obj )->Close();
01351 
01352   } //if ( inputtype == kTMapFile )
01353   else if ( inputtype == kTFile ) {
01354 
01355     while( ( obj = gROOT->GetListOfFiles()->FindObject(filename) ) )
01356       ( (TFile*)obj )->Close();
01357 
01358   } //else if ( inputtype == kTFile )
01359   else if ( inputtype == kTSocket ) {
01360 
01361     while( ( obj =gROOT->GetListOfSockets()->FindObject(filename) ) )
01362       ( (TSocket*)obj )->Close();
01363 
01364   } //else if ( inputtype == kTSocket ) 
01365  
01366   return obj;
01367 
01368 }
01369 
01370 TObject *HistoDisplay::CloseFile( TObject *obj )
01371 {
01372   //cout << " In CloseFile ( obj )" << endl;
01373 
01374   if ( obj ) { 
01375 
01376     if ( obj->InheritsFrom( TMapFile::Class() ) ) 
01377       ( (TMapFile*)obj )->Close();
01378 
01379     else if ( obj->InheritsFrom( TMapFile::Class() ) ) 
01380       ( (TFile*)obj )->Close();
01381 
01382     else if ( obj->InheritsFrom( TSocket::Class() ) ) 
01383       ( (TSocket*)obj )->Close();
01384  
01385   } //if ( obj ) 
01386 
01387   return obj;
01388 
01389 }
01390 
01391 
01392 void HistoDisplay::CloseConnection() 
01393 {
01394 
01395   //if (MFileOpen) {
01396   if ( gROOT->GetListOfMappedFiles() ) {
01397     //delete MFile;
01398     //gROOT->GetListOfMappedFiles()->Delete();
01399     // To avoid Error in <TMapFile::Close>: 
01400     //  shadow map == 0, should never happen!
01401     TIter next( gROOT->GetListOfMappedFiles() );
01402     TMapFile* mfile = 0; 
01403     while ( ( mfile = (TMapFile*)next() ) ) {
01404       mfile->Close();
01405       //gROOT->GetListOfMappedFiles()->Remove(mfile);
01406       // is called by close
01407     }
01408     //MFile = 0;
01409     //MFileOpen = kFALSE;
01410   }
01411 
01412   //if (RFileOpen) {
01413   if ( gROOT->GetListOfFiles() ) {
01414     //delete RFile;
01415     //gROOT->GetListOfFiles()->Delete();
01416     TIter next( gROOT->GetListOfFiles() );
01417     TFile* file = 0; 
01418     while ( ( file = (TFile*)next() ) ) {
01419       file->Close();
01420       //gROOT->GetListOfFiles()->Remove(file);
01421       // is called by close
01422     }
01423     //RFile = 0;
01424     //RFileOpen = kFALSE;
01425   }
01426 
01427   //if (sockOpen) {
01428 
01429   if ( gROOT->GetListOfSockets() ) {
01430     //gROOT->GetListOfSockets()->Delete();
01431     gROOT->GetListOfSockets()->ls();
01432     TIter next( gROOT->GetListOfSockets() );
01433     TSocket* socktmp = 0;
01434     while ( ( socktmp = (TSocket*)next() ) ) {
01435       //socktmp->Send("END CONNECTION");
01436       socktmp->Send( DspEndConnection.c_str() );
01437       socktmp->Close();
01438       //gROOT->GetListOfFiles()->Remove(socktmp);
01439       // is called by close
01440     }
01441     //sockOpen = kFALSE;
01442   }
01443 
01444   //InputOpen = kFALSE;
01445 
01446 }
01447 
01448 
01449 
01450 /*
01451 //void HistoDisplay::HistoDisplayMain( TObject *inputobj )
01452 //void HistoDisplay::HistoDisplayMain()
01453 void HistoDisplay::HistoDisplayMain( Int_t autoOpen )
01454 {
01455   //cout << " In HistoDisplayMain" << endl;
01456 
01457   TObject *inputobj = InputObj;
01458 
01459   TPad *padsav = 0;
01460 
01461   if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) )
01462     padsav = (TPad*) gPad;
01463 
01464   TConsumerInfo *info = 0;
01465 
01466   info = MakeConsumerInfo( MonitorName.Data(), "ConsumerInfo.txt" );
01467 
01468   //if ( info ) {
01469   if ( info && autoOpen ) {
01470 
01471     const char *filename = 0;
01472     EInputTypes inputtype;
01473     const char *inputname = ( info->getInputName() ).Data();
01474 
01475     if ( strstr( inputname, "TMapFile:" ) ) {
01476       filename = inputname + strlen( "TMapFile:" );
01477       inputtype = kTMapFile;
01478     } //if ( strstr( info->getInputName(), "TMapFile:" ) ) 
01479     else if ( strstr( inputname, "TFile:" ) ) {
01480       filename = inputname + strlen( "TFile:" );
01481       inputtype = kTFile;
01482     } //else if ( strstr( info->getInputName(), "TFile:" ) ) 
01483     else if ( strstr( inputname, "TSocket:" ) ) {
01484       filename = inputname + strlen( "TSocket:" );
01485       inputtype = kTSocket;
01486     } //if ( strstr( info->getInputName(), "TSocket:" ) ) 
01487     else
01488       cout << " No Consumer " << inputname 
01489            << " in ConsumerInfo.txt." << endl;
01490 
01491     if ( filename ) {
01492       inputobj = OpenFile( filename, inputtype, "READE" );
01493       InputObj = inputobj;
01494     }
01495 
01496   } //if( info && autoOpen )
01497 
01498 
01499 
01500 
01501 
01502   //DelTreeItemsOfInput( inputobj );
01503   AddTreeItemsOfInput( inputobj );
01504   RefreshTreeItem( fHistoListTree->GetFirstItem() );
01505   fClient->NeedRedraw( fHistoListTree );
01506 
01507   if ( padsav ) padsav->cd();
01508 
01509 
01510 }
01511 */
01512 
01513 
01514 TConsumerInfo* HistoDisplay::MakeConsumerInfo( TObject *inputobj ) 
01515 {
01516   //cout << " In Make ConsumerInfo( inputobj ) " << endl;
01517 
01518   if ( !inputobj ) return 0;
01519 
01520   TConsumerInfo *info = 0;
01521   TObject *obj = 0;
01522 
01523   /*
01524   if ( inputobj->InheritsFrom( TMapFile::Class() ) ) {
01525     TMapFile *file = (TMapFile*) inputobj;
01526     obj =  file->Get("ConsumerInfo");
01527   } //if ( inputobj->InheritsFrom( TMapFile::Class() )
01528 
01529   else if ( inputobj->InheritsFrom( TFile::Class() ) ) {
01530     TFile *file = (TFile*) inputobj;
01531     obj =  file->Get("ConsumerInfo");
01532   } //if ( inputobj->InheritsFrom( TFile::Class() ) 
01533 
01534   else if ( inputobj->InheritsFrom( TSocket::Class() ) ) {
01535     TSocket *sock = (TSocket*) inputobj;
01536     if ( sock->IsValid() ) {
01537       //request TConsumerInfo
01538       TMessage *mess;
01539       sock->Send("ConsumerInfo");
01540       sock->Recv(mess);
01541       if ( mess ) {
01542         if ( mess->What() == kMESS_OBJECT) {
01543           obj = mess->ReadObject(mess->GetClass());
01544         } //if ( mess->What() == kMESS_OBJECT)
01545         delete mess;
01546       } //if ( mess )
01547     } //if ( sock->IsValid() )
01548   } //else if ( inputobj->InheritsFrom( TSocket::Class() ) )
01549 
01550   if ( obj && obj->InheritsFrom( TConsumerInfo::Class() ) ) {
01551     info = (TConsumerInfo*)obj;
01552     //info->print();
01553   } //if ( obj && obj->InheritsFrom( TConsumerInfo::Class() ) )
01554   */
01555 
01556 
01557   obj = GetNewObj( "ConsumerInfo", inputobj );
01558 
01559   if ( obj && obj->InheritsFrom( TConsumerInfo::Class() ) ) {
01560     info = (TConsumerInfo*)obj;
01561     //info->print();
01562   } //if ( obj && obj->InheritsFrom( TConsumerInfo::Class() ) )
01563 
01564 
01565 
01566   return info;
01567 }
01568 
01569 
01570 
01571 TConsumerInfo* HistoDisplay::
01572 MakeConsumerInfo( const char *TheConsumerName, const char *filename ) 
01573 {
01574   //cout << " In Make ConsumerInfo( file ) " << endl;
01575   //cout << TheConsumerName << " " << filename << endl;
01576 
01577   //if ( !TheConsumerName || !filename ) return 0;
01578   if ( ( strlen( TheConsumerName ) == 0 ) || !filename ) return 0;
01579 
01580   TConsumerInfo *info = 0;
01581 
01582   const int maxsize = 256;
01583   ifstream infile( filename );
01584 
01585   if ( infile ) {
01586 
01587     do {
01588       char str[ maxsize ];
01589       infile.getline( str, maxsize - 1 );
01590 
01591       // ConsumerInfo --
01592       if ( char *pos = const_cast<char*>(strstr( str, "ConsumerInfo ")) ) {
01593 
01594         char *ConsumerName = 0;
01595         ConsumerName =  getword( pos + strlen( "ConsumerInfo " ) ); 
01596 
01597         if ( !strcmp( ConsumerName, TheConsumerName ) ) {
01598 
01599           //tmp
01600           //cout << " ConsumerName = " << ConsumerName << endl;
01601 
01602           info = new TConsumerInfo( "ConsumerInfo" );
01603 
01604           do {
01605             char str1[ maxsize ];
01606             infile.getline( str1, maxsize - 1 );
01607             // run: --
01608             if ( strstr( str1, "run:" ) ) {
01609               char *runstr = 0;
01610               runstr = getword( str1 + strlen( "run:" ) );
01611 
01612               int runnumber = 0;
01613               if ( runstr ) {
01614                 runnumber = atoi( runstr );
01615                 delete [] runstr;
01616               } //if ( runstr )
01617 
01618               //cout << " runnumber = " << runnumber << endl;
01619               info->setRunNumber( runnumber );
01620 
01621               if ( char *pos = const_cast<char*>(strstr( str1, "number of events:" )) ) {
01622                 char *nevstr = 0;
01623 
01624                 nevstr = getword( pos + strlen( "number of events:" ) );
01625 
01626                 int eventnumber = 0;
01627                 if ( nevstr ) {
01628                   eventnumber = atoi( nevstr );
01629                   delete [] nevstr;
01630                 } //if ( nevstr )
01631 
01632                 //cout << " eventnumber = " << eventnumber << endl;
01633                 info->setNevents( eventnumber );
01634 
01635 
01636               } //if ( char *pos = strstr( str1, "number of events:" ) ) 
01637 
01638             }// if ( strstr( str1, "run:" ) )
01639 
01640             //--
01641             // TMapFile, TFile, TSocket -- 
01642             char *inputname = 0;
01643 
01644             if ( strstr( str1, "TMapFile:" ) ) {
01645 
01646               inputname = getword( str1 + strlen( "TMapFile:" ) ); 
01647               info->setInputName( TString( "TMapFile:" ) +
01648                                   TString( inputname ) );
01649 
01650             }// if ( strstr( str1, "TMapFile:" ) )
01651             else if  ( strstr( str1, "TFile:" ) ) {
01652 
01653               inputname = getword( str1 + strlen( "TFile:" ) ); 
01654               info->setInputName( TString( "TFile:" ) +
01655                                   TString( inputname ) );
01656 
01657             }// else if ( strstr( str1, "TFile:" ) )
01658             else if  ( strstr( str1, "TSocket:" ) ) {
01659 
01660               inputname = getword( str1 + strlen( "TSocket:" ) ); 
01661               info->setInputName( TString( "TSocket:" ) +
01662                                   TString( inputname ) );
01663 
01664             } //else if  ( strstr( str1, "TSocket:" ) ) 
01665 
01666             if ( inputname ) {
01667 
01668               //cout << " InputName = " << inputname << endl;
01669               //info->setInputName( TString( inputname ) );
01670 
01671 
01672               delete [] inputname;
01673             } //if ( inputname )
01674 
01675             //--
01676             // objects: --
01677             if ( strstr( str1, "objects:" ) ) {
01678 
01679               do {
01680                 char str2[ maxsize ];
01681                 infile.getline( str2, maxsize - 1 );
01682 
01683                 if ( str2 && ( strlen( str2 ) > 0 ) 
01684                      && !strstr( str2, "ConsumerInfo" ) ) {
01685 
01686                   char *path = 0;
01687                   char *name = 0;
01688 
01689                   char *pathname = getword( str2 );
01690 
01691                   //if ( pathname && ( *pathname != commentchar ) ) {
01692                   if ( pathname ) {
01693 
01694                     char *begin = str2 + strlen( pathname ) + 1;
01695 
01696                     char *pos = 0;
01697                     while ( ( pos = const_cast<char*>(strchr( pathname, '\"' ) )) && 
01698                             ( strchr( pos + 1, '\"' ) ) ) {
01699                       char *tmp = 0;
01700                       tmp = const_cast<char*>(strdelete( pathname, "\"" ));
01701                       delete [] pathname;
01702                       pathname = strdelete( tmp, "\"" );
01703                       delete [] tmp;
01704                     } // while ( strchr( pathname, '\"') )
01705 
01706 
01707                     if ( char *pos = const_cast<char*>( strrchr( pathname, '/')) ) {
01708                       pos++;
01709 
01710                       name = new char[ strlen( pos ) + 1 ];
01711                       strcpy( name, pos );
01712 
01713                       char tmpchr = *pos;
01714                       *pos = '\0';
01715 
01716                       path = new char[ strlen( pathname ) + 1 ];
01717                       strcpy( path, pathname );
01718 
01719                       *pos = tmpchr;
01720         
01721                     } //if ( path = strrchr( pathname, '/') )
01722                     else {
01723                       path = new char;
01724                       *path = '\0'; // was: path="" < mem leak
01725 
01726                       name = new char[ strlen( pathname ) + 1 ];
01727                       strcpy( name, pathname );
01728 
01729                     } //else //if ( path = strrchr( pathname, '/') )
01730 
01731 
01732                     int status = 999;
01733                     char *statusstr = getword( begin );
01734                     if ( statusstr ) {
01735                       delete [] statusstr;
01736                       status = atoi( statusstr );
01737                     } //if ( statusstr )
01738 
01739                     /*
01740                     cout << " path = " << path 
01741                          << " name = " << name 
01742                          << " status = " << status << endl;
01743                     */
01744                     info->addObject( TString( name ), TString( path ), status );
01745 
01746                     if ( pathname ) {
01747                       delete [] pathname;
01748                       pathname = 0;
01749                     }
01750                     if ( path ) {
01751                       delete [] path;
01752                       path = 0;
01753                     }
01754                     if ( name ) {
01755                       delete [] name;
01756                       name = 0;
01757                     }
01758 
01759 
01760                   } //if ( pathname && ( *pathname != commentchar ) )
01761                 } // if ( str2 && ( strlen( str2 ) > 0 ) )
01762                 else break;
01763 
01764               } while( !infile.eof() ); //str2
01765 
01766 
01767               break;
01768 
01769             } //if ( strstr( str1, "objects:" ) )
01770 
01771             //--
01772 
01773 
01774           } while ( !infile.eof() ); //str1
01775 
01776 
01777           if ( ConsumerName ) delete [] ConsumerName;
01778           break;
01779 
01780         }//if ( !strcmp( ConsumerName, TheConsumerName ) )
01781 
01782       } //if ( strstr( str, "ConsumerInfo") ) 
01783 
01784 
01785     } while ( !infile.eof() ); //str
01786 
01787     infile.close();
01788 
01789     if ( !info ) cout << " No info of " << TheConsumerName 
01790                       << " in " << filename << endl;
01791 
01792   } //if ( infile )
01793   else
01794     cout << " Failed to open file " << filename << endl;
01795 
01796   return info;
01797 
01798 }
01799 
01800 
01801 
01802 
01803 char *getword( char *str , const char commentchar )
01804 {
01805   //cout << " In getword " << endl;
01806 
01807   char *word = 0;
01808 
01809   if ( str && ( strlen( str ) > 0 ) ) {
01810     char *begin = str;
01811     while( isspace( *begin ) && ( *begin != '\0' ) ) begin++;
01812 
01813     //if ( *begin != '\0' ) {
01814     if ( ( *begin != '\0' ) &&
01815          ( *begin != commentchar ) ) {
01816 
01817       char *end = begin;
01818 
01819       //while( !isspace( *end ) ) end++;
01820 
01821       while( !isspace( *end ) ) {
01822         char *tmp = 0;
01823         if ( ( *end == '\"' ) && 
01824              ( tmp = const_cast<char*>(strchr( end + 1 , '\"' )) )  ) end = tmp;
01825         else end++;
01826       }
01827 
01828       char tmpchr = *end;
01829       *end = '\0';
01830  
01831       word = new char[ strlen( begin ) + 1 ];
01832       strcpy( word , begin );
01833 
01834       *end = tmpchr;
01835 
01836     } //if ( *begin != '\0' )
01837 
01838   } // if ( str && ( strlen( str ) > 0 ) )
01839 
01840   return word;
01841 
01842 }
01843 
01844 
01845 char *strdelete( char *str, const char *del )
01846 {
01847   //cout << " In strdelete " << endl;
01848 
01849   char *newword = 0;
01850 
01851   char *pos = 0;
01852   if ( ( pos = const_cast<char*>(strstr( str, del )) ) ) {
01853     newword = new char[ strlen( str ) - strlen( del ) + 1 ];
01854     if ( newword ) {
01855       char tmp = *pos;
01856       *pos = '\0';
01857 
01858       strcpy( newword, str );
01859 
01860       *pos = tmp;
01861 
01862       strcat( newword, pos + strlen( del ) );
01863 
01864     }//if ( newword )
01865   } //if ( pos = strstr( str, del ) )
01866 
01867   return newword;
01868 
01869 }
01870 
01871 
01872 
01873 char* strstrn( const char *s, const char *k ) 
01874 {
01875   const char *pk = k;
01876   const char *ps = 0;
01877 
01878   while ( *s != '\0' ) {
01879     if ( tolower( *s ) == tolower( *pk ) ) {
01880       if ( pk == k ) ps = s;
01881       pk++;
01882       if ( *pk == '\0' ) break;
01883     } //if ( tolower( *ps ) == tolower( *pk ) )
01884     else {
01885       pk = k;
01886       ps = 0;
01887     } //else //if ( tolower( *ps ) == tolower( *pk ) )
01888     s++;
01889   } //while ( *s != '\0' ) 
01890 
01891   return  (char*) ps;
01892 
01893 }
01894 
01895 
01896 
01897 
01898 
01899 void HistoDisplay::MakeHistoList( TObject *inputobj )
01900 {
01901   //cout << " In MakeHistoList " << endl;
01902 
01903   if ( ! inputobj ) return ;
01904 
01905   if ( fHistoList && !( fHistoList->IsEmpty( )) ) fHistoList->Clear();
01906 
01907   if ( inputobj->IsA() == TMapFile::Class() ) {
01908     MakeHistoListM( (TMapFile*) inputobj );
01909   }
01910   else if ( inputobj->IsA() == TFile::Class() ) {
01911     MakeHistoListR( (TFile*) inputobj );
01912   }
01913   else if ( inputobj->IsA() == TSocket::Class() ) {
01914     MakeHistoListS( (TSocket*) inputobj );
01915   }
01916 
01917 }
01918 
01919 void HistoDisplay::MakeHistoListM( TMapFile *MFile )
01920 {
01921   if ( ! MFile ) return ;
01922 
01923   TMapRec *mr = MFile->GetFirst();
01924   while( MFile->OrgAddress(mr) ) {
01925     TString name = mr->GetName();
01926     TObject * obj = 0;
01927     obj = (TObject*)MFile->Get(name.Data(),obj);
01928     if ( obj && obj->InheritsFrom(TH1::Class()) ||
01929          //obj->InheritsFrom(TPad::Class()) ) {
01930          obj->InheritsFrom(TCanvas::Class()) ) {
01931       fHistoList->Add(obj);
01932     }
01933     mr = mr->GetNext();
01934   }
01935 }
01936 
01937 void HistoDisplay::MakeHistoListR( TFile *RFile )
01938 {
01939   if ( ! RFile ) return ;
01940 
01941   TIter next(RFile->GetListOfKeys());
01942   TKey *key;
01943   TObject *obj=0;
01944   while ( ( key = (TKey*)next() )  ) {
01945     obj = (TObject*)RFile->Get(key->GetName());
01946     if ( obj &&  obj->InheritsFrom(TH1::Class()) ||
01947          //obj->InheritsFrom(TPad::Class()) ) {
01948          obj->InheritsFrom(TCanvas::Class()) ) {
01949       fHistoList->Add(obj);
01950     }
01951   }
01952 }
01953 
01954 void HistoDisplay::MakeHistoListS( TSocket *sock )// added FH changed HS
01955 {
01956   if ( ! sock ) return ;
01957 
01958   if ( sock->IsValid() ) {
01959       //request TConsumerInfo
01960       TMessage *mess;
01961       TConsumerInfo *info;
01962       sock->Send("ConsumerInfo");
01963       sock->Recv(mess);
01964       if ( mess ) {
01965       if ( mess->What() == kMESS_OBJECT)
01966         {
01967           info = (TConsumerInfo*)mess->ReadObject(mess->GetClass());
01968           if (!info) {
01969               cerr << "Null info from ReadObject!!!\n";
01970               return;
01971           }
01972           //info->print();
01973           info->updateList(fHistoList,sock);
01974           delete info;
01975         }
01976       delete mess;
01977       }
01978   }
01979 
01980 }
01981 
01982 
01983 
01984 
01985 void HistoDisplay::AddToDisplayedList( const TObject *inputobj )
01986 {
01987   // cout << " In AddToDisplayedList " << endl;
01988 
01989   if ( !inputobj ) return ;
01990 
01991 
01992   if ( fHistoList && !fHistoList->IsEmpty() ) {
01993 
01994     TIter nextList(fHistoList);
01995     TObject *obj = 0;
01996     while ( ( obj = nextList() ) ) {
01997 
01998       //unused:     CObject *coj = UpdateHistoList( obj->GetName(), inputobj );
01999 
02000     }//while ( (obj = nextList()) )
02001 
02002   }//if ( fHistoList && !fHistoList->IsEmpty() )
02003 
02004   //tmp
02005   //fDisplayedList->ls();
02006 
02007 }
02008 
02009 
02010 
02011 
02012 void HistoDisplay::AddToTree( TObject *inputobj )
02013 {
02014   if ( fHistoList && !fHistoList->IsEmpty() ) {
02015 
02016     TIter nextHisto(fHistoList);
02017     TObject *obj = 0;
02018 
02019     while ( (obj = nextHisto()) ) {
02020       TString PathName;
02021       //TString DirPath;
02022 
02023       PathName = GetDirPath( TString(obj->GetName()) ) 
02024         //PathName = "/" + TString( inputobj->GetName() ) 
02025         + "/" + TString(obj->GetName());
02026  
02027       //MakeTGListTree( PathName, inputobj );
02028       MakeTGListTree( PathName, inputobj, obj->GetTitle() );
02029     } //while ( (obj = nextHisto()) )
02030 
02031     fClient->NeedRedraw(fHistoListTree);
02032 
02033   } //if ( fHistoList && !fHistoList->IsEmpty() )
02034 
02035 }
02036 
02037 
02038 
02039 void HistoDisplay::MakeTGListTree( const TString &PathName, 
02040                                    //TObject *inputobj )
02041                                    TObject *inputobj,
02042                                    const char* tip )
02043 {
02044   //cout << " In MakeTGListTree " << endl;
02045 
02046 
02047   while ( PathName.Contains("//") ) {
02048     TRegexp re("//+");
02049     PathName(re) = "/";
02050   }
02051 
02052   //cout << " PathName = " << PathName.Data() << endl;
02053 
02054   const int treemax = 10;
02055 
02056   int index[treemax];
02057 
02058   int PathLength = PathName.Length();
02059 
02060   int ii;
02061   int ind;
02062   for ( ii=0, ind = PathName.Index("/",1,0,TString::kExact) ;
02063         0 <= ind && ind <= PathLength ; ++ii ) {
02064     index[ii] = ind;
02065     ind = PathName.Index("/",1,ind+1,TString::kExact);
02066   }
02067 
02068   int nindex = ii;
02069   index[nindex] = PathLength;
02070 
02071   TString DirName;
02072   TString HistoName;
02073 
02074   TString CurPathName;
02075   TString CurParentName;
02076   TString CurItemName;
02077 
02078 
02079   TGListTreeItem *itemOrg= 0;
02080   itemOrg = fHistoListTree->FindItemByPathname( PathName.Data() );
02081 
02082   //if ( !fHistoListTree
02083   //->FindItemByPathname( PathName.Data() ) ) {
02084 
02085   if ( !itemOrg ) {
02086 
02087     if ( 1 < nindex ) {
02088 
02089       DirName = PathName( 0, index[nindex-1] );
02090       HistoName = PathName( index[nindex-1]+1, index[nindex] );
02091 
02092 
02093       if ( !fHistoListTree
02094           ->FindItemByPathname( DirName.Data() ) ) {
02095 
02096         for ( int i=0 ; i < nindex-1 ; ++i ) {
02097           CurPathName = DirName(0,index[i+1]);
02098 
02099           if ( !fHistoListTree
02100               ->FindItemByPathname( CurPathName.Data() ) ) {
02101 
02102             if ( i==0 ) { 
02103               CurItemName = DirName(index[i]+1,index[i+1]-index[i]-1);
02104               TGListTreeItem *item = 0;
02105               /*              
02106               fHistoListTree
02107                 ->AddItem( 0, CurItemName.Data() )
02108                 ->SetUserData(inputobj);
02109               */
02110               item = fHistoListTree
02111                 ->AddItem( 0, CurItemName.Data() );
02112               if ( item ) {
02113                 item->SetUserData(inputobj);
02114                 //if ( tip ) fHistoListTree->SetToolTipItem( item, tip );
02115               } // if ( item )
02116             } //if ( i==0 )
02117             else {
02118               CurParentName = DirName( 0, index[i]);
02119               CurItemName = DirName(index[i]+1,index[i+1]-index[i]-1);
02120               /*
02121               fHistoListTree
02122                 ->AddItem( fHistoListTree
02123                            ->FindItemByPathname( CurParentName.Data() ),
02124                            CurItemName.Data() )
02125                 ->SetUserData(inputobj);
02126               */
02127               TGListTreeItem *item = 0;
02128               item = fHistoListTree
02129                 ->AddItem( fHistoListTree
02130                            ->FindItemByPathname( CurParentName.Data() ),
02131                            CurItemName.Data() );
02132               if ( item ) {
02133                 item->SetUserData(inputobj);
02134                 //if ( tip ) fHistoListTree->SetToolTipItem( item, tip );
02135               } // if ( item )
02136 
02137             } // else //if ( i==0 )
02138           } // if ( !fHistoListTree...
02139         } //for ( int i=0 ; i < nindex-1 ; ++i )
02140       }//if ( !fHistoListTree...
02141 
02142       /*
02143       fHistoListTree
02144         ->AddItem( fHistoListTree->FindItemByPathname(DirName.Data()),
02145                    HistoName.Data() )
02146         ->SetUserData(inputobj);
02147       */
02148       TGListTreeItem *item = 0;
02149       item = fHistoListTree
02150         ->AddItem( fHistoListTree->FindItemByPathname(DirName.Data()),
02151                    HistoName.Data() );
02152       if ( item ) {
02153         item->SetUserData(inputobj);
02154         if ( tip ) fHistoListTree->SetToolTipItem( item, tip );
02155       } // if ( item )
02156 
02157     } //if ( 1 < nindex ) 
02158     else {
02159 
02160       HistoName = PathName( index[nindex-1]+1, index[nindex] );
02161       /*
02162       fHistoListTree
02163         ->AddItem( 0, HistoName.Data() )
02164         ->SetUserData(inputobj);
02165       */
02166       TGListTreeItem *item = 0;
02167       item = fHistoListTree
02168         ->AddItem( 0, HistoName.Data() );
02169       if ( item ) {
02170         item->SetUserData(inputobj);
02171         if ( tip ) fHistoListTree->SetToolTipItem( item, tip );
02172       } // if ( item )
02173 
02174 
02175     } //else // if ( 1 < nindex )
02176 
02177   } //  if ( !itemOrg ) 
02178   else {
02179     TObject *inputobjOrg = (TObject*) ( itemOrg->GetUserData() );
02180     if ( !inputobj->IsEqual( inputobjOrg ) ) {
02181       itemOrg->SetUserData(inputobj);
02182       if ( tip ) fHistoListTree->SetToolTipItem( itemOrg, tip );
02183     } //if ( !inputobj->IsEqual( inputobjOrg ) ) 
02184 
02185   } //else // if ( !itemOrg )
02186 }
02187 
02188 
02189 
02190 void HistoDisplay::SortTGListTree()
02191 {
02192 
02193   if ( fHistoListTree->GetFirstItem() ) {
02194 
02195   TGListTreeItem *item;
02196   TGListTreeItem **list;
02197   int ichild = 0;
02198   int iparent = 0;
02199 
02200   const int itemmax = 200;
02201   list = new TGListTreeItem* [itemmax];
02202   list[ichild] = fHistoListTree->GetFirstItem();
02203 
02204   do
02205   {
02206     if ( fHistoListTree->SortChildren( list[iparent] ) ) {
02207       if ( (item = list[iparent]->GetFirstChild()) ) {
02208         list[++ichild] = item;
02209         while ( ( item =  list[ichild]->GetNextSibling() )
02210                 && ichild < itemmax ) list[++ichild] = item;
02211       }
02212     }
02213     iparent++;
02214 
02215   } while ( iparent <= ichild && ichild < itemmax );
02216   
02217   delete [] list;
02218 
02219   } //if ( fHistoListTree->GetFirstItem() )
02220 
02221   fClient->NeedRedraw(fHistoListTree);
02222 
02223 }
02224 
02225 
02226 void HistoDisplay::RemoveTGListTree()
02227 {
02228   TGListTreeItem *item;
02229   if ( fHistoListTree ) {
02230     while ( (item = fHistoListTree->GetFirstItem()) ) {
02231       fHistoListTree->DeleteItem( item );
02232     } //while ( (item = fHistoListTree->GetFirstItem()) )
02233     fClient->NeedRedraw(fHistoListTree);
02234     fSelectedItem = 0;
02235   }//if ( fHistoListTree ) 
02236 }
02237 
02238 
02239 void HistoDisplay::
02240 DelTreeItemsOfInput( TObject *inputobj )
02241 {
02242   //cout << " In DelTreeItemsOfInput " << endl;
02243   TGListTreeItem *item = fHistoListTree->GetFirstItem();
02244 
02245   while( item ) {
02246     fHistoListTree->RecursiveDeleteItem( item, inputobj );
02247     item = item->GetNextSibling();
02248   }//while( item )
02249 
02250 }
02251 
02252 /*
02253 void HistoDisplay::AddTreeItemsOfInput( TObject *inputobj ) 
02254 {
02255 //cout << " In AddTreeItemsOfInput " << endl;
02256 
02257   if ( !inputobj ) {
02258     cout << " No input is specified. " << endl;
02259     return;
02260   } //if ( !inputobj )
02261 
02262 
02263   TPad *padsav = 0;
02264 
02265   if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) )
02266     padsav = (TPad*) gPad;
02267 
02268 
02269 
02270   TConsumerInfo *info = MakeConsumerInfo( inputobj );
02271 
02272   if ( info ) {
02273     TIterConsumerInfo nextObjName( info );
02274 
02275     TString objName;
02276     Int_t count = 0;
02277     Int_t countAdded = 0;
02278 
02279     while ( ( objName = nextObjName() ) ) {
02280       //if ( objName.IsNull() || count > 1000 ) break;
02281       if ( objName.IsNull() ) break;
02282 
02283       //tmp
02284       //cout << " objName = " << objName << endl;
02285 
02286       CObject *cobj = UpdateHistoList( objName.Data(), inputobj );
02287       if ( cobj ) {
02288         TString pathname = 
02289           "/" + info->getPath( objName.Data() ) + "/" + objName;
02290         //MakeTGListTree( pathname, inputobj );
02291         MakeTGListTree( pathname, inputobj, cobj->GetTitle() );
02292         countAdded++;
02293       } //if ( cobj )
02294       
02295       count++;
02296     } //while ( objName = nextObjName() )
02297 
02298     if ( countAdded ) {
02299       fClient->NeedRedraw( fHistoListTree );
02300       //fDisplayedList->ls();
02301     } //if ( cout2 )
02302     else
02303       cout << " No object"
02304            << " is found in the input: " 
02305            << inputobj->GetName()
02306            << endl;
02307 
02308     delete info;
02309 
02310   } //if( info )
02311   else {
02312 
02313     //if ( !inputobj ) return;
02314 
02315     MakeHistoList(inputobj);
02316     AddToTree(inputobj);
02317     AddToDisplayedList(inputobj);
02318 
02319   } //else //if( info )
02320 
02321   if ( padsav ) padsav->cd();
02322 
02323 
02324 }
02325 */
02326 
02327 
02328 void HistoDisplay::AddTreeItemsOfInput( TObject *inputobj ) 
02329 {
02330   //cout << " In AddTreeItemsOfInput " << endl;
02331 
02332   if ( !inputobj ) {
02333     cout << " No input is specified. " << endl;
02334     return;
02335   } //if ( !inputobj )
02336 
02337 
02338   TPad *padsav = 0;
02339   if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) )
02340     padsav = (TPad*) gPad;
02341 
02342 
02343   TConsumerInfo *info = MakeConsumerInfo( inputobj );
02344 
02345   if ( info ) {
02346     TIterConsumerInfo nextObjName( info );
02347 
02348     TString objName;
02349     Int_t countAdded = 0;
02350 
02351     while ( ( objName = nextObjName() ) ) {
02352       if ( objName.IsNull() ) break;
02353 
02354       TString pathname = 
02355         "/" + info->getPath( objName.Data() ) + "/" + objName;
02356 
02357       MakeTGListTree( pathname, inputobj );
02358       countAdded++;
02359 
02360     } //while ( objName = nextObjName() )
02361 
02362     if ( countAdded ) {
02363       //fClient->NeedRedraw( fHistoListTree );
02364       //fDisplayedList->ls();
02365     } //if ( cout2 )
02366     else
02367       cout << " No object"
02368            << " is found in the input: " 
02369            << inputobj->GetName()
02370            << endl;
02371 
02372     delete info;
02373 
02374   } //if( info )
02375   else {
02376 
02377     //if ( !inputobj ) return;
02378 
02379     MakeHistoList(inputobj);
02380     AddToTree(inputobj);
02381     AddToDisplayedList(inputobj);
02382 
02383   } //else //if( info )
02384 
02385   if ( padsav ) padsav->cd();
02386 
02387 }
02388 
02389 
02390 
02391 void HistoDisplay::RefreshTreeItem( TGListTreeItem *item ) 
02392 {
02393   //cout << " In RefreshTreeItem " << endl;
02394 
02395 
02396   while ( item ) {
02397 
02398     //tmp
02399     //cout << " item = " << item->GetText() <<endl;
02400 
02401     TGListTreeItem *sibling = item->GetNextSibling();
02402 
02403     TGListTreeItem *parent = item->GetParent();
02404 
02405     TGListTreeItem *firstchild = item->GetFirstChild();
02406 
02407     if ( firstchild ) {
02408 
02409       RefreshTreeItem( firstchild );
02410 
02411     } //if ( firstchild ) 
02412     else {
02413 
02414       TObject *inputobj =
02415         (TObject*)item->GetUserData();
02416 
02417       if ( inputobj ) {
02418 
02419         TPad *padsav = 0;
02420         if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) )
02421           padsav = (TPad*) gPad;
02422       
02423         CObject *cobj = UpdateHistoList( item->GetText(), inputobj );
02424         if ( !cobj ) 
02425           fHistoListTree->DeleteItem( item );
02426         else
02427           fHistoListTree->SetToolTipItem( item, cobj->GetTitle() );
02428 
02429         if ( padsav ) padsav->cd();
02430 
02431       } //if ( inputobj )
02432 
02433     } //else //if ( firstchild )
02434 
02435     item = sibling;
02436 
02437     if ( !item &&
02438          parent && !( parent->GetFirstChild() ) )
02439       fHistoListTree->DeleteItem( parent );
02440 
02441   }  //while ( item ) 
02442 
02443   //fClient->NeedRedraw( fHistoListTree );
02444 
02445 }
02446 
02447 
02448 
02449 
02450 void HistoDisplay::
02451 SearchWarningErrorFolder( TGListTreeItem *item, TObject *socket )
02452 {
02453   //cout << " In SearchWarningErrorFolder " << endl;
02454 
02455   while ( item ) {
02456 
02457     /*
02458       if ( ( strstr( item->GetText(), "warning" ) ||
02459              strstr( item->GetText(), "Warning" ) ||
02460              strstr( item->GetText(), "WARNING" ) ||
02461              strstr( item->GetText(), "error" ) ||
02462              strstr( item->GetText(), "Error" ) ||
02463              strstr( item->GetText(), "ERROR" )  ) &&
02464            ( socket->IsEqual( (TObject*) item->GetUserData() )  )  ) {
02465     */
02466 
02467     if ( ( ( strstrn( item->GetText(), kWarningFolder ) ) ||
02468            ( strstrn( item->GetText(), kErrorFolder ) ) ) &&
02469          //( socket->IsEqual( (TObject*) item->GetUserData() ) ) ) {
02470          ( !strcmp( socket->GetName(), 
02471                     ( (TObject*)item->GetUserData())->GetName() ) ) ) {
02472 
02473         //tmp
02474       //cout << "item->GetText()" << item->GetText() << endl;
02475 
02476 
02477         fHistoListTree->OpenItem( item );
02478 
02479         /*
02480         PopUpSlides( item,
02481                      "WarningErrorCanvas",
02482                      "Warning/Error Canvas" );
02483         */
02484 
02485 
02486         PopUpSlides( item,
02487                      kWarningErrorCanvasName,
02488                      kWarningErrorCanvasTitle );
02489 
02490       } //if ( strstr( item->GetText(), "warning" ) ||
02491 
02492 
02493     TGListTreeItem *sibling = item->GetNextSibling();
02494     TGListTreeItem *firstchild = item->GetFirstChild();
02495 
02496     if ( firstchild ) {
02497 
02498       SearchWarningErrorFolder( firstchild, socket );
02499 
02500     } //if ( firstchild ) 
02501 
02502     item = sibling;
02503 
02504   }  //while ( item ) 
02505 
02506 
02507 
02508 }
02509 
02510 
02511 void HistoDisplay::PopUpSlides( TGListTreeItem *item,
02512 const char *canvasname, const char *canvastitle ) 
02513 {
02514   //cout << " In PopUpWarningSlides " << endl;
02515 
02516   TVirtualPad *padsav = 0;
02517   if ( gPad ) padsav = gPad;
02518 
02519   TCanvas *canvas = 0;
02520 
02521   canvas =
02522     (TCanvas*) 
02523     ( gROOT->GetListOfCanvases()->FindObject( canvasname ) );
02524             
02525   if ( !canvas ) {
02526     canvas = 
02527       new TCanvas( canvasname, canvastitle, 400, 400 );
02528   } //if ( !canvas )
02529 
02530   if ( canvas ) {
02531 
02532     TCanvasImp *canvasimp = canvas->GetCanvasImp();
02533     if ( canvasimp ) canvasimp->Show();
02534 
02535     canvas->Clear();
02536     canvas->cd();
02537 
02538     //if ( fSlideTimer )
02539     if ( fSlideTimer && !fSlideTimer->HasTimedOut() )
02540       fSlideTimer->TurnOff();
02541 
02542     StartSlides( item );
02543 
02544   } // if ( canvas ) 
02545 
02546   if ( padsav ) padsav->cd();
02547 
02548 
02549 }
02550 
02551 
02552 
02553 
02554 
02555 
02556 
02557 
02558 
02559 CObject* HistoDisplay::GetCObjFromListItem( TGListTreeItem *item ) 
02560 {
02561   //cout << " In GetCObjFromListItem " << endl;
02562 
02563   if ( !item ) return 0;
02564 
02565   CObject *cobj = 0;
02566 
02567   //TVirtualPad *padsav = 0;
02568   //if ( gPad && !gROOT->GetListOfCanvases()->IsEmpty() ) padsav = gPad;
02569 
02570 
02571   TObject *obj = fDisplayedList->FindObject( item->GetText() );
02572 
02573   if ( !obj ) {
02574     if ( !item->GetFirstChild() ) {
02575       TObject *inputobj = (TObject*)item->GetUserData();
02576       if ( inputobj ) 
02577         cobj =  UpdateHistoList( item->GetText(), inputobj );
02578 
02579         if ( !cobj ) 
02580           //fHistoListTree->DeleteItem( item );
02581           cout <<  item->GetText() << " is not found." << endl;
02582         else
02583           fHistoListTree->SetToolTipItem( item, cobj->GetTitle() );
02584 
02585     } //if ( !item->GetFirstChild() )
02586   } //if ( !obj ) 
02587   else 
02588     if ( obj->InheritsFrom( CObject::Class() ) ) {
02589       cobj = ( CObject* )obj;
02590       const TObject *inputobj = (TObject*)item->GetUserData();
02591 
02592       if ( cobj->GetInputSource() != inputobj ) {
02593         //tmp
02594         //cout << " inputobj is changed " << endl;
02595         cobj->SetInputSource( inputobj );
02596 
02597       } //if ( cobj->GetInputSource() != inputobj ) 
02598         
02599     } //if ( obj->InheritsFrom( CObject::Class() ) )
02600 
02601 
02602 
02603   //if ( padsav ) padsav->cd();
02604 
02605 
02606   return cobj;
02607 
02608 }
02609 
02610 
02611 
02612 
02613 
02614 
02615 
02616 
02617 
02618 
02619 
02620 
02621 
02622 
02623 void HistoDisplay::DrawHisto( TObject *obj )
02624 {
02625   //cout << " In DrawHisto obj " << endl;
02626 
02627   /*
02628   // For older version of ROOT, this is needed.
02629   static int icount = 0;
02630   if ( !(icount++) || gROOT->GetListOfCanvases()->IsEmpty() ) gPad = 0;
02631   */
02632 
02633   if ( gROOT->GetListOfCanvases()->IsEmpty() ) gPad = 0;
02634 
02635   if ( obj ) {
02636 
02637     //obj->ls();
02638 
02639     TCanvas *CurrentCanvas = 0;
02640 
02641     if ( !gPad ) {
02642       CanvasNumber++;
02643       char *num= new char[3];
02644       sprintf( num, "%d", CanvasNumber );
02645       CurrentCanvas =
02646         new TCanvas( CanvasName + TString( num ),
02647                      CanvasTitle + TString( num ) , 500, 500 );
02648       delete[] num;
02649       CurrentCanvas->cd();
02650     }
02651 
02652 
02653 
02654     TPad *gPadSav = (TPad*)gPad;
02655     CurrentCanvas = gPadSav->GetCanvas();
02656 
02657 
02658     if ( obj->InheritsFrom( CHistogram::Class() ) ) {
02659 
02660       CHistogram *chisto = (CHistogram*) obj;
02661       TH1 *histo = chisto->SubtractedHisto();
02662       //TH1 *histo =  chisto->GetHistoDrawn();
02663 
02664       if ( histo ) {
02665 
02666         TObject *hobj = chisto->GetTObject();
02667 
02668         Option_t *option = 0;
02669         if ( hobj ) option = hobj->GetOption();
02670 
02671         //gPadSav->Clear();
02672         RecursivePadClear( gPadSav );
02673         gPadSav->cd();
02674 
02675 
02676 
02677         TString padname;
02678         TString padtitle;
02679 
02680         if ( gPadSav == CurrentCanvas ) {
02681 
02682           //tmp
02683           /*
02684           CurrentCanvas->SetWindowSize( 500, 500 );
02685           CurrentCanvas->Resize();
02686           */
02687 
02688           if ( strcmp( CurrentCanvas->GetName(),
02689                        kWarningErrorCanvasName ) ) {
02690 
02691           padname = "Canvas_of_" +  TString( histo->GetName() ) ;
02692           if ( fSlideCanvasList->FindObject( CurrentCanvas ) )
02693             //padtitle = "<Slide Canvas>" + TString( histo->GetTitle() );
02694             padtitle = "<Auto Update>" + TString( histo->GetTitle() );
02695           else
02696             padtitle = TString( histo->GetTitle() );
02697           CurrentCanvas->SetName( padname.Data() );
02698           CurrentCanvas->SetTitle( padtitle.Data() );
02699 
02700           } // if ( strcmp( CurrentCanvas->GetName(),
02701 
02702 
02703           //gPadSav->cd();
02704           //DrawTH1( histo, option, gPadSav );
02705           DrawTH1( histo, option, CurrentCanvas );
02706         } //if ( gPadSav == gPadSav->GetCanvas() )
02707         else { 
02708 
02709           padname = "Pad_of_" + TString( histo->GetName() );
02710           padtitle = TString( histo->GetTitle() );
02711 
02712           gPadSav->SetName( padname.Data() );
02713           gPadSav->SetTitle( padtitle.Data() );
02714           //gPadSav->cd();
02715           DrawTH1( histo, option, gPadSav );
02716 
02717           ChangeCanvasNameTitle( CurrentCanvas );
02718 
02719         } // else //if ( gPadSav == gPadSav->GetCanvas() )
02720 
02721 
02722       } //if ( histo )
02723 
02724     } //if ( obj->InheritsFrom( CHistogram::Class() ) ) 
02725 
02726     else if ( obj->InheritsFrom( CObject::Class() ) ) {
02727       CObject *cobj = (CObject*)obj;
02728       TObject *tobj = cobj->GetTObject();
02729 
02730       if ( tobj->InheritsFrom( TPad::Class() ) ) {
02731 
02732         TPad *c2 = (TPad*)tobj;
02733 
02734         //tmp
02735         //cout << " gPadSav->GetName() = " << gPadSav->GetName() << endl;
02736 
02737         gPadSav->cd(); // necessary to prevent bad x window allocation.
02738 
02739         if ( c2 ) {
02740 
02741 
02742           if ( gPadSav == CurrentCanvas ) {
02743             //gPadSav->Clear();
02744             //RecursivePadClear( gPadSav );
02745             gPadSav->cd();
02746 
02747           //tmp
02748           /*
02749             if ( c2->InheritsFrom( TCanvas::Class() ) )
02750               DuplicateCanvasSize( CurrentCanvas, (TCanvas*)c2 );
02751           */
02752 
02753           if ( strcmp( CurrentCanvas->GetName(),
02754                        kWarningErrorCanvasName ) ) {
02755 
02756             CurrentCanvas->SetName( c2->GetName() );
02757             TString padtitle;
02758             if ( fSlideCanvasList->FindObject( CurrentCanvas ) )
02759               //padtitle = "<Slide Canvas>" + TString( c2->GetTitle() );
02760               padtitle = "<Auto Update>" + TString( c2->GetTitle() );
02761             else
02762               padtitle = TString( c2->GetTitle() );
02763             CurrentCanvas->SetTitle( padtitle );
02764 
02765           } // if ( strcmp( CurrentCanvas->GetName(),
02766 
02767 
02768             DrawTPad( c2, gPadSav );
02769 
02770           } //if ( gPadSav == gPadSav->GetCanvas() )
02771           else {
02772             gPadSav->SetName( c2->GetName() );
02773             gPadSav->SetTitle( c2->GetTitle() );
02774             DrawTPad( c2, gPadSav );
02775             ChangeCanvasNameTitle( CurrentCanvas );
02776 
02777           } //else //if ( gPadSav == gPadSav->GetCanvas() ) 
02778 
02779         } //if (c2)
02780 
02781       } //if ( tobj->InheritsFrom( TPad::Class() ) )
02782 
02783     } //else if ( obj->InheritsFrom( CObject::Class() ) ) 
02784 
02785 
02786     //ChangeCanvasNameTitle( CurrentCanvas );
02787 
02788     gPadSav->cd();
02789     /*
02790     gPadSav->Modified();
02791     gPadSav->Update();
02792     */
02793     CurrentCanvas->Modified();
02794     CurrentCanvas->Update();
02795 
02796 
02797     //cout << "Drawing done" << endl << endl;
02798       
02799   } //if (obj)
02800 
02801 
02802 }
02803 
02804 
02805 
02806 void HistoDisplay::DrawHisto( TList *fSelectedList )
02807 {
02808   //cout << " In DrawHisto list " << endl;
02809 
02810   // For older version of ROOT, this is needed.
02811   //static int icount = 0;
02812   if ( gROOT->GetListOfCanvases()->IsEmpty() ) gPad = 0;
02813 
02814     if ( fSelectedList && !fSelectedList->IsEmpty() ) {
02815       int nPad = fSelectedList->GetSize();
02816       int nPadX = (int) sqrt( (float)nPad );
02817       int nPadY = nPadX;
02818 
02819       if ( nPadX*nPadY < nPad ) {
02820         nPadX++;
02821         if ( nPadX * nPadY < nPad ) nPadY++;
02822       } //if ( nPadX*nPadY < nPad ) 
02823 
02824 
02825       // pad size ww,wh--
02826       int ww, wh;
02827       ww = wh = 300;
02828 
02829       TCanvas *CurrentCanvas = 0;
02830 
02831       if ( !gPad ){
02832         CanvasNumber++;
02833         char *num = new char[3];
02834         sprintf( num, "%d", CanvasNumber);
02835         CurrentCanvas =
02836           new TCanvas( CanvasName + TString( num ),
02837                        CanvasTitle + TString( num) , ww * nPadX, wh * nPadY );
02838         delete num;
02839         CurrentCanvas->cd();
02840       }//if (!gPad)
02841       else {
02842         CurrentCanvas = (TCanvas*)gPad->GetCanvas();
02843 
02844         //CurrentCanvas->Clear();
02845         RecursivePadClear( CurrentCanvas );
02846         CurrentCanvas->cd();
02847 
02848         //tmp
02849         /*
02850         CurrentCanvas->SetWindowSize( ww * nPadX, wh * nPadY );
02851         CurrentCanvas->Resize();
02852         */
02853 
02854       }//if (!gPad) else
02855 
02856 
02857       CurrentCanvas->Divide( nPadX, nPadY );
02858 
02859 
02860       int iPad = 0;
02861 
02862       TIter nextList(fSelectedList);
02863 
02864       TObject *obj = 0;
02865       while ( ( obj = nextList() ) ) {
02866         iPad++;
02867 
02868         if ( obj->InheritsFrom( CHistogram::Class() ) ) {
02869 
02870           CurrentCanvas->cd(iPad);
02871 
02872           CHistogram *chisto = (CHistogram*)obj;
02873 
02874           TH1 *histo = chisto->SubtractedHisto();
02875           //TH1 *histo = chisto->GetHistoDrawn();
02876 
02877           if ( histo ) {
02878  
02879             Option_t *option;
02880             option = chisto->GetTObject()->GetOption();
02881 
02882             TPad *gpad = (TPad*)gPad;
02883 
02884             TString padname = "Pad_of_" +  TString( histo->GetName() ) ;
02885             TString padtitle = TString( histo->GetTitle() ) ;
02886 
02887             gpad->SetName( padname.Data() );
02888             gpad->SetTitle( padtitle.Data() );
02889 
02890             DrawTH1(histo, option, gpad);
02891 
02892             gpad->Modified();
02893             gpad->Update();
02894 
02895           } //if( histo )
02896 
02897         } //if ( obj->InheritsFrom( CHistogram::Class() ) )
02898             
02899         else if ( obj->InheritsFrom( CObject::Class() ) ) {
02900 
02901           CObject *cobj = (CObject*)obj;
02902           TObject *tobj = cobj->GetTObject();
02903 
02904           if ( tobj && tobj->InheritsFrom( TPad::Class() ) ) {
02905 
02906             CurrentCanvas->cd(iPad);
02907 
02908             TPad *gpad = (TPad*)gPad;
02909             TPad *c2 = (TPad*)tobj;
02910 
02911             if (c2) {
02912               gpad->SetName( c2->GetName() );
02913               gpad->SetTitle( c2->GetTitle() );
02914 
02915               DrawTPad(c2, gpad);
02916               //gpad->Modified();
02917               gpad->Update();
02918 
02919             } //if (c2)
02920 
02921           } //if ( tobj && tobj->InheritsFrom( TPad::Class() ) )
02922 
02923         } //else if ( obj->InheritsFrom( CObject::Class() ) )
02924 
02925       } // while ( obj = nextList() )
02926 
02927 
02928       ChangeCanvasNameTitle( CurrentCanvas );
02929 
02930 
02931       CurrentCanvas->cd();
02932       CurrentCanvas->Modified();
02933       CurrentCanvas->Update();
02934 
02935       //cout << "Drawing done" << endl << endl;
02936 
02937     } // if ( fSelectedList && !fSelectedList->IsEmpty() )
02938       
02939 
02940 }
02941 
02942 
02943 
02944 
02945 
02946 void HistoDisplay::ChangeCanvasNameTitle( TCanvas *canvas )
02947 {
02948   //cout << " In ChangeCanvasNameTitle " << endl;
02949 
02950   if ( !canvas ) return;
02951 
02952   TList *list = canvas->GetListOfPrimitives();
02953 
02954   Int_t count = 0;
02955   TObject *obj = 0;
02956 
02957 
02958   TString canvasname = "";
02959   TString canvastitle = "";
02960 
02961   /*
02962   const char *name = 0;
02963   name = canvas->GetName();
02964   if ( name && fDisplayedList->FindObject( name ) ) {
02965     count++;
02966     canvasname = name;
02967     canvastitle = canvas->GetTitle();
02968   } //if ( name && fDisplayedList->FindObject( obj ) ) 
02969   */
02970 
02971 
02972   TIter next( list );
02973 
02974   while ( ( obj = next() ) ) {
02975 
02976     const char *name = 0;
02977     name = obj->GetName();
02978 
02979     if ( strstr( name, "Pad_of_" ) )
02980       name = &( name[ strlen( "Pad_of_" ) ] );
02981 
02982     //cout << " name " <<  name << endl;
02983 
02984     if ( name && fDisplayedList->FindObject( name ) ) {
02985       count++;
02986       if ( count == 1 ) {
02987           canvasname = TString( name );
02988           canvastitle = TString( obj->GetTitle() );
02989       } // if ( count == 1 )
02990       else if ( count == 2 ) {
02991         canvasname = canvasname + "__" + TString( name );
02992         canvastitle = canvastitle + ", " + TString( obj->GetTitle() );
02993       } //else if ( count == 2 )
02994       else if ( count == 3 ) {
02995         canvasname = canvasname + "__etc";
02996         canvastitle = canvastitle + ", etc.";
02997       } //else if ( count == 3 )
02998     } //if ( name && fDisplayedList->FindObject( obj ) ) 
02999 
03000   } //while ( obj = next() )
03001 
03002   if ( count ) {
03003     if ( fSlideCanvasList->FindObject( canvas->GetName() ) )
03004       //canvastitle =  "<Slide Canvas>" + canvastitle; 
03005       canvastitle =  "<Auto Update>" + canvastitle; 
03006 
03007     canvas->SetName( canvasname.Data() );
03008     canvas->SetTitle( canvastitle.Data() );
03009   } //if ( count )
03010 
03011 }
03012 
03013 
03014 
03015 void HistoDisplay::DuplicateCanvasSize( TCanvas *guicanvas,
03016                                         TCanvas *consumercanvas )
03017 {
03018   //cout << " In DuplicateCanvasSize " << endl;
03019 
03020   if ( !guicanvas || !consumercanvas ) return;
03021   Int_t ww, wh;
03022 
03023   ww = consumercanvas->GetWindowWidth();
03024   wh = consumercanvas->GetWindowHeight();
03025 
03026   if ( !ww || !wh ) {
03027     ww = consumercanvas->GetWw() + 4;
03028     wh = consumercanvas->GetWh() + 28;
03029   } //if ( !ww || !wh )
03030 
03031   if ( ww && wh ) {
03032     guicanvas->SetWindowSize( ww, wh );
03033     guicanvas->Resize();
03034   } //if ( ww && wh )
03035 
03036 }
03037 
03038 
03039 
03040 
03041 
03042 
03043 
03044 void HistoDisplay::DrawTH1(TH1 *histo, Option_t *option
03045                            , TVirtualPad *BackPad )
03046 {
03047   //cout << " In DrawTH1" << endl;
03048 
03049   if ( !histo || !BackPad ) return;
03050   //BackPad->Clear(); // Done by TH1::Draw()
03051   //RecursivePadClear( BackPad );
03052 
03053   BackPad->cd();
03054 
03055   //histo->Draw(option);
03056 
03057   histo->Draw();
03058   histo->SetDrawOption( option );
03059 
03060   //cout << " End of DrawTH1 " << endl;
03061 
03062 }
03063 
03064 
03065 
03066 
03067 
03068 void HistoDisplay::DrawTPad( TPad *DrawnPad, TVirtualPad *BackPad )
03069 {
03070   //  cout << " In DrawTPad  " << endl;
03071 
03072   if ( !DrawnPad || !BackPad ) return;
03073 
03074   //copy pad attributes
03075   BackPad->Range( DrawnPad->GetX1(), DrawnPad->GetY1(),
03076                   DrawnPad->GetX2(), DrawnPad->GetY2() );
03077   BackPad->SetTickx( DrawnPad->GetTickx() );
03078   BackPad->SetTicky( DrawnPad->GetTicky() );
03079   BackPad->SetGridx( DrawnPad->GetGridx() );
03080   BackPad->SetGridy( DrawnPad->GetGridy() );
03081   BackPad->SetLogx( DrawnPad->GetLogx() );
03082   BackPad->SetLogy( DrawnPad->GetLogy() );
03083   BackPad->SetLogz( DrawnPad->GetLogz() );
03084   BackPad->SetBorderSize( DrawnPad->GetBorderSize() );
03085   BackPad->SetBorderMode( DrawnPad->GetBorderMode() );
03086   DrawnPad->TAttLine::Copy( (TAttLine&)*BackPad );
03087   DrawnPad->TAttFill::Copy( (TAttFill&)*BackPad );
03088   DrawnPad->TAttPad::Copy( (TAttPad&)*BackPad );
03089 
03090 
03091   TList *list = DrawnPad->GetListOfPrimitives();
03092   TIter next( list );
03093   TObject *objInPad;
03094 
03095   //  BackPad->Clear();
03096      RecursivePadClear( BackPad );
03097 
03098 
03099   //  BackPad->cd();
03100 
03101 
03102   while( ( objInPad = next() ) ) {
03103     BackPad->cd(); // this is absolutely necessary in compiled mode.
03104     // and just before Draw(). Learned hard way.
03105     // Seemed not true for newer ROOT version.
03106 
03107     //    objInPad->Print();
03108     gROOT->SetSelectedPad( BackPad ); 
03109     // not BackPad->cd() but this for primitiveList->Add
03110 
03111     // objInPad->DrawClone(); // Best choise to draw all in DrawnPad.
03112     // But does not draw them on additional pad made here.
03113     // Not allowed to change pad size. 
03114 
03115     //  objInPad->Clone()->Draw();
03116 
03117         BackPad->GetListOfPrimitives()
03118       //->Add( objInPad->Clone(), objInPad->GetDrawOption() );
03119         ->Add( objInPad->Clone(), next.GetOption() );
03120 
03121   } // while( objInPad = next() )
03122 
03123   BackPad->Modified();
03124   delete objInPad;
03125 
03126 }
03127 
03128 
03129 void HistoDisplay::RecursivePadClear( TVirtualPad *pad, Option_t *option )
03130 {
03131   //cout << " In RecursivePadClear " << endl;
03132   if ( !pad ) return;
03133   //cout << pad->GetName() << endl;
03134 
03135 
03136   TList *primitivelist = pad->GetListOfPrimitives();
03137   TFrame *frame = pad->GetFrame();
03138 
03139   TIter next( primitivelist );
03140 
03141   TObject *obj;
03142   while ( ( obj = next() ) ) {
03143 
03144       if ( !( obj->TestBit( kCanDelete ) ) &&
03145            !( frame && frame->IsEqual( obj ) ) ) obj->SetBit( kCanDelete );
03146 
03147       if ( obj->InheritsFrom( TPad::Class() )  ) {
03148         TPad *padInside = (TPad*) obj;
03149         RecursivePadClear( padInside, option );
03150       } // if ( obj->InheritsFrom( TPad::Class() )  )
03151 
03152   } //while ( obj = next() )
03153 
03154   pad->Clear( option );
03155 
03156 }
03157 
03158 
03159 
03160 
03161 void HistoDisplay::UpdateTimerOn()
03162 {
03163   //cout << " In UpdateTimerOn " << endl;
03164 
03165   TVirtualPad *currentPad;
03166 
03167   if ( !gPad || ( gROOT->GetListOfCanvases()->IsEmpty() ) )
03168     return;
03169   else
03170     currentPad = gPad;
03171 
03172 
03173   Int_t sleeptime  = 0;
03174 
03175   if ( AutoUpdate ) {
03176 
03177     sleeptime =  atoi( fFrequencyTextBuffer->GetString() );
03178 
03179     if ( fUpdateTimer ) {
03180       fUpdateTimer->SetTime( max( sleeptime, 800 ) );
03181       //cout << " Timer Time = " << fUpdateTimer->GetTime() << endl;
03182 
03183       fUpdateTimer->SetCurrentPad( currentPad );
03184 
03185       Running = kTRUE;
03186 //      fReadFileButton->ChangeBackground(Green);
03187       fUpdateTimer->TurnOn();
03188 
03189       //return;
03190     } //if ( fUpdateTimer )
03191 
03192   } //if ( AutoUpdate )
03193 
03194 
03195   //cout << "Update done" << endl << endl;
03196 
03197 }
03198 
03199 
03200 
03201 Bool_t HistoDisplayUpdateTimer::Notify()
03202 {
03203   //cout << " In HistoDisplayUpdateTimer::Notify " << endl; 
03204   if ( this &&
03205        ( !fHistoDisplay->AutoUpdate ||
03206          !fHistoDisplay->Running ) ) {
03207 
03208     fHistoDisplay->Running = kFALSE;
03209 
03210     TurnOff();   // same as Remove();
03211 
03212     fHistoDisplay->fPauseHistoButton->SetState( kButtonDisabled );
03213     fHistoDisplay->fRestartHistoButton->SetState( kButtonUp );
03214 
03215     fHistoDisplay->fHistoListTree
03216       ->HighlightItem( fHistoDisplay->fSelectedItem );
03217     fHistoDisplay->fClient->NeedRedraw( fHistoDisplay->fHistoListTree );
03218 
03219     //cout << "Update done" << endl << endl;
03220     cout << "Update stopped" << endl << endl;
03221     return kTRUE;
03222   } //if ( this &&
03223 
03224   //fHistoDisplay->UpdateCanvas();
03225   fHistoDisplay->UpdateCanvas( fCurrentPad );
03226   Reset();
03227   return kFALSE;
03228 
03229 }
03230 
03231 
03232 
03233 
03234 //void HistoDisplay::UpdateCanvas() {
03235 void HistoDisplay::UpdateCanvas( TVirtualPad *currentpad ) {
03236 
03237   //  cout << " In UpdateCanvas " << endl;
03238 
03239   if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) ) {
03240 
03241     TCanvas *canvas = 0;
03242     static TObjLink *link = 0;
03243 
03244     TPad *gPadSav = (TPad*) gPad;
03245 
03246     if ( AutoUpdate &&
03247         SlideShowUpdate &&
03248         fSlideCanvasList &&
03249         !( fSlideCanvasList->IsEmpty() ) ) {
03250 
03251       if ( !link ) link = fSlideCanvasList->FirstLink();
03252 
03253       if ( link ) {
03254 
03255         TObject *ocanv = 0;
03256         if ( ( ocanv = link->GetObject() ) &&
03257              ( gROOT->GetListOfCanvases()->FindObject( ocanv ) ) &&
03258              ( ocanv->InheritsFrom( TCanvas::Class() ) ) ) {
03259           canvas = (TCanvas*) ocanv;
03260 
03261           //canvas->cd();
03262           UpdatePad( canvas );
03263 
03264           link = link->Next();
03265         } //if ( ( ocanv = link->GetObject() ) &&
03266         else {
03267           TObjLink *linktmp = link;
03268           link = link->Next();
03269           fSlideCanvasList->Remove( linktmp );
03270           return;
03271         } // else //if ( ( ocanv = link->GetObject() ) &&
03272 
03273       } //if ( link ) 
03274 
03275 
03276     } //if ( AutoUpdate &&
03277     else {
03278 
03279       link = 0;
03280       //canvas = gPad->GetCanvas();
03281 
03282       if ( !currentpad ||
03283            !gROOT->GetListOfCanvases()->FindObject( currentpad ) )
03284         currentpad = gPadSav;
03285 
03286       UpdatePad( currentpad );
03287 
03288       //      canvas = currentpad->GetCanvas();  DP
03289 
03290     } //else //if ( AutoUpdate && 
03291 
03292     /*
03293     if ( canvas ) {
03294       TCanvasImp *canvasimp = canvas->GetCanvasImp();
03295       if ( canvasimp ) canvasimp->Show();
03296     } // if ( canvas ) 
03297     */
03298 
03299     //TPad *gpad = (TPad*) gPad;
03300     //UpdatePad( gpad );
03301 
03302 
03303     delete canvas;
03304     delete link;
03305     //    cout << gROOT->GetListOfCanvases()->GetSize();
03306   
03307 
03308      gPadSav->cd();
03309      // delete gPadSav;
03310   } //if( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) ) 
03311 
03312 
03313 }
03314 
03315 
03316 
03317 
03318 //void HistoDisplay::StartSlides( const TGListTreeItem *selectedItem )
03319 void HistoDisplay::StartSlides( TGListTreeItem */*selectedItem*/ )
03320 {
03321   // cout << " In StartSlides " << endl;
03322   /*
03323   if ( selectedItem &&
03324        selectedItem->GetFirstChild() &&
03325        selectedItem->GetFirstChild()->GetNextSibling() &&
03326        selectedItem->IsOpen() ) {
03327 
03328     //Running = kTRUE;
03329 
03330     fPauseHistoButton->SetState( kButtonUp );
03331     fRestartHistoButton->SetState( kButtonDisabled );
03332   */
03333     /*
03334     //if ( fUpdateTimer && !fUpdateTimer->HasTimedOut() )
03335     if ( fUpdateTimer )
03336       fUpdateTimer->TurnOff();
03337     */
03338   /*
03339     //SlideTimerOn();
03340     SlideTimerOn( selectedItem );
03341 
03342   } //if ( selectedItem &&
03343   */
03344 
03345 }
03346 
03347 
03348 //void HistoDisplay::SlideTimerOn()
03349 //void HistoDisplay::SlideTimerOn( cosnt TGListTreeItem *item )
03350 void HistoDisplay::SlideTimerOn( TGListTreeItem */*item*/ )
03351 {
03352   //  cout << " In SlideTimerOn " << endl;
03353 
03354   //if ( !gPad || ( gROOT->GetListOfCanvases()->IsEmpty() ) ) return;
03355 
03356   /*
03357   Int_t sleeptime  = 0;
03358 
03359   sleeptime =  atoi( fFrequencyTextBuffer->GetString() );
03360 
03361   if ( fSlideTimer ) {
03362 
03363     fSlideTimer->SetTime( max( sleeptime, 2000 ) );
03364     //cout << " Timer Time = " << fSlideTimer->GetTime() << endl;
03365 
03366     //fSlideTimer->SetCurrentItem( fSelectedItem ); 
03367     fSlideTimer->SetCurrentItem( item ); 
03368 
03369     TVirtualPad *pad = 0;
03370     //if ( gPad && !gROOT->GetListOfCanvases()->IsEmpty() ) pad = gPad;
03371     if ( gROOT->GetListOfCanvases()->IsEmpty() ) gPad = 0;
03372     pad = gPad;
03373     fSlideTimer->SetCurrentPad( pad );
03374 
03375 
03376     if ( fUpdateTimer
03377          && ( fUpdateTimer->GetCurrentPad() == gPad )
03378          && !fUpdateTimer->HasTimedOut() )
03379       //if ( fUpdateTimer )
03380       fUpdateTimer->TurnOff();
03381 
03382 
03383 
03384     Running = kTRUE;
03385     fReadFileButton->ChangeBackground(Green);
03386     //  cout << "Button changed to green\n"; 
03387     gClient->NeedRedraw(fReadFileButton);
03388    fSlideTimer->TurnOn();
03389 
03390   } // if ( fSlideTimer ) {
03391 
03392   */
03393 }
03394 
03395 
03396 
03397 Bool_t HistoDisplaySlideTimer::Notify()
03398 {
03399   //cout << " In Notify (Slide Timer ) " << endl;
03400 
03401   if ( this &&
03402        !fHistoDisplay->Running  ) {
03403 
03404     fHistoDisplay->Running = kFALSE;
03405 
03406 
03407   
03408     TurnOff();   // same as Remove();
03409 
03410     fHistoDisplay->fPauseHistoButton->SetState( kButtonDisabled );
03411     fHistoDisplay->fRestartHistoButton->SetState( kButtonUp );
03412 
03413     fHistoDisplay->fHistoListTree
03414       ->HighlightItem( fHistoDisplay->fSelectedItem );
03415     fHistoDisplay->fClient->NeedRedraw( fHistoDisplay->fHistoListTree );
03416 
03417     //cout << "Update done" << endl << endl;
03418     cout << "Slide show stopped" << endl << endl;
03419  
03420 
03421   } //if ( this &&
03422 
03423   //fHistoDisplay->CycleSlides( fCurrentItem );
03424   fHistoDisplay->CycleSlides( fCurrentItem, fCurrentPad );
03425   fHistoDisplay->fReadFileButton->ChangeBackground(fHistoDisplay->Green);
03426   // cout << "Button changed to green\n";
03427    gClient->NeedRedraw(fHistoDisplay->fReadFileButton);
03428   Reset();
03429   return kFALSE;
03430 
03431 }
03432 
03433 
03434 
03435 
03436 //void HistoDisplay::CycleSlides( const TGListTreeItem *currentitem )
03437 void HistoDisplay::CycleSlides( const TGListTreeItem */*currentitem*/,
03438                                 TVirtualPad */*currentpad*/ )
03439 {
03440   //  cout << " In CycleSlides " << endl;
03441 
03442   /*
03443   static TGListTreeItem *item = 0;
03444 
03445   TVirtualPad *padsav = 0;
03446 
03447   if ( !currentitem ) {
03448     Running = kFALSE;
03449     //    fReadFileButton->ChangeBackground(Red);
03450     return;
03451   } //if ( !currentitem ) 
03452 
03453   if ( !item || ( item && ( item->GetParent() != currentitem ) ) ) 
03454     item = currentitem->GetFirstChild();
03455 
03456   if ( item ) {
03457 
03458     //if ( !gROOT->GetListOfCanvases()->IsEmpty() && gPad )
03459     if ( gROOT->GetListOfCanvases()->IsEmpty() ) gPad = 0;
03460     padsav =  gPad;
03461 
03462     //TObject *obj = fDisplayedList->FindObject( item->GetText() );
03463     TObject *obj = GetCObjFromListItem( item );
03464 
03465     if( obj ) {
03466       if ( obj->InheritsFrom( CObject::Class() ) ) {
03467 
03468         const TObject *inputobj = 
03469           ( (CObject*)obj )->GetInputSource();
03470         TObject *cobj = 
03471           UpdateHistoList( item->GetText(), inputobj );
03472 
03473         fHistoListTree->HighlightItem( item );
03474         fClient->NeedRedraw( fHistoListTree );
03475 
03476         if ( currentpad &&
03477              gROOT->GetListOfCanvases()->FindObject( currentpad ) )
03478           currentpad->cd();
03479         else if ( padsav ) {
03480           padsav->cd();
03481           fSlideTimer->SetCurrentPad( padsav );
03482         }
03483 
03484         DrawHisto( cobj );
03485 
03486         if ( padsav ) padsav->cd();
03487 
03488       } //if ( obj->InheritsFrom( CObject::Class() ) )
03489     }//if( obj )
03490 
03491 
03492 
03493     item = item->GetNextSibling();
03494 
03495     if ( !item ) 
03496       if ( AutoUpdate ) item = fSelectedItem->GetFirstChild();
03497       else
03498         Running = kFALSE;
03499     //    fReadFileButton->ChangeBackground(Red);
03500 
03501   } // if ( item )
03502   else {
03503     Running = kFALSE;
03504     // fReadFileButton->ChangeBackground(Red);
03505   } //else //if ( item )
03506 
03507   */
03508 }
03509 
03510 
03511 
03512 
03513 
03514 
03515 void HistoDisplay::UpdatePad( TVirtualPad *pad )
03516 {
03517   //cout << " In UpdatePad " << endl;
03518 
03519   if ( !pad ) return;
03520 
03521   DrawUpdatedPad( pad );
03522   pad->cd();
03523   pad->Modified();
03524   pad->Update();
03525 
03526 }
03527 
03528 
03529 
03530 void HistoDisplay::DrawUpdatedPad( TVirtualPad *currentPad )
03531 {
03532   //  cout << " In DrawUpdatedPad " << endl;
03533 
03534   if ( ! currentPad ) return;
03535 
03536   //if ( currentPad != currentPad->GetCanvas() ) {
03537 
03538     const char *name = currentPad->GetName();
03539 
03540     TObject *objP = fDisplayedList->FindObject( name );
03541  
03542     if ( objP && objP->InheritsFrom( CObject::Class() ) ) {
03543 
03544       const TObject *inputObj = ( (CObject*)objP )->GetInputSource();
03545       CObject *objNew = UpdateHistoList( name, inputObj );
03546 
03547       if ( objNew ) {
03548         TObject *tobj =  objNew->GetTObject();
03549         
03550         if ( tobj->InheritsFrom( TPad::Class() ) ) {
03551            DrawTPad( (TPad*)tobj, currentPad );
03552           //      ReplacePad( (TPad*)tobj, currentPad );
03553            //     cout << "In here - replace pad\n";
03554           //      delete name;
03555          
03556                   return;
03557         } //if ( tobj->InheritsFrom( TPad::Class() ) )
03558        
03559       } //if ( objNew )
03560 
03561     } //if ( objP && objP->InheritsFrom( CObject::Class() ) )
03562 
03563     //} //if ( currentPad != currentPad->GetCanvas() )
03564 
03565 
03566   //TFrame *frame = currentPad->GetFrame();
03567 
03568   TObjOptLink *lnk = (TObjOptLink*)currentPad
03569     ->GetListOfPrimitives()
03570     ->FirstLink();
03571 
03572   while( lnk ) {
03573 
03574     TObject *obj = lnk->GetObject();
03575 
03576     if ( obj->InheritsFrom(TPad::Class()) ) {
03577 
03578       DrawUpdatedPad( (TPad*)obj );
03579         
03580     } //if ( obj->InheritsFrom(TPad::Class()) )
03581 
03582     else {
03583 
03584       if ( obj->InheritsFrom(TH1::Class()) ) {
03585 
03586         TObject *obj2 = fDisplayedList->FindObject(obj->GetName());
03587         
03588         if ( obj2 && obj2->InheritsFrom(CObject::Class()) ) {
03589 
03590           const TObject *inputObj = ((CObject*)obj2)->GetInputSource();
03591 
03592           CObject *objNew = UpdateHistoList(obj2->GetName(), inputObj);
03593 
03594           //objNew->ls();
03595 
03596           if (objNew && objNew->InheritsFrom(CHistogram::Class()) ) {
03597 
03598             //gROOT->SetSelectedPad( currentPad );
03599 
03600             TH1 *histo = (TH1*) (((CHistogram*)objNew)->SubtractedHisto());
03601             //TH1 *histo =  ( (CHistogram*)objNew )->GetHistoDrawn();
03602 
03603             if ( histo ) {
03604 
03605               //tmp
03606               if ( ! currentPad->GetPadPaint() ) {
03607 
03608                 TH1 *histoOld = (TH1*)obj;
03609                 histoOld->Reset();
03610                 histoOld->Add(histo);
03611 
03612                 TAxis *xaxis = histo->GetXaxis();
03613                 if ( xaxis ) {
03614                   char *title = new char[ strlen( xaxis->GetTitle() ) + 1 ];
03615                   strcpy( title, xaxis->GetTitle() ); 
03616                   histoOld->SetXTitle( title );
03617                   delete [] title;
03618                 } //if ( xaxis )
03619                 TAxis *yaxis = histo->GetYaxis();
03620                 if ( yaxis ) {
03621                   char *title = new char[ strlen( yaxis->GetTitle() ) + 1 ];
03622                   strcpy( title, yaxis->GetTitle() ); 
03623                   histoOld->SetYTitle( title );
03624                   delete [] title;
03625                 } //if ( yaxis )
03626                 TAxis *zaxis = histo->GetZaxis();
03627                 if ( zaxis ) {
03628                   char *title = new char[ strlen( zaxis->GetTitle() ) + 1 ];
03629                   strcpy( title, zaxis->GetTitle() ); 
03630                   histoOld->SetZTitle( title );
03631                   delete [] title;
03632                 } //if ( zaxis ) 
03633 
03634                 delete histo;
03635 
03636                 currentPad->Modified();
03637 
03638               } //if ( ! currentPad->GetPadPaint() )
03639               else
03640                 cout << " Pad is being paianted. Not updated. " << endl;
03641 
03642             } //if ( histo ) 
03643 
03644           } //if (objNew && objNew->InheritsFrom(CHistogram::Class()) )
03645 
03646         } //if ( obj2 && obj2->InheritsFrom(CObject::Class()) )
03647 
03648       } //if ( obj->InheritsFrom(TH1::Class()) )
03649 
03650       /*
03651       else if ( !( frame->IsEqual( obj ) ) ) {
03652 
03653       } //else if ( !( frame->IsEqual( obj ) ) )
03654       */
03655 
03656     } //else //if ( obj->InheritsFrom(TPad::Class()) )
03657 
03658    lnk = (TObjOptLink*) ( lnk->Next() );
03659 
03660   } //  while( lnk ) 
03661 
03662   // delete name;
03663 
03664   //  cout << " End of DrawUpdatedPad " << endl;
03665 }
03666 
03667 
03668 
03669 void HistoDisplay::ReplacePad( TVirtualPad *newpad, TVirtualPad *oldpad )
03670 {
03671   // cout << " In ReplacePad " << endl;
03672 
03673   if ( !newpad || !oldpad ) return;
03674 
03675   TFrame *frame = newpad->GetFrame();
03676 
03677   TList *oldPrimitiveList = oldpad->GetListOfPrimitives();
03678   TList *newPrimitiveList = newpad->GetListOfPrimitives(); 
03679 
03680   TIter next( newPrimitiveList );
03681 
03682   TObject *obj;
03683   while( ( obj = next() ) ) {
03684 
03685       TObject *objOld = 
03686         oldPrimitiveList->FindObject( obj->GetName() );
03687       TObject *cobj =
03688         fDisplayedList->FindObject( obj->GetName() );
03689 
03690       if ( obj->InheritsFrom( TPad::Class() ) &&
03691            objOld &&
03692            objOld->InheritsFrom( TPad::Class() ) )
03693 
03694         ReplacePad( (TPad*)obj, (TPad*)objOld );
03695 
03696       else if ( obj->InheritsFrom( TH1::Class() ) 
03697                 && objOld
03698                 && objOld->InheritsFrom( TH1::Class() ) ) {
03699 
03700         TH1 *histo;
03701         TH1 *histoOld = (TH1*)objOld;
03702 
03703         if ( cobj && cobj->InheritsFrom( CHistogram::Class() ) ) {
03704           CHistogram *chisto = (CHistogram*)cobj;
03705           //chisto->SetTObject( obj );
03706           histo = chisto->SubtractedHisto();
03707         } //if ( cobj && cobj->InheritsFrom( CHistogram::Class() ) )
03708         else {
03709           histo = (TH1*)( obj->Clone() );
03710         } //else //if ( cobj && cobj->InheritsFrom( CHistogram::Class() ) )
03711 
03712         if ( histo && histoOld
03713              && ! obj->IsEqual( objOld )  ) {
03714           //tmp
03715           if ( ! oldpad->GetPadPaint() ) {
03716 
03717             histoOld->Reset();
03718             histoOld->Add( histo );
03719 
03720             TAxis *xaxis = histo->GetXaxis();
03721             if ( xaxis ) {
03722               char *title = new char[ strlen( xaxis->GetTitle() ) + 1 ];
03723               strcpy( title, xaxis->GetTitle() ); 
03724               histoOld->SetXTitle( title );
03725               delete [] title;
03726             } //if ( xaxis )
03727             TAxis *yaxis = histo->GetYaxis();
03728             if ( yaxis ) {
03729               char *title = new char[ strlen( yaxis->GetTitle() ) + 1 ];
03730               strcpy( title, yaxis->GetTitle() ); 
03731               histoOld->SetYTitle( title );
03732               delete [] title;
03733             } //if ( yaxis )
03734             TAxis *zaxis = histo->GetZaxis();
03735             if ( zaxis ) {
03736               char *title = new char[ strlen( zaxis->GetTitle() ) + 1 ];
03737               strcpy( title, zaxis->GetTitle() ); 
03738               histoOld->SetZTitle( title );
03739               delete [] title;
03740             } //if ( zaxis ) 
03741 
03742             delete histo;
03743             oldpad->Modified();
03744 
03745           } //if ( ! oldpad->GetPadPaint() )
03746           else
03747             cout << " Pad is being painted. Not updated. " << endl;
03748 
03749         } //if ( histo && histoOld )
03750 
03751       }  //else if ( obj->InheritsFrom( TH1::Class() ) && 
03752 
03753       //tmp
03754       // Should be comment out the following to avoid double TFrames.
03755       else {
03756 
03757         if ( !( frame->IsEqual( obj ) ) ) {
03758 
03759           //tmp
03760           if ( objOld ) {
03761                //&& !obj->IsEqual(objOld) ) {
03762             TObject *objtmp = oldPrimitiveList->Remove( objOld );
03763             if ( objtmp ) delete objOld;
03764           } //if ( objOld ) 
03765 
03766           oldpad->cd();
03767           obj->Clone()->Draw();
03768           oldpad->Modified();
03769 
03770         } //if ( !( frame->IsEqual( obj ) ) )
03771 
03772       } //else //if ( obj->InheritsFrom( TPad::Class() ) &&
03773 
03774   } //while ( obj = next() )
03775 
03776 
03777 }
03778  
03779 
03780 
03781 
03782 
03783 
03784 
03785 void HistoDisplay::ClearCurrentPad() {
03786 
03787   //cout << " In ClearCurrentPad " << endl; 
03788 
03789   //TPad *padsav = (TPad*) gPad;
03790   TPad *pad = (TPad*)gROOT->GetSelectedPad();
03791 
03792   if ( !pad ) return;
03793 
03794   //pad->Clear();
03795   RecursivePadClear( pad );
03796   pad->cd();
03797 
03798   
03799   /*
03800     if ( pad != pad->GetCanvas() ) {
03801     pad->SetName("VOID");
03802     }
03803   */
03804   pad->SetName("VOID");
03805 
03806   pad->SetTitle("Cleared");
03807 
03808   pad->Modified();
03809   pad->Update();
03810   //padsav->cd();
03811 
03812   //cout << "Cleared " << endl;
03813 
03814 }
03815 
03816 
03817 
03818 
03819 
03820 
03821 CObject* HistoDisplay::
03822 UpdateHistoList(const char* objName, const TObject *inputobj )
03823 {
03824   //cout << " In UpdateHistoList " << endl;
03825   //cout << " updating " << objName << endl;
03826 
03827   /*
03828   if ( !inputobj ) {
03829     cout << " Input Object is not set. " << endl; 
03830     return 0;
03831   }
03832   */
03833 
03834   //const char *path = gROOT->GetPath(); 
03835   TVirtualPad *padsav = 0;
03836   if ( gPad && !gROOT->GetListOfCanvases()->IsEmpty() ) padsav = gPad;
03837 
03838 
03839 
03840   TObject *obj = GetNewObj( objName, inputobj );
03841   CObject *cobj = 0; 
03842 
03843   if ( obj ) {
03844 
03845     TObject *objold = fDisplayedList->FindObject( objName );
03846 
03847     /*
03848     TObjLink *lnk = fDisplayedList->FirstLink();
03849     while (lnk) {
03850       TObject *objtmp = lnk->GetObject();
03851       if (objtmp && 
03852           objtmp->GetName() && !strcmp(objName, objtmp->GetName())) {
03853 
03854         if ( objtmp->InheritsFrom( CObject::Class() ) ) {
03855           CObject *cobjtmp = (CObject*)objtmp;
03856           TObject *inputtmp = cobjtmp->GetInputSource();
03857           if ( ( inputtmp && inputtmp->GetName() ) &&
03858                ( inputobj && inputobj->GetName() ) &&
03859                ( !strcmp( inputtmp->GetName(),
03860                           inputobj->GetName() ) ) ) {
03861             //objold = objtmp;
03862             cobj = cobjtmp;
03863             cobj->SetTObject( obj );
03864             if ( cobj->GetInputSource() != inputobj )
03865               cobj->SetInputSource( inputobj );
03866               
03867           } //if ( ( inputtmp && inputtmp->GetName() ) &&
03868 
03869 
03870         }//if ( objtmp->InheritsFrom( CObject::Class() ) ) 
03871 
03872 
03873       } //if ( objtmp && objtmp->GetName() && ... )
03874 
03875       lnk = lnk->Next();
03876     } //while (lnk) 
03877 
03878     */
03879 
03880 
03881     if ( objold && objold->InheritsFrom( CObject::Class() ) ) {
03882 
03883       cobj = (CObject*) objold;
03884 
03885       if ( cobj ) {
03886         cobj->SetTObject( obj );
03887         //if ( cobj->GetInputSource() != inputobj )
03888         if ( inputobj != cobj->GetInputSource()  ) {
03889           cobj->SetInputSource( inputobj );
03890           //tmp
03891           //cout << " InputObj is updated. " << endl;
03892         } // if ( inputobj != cobj->GetInputSource()  )  
03893       } // if ( cobj )
03894 
03895     } //if ( objold && objold->InheritsFrom( CObject::Class() ) )
03896 
03897     else {
03898 
03899       //if ( !cobj ) {
03900 
03901       if ( obj->InheritsFrom(TH1::Class()) ) {
03902 
03903         CHistogram *cobjnew =
03904           new CHistogram( (TH1*)obj, inputobj, 0, 0 );
03905 
03906                         fDisplayedList->Add( cobjnew );
03907 
03908         cobj = cobjnew;
03909 
03910       } //if ( obj->InheritsFrom(TH1::Class()) )
03911       else {
03912 
03913         CObject *cobjnew =
03914           new CObject( obj, inputobj );
03915 
03916                         fDisplayedList->Add( cobjnew );
03917 
03918         cobj = cobjnew;
03919 
03920       } // else //if ( obj->InheritsFrom(TH1::Class()) )
03921 
03922       //} // if ( !cobj ) 
03923 
03924 
03925     } //else //if ( objold && objold->InheritsFrom( CObject::Class() ) )
03926 
03927         if ( obj->InheritsFrom( TPad::Class() ) )
03928         AddPadHistosToHistoList( (TPad*)obj );
03929 
03930   } //if ( obj )
03931 
03932   else {
03933 
03934     //tmp
03935     /*
03936     if ( objold && objold->InheritsFrom( CObject::Class() ) ) 
03937       cobj = (CObject*) objold;
03938     */
03939     //tmp
03940     //cout << " obj is not got from the input stream. " << endl;
03941 
03942   } //else //if(obj)
03943 
03944   //tmp
03945   if ( !cobj ) cout << " Not updated. " << endl;
03946 
03947 
03948   //gROOT->Cd( path );
03949   if ( padsav ) padsav->cd(); 
03950 
03951 
03952   return cobj;
03953 
03954 }
03955 
03956 
03957 
03958 void HistoDisplay::AddPadHistosToHistoList( TPad *pad )
03959 {
03960   //cout << " In AddPadHistosToHistoList " << endl; 
03961 
03962   if ( !pad ) return;
03963 
03964   TObjLink *link = pad->GetListOfPrimitives()->FirstLink();
03965 
03966   while ( link ) {
03967 
03968     TObject *obj = link->GetObject();
03969 
03970     if ( obj ) {
03971 
03972       if ( obj->InheritsFrom( TPad::Class() ) ) 
03973         AddPadHistosToHistoList( (TPad*)obj ); 
03974 
03975       else if ( obj->InheritsFrom( TH1::Class() ) ) {
03976 
03977         TObject *objold = fDisplayedList->FindObject( obj->GetName() );
03978 
03979         if ( objold && objold->InheritsFrom( CObject::Class())  ) {
03980 
03981           CObject *cobj = (CObject*)objold;
03982           //cobj->SetTObject( obj );
03983           cobj->SetTObject( obj->Clone() );
03984 
03985         } //if ( objold && objold->InheritsFrom( CObject::Class()) )
03986         else {
03987 
03988           CHistogram *cobjnew =
03989             //new CHistogram( (TH1*)obj, 0, 0, 0 );
03990             new CHistogram( (TH1*)obj->Clone(), 0, 0, 0 );
03991 
03992                   fDisplayedList->Add( cobjnew );
03993 
03994         } //else //if ( objold && objold->InheritsFrom( CObject::Class()) ) )
03995 
03996       } //else if ( obj->InheritsFrom( TH1::Class() ) )
03997 
03998     } //if ( obj ) 
03999 
04000     link = link->Next();
04001 
04002   } //while ( link )
04003 
04004   //cout << " End of AddPadHistosToHistoList " << endl; 
04005 
04006 }
04007 
04008 
04009 
04010 TObject* HistoDisplay::
04011 GetNewObj(const char* objName, const TObject* inputobj)
04012 {
04013   //cout << " In GetNewObj" << endl;
04014 
04015   TObject *obj = 0;
04016 
04017   if (inputobj) {
04018 
04019     if ( inputobj->IsA() == TMapFile::Class() )   {
04020       TMapFile *mfile = (TMapFile*)inputobj;
04021       if (mfile) obj = (TObject*)mfile->Get( objName );
04022     }
04023     else if ( inputobj->IsA() == TFile::Class() )   {
04024       TFile *rfile = (TFile*)inputobj;
04025       if (rfile) obj = (TObject*)rfile->Get( objName );
04026     }
04027     else if ( inputobj->IsA() == TSocket::Class() )   {
04028       TSocket *socket = (TSocket*)inputobj;
04029 
04030       if ( socket && socket->IsValid() ) {
04031 
04032         Int_t count = 0;
04033         Int_t maxcount = 8; 
04034 
04035         while ( !obj && count < maxcount ) {
04036 
04037           socket->Send( objName );
04038           TMessage *message = NULL;
04039 
04040           Int_t resRecv;
04041           resRecv = socket->Recv(message);
04042           //cout << "resRecv: " << resRecv << endl;
04043           if (resRecv == -1) {
04044             cerr << " HistoDisplay: ERROR:"
04045                  << " Socket->Receive failed. resRecv = " << resRecv << ".\n" 
04046                  << "    ==> Closing the socket connection." << ".\n"
04047                  << "    ==> Please open again. "
04048                  << endl;
04049             socket->Close();
04050             Running = kFALSE;
04051             fReadFileButton->ChangeBackground(Red);  
04052             //  cout << "Button changed to red\n";
04053             gClient->NeedRedraw(fReadFileButton);
04054             count = maxcount;      // Stop the request loop
04055           } //if (resRecv == -1)
04056           else {
04057             if (message) {
04058               if (message->What() == kMESS_OBJECT) {
04059                 obj = (TObject*)message->ReadObject(message->GetClass());
04061                 // The following was added: //2001/01/16 Wolfgang Wagner
04062                 if (obj) {
04063                   if (TString(obj->GetName()) != TString(objName))
04064                     cerr << "ERROR: Got object: " << obj->GetName()
04065                           << " but requested " << objName << "." << endl;
04066                 }
04068               }
04069               else {
04070                 if (message->What() == kMESS_STRING) {          
04071                   int messLength = message->BufferSize() + 10; 
04072                   char* keyString = new char[messLength];
04073                   message->ReadString(keyString,messLength);                  
04074                   string serverString(keyString);
04075                   delete keyString;
04076                   keyString = 0;
04077                   // We got a message string from Display Server 
04078                   // indicating a special request.
04079                   // Now we need to decode the string.
04080                   // The key strings are defined in ServerProtocol.hh
04081                   //
04082                   bool localDebug = false;
04083                   if (localDebug) {
04084                     cout << "HistoDisplay: got string: " << serverString
04085                          << "." << endl;
04086                   } 
04087                   if (serverString == DspEndConnection) {
04088                     cout << "HistoDisplay: The Display Server ended the "
04089                          << "connection." << endl;
04090                     count = maxcount;
04091                     socket->Close();
04092                     Running = kFALSE;
04093                     fReadFileButton->ChangeBackground(Red); 
04094                     // cout << "Button changed to red\n";            
04095                     gClient->NeedRedraw(fReadFileButton);
04096                     fChButtonSlideUpdate->SetState(kButtonUp);
04097                     SlideShowUpdate = kFALSE;
04098                   }
04099                   if (serverString == DspObjectNotFound) {
04100                     cerr << "HistoDisplay: The requested object '"
04101                          << objName << "' is not available from the "
04102                          << endl;
04103                     cerr << "Display Server." << endl;
04104                     count = maxcount;                      
04105                   }
04106                   if (serverString == DspRequestNewInfo) {
04107                     if (localDebug) {
04108                       cout << "HistoDisplay: The Display Server suggests "
04109                            << "to request the TConsumerInfo." << endl;
04110                     }  
04111                     //TConsumerInfo* locInfo = MakeConsumerInfo(socket); 
04112                     //DelTreeItemsOfInput( socket );
04113                     AddTreeItemsOfInput( socket );
04114                     RefreshTreeItem( fHistoListTree->GetFirstItem() );
04115                     SearchWarningErrorFolder
04116                       ( fHistoListTree->GetFirstItem(), socket );
04117                     fClient->NeedRedraw( fHistoListTree );
04118                   }
04119                 } 
04120               }
04121             }
04122           } //else //if (resRecv == -1)
04123 
04124           delete message;
04125           count++;
04126         } //while ( !obj && count < maxcount )
04127 
04128         if ( ! obj ) {
04129           cout << " Failed to get " << objName << endl;
04130         fReadFileButton->ChangeBackground(Red);
04131         gClient->NeedRedraw(fReadFileButton);
04132         fChButtonSlideUpdate->SetState(kButtonUp);
04133         SlideShowUpdate = kFALSE;
04134         //      cout << "Button changed to red\n";
04135         } //if ( ! obj )
04136         else {
04137           if ( count > 1 ) cout << " The object " << objName 
04138                                 << " is sent from the socket by " << count
04139                                 << " tries." << endl;
04140         } //else of if ( ! obj )
04141 
04142       } //if ( socket && socket->IsValid() )
04143       else {
04144         cout << "no connection to socket..."
04145              << socket->GetName() << endl;
04146         Running = kFALSE;
04147         fReadFileButton->ChangeBackground(Red);
04148         gClient->NeedRedraw(fReadFileButton);
04149         fChButtonSlideUpdate->SetState(kButtonUp);
04150         SlideShowUpdate = kFALSE;
04151         //   cout << "Button changed to red\n";
04152       } //else //if ( socket && socket->IsValid() )
04153 
04154     } // TMapFile,TFile, TSocket 
04155     else {
04156 
04157       cout << " No inputobj " << endl;
04158 
04159     } //else // TMapFile,TFile, TSocket
04160 
04161   } // if(inputobj)
04162 
04163   //tmp
04164   //if ( !obj ) cout << " No object found " << endl;
04165 
04166   return obj;
04167 
04168 }
04169 
04170 
04171 
04172 
04173 
04174 
04175 
04176 void HistoDisplay::AddSubtractHisto( TVirtualPad *currentPad , int option)
04177 {
04178   // Zero or Restore all histos on the currentPad.
04179   // int option = 0    ; unzero
04180   //            = else ;   zero 
04181 
04182   // cout << " In AddSubtractHisto" << endl;
04183 
04184   if (!currentPad) return;
04185 
04186   TList *primitiveList = currentPad->GetListOfPrimitives();
04187   TIter next(primitiveList);
04188   TObject *obj = 0;
04189 
04190   while ( ( obj = next() ) ) {
04191     if ( obj->InheritsFrom(TPad::Class()) ) {
04192 
04193       AddSubtractHisto( (TPad*)obj , option);
04194 
04195     } //if ( obj->InheritsFrom(TPad::Class()) )
04196     else {
04197 
04198       if ( obj->InheritsFrom(TH1::Class()) ) {
04199 
04200         TObject *obj2 = 
04201           fDisplayedList->FindObject(obj->GetName());
04202 
04203         if( obj2 && obj2->InheritsFrom(CHistogram::Class()) ) {
04204 
04205           CHistogram *chisto = (CHistogram*)obj2;
04206           TH1 *histo = (TH1*) chisto->GetTObject();
04207 
04208           if (option) {
04209             if (histo) chisto->SetSubtractHisto( histo );
04210           } //if (option)
04211           else {
04212             chisto->SetSubtractHisto(0);
04213           } //else //if (option)
04214 
04215 
04216         }//if( obj2 && obj2->InheritsFrom(CHistogram::Class()) )
04217 
04218 
04219       } //if ( obj->InheritsFrom(TH1::Class()) )
04220 
04221 
04222     } //else//if ( obj->InheritsFrom(TPad::Class()) )
04223 
04224 
04225   } //while ( obj = next() )
04226 
04227 }
04228 
04229 
04230 
04231 TH1* HistoDisplay::HistoInPad( TVirtualPad *pad, Int_t &counthisto ) 
04232 {
04233   //cout << " In HistoInPad " << endl;
04234 
04235   if ( !pad ) return 0;
04236 
04237   TList *primitiveList = pad->GetListOfPrimitives();
04238   TIter next( primitiveList );
04239 
04240   TH1 *histo = 0;
04241 
04242   TObject *obj;
04243   while ( ( obj = next() ) && ( counthisto <= 1 ) ) {
04244 
04245     if ( obj->InheritsFrom( TH1::Class() ) ) {
04246       counthisto++ ;
04247       if ( counthisto == 1 ) histo = (TH1*)obj;
04248     } //if ( obj->InheritsFrom( TH1::Class() ) )
04249 
04250     if ( obj->InheritsFrom( TPad::Class() ) )
04251       histo = HistoInPad( (TPad*)obj , counthisto );
04252 
04253   } //while ( ( obj = next() ) && ( counthisto <= 1 ) )
04254 
04255   if ( counthisto >= 2 ) return 0;
04256 
04257   return histo;
04258 
04259 }
04260 
04261 
04262 
04263 
04264 void HistoDisplay::DrawContentHisto(TH1* histo)
04265 {
04266   //cout << " In DrawContentHisto" << endl;
04267   if ( !histo ) return;
04268 
04269   DrawOnTheCanvas( "ContentHistoCanvas", "Bin-Content Histogram Canvas",
04270                    300, 300,
04271                    ContentHisto(histo) ) ;
04272 }
04273 
04274 
04275 
04276 TH1F* HistoDisplay::ContentHisto( TH1* histo )
04277 {
04278   //cout << " In ContentHisto" << endl;
04279   if (!histo) return 0;
04280 
04281   float min, max;
04282   min = histo->GetMinimum();
04283   max = histo->GetMaximum();
04284 
04285   if ( min == max ) return 0;
04286 
04287   int nbin;
04288   nbin = 50;
04289   float binsize;
04290   binsize = (max - min)/nbin;
04291 
04292   TH1F* contenthisto = 
04293     new TH1F("BinContenHisto", histo->GetTitle(), nbin,
04294             min - 2*binsize, max + 2*binsize );
04295   // oldone is removed by canvas->Clear() in DrawOntheCanvas.
04296 
04297   contenthisto->SetXTitle("Hits in a bin");
04298   contenthisto->SetYTitle("Number of bins");
04299 
04300   Int_t nbinsx = histo->GetNbinsX();
04301   Int_t nbinsy = histo->GetNbinsY();
04302   Int_t nbinsz = histo->GetNbinsZ();
04303 
04304 
04305    Int_t bin, binx, biny, binz;
04306    double content;
04307    for (binz=0;binz<=nbinsz+1;binz++) {
04308      for (biny=0;biny<=nbinsy+1;biny++) {
04309        for (binx=0;binx<=nbinsx+1;binx++) {
04310             bin = binx +(nbinsx+2)*(biny + (nbinsy+2)*binz);
04311             content = histo->GetBinContent(bin);
04312             if (content) contenthisto->Fill(content);
04313        }
04314      }
04315    }
04316 
04317    return contenthisto;
04318 }
04319 
04320 
04321 void HistoDisplay::DrawOnTheCanvas(
04322  const char* canvasname, const char* canvastitle, int padx, int pady, 
04323  TObject *obj )
04324 {
04325   //cout << " In DrawOnTheCanvas" << endl;
04326   if (!obj) return;
04327 
04328   TPad *padsav  = (TPad*)gPad;
04329 
04330   TCanvas *canvas;
04331 
04332   canvas = 
04333     (TCanvas*) ( gROOT->GetListOfCanvases()->FindObject( canvasname ) );
04334 
04335   if (!canvas) {
04336     canvas = new TCanvas( canvasname, canvastitle, padx, pady);
04337   }
04338   else {
04339     //canvas->SetWindowSize( padx, pady);
04340     canvas->cd();
04341     canvas->Clear();
04342   } //if (!canvas)
04343 
04344   obj->Draw();
04345 
04346   canvas->Modified();
04347   canvas->Update();
04348 
04349   padsav->cd();
04350 
04351 }
04352 
04353 
04354 
04355 void HistoDisplay::PrintCanvas( TPad *canvas )
04356 {
04357   //cout << " In PrintCanvas " << endl;
04358   // From TGTextEdit.cxx
04359     Int_t ret;
04360     static char *gPrinter = 0;
04361     static char *gPrintCommand = 0;
04362 
04363     if (!gPrinter) {
04364       //gPrinter = StrDup(""); // use gEnv
04365       //gPrintCommand = StrDup("lpr");
04366       gPrinter = StrDup("157-ept7-hp"); // use gEnv
04367       gPrintCommand = StrDup("xprint -h -P");
04368     } //if (!gPrinter)
04369 
04370     //unused    TGPrintDialog *printdialog =
04371     //      new TGPrintDialog( fClient->GetRoot(), this, 400, 150,
04372     //          &gPrinter, &gPrintCommand, &ret );
04373 
04374     if ( ret ) {
04375       if ( canvas ) {
04376 
04377         const char *canvasname = canvas->GetName();
04378 
04379         char *msg = 0;
04380         if ( strlen( gPrinter ) ) {
04381           /*
04382           msg = new char[ strlen( gPrintCommand ) + 3 + strlen( gPrinter ) 
04383                         + 1 + strlen( canvasname ) + 4 + 1 ];
04384           sprintf( msg, "%s -P%s %s.ps\n", gPrintCommand,
04385                    gPrinter, canvasname );
04386           */
04387           msg = new char[ strlen( gPrintCommand ) + 1 + strlen( gPrinter ) 
04388                         + 1 + strlen( canvasname ) + 6 + 1 ];
04389           sprintf( msg, "%s %s \"%s.ps\"\n", gPrintCommand,
04390                    gPrinter, canvasname );
04391 
04392         } //if ( gPrinter )
04393         else {
04394           msg = new char[ strlen( gPrintCommand )
04395                         + 1 + strlen( canvasname ) + 6 + 1 ];
04396           sprintf( msg, "%s \"%s.ps\"\n", gPrintCommand, canvasname );  
04397         } //else //if ( gPrinter ) 
04398 
04399 
04400         canvas->Print( 0, "ps" );
04401 
04402         cout << msg << endl;
04403         gSystem->Exec( msg );
04404 
04405         if ( msg ) delete [] msg;
04406 
04407       } //if ( canvas )
04408     } //if (ret)
04409 
04410     // do not need delete printdialog
04411     // because done by closing the windown.
04412 }
04413 
04414 
04415 void HistoDisplay::CloseWindow()
04416 {
04417   gApplication->Terminate(0);
04418 
04419 }
04420 
04421 void HistoDisplay::ResetObjects()
04422 {
04423   //cout << " In ResetObjects " << endl;
04424 
04425   RemoveTGListTree();
04426 
04427   if ( fDisplayedList ) fDisplayedList->Delete();
04428 
04429   CloseConnection();
04430 }
04431 
04432 
04433 HistoDisplay::~HistoDisplay()
04434 {
04435 
04436   ResetObjects();
04437 
04438   delete fHistoList;
04439   delete fDisplayedList;
04440   delete fSlideCanvasList;
04441 
04442   delete fUpdateTimer;
04443   delete fSlideTimer;
04444 
04445   CloseMenuBar();
04446   CloseTitleFrame();
04447   CloseTGListTreeFrame();
04448   CloseInputFrame();
04449   CloseStatusBar();
04450 
04451   delete fMainFrame;
04452   delete fMainFrameLayout;
04453 }
04454 
04455 
04456 void HistoDisplay::MenuConnectStatus()
04457 {
04458 
04459         TGTransientFrame *fTransientFrame;
04460         fTransientFrame =
04461           new TGTransientFrame(gClient->GetRoot(), this, 500, 200);
04462         TGLayoutHints *fLayout;
04463         fLayout =
04464           new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0);
04465 
04466         TGTextView *fTextView;
04467         fTextView =
04468           new TGTextView( fTransientFrame, 600, 200);
04469                           //,kSunkenFrame | kDoubleBorder );
04470 
04471         TString StatusTxt = "\n";
04472         consumerlist->readWebPage();
04473         ostrstream ostr;
04474         consumerlist->print(ostr);
04475         ostr << ends;
04476         StatusTxt.Append(ostr.str());
04477 
04478 
04479         if ( fTextView->LoadBuffer( StatusTxt.Data() ) ) {
04480           fTextView->MapWindow();
04481         }
04482         else {
04483           cout << " Failed to load Socket status text info."  << endl;
04484         }
04485 
04486         fTransientFrame->AddFrame(fTextView,fLayout);
04487         fTransientFrame->SetWindowName("Connection Status");
04488         fTransientFrame->MapSubwindows();
04489         fTransientFrame->MapWindow();
04490 
04491 }
04492 
04493 
04494 //Help menu contents modified by Koji (2000/04/19)
04495 
04496 void HistoDisplay::MenuHelp(const char *s, const char *helpText)
04497 {
04498   //cout << " In MenuHelp " << endl;
04499 
04500   TRootHelpDialog  *fHelpDialog;
04501   fHelpDialog =
04502     new TRootHelpDialog( this, s, 500, 400);
04503   {
04504     fHelpDialog->SetText(helpText);
04505     fHelpDialog->Popup();
04506   }
04507 }
04508 
04509 void HistoDisplay::MessageBox(const char *msg)
04510 {
04511   //cout << " In MessageBox " << endl;
04512 
04513         int retval;
04514 
04515         EMsgBoxIcon icontype = kMBIconExclamation;
04516         //Int_t buttons = kMBOk;
04517         int buttons = kMBOk;
04518 
04519         new TGMsgBox(fClient->GetRoot(), this, "WARNING", msg, 
04520                      icontype, buttons, &retval);
04521 }
04522 
04523 
04524 // Choose File Name buttons. --
04525 
04526 const char* HistoDisplay::FileDialogWindow()
04527 { 
04528 
04529   //const char *filetypes[] = { "All files",     "*",
04530   //                  "ROOT files",    "*.root",
04531   //                  "MAP files",     "*.map",
04532   //                  0,               0 };
04533 
04534 
04535   static TGFileInfo fi;
04536   //fi.fFileTypes = (char **)filetypes;
04537 
04538 
04539   //EInputTypes inputtype;
04540 
04541   if ( fRaButMFile->GetState() == kButtonDown ) {
04542     //inputtype = kTMapFile;
04543     const char* filetypes[] = { "MAP files",     "*.map",
04544                     "All files",     "*",
04545                     "ROOT files",    "*.root",
04546                     0,               0 };
04547     fi.fFileTypes = (const char **)filetypes;
04548   }
04549   else if ( fRaButRFile->GetState() == kButtonDown ) {
04550     //inputtype = kTFile;
04551     const char* filetypes[] = {"ROOT files",    "*.root",
04552                    "All files",     "*",
04553                    "MAP files",     "*.map",
04554                    0,               0 };
04555     fi.fFileTypes = (const char **)filetypes;
04556   }
04557   else if ( fRaButSocket->GetState() == kButtonDown ) {
04558     //inputtype = kTSocket;
04559     const char* filetypes[] = { "All files",     "*",
04560                     "ROOT files",    "*.root",
04561                     "MAP files",     "*.map",
04562                     0,               0 };
04563     fi.fFileTypes = (const char **)filetypes;
04564   }
04565 
04566 
04567 
04568   new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi);
04569 
04570   return fi.fFilename;
04571 }
04572 
04573 void HistoDisplay::FileNameClear()
04574 {
04575   //cout << " In File Name Clear " << endl;
04576   fFileNameBuffer->Clear();
04577   fFileNameTextEntry->SetState(kTRUE);
04578 }
04579 
04580 //--
04581 
04582 
04583 
04584 Bool_t HistoDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t /*parm2*/)
04585 {
04586 
04587   //cout << " In ProcessMessage " << endl;
04588 
04589   //static TObject *inputobj = 0;
04590   //TObject *inputobj2 =0;
04591   TPad *gpad = 0;
04592 
04593   switch ( GET_MSG(msg) ) {
04594   case kC_COMMAND:
04595     switch ( GET_SUBMSG(msg) ) {
04596     case kCM_MENU:
04597       switch ( parm1 ) {
04598       case kM_MENU_FILE_NEWGUI:
04599         new HistoDisplay(gClient->GetRoot(), 200, 400, fsocketserver, fport);
04600         break;
04601       case kM_MENU_FILE_NEWCANVAS:
04602         //gROOT->GetMakeDefCanvas()();
04603         {
04604           CanvasNumber++;
04605           char *num = new char[3];
04606           sprintf( num, "%d", CanvasNumber);
04607           TCanvas *CurrentCanvas =
04608             new TCanvas( CanvasName + TString( num ),
04609                          CanvasTitle + TString( num) , 500, 500 );
04610           delete num;
04611           CurrentCanvas->cd();
04612         }
04613         break;
04614       case kM_MENU_FILE_NEWSLIDE:
04615         {
04616           static int i = 0;
04617           i++;
04618           //TString name = "MINOSSlideShowCanvas";
04619           //TString title = "MINOS Slide Show Canvas ";
04620           TString name = "AutoUpdateCanvas";
04621           TString title = "Auto Update Canvas ";
04622           char *num = 0;
04623           num = new char[ 3 ];
04624           sprintf( num, "%d", i );
04625           name = name + TString( num );
04626           title = title + TString( num );
04627           delete num;
04628           //tmp
04629           //cout << name << " " << title << endl; 
04630           TCanvas *slideCanvas = new TCanvas( name, title, 500, 500 );
04631           slideCanvas->cd();
04632           if ( fSlideCanvasList ) {
04633             if ( !( fSlideCanvasList->IsEmpty() ) )  {
04634               TObjLink *link = fSlideCanvasList->FirstLink();
04635               while ( link ) {
04636                 TObject *obj = 0;
04637                 obj = link->GetObject();
04638                 link = link->Next();
04639                 if ( !obj ||
04640                      !( gROOT->GetListOfCanvases()->FindObject( obj ) ) )
04641                   fSlideCanvasList->Remove( obj );
04642               } //while ( link )
04643             } //if ( !( fSlideCanvasList->IsEmpty() )
04644             fSlideCanvasList->Add( slideCanvas );
04645           } //if ( fSlideCanvasList )
04646         } //{
04647         break;
04648       case kM_MENU_FILE_CLOSE:
04649         // Do not know how to close one window.
04650         DestroyWindow(); // in TGWindow
04651         //cout << " Sorry. Not yet. " << endl;
04652         break;
04653       case kM_MENU_FILE_EXIT:
04654         Running = kFALSE;
04655         fReadFileButton->ChangeBackground(Red);
04656         //  cout << "Button changed to red\n";
04657         fChButtonSlideUpdate->SetState(kButtonUp);
04658         SlideShowUpdate = kFALSE;         
04659         gClient->NeedRedraw(fReadFileButton);
04660 
04661         ResetObjects();
04662 
04663         CloseWindow();
04664         break;
04665       case kM_MENU_LISTTREE_SORTTREE:
04666         SortTGListTree();
04667         break;
04668       case kM_MENU_LISTTREE_SORTFOLDER:
04669         if ( fSelectedItem ) {
04670           fHistoListTree->SortChildren(fSelectedItem);
04671           fClient->NeedRedraw(fHistoListTree);
04672         }
04673         break;
04674       case kM_MENU_LISTTREE_DELETE:
04675         if ( fSelectedItem ) {
04676           CObject *cobj = 
04677             (CObject*) fDisplayedList
04678             ->FindObject(fSelectedItem->GetText()); 
04679 
04680           if ( fDisplayedList->Remove( cobj ) ) delete cobj;
04681 
04682           fHistoListTree->DeleteItem(fSelectedItem);
04683           fClient->NeedRedraw(fHistoListTree);
04684         }
04685         fSelectedItem = 0;
04686         break;
04687       case kM_MENU_LISTTREE_CLEAR:
04688 
04689         if ( fDisplayedList ) fDisplayedList->Clear();
04690         RemoveTGListTree();
04691         break;
04692       case kM_MENU_LISTTREE_REFRESH:
04693 
04694         if ( fSelectedItem )
04695           RefreshTreeItem( fSelectedItem );
04696         else
04697           RefreshTreeItem( fHistoListTree->GetFirstItem() );
04698 
04699         break;
04700         /*
04701       case kM_MENU_CONNECT_MON1:
04702         cout << " Sorry. Not yet implemented. " << endl;
04703         break;
04704       case kM_MENU_CONNECT_MON2:
04705         cout << " Sorry. Not yet implemented. " << endl;
04706         break;
04707       case kM_MENU_CONNECT_MON3:
04708         cout << " Sorry. Not yet implemented. " << endl;
04709         break;
04710       case kM_MENU_CONNECT_MON4:
04711         cout << " Sorry. Not yet implemented. " << endl;
04712         break;
04713       case kM_MENU_CONNECT_MON5:
04714         cout << " Sorry. Not yet implemented. " << endl;
04715         break;
04716         */
04717 
04718       case kM_MENU_CONNECT_STATUS:
04719         MenuConnectStatus();
04720         break;
04721 
04722       case kM_MENU_HELP_GUI:
04723         MenuHelp("Help on this GUI...", gHelpHistoDisplay);
04724         break;
04725 
04726       case kM_MENU_HELP_ROOT:
04727         MenuHelp("Help on ROOT...", gHelpAbout);
04728         break;
04729 
04730       case kM_MENU_HELP_CANVAS:
04731         MenuHelp("Help on Canvas...", gHelpCanvas);
04732         break;
04733       } // switch( parm1 )
04734       break; //kCM_MENU
04735 
04736 
04737     case kCM_BUTTON:
04738       switch ( parm1 ) {
04739 
04740       case kM_PICTBUTTON:
04741         //PopupWindow();
04742         new PhotoWindow(fClient->GetRoot(), this, 400, 500);
04743         break;
04744 
04745 
04746       case kM_BUTTON_FILENAME:
04747         {
04748 
04749           // dp : reset first
04750 
04751           fReadFileButton->SetState(kButtonUp);
04752           fReadFileButton->ChangeBackground(Red);
04753           fChButtonSlideUpdate->SetState(kButtonUp);
04754           SlideShowUpdate = kFALSE;
04755           // cout << "Button changed to red\n";   
04756             gClient->NeedRedraw(fReadFileButton);
04757           Running = kFALSE;
04758 
04759           fSelectedItem = 0;
04760 
04761           ResetObjects();
04762 
04763           // Delete and Remove files, socket, and lists, ListTrees --
04764           if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) ) {
04765             TCanvas *CurrentCanvas = 0;
04766             CurrentCanvas = gPad->GetCanvas();
04767             if ( CurrentCanvas ) {
04768               //CurrentCanvas->Clear();
04769               RecursivePadClear( CurrentCanvas );
04770               CurrentCanvas->cd();
04771               CurrentCanvas->Modified();
04772               CurrentCanvas->Update();
04773             } //if ( CurrentCanvas )
04774           } //if ( gPad && !( gROOT->GetCanvasList()->IsEmpty() ) )
04775 
04776 
04777 
04778 
04779 
04780           FileName = TString( fFileNameBuffer->GetString() );
04781 
04782           EInputTypes inputtype;
04783 
04784           if ( fRaButMFile->GetState() == kButtonDown )
04785             inputtype = kTMapFile;
04786           else if ( fRaButRFile->GetState() == kButtonDown )
04787             inputtype = kTFile;
04788           else if ( fRaButSocket->GetState() == kButtonDown )
04789             inputtype = kTSocket;
04790 
04791           //InputObj = OpenFile( FileName.Data(), inputtype, "READ" );
04792           TObject *InputObj = OpenFile( FileName.Data(), inputtype, "READ" );
04793 
04794 
04795           //if ( InputOpen ) {
04796           if ( InputObj ) {
04797 
04798             AddTreeItemsOfInput( InputObj );
04799             //RefreshTreeItem( fHistoListTree->GetFirstItem() );
04800             fClient->NeedRedraw( fHistoListTree );
04801             fReadFileButton->ChangeBackground(Green);
04802             // cout << "Button changed to green\n";
04803             // cout << "Opened file\n";
04804             gClient->NeedRedraw(fReadFileButton);
04805             //    fMainFrame->Update();
04806 
04807             char* str = new char[ 9 + FileName.Length() ];
04808             strcpy(str, " Opened ");
04809             fStatusBar
04810               ->SetText( strcat(str, FileName.Data()), 1);
04811             delete [] str;
04812           } //if ( InputObj ) 
04813           else {
04814 
04815             //if ( inputtype == kTMapFile && !InputOpen ) {
04816             if ( inputtype == kTMapFile ) {
04817               const char *sg = "Failed to open memory map file.";
04818               MessageBox(sg);
04819             }
04820             //else if ( inputtype == kTFile && !InputOpen ) {
04821             else if ( inputtype == kTFile ) {
04822               const char *sg = "Failed to open ROOT file.";
04823               MessageBox(sg);
04824             }
04825             //else if ( inputtype == kTSocket && !InputOpen ) {
04826             else if ( inputtype == kTSocket ) {
04827               const char *sg = "Failed to open the socket connection.";
04828               MessageBox(sg);
04829             }
04830 
04831             char* str = new char[16+FileName.Length()];
04832             str = strcpy(str," Error Opening ");
04833             fStatusBar
04834               ->SetText( strcat(str, FileName.Data()), 1);
04835             delete [] str;
04836           }
04837         }
04838 
04839         break;
04840 
04841 
04842       case kM_BUTTON_CHOOSEFILE:
04843         if( (fRaButMFile->GetState() == kButtonDown) ||
04844             (fRaButRFile->GetState() == kButtonDown) ) {
04845 
04846           const char *file = FileDialogWindow(); 
04847           if ( file ){ 
04848 
04849             fFileNameBuffer->Clear();
04850 
04851             // Older version of  ROOT.
04852             /*
04853             char s[80] = "";
04854             strcat(s, gSystem->WorkingDirectory()); 
04855             strcat(s, "/"); 
04856             strcat(s, file); 
04857 
04858             fFileNameBuffer->AddText(0, s);
04859             */
04860 
04861             fFileNameBuffer->AddText(0, file);
04862 
04863             gClient->NeedRedraw(fFileNameTextEntry);
04864 
04865             //T.A
04866             delete [] file;
04867           }
04868 
04869         }
04870 
04871         break;
04872             
04873       case kM_BUTTON_CLEARFILENAME:
04874 
04875         FileNameClear();
04876 
04877         break;
04878 
04879         /*
04880       case kM_BUTTON_START:
04881 
04882         MonitorName = TString( fMonitorNameBuffer->GetString() );
04883 
04884         HistoDisplayMain();
04885         //inputobj2 = inputobj;
04886         //HistoDisplayMain( inputobj2 );
04887 
04888         //tmp
04889         //fReadFileButton->SetState(kButtonUp);
04890 
04891         //tmp
04892         //fStartHistoButton->SetState(kButtonDisabled);
04893         fStopHistoButton->SetState(kButtonUp);
04894 
04895         fClearHistoButton->SetState(kButtonUp);
04896 
04897         fPrintHistoButton->SetState(kButtonUp);
04898 
04899         fZeroHistoButton->SetState(kButtonUp);
04900         fUnZeroHistoButton->SetState(kButtonUp);
04901         fContentHistoButton->SetState(kButtonUp);
04902 
04903 
04904         break;
04905         */
04906 
04907       case kM_BUTTON_PAUSE:
04908 
04909         if ( Running ) {
04910           fPauseHistoButton->SetState( kButtonDisabled );
04911           fRestartHistoButton->SetState( kButtonUp );
04912           Running = kFALSE;
04913         } //if ( Running )
04914 
04915 
04916 
04917         break;
04918       case kM_BUTTON_CLEAR:
04919 
04920         ClearCurrentPad();
04921         break;
04922 
04923       case kM_BUTTON_PRINT:
04924 
04925         if ( gPad || !( gROOT->GetListOfCanvases()->IsEmpty() ) ) {
04926           //PrintCanvas( gPad->GetCanvas() );
04927           PrintCanvas( (TPad*)gPad );
04928         }//if ( gPad || !( gROOT->GetListOfCanvases()->IsEmpty() ) ) 
04929           
04930         break;
04931 
04932       case kM_BUTTON_RESTART:
04933 
04934         if ( fSelectedItem ) {
04935           /*
04936           if ( strstr( fSelectedItem->GetText(), "slide" ) ||
04937                strstr( fSelectedItem->GetText(), "Slide" ) ||
04938                strstr( fSelectedItem->GetText(), "SLIDE" ) ) {
04939           */
04940           if ( strstrn( fSelectedItem->GetText(), kSlideShowFolder ) ) {
04941 
04942             StartSlides( fSelectedItem );
04943 
04944           } //if ( strstr( fSelectedItem->GetText() ) ||
04945 
04946           else {
04947 
04948             if ( AutoUpdate ) {
04949               fPauseHistoButton->SetState( kButtonUp );
04950               fRestartHistoButton->SetState( kButtonDisabled );
04951               UpdateTimerOn();
04952             } // if ( AutoUpdate ) {
04953             else {
04954               UpdateCanvas();
04955             } //else //if ( AutoUpdate ) {
04956 
04957           } //else // if ( strstr( fSelectedItem->GetText(), "slide" ) ||
04958 
04959         } //if( fSelectedItem )  
04960 
04961         break;
04962       case kM_BUTTON_ZERO:
04963 
04964         gpad = (TPad*)gPad;
04965         AddSubtractHisto(gpad, 1);
04966 
04967         UpdateCanvas();
04968 
04969 
04970 
04971         break;
04972       case kM_BUTTON_UNZERO:
04973 
04974         gpad = (TPad*)gPad;
04975         AddSubtractHisto(gpad, 0);
04976         UpdateCanvas();
04977 
04978         break;
04979       case kM_BUTTON_CONTENT:
04980         /*
04981         if ( fSelectedItem ) {
04982           TObject *obj = 
04983             fDisplayedList->FindObject( fSelectedItem->GetText() );
04984           if ( obj && obj->InheritsFrom(CHistogram::Class()) ) {
04985             TH1 *histo =
04986               (TH1*) ( ((CHistogram*)obj)->SubtractedHisto() );
04987             //TH1 *histo =  ( (CHistogram*)obj )->GetHistoDrawn();
04988 
04989             DrawContentHisto( histo );
04990             delete histo;
04991           }
04992         }
04993         */
04994 
04995         gpad = (TPad*)gPad;
04996         if ( gpad ) {
04997 
04998           Int_t counthisto = 0;
04999           TH1 *histo = HistoInPad( gpad , counthisto );
05000           if ( counthisto == 1 ) DrawContentHisto( histo ); 
05001           else if ( counthisto >= 2 )
05002             cout << " Select one histo on canvas. " << endl;
05003 
05004         } //if ( gpad )
05005 
05006 
05007         break;
05008 
05009       case kM_BUTTON_CANVAS:
05010         {
05011           static int i = 0;
05012           i++;
05013           //TString name = "MINOSSlideShowCanvas";
05014           //TString title = "MINOS Slide Show Canvas ";
05015           TString name = "AutoUpdateCanvas";
05016           TString title = "Auto Update Canvas ";
05017           char *num = 0;
05018           num = new char[ 3 ];
05019           sprintf( num, "%d", i );
05020           name = name + TString( num );
05021           title = title + TString( num );
05022           delete num;
05023           //tmp
05024           //cout << name << " " << title << endl; 
05025           TCanvas *slideCanvas = new TCanvas( name, title, 500, 500 );
05026           slideCanvas->cd();
05027           if ( fSlideCanvasList ) {
05028             if ( !( fSlideCanvasList->IsEmpty() ) )  {
05029               TObjLink *link = fSlideCanvasList->FirstLink();
05030               while ( link ) {
05031                 TObject *obj = 0;
05032                 obj = link->GetObject();
05033                 link = link->Next();
05034                 if ( !obj ||
05035                      !( gROOT->GetListOfCanvases()->FindObject( obj ) ) )
05036                   fSlideCanvasList->Remove( obj );
05037               } //while ( link )
05038             } //if ( !( fSlideCanvasList->IsEmpty() )
05039             fSlideCanvasList->Add( slideCanvas );
05040           } //if ( fSlideCanvasList )
05041         } //{
05042         break;
05043 
05044       case kM_BUTTON_STOP:
05045 
05046         cout << "Pressed RESET\n";
05047         /*
05048         fPauseHistoButton->SetState(kButtonDisabled);
05049         fRestartHistoButton->SetState(kButtonDisabled);
05050         fZeroHistoButton->SetState(kButtonDisabled);
05051         fUnZeroHistoButton->SetState(kButtonDisabled);
05052         fContentHistoButton->SetState(kButtonDisabled);
05053         fStopHistoButton->SetState(kButtonDisabled);
05054         */
05055 
05056         if (fUpdateTimer) {fUpdateTimer->TurnOff();}
05057         if (fSlideTimer) {fSlideTimer->TurnOff();}
05058 
05059         if ( Running ) {
05060           fPauseHistoButton->SetState( kButtonDisabled );
05061           fRestartHistoButton->SetState( kButtonUp );
05062           Running = kFALSE;
05063         }
05064 
05065 ;
05066 
05067         fReadFileButton->SetState(kButtonUp);
05068           fReadFileButton->ChangeBackground(Red);
05069           // cout << "Button changed to red\n";  
05070             gClient->NeedRedraw(fReadFileButton);
05071             fChButtonSlideUpdate->SetState(kButtonUp);
05072             SlideShowUpdate = kFALSE;
05073         Running = kFALSE;
05074 
05075         fSelectedItem = 0;
05076 
05077         ResetObjects();
05078 
05079         fHistoListTree->Clear(); //dp
05080 
05081         // Delete and Remove files, socket, and lists, ListTrees --
05082         if ( gPad && !( gROOT->GetListOfCanvases()->IsEmpty() ) ) {
05083           TCanvas *CurrentCanvas = 0;
05084           CurrentCanvas = gPad->GetCanvas();
05085           if ( CurrentCanvas ) {
05086             //CurrentCanvas->Clear();
05087             RecursivePadClear( CurrentCanvas );
05088             CurrentCanvas->cd();
05089             CurrentCanvas->Modified();
05090             CurrentCanvas->Update();
05091           } //if ( CurrentCanvas )
05092         } //if ( gPad && !( gROOT->GetCanvasList()->IsEmpty() ) )
05093 
05094 
05095         //--
05096 
05097         break;
05098         /*
05099       case kM_BUTTON_EXIT:
05100         Running = kFALSE;
05101 
05102         ResetObjects();
05103 
05104         CloseWindow();
05105         break;
05106         */
05107 
05108       } //switch parm1
05109       break; //kCM_BUTTON
05110 
05111     case kCM_CHECKBUTTON:
05112       switch ( parm1 ) {
05113       case kM_CHBUTTON_AUTOUPDATE:
05114         if ( fChButtonAutoUpdate->GetState() == kButtonDown ) {
05115           AutoUpdate = kTRUE;
05116 
05117           fChButtonSlideUpdate->SetState(kButtonUp);
05118         }
05119         else {
05120           AutoUpdate = kFALSE;
05121           fPauseHistoButton->SetState(kButtonDisabled);
05122           fRestartHistoButton->SetState(kButtonUp);
05123           Running = kFALSE;
05124 
05125           fChButtonSlideUpdate->SetState(kButtonUp);
05126           fChButtonSlideUpdate->SetState(kButtonDisabled);
05127           SlideShowUpdate = kFALSE;
05128         }
05129         break;
05130 
05131       case kM_CHBUTTON_SLIDEUPDATE:
05132         if ( fChButtonSlideUpdate->GetState() == kButtonDown ) 
05133           SlideShowUpdate = kTRUE;
05134         else 
05135           SlideShowUpdate = kFALSE;
05136 
05137         break;
05138       } // switch parm1 of Check Button
05139 
05140       break; //kCM_CHECKBUTTON
05141 
05142     case kCM_RADIOBUTTON:
05143       switch ( parm1 ) {
05144       case kM_RABUTTON_MFILE:
05145         fRaButMFile->SetState(kButtonDown);
05146         fRaButRFile->SetState(kButtonUp);
05147         fRaButSocket->SetState(kButtonUp);
05148         break; // kM_RABUTTON_MFILE
05149       case kM_RABUTTON_RFILE:
05150         fRaButMFile->SetState(kButtonUp);
05151         fRaButRFile->SetState(kButtonDown);
05152         fRaButSocket->SetState(kButtonUp);
05153         break; // kM_RABUTTON_RFILE
05154       case kM_RABUTTON_SOCKET:
05155         fRaButMFile->SetState(kButtonUp);
05156         fRaButRFile->SetState(kButtonUp);
05157         fRaButSocket->SetState(kButtonDown);
05158         break; // kM_RABUTTON_SOCKET
05159       } // switch parm1 of Radio Button
05160 
05161       break; //kCM_RADIOBUTTON
05162 
05163 
05164     } //switch submsg of kC_COMMAND
05165     break; // kC_COMMAND
05166 
05167   case kC_LISTTREE:
05168     switch ( GET_SUBMSG(msg) ) {
05169 
05170     case kCT_ITEMCLICK:
05171       if ( parm1 == kButton1 || parm1 == kButton2 ) {
05172         TGListTreeItem *item;
05173         if ( (item = fHistoListTree->GetSelected()) !=0 &&
05174             item != fSelectedItem) {
05175           fClient->NeedRedraw(fHistoListTree);
05176           fSelectedItem = item;
05177         }
05178       } //if parm1 of kCT_ITEMCLICK
05179 
05180       else if ( parm1 == kButton3 ) {
05181         TGListTreeItem *item;
05182         if ( (item = fHistoListTree->GetSelected()) !=0 ) {
05183           fClient->NeedRedraw(fHistoListTree);
05184           fSelectedItem = item;
05185 
05186 
05187           if ( fSelectedItem ) {
05188 
05189             /*
05190             if ( strstr( fSelectedItem->GetText(), "slide" ) ||
05191                  strstr( fSelectedItem->GetText(), "Slide" ) ||
05192                  strstr( fSelectedItem->GetText(), "SLIDE" ) ) {
05193             */
05194             if ( strstrn( fSelectedItem->GetText(), kSlideShowFolder ) ) {
05195 
05196               //dp            StartSlides( fSelectedItem );
05197 
05198             } //if ( strstr( fSelectedItem->GetText() ) ||
05199 
05200 
05201             else {
05202 
05203               if ( fSlideTimer && 
05204                    ( fSlideTimer->GetCurrentPad() == gPad ) &&
05205                    !fSlideTimer->HasTimedOut() )
05206                 //if ( fSlideTimer )
05207                 fSlideTimer->TurnOff();
05208 
05209 
05210               if ( fSelectedItem->GetFirstChild() &&
05211                    fSelectedItem->GetFirstChild()->GetNextSibling() &&
05212                    fSelectedItem->IsOpen() ) {
05213 
05214                 TList *selectedList = new TList();
05215 
05216                 TGListTreeItem *item2;
05217                 item2 = fSelectedItem->GetFirstChild();
05218 
05219                 while ( item2 ) {
05220                   //TObject *obj2 = 0;
05221                   //obj2 = fDisplayedList->FindObject( item2->GetText() );
05222 
05223                   TObject *obj2 = GetCObjFromListItem( item2 );
05224 
05225                   if( obj2 ) {
05226                     selectedList->Add( obj2 );
05227                     //obj2->ls();
05228                   }//if( obj2 )
05229                   item2 = item2->GetNextSibling();
05230                 }// while( item2 )
05231 
05232                 DrawHisto( selectedList );
05233                 delete selectedList;
05234 
05235               } //if ( selectedItem->GetFirstChild() &&
05236               else {
05237 
05238                 //TObject *obj =
05239                 //fDisplayedList->FindObject( fSelectedItem->GetText() );
05240 
05241                 TObject *obj = GetCObjFromListItem( item );
05242 
05243                 DrawHisto( obj );
05244 
05245               } //else //if ( selectedItem->GetFirstChild() &&
05246 
05247 
05248               if ( AutoUpdate ) {
05249                 fPauseHistoButton->SetState( kButtonUp );
05250                 fRestartHistoButton->SetState( kButtonDisabled );
05251               
05252                 UpdateTimerOn();
05253 
05254               } //if (AutoUpdate)
05255               else {
05256 
05257                 //if ( !Running ) {
05258                   fPauseHistoButton->SetState( kButtonDisabled );
05259                   fRestartHistoButton->SetState( kButtonUp );
05260                   //} //if ( !Running ) {
05261 
05262               } //else //if (AutoUpdate)
05263 
05264 
05265 
05266             } //else //if ( strstr( fSelectedItem->GetText() ) ||
05267 
05268           } //if ( fSelectedItem )
05269 
05270 
05271         } //if ( (item = fHistoListTree->GetSelected()) !=0 )
05272       } // else if parm1 == kButton3 of kCT_ITEMCLICK
05273       break; // kCT_ITEMCLICK
05274 
05275 
05276     case kCT_ITEMDBLCLICK:
05277       //if ( parm1 == kButton1 ) {
05278       if ( parm1 ) {
05279         TGListTreeItem *item;
05280         if ( (item = fHistoListTree->GetSelected()) !=0 ) {
05281           fClient->NeedRedraw(fHistoListTree);
05282           fSelectedItem = item;
05283 
05284           if ( fSelectedItem ) {
05285 
05286             //TObject *obj =
05287             //fDisplayedList->FindObject( fSelectedItem->GetText() );
05288 
05289             TObject *obj = GetCObjFromListItem( item );
05290 
05291             if ( !obj ) {
05292  
05293               /*
05294               if ( ( strstr( fSelectedItem->GetText(), "slide" ) ||
05295                      strstr( fSelectedItem->GetText(), "Slide" ) ||
05296                      strstr( fSelectedItem->GetText(), "SLIDE" ) ) ) {
05297               */
05298               if ( strstrn( fSelectedItem->GetText(), kSlideShowFolder ) ) {
05299 
05300                 //dp            StartSlides( fSelectedItem );
05301 
05302               } // if ( ( strstr( fSelectedItem->GetText(), "slide" ) ||
05303 
05304             } //if ( !obj )  
05305 
05306             else {
05307 
05308               if ( fSlideTimer &&
05309                    ( fSlideTimer->GetCurrentPad() == gPad ) &&
05310                    !fSlideTimer->HasTimedOut() )
05311                 //if ( fSlideTimer )
05312                 fSlideTimer->TurnOff();
05313 
05314               DrawHisto( obj );
05315 
05316               if ( AutoUpdate ) {
05317                 fPauseHistoButton->SetState( kButtonUp );
05318                 fRestartHistoButton->SetState( kButtonDisabled );
05319 
05320                 UpdateTimerOn();
05321 
05322               } //if ( AutoUpdate )
05323               else {
05324 
05325                 //if ( !Running ) {
05326                   fPauseHistoButton->SetState( kButtonDisabled );
05327                   fRestartHistoButton->SetState( kButtonUp );
05328                   //} //if ( !Running ) {
05329 
05330               } //else //if (AutoUpdate)
05331 
05332 
05333             } //else //if ( !obj )
05334 
05335 
05336           } //if ( fSelectedItem )
05337 
05338 
05339         } //if ( (item = fHistoListTree->GetSelected()) !=0 )
05340       } //if ( parm1 == kButton1 ) of kCT_ITEMDBLCLICK
05341       break; // kCT_ITEMDBLCLICK
05342 
05343     } // switch submsg of kC_LISTTREE
05344     break; //case kC_LISTTREE
05345 
05346   case kC_TEXTENTRY:
05347     switch (GET_SUBMSG(msg)) {
05348 
05349     case kTE_ENTER:
05350 
05351       switch ( parm1 ) {
05352 
05353       case kM_TEXTENTRY_FILENAME:
05354 
05355         {
05356           FileName = TString( fFileNameBuffer->GetString() );
05357 
05358           EInputTypes inputtype;
05359 
05360           if ( fRaButMFile->GetState() == kButtonDown )
05361             inputtype = kTMapFile;
05362           else if ( fRaButRFile->GetState() == kButtonDown )
05363             inputtype = kTFile;
05364           else if ( fRaButSocket->GetState() == kButtonDown )
05365             inputtype = kTSocket;
05366 
05367           //InputObj = OpenFile( FileName.Data(), inputtype, "READ" );
05368           TObject *InputObj = OpenFile( FileName.Data(), inputtype, "READ" );
05369 
05370 
05371           //if ( InputOpen ) {
05372           if ( InputObj ) {
05373 
05374             AddTreeItemsOfInput( InputObj );
05375             //RefreshTreeItem( fHistoListTree->GetFirstItem() );
05376             fClient->NeedRedraw( fHistoListTree );
05377 
05378 
05379             char* str = new char[ 9 + FileName.Length() ];
05380             strcpy(str, " Opened ");
05381             fStatusBar
05382               ->SetText( strcat(str, FileName.Data()), 1);
05383             delete [] str;
05384           } //if ( InputObj ) 
05385           else {
05386 
05387             //if ( inputtype == kTMapFile && !InputOpen ) {
05388             if ( inputtype == kTMapFile ) {
05389               const char *sg = "Failed to open memory map file.";
05390               MessageBox(sg);
05391             }
05392             //else if ( inputtype == kTFile && !InputOpen ) {
05393             else if ( inputtype == kTFile ) {
05394               const char *sg = "Failed to open ROOT file.";
05395               MessageBox(sg);
05396             }
05397             //else if ( inputtype == kTSocket && !InputOpen ) {
05398             else if ( inputtype == kTSocket ) {
05399               const char *sg = "Failed to open the socket connection.";
05400               MessageBox(sg);
05401             }
05402 
05403             char* str = new char[16+FileName.Length()];
05404             strcpy(str," Error Opening ");
05405             fStatusBar
05406               ->SetText( strcat(str, FileName.Data()), 1);
05407             delete [] str;
05408 
05409           } // else //if ( InputObj )
05410 
05411         }
05412         break;//  kM_TEXTENTRY_FILENAME
05413     
05414       }//switch ( parm1 )
05415 
05416       break; //case kTE_ENTER:
05417 
05418     default:
05419       break;
05420 
05421     }//switch (GET_SUBMSG(msg)) 
05422 
05423     break; //case kC_TEXTENTRY:
05424 
05425   default:
05426     break;
05427 
05428   } //switch ( GET_MSG(msg) )
05429 
05430   return kTRUE;
05431 
05432 }
05433 
05434 
05435 
05436 //void HistoDisplay::GetDirPath( const TString &Item)
05437 //char* HistoDisplay::GetDirPath( const TString &Item)
05438 TString HistoDisplay::GetDirPath( const TString &/*Item*/)
05439 {
05440   //cout << " GetDirPath " << endl;
05441 
05442   TString DirPath;
05443 
05444   DirPath = "/" + MonitorName ;
05445   //DirPath = "/";
05446 
05447   /*
05448   char *dirpath = new char[DirPath.Length()];
05449 
05450   cout << " DirPath in DirName" << DirPath.Data() << endl;
05451   strcpy(dirpath, DirPath.Data());
05452   cout << " dirpath in DirName" << dirpath << endl;
05453   return dirpath;
05454   */
05455 
05456   return DirPath;
05457 
05458 }
05459 
05460 
05461 //******************** Modified by Koji (1999/12/2) ************************
05462 
05463 PhotoWindow::PhotoWindow(const TGWindow *p, const TGWindow *main, UInt_t w,
05464                          UInt_t h, UInt_t options)
05465   :TGTransientFrame(p, main, w, h, options)
05466 {
05467     gClient->GetColorByName("Cyan",Cyan);
05468     ChangeBackground(Cyan);
05469 
05470  fTitleFrame = new TGCompositeFrame(this,800,100);
05471  FontStruct_t labelfont0, labelfont1;
05472  labelfont0 = gClient->GetFontByName("-adobe-helvetica-medium-r-*-*-18-*-*-*-*-*-iso8859-1");
05473    GCValues_t   gval0, gval1, gval2;
05474    gval0.fMask = kGCForeground | kGCFont;
05475    gval0.fFont = gVirtualX->GetFontHandle(labelfont0);
05476    gClient->GetColorByName("red", gval0.fForeground);
05477    fTextGC0 = gVirtualX->CreateGC(gClient->GetRoot()->GetId(), &gval0);
05478    fTitleLabel = new TGLabel(fTitleFrame, "MINOS Online Monitoring System", fTextGC0, labelfont0);
05479    fTitleLabel->ChangeBackground(Cyan);
05480    fTitleFrame->AddFrame(fTitleLabel, new TGLayoutHints(kLHintsTop | kLHintsCenterX));
05481 
05482    // fPicBut0 = new TGPictureButton(this, gClient->GetPicture("${CONSUMER_ICONS}/photo.xpm"), 1);
05483 
05484 fPicBut0 = new TGPictureButton(this, gClient->GetPicture("${CONSUMER_ICONS}/photo_old.xpm"), 1);
05485 
05486  fPicBut1 = new TGPictureButton(this, gClient->GetPicture("${CONSUMER_ICONS}/ta.xpm"), 2);
05487 
05488  fButton = new TGTextButton(this, "OK", 3);
05489  fButton->Associate(this);
05490  // fButton->SetCommand(".q" );
05491  gClient->GetColorByName("LightYellow",LightYellow);
05492  fButton->ChangeBackground(LightYellow);
05493 
05494 
05495    labelfont1 = gClient->GetFontByName("-adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
05496    gval1.fMask = kGCForeground | kGCFont;
05497    gval1.fFont = gVirtualX->GetFontHandle(labelfont1);
05498    gClient->GetColorByName("blue", gval1.fForeground);
05499    fTextGC1 = gVirtualX->CreateGC(gClient->GetRoot()->GetId(), &gval1);
05500 
05501    gval2.fMask = kGCForeground | kGCFont;
05502    gval2.fFont = gVirtualX->GetFontHandle(labelfont1);
05503    gClient->GetColorByName("magenta", gval2.fForeground);
05504    fTextGC2 = gVirtualX->CreateGC(gClient->GetRoot()->GetId(), &gval2);
05505 
05506  fTextFrame0 = new TGCompositeFrame(this,100,50);
05507  fTextFrame1 = new TGCompositeFrame(this,100,50);
05508  fTextFrame2 = new TGCompositeFrame(this,100,50);
05509 
05510  fTextLabel0 = new TGLabel(fTextFrame0, "H. Wenzel", fTextGC1, labelfont1);
05511  fTextLabel1 = new TGLabel(fTextFrame0, "IEKP Karlsruhe", fTextGC2, labelfont1);
05512  fTextLabel2 = new TGLabel(fTextFrame1, "K. Maeshima                   K. Ikado        ", fTextGC1, labelfont1);
05513  fTextLabel3 = new TGLabel(fTextFrame1, "     Fermilab                 Waseda Univ.     ", fTextGC2, labelfont1);
05514  //fTextLabel4 = new TGLabel(fTextFrame2, "F. Hartmann                T. Arisawa                 G. Veramendi", fTextGC1, labelfont1);
05515  fTextLabel4 = new TGLabel(fTextFrame2, "H.Stadie,W.Wagner         T. Arisawa                 G. Veramendi", fTextGC1, labelfont1);
05516  fTextLabel41 = new TGLabel(fTextFrame2, " F.Hartmann", fTextGC1, labelfont1);
05517  fTextLabel5 = new TGLabel(fTextFrame2, "IEKP Karlsruhe              Waseda Univ.                   LBNL        ", fTextGC2, labelfont1);
05518 
05519  fTextLabel0->ChangeBackground(Cyan);
05520  fTextLabel1->ChangeBackground(Cyan);
05521  fTextLabel2->ChangeBackground(Cyan);
05522  fTextLabel3->ChangeBackground(Cyan);
05523  fTextLabel4->ChangeBackground(Cyan);
05524  fTextLabel41->ChangeBackground(Cyan);
05525  fTextLabel5->ChangeBackground(Cyan);
05526 
05527  fTextFrame0->AddFrame(fTextLabel0,new TGLayoutHints(kLHintsCenterX) );
05528  fTextFrame0->AddFrame(fTextLabel1,new TGLayoutHints(kLHintsCenterX) );
05529  fTextFrame1->AddFrame(fTextLabel2,new TGLayoutHints(kLHintsCenterX));
05530  fTextFrame1->AddFrame(fTextLabel3,new TGLayoutHints(kLHintsCenterX));
05531  fTextFrame2->AddFrame(fTextLabel4,new TGLayoutHints(kLHintsCenterX));
05532  fTextFrame2->AddFrame(fTextLabel41,new TGLayoutHints(kLHintsLeft));
05533  fTextFrame2->AddFrame(fTextLabel5,new TGLayoutHints(kLHintsCenterX));
05534 
05535  fTitleFrame->ChangeBackground(Cyan);
05536  fTextFrame0->ChangeBackground(Cyan);
05537  fTextFrame1->ChangeBackground(Cyan);
05538  fTextFrame2->ChangeBackground(Cyan);
05539 
05540     AddFrame(fTitleFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX,10,10,10,10));
05541     AddFrame(fPicBut0, new TGLayoutHints(kLHintsTop | kLHintsCenterX,10,10,0));
05542     AddFrame(fTextFrame0, new TGLayoutHints(kLHintsTop | kLHintsCenterX));
05543     AddFrame(fTextFrame1, new TGLayoutHints(kLHintsTop | kLHintsCenterX));
05544     AddFrame(fPicBut1, new TGLayoutHints(kLHintsTop | kLHintsCenterX,0,0,10));
05545     AddFrame(fTextFrame2, new TGLayoutHints(kLHintsTop | kLHintsCenterX));
05546     AddFrame(fButton, new TGLayoutHints(kLHintsBottom | kLHintsCenterX));
05547 
05548     MapSubwindows();
05549     Layout();
05550     SetWindowName("MINOS Online Monitoring System");
05551     MapWindow();
05552 
05553 }
05554  
05555 PhotoWindow::~PhotoWindow()
05556 {
05557   delete fButton;  delete fPicBut0; delete fPicBut1;
05558   delete fTitleLabel;  delete fTextLabel0;  delete fTextLabel1;
05559   delete fTextLabel2;  delete fTextLabel4;  delete fTextLabel5;
05560   delete fTextLabel41;
05561   delete fTitleFrame;  delete fTextFrame0;  delete fTextFrame1;
05562   delete fTextFrame2;
05563 }
05564 
05565 void PhotoWindow::ClosePhotoWindow()
05566 {
05567   delete this;
05568 }
05569 
05570 Bool_t PhotoWindow::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
05571 {
05572   switch ( GET_MSG(msg) ) {
05573   case kC_COMMAND:
05574     switch ( GET_SUBMSG(msg) ) {
05575     case kCM_BUTTON:
05576       switch ( parm1 ) {
05577       case 3:
05578         {
05579           ClosePhotoWindow();
05580         }
05581         break; //case 3:
05582       default:
05583         break;
05584       } //switch ( parm1 ) 
05585       break; //case kCM_BUTTON:
05586     default:
05587       break;
05588     } // switch ( GET_SUBMSG(msg) ) 
05589     break; //case kC_COMMAND:
05590   default:
05591     break;
05592   } //switch ( GET_MSG(msg) )
05593   return kTRUE;
05594 }
05595 
05596 //***********************************************************************
05597 

Generated on Sat Mar 14 22:40:08 2009 for loon by doxygen 1.3.5