CMS 3D CMS Logo

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