CMS 3D CMS Logo

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