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