15 #include <boost/bind.hpp> 16 #include <boost/program_options.hpp> 20 #include "TGLWidget.h" 23 #include "TGFileDialog.h" 26 #include "TServerSocket.h" 28 #include "TEveManager.h" 31 #include <KeySymbols.h> 128 m_metadataManager.
get())),
129 m_loadedAnyInputFile(
false),
132 m_liveTimer(new SignalTimer()),
133 m_liveTimeout(600000),
134 m_lastXEventSerial(0),
135 m_noVersionCheck(
false)
138 TGLWidget*
w = TGLWidget::Create(gClient->GetDefaultRoot(), kTRUE, kTRUE, 0, 10, 10);
142 fwLog(
fwlog::kError) <<
"Failed creating an OpenGL window: " << iException.what() <<
"\n" 144 "- Is DISPLAY environment variable set?\n" 145 "- Are OpenGL libraries installed?\n" 146 "- If running remotely, make sure you use 'ssh -X' or 'ssh -Y'.\n" 147 "See also: https://twiki.cern.ch/twiki/bin/viewauth/CMS/WorkBookFireworks\n";
155 descString +=
" [options] <data file>\nGeneral";
157 namespace po = boost::program_options;
158 po::options_description desc(descString);
164 (
kGeomFileCommandOpt, po::value<std::string>(),
"Reco geometry file. Default is cmsGeom10.root")
165 (
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")
166 (
kFieldCommandOpt, po::value<double>(),
"Set magnetic field value explicitly. Default is auto-field estimation")
168 (
kSoftCommandOpt,
"Try to force software rendering to avoid problems with bad hardware drivers")
172 po::options_description livedesc(
"Live Event Display");
173 livedesc.add_options()
174 (
kPlayCommandOpt, po::value<float>(),
"Start in play mode with given interval between events in seconds")
175 (
kPortCommandOpt, po::value<unsigned int>(),
"Listen to port for new data files to open")
177 (
kChainCommandOpt, po::value<unsigned int>(),
"Chain up to a given number of recently open files. Default is 1 - no chain")
178 (
kLiveCommandOpt,
"Enforce playback mode if a user is not using display")
179 (
kAutoSaveAllViews, po::value<std::string>(),
"Auto-save all views with given prefix (run_event_lumi_view.<auto-save-type> is appended)")
180 (
kAutoSaveType, po::value<std::string>(),
"Image type of auto-saved views, png or jpg (png is default)")
181 (
kAutoSaveHeight, po::value<int>(),
"Screenshots height when auto-save-all-views is enabled")
184 po::options_description debugdesc(
"Debug");
185 debugdesc.add_options()
186 (
kLogLevelCommandOpt, po::value<unsigned int>(),
"Set log level starting from 0 to 4 : kDebug, kInfo, kWarning, kError")
188 (
kEnableFPE,
"Enable detection of floating-point exceptions");
191 po::options_description rnrdesc(
"Appearance");
192 rnrdesc.add_options()
196 po::positional_options_description
p;
200 po::options_description hiddendesc(
"hidden");
201 hiddendesc.add_options();
203 po::options_description
all(
"");
204 all.add(desc).add(rnrdesc).add(livedesc).add(debugdesc);
208 char **newArgv =
argv;
209 po::variables_map vm;
211 po::store(po::command_line_parser(newArgc, newArgv).
240 const char* cmspath = gSystem->Getenv(
"CMSSW_BASE");
242 throw std::runtime_error(
"CMSSW_BASE environment variable not set");
293 bool eveMode = vm.count(
kEveOpt);
299 TEveManager::Create(kFALSE, eveMode ?
"FIV" :
"FI");
327 TEveLine::SetDefaultSmooth(kTRUE);
380 if (type !=
"png" && type !=
"jpg")
387 fmt +=
"%u_%u_%llu_%s.";
401 gSystem->SetFPEMask();
455 gSystem->ProcessEvents();
479 return static_cast<const fwlite::Event*>(
m_navigator->getCurrentEvent());
511 const char* kRootType[] = {
"ROOT files",
"*.root", 0, 0};
513 fi.fFileTypes = kRootType;
518 fi.fIniDir =
new char[128];
519 strncpy(fi.fIniDir,
".", 127);
536 const char* kRootType[] = {
"ROOT files",
"*.root", 0, 0};
538 fi.fFileTypes = kRootType;
543 fi.fIniDir =
new char[128];
544 strncpy(fi.fIniDir,
".", 127);
549 m_navigator->appendFile(fi.fFilename,
false,
false);
563 "Open Remote Data Files",
566 m_searchFiles->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
569 if(!chosenFile.empty()) {
608 else if (!reachedEnd)
741 m_monitor = std::auto_ptr<TMonitor>(
new TMonitor);
742 TServerSocket*
server =
new TServerSocket(iSocket,kTRUE);
743 if (server->GetErrorCode())
745 fwLog(
fwlog::kError) <<
"CmsShowMain::setupSocket, can't create socket on port "<< iSocket <<
"." << std::endl;
754 m_monitor->Connect(
"Ready(TSocket*)",
"CmsShowMain",
this,
"notified(TSocket*)");
761 TServerSocket*
server =
dynamic_cast<TServerSocket*
> (iSocket);
764 TSocket* connection = server->Accept();
769 s <<
"received connection from "<<iSocket->GetInetAddress().GetHostName();
776 memset(buffer,0,
sizeof(buffer));
777 if (iSocket->RecvRaw(buffer,
sizeof(buffer)) <= 0)
788 if (lastNonSpace != std::string::npos)
790 fileName.erase(lastNonSpace+1);
794 s <<
"New file notified '"<<fileName<<
"'";
815 std::stringstream sr;
816 sr <<
"New file registered '"<<fileName<<
"'";
821 std::stringstream sr;
822 sr <<
"New file NOT registered '"<<fileName<<
"'";
832 Int_t keycode = gVirtualX->KeysymToKeycode((
int)kKey_Space);
834 gVirtualX->GrabKey(
id, keycode, 0,
isPlaying());
895 Window_t rootw, childw;
896 Int_t root_x, root_y, win_x, win_y;
898 gVirtualX->QueryPointer(gClient->GetDefaultRoot()->GetId(),
915 #if defined(R__LINUX) 916 TGX11 *x11 =
dynamic_cast<TGX11*
>(gVirtualX);
918 XAnyEvent *
ev = (XAnyEvent*) x11->GetNativeEvent();
DieTimer(CmsShowMain *app)
void fileChangedSlot(const TFile *file)
static const char *const kPlayCommandOpt
static const char *const kNoVersionCheck
void navigatorChangedFilterState(int)
void startAutoLoadTimer()
const fwlite::Event * getCurrentEvent() const
static const char *const kGeomFileCommandOpt
void setLoadedAnyInputFileAfterStartup()
void showEventFilterGUI(const TGWindow *p)
FWSelectionManager * selectionManager()
sigc::signal< void > filterButtonClicked_
static const char *const kChainCommandOpt
static const char *const kAutoSaveAllViews
bool m_loadedAnyInputFile
void resetInitialization()
virtual void checkPosition()
virtual void eventChangedImp()
FWGUIManager * guiManager()
static const char *const kZeroWinOffsets
void setupSocket(unsigned int)
void setFilterButtonIcon(int)
static const char *const kSyncAllViews
static const char *const kFieldCommandOpt
void setAutoSaveAllViewsHeight(int x)
FWEventItemsManager * eiManager()
virtual void checkKeyBindingsOnPLayEventsStateChanged()
sigc::signal< void > activated
static const char *const kLogLevelOpt
static const char *const kSimGeomFileOpt
std::auto_ptr< FWLiteJobMetadataManager > m_metadataManager
static const char *const kNoConfigFileOpt
const char * configFilename() const
const std::string sOpenData
void setup(FWNavigatorBase *navigator, fireworks::Context *context, FWJobMetadataManager *metadataManager)
void updateStatus(const char *status)
void setContext(fireworks::Context *)
void enableNavigatorControls()
static const char *const kConfigFileCommandOpt
void enableActions(bool enable=true)
virtual void autoLoadNewEvent()
std::auto_ptr< SignalTimer > m_liveTimer
static const char *const kExpertCommandOpt
static const char *const kAdvancedRenderOpt
CmsShowMain(int argc, char *argv[])
static const char *const kGeomFileOpt
std::auto_ptr< fireworks::Context > m_context
void setupAutoLoad(float x)
static const char *const kPortCommandOpt
void setGeometryFilename(const std::string &filename)
static const char *const kPlayOpt
virtual void stopPlaying()
void filterButtonClicked()
const std::string sAppendData
FWMagField * getField() const
virtual Bool_t Notify() override
CmsShowTaskExecutor * startupTasks()
virtual Bool_t isEnabled() const
std::auto_ptr< TMonitor > m_monitor
UInt_t m_lastXEventSerial
sigc::signal< void, const TGWindow * > showEventFilterGUI_
static const char *const kEveOpt
virtual void eventChangedImp()
static void enable()
enable automatic library loading
static const char *const kConfigFileOpt
static const char *const kFreePaletteCommandOpt
static const char *const kLoopOpt
void setupConfiguration()
static const char *const kEveCommandOpt
static const char *const kSoftCommandOpt
static const char *const kLogLevelCommandOpt
CmsShowMainFrame * getMainFrame() const
ESource getSource() const
static const char *const kNoConfigFileCommandOpt
static const char *const kEnableFPE
std::vector< std::string > m_inputFiles
void setSimGeometryFilename(const std::string &filename)
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
void updateEventFilterEnable(bool)
static const char *const kHelpCommandOpt
static FWGUIManager * getGUIManager()
static const char *const kInputFilesCommandOpt
static const char *const kInputFilesOpt
static const char *const kPlainRootCommandOpt
void setAutoSaveAllViewsFormat(const std::string &fmt)
std::auto_ptr< CmsShowNavigator > m_navigator
void setFilterButtonText(const char *txt)
std::auto_ptr< CmsShowSearchFiles > m_searchFiles
static const char *const kAutoSaveType
static const char *const kRootInteractiveCommandOpt
CSGContinuousAction * playEventsAction()
static const char *const kAdvancedRenderCommandOpt
boost::function0< void > TaskFunctor
FWConfigurationManager * configurationManager()
void showEventFilterGUI()
void addTask(const TaskFunctor &iTask)
void setMaxNumberOfFilesToChain(unsigned int i)
virtual void stopPlaying()
const std::string & geometryFilename(void)
void setPresentLogLevel(LogLevel)
const fireworks::Context * context() const
static const char *const kSimGeomFileCommandOpt
static void syncAllViews()
void titleChanged(const char *title)
void resetFieldEstimate() const
static const char *const kHelpOpt
static const char *const kLoopCommandOpt
static const char *const kAutoSaveHeight
void setConfigFilename(const std::string &f)
T get(const Candidate &c)
const_iterator end() const
const std::string sSearchFiles