CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsShowMain.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : CmsShowMain
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Mon Dec 3 08:38:38 PST 2007
11 //
12 
13 // system include files
14 #include <sstream>
15 #include <boost/bind.hpp>
16 #include <boost/program_options.hpp>
17 #include <string.h>
18 
19 #include "TSystem.h"
20 #include "TGLWidget.h"
21 #include "TTimer.h"
22 #include "TROOT.h"
23 #include "TGFileDialog.h"
24 #include "TGMsgBox.h"
25 #include "TMonitor.h"
26 #include "TServerSocket.h"
27 #include "TEveLine.h"
28 #include "TEveManager.h"
29 #include "TFile.h"
30 #include "TGClient.h"
31 
33 
35 
49 
54 
56 
60 
62 
64 
65 #if defined(R__LINUX)
66 #include "TGX11.h" // !!!! AMT has to be at the end to pass build
67 #include "X11/Xlib.h"
68 #endif
69 //
70 // constants, enums and typedefs
71 //
72 
73 static const char* const kInputFilesOpt = "input-files";
74 static const char* const kInputFilesCommandOpt = "input-files,i";
75 static const char* const kConfigFileOpt = "config-file";
76 static const char* const kConfigFileCommandOpt = "config-file,c";
77 static const char* const kGeomFileOpt = "geom-file";
78 static const char* const kGeomFileCommandOpt = "geom-file,g";
79 static const char* const kSimGeomFileOpt = "sim-geom-file";
80 static const char* const kSimGeomFileCommandOpt= "sim-geom-file";
81 static const char* const kNoConfigFileOpt = "noconfig";
82 static const char* const kNoConfigFileCommandOpt = "noconfig,n";
83 static const char* const kPlayOpt = "play";
84 static const char* const kPlayCommandOpt = "play,p";
85 static const char* const kLoopOpt = "loop";
86 static const char* const kLoopCommandOpt = "loop";
87 static const char* const kLogLevelCommandOpt = "log";
88 static const char* const kLogLevelOpt = "log";
89 static const char* const kEveOpt = "eve";
90 static const char* const kEveCommandOpt = "eve";
91 static const char* const kAdvancedRenderOpt = "shine";
92 static const char* const kAdvancedRenderCommandOpt = "shine,s";
93 static const char* const kHelpOpt = "help";
94 static const char* const kHelpCommandOpt = "help,h";
95 static const char* const kSoftCommandOpt = "soft";
96 static const char* const kPortCommandOpt = "port";
97 static const char* const kPlainRootCommandOpt = "prompt";
98 static const char* const kRootInteractiveCommandOpt = "root-interactive,r";
99 static const char* const kChainCommandOpt = "chain";
100 static const char* const kLiveCommandOpt = "live";
101 static const char* const kFieldCommandOpt = "field";
102 static const char* const kFreePaletteCommandOpt = "free-palette";
103 static const char* const kAutoSaveAllViews = "auto-save-all-views";
104 static const char* const kAutoSaveHeight = "auto-save-height";
105 static const char* const kEnableFPE = "enable-fpe";
106 static const char* const kZeroWinOffsets = "zero-window-offsets";
107 static const char* const kNoVersionCheck = "no-version-check";
108 
109 
110 //
111 // constructors and destructor
112 //
114  : CmsShowMainBase(),
115  m_navigator(new CmsShowNavigator(*this)),
116  m_metadataManager(new FWLiteJobMetadataManager()),
117  m_context(new fireworks::Context(changeManager(),
118  selectionManager(),
119  eiManager(),
120  colorManager(),
121  m_metadataManager.get())),
122  m_loadedAnyInputFile(false),
123  m_openFile(0),
124  m_live(false),
125  m_liveTimer(new SignalTimer()),
126  m_liveTimeout(600000),
127  m_lastXEventSerial(0),
128  m_noVersionCheck(false)
129 {
130  try {
131  TGLWidget* w = TGLWidget::Create(gClient->GetDefaultRoot(), kTRUE, kTRUE, 0, 10, 10);
132  delete w;
133  }
134  catch (std::exception& iException) {
135  fwLog(fwlog::kError) << "Failed creating an OpenGL window: " << iException.what() << "\n"
136  "Things to check:\n"
137  "- Is DISPLAY environment variable set?\n"
138  "- Are OpenGL libraries installed?\n"
139  "- If running remotely, make sure you use 'ssh -X' or 'ssh -Y'.\n"
140  "See also: https://twiki.cern.ch/twiki/bin/viewauth/CMS/WorkBookFireworks\n";
141  gSystem->Exit(1);
142  }
143 
144  eiManager()->setContext(m_context.get());
145 
146 
147  std::string descString(argv[0]);
148  descString += " [options] <data file>\nGeneral";
149 
150  namespace po = boost::program_options;
151  po::options_description desc(descString);
152  desc.add_options()
153  (kInputFilesCommandOpt, po::value< std::vector<std::string> >(), "Input root files")
154  (kConfigFileCommandOpt, po::value<std::string>(), "Include configuration file")
155  (kNoConfigFileCommandOpt, "Empty configuration")
156  (kNoVersionCheck, "No file version check")
157  (kGeomFileCommandOpt, po::value<std::string>(), "Reco geometry file. Default is cmsGeom10.root")
158  (kSimGeomFileCommandOpt,po::value<std::string>(), "Geometry file for browsing in table view. Default is CmsSimGeom-14.root. Can be simulation or reco geometry in TGeo format")
159  (kFieldCommandOpt, po::value<double>(), "Set magnetic field value explicitly. Default is auto-field estimation")
160  (kRootInteractiveCommandOpt, "Enable root interactive prompt")
161  (kSoftCommandOpt, "Try to force software rendering to avoid problems with bad hardware drivers")
162  (kHelpCommandOpt, "Display help message");
163 
164  po::options_description livedesc("Live Event Display");
165  livedesc.add_options()
166  (kPlayCommandOpt, po::value<float>(), "Start in play mode with given interval between events in seconds")
167  (kPortCommandOpt, po::value<unsigned int>(), "Listen to port for new data files to open")
168  (kLoopCommandOpt, "Loop events in play mode")
169  (kChainCommandOpt, po::value<unsigned int>(), "Chain up to a given number of recently open files. Default is 1 - no chain")
170  (kLiveCommandOpt, "Enforce playback mode if a user is not using display")
171  (kAutoSaveAllViews, po::value<std::string>(), "Auto-save all views with given prefix (run_event_lumi_view.png is appended)")
172  (kAutoSaveHeight, po::value<int>(), "Screenshots height when auto-save-all-views is enabled");
173 
174  po::options_description debugdesc("Debug");
175  debugdesc.add_options()
176  (kLogLevelCommandOpt, po::value<unsigned int>(), "Set log level starting from 0 to 4 : kDebug, kInfo, kWarning, kError")
177  (kEveCommandOpt, "Show TEveBrowser to help debug problems")
178  (kEnableFPE, "Enable detection of floating-point exceptions");
179 
180 
181  po::options_description rnrdesc("Appearance");
182  rnrdesc.add_options()
183  (kFreePaletteCommandOpt, "Allow free color selection (requires special configuration!)")
184  (kZeroWinOffsets, "Disable auto-detection of window position offsets")
185  (kAdvancedRenderCommandOpt, "Enable line anti-aliasing");
186  po::positional_options_description p;
187  p.add(kInputFilesOpt, -1);
188 
189 
190  po::options_description hiddendesc("hidden");
191  hiddendesc.add_options();
192 
193  po::options_description all("");
194  all.add(desc).add(rnrdesc).add(livedesc).add(debugdesc);
195 
196 
197  int newArgc = argc;
198  char **newArgv = argv;
199  po::variables_map vm;
200  try{
201  po::store(po::command_line_parser(newArgc, newArgv).
202  options(all).positional(p).run(), vm);
203 
204  po::notify(vm);
205  }
206  catch ( const std::exception& e)
207  {
208  // Return with exit status 0 to avoid generating crash reports
209 
210  fwLog(fwlog::kError) << e.what() << std::endl;
211  std::cout << all <<std::endl;
212  exit(0);
213  }
214 
215  if(vm.count(kHelpOpt)) {
216  std::cout << all <<std::endl;
217  exit(0);
218  }
219 
220  if(vm.count(kLogLevelOpt)) {
221  fwlog::LogLevel level = (fwlog::LogLevel)(vm[kLogLevelOpt].as<unsigned int>());
223  }
224 
225  if(vm.count(kPlainRootCommandOpt)) {
226  fwLog(fwlog::kInfo) << "Plain ROOT prompt requested" << std::endl;
227  return;
228  }
229 
230  const char* cmspath = gSystem->Getenv("CMSSW_BASE");
231  if(0 == cmspath) {
232  throw std::runtime_error("CMSSW_BASE environment variable not set");
233  }
234 
235  // input file
236  if (vm.count(kInputFilesOpt)) {
237  m_inputFiles = vm[kInputFilesOpt].as< std::vector<std::string> >();
238  }
239 
240  if (!m_inputFiles.size())
241  fwLog(fwlog::kInfo) << "No data file given." << std::endl;
242  else if (m_inputFiles.size() == 1)
243  fwLog(fwlog::kInfo) << "Input " << m_inputFiles.front() << std::endl;
244  else
245  fwLog(fwlog::kInfo) << m_inputFiles.size() << " input files; first: " << m_inputFiles.front() << ", last: " << m_inputFiles.back() << std::endl;
246 
247  // configuration file
248  if (vm.count(kConfigFileOpt)) {
249  setConfigFilename(vm[kConfigFileOpt].as<std::string>());
250  if (access(configFilename(), R_OK) == -1)
251  {
252  fwLog(fwlog::kError) << "Specified configuration file does not exist. Quitting.\n";
253  exit(0);
254  }
255  } else {
256  if (vm.count(kNoConfigFileOpt)) {
257  fwLog(fwlog::kInfo) << "No configuration is loaded, show everything.\n";
258  setConfigFilename("");
259  } else
260  setConfigFilename("default.fwc");
261  }
262  fwLog(fwlog::kInfo) << "Config " << configFilename() << std::endl;
263 
264  // geometry
265  if (vm.count(kGeomFileOpt)) {
266  setGeometryFilename(vm[kGeomFileOpt].as<std::string>());
267  fwLog(fwlog::kInfo) << "Geometry file " << geometryFilename() << "\n";
268  } else {
269  // fwLog(fwlog::kInfo) << "No geom file name. Choosing default.\n";
270  setGeometryFilename("cmsGeom10.root");
271  }
272 
273  if (vm.count(kSimGeomFileOpt)) {
274  setSimGeometryFilename(vm[kSimGeomFileOpt].as<std::string>());
275  } else {
276  setSimGeometryFilename("cmsSimGeom-14.root");
277  }
278  // Free-palette palette
279  if (vm.count(kFreePaletteCommandOpt)) {
281  fwLog(fwlog::kInfo) << "Palette restriction removed on user request!\n";
282  }
283  bool eveMode = vm.count(kEveOpt);
284 
285  //Delay creating guiManager and enabling autoloading until here so that if we have a 'help' request we don't
286  // open any graphics or build dictionaries
288 
289  TEveManager::Create(kFALSE, eveMode ? "FIV" : "FI");
290 
291  setup(m_navigator.get(), m_context.get(), m_metadataManager.get());
292 
293  if (vm.count(kZeroWinOffsets))
294  {
296  fwLog(fwlog::kInfo) << "Window offsets reset on user request!\n";
297  }
298 
299  if ( vm.count(kAdvancedRenderOpt) )
300  {
301  TEveLine::SetDefaultSmooth(kTRUE);
302  }
303 
304  //figure out where to find macros
305  //tell ROOT where to find our macros
307  // first check if port is not occupied
308  if (vm.count(kPortCommandOpt)) {
309  f=boost::bind(&CmsShowMain::setupSocket, this, vm[kPortCommandOpt].as<unsigned int>());
310  startupTasks()->addTask(f);
311  }
312 
313  f=boost::bind(&CmsShowMainBase::loadGeometry,this);
314  startupTasks()->addTask(f);
315  f=boost::bind(&CmsShowMainBase::setupViewManagers,this);
316  startupTasks()->addTask(f);
317  f=boost::bind(&CmsShowMainBase::setupConfiguration,this);
318  startupTasks()->addTask(f);
319  f=boost::bind(&CmsShowMain::setupDataHandling,this);
320  startupTasks()->addTask(f);
321 
322  if (vm.count(kLoopOpt))
323  setPlayLoop();
324 
325  if (eveMode) {
326  f = boost::bind(&CmsShowMainBase::setupDebugSupport,this);
327  startupTasks()->addTask(f);
328  }
329  if(vm.count(kChainCommandOpt)) {
330  f = boost::bind(&CmsShowNavigator::setMaxNumberOfFilesToChain, m_navigator.get(), vm[kChainCommandOpt].as<unsigned int>());
331  startupTasks()->addTask(f);
332  }
333  if (vm.count(kPlayOpt)) {
334  f = boost::bind(&CmsShowMainBase::setupAutoLoad, this, vm[kPlayOpt].as<float>());
335  startupTasks()->addTask(f);
336  }
337 
338  if(vm.count(kLiveCommandOpt))
339  {
340  f = boost::bind(&CmsShowMain::setLiveMode, this);
341  startupTasks()->addTask(f);
342  }
343 
344  if(vm.count(kFieldCommandOpt))
345  {
346  m_context->getField()->setSource(FWMagField::kUser);
347  m_context->getField()->setUserField(vm[kFieldCommandOpt].as<double>());
348  }
349  if(vm.count(kAutoSaveAllViews)) {
351  fmt += "%u_%u_%llu_%s.png";
353  }
354  if (vm.count(kAutoSaveHeight)) {
356  }
357  if(vm.count(kNoVersionCheck)) {
358  m_noVersionCheck=true;
359  }
360  if(vm.count(kEnableFPE)) {
361  gSystem->SetFPEMask();
362  }
363 
364  if (vm.count(kPortCommandOpt)) {
365  f=boost::bind(&CmsShowMain::connectSocket, this);
366  startupTasks()->addTask(f);
367  }
368 
370 }
371 
372 //
373 // Destruction
374 //
375 
377 {
378  //avoids a seg fault from eve which happens if eve is terminated after the GUI is gone
380 }
381 
382 class DieTimer : public TTimer
383 {
384 protected:
386 public:
387  DieTimer(CmsShowMain* app) : TTimer(), fApp(app)
388  {
389  Start(0, kTRUE);
390  }
391 
392  virtual Bool_t Notify() override
393  {
394  TurnOff();
395  fApp->doExit();
396  delete this;
397  return kFALSE;
398  }
399 };
400 
402 {
403  new DieTimer(this);
404 }
405 
407 {
408  // pre terminate eve
409  m_context->deleteEveElements();
411 
412  // sleep at least 150 ms
413  // windows in ROOT GUI are destroyed in 150 ms timeout after
414  gSystem->Sleep(151);
415  gSystem->ProcessEvents();
416  gSystem->ExitLoop();
417 }
418 
419 //
420 // assignment operators
421 //
422 // const CmsShowMain& CmsShowMain::operator=(const CmsShowMain& rhs)
423 // {
424 // //An exception safe implementation is
425 // CmsShowMain temp(rhs);
426 // swap(rhs);
427 //
428 // return *this;
429 // }
430 
431 //
432 // member functions
433 //
434 
435 const fwlite::Event*
437 {
438  if (m_navigator.get())
439  return static_cast<const fwlite::Event*>(m_navigator->getCurrentEvent());
440  return 0;
441 }
442 
443 void
445 {
446  m_openFile = file;
447  if (file)
448  guiManager()->titleChanged(m_navigator->frameTitle());
449 
451 }
452 
453 void
455 {
457  guiManager()->titleChanged(m_navigator->frameTitle());
459 }
460 
462  //printf("Need to reset\n");
463 }
464 
466 {
467  const char* kRootType[] = {"ROOT files","*.root", 0, 0};
468  TGFileInfo fi;
469  fi.fFileTypes = kRootType;
470  /* this is how things used to be done:
471  fi.fIniDir = ".";
472  this is bad because the destructor calls delete[] on fIniDir.
473  */
474  fi.fIniDir = new char[128];
475  strncpy(fi.fIniDir, ".", 127);
476  guiManager()->updateStatus("waiting for data file ...");
477  new TGFileDialog(gClient->GetDefaultRoot(), guiManager()->getMainFrame(), kFDOpen, &fi);
478  guiManager()->updateStatus("loading file ...");
479  if (fi.fFilename) {
480  m_navigator->openFile(fi.fFilename);
481  m_loadedAnyInputFile = true;
482  m_navigator->firstEvent();
483  checkPosition();
484  draw();
485  }
486  guiManager()->clearStatus();
487 }
488 
490 {
491  const char* kRootType[] = {"ROOT files","*.root", 0, 0};
492  TGFileInfo fi;
493  fi.fFileTypes = kRootType;
494  /* this is how things used to be done:
495  fi.fIniDir = ".";
496  this is bad because the destructor calls delete[] on fIniDir.
497  */
498  fi.fIniDir = new char[128];
499  strncpy(fi.fIniDir, ".", 127);
500  guiManager()->updateStatus("waiting for data file ...");
501  new TGFileDialog(gClient->GetDefaultRoot(), guiManager()->getMainFrame(), kFDOpen, &fi);
502  guiManager()->updateStatus("loading file ...");
503  if (fi.fFilename) {
504  m_navigator->appendFile(fi.fFilename, false, false);
505  m_loadedAnyInputFile = true;
506  checkPosition();
507  draw();
508  guiManager()->titleChanged(m_navigator->frameTitle());
509  }
510  guiManager()->clearStatus();
511 }
512 
513 void
515 {
516  if (m_searchFiles.get() == 0) {
517  m_searchFiles = std::auto_ptr<CmsShowSearchFiles>(new CmsShowSearchFiles("",
518  "Open Remote Data Files",
519  guiManager()->getMainFrame(),
520  500, 400));
521  m_searchFiles->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
522  }
523  std::string chosenFile = m_searchFiles->chooseFileFromURL();
524  if(!chosenFile.empty()) {
525  guiManager()->updateStatus("loading file ...");
526  if(m_navigator->openFile(chosenFile.c_str())) {
527  m_loadedAnyInputFile = true;
528  m_navigator->firstEvent();
529  checkPosition();
530  draw();
531  guiManager()->clearStatus();
532  } else {
533  guiManager()->updateStatus("failed to load data file");
534  }
535  }
536 }
537 
538 //
539 // const member functions
540 //
541 
542 //_______________________________________________________________________________
543 void
545 {
547 
548  // case when start with no input file
550  {
551  if (m_monitor.get())
553  return;
554  }
555 
556  bool reachedEnd = (forward() && m_navigator->isLastEvent()) || (!forward() && m_navigator->isFirstEvent());
557 
558  if (loop() && reachedEnd)
559  {
560  forward() ? m_navigator->firstEvent() : m_navigator->lastEvent();
561  draw();
562  }
563  else if (!reachedEnd)
564  {
565  forward() ? m_navigator->nextEvent() : m_navigator->previousEvent();
566  draw();
567  }
568 
569  // stop loop in case no loop or monitor mode
570  if (reachedEnd && (loop() || m_monitor.get()) == kFALSE)
571  {
572  if (forward() && m_navigator->isLastEvent())
573  {
575  checkPosition();
576  }
577 
578  if ((!forward()) && m_navigator->isFirstEvent())
579  {
581  checkPosition();
582  }
583  }
584  else
586 }
587 
588 //______________________________________________________________________________
589 
590 void
592 {
593  if ((m_monitor.get() || loop() ) && isPlaying())
594  return;
595 
597 
598  if (m_navigator->isFirstEvent())
600 
601  if (m_navigator->isLastEvent())
602  {
603  guiManager()->disableNext();
604  // force enable play events action in --port mode
605  if (m_monitor.get() && !guiManager()->playEventsAction()->isEnabled())
607  }
608 }
609 
610 //==============================================================================
611 void
613 {
614  guiManager()->updateStatus("Setting up data handling...");
615 
616 
617  // navigator filtering ->
618  m_navigator->fileChanged_.connect(boost::bind(&CmsShowMain::fileChangedSlot, this, _1));
619  m_navigator->editFiltersExternally_.connect(boost::bind(&FWGUIManager::updateEventFilterEnable, guiManager(), _1));
620  m_navigator->filterStateChanged_.connect(boost::bind(&CmsShowMain::navigatorChangedFilterState, this, _1));
621  m_navigator->postFiltering_.connect(boost::bind(&CmsShowMain::postFiltering, this, _1));
622 
623  // navigator fitlering <-
626 
627  // Data handling. File related and therefore not in the base class.
628  if (guiManager()->getAction(cmsshow::sOpenData) != 0)
629  guiManager()->getAction(cmsshow::sOpenData)->activated.connect(sigc::mem_fun(*this, &CmsShowMain::openData));
630  if (guiManager()->getAction(cmsshow::sAppendData) != 0)
631  guiManager()->getAction(cmsshow::sAppendData)->activated.connect(sigc::mem_fun(*this, &CmsShowMain::appendData));
632  if (guiManager()->getAction(cmsshow::sSearchFiles) != 0)
634 
635  setupActions();
636  // init data from CmsShowNavigator configuration, can do this with signals since there were not connected yet
637  guiManager()->setFilterButtonIcon(m_navigator->getFilterState());
638 
639  for (unsigned int ii = 0; ii < m_inputFiles.size(); ++ii)
640  {
641  const std::string& fname = m_inputFiles[ii];
642  if (fname.empty())
643  continue;
644  guiManager()->updateStatus("loading data file ...");
645  if (!m_navigator->appendFile(fname, false, false))
646  {
647  guiManager()->updateStatus("failed to load data file");
648  }
649  else
650  {
651  m_loadedAnyInputFile = true;
652 
653  }
654  }
655 
657  {
658  m_navigator->firstEvent();
659  checkPosition();
660  draw();
661  }
662  else if (m_monitor.get() == 0 && (eiManager()->begin() != eiManager()->end()) )
663  {
664  if (m_inputFiles.empty())
665  openDataViaURL();
666  else
667  openData();
668  }
669 }
670 
671 void
672 CmsShowMain::setupSocket(unsigned int iSocket)
673 {
674  m_monitor = std::auto_ptr<TMonitor>(new TMonitor);
675  TServerSocket* server = new TServerSocket(iSocket,kTRUE);
676  if (server->GetErrorCode())
677  {
678  fwLog(fwlog::kError) << "CmsShowMain::setupSocket, can't create socket on port "<< iSocket << "." << std::endl;
679  exit(0);
680  }
681  m_monitor->Add(server);
682 }
683 
684 void
686 {
687  m_monitor->Connect("Ready(TSocket*)","CmsShowMain",this,"notified(TSocket*)");
688 
689 }
690 
691 void
692 CmsShowMain::notified(TSocket* iSocket)
693 {
694  TServerSocket* server = dynamic_cast<TServerSocket*> (iSocket);
695  if (server)
696  {
697  TSocket* connection = server->Accept();
698  if (connection)
699  {
700  m_monitor->Add(connection);
701  std::stringstream s;
702  s << "received connection from "<<iSocket->GetInetAddress().GetHostName();
703  guiManager()->updateStatus(s.str().c_str());
704  }
705  }
706  else
707  {
708  char buffer[4096];
709  memset(buffer,0,sizeof(buffer));
710  if (iSocket->RecvRaw(buffer, sizeof(buffer)) <= 0)
711  {
712  m_monitor->Remove(iSocket);
713  //std::stringstream s;
714  //s << "closing connection to "<<iSocket->GetInetAddress().GetHostName();
715  //m_guiManager->updateStatus(s.str().c_str());
716  delete iSocket;
717  return;
718  }
719  std::string fileName(buffer);
720  std::string::size_type lastNonSpace = fileName.find_last_not_of(" \n\t");
721  if (lastNonSpace != std::string::npos)
722  {
723  fileName.erase(lastNonSpace+1);
724  }
725 
726  std::stringstream s;
727  s <<"New file notified '"<<fileName<<"'";
728  guiManager()->updateStatus(s.str().c_str());
729 
730  bool appended = m_navigator->appendFile(fileName, true, m_live);
731 
732  if (appended)
733  {
734  if (m_live && isPlaying() && forward())
735  m_navigator->activateNewFileOnNextEvent();
736  else if (!isPlaying())
737  checkPosition();
738 
739  // bootstrap case: --port and no input file
741  {
742  m_loadedAnyInputFile = true;
743  m_navigator->firstEvent();
744  if (!isPlaying())
745  draw();
746  }
747 
748  std::stringstream sr;
749  sr <<"New file registered '"<<fileName<<"'";
750  guiManager()->updateStatus(sr.str().c_str());
751  }
752  else
753  {
754  std::stringstream sr;
755  sr <<"New file NOT registered '"<<fileName<<"'";
756  guiManager()->updateStatus(sr.str().c_str());
757  }
758  }
759 }
760 
761 void
763 {
765  if (m_live)
766  m_navigator->resetNewFileOnNextEvent();
767  setIsPlaying(false);
769  checkPosition();
770 }
771 
772 void
774 {
776  if (m_navigator->filesNeedUpdate() == false)
777  {
778  guiManager()->setFilterButtonText(m_navigator->filterStatusMessage());
779  checkPosition();
780  }
781 }
782 
783 void
785 {
786  if (m_navigator->getFilterState() == CmsShowNavigator::kWithdrawn )
788  else
789  m_navigator->toggleFilterEnable();
790 }
791 
792 void
794 {
795  // called only if filter has changed
796  guiManager()->updateStatus("Filtering events");
797 }
798 
799 void
801 {
802  // called only filter is changed
803  guiManager()->clearStatus();
804  if (doDraw) draw();
805  checkPosition();
806  guiManager()->setFilterButtonText(m_navigator->filterStatusMessage());
807 }
808 
809 //______________________________________________________________________________
810 
811 void
813 {
814  m_live = true;
815  m_liveTimer.reset(new SignalTimer());
816  m_liveTimer->timeout_.connect(boost::bind(&CmsShowMain::checkLiveMode,this));
817 
818  Window_t rootw, childw;
819  Int_t root_x, root_y, win_x, win_y;
820  UInt_t mask;
821  gVirtualX->QueryPointer(gClient->GetDefaultRoot()->GetId(),
822  rootw, childw,
823  root_x, root_y,
824  win_x, win_y,
825  mask);
826 
827 
828  m_liveTimer->SetTime(m_liveTimeout);
829  m_liveTimer->Reset();
830  m_liveTimer->TurnOn();
831 }
832 
833 void
835 {
836  m_liveTimer->TurnOff();
837 
838 #if defined(R__LINUX)
839  TGX11 *x11 = dynamic_cast<TGX11*>(gVirtualX);
840  if (x11) {
841  XAnyEvent *ev = (XAnyEvent*) x11->GetNativeEvent();
842  // printf("serial %d \n",(int)ev->serial );
843 
844  if ( !isPlaying() && m_lastXEventSerial == ev->serial )
846  m_lastXEventSerial = ev->serial;
847  }
848 #endif
849  m_liveTimer->SetTime((Long_t)(m_liveTimeout));
850  m_liveTimer->Reset();
851  m_liveTimer->TurnOn();
852 }
DieTimer(CmsShowMain *app)
Definition: CmsShowMain.cc:387
void fileChangedSlot(const TFile *file)
Definition: CmsShowMain.cc:444
static const char *const kPlayCommandOpt
Definition: CmsShowMain.cc:84
static const char *const kNoVersionCheck
Definition: CmsShowMain.cc:107
void navigatorChangedFilterState(int)
Definition: CmsShowMain.cc:773
void openData()
Definition: CmsShowMain.cc:465
const fwlite::Event * getCurrentEvent() const
Definition: CmsShowMain.cc:436
CmsShowMain * fApp
Definition: CmsShowMain.cc:385
static const char *const kGeomFileCommandOpt
Definition: CmsShowMain.cc:78
void showEventFilterGUI(const TGWindow *p)
FWSelectionManager * selectionManager()
sigc::signal< void > filterButtonClicked_
Definition: FWGUIManager.h:205
static const char *const kChainCommandOpt
Definition: CmsShowMain.cc:99
static const char *const kAutoSaveAllViews
Definition: CmsShowMain.cc:103
bool m_loadedAnyInputFile
Definition: CmsShowMain.h:119
void resetInitialization()
Definition: CmsShowMain.cc:461
virtual void checkPosition()
Definition: CmsShowMain.cc:591
virtual void eventChangedImp()
Definition: CmsShowMain.cc:454
const double w
Definition: UKUtility.cc:23
FWGUIManager * guiManager()
static const char *const kZeroWinOffsets
Definition: CmsShowMain.cc:106
void appendData()
Definition: CmsShowMain.cc:489
void preFiltering()
Definition: CmsShowMain.cc:793
void setupSocket(unsigned int)
Definition: CmsShowMain.cc:672
void setFilterButtonIcon(int)
void checkLiveMode()
Definition: CmsShowMain.cc:834
static const char *const kFieldCommandOpt
Definition: CmsShowMain.cc:101
void setAutoSaveAllViewsHeight(int x)
void enable()
Definition: CSGAction.cc:284
FWEventItemsManager * eiManager()
sigc::signal< void > activated
Definition: CSGAction.h:88
static const char *const kLogLevelOpt
Definition: CmsShowMain.cc:88
static const char *const kSimGeomFileOpt
Definition: CmsShowMain.cc:79
std::auto_ptr< FWLiteJobMetadataManager > m_metadataManager
Definition: CmsShowMain.h:115
static const char *const kNoConfigFileOpt
Definition: CmsShowMain.cc:81
bool ev
const char * configFilename() const
const std::string sOpenData
Definition: ActionsList.cc:12
void setup(FWNavigatorBase *navigator, fireworks::Context *context, FWJobMetadataManager *metadataManager)
void updateStatus(const char *status)
void setContext(fireworks::Context *)
virtual ~CmsShowMain()
Definition: CmsShowMain.cc:376
int ii
Definition: cuy.py:588
uint16_t size_type
static const char *const kConfigFileCommandOpt
Definition: CmsShowMain.cc:76
void setupDataHandling()
Definition: CmsShowMain.cc:612
void enableActions(bool enable=true)
virtual void autoLoadNewEvent()
Definition: CmsShowMain.cc:544
static const char * fmt
Definition: Version.cc:9
std::auto_ptr< SignalTimer > m_liveTimer
Definition: CmsShowMain.h:126
static const char *const kAdvancedRenderOpt
Definition: CmsShowMain.cc:91
CmsShowMain(int argc, char *argv[])
Definition: CmsShowMain.cc:113
static const char *const kGeomFileOpt
Definition: CmsShowMain.cc:77
std::auto_ptr< fireworks::Context > m_context
Definition: CmsShowMain.h:116
LogLevel
Definition: fwLog.h:35
void setupAutoLoad(float x)
static const char *const kPortCommandOpt
Definition: CmsShowMain.cc:96
void setGeometryFilename(const std::string &filename)
static const char *const kPlayOpt
Definition: CmsShowMain.cc:83
void filterButtonClicked()
Definition: CmsShowMain.cc:784
void resetWMOffsets()
const std::string sAppendData
Definition: ActionsList.cc:13
bool loop() const
virtual Bool_t Notify() override
Definition: CmsShowMain.cc:392
CmsShowTaskExecutor * startupTasks()
virtual Bool_t isEnabled() const
Definition: CSGAction.cc:308
std::auto_ptr< TMonitor > m_monitor
Definition: CmsShowMain.h:132
UInt_t m_lastXEventSerial
Definition: CmsShowMain.h:128
sigc::signal< void, const TGWindow * > showEventFilterGUI_
Definition: FWGUIManager.h:206
static const char *const kEveOpt
Definition: CmsShowMain.cc:89
virtual void quit()
Definition: CmsShowMain.cc:401
virtual void eventChangedImp()
static const char *const kConfigFileOpt
Definition: CmsShowMain.cc:75
static const char *const kFreePaletteCommandOpt
Definition: CmsShowMain.cc:102
static const char *const kLoopOpt
Definition: CmsShowMain.cc:85
static const char *const kEveCommandOpt
Definition: CmsShowMain.cc:90
double f[11][100]
static const char *const kSoftCommandOpt
Definition: CmsShowMain.cc:95
static const char *const kLogLevelCommandOpt
Definition: CmsShowMain.cc:87
CmsShowMainFrame * getMainFrame() const
Definition: FWGUIManager.h:199
void disablePrevious()
static const char *const kNoConfigFileCommandOpt
Definition: CmsShowMain.cc:82
static const char *const kEnableFPE
Definition: CmsShowMain.cc:105
std::vector< std::string > m_inputFiles
Definition: CmsShowMain.h:118
void setLiveMode()
Definition: CmsShowMain.cc:812
void setIsPlaying(bool value)
void setSimGeometryFilename(const std::string &filename)
void clearStatus()
void postFiltering(bool)
Definition: CmsShowMain.cc:800
const_iterator begin() const
NOTE: iterator is allowed to return a null object for items that have been removed.
CSGAction * getAction(const std::string name)
static const char *const kLiveCommandOpt
Definition: CmsShowMain.cc:100
void updateEventFilterEnable(bool)
static const char *const kHelpCommandOpt
Definition: CmsShowMain.cc:94
static const char *const kInputFilesCommandOpt
Definition: CmsShowMain.cc:74
#define fwLog(_level_)
Definition: fwLog.h:50
static const char *const kInputFilesOpt
Definition: CmsShowMain.cc:73
static const char *const kPlainRootCommandOpt
Definition: CmsShowMain.cc:97
tuple argc
Definition: dir2webdir.py:38
const TFile * m_openFile
Definition: CmsShowMain.h:120
void setAutoSaveAllViewsFormat(const std::string &fmt)
std::auto_ptr< CmsShowNavigator > m_navigator
Definition: CmsShowMain.h:114
void setFilterButtonText(const char *txt)
std::auto_ptr< CmsShowSearchFiles > m_searchFiles
Definition: CmsShowMain.h:122
static const char *const kRootInteractiveCommandOpt
Definition: CmsShowMain.cc:98
CSGContinuousAction * playEventsAction()
string fname
main script
bool m_noVersionCheck
Definition: CmsShowMain.h:130
static const char *const kAdvancedRenderCommandOpt
Definition: CmsShowMain.cc:92
void doExit()
Definition: CmsShowMain.cc:406
bool isPlaying() const
boost::function0< void > TaskFunctor
void showEventFilterGUI()
void addTask(const TaskFunctor &iTask)
int m_liveTimeout
Definition: CmsShowMain.h:127
void evePreTerminate()
void setMaxNumberOfFilesToChain(unsigned int i)
static void enable()
enable automatic library loading
tuple cout
Definition: gather_cfg.py:121
virtual void stopPlaying()
Definition: CmsShowMain.cc:762
void notified(TSocket *)
Definition: CmsShowMain.cc:692
tuple level
Definition: testEve_cfg.py:34
bool forward() const
volatile std::atomic< bool > shutdown_flag false
const std::string & geometryFilename(void)
static void EnableFreePalette()
void setPresentLogLevel(LogLevel)
Definition: fwLog.cc:55
static const char *const kSimGeomFileCommandOpt
Definition: CmsShowMain.cc:80
void connectSocket()
Definition: CmsShowMain.cc:685
void titleChanged(const char *title)
static const char *const kHelpOpt
Definition: CmsShowMain.cc:93
void disableNext()
static const char *const kLoopCommandOpt
Definition: CmsShowMain.cc:86
void openDataViaURL()
Definition: CmsShowMain.cc:514
static const char *const kAutoSaveHeight
Definition: CmsShowMain.cc:104
void reachedEnd()
void setConfigFilename(const std::string &f)
T get(const Candidate &c)
Definition: component.h:55
const_iterator end() const
const std::string sSearchFiles
Definition: ActionsList.cc:14