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