Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:06

0001 
0002 // -*- C++ -*-
0003 //
0004 // Package:     Core
0005 // Class  :     CmsShowMainFrame
0006 //
0007 // Implementation:
0008 //     <Notes on implementation>
0009 //
0010 // Original Author:  Chris Jones
0011 //         Created:  Thu May 29 20:58:23 CDT 2008
0012 
0013 #include "FWCore/Common/interface/EventBase.h"
0014 
0015 // system include files
0016 #include <TCollection.h>
0017 #include <TApplication.h>
0018 #include <TEveWindow.h>
0019 #include <TGClient.h>
0020 #include <TGLayout.h>
0021 #include <TGButton.h>
0022 #include <TGMenu.h>
0023 #include <TGLabel.h>
0024 #include <TGTab.h>
0025 #include <TGPack.h>
0026 #include <TGStatusBar.h>
0027 #include <KeySymbols.h>
0028 #include <TGSlider.h>
0029 #include <TSystem.h>
0030 #include <TImage.h>
0031 #include <TEnv.h>
0032 #include <TVirtualX.h>
0033 // user include files
0034 #include "DataFormats/Provenance/interface/EventID.h"
0035 #include "Fireworks/Core/interface/CSGAction.h"
0036 #include "Fireworks/Core/interface/CSGContinuousAction.h"
0037 #include "Fireworks/Core/interface/CmsShowMainFrame.h"
0038 #include "Fireworks/Core/interface/ActionsList.h"
0039 #include "Fireworks/Core/interface/BuilderUtils.h"
0040 
0041 #include "Fireworks/Core/interface/FWGUIManager.h"
0042 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
0043 
0044 #include "Fireworks/Core/interface/FWIntValueListener.h"
0045 #include "Fireworks/Core/interface/fwLog.h"
0046 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
0047 #include "Fireworks/Core/src/FWNumberEntry.h"
0048 
0049 #include "Fireworks/Core/interface/fwPaths.h"
0050 #include "Fireworks/Core/interface/Context.h"
0051 #include "Fireworks/Core/interface/CmsShowCommon.h"
0052 
0053 #include <fstream>
0054 
0055 //
0056 // constants, enums and typedefs
0057 //
0058 
0059 //
0060 // static data member definitions
0061 //
0062 
0063 // AMT: temprary workaround until TGPack::ResizeExistingFrames() is public
0064 class FWPack : public TGPack {
0065   friend class CmsShowMainFrame;
0066 
0067 public:
0068   FWPack(const TGWindow *w) : TGPack(w, 100, 100) {}
0069   ~FWPack() override {}
0070 };
0071 
0072 //
0073 // constructors and destructor
0074 //
0075 CmsShowMainFrame::CmsShowMainFrame(const TGWindow *p, UInt_t w, UInt_t h, FWGUIManager *m)
0076     : TGMainFrame(p, w, h),
0077       m_filterEnableBtn(),
0078       m_filterShowGUIBtn(),
0079       m_runEntry(nullptr),
0080       m_lumiEntry(nullptr),
0081       m_eventEntry(nullptr),
0082       m_delaySliderListener(nullptr),
0083       m_manager(m),
0084       m_fworksAbout(nullptr) {
0085   const unsigned int backgroundColor = 0x2f2f2f;
0086   const unsigned int textColor = 0xb3b3b3;
0087   gClient->SetStyle("classic");
0088   CSGAction *openData = new CSGAction(this, cmsshow::sOpenData.c_str());
0089   CSGAction *appendData = new CSGAction(this, cmsshow::sAppendData.c_str());
0090   CSGAction *searchFiles = new CSGAction(this, cmsshow::sSearchFiles.c_str());
0091 
0092   CSGAction *loadConfig = new CSGAction(this, cmsshow::sLoadConfig.c_str());
0093   CSGAction *saveConfig = new CSGAction(this, cmsshow::sSaveConfig.c_str());
0094   CSGAction *saveConfigAs = new CSGAction(this, cmsshow::sSaveConfigAs.c_str());
0095 
0096   CSGAction *loadPartialConfig = new CSGAction(this, cmsshow::sLoadPartialConfig.c_str());
0097   CSGAction *savePartialConfig = new CSGAction(this, cmsshow::sSavePartialConfig.c_str());
0098   CSGAction *savePartialConfigAs = new CSGAction(this, cmsshow::sSavePartialConfigAs.c_str());
0099 
0100   CSGAction *exportImage = new CSGAction(this, cmsshow::sExportImage.c_str());
0101   CSGAction *exportImages = new CSGAction(this, cmsshow::sExportAllImages.c_str());
0102   CSGAction *quit = new CSGAction(this, cmsshow::sQuit.c_str());
0103 
0104   CSGAction *undo = new CSGAction(this, cmsshow::sUndo.c_str());
0105   undo->disable();  //NOTE: All disables happen again later in this routine
0106   CSGAction *redo = new CSGAction(this, cmsshow::sRedo.c_str());
0107   redo->disable();  //NOTE: All disables happen again later in this routine
0108   CSGAction *cut = new CSGAction(this, cmsshow::sCut.c_str());
0109   cut->disable();  //NOTE: All disables happen again later in this routine
0110   CSGAction *copy = new CSGAction(this, cmsshow::sCopy.c_str());
0111   copy->disable();  //NOTE: All disables happen again later in this routine
0112   CSGAction *paste = new CSGAction(this, cmsshow::sPaste.c_str());
0113   paste->disable();  //NOTE: All disables happen again later in this routine
0114 
0115   CSGAction *goToFirst = new CSGAction(this, cmsshow::sGotoFirstEvent.c_str());
0116   CSGAction *goToLast = new CSGAction(this, cmsshow::sGotoLastEvent.c_str());
0117 
0118   CSGAction *nextEvent = new CSGAction(this, cmsshow::sNextEvent.c_str());
0119   CSGAction *previousEvent = new CSGAction(this, cmsshow::sPreviousEvent.c_str());
0120 
0121   CSGContinuousAction *playEvents = new CSGContinuousAction(this, cmsshow::sPlayEvents.c_str());
0122   CSGContinuousAction *playEventsBack = new CSGContinuousAction(this, cmsshow::sPlayEventsBack.c_str());
0123   CSGContinuousAction *loop = new CSGContinuousAction(this, cmsshow::sAutoRewind.c_str());
0124 
0125   CSGAction *showCommonInsp = new CSGAction(this, cmsshow::sShowCommonInsp.c_str());
0126   CSGAction *colorset = new CSGAction(this, cmsshow::sBackgroundColor.c_str());
0127 
0128   CSGAction *showObjInsp = new CSGAction(this, cmsshow::sShowObjInsp.c_str());
0129   CSGAction *showEventDisplayInsp = new CSGAction(this, cmsshow::sShowEventDisplayInsp.c_str());
0130   CSGAction *showMainViewCtl = new CSGAction(this, cmsshow::sShowMainViewCtl.c_str());
0131   CSGAction *showAddCollection = new CSGAction(this, cmsshow::sShowAddCollection.c_str());
0132   CSGAction *showInvMassDialog = new CSGAction(this, cmsshow::sShowInvMassDialog.c_str());
0133 
0134   CSGAction *help = new CSGAction(this, cmsshow::sHelp.c_str());
0135   CSGAction *keyboardShort = new CSGAction(this, cmsshow::sKeyboardShort.c_str());
0136   CSGAction *helpGL = new CSGAction(this, cmsshow::sHelpGL.c_str());
0137 
0138   m_nextEvent = nextEvent;
0139   m_previousEvent = previousEvent;
0140   m_goToFirst = goToFirst;
0141   m_goToLast = goToLast;
0142   m_playEvents = playEvents;
0143   m_playEventsBack = playEventsBack;
0144   m_loopAction = loop;
0145 
0146   goToFirst->setToolTip("Goto first event");
0147   goToLast->setToolTip("Goto last event");
0148   previousEvent->setToolTip("Goto previous event");
0149   nextEvent->setToolTip("Goto next event");
0150   playEvents->setToolTip("Play events");
0151   playEventsBack->setToolTip("Play events backwards");
0152 
0153   TGCompositeFrame *menuTopFrame = new TGCompositeFrame(this, 1, 1, kHorizontalFrame, backgroundColor);
0154 
0155   TGMenuBar *menuBar = new TGMenuBar(menuTopFrame, this->GetWidth(), 28, kHorizontalFrame);
0156 
0157   TGPopupMenu *fileMenu = new TGPopupMenu(gClient->GetRoot());
0158   menuBar->AddPopup("File", fileMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
0159 
0160   openData->createMenuEntry(fileMenu);
0161   appendData->createMenuEntry(fileMenu);
0162   searchFiles->createMenuEntry(fileMenu);
0163   //searchFiles->disable();
0164 
0165   fileMenu->AddSeparator();
0166   loadConfig->createMenuEntry(fileMenu);
0167   saveConfig->createMenuEntry(fileMenu);
0168   saveConfigAs->createMenuEntry(fileMenu);
0169 
0170   TGPopupMenu *partialSaveMenu = new TGPopupMenu(gClient->GetRoot());
0171   fileMenu->AddPopup("Advanced Configuration", partialSaveMenu);
0172 
0173   loadPartialConfig->createMenuEntry(partialSaveMenu);
0174   savePartialConfig->createMenuEntry(partialSaveMenu);
0175   savePartialConfigAs->createMenuEntry(partialSaveMenu);
0176   fileMenu->AddSeparator();
0177 
0178   exportImage->createMenuEntry(fileMenu);
0179   exportImages->createMenuEntry(fileMenu);
0180   fileMenu->AddSeparator();
0181 
0182   quit->createMenuEntry(fileMenu);
0183 
0184   openData->createShortcut(kKey_O, "CTRL", GetId());
0185   loadConfig->createShortcut(kKey_L, "CTRL", GetId());
0186   saveConfig->createShortcut(kKey_S, "CTRL", GetId());
0187   saveConfigAs->createShortcut(kKey_S, "CTRL+SHIFT", GetId());
0188   exportImage->createShortcut(kKey_P, "CTRL", GetId());
0189   // comment out the followinf one, seems to get double open file dialog events on OSX
0190   // exportImages->createShortcut(kKey_P, "CTRL+SHIFT", GetId());
0191   quit->createShortcut(kKey_Q, "CTRL", GetId());
0192 
0193   TGPopupMenu *editMenu = new TGPopupMenu(gClient->GetRoot());
0194   menuBar->AddPopup("Edit", editMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
0195 
0196   showCommonInsp->createMenuEntry(editMenu);
0197   showCommonInsp->createShortcut(kKey_A, "CTRL+SHIFT", GetId());
0198   colorset->createMenuEntry(editMenu);
0199   colorset->createShortcut(kKey_B, "CTRL", GetId());
0200   editMenu->AddSeparator();
0201 
0202   undo->createMenuEntry(editMenu);
0203   undo->createShortcut(kKey_Z, "CTRL", GetId());
0204   redo->createMenuEntry(editMenu);
0205   redo->createShortcut(kKey_Z, "CTRL+SHIFT", GetId());
0206   editMenu->AddSeparator();
0207 
0208   cut->createMenuEntry(editMenu);
0209   cut->createShortcut(kKey_X, "CTRL", GetId());
0210   copy->createMenuEntry(editMenu);
0211   copy->createShortcut(kKey_C, "CTRL", GetId());
0212   paste->createMenuEntry(editMenu);
0213   paste->createShortcut(kKey_V, "CTRL", GetId());
0214 
0215   TGPopupMenu *viewMenu = new TGPopupMenu(gClient->GetRoot());
0216   menuBar->AddPopup("View", viewMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
0217 
0218   m_newViewerMenu = new TGPopupMenu(gClient->GetRoot());
0219   viewMenu->AddPopup("New Viewer", m_newViewerMenu);
0220 
0221   viewMenu->AddSeparator();
0222 
0223   nextEvent->createMenuEntry(viewMenu);
0224   nextEvent->createShortcut(kKey_Right, "CTRL", GetId());
0225   previousEvent->createMenuEntry(viewMenu);
0226   previousEvent->createShortcut(kKey_Left, "CTRL", GetId());
0227   goToFirst->createMenuEntry(viewMenu);
0228   goToLast->createMenuEntry(viewMenu);
0229   playEvents->createMenuEntry(viewMenu);
0230   playEvents->createShortcut(kKey_Space, "CTRL", GetId());
0231   playEventsBack->createMenuEntry(viewMenu);
0232   playEventsBack->createShortcut(kKey_Space, "CTRL+SHIFT", GetId());
0233   loop->createMenuEntry(viewMenu);
0234 
0235   TGPopupMenu *windowMenu = new TGPopupMenu(gClient->GetRoot());
0236   menuBar->AddPopup("Window", windowMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
0237 
0238   showCommonInsp->createMenuEntry(windowMenu);
0239   showObjInsp->createMenuEntry(windowMenu);
0240   showEventDisplayInsp->createShortcut(kKey_I, "CTRL", GetId());
0241   showEventDisplayInsp->createMenuEntry(windowMenu);
0242   showAddCollection->createMenuEntry(windowMenu);
0243   showMainViewCtl->createMenuEntry(windowMenu);
0244   showInvMassDialog->createMenuEntry(windowMenu);
0245 
0246   TGPopupMenu *helpMenu = new TGPopupMenu(gClient->GetRoot());
0247   menuBar->AddPopup("Help", helpMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
0248   help->createMenuEntry(helpMenu);
0249   keyboardShort->createMenuEntry(helpMenu);
0250   helpMenu->AddSeparator();
0251   helpGL->createMenuEntry(helpMenu);
0252 
0253   // colors
0254   menuBar->SetBackgroundColor(backgroundColor);
0255   TIter next(menuBar->GetTitles());
0256   TGMenuTitle *title;
0257   while ((title = (TGMenuTitle *)next()))
0258     title->SetTextColor(textColor);
0259 
0260   menuTopFrame->AddFrame(menuBar, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
0261 
0262   AddFrame(menuTopFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
0263 
0264   // !!!! MT Line separating menu from other window components.
0265   // I would even remove it and squeeze the navigation buttons up.
0266   AddFrame(new TGFrame(this, 1, 1, kChildFrame, 0x503020), new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
0267 
0268   m_statBar = new TGStatusBar(this, this->GetWidth(), 12);
0269   AddFrame(m_statBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
0270 
0271   TGHorizontalFrame *fullbar = new TGHorizontalFrame(this, this->GetWidth(), 30, 0, backgroundColor);
0272 
0273   /**************************************************************************/
0274   // controls
0275 
0276   TGCompositeFrame *controlFrame = new TGVerticalFrame(fullbar, 10, 20, 0, backgroundColor);
0277 
0278   TGCompositeFrame *buttonFrame = new TGHorizontalFrame(controlFrame, 10, 10, 0, backgroundColor);
0279   TImage *imgBtn = TImage::Open(FWCheckBoxIcon::coreIcondir() + "slider-bg-up.png");
0280   buttonFrame->SetBackgroundPixmap(imgBtn->GetPixmap());
0281 
0282   goToFirst->createCustomIconsButton(
0283       buttonFrame,
0284       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotofirst.png"),
0285       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotofirst-over.png"),
0286       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotofirst-disabled.png"),
0287       new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 3, 10, 0));
0288 
0289   playEventsBack->createCustomIconsButton(
0290       buttonFrame,
0291       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-backward.png"),
0292       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-backward-over.png"),
0293       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-backward-disabled.png"),
0294       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause.png"),
0295       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause-over.png"),
0296       new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
0297 
0298   previousEvent->createCustomIconsButton(
0299       buttonFrame,
0300       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepback.png"),
0301       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepback-over.png"),
0302       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepback-disabled.png"),
0303       new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
0304 
0305   nextEvent->createCustomIconsButton(
0306       buttonFrame,
0307       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepforward.png"),
0308       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepforward-over.png"),
0309       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepforward-disabled.png"),
0310       new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
0311 
0312   playEvents->createCustomIconsButton(
0313       buttonFrame,
0314       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-forward.png"),
0315       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-forward-over.png"),
0316       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-forward-disabled.png"),
0317       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause.png"),
0318       fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause-over.png"),
0319       new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
0320 
0321   goToLast->createCustomIconsButton(buttonFrame,
0322                                     fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotolast.png"),
0323                                     fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotolast-over.png"),
0324                                     fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotolast-disabled.png"),
0325                                     new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
0326 
0327   controlFrame->AddFrame(buttonFrame, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
0328 
0329   /**************************************************************************/
0330 
0331   TGHorizontalFrame *sliderFrame = new TGHorizontalFrame(controlFrame, 10, 10, 0, backgroundColor);
0332   TImage *imgSld = TImage::Open(FWCheckBoxIcon::coreIcondir() + "slider-bg-down.png");
0333   sliderFrame->SetBackgroundPixmap(imgSld->GetPixmap());
0334   TString sldBtn = FWCheckBoxIcon::coreIcondir() + "slider-button.png";
0335 
0336   m_delaySlider = new TGHSlider(sliderFrame, 109, kSlider1 | kScaleNo);
0337   sliderFrame->AddFrame(m_delaySlider, new TGLayoutHints(kLHintsTop | kLHintsLeft, 39, 8, 1, 3));
0338   m_delaySlider->SetRange(0, 10000);
0339   m_delaySlider->SetPosition(0);
0340   m_delaySlider->SetBackgroundColor(0x1a1a1a);
0341   m_delaySlider->ChangeSliderPic(sldBtn);
0342 
0343   controlFrame->AddFrame(sliderFrame, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
0344 
0345   fullbar->AddFrame(controlFrame, new TGLayoutHints(kLHintsLeft, 2, 2, 5, 8));
0346 
0347   m_delaySliderListener = new FWIntValueListener();
0348   TQObject::Connect(
0349       m_delaySlider, "PositionChanged(Int_t)", "FWIntValueListenerBase", m_delaySliderListener, "setValue(Int_t)");
0350 
0351   //==============================================================================
0352 
0353   // delay label
0354   {
0355     TGVerticalFrame *delayFrame = new TGVerticalFrame(fullbar, 60, 10, 0, backgroundColor);
0356 
0357     TGLabel *label = new TGLabel(delayFrame, "Delay");
0358     label->SetTextJustify(kTextCenterX);
0359     label->SetTextColor(0xb3b3b3);
0360     label->SetBackgroundColor(backgroundColor);
0361     delayFrame->AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 22, 0));
0362 
0363     TGHorizontalFrame *labFixed = new TGHorizontalFrame(delayFrame, 70, 20, kFixedSize, backgroundColor);
0364     m_delayLabel = new TGLabel(labFixed, "0.0s");
0365     m_delayLabel->SetBackgroundColor(backgroundColor);
0366     m_delayLabel->SetTextJustify(kTextCenterX);
0367     m_delayLabel->SetTextColor(0xffffff);
0368     labFixed->AddFrame(m_delayLabel, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 0, 0, 0, 0));
0369     delayFrame->AddFrame(labFixed, new TGLayoutHints(kLHintsLeft, 0, 4, 0, 0));
0370 
0371     fullbar->AddFrame(delayFrame, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
0372   }
0373 
0374   //==============================================================================
0375 
0376   // text/num entries
0377 
0378   Int_t entryHeight = 22;
0379   TGVerticalFrame *texts = new TGVerticalFrame(fullbar, 400, 10, 0, backgroundColor);
0380 
0381   // upper row
0382   {
0383     TGPack *runInfo = new TGPack(texts, 400, entryHeight, kFixedHeight);
0384     runInfo->SetVertical(kFALSE);
0385     runInfo->SetUseSplitters(kFALSE);
0386     runInfo->SetBackgroundColor(backgroundColor);
0387 
0388     TGHorizontalFrame *rLeft = new TGHorizontalFrame(runInfo, 1, entryHeight);
0389     makeFixedSizeLabel(rLeft, "Run", backgroundColor, 0xffffff, 26, entryHeight);
0390     m_runEntry = new FWNumberEntryField(rLeft, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
0391     rLeft->AddFrame(m_runEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 8, 0, 0));
0392     runInfo->AddFrameWithWeight(rLeft, nullptr, 0.28);
0393 
0394     TGHorizontalFrame *rMid = new TGHorizontalFrame(runInfo, 1, entryHeight);
0395     makeFixedSizeLabel(rMid, "Lumi", backgroundColor, 0xffffff, 36, entryHeight);
0396     m_lumiEntry = new FWNumberEntryField(rMid, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
0397     rMid->AddFrame(m_lumiEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 8, 0, 0));
0398     runInfo->AddFrameWithWeight(rMid, nullptr, 0.32);
0399 
0400     TGHorizontalFrame *rRight = new TGHorizontalFrame(runInfo, 1, entryHeight);
0401     makeFixedSizeLabel(rRight, "Event", backgroundColor, 0xffffff, 42, entryHeight);
0402     m_eventEntry = new FWNumberEntryField(rRight, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
0403     rRight->AddFrame(m_eventEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
0404     runInfo->AddFrameWithWeight(rRight, nullptr, 0.4);
0405 
0406     texts->AddFrame(runInfo, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 4));
0407   }
0408 
0409   // lower row
0410   {
0411     TGHorizontalFrame *filterFrame = new TGHorizontalFrame(texts, 400, entryHeight, 0, backgroundColor);
0412 
0413     // filter state Off
0414     m_filterIcons[0] = fClient->GetPicture("unchecked_t.xpm");
0415     m_filterIcons[1] = fClient->GetPicture("unchecked_t.xpm");
0416     m_filterIcons[2] = fClient->GetPicture("unchecked_dis_t.xpm");
0417 
0418     // filter state On
0419     m_filterIcons[3] = fClient->GetPicture("checked_t.xpm");
0420     m_filterIcons[4] = fClient->GetPicture("checked_t.xpm");
0421     m_filterIcons[5] = fClient->GetPicture("checked_dis_t.xpm");
0422 
0423     // filter withdrawn
0424     m_filterIcons[6] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg.png");
0425     m_filterIcons[7] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg-over.png");
0426     m_filterIcons[8] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg.png");
0427 
0428     m_filterEnableBtn = new FWCustomIconsButton(filterFrame, m_filterIcons[0], m_filterIcons[1], m_filterIcons[2]);
0429     m_filterEnableBtn->SetBackgroundColor(backgroundColor);
0430     m_filterEnableBtn->SetToolTipText("Enable/disable event filtering");
0431     filterFrame->AddFrame(m_filterEnableBtn, new TGLayoutHints(kLHintsLeft, 4, 0, 3, 0));
0432 
0433     m_filterShowGUIBtn = new TGTextButton(filterFrame, "Event filtering is OFF");
0434     m_filterShowGUIBtn->ChangeOptions(kRaisedFrame);
0435     m_filterShowGUIBtn->SetBackgroundColor(backgroundColor);
0436     m_filterShowGUIBtn->SetTextColor(0xFFFFFF);
0437     m_filterShowGUIBtn->SetToolTipText("Edit filters");
0438     filterFrame->AddFrame(m_filterShowGUIBtn, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 6, 7, 0, 0));
0439 
0440     texts->AddFrame(filterFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
0441   }
0442 
0443   fullbar->AddFrame(texts, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 12, 0));
0444 
0445   //==============================================================================
0446 
0447   TGVerticalFrame *texts2 = new TGVerticalFrame(fullbar, 200, 44, kFixedSize, backgroundColor);
0448 
0449   // time
0450   m_timeText = new TGLabel(texts2, "...");
0451   m_timeText->SetTextJustify(kTextLeft);
0452   m_timeText->SetTextColor(0xffffff);
0453   m_timeText->SetBackgroundColor(backgroundColor);
0454   texts2->AddFrame(m_timeText, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 1));
0455 
0456   fullbar->AddFrame(texts2, new TGLayoutHints(kLHintsLeft, 5, 5, 16, 5));
0457 
0458   //==============================================================================
0459 
0460   //  logo
0461   {
0462     TGVerticalFrame *parentLogoFrame = new TGVerticalFrame(fullbar, 70, 53, kFixedSize);
0463     parentLogoFrame->SetBackgroundColor(backgroundColor);
0464     fullbar->AddFrame(parentLogoFrame, new TGLayoutHints(kLHintsRight | kLHintsCenterY));
0465 
0466     TGVerticalFrame *logoFrame = new TGVerticalFrame(parentLogoFrame, 53, 53, kFixedSize);
0467     TImage *logoImg = TImage::Open(FWCheckBoxIcon::coreIcondir() + "CMSRedOnBlackThick.png");
0468     logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
0469     parentLogoFrame->AddFrame(logoFrame, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 14, 0, 0));
0470   }
0471   {
0472     TGCompositeFrame *logoFrame = new TGCompositeFrame(this, 61, 23, kFixedSize | kHorizontalFrame, backgroundColor);
0473     FWCustomIconsButton *infoBut =
0474         new FWCustomIconsButton(logoFrame,
0475                                 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray.png"),
0476                                 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray-green.png"),
0477                                 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray-red.png"),
0478                                 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray-red.png"));
0479     logoFrame->AddFrame(infoBut);
0480     infoBut->Connect("Clicked()", "CmsShowMainFrame", this, "showFWorksInfo()");
0481     //TImage *logoImg  = TImage::Open( FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray.png");
0482     //logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
0483     menuTopFrame->AddFrame(logoFrame, new TGLayoutHints(kLHintsRight | kLHintsBottom, 0, 13, 3, 1));
0484   }
0485 
0486   //==============================================================================
0487 
0488   AddFrame(fullbar, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
0489 
0490   //Start disabled
0491   goToFirst->disable();
0492   goToLast->disable();
0493   previousEvent->disable();
0494   nextEvent->disable();
0495   playEvents->disable();
0496   playEventsBack->disable();
0497   loop->disable();
0498 
0499   //NOTE: There appears to be a bug in ROOT such that creating a menu item and setting it as
0500   // disabled immediately is ignored.  Therefore we have to wait till here to actually get ROOT
0501   // to disable these menu items
0502   undo->disable();
0503   redo->disable();
0504   cut->disable();
0505   copy->disable();
0506   paste->disable();
0507 
0508   //==============================================================================
0509 
0510   FWPack *csArea = new FWPack(this);
0511   csArea->SetVertical(kFALSE);
0512 
0513   TGCompositeFrame *cf = m_manager->createList(csArea);
0514   csArea->AddFrameWithWeight(cf, nullptr, 20);
0515 
0516   TEveCompositeFrameInPack *slot = new TEveCompositeFrameInPack(csArea, nullptr, csArea);
0517   csArea->AddFrameWithWeight(slot, nullptr, 80);
0518   TEveWindowSlot *ew_slot = TEveWindow::CreateDefaultWindowSlot();
0519   ew_slot->PopulateEmptyFrame(slot);
0520   m_manager->createViews(ew_slot);
0521 
0522   AddFrame(csArea, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 2));
0523   csArea->MapSubwindows();
0524 
0525   SetWindowName("cmsShow");
0526 }
0527 
0528 // CmsShowMainFrame::CmsShowMainFrame(const CmsShowMainFrame& rhs)
0529 // {
0530 //    // do actual copying here;
0531 // }
0532 
0533 CmsShowMainFrame::~CmsShowMainFrame() { Cleanup(); }
0534 
0535 //
0536 // assignment operators
0537 //
0538 // const CmsShowMainFrame& CmsShowMainFrame::operator=(const CmsShowMainFrame& rhs)
0539 // {
0540 //   //An exception safe implementation is
0541 //   CmsShowMainFrame temp(rhs);
0542 //   swap(rhs);
0543 //
0544 //   return *this;
0545 // }
0546 
0547 //
0548 // member functions
0549 //
0550 
0551 CSGAction *CmsShowMainFrame::createNewViewerAction(const std::string &iActionName, bool separator) {
0552   CSGAction *action(new CSGAction(this, iActionName.c_str()));
0553   action->createMenuEntry(m_newViewerMenu);
0554   if (separator)
0555     m_newViewerMenu->AddSeparator();
0556   return action;
0557 }
0558 
0559 void CmsShowMainFrame::loadEvent(const edm::EventBase &event) {
0560   m_runEntry->SetUIntNumber(event.id().run());
0561   m_lumiEntry->SetUIntNumber(event.id().luminosityBlock());
0562   m_eventEntry->SetULong64Number(event.id().event());
0563 
0564   m_timeText->SetText(fireworks::getLocalTime(event).c_str());
0565 }
0566 
0567 void CmsShowMainFrame::enableNavigatorControls() {
0568   m_nextEvent->enable();
0569   m_previousEvent->enable();
0570   m_goToFirst->enable();
0571   m_goToLast->enable();
0572   m_playEvents->enable();
0573   m_playEventsBack->enable();
0574   m_loopAction->enable();
0575 }
0576 
0577 void CmsShowMainFrame::CloseWindow() { getAction(cmsshow::sQuit)->activated(); }
0578 
0579 void CmsShowMainFrame::quit() { getAction(cmsshow::sQuit)->activated(); }
0580 
0581 void CmsShowMainFrame::enableActions(bool enable) {
0582   CSGActionSupervisor::enableActions(enable);
0583 
0584   m_runEntry->SetEnabled(enable);
0585   m_lumiEntry->SetEnabled(enable);
0586   m_eventEntry->SetEnabled(enable);
0587   m_filterEnableBtn->SetEnabled(enable);
0588   m_filterShowGUIBtn->SetEnabled(enable);
0589 }
0590 
0591 void CmsShowMainFrame::enablePrevious(bool enable) {
0592   if (m_previousEvent != nullptr) {
0593     if (enable) {
0594       m_previousEvent->enable();
0595       m_goToFirst->enable();
0596       m_playEventsBack->enable();
0597     } else {
0598       m_previousEvent->disable();
0599       m_goToFirst->disable();
0600       m_playEventsBack->disable();
0601       m_playEventsBack->stop();
0602     }
0603   }
0604 }
0605 
0606 void CmsShowMainFrame::enableNext(bool enable) {
0607   if (m_nextEvent != nullptr) {
0608     if (enable) {
0609       m_nextEvent->enable();
0610       m_goToLast->enable();
0611       m_playEvents->enable();
0612     } else {
0613       m_nextEvent->disable();
0614       m_goToLast->disable();
0615       m_playEvents->disable();
0616       m_playEvents->stop();
0617     }
0618   }
0619 }
0620 
0621 /** To disable GUI to jump from event to another,
0622     when this is not possible (i.e. when in full framework mode).
0623   */
0624 void CmsShowMainFrame::enableComplexNavigation(bool enable) {
0625   if (enable)
0626     m_goToLast->enable();
0627   else
0628     m_goToLast->disable();
0629 }
0630 
0631 bool CmsShowMainFrame::nextIsEnabled() { return m_nextEvent->isEnabled(); }
0632 
0633 bool CmsShowMainFrame::previousIsEnabled() { return m_previousEvent->isEnabled(); }
0634 
0635 void CmsShowMainFrame::updateStatusBar(const char *status) {
0636   m_statBar->SetText(status, 0);
0637   //force the status bar to update its image
0638   gClient->ProcessEventsFor(m_statBar);
0639 }
0640 
0641 void CmsShowMainFrame::clearStatusBar() {
0642   m_statBar->SetText("", 0);
0643   //don't process immediately since we want this on the event queue
0644   // since results of the last action may still be happening
0645 }
0646 
0647 void CmsShowMainFrame::HandleMenu(Int_t id) {
0648   switch (id) {
0649     case 1: {
0650       gApplication->Terminate(0);
0651     } break;
0652     default:
0653       fwLog(fwlog::kInfo) << "Invalid menu id\n";
0654       break;
0655   }
0656 }
0657 
0658 Bool_t CmsShowMainFrame::HandleKey(Event_t *event) {
0659   if (event->fType == kGKeyPress) {
0660     const std::vector<CSGAction *> &alist = getListOfActions();
0661     std::vector<CSGAction *>::const_iterator it_act;
0662     Int_t keycode;
0663     Int_t modcode;
0664     for (it_act = alist.begin(); it_act != alist.end(); ++it_act) {
0665       keycode = (*it_act)->getKeycode();
0666       modcode = (*it_act)->getModcode();
0667       if ((event->fCode == (UInt_t)keycode) &&
0668           ((event->fState == (UInt_t)modcode) || (event->fState == (UInt_t)(modcode | kKeyMod2Mask)) ||
0669            (event->fState == (UInt_t)(modcode | kKeyLockMask)) ||
0670            (event->fState == (UInt_t)(modcode | kKeyMod2Mask | kKeyLockMask)))) {
0671         (*it_act)->activated.emit();
0672         //  return kTRUE;
0673         return false;
0674       }
0675     }
0676 
0677     // special case is --live option where Space key is grabbed
0678     static UInt_t spacecode = gVirtualX->KeysymToKeycode((int)kKey_Space);
0679     if (event->fCode == spacecode && event->fState == 0) {
0680       if (playEventsAction()->isRunning())
0681         playEventsAction()->switchMode();
0682       else if (playEventsBackwardsAction()->isRunning())
0683         playEventsBackwardsAction()->switchMode();
0684     }
0685   }
0686   return kFALSE;
0687 }
0688 
0689 void CmsShowMainFrame::setPlayDelayGUI(Float_t val, Bool_t sliderChanged) {
0690   m_delayLabel->SetText(Form("%.1fs", val));
0691   if (sliderChanged)
0692     m_delaySlider->SetPosition(Int_t(val * 1000));
0693 }
0694 
0695 void CmsShowMainFrame::makeFixedSizeLabel(
0696     TGHorizontalFrame *p, const char *txt, UInt_t bgCol, UInt_t txtCol, Int_t width, Int_t height) {
0697   // Utility function.
0698 
0699   p->SetBackgroundColor(bgCol);
0700   TGCompositeFrame *lframe = new TGHorizontalFrame(p, width, height, kFixedSize, bgCol);
0701   TGLabel *label = new TGLabel(lframe, txt);
0702   label->SetBackgroundColor(bgCol);
0703   label->SetTextColor(txtCol);
0704   lframe->AddFrame(label, new TGLayoutHints(kLHintsRight | kLHintsTop, 0, 4));
0705   p->AddFrame(lframe, new TGLayoutHints(kLHintsLeft, 0, 0, 3, 0));
0706 }
0707 
0708 class InfoFrame : public TGMainFrame {
0709 public:
0710   InfoFrame(const TGWindow *p, UInt_t w, UInt_t h, UInt_t opts) : TGMainFrame(p, w, h, opts) {}
0711   ~InfoFrame() override {}
0712 
0713   void CloseWindow() override { UnmapWindow(); }
0714 };
0715 
0716 void CmsShowMainFrame::showFWorksInfo() {
0717   if (m_fworksAbout == nullptr) {
0718     UInt_t ww = 280, hh = 190;
0719     int number_of_lines = 0;
0720     int fontSize = 8;
0721     TString infoText;
0722     if (gSystem->Getenv("CMSSW_VERSION")) {
0723       infoText = "Version ";
0724       infoText += gSystem->Getenv("CMSSW_VERSION");
0725       infoText += "\n";
0726       number_of_lines += 1;
0727     } else {
0728       TString infoFileName("/data/version.txt");
0729       fireworks::setPath(infoFileName);
0730       std::string line;
0731       std::ifstream infoFile(infoFileName);
0732       while (std::getline(infoFile, line)) {
0733         ++number_of_lines;
0734         infoText += line.c_str();
0735         infoText += "\n";
0736       }
0737       infoFile.close();
0738     }
0739     infoText += "\nIt works or we fix it for free!\nhn-cms-visualization@cern.ch\n";
0740 
0741     hh = 130 + 2 * fontSize * (number_of_lines + 1);
0742 
0743     m_fworksAbout = new InfoFrame(gClient->GetRoot(), ww, hh, kVerticalFrame | kFixedSize);
0744     m_fworksAbout->SetWMSizeHints(ww, hh, ww, hh, 0, 0);
0745     m_fworksAbout->SetBackgroundColor(0x2f2f2f);
0746 
0747     TGFrame *logoFrame = new TGFrame(m_fworksAbout, 140, 48, kFixedSize);
0748     TImage *logoImg = TImage::Open(FWCheckBoxIcon::coreIcondir() + "logo-fireworks.png");
0749     logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
0750     m_fworksAbout->AddFrame(logoFrame, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 16, 0));
0751 
0752     TGLabel *label = new TGLabel(m_fworksAbout, infoText);
0753     label->SetBackgroundColor(0x2f2f2f);
0754     label->SetForegroundColor(0xffffff);
0755 
0756     FontStruct_t defaultFontStruct = label->GetDefaultFontStruct();
0757     try {
0758       TGFontPool *pool = gClient->GetFontPool();
0759       TGFont *defaultFont = pool->GetFont(defaultFontStruct);
0760       FontAttributes_t attributes = defaultFont->GetFontAttributes();
0761       label->SetTextFont(pool->GetFont(attributes.fFamily, fontSize, attributes.fWeight, attributes.fSlant));
0762     } catch (...) {
0763     }
0764 
0765     m_fworksAbout->AddFrame(label, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 0, 0, 12, 0));
0766 
0767     TGTextButton *btn = new TGTextButton(m_fworksAbout, "  OK  ");
0768     btn->SetBackgroundColor(0x2f2f2f);
0769     btn->SetForegroundColor(0xffffff);
0770     m_fworksAbout->AddFrame(btn, new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 0, 12));
0771     btn->Connect("Clicked()", "TGMainFrame", m_fworksAbout, "CloseWindow()");
0772 
0773     m_fworksAbout->MapSubwindows();
0774     m_fworksAbout->Layout();
0775   }
0776 
0777   m_fworksAbout->MapRaised();
0778 }
0779 
0780 void CmsShowMainFrame::bindCSGActionKeys(const TGMainFrame *f) const {
0781   for (std::vector<CSGAction *>::const_iterator i = m_actionList.begin(); i != m_actionList.end(); ++i) {
0782     if ((*i)->getKeycode())
0783       f->BindKey(this, (*i)->getKeycode(), (*i)->getModcode());
0784   }
0785 }
0786 
0787 void CmsShowMainFrame::setSummaryViewWeight(float x) {
0788   TGFrameElement *fe = (TGFrameElement *)GetList()->Last();
0789   FWPack *pack = (FWPack *)(fe->fFrame);
0790 
0791   TGFrameElementPack *fep;
0792   fep = (TGFrameElementPack *)pack->GetList()->At(1);
0793   fep->fWeight = x;
0794 
0795   fep = (TGFrameElementPack *)pack->GetList()->At(3);
0796   fep->fWeight = 100 - x;
0797 
0798   pack->ResizeExistingFrames();
0799   pack->Layout();
0800 }
0801 
0802 float CmsShowMainFrame::getSummaryViewWeight() const {
0803   TGFrameElement *fe = (TGFrameElement *)GetList()->Last();
0804   TGPack *pack = (TGPack *)(fe->fFrame);
0805 
0806   TGFrameElementPack *fep = (TGFrameElementPack *)pack->GetList()->At(1);
0807   return fep->fWeight;
0808 }