CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/Core/src/CmsShowMainFrame.cc

Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 //
00004 // Package:     Core
00005 // Class  :     CmsShowMainFrame
00006 //
00007 // Implementation:
00008 //     <Notes on implementation> 
00009 //
00010 // Original Author:  Chris Jones
00011 //         Created:  Thu May 29 20:58:23 CDT 2008
00012 // $Id: CmsShowMainFrame.cc,v 1.122 2012/06/25 22:23:14 amraktad Exp $
00013 
00014 #include "FWCore/Common/interface/EventBase.h"
00015 
00016 // system include files
00017 #include <TCollection.h>
00018 #include <TApplication.h>
00019 #include <TEveWindow.h>
00020 #include <TGClient.h>
00021 #include <TGLayout.h>
00022 #include <TGButton.h>
00023 #include <TGMenu.h>
00024 #include <TGLabel.h>
00025 #include <TGTab.h>
00026 #include <TGPack.h>
00027 #include <TGStatusBar.h>
00028 #include <KeySymbols.h>
00029 #include <TGSlider.h>
00030 
00031 #include <TSystem.h>
00032 #include <TImage.h>
00033 // user include files
00034 #include "DataFormats/Provenance/interface/EventID.h"
00035 #include "Fireworks/Core/interface/CSGAction.h"
00036 #include "Fireworks/Core/interface/CSGContinuousAction.h"
00037 #include "Fireworks/Core/interface/CmsShowMainFrame.h"
00038 #include "Fireworks/Core/interface/ActionsList.h"
00039 #include "Fireworks/Core/interface/BuilderUtils.h"
00040 
00041 #include "Fireworks/Core/interface/FWGUIManager.h"
00042 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
00043 
00044 #include "Fireworks/Core/interface/FWIntValueListener.h"
00045 #include "Fireworks/Core/interface/fwLog.h"
00046 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
00047 #include "Fireworks/Core/src/FWNumberEntry.h"
00048 
00049 #include "Fireworks/Core/interface/fwPaths.h"
00050 
00051 #include <fstream>
00052 
00053 //
00054 // constants, enums and typedefs
00055 //
00056 
00057 //
00058 // static data member definitions
00059 //
00060 
00061 
00062 // AMT: temprary workaround until TGPack::ResizeExistingFrames() is public
00063 class FWPack : public TGPack
00064 {
00065    friend class CmsShowMainFrame;
00066 public:
00067    FWPack(const TGWindow* w) : TGPack(w, 100, 100) {}
00068    virtual ~FWPack() {}
00069 };
00070 
00071 //
00072 // constructors and destructor
00073 //
00074 CmsShowMainFrame::CmsShowMainFrame(const TGWindow *p,UInt_t w,UInt_t h,FWGUIManager *m) :
00075    TGMainFrame(p, w, h),
00076    m_filterEnableBtn(),
00077    m_filterShowGUIBtn(),
00078    m_runEntry(0),
00079    m_lumiEntry(0),
00080    m_eventEntry(0),
00081    m_delaySliderListener(0),
00082    m_manager(m),
00083    m_fworksAbout(0)
00084 {
00085    const unsigned int backgroundColor=0x2f2f2f;
00086    const unsigned int textColor= 0xb3b3b3;
00087 
00088    CSGAction *openData    = new CSGAction(this, cmsshow::sOpenData.c_str());
00089    CSGAction *appendData  = new CSGAction(this, cmsshow::sAppendData.c_str());
00090    CSGAction *searchFiles = new CSGAction(this, cmsshow::sSearchFiles.c_str());
00091 
00092    CSGAction *loadConfig   = new CSGAction(this, cmsshow::sLoadConfig.c_str());
00093    CSGAction *saveConfig   = new CSGAction(this, cmsshow::sSaveConfig.c_str());
00094    CSGAction *saveConfigAs = new CSGAction(this, cmsshow::sSaveConfigAs.c_str());
00095    CSGAction *exportImage  = new CSGAction(this, cmsshow::sExportImage.c_str());
00096    CSGAction *exportImages = new CSGAction(this, cmsshow::sExportAllImages.c_str());
00097    CSGAction *quit = new CSGAction(this, cmsshow::sQuit.c_str());
00098 
00099    CSGAction *undo = new CSGAction(this, cmsshow::sUndo.c_str());
00100    undo->disable(); //NOTE: All disables happen again later in this routine
00101    CSGAction *redo  = new CSGAction(this, cmsshow::sRedo.c_str());
00102    redo->disable(); //NOTE: All disables happen again later in this routine
00103    CSGAction *cut   = new CSGAction(this, cmsshow::sCut.c_str());
00104    cut->disable();  //NOTE: All disables happen again later in this routine
00105    CSGAction *copy  = new CSGAction(this, cmsshow::sCopy.c_str());
00106    copy->disable(); //NOTE: All disables happen again later in this routine
00107    CSGAction *paste = new CSGAction(this, cmsshow::sPaste.c_str());
00108    paste->disable();//NOTE: All disables happen again later in this routine
00109 
00110    CSGAction *goToFirst = new CSGAction(this, cmsshow::sGotoFirstEvent.c_str());
00111    CSGAction *goToLast = new CSGAction(this, cmsshow::sGotoLastEvent.c_str());
00112 
00113    CSGAction *nextEvent          = new CSGAction(this, cmsshow::sNextEvent.c_str());
00114    CSGAction *previousEvent      = new CSGAction(this, cmsshow::sPreviousEvent.c_str());
00115 
00116    CSGContinuousAction *playEvents     = new CSGContinuousAction(this, cmsshow::sPlayEvents.c_str());
00117    CSGContinuousAction *playEventsBack = new CSGContinuousAction(this, cmsshow::sPlayEventsBack.c_str());
00118    CSGContinuousAction *loop           = new CSGContinuousAction(this, cmsshow::sAutoRewind.c_str());
00119 
00120    CSGAction *showCommonInsp = new CSGAction(this, cmsshow::sShowCommonInsp.c_str());
00121    CSGAction *colorset       = new CSGAction(this, cmsshow::sBackgroundColor.c_str());
00122 
00123    CSGAction *showObjInsp          = new CSGAction(this, cmsshow::sShowObjInsp.c_str());
00124    CSGAction *showEventDisplayInsp = new CSGAction(this, cmsshow::sShowEventDisplayInsp.c_str());
00125    CSGAction *showMainViewCtl      = new CSGAction(this, cmsshow::sShowMainViewCtl.c_str());
00126    CSGAction *showAddCollection    = new CSGAction(this, cmsshow::sShowAddCollection.c_str());
00127    CSGAction *showInvMassDialog    = new CSGAction(this, cmsshow::sShowInvMassDialog.c_str());
00128 
00129    CSGAction *help               = new CSGAction(this, cmsshow::sHelp.c_str());
00130    CSGAction *keyboardShort      = new CSGAction(this, cmsshow::sKeyboardShort.c_str());
00131    CSGAction *helpGL             = new CSGAction(this, cmsshow::sHelpGL.c_str());
00132 
00133    m_nextEvent = nextEvent;
00134    m_previousEvent = previousEvent;
00135    m_goToFirst = goToFirst;
00136    m_goToLast = goToLast;
00137    m_playEvents = playEvents;
00138    m_playEventsBack = playEventsBack;
00139    m_loopAction = loop;
00140 
00141    goToFirst->setToolTip("Goto first event");
00142    goToLast->setToolTip("Goto last event");
00143    previousEvent->setToolTip("Goto previous event");
00144    nextEvent->setToolTip("Goto next event");
00145    playEvents->setToolTip("Play events");
00146    playEventsBack->setToolTip("Play events backwards");
00147 
00148    TGCompositeFrame *menuTopFrame = new TGCompositeFrame(this, 1, 1, kHorizontalFrame, backgroundColor);
00149 
00150    TGMenuBar *menuBar = new TGMenuBar(menuTopFrame, this->GetWidth(), 28, kHorizontalFrame);
00151 
00152    TGPopupMenu *fileMenu = new TGPopupMenu(gClient->GetRoot());
00153    menuBar->AddPopup("File", fileMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
00154    
00155    openData->createMenuEntry(fileMenu);
00156    appendData->createMenuEntry(fileMenu);
00157    searchFiles->createMenuEntry(fileMenu);
00158    //searchFiles->disable();
00159    loadConfig->createMenuEntry(fileMenu);
00160    saveConfig->createMenuEntry(fileMenu);
00161    saveConfigAs->createMenuEntry(fileMenu);
00162    fileMenu->AddSeparator();
00163     
00164    exportImage->createMenuEntry(fileMenu);
00165    exportImages->createMenuEntry(fileMenu);
00166    fileMenu->AddSeparator();
00167 
00168    quit->createMenuEntry(fileMenu);
00169 
00170    openData->createShortcut(kKey_O, "CTRL", GetId());
00171    loadConfig->createShortcut(kKey_L, "CTRL", GetId());
00172    saveConfig->createShortcut(kKey_S, "CTRL", GetId());
00173    saveConfigAs->createShortcut(kKey_S, "CTRL+SHIFT", GetId());
00174    exportImage->createShortcut(kKey_P, "CTRL", GetId());
00175    exportImages->createShortcut(kKey_P, "CTRL+SHIFT", GetId());
00176    quit->createShortcut(kKey_Q, "CTRL", GetId());
00177 
00178    TGPopupMenu *editMenu = new TGPopupMenu(gClient->GetRoot());
00179    menuBar->AddPopup("Edit", editMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
00180 
00181    showCommonInsp->createMenuEntry(editMenu);
00182    showCommonInsp->createShortcut(kKey_A, "CTRL+SHIFT", GetId());
00183    colorset->createMenuEntry(editMenu);
00184    colorset->createShortcut(kKey_B, "CTRL", GetId());
00185    editMenu->AddSeparator();
00186 
00187    undo->createMenuEntry(editMenu);
00188    undo->createShortcut(kKey_Z, "CTRL", GetId());
00189    redo->createMenuEntry(editMenu);
00190    redo->createShortcut(kKey_Z, "CTRL+SHIFT", GetId());
00191    editMenu->AddSeparator();
00192 
00193    cut->createMenuEntry(editMenu);
00194    cut->createShortcut(kKey_X, "CTRL", GetId());
00195    copy->createMenuEntry(editMenu);
00196    copy->createShortcut(kKey_C, "CTRL", GetId());
00197    paste->createMenuEntry(editMenu);
00198    paste->createShortcut(kKey_V, "CTRL", GetId());
00199 
00200    TGPopupMenu *viewMenu = new TGPopupMenu(gClient->GetRoot());
00201    menuBar->AddPopup("View", viewMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));  
00202 
00203    m_newViewerMenu = new TGPopupMenu(gClient->GetRoot());
00204    viewMenu->AddPopup("New Viewer", m_newViewerMenu);
00205 
00206    viewMenu->AddSeparator();
00207 
00208    nextEvent->createMenuEntry(viewMenu);
00209    nextEvent->createShortcut(kKey_Right, "CTRL", GetId());
00210    previousEvent->createMenuEntry(viewMenu);
00211    previousEvent->createShortcut(kKey_Left, "CTRL", GetId());
00212    goToFirst->createMenuEntry(viewMenu);
00213    goToLast->createMenuEntry(viewMenu);
00214    playEvents->createMenuEntry(viewMenu);
00215    playEvents->createShortcut(kKey_Space, "CTRL", GetId());
00216    playEventsBack->createMenuEntry(viewMenu);
00217    playEventsBack->createShortcut(kKey_Space, "CTRL+SHIFT", GetId());
00218    loop->createMenuEntry(viewMenu);
00219 
00220    TGPopupMenu* windowMenu = new TGPopupMenu(gClient->GetRoot());
00221    menuBar->AddPopup("Window", windowMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
00222 
00223    showCommonInsp->createMenuEntry(windowMenu);
00224    showObjInsp->createMenuEntry(windowMenu);
00225    showEventDisplayInsp->createShortcut(kKey_I, "CTRL", GetId());
00226    showEventDisplayInsp->createMenuEntry(windowMenu);
00227    showAddCollection->createMenuEntry(windowMenu);
00228    showMainViewCtl->createMenuEntry(windowMenu);
00229    showInvMassDialog->createMenuEntry(windowMenu);
00230 
00231    TGPopupMenu *helpMenu = new TGPopupMenu(gClient->GetRoot());
00232    menuBar->AddPopup("Help", helpMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
00233    help->createMenuEntry(helpMenu);
00234    keyboardShort->createMenuEntry(helpMenu);
00235    helpMenu->AddSeparator();
00236    helpGL->createMenuEntry(helpMenu);
00237 
00238    // colors
00239    menuBar->SetBackgroundColor(backgroundColor);
00240    TIter next(menuBar->GetTitles());
00241    TGMenuTitle *title;
00242    while ((title = (TGMenuTitle *)next()))
00243       title->SetTextColor(textColor);
00244 
00245    menuTopFrame->AddFrame(menuBar, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
00246    AddFrame(menuTopFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
00247 
00248    // !!!! MT Line separating menu from other window components.
00249    // I would even remove it and squeeze the navigation buttons up.
00250    AddFrame(new TGFrame(this, 1, 1, kChildFrame, 0x503020),
00251             new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
00252 
00253    m_statBar = new TGStatusBar(this, this->GetWidth(), 12);
00254    AddFrame(m_statBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
00255 
00256    TGHorizontalFrame *fullbar = new TGHorizontalFrame(this, this->GetWidth(), 30,0, backgroundColor);
00257 
00258    /**************************************************************************/
00259    // controls
00260 
00261    TGCompositeFrame* controlFrame = new TGVerticalFrame(fullbar, 10, 20, 0, backgroundColor);
00262 
00263    TGCompositeFrame* buttonFrame = new TGHorizontalFrame(controlFrame, 10, 10, 0, backgroundColor);
00264    TImage *imgBtn  = TImage::Open(FWCheckBoxIcon::coreIcondir()+"slider-bg-up.png");
00265    buttonFrame->SetBackgroundPixmap(imgBtn->GetPixmap());
00266 
00267 
00268    goToFirst->createCustomIconsButton(buttonFrame,
00269                                       fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-gotofirst.png"),
00270                                       fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-gotofirst-over.png"),
00271                                       fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-gotofirst-disabled.png"),
00272                                       new TGLayoutHints(kLHintsCenterY| kLHintsLeft, 4, 3, 10, 0));
00273 
00274    playEventsBack->createCustomIconsButton(buttonFrame,
00275                                            fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-backward.png"),
00276                                            fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-backward-over.png"),
00277                                            fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-backward-disabled.png"),
00278                                            fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-pause.png"),
00279                                            fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-pause-over.png"),
00280                                            new TGLayoutHints(kLHintsCenterY| kLHintsLeft, 2, 3, 10, 0));
00281 
00282    previousEvent->createCustomIconsButton(buttonFrame,
00283                                           fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-stepback.png"),
00284                                           fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-stepback-over.png"),
00285                                           fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-stepback-disabled.png"),
00286                                           new TGLayoutHints(kLHintsCenterY| kLHintsLeft, 2, 3, 10, 0));
00287 
00288    nextEvent->createCustomIconsButton(buttonFrame,
00289                                       fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-stepforward.png"),
00290                                       fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-stepforward-over.png"),
00291                                       fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-stepforward-disabled.png"),
00292                                       new TGLayoutHints(kLHintsCenterY| kLHintsLeft, 2, 3, 10, 0));
00293 
00294 
00295    playEvents->createCustomIconsButton(buttonFrame,
00296                                        fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-forward.png"),
00297                                        fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-forward-over.png"),
00298                                        fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-forward-disabled.png"),
00299                                        fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-pause.png"),
00300                                        fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-pause-over.png"),
00301                                        new TGLayoutHints(kLHintsCenterY| kLHintsLeft, 2, 3, 10, 0));
00302 
00303    goToLast->createCustomIconsButton(buttonFrame,
00304                                      fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-gotolast.png"),
00305                                      fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-gotolast-over.png"),
00306                                      fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"button-gotolast-disabled.png"),
00307                                      new TGLayoutHints(kLHintsCenterY| kLHintsLeft, 2, 3, 10, 0));
00308 
00309    controlFrame->AddFrame(buttonFrame, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
00310 
00311    /**************************************************************************/
00312 
00313    TGHorizontalFrame* sliderFrame = new TGHorizontalFrame(controlFrame, 10, 10, 0, backgroundColor);
00314    TImage *imgSld  = TImage::Open(FWCheckBoxIcon::coreIcondir()+"slider-bg-down.png");
00315    sliderFrame->SetBackgroundPixmap(imgSld->GetPixmap());
00316    TString sldBtn = FWCheckBoxIcon::coreIcondir() +"slider-button.png";
00317 
00318    m_delaySlider = new TGHSlider(sliderFrame, 109, kSlider1 | kScaleNo);
00319    sliderFrame->AddFrame(m_delaySlider, new TGLayoutHints(kLHintsTop | kLHintsLeft, 39, 8, 1, 3));
00320    m_delaySlider->SetRange(0, 10000);
00321    m_delaySlider->SetPosition(0);
00322    m_delaySlider->SetBackgroundColor(0x1a1a1a);
00323    m_delaySlider->ChangeSliderPic(sldBtn);
00324 
00325    controlFrame->AddFrame(sliderFrame, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
00326 
00327    fullbar->AddFrame(controlFrame, new TGLayoutHints(kLHintsLeft, 2, 2, 5, 8));
00328 
00329    m_delaySliderListener =  new FWIntValueListener();
00330    TQObject::Connect(m_delaySlider, "PositionChanged(Int_t)", "FWIntValueListenerBase",  m_delaySliderListener, "setValue(Int_t)");
00331 
00332    //==============================================================================
00333 
00334    // delay label
00335    {
00336       TGVerticalFrame* delayFrame = new TGVerticalFrame(fullbar, 60, 10, 0, backgroundColor);
00337 
00338       TGLabel *label = new TGLabel(delayFrame, "Delay");
00339       label->SetTextJustify(kTextCenterX);
00340       label->SetTextColor(0xb3b3b3);
00341       label->SetBackgroundColor(backgroundColor);
00342       delayFrame->AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 22, 0));
00343 
00344       TGHorizontalFrame *labFixed = new TGHorizontalFrame(delayFrame, 70, 20, kFixedSize, backgroundColor);
00345       m_delayLabel = new TGLabel(labFixed, "0.0s");
00346       m_delayLabel->SetBackgroundColor(backgroundColor);
00347       m_delayLabel->SetTextJustify(kTextCenterX);
00348       m_delayLabel->SetTextColor(0xffffff);
00349       labFixed->AddFrame(m_delayLabel, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 0, 0, 0, 0));
00350       delayFrame->AddFrame(labFixed, new TGLayoutHints(kLHintsLeft, 0, 4, 0, 0));
00351 
00352       fullbar->AddFrame(delayFrame, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00353    }
00354 
00355    //==============================================================================
00356 
00357    // text/num entries
00358 
00359    Int_t entryHeight = 22;
00360    TGVerticalFrame *texts = new TGVerticalFrame(fullbar, 400, 10, 0, backgroundColor);
00361 
00362    // upper row
00363    {
00364       TGPack *runInfo = new TGPack(texts, 400, entryHeight, kFixedHeight);
00365       runInfo->SetVertical(kFALSE);
00366       runInfo->SetUseSplitters(kFALSE);
00367       runInfo->SetBackgroundColor(backgroundColor);
00368 
00369       TGHorizontalFrame *rLeft = new TGHorizontalFrame(runInfo, 1, entryHeight);
00370       makeFixedSizeLabel(rLeft, "Run", backgroundColor, 0xffffff, 26, entryHeight);
00371       m_runEntry = new FWNumberEntryField(rLeft, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
00372       rLeft->AddFrame(m_runEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0,8,0,0));
00373       runInfo->AddFrameWithWeight(rLeft, 0, 0.28);
00374 
00375       TGHorizontalFrame *rMid = new TGHorizontalFrame(runInfo, 1, entryHeight);
00376       makeFixedSizeLabel(rMid, "Lumi", backgroundColor, 0xffffff, 36, entryHeight);
00377       m_lumiEntry = new FWNumberEntryField(rMid, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
00378       rMid->AddFrame(m_lumiEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0,8,0,0));
00379       runInfo->AddFrameWithWeight(rMid, 0, 0.32);
00380 
00381       TGHorizontalFrame *rRight = new TGHorizontalFrame(runInfo, 1, entryHeight);
00382       makeFixedSizeLabel(rRight, "Event", backgroundColor, 0xffffff, 42, entryHeight);
00383       m_eventEntry = new FWNumberEntryField(rRight, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
00384       rRight->AddFrame(m_eventEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0,0,0,0));
00385       runInfo->AddFrameWithWeight(rRight, 0, 0.4);
00386 
00387       texts->AddFrame(runInfo, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,0,4));
00388    }
00389 
00390    // lower row
00391    {
00392       TGHorizontalFrame *filterFrame = new TGHorizontalFrame(texts, 400, entryHeight, 0, backgroundColor);
00393    
00394       // filter state Off
00395       m_filterIcons[0] = fClient->GetPicture("unchecked_t.xpm");
00396       m_filterIcons[1] = fClient->GetPicture("unchecked_t.xpm");
00397       m_filterIcons[2] = fClient->GetPicture("unchecked_dis_t.xpm");
00398    
00399       // filter state On
00400       m_filterIcons[3] = fClient->GetPicture("checked_t.xpm");
00401       m_filterIcons[4] = fClient->GetPicture("checked_t.xpm");
00402       m_filterIcons[5] = fClient->GetPicture("checked_dis_t.xpm");
00403    
00404       // filter withdrawn
00405       m_filterIcons[6] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg.png");
00406       m_filterIcons[7] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg-over.png");
00407       m_filterIcons[8] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg.png");
00408    
00409       m_filterEnableBtn = new FWCustomIconsButton(filterFrame, m_filterIcons[0], m_filterIcons[1], m_filterIcons[2]);
00410       m_filterEnableBtn->SetBackgroundColor(backgroundColor);
00411       m_filterEnableBtn->SetToolTipText("Enable/disable event filtering");
00412       filterFrame->AddFrame(m_filterEnableBtn, new TGLayoutHints(kLHintsLeft, 4,0,3,0));
00413 
00414       m_filterShowGUIBtn = new TGTextButton(filterFrame,"Event filtering is OFF");
00415       m_filterShowGUIBtn->ChangeOptions(kRaisedFrame);
00416       m_filterShowGUIBtn->SetBackgroundColor(backgroundColor);
00417       m_filterShowGUIBtn->SetTextColor(0xFFFFFF);
00418       m_filterShowGUIBtn->SetToolTipText("Edit filters");
00419       filterFrame->AddFrame(m_filterShowGUIBtn, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 6,7,0,0));
00420 
00421       texts->AddFrame(filterFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,4,0));
00422    }
00423 
00424    fullbar->AddFrame(texts, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 12, 0));
00425 
00426    //==============================================================================
00427 
00428    TGVerticalFrame *texts2 = new TGVerticalFrame(fullbar, 200, 44, kFixedSize, backgroundColor);
00429 
00430    // time
00431    m_timeText = new TGLabel(texts2, "...");
00432    m_timeText->SetTextJustify(kTextLeft);
00433    m_timeText->SetTextColor(0xffffff);
00434    m_timeText->SetBackgroundColor(backgroundColor);
00435    texts2->AddFrame(m_timeText, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,0,1));
00436 
00437    fullbar->AddFrame(texts2, new TGLayoutHints(kLHintsLeft, 5, 5, 16, 5));
00438 
00439    //==============================================================================
00440 
00441    //  logo
00442    {
00443       TGVerticalFrame* parentLogoFrame = new TGVerticalFrame(fullbar, 70, 53, kFixedSize); 
00444       parentLogoFrame->SetBackgroundColor(backgroundColor);
00445       fullbar->AddFrame(parentLogoFrame, new TGLayoutHints(kLHintsRight | kLHintsCenterY));
00446 
00447       TGVerticalFrame* logoFrame = new TGVerticalFrame(parentLogoFrame, 53, 53, kFixedSize);
00448       TImage *logoImg  = TImage::Open(FWCheckBoxIcon::coreIcondir() + "CMSRedOnBlackThick.png");
00449       logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
00450       parentLogoFrame->AddFrame(logoFrame, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 14, 0, 0));
00451    }
00452    {
00453       TGCompositeFrame *logoFrame = new TGCompositeFrame(this, 61, 23, kFixedSize | kHorizontalFrame, backgroundColor);
00454       FWCustomIconsButton *infoBut =
00455          new FWCustomIconsButton(logoFrame, fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"fireworksSmallGray.png"),
00456                                  fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"fireworksSmallGray-green.png"),
00457                                  fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"fireworksSmallGray-red.png"),
00458                                  fClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"fireworksSmallGray-red.png"));
00459       logoFrame->AddFrame(infoBut);
00460       infoBut->Connect("Clicked()", "CmsShowMainFrame", this, "showFWorksInfo()");
00461       //TImage *logoImg  = TImage::Open( FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray.png");
00462       //logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
00463       menuTopFrame->AddFrame(logoFrame, new TGLayoutHints(kLHintsRight | kLHintsBottom, 0, 13, 3, 1));
00464    }
00465   
00466    //==============================================================================
00467 
00468    AddFrame(fullbar, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
00469 
00470    //Start disabled
00471    goToFirst->disable();
00472    goToLast->disable();
00473    previousEvent->disable();
00474    nextEvent->disable();
00475    playEvents->disable();
00476    playEventsBack->disable();
00477    loop->disable();
00478    
00479    //NOTE: There appears to be a bug in ROOT such that creating a menu item and setting it as
00480    // disabled immediately is ignored.  Therefore we have to wait till here to actually get ROOT
00481    // to disable these menu items
00482    undo->disable();
00483    redo->disable();
00484    cut->disable();
00485    copy->disable();
00486    paste->disable();
00487    
00488    //==============================================================================
00489 
00490    FWPack *csArea = new FWPack(this);
00491    csArea->SetVertical(kFALSE);
00492 
00493    TGCompositeFrame *cf = m_manager->createList(csArea);
00494    csArea->AddFrameWithWeight(cf, 0, 20);
00495 
00496    TEveCompositeFrameInPack *slot = new TEveCompositeFrameInPack(csArea, 0, csArea);
00497    csArea->AddFrameWithWeight(slot, 0, 80);
00498    TEveWindowSlot *ew_slot = TEveWindow::CreateDefaultWindowSlot();
00499    ew_slot->PopulateEmptyFrame(slot);
00500    m_manager->createViews(ew_slot);
00501 
00502    AddFrame(csArea,new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 2));
00503    csArea->MapSubwindows();
00504 
00505    SetWindowName("cmsShow");
00506 }
00507 
00508 // CmsShowMainFrame::CmsShowMainFrame(const CmsShowMainFrame& rhs)
00509 // {
00510 //    // do actual copying here;
00511 // }
00512 
00513 CmsShowMainFrame::~CmsShowMainFrame() {
00514    Cleanup();
00515 }
00516 
00517 //
00518 // assignment operators
00519 //
00520 // const CmsShowMainFrame& CmsShowMainFrame::operator=(const CmsShowMainFrame& rhs)
00521 // {
00522 //   //An exception safe implementation is
00523 //   CmsShowMainFrame temp(rhs);
00524 //   swap(rhs);
00525 //
00526 //   return *this;
00527 // }
00528 
00529 //
00530 // member functions
00531 //
00532 
00533 CSGAction*
00534 CmsShowMainFrame::createNewViewerAction(const std::string& iActionName, bool separator)
00535 {
00536    CSGAction* action(new CSGAction(this, iActionName.c_str()));
00537    action->createMenuEntry(m_newViewerMenu);
00538    if (separator) m_newViewerMenu->AddSeparator();
00539    return action;
00540 }
00541 
00542 void CmsShowMainFrame::loadEvent(const edm::EventBase& event)
00543 {
00544    m_runEntry  ->SetUIntNumber(event.id().run());
00545    m_lumiEntry ->SetUIntNumber(event.id().luminosityBlock());
00546    m_eventEntry->SetUIntNumber(event.id().event());
00547 
00548    m_timeText->SetText( fireworks::getLocalTime( event ).c_str() );
00549 }
00550 
00551 void CmsShowMainFrame::enableNavigatorControls()
00552 {
00553    m_nextEvent->enable();
00554    m_previousEvent->enable();
00555    m_goToFirst->enable();
00556    m_goToLast->enable();
00557    m_playEvents->enable();
00558    m_playEventsBack->enable();
00559    m_loopAction->enable();
00560 }
00561 
00562 void  CmsShowMainFrame::CloseWindow()
00563 {
00564    getAction(cmsshow::sQuit)->activated();
00565 }
00566 
00567 void CmsShowMainFrame::quit() {
00568    getAction(cmsshow::sQuit)->activated();
00569 }
00570 
00571 void
00572 CmsShowMainFrame::enableActions(bool enable)
00573 {
00574    CSGActionSupervisor::enableActions(enable);
00575 
00576    m_runEntry->SetEnabled(enable);
00577    m_lumiEntry->SetEnabled(enable);
00578    m_eventEntry->SetEnabled(enable);
00579    m_filterEnableBtn->SetEnabled(enable);
00580    m_filterShowGUIBtn->SetEnabled(enable);
00581 }
00582 
00583 void
00584 CmsShowMainFrame::enablePrevious(bool enable)
00585 {
00586    if (m_previousEvent != 0) {
00587       if (enable) {
00588          m_previousEvent->enable();
00589          m_goToFirst->enable();
00590          m_playEventsBack->enable();
00591       } else {
00592          m_previousEvent->disable();
00593          m_goToFirst->disable();
00594          m_playEventsBack->disable();
00595          m_playEventsBack->stop();
00596       }
00597    }
00598 }
00599 
00600 void
00601 CmsShowMainFrame::enableNext(bool enable)
00602 {
00603    if (m_nextEvent != 0) {
00604       if (enable) {
00605          m_nextEvent->enable();
00606          m_goToLast->enable();
00607          m_playEvents->enable();
00608       } else {
00609          m_nextEvent->disable();
00610          m_goToLast->disable();
00611          m_playEvents->disable();
00612          m_playEvents->stop();
00613       }
00614    }
00615 }
00616 
00620 void
00621 CmsShowMainFrame::enableComplexNavigation(bool enable)
00622 {
00623    if (enable)
00624       m_goToLast->enable();
00625    else
00626       m_goToLast->disable();
00627 }
00628 
00629 bool
00630 CmsShowMainFrame::nextIsEnabled()
00631 {
00632    return m_nextEvent->isEnabled();
00633 }
00634 
00635 bool
00636 CmsShowMainFrame::previousIsEnabled()
00637 {
00638    return m_previousEvent->isEnabled();
00639 }
00640 
00641 void CmsShowMainFrame::updateStatusBar(const char* status) {
00642    m_statBar->SetText(status, 0);
00643    //force the status bar to update its image
00644    gClient->ProcessEventsFor(m_statBar);
00645 }
00646 
00647 void CmsShowMainFrame::clearStatusBar()
00648 {
00649    m_statBar->SetText("", 0);
00650    //don't process immediately since we want this on the event queue
00651    // since results of the last action may still be happening
00652 }
00653 
00654 void CmsShowMainFrame::HandleMenu(Int_t id) {
00655    switch(id) {
00656       case 1:
00657       {
00658          gApplication->Terminate(0);
00659       }
00660       break;
00661       default:
00662          fwLog(fwlog::kInfo) << "Invalid menu id\n";
00663          break;
00664    }
00665 }
00666 
00667 Bool_t CmsShowMainFrame::HandleKey(Event_t *event) {
00668    if (event->fType == kGKeyPress) {
00669       const std::vector<CSGAction*>& alist = getListOfActions();
00670       std::vector<CSGAction*>::const_iterator it_act;
00671       Int_t keycode;
00672       Int_t modcode;
00673       for (it_act = alist.begin(); it_act != alist.end(); ++it_act) {
00674          keycode = (*it_act)->getKeycode();
00675          modcode = (*it_act)->getModcode();
00676          if ((event->fCode == (UInt_t)keycode) &&
00677              ((event->fState == (UInt_t)modcode) ||
00678               (event->fState == (UInt_t)(modcode | kKeyMod2Mask)) ||
00679               (event->fState == (UInt_t)(modcode | kKeyLockMask)) ||
00680               (event->fState == (UInt_t)(modcode | kKeyMod2Mask | kKeyLockMask)))) {
00681             (*it_act)->activated.emit();
00682             //  return kTRUE;
00683             return false;
00684          }
00685       }
00686    }
00687    return kFALSE;
00688 }
00689 
00690 void
00691 CmsShowMainFrame::setPlayDelayGUI(Float_t val, Bool_t sliderChanged)
00692 {
00693    m_delayLabel->SetText(Form("%.1fs", val));
00694    if (sliderChanged)
00695       m_delaySlider->SetPosition(Int_t(val*1000));
00696 }
00697 
00698 void
00699 CmsShowMainFrame::makeFixedSizeLabel(TGHorizontalFrame* p, const char* txt,
00700                                      UInt_t bgCol, UInt_t txtCol,
00701                                      Int_t  width, Int_t  height)
00702 {
00703    // Utility function.
00704 
00705 
00706    p->SetBackgroundColor(bgCol);
00707    TGCompositeFrame *lframe = new TGHorizontalFrame(p, width, height, kFixedSize, bgCol);
00708    TGLabel* label = new TGLabel(lframe, txt);
00709    label->SetBackgroundColor(bgCol);
00710    label->SetTextColor(txtCol);
00711    lframe->AddFrame(label, new TGLayoutHints(kLHintsRight | kLHintsTop, 0, 4));
00712    p->AddFrame(lframe, new TGLayoutHints(kLHintsLeft, 0, 0, 3, 0));
00713 }
00714 
00715 class InfoFrame : public TGMainFrame {
00716 public:
00717    InfoFrame(const TGWindow* p, UInt_t w, UInt_t h, UInt_t opts) : TGMainFrame(p, w, h, opts) {}
00718    virtual ~InfoFrame() {}
00719    
00720    virtual void CloseWindow()
00721    {
00722       UnmapWindow();  
00723    }
00724 };
00725 
00726 void
00727 CmsShowMainFrame::showFWorksInfo()
00728 {
00729    if (m_fworksAbout == 0)
00730    {
00731       UInt_t ww = 280, hh = 190;
00732       int number_of_lines = 0;
00733       int fontSize = 8;
00734       TString infoText;
00735       if (gSystem->Getenv("CMSSW_VERSION"))
00736       {
00737          infoText = "Version ";
00738          infoText += gSystem->Getenv("CMSSW_VERSION");
00739          infoText +="\n";
00740          number_of_lines += 1;
00741       }
00742       else
00743       {
00744          TString infoFileName("/data/version.txt");
00745          fireworks::setPath(infoFileName);
00746          std::string line;
00747          ifstream infoFile(infoFileName);
00748          while (std::getline(infoFile, line))
00749          {
00750             ++number_of_lines;
00751             infoText += line.c_str();
00752             infoText += "\n";
00753          }
00754          infoFile.close();
00755       }
00756       infoText += "\nIt works or we fix it for free!\nhn-cms-visualization@cern.ch\n";
00757 
00758       hh = 130 + 2* fontSize*(number_of_lines + 1);
00759       
00760       m_fworksAbout = new InfoFrame(gClient->GetRoot(), ww, hh, kVerticalFrame | kFixedSize);
00761       m_fworksAbout->SetWMSizeHints(ww, hh, ww, hh, 0, 0);
00762       m_fworksAbout->SetBackgroundColor(0x2f2f2f);
00763       
00764       TGFrame* logoFrame = new TGFrame(m_fworksAbout, 140, 48, kFixedSize);
00765       TImage *logoImg  = TImage::Open(FWCheckBoxIcon::coreIcondir()+"logo-fireworks.png");
00766       logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
00767       m_fworksAbout->AddFrame(logoFrame, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 16, 0));
00768       
00769       TGLabel* label = new TGLabel(m_fworksAbout, infoText);
00770       label->SetBackgroundColor(0x2f2f2f);
00771       label->SetForegroundColor(0xffffff);
00772 
00773       FontStruct_t defaultFontStruct = label->GetDefaultFontStruct();
00774       try
00775       {
00776          TGFontPool *pool = gClient->GetFontPool();
00777          TGFont* defaultFont = pool->GetFont(defaultFontStruct);
00778          FontAttributes_t attributes = defaultFont->GetFontAttributes();
00779          label->SetTextFont(pool->GetFont(attributes.fFamily, fontSize, 
00780                                           attributes.fWeight, attributes.fSlant));
00781       } 
00782       catch(...)
00783       {
00784       }
00785 
00786       m_fworksAbout->AddFrame(label, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 0, 0, 12, 0));      
00787             
00788       TGTextButton* btn = new TGTextButton(m_fworksAbout, "  OK  ");
00789       btn->SetBackgroundColor(0x2f2f2f);
00790       btn->SetForegroundColor(0xffffff);
00791       m_fworksAbout->AddFrame(btn, new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 0, 12));
00792       btn->Connect("Clicked()", "TGMainFrame", m_fworksAbout, "CloseWindow()");
00793 
00794       m_fworksAbout->MapSubwindows();
00795       m_fworksAbout->Layout();
00796    }
00797    
00798    m_fworksAbout->MapRaised();
00799 }
00800 
00801 
00802 void
00803 CmsShowMainFrame::bindCSGActionKeys(const TGMainFrame* f) const
00804 {
00805    for (std::vector<CSGAction*>::const_iterator i = m_actionList.begin(); i != m_actionList.end(); ++i)
00806    {
00807       if ((*i)-> getKeycode())
00808          f->BindKey(this, (*i)->getKeycode(), (*i)->getModcode()); 
00809    }
00810 }
00811 
00812 void
00813 CmsShowMainFrame::setSummaryViewWeight(float x)
00814 {
00815 
00816    TGFrameElement* fe = (TGFrameElement*) GetList()->Last();
00817    FWPack* pack = (FWPack*)(fe->fFrame);
00818 
00819    TGFrameElementPack* fep;
00820    fep  = (TGFrameElementPack*)pack->GetList()->At(1);
00821    fep->fWeight = x;
00822 
00823    fep  = (TGFrameElementPack*)pack->GetList()->At(3);
00824    fep->fWeight = 100 -x;
00825 
00826    pack->ResizeExistingFrames();
00827    pack->Layout();
00828 }
00829 
00830 float
00831 CmsShowMainFrame::getSummaryViewWeight() const
00832 {
00833    TGFrameElement* fe = (TGFrameElement*)GetList()->Last();
00834    TGPack* pack = (TGPack*)(fe->fFrame);
00835 
00836    TGFrameElementPack* fep = (TGFrameElementPack*)pack->GetList()->At(1);
00837    return fep->fWeight;
00838       
00839 }