CMS 3D CMS Logo

CmsShowMainFrame.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: Core
5 // Class : CmsShowMainFrame
6 //
7 // Implementation:
8 // <Notes on implementation>
9 //
10 // Original Author: Chris Jones
11 // Created: Thu May 29 20:58:23 CDT 2008
12 
14 
15 // system include files
16 #include <TCollection.h>
17 #include <TApplication.h>
18 #include <TEveWindow.h>
19 #include <TGClient.h>
20 #include <TGLayout.h>
21 #include <TGButton.h>
22 #include <TGMenu.h>
23 #include <TGLabel.h>
24 #include <TGTab.h>
25 #include <TGPack.h>
26 #include <TGStatusBar.h>
27 #include <KeySymbols.h>
28 #include <TGSlider.h>
29 #include <TSystem.h>
30 #include <TImage.h>
31 #include <TEnv.h>
32 #include <TVirtualX.h>
33 // user include files
40 
43 
48 
52 
53 #include <fstream>
54 
55 //
56 // constants, enums and typedefs
57 //
58 
59 //
60 // static data member definitions
61 //
62 
63 // AMT: temprary workaround until TGPack::ResizeExistingFrames() is public
64 class FWPack : public TGPack {
65  friend class CmsShowMainFrame;
66 
67 public:
68  FWPack(const TGWindow *w) : TGPack(w, 100, 100) {}
69  ~FWPack() override {}
70 };
71 
72 //
73 // constructors and destructor
74 //
75 CmsShowMainFrame::CmsShowMainFrame(const TGWindow *p, UInt_t w, UInt_t h, FWGUIManager *m)
76  : TGMainFrame(p, w, h),
79  m_runEntry(nullptr),
80  m_lumiEntry(nullptr),
81  m_eventEntry(nullptr),
82  m_delaySliderListener(nullptr),
83  m_manager(m),
84  m_fworksAbout(nullptr) {
85  const unsigned int backgroundColor = 0x2f2f2f;
86  const unsigned int textColor = 0xb3b3b3;
87  gClient->SetStyle("classic");
88  CSGAction *openData = new CSGAction(this, cmsshow::sOpenData.c_str());
89  CSGAction *appendData = new CSGAction(this, cmsshow::sAppendData.c_str());
90  CSGAction *searchFiles = new CSGAction(this, cmsshow::sSearchFiles.c_str());
91 
92  CSGAction *loadConfig = new CSGAction(this, cmsshow::sLoadConfig.c_str());
93  CSGAction *saveConfig = new CSGAction(this, cmsshow::sSaveConfig.c_str());
94  CSGAction *saveConfigAs = new CSGAction(this, cmsshow::sSaveConfigAs.c_str());
95 
96  CSGAction *loadPartialConfig = new CSGAction(this, cmsshow::sLoadPartialConfig.c_str());
97  CSGAction *savePartialConfig = new CSGAction(this, cmsshow::sSavePartialConfig.c_str());
98  CSGAction *savePartialConfigAs = new CSGAction(this, cmsshow::sSavePartialConfigAs.c_str());
99 
100  CSGAction *exportImage = new CSGAction(this, cmsshow::sExportImage.c_str());
101  CSGAction *exportImages = new CSGAction(this, cmsshow::sExportAllImages.c_str());
102  CSGAction *quit = new CSGAction(this, cmsshow::sQuit.c_str());
103 
104  CSGAction *undo = new CSGAction(this, cmsshow::sUndo.c_str());
105  undo->disable(); //NOTE: All disables happen again later in this routine
106  CSGAction *redo = new CSGAction(this, cmsshow::sRedo.c_str());
107  redo->disable(); //NOTE: All disables happen again later in this routine
108  CSGAction *cut = new CSGAction(this, cmsshow::sCut.c_str());
109  cut->disable(); //NOTE: All disables happen again later in this routine
110  CSGAction *copy = new CSGAction(this, cmsshow::sCopy.c_str());
111  copy->disable(); //NOTE: All disables happen again later in this routine
112  CSGAction *paste = new CSGAction(this, cmsshow::sPaste.c_str());
113  paste->disable(); //NOTE: All disables happen again later in this routine
114 
115  CSGAction *goToFirst = new CSGAction(this, cmsshow::sGotoFirstEvent.c_str());
116  CSGAction *goToLast = new CSGAction(this, cmsshow::sGotoLastEvent.c_str());
117 
118  CSGAction *nextEvent = new CSGAction(this, cmsshow::sNextEvent.c_str());
119  CSGAction *previousEvent = new CSGAction(this, cmsshow::sPreviousEvent.c_str());
120 
121  CSGContinuousAction *playEvents = new CSGContinuousAction(this, cmsshow::sPlayEvents.c_str());
122  CSGContinuousAction *playEventsBack = new CSGContinuousAction(this, cmsshow::sPlayEventsBack.c_str());
124 
125  CSGAction *showCommonInsp = new CSGAction(this, cmsshow::sShowCommonInsp.c_str());
126  CSGAction *colorset = new CSGAction(this, cmsshow::sBackgroundColor.c_str());
127 
128  CSGAction *showObjInsp = new CSGAction(this, cmsshow::sShowObjInsp.c_str());
129  CSGAction *showEventDisplayInsp = new CSGAction(this, cmsshow::sShowEventDisplayInsp.c_str());
130  CSGAction *showMainViewCtl = new CSGAction(this, cmsshow::sShowMainViewCtl.c_str());
131  CSGAction *showAddCollection = new CSGAction(this, cmsshow::sShowAddCollection.c_str());
132  CSGAction *showInvMassDialog = new CSGAction(this, cmsshow::sShowInvMassDialog.c_str());
133 
134  CSGAction *help = new CSGAction(this, cmsshow::sHelp.c_str());
135  CSGAction *keyboardShort = new CSGAction(this, cmsshow::sKeyboardShort.c_str());
136  CSGAction *helpGL = new CSGAction(this, cmsshow::sHelpGL.c_str());
137 
138  m_nextEvent = nextEvent;
139  m_previousEvent = previousEvent;
140  m_goToFirst = goToFirst;
141  m_goToLast = goToLast;
142  m_playEvents = playEvents;
143  m_playEventsBack = playEventsBack;
144  m_loopAction = loop;
145 
146  goToFirst->setToolTip("Goto first event");
147  goToLast->setToolTip("Goto last event");
148  previousEvent->setToolTip("Goto previous event");
149  nextEvent->setToolTip("Goto next event");
150  playEvents->setToolTip("Play events");
151  playEventsBack->setToolTip("Play events backwards");
152 
153  TGCompositeFrame *menuTopFrame = new TGCompositeFrame(this, 1, 1, kHorizontalFrame, backgroundColor);
154 
155  TGMenuBar *menuBar = new TGMenuBar(menuTopFrame, this->GetWidth(), 28, kHorizontalFrame);
156 
157  TGPopupMenu *fileMenu = new TGPopupMenu(gClient->GetRoot());
158  menuBar->AddPopup("File", fileMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
159 
160  openData->createMenuEntry(fileMenu);
161  appendData->createMenuEntry(fileMenu);
162  searchFiles->createMenuEntry(fileMenu);
163  //searchFiles->disable();
164 
165  fileMenu->AddSeparator();
166  loadConfig->createMenuEntry(fileMenu);
167  saveConfig->createMenuEntry(fileMenu);
168  saveConfigAs->createMenuEntry(fileMenu);
169 
170  TGPopupMenu *partialSaveMenu = new TGPopupMenu(gClient->GetRoot());
171  fileMenu->AddPopup("Advanced Configuration", partialSaveMenu);
172 
173  loadPartialConfig->createMenuEntry(partialSaveMenu);
174  savePartialConfig->createMenuEntry(partialSaveMenu);
175  savePartialConfigAs->createMenuEntry(partialSaveMenu);
176  fileMenu->AddSeparator();
177 
178  exportImage->createMenuEntry(fileMenu);
179  exportImages->createMenuEntry(fileMenu);
180  fileMenu->AddSeparator();
181 
182  quit->createMenuEntry(fileMenu);
183 
184  openData->createShortcut(kKey_O, "CTRL", GetId());
185  loadConfig->createShortcut(kKey_L, "CTRL", GetId());
186  saveConfig->createShortcut(kKey_S, "CTRL", GetId());
187  saveConfigAs->createShortcut(kKey_S, "CTRL+SHIFT", GetId());
188  exportImage->createShortcut(kKey_P, "CTRL", GetId());
189  // comment out the followinf one, seems to get double open file dialog events on OSX
190  // exportImages->createShortcut(kKey_P, "CTRL+SHIFT", GetId());
191  quit->createShortcut(kKey_Q, "CTRL", GetId());
192 
193  TGPopupMenu *editMenu = new TGPopupMenu(gClient->GetRoot());
194  menuBar->AddPopup("Edit", editMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
195 
196  showCommonInsp->createMenuEntry(editMenu);
197  showCommonInsp->createShortcut(kKey_A, "CTRL+SHIFT", GetId());
198  colorset->createMenuEntry(editMenu);
199  colorset->createShortcut(kKey_B, "CTRL", GetId());
200  editMenu->AddSeparator();
201 
202  undo->createMenuEntry(editMenu);
203  undo->createShortcut(kKey_Z, "CTRL", GetId());
204  redo->createMenuEntry(editMenu);
205  redo->createShortcut(kKey_Z, "CTRL+SHIFT", GetId());
206  editMenu->AddSeparator();
207 
208  cut->createMenuEntry(editMenu);
209  cut->createShortcut(kKey_X, "CTRL", GetId());
210  copy->createMenuEntry(editMenu);
211  copy->createShortcut(kKey_C, "CTRL", GetId());
212  paste->createMenuEntry(editMenu);
213  paste->createShortcut(kKey_V, "CTRL", GetId());
214 
215  TGPopupMenu *viewMenu = new TGPopupMenu(gClient->GetRoot());
216  menuBar->AddPopup("View", viewMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
217 
218  m_newViewerMenu = new TGPopupMenu(gClient->GetRoot());
219  viewMenu->AddPopup("New Viewer", m_newViewerMenu);
220 
221  viewMenu->AddSeparator();
222 
223  nextEvent->createMenuEntry(viewMenu);
224  nextEvent->createShortcut(kKey_Right, "CTRL", GetId());
225  previousEvent->createMenuEntry(viewMenu);
226  previousEvent->createShortcut(kKey_Left, "CTRL", GetId());
227  goToFirst->createMenuEntry(viewMenu);
228  goToLast->createMenuEntry(viewMenu);
229  playEvents->createMenuEntry(viewMenu);
230  playEvents->createShortcut(kKey_Space, "CTRL", GetId());
231  playEventsBack->createMenuEntry(viewMenu);
232  playEventsBack->createShortcut(kKey_Space, "CTRL+SHIFT", GetId());
233  loop->createMenuEntry(viewMenu);
234 
235  TGPopupMenu *windowMenu = new TGPopupMenu(gClient->GetRoot());
236  menuBar->AddPopup("Window", windowMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
237 
238  showCommonInsp->createMenuEntry(windowMenu);
239  showObjInsp->createMenuEntry(windowMenu);
240  showEventDisplayInsp->createShortcut(kKey_I, "CTRL", GetId());
241  showEventDisplayInsp->createMenuEntry(windowMenu);
242  showAddCollection->createMenuEntry(windowMenu);
243  showMainViewCtl->createMenuEntry(windowMenu);
244  showInvMassDialog->createMenuEntry(windowMenu);
245 
246  TGPopupMenu *helpMenu = new TGPopupMenu(gClient->GetRoot());
247  menuBar->AddPopup("Help", helpMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 2, 0));
248  help->createMenuEntry(helpMenu);
249  keyboardShort->createMenuEntry(helpMenu);
250  helpMenu->AddSeparator();
251  helpGL->createMenuEntry(helpMenu);
252 
253  // colors
254  menuBar->SetBackgroundColor(backgroundColor);
255  TIter next(menuBar->GetTitles());
256  TGMenuTitle *title;
257  while ((title = (TGMenuTitle *)next()))
258  title->SetTextColor(textColor);
259 
260  menuTopFrame->AddFrame(menuBar, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
261 
262  AddFrame(menuTopFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
263 
264  // !!!! MT Line separating menu from other window components.
265  // I would even remove it and squeeze the navigation buttons up.
266  AddFrame(new TGFrame(this, 1, 1, kChildFrame, 0x503020), new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
267 
268  m_statBar = new TGStatusBar(this, this->GetWidth(), 12);
269  AddFrame(m_statBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX));
270 
271  TGHorizontalFrame *fullbar = new TGHorizontalFrame(this, this->GetWidth(), 30, 0, backgroundColor);
272 
273  /**************************************************************************/
274  // controls
275 
276  TGCompositeFrame *controlFrame = new TGVerticalFrame(fullbar, 10, 20, 0, backgroundColor);
277 
278  TGCompositeFrame *buttonFrame = new TGHorizontalFrame(controlFrame, 10, 10, 0, backgroundColor);
279  TImage *imgBtn = TImage::Open(FWCheckBoxIcon::coreIcondir() + "slider-bg-up.png");
280  buttonFrame->SetBackgroundPixmap(imgBtn->GetPixmap());
281 
282  goToFirst->createCustomIconsButton(
283  buttonFrame,
284  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotofirst.png"),
285  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotofirst-over.png"),
286  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotofirst-disabled.png"),
287  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 3, 10, 0));
288 
289  playEventsBack->createCustomIconsButton(
290  buttonFrame,
291  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-backward.png"),
292  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-backward-over.png"),
293  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-backward-disabled.png"),
294  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause.png"),
295  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause-over.png"),
296  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
297 
298  previousEvent->createCustomIconsButton(
299  buttonFrame,
300  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepback.png"),
301  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepback-over.png"),
302  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepback-disabled.png"),
303  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
304 
305  nextEvent->createCustomIconsButton(
306  buttonFrame,
307  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepforward.png"),
308  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepforward-over.png"),
309  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-stepforward-disabled.png"),
310  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
311 
312  playEvents->createCustomIconsButton(
313  buttonFrame,
314  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-forward.png"),
315  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-forward-over.png"),
316  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-forward-disabled.png"),
317  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause.png"),
318  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-pause-over.png"),
319  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
320 
321  goToLast->createCustomIconsButton(buttonFrame,
322  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotolast.png"),
323  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotolast-over.png"),
324  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "button-gotolast-disabled.png"),
325  new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 3, 10, 0));
326 
327  controlFrame->AddFrame(buttonFrame, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
328 
329  /**************************************************************************/
330 
331  TGHorizontalFrame *sliderFrame = new TGHorizontalFrame(controlFrame, 10, 10, 0, backgroundColor);
332  TImage *imgSld = TImage::Open(FWCheckBoxIcon::coreIcondir() + "slider-bg-down.png");
333  sliderFrame->SetBackgroundPixmap(imgSld->GetPixmap());
334  TString sldBtn = FWCheckBoxIcon::coreIcondir() + "slider-button.png";
335 
336  m_delaySlider = new TGHSlider(sliderFrame, 109, kSlider1 | kScaleNo);
337  sliderFrame->AddFrame(m_delaySlider, new TGLayoutHints(kLHintsTop | kLHintsLeft, 39, 8, 1, 3));
338  m_delaySlider->SetRange(0, 10000);
339  m_delaySlider->SetPosition(0);
340  m_delaySlider->SetBackgroundColor(0x1a1a1a);
341  m_delaySlider->ChangeSliderPic(sldBtn);
342 
343  controlFrame->AddFrame(sliderFrame, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
344 
345  fullbar->AddFrame(controlFrame, new TGLayoutHints(kLHintsLeft, 2, 2, 5, 8));
346 
348  TQObject::Connect(
349  m_delaySlider, "PositionChanged(Int_t)", "FWIntValueListenerBase", m_delaySliderListener, "setValue(Int_t)");
350 
351  //==============================================================================
352 
353  // delay label
354  {
355  TGVerticalFrame *delayFrame = new TGVerticalFrame(fullbar, 60, 10, 0, backgroundColor);
356 
357  TGLabel *label = new TGLabel(delayFrame, "Delay");
358  label->SetTextJustify(kTextCenterX);
359  label->SetTextColor(0xb3b3b3);
360  label->SetBackgroundColor(backgroundColor);
361  delayFrame->AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 22, 0));
362 
363  TGHorizontalFrame *labFixed = new TGHorizontalFrame(delayFrame, 70, 20, kFixedSize, backgroundColor);
364  m_delayLabel = new TGLabel(labFixed, "0.0s");
365  m_delayLabel->SetBackgroundColor(backgroundColor);
366  m_delayLabel->SetTextJustify(kTextCenterX);
367  m_delayLabel->SetTextColor(0xffffff);
368  labFixed->AddFrame(m_delayLabel, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 0, 0, 0, 0));
369  delayFrame->AddFrame(labFixed, new TGLayoutHints(kLHintsLeft, 0, 4, 0, 0));
370 
371  fullbar->AddFrame(delayFrame, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
372  }
373 
374  //==============================================================================
375 
376  // text/num entries
377 
378  Int_t entryHeight = 22;
379  TGVerticalFrame *texts = new TGVerticalFrame(fullbar, 400, 10, 0, backgroundColor);
380 
381  // upper row
382  {
383  TGPack *runInfo = new TGPack(texts, 400, entryHeight, kFixedHeight);
384  runInfo->SetVertical(kFALSE);
385  runInfo->SetUseSplitters(kFALSE);
386  runInfo->SetBackgroundColor(backgroundColor);
387 
388  TGHorizontalFrame *rLeft = new TGHorizontalFrame(runInfo, 1, entryHeight);
389  makeFixedSizeLabel(rLeft, "Run", backgroundColor, 0xffffff, 26, entryHeight);
390  m_runEntry = new FWNumberEntryField(rLeft, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
391  rLeft->AddFrame(m_runEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 8, 0, 0));
392  runInfo->AddFrameWithWeight(rLeft, nullptr, 0.28);
393 
394  TGHorizontalFrame *rMid = new TGHorizontalFrame(runInfo, 1, entryHeight);
395  makeFixedSizeLabel(rMid, "Lumi", backgroundColor, 0xffffff, 36, entryHeight);
396  m_lumiEntry = new FWNumberEntryField(rMid, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
397  rMid->AddFrame(m_lumiEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 8, 0, 0));
398  runInfo->AddFrameWithWeight(rMid, nullptr, 0.32);
399 
400  TGHorizontalFrame *rRight = new TGHorizontalFrame(runInfo, 1, entryHeight);
401  makeFixedSizeLabel(rRight, "Event", backgroundColor, 0xffffff, 42, entryHeight);
402  m_eventEntry = new FWNumberEntryField(rRight, -1, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
403  rRight->AddFrame(m_eventEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
404  runInfo->AddFrameWithWeight(rRight, nullptr, 0.4);
405 
406  texts->AddFrame(runInfo, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 4));
407  }
408 
409  // lower row
410  {
411  TGHorizontalFrame *filterFrame = new TGHorizontalFrame(texts, 400, entryHeight, 0, backgroundColor);
412 
413  // filter state Off
414  m_filterIcons[0] = fClient->GetPicture("unchecked_t.xpm");
415  m_filterIcons[1] = fClient->GetPicture("unchecked_t.xpm");
416  m_filterIcons[2] = fClient->GetPicture("unchecked_dis_t.xpm");
417 
418  // filter state On
419  m_filterIcons[3] = fClient->GetPicture("checked_t.xpm");
420  m_filterIcons[4] = fClient->GetPicture("checked_t.xpm");
421  m_filterIcons[5] = fClient->GetPicture("checked_dis_t.xpm");
422 
423  // filter withdrawn
424  m_filterIcons[6] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg.png");
425  m_filterIcons[7] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg-over.png");
426  m_filterIcons[8] = fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "icon-alert-ltgraybg.png");
427 
429  m_filterEnableBtn->SetBackgroundColor(backgroundColor);
430  m_filterEnableBtn->SetToolTipText("Enable/disable event filtering");
431  filterFrame->AddFrame(m_filterEnableBtn, new TGLayoutHints(kLHintsLeft, 4, 0, 3, 0));
432 
433  m_filterShowGUIBtn = new TGTextButton(filterFrame, "Event filtering is OFF");
434  m_filterShowGUIBtn->ChangeOptions(kRaisedFrame);
435  m_filterShowGUIBtn->SetBackgroundColor(backgroundColor);
436  m_filterShowGUIBtn->SetTextColor(0xFFFFFF);
437  m_filterShowGUIBtn->SetToolTipText("Edit filters");
438  filterFrame->AddFrame(m_filterShowGUIBtn, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 6, 7, 0, 0));
439 
440  texts->AddFrame(filterFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 4, 0));
441  }
442 
443  fullbar->AddFrame(texts, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5, 5, 12, 0));
444 
445  //==============================================================================
446 
447  TGVerticalFrame *texts2 = new TGVerticalFrame(fullbar, 200, 44, kFixedSize, backgroundColor);
448 
449  // time
450  m_timeText = new TGLabel(texts2, "...");
451  m_timeText->SetTextJustify(kTextLeft);
452  m_timeText->SetTextColor(0xffffff);
453  m_timeText->SetBackgroundColor(backgroundColor);
454  texts2->AddFrame(m_timeText, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 1));
455 
456  fullbar->AddFrame(texts2, new TGLayoutHints(kLHintsLeft, 5, 5, 16, 5));
457 
458  //==============================================================================
459 
460  // logo
461  {
462  TGVerticalFrame *parentLogoFrame = new TGVerticalFrame(fullbar, 70, 53, kFixedSize);
463  parentLogoFrame->SetBackgroundColor(backgroundColor);
464  fullbar->AddFrame(parentLogoFrame, new TGLayoutHints(kLHintsRight | kLHintsCenterY));
465 
466  TGVerticalFrame *logoFrame = new TGVerticalFrame(parentLogoFrame, 53, 53, kFixedSize);
467  TImage *logoImg = TImage::Open(FWCheckBoxIcon::coreIcondir() + "CMSRedOnBlackThick.png");
468  logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
469  parentLogoFrame->AddFrame(logoFrame, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 14, 0, 0));
470  }
471  {
472  TGCompositeFrame *logoFrame = new TGCompositeFrame(this, 61, 23, kFixedSize | kHorizontalFrame, backgroundColor);
473  FWCustomIconsButton *infoBut =
474  new FWCustomIconsButton(logoFrame,
475  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray.png"),
476  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray-green.png"),
477  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray-red.png"),
478  fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray-red.png"));
479  logoFrame->AddFrame(infoBut);
480  infoBut->Connect("Clicked()", "CmsShowMainFrame", this, "showFWorksInfo()");
481  //TImage *logoImg = TImage::Open( FWCheckBoxIcon::coreIcondir() + "fireworksSmallGray.png");
482  //logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
483  menuTopFrame->AddFrame(logoFrame, new TGLayoutHints(kLHintsRight | kLHintsBottom, 0, 13, 3, 1));
484  }
485 
486  //==============================================================================
487 
488  AddFrame(fullbar, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
489 
490  //Start disabled
491  goToFirst->disable();
492  goToLast->disable();
493  previousEvent->disable();
494  nextEvent->disable();
495  playEvents->disable();
496  playEventsBack->disable();
497  loop->disable();
498 
499  //NOTE: There appears to be a bug in ROOT such that creating a menu item and setting it as
500  // disabled immediately is ignored. Therefore we have to wait till here to actually get ROOT
501  // to disable these menu items
502  undo->disable();
503  redo->disable();
504  cut->disable();
505  copy->disable();
506  paste->disable();
507 
508  //==============================================================================
509 
510  FWPack *csArea = new FWPack(this);
511  csArea->SetVertical(kFALSE);
512 
513  TGCompositeFrame *cf = m_manager->createList(csArea);
514  csArea->AddFrameWithWeight(cf, nullptr, 20);
515 
516  TEveCompositeFrameInPack *slot = new TEveCompositeFrameInPack(csArea, nullptr, csArea);
517  csArea->AddFrameWithWeight(slot, nullptr, 80);
518  TEveWindowSlot *ew_slot = TEveWindow::CreateDefaultWindowSlot();
519  ew_slot->PopulateEmptyFrame(slot);
520  m_manager->createViews(ew_slot);
521 
522  AddFrame(csArea, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 2));
523  csArea->MapSubwindows();
524 
525  SetWindowName("cmsShow");
526 }
527 
528 // CmsShowMainFrame::CmsShowMainFrame(const CmsShowMainFrame& rhs)
529 // {
530 // // do actual copying here;
531 // }
532 
534 
535 //
536 // assignment operators
537 //
538 // const CmsShowMainFrame& CmsShowMainFrame::operator=(const CmsShowMainFrame& rhs)
539 // {
540 // //An exception safe implementation is
541 // CmsShowMainFrame temp(rhs);
542 // swap(rhs);
543 //
544 // return *this;
545 // }
546 
547 //
548 // member functions
549 //
550 
552  CSGAction *action(new CSGAction(this, iActionName.c_str()));
553  action->createMenuEntry(m_newViewerMenu);
554  if (separator)
555  m_newViewerMenu->AddSeparator();
556  return action;
557 }
558 
560  m_runEntry->SetUIntNumber(event.id().run());
561  m_lumiEntry->SetUIntNumber(event.id().luminosityBlock());
562  m_eventEntry->SetULong64Number(event.id().event());
563 
564  m_timeText->SetText(fireworks::getLocalTime(event).c_str());
565 }
566 
568  m_nextEvent->enable();
570  m_goToFirst->enable();
571  m_goToLast->enable();
572  m_playEvents->enable();
574  m_loopAction->enable();
575 }
576 
578 
580 
583 
584  m_runEntry->SetEnabled(enable);
585  m_lumiEntry->SetEnabled(enable);
586  m_eventEntry->SetEnabled(enable);
587  m_filterEnableBtn->SetEnabled(enable);
588  m_filterShowGUIBtn->SetEnabled(enable);
589 }
590 
592  if (m_previousEvent != nullptr) {
593  if (enable) {
595  m_goToFirst->enable();
597  } else {
599  m_goToFirst->disable();
602  }
603  }
604 }
605 
607  if (m_nextEvent != nullptr) {
608  if (enable) {
609  m_nextEvent->enable();
610  m_goToLast->enable();
611  m_playEvents->enable();
612  } else {
613  m_nextEvent->disable();
614  m_goToLast->disable();
616  m_playEvents->stop();
617  }
618  }
619 }
620 
625  if (enable)
626  m_goToLast->enable();
627  else
628  m_goToLast->disable();
629 }
630 
632 
634 
636  m_statBar->SetText(status, 0);
637  //force the status bar to update its image
638  gClient->ProcessEventsFor(m_statBar);
639 }
640 
642  m_statBar->SetText("", 0);
643  //don't process immediately since we want this on the event queue
644  // since results of the last action may still be happening
645 }
646 
648  switch (id) {
649  case 1: {
650  gApplication->Terminate(0);
651  } break;
652  default:
653  fwLog(fwlog::kInfo) << "Invalid menu id\n";
654  break;
655  }
656 }
657 
659  if (event->fType == kGKeyPress) {
660  const std::vector<CSGAction *> &alist = getListOfActions();
661  std::vector<CSGAction *>::const_iterator it_act;
662  Int_t keycode;
663  Int_t modcode;
664  for (it_act = alist.begin(); it_act != alist.end(); ++it_act) {
665  keycode = (*it_act)->getKeycode();
666  modcode = (*it_act)->getModcode();
667  if ((event->fCode == (UInt_t)keycode) &&
668  ((event->fState == (UInt_t)modcode) || (event->fState == (UInt_t)(modcode | kKeyMod2Mask)) ||
669  (event->fState == (UInt_t)(modcode | kKeyLockMask)) ||
670  (event->fState == (UInt_t)(modcode | kKeyMod2Mask | kKeyLockMask)))) {
671  (*it_act)->activated.emit();
672  // return kTRUE;
673  return false;
674  }
675  }
676 
677  // special case is --live option where Space key is grabbed
678  static UInt_t spacecode = gVirtualX->KeysymToKeycode((int)kKey_Space);
679  if (event->fCode == spacecode && event->fState == 0) {
680  if (playEventsAction()->isRunning())
682  else if (playEventsBackwardsAction()->isRunning())
684  }
685  }
686  return kFALSE;
687 }
688 
689 void CmsShowMainFrame::setPlayDelayGUI(Float_t val, Bool_t sliderChanged) {
690  m_delayLabel->SetText(Form("%.1fs", val));
691  if (sliderChanged)
692  m_delaySlider->SetPosition(Int_t(val * 1000));
693 }
694 
696  TGHorizontalFrame *p, const char *txt, UInt_t bgCol, UInt_t txtCol, Int_t width, Int_t height) {
697  // Utility function.
698 
699  p->SetBackgroundColor(bgCol);
700  TGCompositeFrame *lframe = new TGHorizontalFrame(p, width, height, kFixedSize, bgCol);
701  TGLabel *label = new TGLabel(lframe, txt);
702  label->SetBackgroundColor(bgCol);
703  label->SetTextColor(txtCol);
704  lframe->AddFrame(label, new TGLayoutHints(kLHintsRight | kLHintsTop, 0, 4));
705  p->AddFrame(lframe, new TGLayoutHints(kLHintsLeft, 0, 0, 3, 0));
706 }
707 
708 class InfoFrame : public TGMainFrame {
709 public:
710  InfoFrame(const TGWindow *p, UInt_t w, UInt_t h, UInt_t opts) : TGMainFrame(p, w, h, opts) {}
711  ~InfoFrame() override {}
712 
713  void CloseWindow() override { UnmapWindow(); }
714 };
715 
717  if (m_fworksAbout == nullptr) {
718  UInt_t ww = 280, hh = 190;
719  int number_of_lines = 0;
720  int fontSize = 8;
721  TString infoText;
722  if (gSystem->Getenv("CMSSW_VERSION")) {
723  infoText = "Version ";
724  infoText += gSystem->Getenv("CMSSW_VERSION");
725  infoText += "\n";
726  number_of_lines += 1;
727  } else {
728  TString infoFileName("/data/version.txt");
729  fireworks::setPath(infoFileName);
731  std::ifstream infoFile(infoFileName);
732  while (std::getline(infoFile, line)) {
733  ++number_of_lines;
734  infoText += line.c_str();
735  infoText += "\n";
736  }
737  infoFile.close();
738  }
739  infoText += "\nIt works or we fix it for free!\nhn-cms-visualization@cern.ch\n";
740 
741  hh = 130 + 2 * fontSize * (number_of_lines + 1);
742 
743  m_fworksAbout = new InfoFrame(gClient->GetRoot(), ww, hh, kVerticalFrame | kFixedSize);
744  m_fworksAbout->SetWMSizeHints(ww, hh, ww, hh, 0, 0);
745  m_fworksAbout->SetBackgroundColor(0x2f2f2f);
746 
747  TGFrame *logoFrame = new TGFrame(m_fworksAbout, 140, 48, kFixedSize);
748  TImage *logoImg = TImage::Open(FWCheckBoxIcon::coreIcondir() + "logo-fireworks.png");
749  logoFrame->SetBackgroundPixmap(logoImg->GetPixmap());
750  m_fworksAbout->AddFrame(logoFrame, new TGLayoutHints(kLHintsTop | kLHintsCenterX, 0, 0, 16, 0));
751 
752  TGLabel *label = new TGLabel(m_fworksAbout, infoText);
753  label->SetBackgroundColor(0x2f2f2f);
754  label->SetForegroundColor(0xffffff);
755 
756  FontStruct_t defaultFontStruct = label->GetDefaultFontStruct();
757  try {
758  TGFontPool *pool = gClient->GetFontPool();
759  TGFont *defaultFont = pool->GetFont(defaultFontStruct);
760  FontAttributes_t attributes = defaultFont->GetFontAttributes();
761  label->SetTextFont(pool->GetFont(attributes.fFamily, fontSize, attributes.fWeight, attributes.fSlant));
762  } catch (...) {
763  }
764 
765  m_fworksAbout->AddFrame(label, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 0, 0, 12, 0));
766 
767  TGTextButton *btn = new TGTextButton(m_fworksAbout, " OK ");
768  btn->SetBackgroundColor(0x2f2f2f);
769  btn->SetForegroundColor(0xffffff);
770  m_fworksAbout->AddFrame(btn, new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 0, 12));
771  btn->Connect("Clicked()", "TGMainFrame", m_fworksAbout, "CloseWindow()");
772 
773  m_fworksAbout->MapSubwindows();
774  m_fworksAbout->Layout();
775  }
776 
777  m_fworksAbout->MapRaised();
778 }
779 
780 void CmsShowMainFrame::bindCSGActionKeys(const TGMainFrame *f) const {
781  for (std::vector<CSGAction *>::const_iterator i = m_actionList.begin(); i != m_actionList.end(); ++i) {
782  if ((*i)->getKeycode())
783  f->BindKey(this, (*i)->getKeycode(), (*i)->getModcode());
784  }
785 }
786 
788  TGFrameElement *fe = (TGFrameElement *)GetList()->Last();
789  FWPack *pack = (FWPack *)(fe->fFrame);
790 
791  TGFrameElementPack *fep;
792  fep = (TGFrameElementPack *)pack->GetList()->At(1);
793  fep->fWeight = x;
794 
795  fep = (TGFrameElementPack *)pack->GetList()->At(3);
796  fep->fWeight = 100 - x;
797 
798  pack->ResizeExistingFrames();
799  pack->Layout();
800 }
801 
803  TGFrameElement *fe = (TGFrameElement *)GetList()->Last();
804  TGPack *pack = (TGPack *)(fe->fFrame);
805 
806  TGFrameElementPack *fep = (TGFrameElementPack *)pack->GetList()->At(1);
807  return fep->fWeight;
808 }
const std::string sKeyboardShort
Definition: ActionsList.cc:45
TGVerticalFrame * createList(TGCompositeFrame *p)
static const TString & coreIcondir()
const std::string sSavePartialConfig
Definition: ActionsList.cc:21
void CloseWindow() override
FWNumberEntryField * m_lumiEntry
def pack(high, low)
const std::string sShowCommonInsp
Definition: ActionsList.cc:29
string separator
Definition: mps_merge.py:79
virtual void SetUIntNumber(UInt_t n)
FWPack(const TGWindow *w)
const std::string sHelp
Definition: ActionsList.cc:44
const std::string sCut
Definition: ActionsList.cc:34
InfoFrame(const TGWindow *p, UInt_t w, UInt_t h, UInt_t opts)
const std::string sSavePartialConfigAs
Definition: ActionsList.cc:22
void loadEvent(const edm::EventBase &event)
void createViews(TEveWindowSlot *slot)
T w() const
virtual void enableActions(bool enable=true)
~CmsShowMainFrame() override
void HandleMenu(Int_t id) override
const std::vector< CSGAction * > & getListOfActions() const
void enable()
Definition: CSGAction.cc:269
auto const & hh
const std::string sBackgroundColor
Definition: ActionsList.cc:30
const std::string sPlayEvents
Definition: ActionsList.cc:7
FWGUIManager * m_manager
FWCustomIconsButton * m_filterEnableBtn
void enableNext(bool enable=true)
const std::string sOpenData
Definition: ActionsList.cc:12
FWIntValueListener * m_delaySliderListener
const std::string sRedo
Definition: ActionsList.cc:33
void createCustomIconsButton(TGCompositeFrame *p, const TGPicture *upPic, const TGPicture *downPic, const TGPicture *disabledPic, const TGPicture *upRunningPic, const TGPicture *downRunningPic, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
const std::string sSaveConfigAs
Definition: ActionsList.cc:18
void disable()
Definition: CSGAction.cc:274
CSGContinuousAction * m_playEventsBack
CSGAction * m_nextEvent
const std::string sNextEvent
Definition: ActionsList.cc:5
TGSlider * m_delaySlider
CSGContinuousAction * playEventsBackwardsAction() const
const std::string sSaveConfig
Definition: ActionsList.cc:17
char const * label
Bool_t HandleKey(Event_t *event) override
const TGPicture * m_filterIcons[9]
std::vector< CSGAction * > m_actionList
virtual void SetULong64Number(ULong64_t n)
const std::string sAppendData
Definition: ActionsList.cc:13
void setToolTip(const std::string &tip)
Definition: CSGAction.cc:104
CSGContinuousAction * m_loopAction
TGMainFrame * m_fworksAbout
CSGAction * createNewViewerAction(const std::string &iActionName, bool seaprator)
void CloseWindow() override
FWNumberEntryField * m_eventEntry
void updateStatusBar(const char *status)
const std::string sShowAddCollection
Definition: ActionsList.cc:41
double f[11][100]
const std::string sGotoLastEvent
Definition: ActionsList.cc:4
TGPopupMenu * m_newViewerMenu
const std::string sExportImage
Definition: ActionsList.cc:24
const std::string sAutoRewind
Definition: ActionsList.cc:10
void createMenuEntry(TGPopupMenu *menu)
Definition: CSGAction.cc:205
const std::string sShowMainViewCtl
Definition: ActionsList.cc:40
FWNumberEntryField * m_runEntry
const std::string sPlayEventsBack
Definition: ActionsList.cc:8
CSGAction * getAction(const std::string &name)
void enableActions(bool enable=true) override
const std::string sShowObjInsp
Definition: ActionsList.cc:38
~FWPack() override
float getSummaryViewWeight() const
CSGAction * m_previousEvent
#define fwLog(_level_)
Definition: fwLog.h:45
const std::string sGotoFirstEvent
Definition: ActionsList.cc:3
const std::string sCopy
Definition: ActionsList.cc:35
CmsShowMainFrame(const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1, FWGUIManager *m=nullptr)
virtual Bool_t isEnabled() const
Definition: CSGAction.cc:289
CSGAction * m_goToLast
const std::string sShowInvMassDialog
Definition: ActionsList.cc:42
void setSummaryViewWeight(float)
const std::string sShowEventDisplayInsp
Definition: ActionsList.cc:39
void enablePrevious(bool enable=true)
const std::string sPreviousEvent
Definition: ActionsList.cc:6
CSGContinuousAction * m_playEvents
~InfoFrame() override
std::string getLocalTime(const edm::EventBase &event)
CSGAction * m_goToFirst
CSGContinuousAction * playEventsAction() const
const std::string sLoadConfig
Definition: ActionsList.cc:16
float x
sigc::signal< void()> activated
Definition: CSGAction.h:100
FWCustomIconsButton * createCustomIconsButton(TGCompositeFrame *p, const TGPicture *upPic, const TGPicture *downPic, const TGPicture *disabledPic, TGLayoutHints *l=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
Definition: CSGAction.cc:155
void makeFixedSizeLabel(TGHorizontalFrame *p, const char *txt, UInt_t bgCol, UInt_t txtCol, Int_t width, Int_t height)
void bindCSGActionKeys(const TGMainFrame *f) const
void createShortcut(UInt_t key, const char *mod, int windowID)
Definition: CSGAction.cc:175
const std::string sExportAllImages
Definition: ActionsList.cc:25
const std::string sPaste
Definition: ActionsList.cc:36
void enableComplexNavigation(bool enable=true)
const std::string sQuit
Definition: ActionsList.cc:27
TGTextButton * m_filterShowGUIBtn
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const std::string sHelpGL
Definition: ActionsList.cc:46
void setPlayDelayGUI(Float_t val, Bool_t sliderChanged)
const std::string sLoadPartialConfig
Definition: ActionsList.cc:20
const std::string sUndo
Definition: ActionsList.cc:32
void setPath(TString &v)
Definition: fwPaths.cc:15
Definition: event.py:1
TGStatusBar * m_statBar
const std::string sSearchFiles
Definition: ActionsList.cc:14