ATLAS Offline Software
Loading...
Searching...
No Matches
VP1MainWindow.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Implementation of class VP1MainWindow //
8// //
9// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10// //
11// Initial version: April 2007 //
12//
13// Updates:
14// - Riccardo.Maria.Bianchi@cern.ch
15// //
17
19
29
30#ifdef BUILDVP1LIGHT
35#endif
36
38
40#include "VP1Base/IVP1System.h"
41#include "VP1Base/VP1Msg.h"
42#include "VP1Base/VP1Settings.h"
44#include "VP1Base/VP1QtUtils.h"
45
46
47#include <QMessageBox>
48#include <QImageWriter>
49#include <QFileInfo>
50#include <QInputDialog>
51#include <QLabel>
52#include <QCloseEvent>
53#include <QFileDialog>
54#include <QDir>
55#include <QTimer>
56#include <QSettings>
57#include <QComboBox>
58#include <QPainter>
59#include <QPrinter>
60#include <QPrintDialog>
61#include <QProgressBar>
62#include <QStyleFactory>
63#include <QDateTime>
64#include <QTimeZone>
65#include <QMutex>
66#include <QDesktopServices>
67#include <QUrl>
68#include <QProcess>
69#include <QGraphicsView>
70#include <QGraphicsScene>
71#include <QtGui>
72#include <QScrollBar>
73
74
75
76/* FIXME: LCG does not ship QWebEngine with Qt5 at the moment,
77 * but later you want to put it back again!
78 */
79/*
80#include <QtGlobal>
81#if QT_VERSION > QT_VERSION_CHECK(5, 5, 0)
82 #include <QWebEngineView> // Qt 5.6
83#else
84 #include <QtWebKit>
85#endif
86*/
87
88#include <cassert>
89#include <iostream>
90
91namespace {
92
93bool saveSnapshot(QWidget *parent, const QPixmap& snapshot, const QString& filename)
94{
95 QString error;
96 if (snapshot.isNull()) {
97 error = QStringLiteral("VP1 could not render the snapshot. No image was saved.\n\n"
98 "Offscreen OpenGL rendering may be unavailable on this display. "
99 "Check the terminal for Coin/GLX errors.\n\n") + VP1SnapshotStatus::failureHint();
100 } else {
101 QImageWriter writer(filename);
102 if (!writer.write(snapshot.toImage())) {
103 error = QStringLiteral("Could not write the snapshot:\n%1").arg(writer.errorString());
104 } else {
105 const QFileInfo output(filename);
106 if (!output.isFile() || output.size() == 0)
107 error = QStringLiteral("The image writer reported success, but no non-empty output file was found.");
108 }
109 }
110 if (error.isEmpty())
111 return true;
112
113 const QString message = error + QStringLiteral("\n\nOutput file: ") + filename;
114 VP1Msg::message(QStringLiteral("ERROR - Snapshot failed: ") + message);
115 QMessageBox dialog(QMessageBox::Critical, QStringLiteral("Snapshot failed"), message,
116 QMessageBox::Ok, parent);
117 dialog.setTextFormat(Qt::PlainText);
118 dialog.exec();
119 return false;
120}
121
122QString eventTimeUTC(unsigned timestamp)
123{
124 return QDateTime::fromSecsSinceEpoch(timestamp, Qt::UTC)
125 .toString(QStringLiteral("yyyy-MM-dd HH:mm:ss 'UTC'"));
126}
127
128QString eventTimeCERN(unsigned timestamp)
129{
130 const QTimeZone cernTimeZone("Europe/Zurich");
131 return QDateTime::fromSecsSinceEpoch(timestamp, Qt::UTC)
132 .toTimeZone(cernTimeZone)
133 .toString(QStringLiteral("yyyy-MM-dd HH:mm:ss t"));
134}
135
136}
137
138
139//_________________________________________________________________________________
141: QMainWindow(parent),
142 m_runnumber(-1),
143 m_eventnumber(-1),
144 m_betweenevents(true),
145 m_mustquit(false),
146 m_dummyemptycontroller(new QWidget(0)),
147 m_scheduler(sched),
148 m_availEvents(ae),
149 m_settingsfile(QDir::homePath()+QDir::separator()+".atlasvp1"),
150 m_userRequestedExit(false),
152 m_mutex(new QMutex()),
153 m_edEditor(0)
154{
155 setupUi(this); // this sets up the GUI
156
158 //
159 #if defined BUILDVP1LIGHT
160 bool checkShowAllCruiseAndEventControls = VP1QtUtils::expertSettingIsSet("expert","ExpertSettings/VP1_DEVEL_SHOW_ALL_CRUISE_AND_EVENT_CONTROLS");
161 #else
162 bool checkShowAllCruiseAndEventControls = VP1QtUtils::environmentVariableIsOn("VP1_DEVEL_SHOW_ALL_CRUISE_AND_EVENT_CONTROLS");
163 #endif
164
165 if (!checkShowAllCruiseAndEventControls) {
166 pushButton_eventseek->setVisible(false);
167 groupBox_cruise->setVisible(false);
168 }
169
170 if (m_availEvents) {
171 connect(m_availEvents,SIGNAL(message(const QString&)),this,SLOT(helperAddToMessageBox(const QString&)));
172 connect(m_availEvents,SIGNAL(freshEventsChanged()),this,SLOT(updateEventControls()));
173 }
174
175 // File menu
176 if(!m_availEvents) {
177 QMenu* menu_file = new QMenu(menubar);
178 menu_file->setObjectName("menu_file");
179 menu_file->setTitle("&File");
180 menubar->addAction(menu_file->menuAction());
181 m_action_addEventFile = menu_file->addAction("&Add event file ...");
182
183 connect(m_action_addEventFile,SIGNAL(triggered(bool)),this,SLOT(addEventFile()));
184 }
185
186 #ifndef BUILDVP1LIGHT
187 pushButton_previousevent->setVisible(false);
188 pushButton_eventselect->setVisible(false);
189 #else
190 pushButton_eventselect->setVisible(true);
191 pushButton_eventselect->setText("Event: 0/0");
192 pushButton_eventselect->setEnabled(false);
193 pushButton_previousevent->setEnabled(false);
194 //Disable all controls that are not available in VP1Light
195 // pushButton_quicksetup_3dcocktail->setEnabled(false);
196 // pushButton_quicksetup_3dcocktail->setToolTip("Not available in VP1Light");
197 pushButton_quicksetup_trackingstudies->setEnabled(false);
198 pushButton_quicksetup_trackingstudies->setToolTip("Not available in VP1Light");
199 pushButton_quicksetup_calostudies->setEnabled(false);
200 pushButton_quicksetup_calostudies->setToolTip("Not available in VP1Light");
201 action_quicklaunch_Tracking_studies->setEnabled(false);
202 action_quicklaunch_Tracking_studies->setToolTip("Not available in VP1Light");
203 action_quicklaunch_Calo_studies->setEnabled(false);
204 action_quicklaunch_Calo_studies->setToolTip("Not available in VP1Light");
205 action_quicklaunch_Storegate_browser->setEnabled(false);
206 action_quicklaunch_Storegate_browser->setToolTip("Not available in VP1Light");
207 action_quicklaunch_trackcalo_commis->setEnabled(false);
208 action_quicklaunch_trackcalo_commis->setToolTip("Not available in VP1Light");
209 m_action_addEventFile->setEnabled(false);
210 #endif
211
213 //Do we need a menu for multiple input directories?
214
215 VP1AvailEvtsLocalDir* availLocal = dynamic_cast<VP1AvailEvtsLocalDir*>(m_availEvents);
216
217 QStringList inputdirs;
218 if (availLocal)
219 inputdirs = availLocal->availableSourceDirectories();
220
221 if (availLocal&&!inputdirs.isEmpty()) {
222
223 QString currentdir = availLocal->currentSourceDir();
224 if (currentdir.endsWith("/"))
225 currentdir.chop(1);
226 m_currentStream = QDir(currentdir).dirName();
227 QMenu * menu_inputdir = new QMenu(menubar);
228 menu_inputdir->setObjectName("menu_inputdir");
229 menu_inputdir->setTitle("&Stream");
230
231 menubar->addAction(menu_inputdir->menuAction());
232
233 QActionGroup * inputdir_actiongroup = new QActionGroup(menu_inputdir);
234 QAction*action_inputdir_current(0);
235 for (QString inputdir : inputdirs) {
236 if (inputdir.endsWith("/"))
237 inputdir.chop(1);
238 QString dirname = QDir(inputdir).dirName();
239 QAction * action_inputdir = new QAction(this);
240 action_inputdir->setObjectName("action_inputdir_"+dirname);
241 action_inputdir->setData(inputdir);
242 action_inputdir->setStatusTip("Get input files from: "+inputdir);
243 action_inputdir->setCheckable(true);
244
245 if (currentdir==inputdir)
246 action_inputdir_current = action_inputdir;
247 menu_inputdir->addAction(action_inputdir);
248 inputdir_actiongroup->addAction(action_inputdir);
249 m_inputdiractions << action_inputdir;
250 connect(action_inputdir,SIGNAL(triggered(bool)),this,SLOT(inputDirectoryActionTriggered()));
251 }
252 if (action_inputdir_current) {
253 action_inputdir_current->blockSignals(true);
254 action_inputdir_current->setChecked(true);
255 action_inputdir_current->blockSignals(false);
256 }
257
258 // Populate inputdirstatuses
259 for(QAction* action : m_inputdiractions)
260 m_inputdirstatuses[action] = VP1DirStatusData(action->data().toString(),
261 QString(),
262 true,
263 false);
264
266 m_streamMenuUpdater->start();
267
268 //Fixme: start timer which every minute checks the status of these directories
269 QTimer *timer = new QTimer(this);
270 connect(timer, SIGNAL(timeout()), this, SLOT(updateInputDirectoriesStatus()));
271 timer->start(5000);//update this menu rather often (this is only for P1 anyway)
272 }
273
274 //.......
275
277 m_tabmanager = new VP1TabManager(this,tabWidget_central,m_channelmanager);
278 stackedWidget_customcontrols->addWidget(m_dummyemptycontroller);
279
280 //Final touches to instructions page:
281
282 // Remove any margins added by the layouts in the stacked
283 // widget. This really ought to be the default for stacked widgets!
284 for (int i=0;i<stackedWidget_central->count();++i)
285 stackedWidget_central->widget(i)->layout()->setContentsMargins(0,0,0,0);
286
287 frame_instructions->setStyleSheet("QFrame#frame_instructions { "+VP1DockWidget::highlightStyle()+" } ");
288 frame_instructions->setFrameShape(QFrame::StyledPanel);
289 // textBrowser_intro1->setStyleSheet("QTextBrowser#textBrowser_intro1 { background-color: rgba(0, 0, 0, 0%) } ");
290 // textBrowser_intro2->setStyleSheet("QTextBrowser#textBrowser_intro2 { background-color: rgba(0, 0, 0, 0%) } ");
291 #ifndef BUILDVP1LIGHT
292 connect(pushButton_quicksetup_3dcocktail,SIGNAL(clicked()),this,SLOT(quickSetupTriggered()));
293 #else
294 connect(pushButton_quicksetup_3dcocktail,SIGNAL(clicked()),this,SLOT(quickSetupTriggered()));
295 #endif
296 connect(pushButton_quicksetup_trackingstudies,SIGNAL(clicked()),this,SLOT(quickSetupTriggered()));
297 connect(pushButton_quicksetup_calostudies,SIGNAL(clicked()),this,SLOT(quickSetupTriggered()));
298 connect(pushButton_quicksetup_geometrystudies,SIGNAL(clicked()),this,SLOT(quickSetupTriggered()));
299 connect(pushButton_quicksetup_analysisstudies,SIGNAL(clicked()),this,SLOT(quickSetupTriggered()));
300
301 //Default application font:
302 m_defaultfont = QApplication::font();
306 else
308
309 //Tabs:
310 connect(m_tabmanager,SIGNAL(tabListChanged(QStringList)),this,SLOT(tabListChanged(QStringList)));
311 connect(tabWidget_central,SIGNAL(currentChanged(int)),this,SLOT(updateCentralStackWidget()));
313
314 //Channels:
315
316 connect(pushButton_saveAllChannels,SIGNAL(clicked()),this,SLOT(saveAllCurrentChannels()));
317 connect(pushButton_makeEventDisplay,SIGNAL(clicked()),this,SLOT(makeAllChannelsEventDisplay()));
318
319 connect(pushButton_3D,SIGNAL(clicked()),this,SLOT(launch3DstereoEditor()));
320
321 connect(pushButton_channelfullscreen,SIGNAL(clicked()),m_tabmanager,SLOT(showCurrentChannelFullScreen()));
322 connect(pushButton_channelinformation,SIGNAL(clicked()),this,SLOT(request_channelInformation()));
323 connect(pushButton_printchannel,SIGNAL(clicked()),this,SLOT(request_printChannel()));
324 connect(pushButton_savesnapshotchannel,SIGNAL(clicked()),this,SLOT(request_saveChannelSnapshot()));
326
327 //Menu:
328 //Quick start:
329 connect(action_quicklaunch_Tracking_studies,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
330 connect(action_quicklaunch_Calo_studies,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
331 connect(action_quicklaunch_Geometry_studies,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
332 connect(action_quicklaunch_analysisstudies,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
333 connect(action_quicklaunch_Storegate_browser,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
334 connect(action_quicklaunch_3dcocktail,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
335 connect(action_quicklaunch_trackcalo_commis,SIGNAL(triggered(bool)),this,SLOT(quickSetupTriggered()));
336 connect(action_exit_VP1,SIGNAL(triggered(bool)),this,SLOT(close()));
337
338 //Configuration
339 m_menu_loadConfFile = menuConfiguration->addMenu ( "&Load tab configuration from file" );
340 m_menu_loadConfFile->setStatusTip("Select .vp1 config file to load");
341 connect(m_menu_loadConfFile,SIGNAL(aboutToShow()),this,SLOT(showMenu_loadConfFile()));
342 menuConfiguration->addSeparator();
343 //plugins:
344 m_menu_loadPlugin = menuConfiguration->addMenu ( "&Load plugin" );
345 m_menu_loadPlugin->setStatusTip("Select plugin to load");
346 // m_action_infoAboutLoadedPlugins = menuPlugins->addAction ( "&Info about loaded plugins" );
347 // m_action_infoAboutLoadedPlugins->setStatusTip("Get information about the presently loaded plugins");
348 // m_action_infoAboutLoadedPlugins->setEnabled(false);
349 connect(m_menu_loadPlugin,SIGNAL(aboutToShow()),this,SLOT(showMenu_loadPlugin()));
350 //Style
351 m_menu_changeStyle = menu_Style->addMenu ( "&Style" );
352 QActionGroup * styleGroup = new QActionGroup(this);
353 QAction * laststyleact(0);
354 bool foundplastique=false;
355 QSettings s(m_settingsfile,QSettings::IniFormat);
356 QString defaultstyle=s.value("style/defaultstyle", "Fusion").toString();
357 for (QString style : QStyleFactory::keys() ) {
358 QAction * act = m_menu_changeStyle->addAction(style);
359 act->setStatusTip("Change application style to "+style);
360 connect(act,SIGNAL(triggered(bool)),this,SLOT(changeStyleActionTriggered()));
361 act->setCheckable(true);
362 styleGroup->addAction(act);
363 laststyleact=act;
364 if (act->text()==defaultstyle) {
365 act->setChecked(true);
366 QApplication::setStyle(QStyleFactory::create(act->text()));
367 foundplastique=true;
368 }
369 }
370 if (!foundplastique) {
371 laststyleact->setChecked(true);
372 QApplication::setStyle(QStyleFactory::create(laststyleact->text()));
373 }
374 //Fonts:
375 int savedgoal = 0;
377 savedgoal = s.value("font/pixelsize_diff", 0).toInt();
378 else
379 savedgoal = s.value("font/pointsize_relativepercent", 0).toInt();
380
381 m_menu_changeFontSize = menu_Style->addMenu ( "&Font size" );
382 QList<int> fontoptions;
384 fontoptions <<15<<10<<+5<<+3<<+2<<+1<<0<<-1<<-2<<-3<<-5<<-10<<-20<<-30;
385 else
386 fontoptions <<150<<100<<50<<30<<20<<10<<5<<0<<-5<<-10<<-20<<-30<<-50;
387
388 QActionGroup * fontGroup = new QActionGroup(this);
389 bool foundsavedgoal(false);
390 QAction * normalfontact(0);
391 for (int fontopt : fontoptions) {
393 continue;
394 QString text = (fontopt==0?"normal": (fontopt>0?"+":"")+QString::number(fontopt)+(m_defaultfont_pointsize < 0.0? " pixels" : "%"));
395 QAction * act = m_menu_changeFontSize->addAction(text);
396 act->setStatusTip("Change overall font size of application to "+text);
397 act->setData(fontopt);
398 act->setCheckable(true);
399 fontGroup->addAction(act);
400 connect(act,SIGNAL(triggered(bool)),this,SLOT(changeFontSizeActionTriggered()));
401 if (fontopt==0)
402 normalfontact=act;
403 if (savedgoal==fontopt) {
404 act->setChecked(true);
405 changeFontSize(fontopt);
406 foundsavedgoal=true;
407 }
408 }
409 if (!foundsavedgoal) {
410 normalfontact->setChecked(true);
411 }
412
413 //
414 m_actionSave_current_tabs = menuConfiguration->addAction ( "&Save current tab configuration to file" );
415 m_actionSave_current_tabs->setStatusTip("Save current tab/channel layout to .vp1 config file");
416 menuConfiguration->addSeparator();
417 m_actionAdd_empty_tab = menuConfiguration->addAction ( "&Add empty tab" );
418 m_actionAdd_empty_tab->setStatusTip("Add empty tab to the current tab list");
419 connect(m_actionAdd_empty_tab,SIGNAL(triggered(bool)),this,SLOT(request_addEmptyTab()));
420 connect(m_actionSave_current_tabs,SIGNAL(triggered(bool)),this,SLOT(request_saveasConfig()));
421
422 //ExpertSettings
423 #ifdef BUILDVP1LIGHT
424 menuConfiguration->addSeparator();
425 m_actionEnableExpertSettings = menuConfiguration->addAction ( "&Settings" );
426 m_actionEnableExpertSettings->setStatusTip("Open additional settings");
427 connect(m_actionEnableExpertSettings, &QAction::triggered, this, &VP1MainWindow::request_expertSettings);
428 #endif
429
430 //Event navigation:
431 connect(pushButton_nextevent,SIGNAL(clicked()),this,SLOT(goToNextEvent()));
432 #ifdef BUILDVP1LIGHT
433 connect(pushButton_previousevent,SIGNAL(clicked()),this,SLOT(goToPreviousEvent()));
434 connect(pushButton_eventselect,SIGNAL(clicked()),this,SLOT(chooseEvent()));
435 #endif
436
437 //Listen for external requests:
439 listenOnTcp();
440 // updateTcpIcon();
441 connect(&m_tcpserver,SIGNAL(listenStateChanged(bool)),this,SLOT(updateTcpIcon()));
444 m_blockallmessages=false;
446
447 //Cruise:
448 connect(pushButton_cruise,SIGNAL(clicked()),this,SLOT(request_cruisemodechange()));
449 connect(radioButton_cruise_event,SIGNAL(clicked()),this,SLOT(request_cruisemodechange()));
450 connect(radioButton_cruise_tab,SIGNAL(clicked()),this,SLOT(request_cruisemodechange()));
451 connect(radioButton_cruise_both,SIGNAL(clicked()),this,SLOT(request_cruisemodechange()));
452
453 // Help menu
454 QMenu* menu_help = new QMenu(menubar);
455 menu_help->setObjectName("menu_help");
456 menu_help->setTitle("&Help");
457 menubar->addAction(menu_help->menuAction());
458 m_action_openVP1Site = menu_help->addAction("VP1 &Web Site");
459 m_action_openUsersGuide = menu_help->addAction("VP1 &User's Guide");
460 m_action_openUsersSupport = menu_help->addAction("VP1 User's &Support (in the system browser)");
461 menu_help->addSeparator();
462 m_action_openAbout = menu_help->addAction("&About VP1");
463
464 QTimer::singleShot(0, this, SLOT(postInitUpdates()));
465
466 if (qgetenv("VP1_REMOTE_MODE") == "1") {
467 QString coinPolicy = QString::fromLocal8Bit(qgetenv("VP1_COIN_INDIRECT_RENDERING_MESSAGE"));
468 if (coinPolicy.isEmpty())
469 coinPolicy = tr("Coin default policy (not initialized by the vp1 launcher).");
470 auto *modeLabel = new QLabel(tr("REMOTE MODE"), this);
471 modeLabel->setStyleSheet("QLabel { background: #ffe08a; color: #202020; font-weight: bold; padding: 4px; }");
472 modeLabel->setToolTip(tr("Remote mode enabled. Continuous rotation after mouse release is off by default. "
473 "Restart with --no-remote if detection is incorrect."));
474 modeLabel->setToolTip(modeLabel->toolTip() + QStringLiteral("\nSnapshot compatibility: ")
476 + QStringLiteral("\nCoin OpenGL policy: ") + coinPolicy);
477 statusBar()->addPermanentWidget(modeLabel);
478 if (!VP1QtUtils::environmentVariableIsSet("VP1_BATCHMODE")) {
479 QTimer::singleShot(0, this, [this, coinPolicy]() {
480 auto *notice = new QMessageBox(QMessageBox::Information, tr("VP1 remote mode"),
481 tr("VP1 has launched in remote mode.\n\nReason: %1.\n\n"
482 "Remote mode improves your experience when running VP1 remotely. "
483 "It helps protect screenshot creation and makes mouse interaction more responsive.")
484 .arg(QString::fromLocal8Bit(qgetenv("VP1_REMOTE_REASON"))),
485 QMessageBox::Ok, this);
486 notice->setTextFormat(Qt::PlainText);
487 notice->setDetailedText(
488 tr("To improve responsiveness, Continue rotating after mouse release is OFF by default. "
489 "Your saved remote preference takes precedence. Normal mouse dragging still works.\n\n"
490 "You can change this setting in the 3D viewer's right-click menu.\n\n"
491 "Snapshot compatibility: %1\n\n"
492 "Coin OpenGL policy: %2\n\n"
493 "If detection is incorrect, restart VP1 with --no-remote.")
494 .arg(VP1SnapshotStatus::description(), coinPolicy));
495 notice->setAttribute(Qt::WA_DeleteOnClose);
496 notice->open();
497 });
498 }
499 }
500
503
504 connect(m_action_openUsersGuide,SIGNAL(triggered(bool)),this,SLOT(help_openUserGuide()));
505 connect(m_action_openVP1Site,SIGNAL(triggered(bool)),this,SLOT(help_openVP1WebSite()));
506 connect(m_action_openUsersSupport,SIGNAL(triggered(bool)),this,SLOT(help_openUserSupport()));
507 connect(m_action_openAbout,SIGNAL(triggered(bool)),this,SLOT(help_openAbout()));
508
509 // FIXME: enabling menubar again. It's part of a quickfix, described here: https://its.cern.ch/jira/browse/ATLASVPONE-120
510 #ifndef BUILDVP1LIGHT
511 menubar->setEnabled(false);
512 #endif
513}
514
515//_________________________________________________________________________________
517{
518 VP1Msg::messageDebug("VP1MainWindow::launch3DstereoEditor()");
519 m_tabmanager->launchStereoEditorCurrentTab();
520
521}
522
523//_________________________________________________________________________________
525 /*
526 * Open the online help from a web url location
527 * with the default system web browser
528 */
529 VP1Msg::messageDebug("VP1MainWindow::help_openUserGuide()");
530 // we use here the default system browser
531 QDesktopServices::openUrl(QUrl("http://atlas-vp1.web.cern.ch/atlas-vp1/doc/"));
532 return;
533}
534
535//_________________________________________________________________________________
537 /*
538 * Open the online page with links to the JIRA issue collectors
539 * with the default system web browser
540 */
541 VP1Msg::messageDebug("VP1MainWindow::help_openUserSupport()");
542 // we use here the default system browser
543 QDesktopServices::openUrl(QUrl("http://atlas-vp1.web.cern.ch/atlas-vp1/vp1_users_support/"));
544 return;
545}
546
547//_________________________________________________________________________________
549 /*
550 * Open the online help from a web url location
551 * with the default system web browser
552 */
553 VP1Msg::messageDebug("VP1MainWindow::help_openVP1WebSite()");
554 // we use here the default system browser
555 QDesktopServices::openUrl(QUrl("http://atlas-vp1.web.cern.ch/atlas-vp1/"));
556 return;
557}
558
559
560//_________________________________________________________________________________
562 /*
563 * open the online help
564 */
565 VP1Msg::messageDebug("VP1MainWindow::help_openAbout()");
566 // we use here the default system browser
567 QDesktopServices::openUrl(QUrl("https://atlas-vp1.web.cern.ch/atlas-vp1/doc_new/about_vp1/CREDITS.html"));
568 return;
569}
570
571
572//_________________________________________________________________________________
574
575 //Make sure that the splitters give maximum space for the tab area.
576
577 int sum1 = splitter_tabwidget_messagebox->sizes().at(0) + splitter_tabwidget_messagebox->sizes().at(1);
578 QList<int> sizes1; sizes1 << sum1 << 0;
579 splitter_tabwidget_messagebox->setSizes ( sizes1 );
580 int bottom = 1;
581 while (splitter_tabwidget_messagebox->sizes().at(1)==0&&bottom<50000) {
582 QList<int> sizes2; sizes2 << sum1-bottom << bottom;
583 splitter_tabwidget_messagebox->setSizes ( sizes2 );
584 ++bottom;
585 }
586
587 int sum2 = splitter_leftright->sizes().at(0) + splitter_leftright->sizes().at(1);
588 int left = 300;
589 QList<int> sizes3; sizes3 << left << sum2-left;
590 splitter_leftright->setSizes ( sizes3 );
591 while (splitter_leftright->sizes().at(0)==0&&left<50000) {
592 QList<int> sizes4; sizes4 << left << sum2-left;
593 splitter_leftright->setSizes ( sizes4 );
594 ++left;
595 }
596
597 int prefwidths = std::max<int>(left,widget_controlsContainer->sizeHint().width());
598 prefwidths = std::max<int>(prefwidths,groupBox_channelcontrols->sizeHint().width());
599 prefwidths = std::max<int>(prefwidths,groupBox_cruise->sizeHint().width());
600 prefwidths = std::max<int>(prefwidths,groupBox_event->sizeHint().width());
601 prefwidths = std::max<int>(prefwidths,stackedWidget_customcontrols->sizeHint().width());
602 widget_controlsContainer->setMaximumWidth(50+prefwidths);
603 // int h1(textBrowser_intro1->viewport()->sizeHint().height());
604 // textBrowser_intro1->setMaximumHeight(h1+2);
605 if (m_availEvents)
606 m_availEvents->init();
608}
609
610//_________________________________________________________________________________
612 progressbar = new QProgressBar();
613 progressbar->setMinimum(0);
614 progressbar->reset();
615 progressbar->setOrientation(Qt::Horizontal);
616 statusBar()->addPermanentWidget(progressbar);
617 m_statusbarlabel = new QLabel();
618 //Turn off ugly box around items in statusbar:
619 statusBar()->setStyleSheet("QStatusBar::item { border-width: 0 }");
620 statusBar()->addPermanentWidget(m_statusbarlabel);
621 progressbar->hide();
622}
623
624//_________________________________________________________________________________
626{
627 if (m_edEditor) {
628 VP1Msg::messageDebug("deleting the editor");
629 delete m_edEditor;
630 }
631 VP1Msg::messageDebug("deleting the tab manager");
632 delete m_tabmanager;
633 VP1Msg::messageDebug("deleting the channel manager");
634 delete m_channelmanager;
635 VP1Msg::messageDebug("deleting the events");
636 delete m_availEvents;
637
639 VP1Msg::messageDebug("deleting the streamupdater");
640 m_streamMenuUpdater->quit();
641 m_streamMenuUpdater->deleteLater();
642 }
643
644 VP1Msg::messageDebug("deleting the mutex");
645 delete m_mutex;
646
647 VP1Msg::messageDebug("deleting the view");
648}
649
650//_________________________________________________________________________________
652 return m_mustquit;
653}
654
655
656//_________________________________________________________________________________
658{
659 bool l = m_tcpserver.isListening();
660 m_statusbarlabel->setPixmap(QIcon(l?":/vp1/icons/icons/network_64x64.png":":/vp1/icons/icons/network_disconnect_64x64.png")
661 .pixmap(progressbar->height(),progressbar->height(),QIcon::Normal,QIcon::On));
662 m_statusbarlabel->setToolTip(l?"Listening on port "+QString::number(m_tcpserver.port())+" for incoming messsages"
663 :"VP1 is presently NOT listening for incoming messages");
664
665}
666
667//_________________________________________________________________________________
668void VP1MainWindow::loadPluginFile(const QString& filename)
669{
670 VP1Msg::messageDebug("loadPluginFile()");
671
672 QString err = m_channelmanager->loadPluginFile(filename);
673 if (!err.isEmpty()) {
674 QMessageBox::critical(0, "Error - could not load plugin file: "+filename,
675 "Could not load plugin file: "
676 +filename+"\n\nReason: "+err,QMessageBox::Ok,QMessageBox::Ok);
677 VP1Msg::message("Could not load plugin file: "+filename+"\n\nReason: "+err);
678 }
679 //Fixme: Error message here is hardcoded to be the same as in loadPluginFile method!!
680}
681
682//_________________________________________________________________________________
684 bool ok;
685 QString newtabname = QInputDialog::getText( 0, "New Tab Name","New tab name:",
686 QLineEdit::Normal, m_tabmanager->suggestNewTabName("My Tab"), &ok );
687 if (!ok||newtabname.isEmpty())
688 return;
689 m_tabmanager->addNewTab(newtabname);
690}
691
692//_________________________________________________________________________________
693void VP1MainWindow::tabListChanged(const QStringList& l) {
695 if (l.count()) {
696 m_actionSave_current_tabs->setEnabled(true);
697 groupBox_cruise->setEnabled(true);
698 } else {
699 m_actionSave_current_tabs->setEnabled(false);
700 groupBox_cruise->setEnabled(false);
701 }
702 if (l.count()>1) {
703 radioButton_cruise_tab->setEnabled(true);
704 radioButton_cruise_both->setEnabled(true);
705 } else {
706 if (radioButton_cruise_tab->isChecked()||radioButton_cruise_both->isChecked())
707 radioButton_cruise_event->setChecked(true);
708 radioButton_cruise_tab->setEnabled(false);
709 radioButton_cruise_both->setEnabled(false);
710 }
711}
712
713//_________________________________________________________________________________
714void VP1MainWindow::addChannelIconsToComboBox(QComboBox* cb, const bool& isbasenames) {
715 int n= cb->count();
716 for (int i = 0; i<n; ++i) {
717 QString icontext = m_channelmanager->getIconLocation(cb->itemText(i), isbasenames);
718 if (!icontext.isEmpty())
719 cb->setItemIcon ( i, QIcon(icontext) );
720 }
721}
722
723//_________________________________________________________________________________
725{
726 VP1Msg::messageDebug("VP1MainWindow::selectedChannelChanged()");
727
728 //Controls box:
729 if (cw) {
730 groupBox_channelcontrols->setTitle("Controls: "+cw->unique_name());
731 groupBox_channelcontrols->setEnabled(true);
732 QWidget* controller = m_channelmanager->getController(cw);
733 if (!controller) {
734 stackedWidget_customcontrols->setCurrentWidget(m_dummyemptycontroller);
735 } else {
736 if (stackedWidget_customcontrols->indexOf(controller)==-1)
737 stackedWidget_customcontrols->addWidget(controller);
738 stackedWidget_customcontrols->setCurrentWidget(controller);
739 }
740 } else {
741 groupBox_channelcontrols->setTitle("Controls: no channel selected");
742 groupBox_channelcontrols->setEnabled(false);
743 stackedWidget_customcontrols->setCurrentWidget(m_dummyemptycontroller);
744 }
745
746 // FIXME: enabling menubar again. It's part of a quickfix, described here: https://its.cern.ch/jira/browse/ATLASVPONE-120
747 menubar->setEnabled(true);
748
749 // FIXME: enabling menubar again. It's part of a quickfix, described here: https://its.cern.ch/jira/browse/ATLASVPONE-120
750 menubar->setEnabled(true);
751}
752
753//_________________________________________________________________________________
755
756 QString filename = QFileDialog::getSaveFileName(this, "Select configuration file to save",
758 "VP1 Configuration files (*.vp1)",0,QFileDialog::DontResolveSymlinks);
759 if(filename.isEmpty())
760 return;
761
762 if (!filename.endsWith(".vp1"))
763 filename += ".vp1";
764
765 m_tabmanager->saveConfigurationToFile(filename,false/*Since the filedialog already asks*/);
766 m_currentconfigfile=filename;
767}
768
769//_________________________________________________________________________________
771{
772 if (m_currentconfigfile.isEmpty()) {
774 return;
775 }
776 m_tabmanager->saveConfigurationToFile(m_currentconfigfile,false);
777}
778
779//_________________________________________________________________________________
781{
782 QString filename = QFileDialog::getOpenFileName(this, "Select configuration file to load",
784 "VP1 configuration files (*.vp1)",0,QFileDialog::DontResolveSymlinks);
785 if(filename.isEmpty())
786 return;
787 m_tabmanager->loadConfigurationFromFile(filename,availablePluginFiles());
788 m_currentconfigfile=filename;
789}
790
791//_________________________________________________________________________________
793{
794#ifdef __APPLE__
795 QString sharedlibsuffix = "dylib";
796#else
797 QString sharedlibsuffix = "so";
798#endif
799 qDebug() << "VP1MainWindow::request_loadPlugin()"<<m_currentloadpluginpath;
800
801 QString filename = QFileDialog::getOpenFileName(this, "Select plugin file to load",
803 "VP1 plugin files (*VP1*."+sharedlibsuffix+")",0,QFileDialog::DontResolveSymlinks);
804 if(filename.isEmpty())
805 return;
806 m_currentloadpluginpath = QFileInfo(filename).dir().absolutePath();
807 loadPluginFile(filename);
808}
809
810//_________________________________________________________________________________
811QMap<QString,QString> VP1MainWindow::availableFiles(const QString& extension,
812 const QString& pathvar,//LD_LIBRARY_PATH or DATAPATH
813 const QString& instareasubdir,
814 const QString& extradirenvvar,
815 bool currentdir ) const
816{
817
818 qDebug() << "VP1MainWindow::availableFiles()";
819 qDebug() << "extension:" << extension << "pathvar:" << pathvar << "instareasubdir:" << instareasubdir << "extradirenvvar:" << extradirenvvar << "currentdir:" << currentdir;
820
821
822 //Add directories from extradirenvvar (e.g. $VP1PLUGINPATH)
823 QStringList vp1pluginpath =
824 extradirenvvar.isEmpty() ?
825 QStringList() :
826 QString(::getenv(extradirenvvar.toStdString().c_str())) .
827#if QTCORE_VERSION >= 0x050E00
828 split(":",Qt::SkipEmptyParts);
829#else
830 split(":",QString::SkipEmptyParts);
831#endif
832 if(VP1Msg::debug()){
833 qDebug() << "extradirenvvar:" << extradirenvvar;
834 qDebug() << "vp1pluginpath:" << vp1pluginpath;
835 }
836
837 #ifdef BUILDVP1LIGHT
838 //Add dir from Expert Settings
839 if(VP1QtUtils::expertSettingValue("expert","ExpertSettings/VP1PLUGINPATH")==""){
840 vp1pluginpath<<QCoreApplication::applicationDirPath()+"/../lib";
841 } else{
842 vp1pluginpath<<VP1QtUtils::expertSettingValue("expert","ExpertSettings/VP1PLUGINPATH");
843 }
844 #endif
845
846 //Currentdir:
847 if (currentdir) {
848 vp1pluginpath<<QDir::currentPath();
849 if (QDir::currentPath()!=VP1Settings::defaultFileSelectDirectory())
851 }
852
853 //Add directories from pathvar (looking in subdir instareasubdir):
854 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
855 VP1Msg::messageDebug("This is the 'pathvar' variable: " + pathvar);
856 QString path = env.value(pathvar);
857 VP1Msg::messageDebug("Add directories from 'pathvar' variable: " + path);
858
859 if (!path.isEmpty()) {
860#if QTCORE_VERSION >= 0x050E00
861 VP1Msg::messageDebug("We're using Qt5...");
862 QStringList tmp = path.split(":",Qt::SkipEmptyParts);//This 'tmp' is for SLC3 compilation.
863#else
864 VP1Msg::messageDebug("We're using Qt older than 5...");
865 QStringList tmp = path.split(":",QString::SkipEmptyParts);//This 'tmp' is for SLC3 compilation.
866#endif
867 for (const QString& dir : tmp) {
868 vp1pluginpath << ( instareasubdir.isEmpty() ? dir : dir+QDir::separator()+instareasubdir );
869 }
870 }
871
872 // Remove duplicates
873 int nDuplicatesRemoved = vp1pluginpath.removeDuplicates();
874 VP1Msg::messageDebug("Removed '" + QString::number(nDuplicatesRemoved) + "' duplicate paths.");
875
876 // Remove all nonexisting directories:
877 QStringList validPluginPaths;
878 validPluginPaths.reserve(vp1pluginpath.size());
879 for (const QString& plugindir : vp1pluginpath) {
880 VP1Msg::messageDebug("plugindir: '" + plugindir + "'");
881 QFileInfo fi(plugindir);
882
883 if (fi.exists() && fi.isDir()) {
884 validPluginPaths << plugindir;
885 } else {
886 VP1Msg::messageDebug("Removed non-valid path: '" + plugindir + "'");
887 }
888 }
889 vp1pluginpath = validPluginPaths;
890
891
892 //Find all files with required extension in the directories (in case of duplicates - the ones appearing first are used):
893 QMap<QString,QString> plugins2fullpath;
894 for (const QString& plugindir : vp1pluginpath) {
895 QStringList plugins = QDir(plugindir).entryList((QStringList()<<("*"+extension)),QDir::CaseSensitive | QDir::Files | QDir::Readable,QDir::Name);
896 for (QString plugin : plugins) {
897 plugin = QFileInfo(plugin).fileName();
898 if (!plugins2fullpath.contains(plugin)) {
899 QString fullpath = plugindir+QDir::separator()+plugin;
900 plugins2fullpath[plugin]=fullpath;
901 }
902 }
903 }
904 return plugins2fullpath;
905}
906
907//_________________________________________________________________________________
908QMap<QString,QString> VP1MainWindow::availablePluginFiles() const
909{
910VP1Msg::messageDebug("VP1MainWindow::availablePluginFiles()");
911
912#ifdef __APPLE__
913 QString sharedlibsuffix = "dylib";
914#else
915 QString sharedlibsuffix = "so";
916#endif
917
918 return availableFiles( "."+sharedlibsuffix, "LD_LIBRARY_PATH", "vp1plugins", "VP1PLUGINPATH" );
919
920}
921
922//_________________________________________________________________________________
924 if (!m_plugindialog)
925 return;
926
927 int res = m_plugindialog->result();
928 QString filename = m_plugindialog->unloadfile();
929 disconnect(m_plugindialog,SIGNAL(finished(int)),this,SLOT(pluginDialogClosed()));
930 m_plugindialog->deleteLater();
931 m_plugindialog = 0;
932
933 if (res!=QDialog::Accepted||filename.isEmpty())
934 return;
935
936 QStringList bns = m_channelmanager->channelsInPluginFile(filename);
937
938 for (const QString& bn : bns) {
939 while(m_channelmanager->basename2UniqueNames(bn).count()>0)
940 m_tabmanager->removeChannel(m_channelmanager->basename2UniqueNames(bn).value(0));
941 }
942
943 m_currentunloadpluginfiles << filename;
944 QTimer::singleShot(0, this, SLOT(unloadPlugin_continue()));
945
946}
947
948//_________________________________________________________________________________
950{
951 for (const QString& filename : m_currentunloadpluginfiles) {
952 bool success = m_channelmanager->unloadPluginFile(filename);
953 if (!success)
954 QMessageBox::critical(0, "Error - problems unloading plugin file: "+filename,
955 "Problems encountered while attempting to unload plugin file: "+filename,QMessageBox::Ok,QMessageBox::Ok);
956 }
958}
959
960//_________________________________________________________________________________
962{
963 return ! (m_betweenevents || (m_availEvents&&m_availEvents->freshEvents().isEmpty()));
964}
965
966
967//_________________________________________________________________________________
969 m_betweenevents=true;
970 if (m_availEvents) {
971 QList<VP1EventFile> evts = m_availEvents->freshEvents();
972 if (evts.empty()) {
973 addToMessageBox("ERROR: Going to next event, but one is not available!");
974 m_scheduler->setNextRequestedEventFile("");
975 } else {
976 m_scheduler->setNextRequestedEventFile(evts.front().fileName());
977 }
978 }
980}
981
982//_________________________________________________________________________________
984 #if defined BUILDVP1LIGHT
985 std::cout << "goToNextEvent: \n"
986 << "m_scheduler->getEvtNr()+2: " << m_scheduler->getEvtNr()+2
987 << "\nm_scheduler->getTotEvtNr(): " << m_scheduler->getTotEvtNr() << std::endl;
988 if ( m_scheduler->getEvtNr()+2 < m_scheduler->getTotEvtNr() ) {
989 std::cout << "First case" << std::endl;
990 m_scheduler->setEvtNr(m_scheduler->getEvtNr()+1);
991 nextEvent();
992 qApp->quit();
993 }
994 else if( m_scheduler->getEvtNr()+2 == m_scheduler->getTotEvtNr() ) {
995 std::cout << "Second case" << std::endl;
996 m_scheduler->setEvtNr(m_scheduler->getEvtNr()+1);
997 nextEvent();
998 qApp->quit();
999 }
1000 #else
1001 nextEvent();
1002 qApp->quit();
1003 #endif
1004}
1005
1006#if defined BUILDVP1LIGHT
1007//_________________________________________________________________________________
1008void VP1MainWindow::goToPreviousEvent() {
1009 if ( m_scheduler->getEvtNr()-1 > 0 ) {
1010 m_scheduler->setEvtNr(m_scheduler->getEvtNr()-1);
1011 nextEvent();
1012 qApp->quit();
1013 }
1014 else if( m_scheduler->getEvtNr()-1 == 0 ) {
1015 m_scheduler->setEvtNr(m_scheduler->getEvtNr()-1);
1016 nextEvent();
1017 qApp->quit();
1018 }
1019}
1020#endif
1021
1022//_________________________________________________________________________________
1023void VP1MainWindow::closeEvent(QCloseEvent * event)
1024{
1025 VP1Msg::messageDebug("VP1MainWindow::closeEvent()");
1026
1027 bool checkEnableAskOnClose;
1028 #if defined BUILDVP1LIGHT
1029 checkEnableAskOnClose = VP1QtUtils::expertSettingIsSet("general","ExpertSettings/VP1_ENABLE_ASK_ON_CLOSE");
1030 #else
1031 checkEnableAskOnClose = VP1QtUtils::environmentVariableIsOn("VP1_ENABLE_ASK_ON_CLOSE");
1032 #endif
1033
1034 if (checkEnableAskOnClose) {
1035 int ret = QMessageBox::warning(this,
1036 "Close VP1?",
1037 "You are about to close VP1 and end the job.\nProceed?",
1038 QMessageBox::Ok| QMessageBox::Cancel,
1039 QMessageBox::Cancel );
1040 if (ret!=QMessageBox::Ok) {
1041 event->ignore();
1042 return;
1043 }
1044 m_userRequestedExit = true;
1045 }
1046
1047 hide();
1048
1049 VP1Msg::messageDebug("calling tabmanager->setSelectedDockWidget(0)...");
1050 m_tabmanager->setSelectedDockWidget(0);
1051 VP1Msg::messageDebug("tabmanager->setSelectedDockWidget(0) called.");
1052
1053 m_mustquit=true; // this will inform VP1Alg that we want to quit VP1 (then we'll quit the Athena algorithm)
1054 VP1Msg::messageDebug("calling qApp->quit()...");
1055 qApp->quit();
1056}
1057
1058//_________________________________________________________________________________
1059void VP1MainWindow::setRunEvtNumber(const int& r, const unsigned long long& e, const unsigned& triggerType, const unsigned& time, const bool& printmessage ) {
1060
1061 m_scheduler->setNextRequestedEventFile("");
1062 const bool sameasold(m_runnumber==r&&m_eventnumber==e);
1063
1064 m_runnumber=r;
1065 m_eventnumber=e;
1066 m_timestamp=time;
1067
1068 m_betweenevents = false;
1069 if (m_availEvents)
1070 m_availEvents->setCurrentEvent(r,e);
1071
1072 for(IVP1ChannelWidget* channel : m_tabmanager->allChannels()) {
1073 channel->setRunEvtNumber(r,e);
1074 channel->setEvtTimestamp(time);
1075 }
1076
1077 if(printmessage) {
1078 qulonglong evNumber = m_eventnumber;
1079 QString evtstr = "run# "+QString::number(m_runnumber)+", event# "+QString::number(evNumber)+(sameasold?" (reused)":"");
1080 QString trighex = triggerType > 0 ? "0x"+QString::number(triggerType, 16).toUpper().rightJustified(sizeof(triggerType),'0') : "";
1081 QString expandedevtstr = evtstr
1082 + QString(trighex.isEmpty()?QString(""):", triggerType: "+trighex)
1083 + QString(time>0 ? ", time: "+eventTimeUTC(time) : "")
1084 + QString(m_currentStream.isEmpty()?"":", "+m_currentStream);
1085
1086 #ifdef BUILDVP1LIGHT
1087 setWindowTitle("VP1Light ["+expandedevtstr+"]");
1088 #else
1089 setWindowTitle("VP1 (Virtual Point 1) ["+expandedevtstr+"]");
1090 #endif // BUILDVP1LIGHT
1091
1092 groupBox_event->setTitle("Event [loaded]");
1093 QString eventDetails =
1094 "Run: " + QString::number(m_runnumber) +
1095 "\nEvent: " + QString::number(evNumber);
1096 if (time > 0) {
1097 eventDetails +=
1098 "\nTime UTC: " + eventTimeUTC(time) +
1099 "\nTime Europe/Zurich (CERN): " + eventTimeCERN(time);
1100 }
1101 label_run_event->setText(eventDetails);
1102
1103 addToMessageBox("New event: "+expandedevtstr,"color:#ff0000");
1104
1105 }
1107}
1108
1109//_________________________________________________________________________________
1110void VP1MainWindow::addToMessageBox( const QString& m, const QString& extrastyleopts,
1111 const QString& title, const QString& titleextrastyleopts )
1112{
1113
1114 if (title.isEmpty())
1115 std::cout<<VP1Msg::prefix_msg()<<": "<<m.toStdString()<<std::endl;
1116 else
1117 std::cout<<VP1Msg::prefix_msg()<<": "<<title.toStdString() << ": " <<m.toStdString()<<std::endl;
1118
1119
1120 QString titlepart = ( title.isEmpty() ? "" : ( titleextrastyleopts.isEmpty() ? title
1121 : "<span style=\"font-style:italic;"+titleextrastyleopts+";\">["+title+"]</span> "));
1122
1123 textBrowser_channelmessages->append(titlepart
1124 + ( extrastyleopts.isEmpty() ? m
1125 : "<span style=\"font-style:italic;"+extrastyleopts+";\">"+m+"</span>"));
1126 textBrowser_channelmessages->verticalScrollBar()->setSliderPosition(textBrowser_channelmessages->verticalScrollBar()->maximum());
1127}
1128
1129//_________________________________________________________________________________
1131{
1132 IVP1System*sys = static_cast<IVP1System*>(sender());
1133 if (!sys) {
1134 addToMessageBox("VP1MainWindow::systemAddToMessageBox Error: Only prints system messages!");
1135 return;
1136 }
1137 if (!sys->channel()) {
1138 addToMessageBox("VP1MainWindow::systemAddToMessageBox Error: System does not know its channel!");
1139 return;
1140 }
1141 addToMessageBox( m, "color:#000000",sys->channel()->unique_name()+"/"+sys->name(),"color:#0000ff" );
1142}
1143
1144//_________________________________________________________________________________
1146{
1147 IVP1ChannelWidget*cw = static_cast<IVP1ChannelWidget*>(sender());
1148 if (!cw) {
1149 addToMessageBox("VP1MainWindow::channelAddToMessageBox Error: Only prints channelwidget messages!");
1150 return;
1151 }
1152 addToMessageBox(m,"color:#000000", cw->unique_name(),"color:#0000ff");
1153}
1154
1155//_________________________________________________________________________________
1157{
1158 addToMessageBox(m);
1159}
1160
1161//_________________________________________________________________________________
1163 if(!m_tabmanager->selectedChannelWidget())
1164 return;
1165
1166 QString out = "Information about channel: "+m_tabmanager->selectedChannelWidget()->name() + "\n\n";
1167 out += "Contact: "+m_tabmanager->selectedChannelWidget()->contact_info()+"\n";
1168 out += "Information: "+m_tabmanager->selectedChannelWidget()->information()+"\n";
1169 out += "Systems:\n\n";
1170 std::set<IVP1System *>::iterator itsys, itsysE = m_tabmanager->selectedChannelWidget()->systems().end();
1171 for (itsys = m_tabmanager->selectedChannelWidget()->systems().begin();itsys!=itsysE;++itsys) {
1172 out += " ==> System "+(*itsys)->name()+"\n";
1173 out += " Contact: "+(*itsys)->contact_info()+"\n";
1174 out += " Information: "+(*itsys)->information()+"\n";
1175 out += "\n";
1176 }
1177
1178 QMessageBox::information(0, "Information about channel: "+m_tabmanager->selectedChannelWidget()->name(),Qt::convertFromPlainText(out),QMessageBox::Ok,QMessageBox::Ok);
1179}
1180
1181//_________________________________________________________________________________
1183{
1184 VP1Msg::messageVerbose("VP1MainWindow::makeAllChannelsEventDisplay()");
1185
1186 QList<QPixmap> list;
1187 QStringList listNames;
1188 QList<unsigned long long> listRunEventNumberTimestamp;
1189
1190 getAllChannelsIntoSnapshots(list, listNames);
1191
1192 listRunEventNumberTimestamp << m_runnumber;
1193 listRunEventNumberTimestamp << m_eventnumber;
1194 listRunEventNumberTimestamp << m_timestamp;
1195
1196 // create a new editor window
1197 m_edEditor = new VP1EventDisplayEditor(this, listRunEventNumberTimestamp);
1198
1199 m_edEditor->addPixmapList(list, listNames);
1200
1201 // pass the lists of all tabs and their names to the editor
1202 m_edEditor->setTabsList( listNames);
1203
1204 m_edEditor->show();
1205
1206}
1207
1208
1209
1210
1211//_________________________________________________________________________________
1212void VP1MainWindow::getAllChannelsIntoSnapshots(QList<QPixmap>& list, QStringList& listNames)
1213{
1214 VP1Msg::messageDebug("VP1MainWindow::getAllChannelsIntoSnapshots()");
1215
1216// int nTabs = m_tabmanager->nTabs();
1217 QList<IVP1ChannelWidget*> allTabs = m_tabmanager->allChannels();
1218
1219 if (allTabs.isEmpty()) {
1220 VP1Msg::message("WARNING - No tabs to save.");
1221 return;
1222 }
1223
1224 int nT = 0;
1225
1226 // loop over all tabs/channels
1227 for(IVP1ChannelWidget* widg : allTabs) {
1228
1229 // increase tab number
1230 ++nT;
1231
1232 // get channel name (e.g. Geometry, 3DCocktail)
1233 QString channelname = m_tabmanager->channelToTab(widg);
1234 channelname.replace(' ','_');
1235 VP1Msg::messageDebug("tab: " + channelname);
1236
1237 // DEBUG MSGS
1238 // get channel info, only for debug
1239 //QString info = widg->information();
1240 //VP1Msg::messageDebug("channel info: " + info);
1241
1242
1243 QPixmap snap = getSingleChannelCustomSnapshot(widg);
1244
1245 list << snap;
1246 listNames << channelname;
1247
1248 }
1249
1250 VP1Msg::messageVerbose(QString::number(nT)+" tabs/channels saved in the QList.");
1251
1252}
1253
1254//_________________________________________________________________________________
1256{
1257 VP1Msg::messageDebug("VP1MainWindow::getSingleChannelCustomSnapshot()");
1258
1259 std::cout << "tab: " << tab << std::endl;
1260
1261 // save the anti-aliasing status, set by the user
1262 bool antialias_original = tab->isAntiAliasing();
1263
1264 // for the final event display images we want the anti-aliasing turned ON,
1265 tab->setAntiAliasing(true);
1266
1267 // get the snapshot
1268 QPixmap snap;
1269 if (width)
1270 snap = tab->getSnapshot(true, width); // 'true' means 'transparent background'
1271 else
1272 snap = tab->getSnapshot(true); // 'true' means 'transparent background'
1273
1274 if (snap.isNull()) {
1275 VP1Msg::message("ERROR! - No snapshot produced!");
1276 return QPixmap();
1277 }
1278
1279 // go back to the original anti-aliasing status, set by the user for the tab
1280 tab->setAntiAliasing(antialias_original);
1281
1282 return snap;
1283}
1284//_________________________________________________________________________________
1285QPixmap VP1MainWindow::getSingleChannelCustomSnapshot(const QString& tabName, int width)
1286{
1287 QList<IVP1ChannelWidget*> allTabs = m_tabmanager->allChannels();
1288
1289 if (allTabs.isEmpty()) {
1290 VP1Msg::message("WARNING - No tabs to get snapshots from.");
1291 }
1292
1293 // loop over all tabs/channels
1294 for(IVP1ChannelWidget* widg : allTabs) {
1295
1296 // get channel name (e.g. Geometry, 3DCocktail)
1297 QString channelname = m_tabmanager->channelToTab(widg);
1298 channelname.replace(' ','_');
1299
1300 if (channelname == tabName) {
1301 VP1Msg::messageDebug("found tab: " + channelname);
1302
1303 if (width)
1305 else
1306 return getSingleChannelCustomSnapshot(widg);
1307
1308 }
1309 }
1310 return QPixmap();
1311}
1312
1313//_________________________________________________________________________________
1315{
1316 VP1Msg::messageDebug("VP1MainWindow::saveAllCurrentChannels()");
1317
1318 int nTabs = m_tabmanager->nTabs();
1319
1320 VP1Msg::messageDebug("# of tabs: " + QString::number(nTabs));
1321
1322 QList<IVP1ChannelWidget*> allTabs = m_tabmanager->allChannels();
1323
1324 if (allTabs.isEmpty()) {
1325 VP1Msg::message("WARNING - No tabs to save.");
1326 return;
1327 }
1328
1329
1330// QString guess;
1331// QString chnlname = m_tabmanager->selectedChannelWidget()->name().toLower();
1332// chnlname.replace(' ','_');
1333
1334 QString base=m_currentsaveimagepath+QDir::separator()+"vp1"
1335 + "_run"+QString::number(m_runnumber)+"_evt"+QString::number(m_eventnumber)
1336 + QString(m_timestamp>0 ? "_"+QDateTime::fromTime_t(m_timestamp).toString(Qt::ISODate).replace(':','-') : "");
1337
1338
1339 // check for existing files
1340 int i(2);
1341 while (QFile::exists(base+".png")) {
1342 base = base+"_"+QString::number(i++);
1343 }
1344
1345 // let the user choose the base filename
1346 QString filename = QFileDialog::getSaveFileName(0, "Select target image file", base,
1347 "Image (*.png *.bmp)",
1348 0,QFileDialog::DontResolveSymlinks);
1349 if(filename.isEmpty()) {
1350 VP1Msg::message("WARNING - No filename selected.");
1351 return;
1352 }
1353
1354 m_currentsaveimagepath = QFileInfo(filename).dir().absolutePath ();
1355
1356
1357 QStringList tab_save_files;
1358
1359 int nT = 0;
1360 for(IVP1ChannelWidget* widg : allTabs) {
1361
1362 // increase tab number
1363 ++nT;
1364
1365 // get channel name (e.g. Geometry, 3DCocktail)
1366 QString channelname = widg->name().toLower();
1367 channelname.replace(' ','_');
1368 VP1Msg::messageDebug("tab: " + channelname);
1369
1370// // get channel info, only for debug
1371// QString info = widg->information();
1372// VP1Msg::messageDebug("channel info: " + info);
1373
1374 QPixmap snap = widg->getSnapshot();
1375 QString tabfilename = filename + "_" + QString::number(nT) + "_" + channelname + ".png";
1376
1377 if (!(tabfilename.endsWith(".png",Qt::CaseInsensitive)||tabfilename.endsWith(".bmp",Qt::CaseInsensitive)))
1378 tabfilename += ".png";
1379
1380
1381 if (!saveSnapshot(this, snap, tabfilename))
1382 return;
1383
1384 tab_save_files << tabfilename;
1385 }
1386
1387 VP1Msg::message("Tabs saved as: " + tab_save_files.join(" - "));
1388
1389
1390 QMessageBox::information(this, tr("Snapshots saved."),
1391 "All tabs have been saved as snapshots in the following files:\n\n"+tab_save_files.join("\n"),
1392 QMessageBox::Ok,
1393 QMessageBox::Ok);
1394
1395
1396// // TODO: test to create a multilayered PSD or TIFF file
1397// // but doesn't work with the ImageMagick version shipped with SLC5...
1398// // So I give it up now...
1399// QProcess *proc = new QProcess();
1400// QString program = "convert";
1401// QStringList arguments;
1402// arguments = tab_save_files;
1403// arguments << " " + m_currentsaveimagepath + QDir::separator() + "out.psd";
1404// VP1Msg::messageDebug("running: " + program + " " + arguments.join(" "));
1405//
1406// // start the process
1407// proc->start(program, arguments );
1408//
1409// if (!proc->waitForStarted())
1410// return;
1411//
1412// if (!proc->waitForFinished())
1413// return;
1414
1415}
1416
1417//_________________________________________________________________________________
1418/*
1419 * save a snaphot of the currently selected tab.
1420 *
1421 * nsnap is an optional parameter: it's an extra label being added
1422 * to the output filename.
1423 */
1425{
1426
1427 VP1Msg::messageDebug("VP1MainWindow::request_saveChannelSnapshot()");
1428
1429 if(!m_tabmanager->selectedChannelWidget()) {
1430 return QString();
1431 }
1432
1433 QString guess;
1434 QString chnlname = m_tabmanager->selectedChannelWidget()->name().toLower();
1435 chnlname.replace(' ','_');
1436
1437 QString base=m_currentsaveimagepath+QDir::separator()+"vp1_"+chnlname
1438 +"_run"+QString::number(m_runnumber)+"_evt"+QString::number(m_eventnumber)
1439 + QString(m_timestamp>0 ? "_"+QDateTime::fromTime_t(m_timestamp).toString(Qt::ISODate).replace(':','-') : "");
1440
1441
1442 // check for existing files
1443 guess=base;
1444 int i(2);
1445 while (QFile::exists(guess+".png")) {
1446 guess=base+"_"+QString::number(i++);
1447 }
1448 guess+=".png";
1449
1450
1451 // adding the extra label xLabel, if provided
1452 if (!xLabel.isEmpty()) {
1453 guess += "_" + xLabel;
1454 }
1455
1456
1457 QString filename = QFileDialog::getSaveFileName(0, "Select target image file", guess,
1458 "Image (*.png *.bmp)",
1459 0,QFileDialog::DontResolveSymlinks);
1460 if(filename.isEmpty())
1461 return QString();
1462
1463 m_currentsaveimagepath = QFileInfo(filename).dir().absolutePath ();
1464
1465 if (!(filename.endsWith(".png",Qt::CaseInsensitive)||filename.endsWith(".bmp",Qt::CaseInsensitive)))
1466 filename += ".png";
1467
1468 VP1Msg::messageVerbose("calling snapshot");
1469 QPixmap pm = m_tabmanager->selectedChannelWidget()->getSnapshot();
1470
1471 if (!saveSnapshot(this, pm, filename))
1472 return QString();
1473
1474 return filename;
1475}
1476
1477//_________________________________________________________________________________
1479 if(!m_tabmanager->selectedChannelWidget())
1480 return;
1481
1482 //The following will paint the widget onto a paper and bring up the print dialog:
1483 QPrinter printer;
1484 QPrintDialog dialog(&printer, this);
1485 if (dialog.exec() == QDialog::Accepted) {
1486 QPixmap pm = m_tabmanager->selectedChannelWidget()->getSnapshot();
1487 if (pm.isNull())
1488 return;
1489 QPainter painter;
1490 painter.begin(&printer);
1491 painter.drawPixmap(0,0,pm);
1492 painter.end();
1493 }
1494}
1495
1496
1497//_________________________________________________________________________________
1499 m_tabmanager->loadConfigurationFromFile(file,availablePluginFiles());
1500}
1501
1502//_________________________________________________________________________________
1504{
1505 VP1Msg::messageDebug("VP1MainWindow::replaceConfigurationFile() : " + file);
1506 m_tabmanager->removeAllTabs();
1507 m_tabmanager->loadConfigurationFromFile(file,availablePluginFiles());
1508}
1509
1510//_________________________________________________________________________________
1512{
1513 QString err;
1514 if (!m_tcpserver.listen(err)) {
1515 qDebug("%s", err.toStdString().c_str());
1516 }
1517}
1518
1519
1520//_________________________________________________________________________________
1522{
1524 if (!m_requestqueue.empty())
1525 QTimer::singleShot(0, this, SLOT(processEnqueuedRequests()));
1526}
1527
1528
1529//_________________________________________________________________________________
1535
1536//_________________________________________________________________________________
1538{
1540 return;
1541 if (m_messages_blockedsenders.contains(request.sender()))
1542 return;
1543 if (m_messages_blockedexactmessages.contains(request))
1544 return;
1546 //Fixme: store TIME of incoming request (to show the user).
1547 if (m_requestqueue.count()<999) {
1548 m_requestqueue.enqueue(request);
1549 m_currentincomingdialog->updatependinginfo();
1550 }
1551 return;
1552 }
1557 connect(md,SIGNAL(finished(int)),this,SLOT(finishedIncomingDialog()));
1558 m_tabmanager->dropOutOfFullScreen();
1559 md->show();
1560}
1561
1562//_________________________________________________________________________________
1564{
1565 if (pushButton_cruise->isChecked()) {
1566 if (radioButton_cruise_event->isChecked()) {
1568 groupBox_cruise->setTitle("Cruise Mode [event]");
1569 } else if (radioButton_cruise_tab->isChecked()) {
1571 groupBox_cruise->setTitle("Cruise Mode [tab]");
1572 } else if (radioButton_cruise_both->isChecked()) {
1574 groupBox_cruise->setTitle("Cruise Mode [event && tab]");
1575 } else { assert(0); }
1576 } else {
1578 groupBox_cruise->setTitle("Cruise Mode [off]");
1579 }
1580}
1581
1582//_________________________________________________________________________________
1584{
1585 m_menu_loadPlugin->clear();
1586
1587 QMap<QString,QString> plugins2fullpath = availablePluginFiles();
1588
1589 if (plugins2fullpath.empty()) {
1590 m_menu_loadPlugin->addAction("No plugins found")->setEnabled(false);
1591 return;
1592 }
1593
1594 QStringList pluglist(plugins2fullpath.keys());
1595 pluglist.sort();
1596
1597 QStringList currentpluginfiles = m_channelmanager->currentPluginFiles();
1598 for(const QString& plug : pluglist) {
1599 QAction * act = m_menu_loadPlugin->addAction(plug);
1600 assert(plugins2fullpath.contains(plug));
1601 QString fullpath = plugins2fullpath[plug];
1602 if (currentpluginfiles.contains(fullpath)) {
1603 act->setEnabled(false);
1604 } else {
1605 act->setData(fullpath);
1606 act->setStatusTip(fullpath);
1607 connect(act,SIGNAL(triggered(bool)),this,SLOT(showMenu_loadPluginItemSelected()));
1608 }
1609 }
1610
1611 m_menu_loadPlugin->addSeparator();
1612 QAction * act_browse = m_menu_loadPlugin->addAction("&Browse...");
1613 act_browse->setStatusTip("Browse filesystem for VP1 plugin files");
1614 connect(act_browse,SIGNAL(triggered(bool)),this,SLOT(request_loadPlugin()));
1615
1616}
1617
1618//_________________________________________________________________________________
1620{
1621 QAction * act = static_cast<QAction*>(sender());
1622 assert(act);
1623 if (!act)
1624 return;
1625 loadPluginFile(act->data().toString());
1626}
1627
1628
1629//_________________________________________________________________________________
1631{
1632 m_menu_loadConfFile->clear();
1633
1634 QMap<QString,QString> conffile2fullpath = availableFiles( ".vp1", "DATAPATH", "", "VP1CONFIGFILEPATH", true );
1635
1636 #ifndef BUILDVP1LIGHT
1637 if (conffile2fullpath.empty()) {
1638 m_menu_loadConfFile->addAction("No .vp1 config files found")->setEnabled(false);
1639 return;
1640 }
1641
1642 QStringList filelist(conffile2fullpath.keys());
1643 filelist.sort();
1644
1645 for(const QString& file : filelist) {
1646 QAction * act = m_menu_loadConfFile->addAction(file);
1647 assert(conffile2fullpath.contains(file));
1648 QString fullpath = conffile2fullpath[file];
1649 act->setData(fullpath);
1650 act->setStatusTip(fullpath);
1651 connect(act,SIGNAL(triggered(bool)),this,SLOT(showMenu_loadConfFileItemSelected()));
1652 }
1653 #endif
1654
1655 m_menu_loadConfFile->addSeparator();
1656 QAction * act_browse = m_menu_loadConfFile->addAction("&Browse...");
1657 act_browse->setStatusTip("Browse filesystem for .vp1 config file");
1658 connect(act_browse,SIGNAL(triggered(bool)),this,SLOT(request_loadConfig()));
1659
1660}
1661
1662
1663//_________________________________________________________________________________
1665{
1666 QAction * act = static_cast<QAction*>(sender());
1667 assert(act);
1668 if (!act)
1669 return;
1670 loadConfigurationFromFile(act->data().toString());
1671}
1672
1673//_________________________________________________________________________________
1675{
1676 QAction * act = static_cast<QAction*>(sender());
1677 assert(act);
1678 if (!act)
1679 return;
1680 assert(QStyleFactory::keys().contains(act->text()));
1681 if (!QStyleFactory::keys().contains(act->text()))
1682 return;
1683 QApplication::setStyle(QStyleFactory::create(act->text()));
1684 QSettings s(m_settingsfile,QSettings::IniFormat);
1685 s.setValue("style/defaultstyle",act->text());
1686
1687}
1688
1689//_________________________________________________________________________________
1691{
1692 QAction * act = static_cast<QAction*>(sender());
1693 assert(act);
1694 if (!act)
1695 return;
1696 bool ok;
1697 int goal = act->data().toInt(&ok);
1698 assert(ok);
1699 if (!ok)
1700 return;
1701 changeFontSize(goal);
1702}
1703
1704//_________________________________________________________________________________
1706{
1707 QFont newfont = m_defaultfont;
1708 QSettings s(m_settingsfile,QSettings::IniFormat);
1709 if (m_defaultfont_pointsize<0.0) {
1710 //pixels
1711 assert(m_defaultfont_pixelsize+goal>0);
1712 if (m_defaultfont_pixelsize+goal<=0)
1713 return;
1714 if (m_defaultfont_pixelsize+goal>200)
1715 return;
1716 newfont.setPixelSize(m_defaultfont_pixelsize+goal);
1717 s.setValue("font/pixelsize_diff",goal);
1718 } else {
1719 //pointsize
1720 double fact = (goal+100.0)/100.0;
1721 if (fact<0.01||fact>50)
1722 return;
1723 double newpointsize=m_defaultfont_pointsize*fact;
1724 if (newpointsize<0)
1725 return;
1726 newfont.setPointSizeF(newpointsize);
1727 s.setValue("font/pointsize_relativepercent",goal);
1728 }
1729 QApplication::setFont(newfont);
1730}
1731
1732
1733//_________________________________________________________________________________
1735{
1736 QWidget * targetpage = tabWidget_central->count() ? page_tabwidget : page_instructions;
1737 if (stackedWidget_central->currentWidget() != targetpage)
1738 stackedWidget_central->setCurrentWidget(targetpage);
1739}
1740
1741//_________________________________________________________________________________
1743{
1744 VP1Msg::messageVerbose("VP1MainWindow::quickSetupTriggered()");
1745
1746 QSettings settings("ATLAS", "VP1Light");
1747
1748 QString plugfile, channelname, tabname;
1749
1750 if (sender()==pushButton_quicksetup_geometrystudies||sender()==action_quicklaunch_Geometry_studies) {
1751
1752 //Open geometry database selection dialog for VP1Light
1753#ifdef BUILDVP1LIGHT
1754 if(settings.value("db/dbByEnv").toString().isEmpty()){
1755 VP1GeoDBSelection dbSelection;
1756 dbSelection.exec();
1757 if(!dbSelection.result())
1758 return;
1759 }
1760#endif // BUILDVP1LIGHT
1761
1762 plugfile="libVP1GeometryPlugin.so";
1763 channelname="Geometry";
1764 tabname = "Geometry";
1765 } else if (sender()==pushButton_quicksetup_trackingstudies||sender()==action_quicklaunch_Tracking_studies) {
1766 plugfile="libVP1TrackPlugin.so";
1767 channelname="Tracking";
1768 tabname = "Tracking";
1769 } else if (sender()==pushButton_quicksetup_calostudies||sender()==action_quicklaunch_Calo_studies) {
1770 plugfile="libVP1CaloPlugin.so";
1771 channelname="Calo Cells";
1772 tabname = "Calorimeter";
1773 } else if (sender()==action_quicklaunch_Storegate_browser) {
1774 plugfile="libVP1BanksPlugin.so";
1775 channelname="Banks";
1776 tabname = "StoreGate";
1777 } else if (sender()==pushButton_quicksetup_3dcocktail||sender()==action_quicklaunch_3dcocktail) {
1778#ifndef BUILDVP1LIGHT
1779 plugfile="libVP13DCocktailPlugin.so";
1780 channelname="3DCocktail";
1781 tabname = "3D Cocktail";
1782#else
1783 //Open Geometry DB and AOD file selection dialog for VP1Light
1784 if(settings.value("aod/aodByEnv").toString().isEmpty()){
1785 VP1AODSelection aodSelection;
1786 aodSelection.exec();
1787 if(!aodSelection.result())
1788 return;
1789 }
1790 if(settings.value("db/dbByEnv").toString().isEmpty()){
1791 VP1GeoDBSelection dbSelection;
1792 dbSelection.exec();
1793 if(!dbSelection.result())
1794 return;
1795 }
1796 m_scheduler->loadEvent();
1797
1798 pushButton_eventselect->setEnabled(true);
1799 plugfile="libVP1LightPlugin.so";
1800 channelname="VP1Light";
1801 tabname = "Geometry/AOD";
1802#endif // BUILDVP1LIGHT
1803 } else if (sender()==action_quicklaunch_trackcalo_commis) {
1804 plugfile="libVP13DCocktailPlugin.so";
1805 channelname="TrackCalo";
1806 tabname = "Track/Calo";
1807 } else if (sender()==pushButton_quicksetup_analysisstudies||sender()==action_quicklaunch_analysisstudies) {
1808
1809 //Open AOD file selection dialog for VP1Light
1810#ifdef BUILDVP1LIGHT
1811 if(settings.value("aod/aodByEnv").toString().isEmpty()){
1812 VP1AODSelection aodSelection;
1813 aodSelection.exec();
1814 if(!aodSelection.result())
1815 return;
1816 }
1817 m_scheduler->loadEvent();
1818 pushButton_eventselect->setEnabled(true);
1819#endif // BUILDVP1LIGHT
1820
1821 plugfile="libVP1AODPlugin.so";
1822 channelname="AOD";
1823 tabname = "Analysis";
1824 } else {
1825 addToMessageBox("quickSetupTriggered() Error: Unknown sender");
1826 return;
1827 }
1828
1829#ifdef __APPLE__
1830 if (plugfile.endsWith(".so"))
1831 plugfile = plugfile.left(plugfile.count()-3)+".dylib";
1832#endif
1833
1834
1835 //Check that the plugin is available:
1836 QMap<QString,QString> plugins2fullpath = availablePluginFiles();
1837 if(VP1Msg::debug()){
1838 qDebug() << "plugins2fullpath: " << plugins2fullpath;
1839 }
1840
1841 if (!plugins2fullpath.contains(plugfile)) {
1842 QMessageBox::critical(0, "Error - could not locate plugin file: "+plugfile,
1843 "could not locate plugin file: "
1844 +plugfile,QMessageBox::Ok,QMessageBox::Ok);
1845 return;
1846 }
1847 QString plugfile_fullpath = plugins2fullpath[plugfile];
1848
1849
1850 //Load plugin
1851 if (!m_channelmanager->currentPluginFiles().contains(plugfile_fullpath)) {
1852 QString err = m_channelmanager->loadPluginFile(plugfile_fullpath);
1853 if (!err.isEmpty()||!m_channelmanager->currentPluginFiles().contains(plugfile_fullpath)) {
1854 QMessageBox::critical(0, "Error - could not load plugin file: "+plugfile_fullpath,//Fixme: Error message here is hardcoded to be the same as in loadPluginFile method!!
1855 "Could not load plugin file: "
1856 +plugfile_fullpath+"\n\nReason: "+err,QMessageBox::Ok,QMessageBox::Ok);
1857 return;
1858 }
1859 }
1860
1861
1862 //Check that plugin contains necessary channel:
1863 if (!m_channelmanager->channelsInPluginFile(plugfile_fullpath).contains(channelname)) {
1864 QMessageBox::critical(0, "Error - did not find necessary channel: "+channelname,
1865 "Could not find channel: "+channelname+" in loaded plugin "+plugfile_fullpath,
1866 QMessageBox::Ok,QMessageBox::Ok);
1867 return;
1868 }
1869
1870 bool save = updatesEnabled();
1871 setUpdatesEnabled(false);
1872
1873
1874 //Add tab:
1875 QString newtabname = m_tabmanager->suggestNewTabName(tabname);
1876 m_tabmanager->addNewTab(newtabname);
1877 if (!m_tabmanager->hasTab(newtabname)) {
1878 QMessageBox::critical(0, "Error - could not create tab: "+newtabname,
1879 "Could not create tab: "+newtabname,
1880 QMessageBox::Ok,QMessageBox::Ok);
1881 setUpdatesEnabled(save);
1882 return;
1883 }
1884
1885
1886 //Finally, add channel:
1887
1888 if (!m_tabmanager->addChannelToTab( channelname, newtabname )) {
1889 QMessageBox::critical(0, "Error - problems launching channel: "+channelname,
1890 "Problems launching channel: "+channelname,
1891 QMessageBox::Ok,QMessageBox::Ok);
1892 setUpdatesEnabled(save);
1893 return;
1894 }
1895
1896
1897 m_tabmanager->showTab(newtabname);
1898
1899
1900 setUpdatesEnabled(save);
1901}
1902
1903//_________________________________________________________________________________
1905{
1906 pushButton_nextevent->setEnabled(okToProceedToNextEvent());
1907 #if defined BUILDVP1LIGHT
1908 pushButton_previousevent->setEnabled(okToProceedToNextEvent());
1909 #endif
1910}
1911
1912//_________________________________________________________________________________
1914{
1915 if(!m_mutex->tryLock()) return;
1916
1917 QFont f;
1918 QFont fb;
1919 fb.setBold(true);
1920
1921 for (QAction * act : m_inputdiractions) {
1922 VP1DirStatusData& dirstatus = m_inputdirstatuses[act];
1923 QString inputdir(act->data().toString());
1924 QString dirname = QDir(inputdir).dirName();
1925 act->setEnabled(dirstatus.enabled);
1926 act->setFont(dirstatus.bold?fb:f);
1927 act->setText(dirname+" ["+dirstatus.dirStatus+"]");
1928 }
1929
1930 m_mutex->unlock();
1931}
1932
1933//_________________________________________________________________________________
1935{
1936 QAction * act = dynamic_cast<QAction*>(sender());
1937 if (!act)
1938 return;
1939 VP1AvailEvtsLocalDir* availLocal = dynamic_cast<VP1AvailEvtsLocalDir*>(m_availEvents);
1940 if (!availLocal)
1941 return;
1942 QString inputdir(act->data().toString());
1943 QFileInfo fi(inputdir);
1944 if (fi.exists()&&fi.isDir()) {
1945 availLocal->setSourceDir(inputdir);
1946 std::cout<<VP1Msg::prefix_msg()<<": "
1947 <<"VP1Message: inputdirectory changed to "
1948 <<availLocal->currentSourceDir().toStdString()<<std::endl;
1949 m_currentStream = QDir(availLocal->currentSourceDir()).dirName();
1950 }
1951
1952
1953}
1954
1955//________________________________________________________________________________
1957{
1958 QStringList returnval(m_userRequestedFiles);
1959 m_userRequestedFiles.clear();
1960 return returnval;
1961}
1962
1963//_________________________________________________________________________________
1965{
1966 QString newEventFile = QFileDialog::getOpenFileName(NULL
1967 ,tr("Open Event File")
1969 ,tr("All files (*.*)"));
1970 if(newEventFile.isEmpty()) return;
1971 if(VP1FileUtilities::fileExistsAndReadable(newEventFile.toStdString())) {
1972 m_userRequestedFiles.append(newEventFile);
1973 addToMessageBox(newEventFile + " will be appended to the list of input files");
1974 }
1975 else
1976 QMessageBox::critical(0, newEventFile + " either does not exist or is not readable",
1977 newEventFile + " either does not exist or is not readable",
1978 QMessageBox::Ok,QMessageBox::Ok);
1979}
1980
1981//_________________________________________________________________________________
1982#ifdef BUILDVP1LIGHT
1983void VP1MainWindow::request_expertSettings(){
1985 es.exec();
1986}
1987
1988void VP1MainWindow::chooseEvent(){
1989 //Open event selection dialog for VP1Light
1990 VP1SelectEvent selectEvent(m_scheduler->getTotEvtNr(), m_scheduler->getEvtNr());
1991 selectEvent.exec();
1992 int newEvtNr = selectEvent.result()-1;
1993
1994 if( (newEvtNr >= 0) && (newEvtNr <= m_scheduler->getTotEvtNr()-1) ){
1995 m_scheduler->setEvtNr(newEvtNr);
1996 nextEvent();
1997 qApp->quit();
1998 }
1999}
2000#endif // BUILDVP1LIGHT
std::shared_ptr< HepMC3::Writer > writer
std::pair< std::vector< unsigned int >, bool > res
std::string toString(const float number)
Pipe a number to a string.
const char * pathvar
const double width
virtual QPixmap getSnapshot(bool transp=false, int width=0, bool batch=false)
virtual bool setAntiAliasing(bool aa)
const QString unique_name() const
virtual bool isAntiAliasing()
const QString & currentSourceDir() const
void setSourceDir(const QString &)
const QStringList & availableSourceDirectories() const
static QString highlightStyle()
const QString & sender() const
static bool fileExistsAndReadable(const std::string &)
void finishedIncomingDialog()
void request_loadPlugin()
void helperAddToMessageBox(const QString &)
void setRunEvtNumber(const int &runnumber, const unsigned long long &eventnumber, const unsigned &triggerType=0, const unsigned &time=0, const bool &printmessage=true)
void changeFontSize(int)
QQueue< VP1ExternalRequest > m_requestqueue
void updateCentralStackWidget()
void help_openUserSupport()
int m_defaultfont_pixelsize
QMenu * m_menu_changeFontSize
VP1EventDisplayEditor * m_edEditor
VP1AvailEvents * m_availEvents
void systemAddToMessageBox(const QString &)
void receivedExternalRequest(VP1ExternalRequest)
QLabel * m_statusbarlabel
void saveAllCurrentChannels()
QString m_currentconfigfile
double m_defaultfont_pointsize
void showMenu_loadConfFileItemSelected()
VP1ChannelManager * m_channelmanager
VP1TabManager * m_tabmanager
QString m_currentsaveimagepath
QString m_currentloadpluginpath
QMap< QString, QString > availablePluginFiles() const
VP1MainWindow(VP1ExecutionScheduler *, VP1AvailEvents *availEvents, QWidget *parent=0)
VP1IncomingMessageDialog * m_currentincomingdialog
QStringList userRequestedFiles()
void request_saveasConfig()
void addChannelIconsToComboBox(QComboBox *cb, const bool &isbasenames)
QAction * m_action_openUsersSupport
QMenu * m_menu_loadPlugin
void request_cruisemodechange()
QWidget * m_dummyemptycontroller
const QString m_settingsfile
QAction * m_actionSave_current_tabs
QList< VP1ExternalRequest > m_messages_blockedexactmessages
void addToMessageBox(const QString &, const QString &extrastyleopts="", const QString &title="", const QString &titleextrastyleopts="")
void replaceConfigurationFile(const QString &file)
QProgressBar * progressbar
QAction * m_action_openUsersGuide
void processEnqueuedRequests()
bool mustQuit() const
QStringList m_userRequestedFiles
void changeStyleActionTriggered()
QMenu * m_menu_loadConfFile
void unloadPlugin_continue()
QString m_currentStream
unsigned long long m_eventnumber
void help_openUserGuide()
QMap< QString, QString > availableFiles(const QString &extension, const QString &pathvar, const QString &instareasubdir, const QString &extradirenvvar, bool currentdir=false) const
bool okToProceedToNextEvent() const
unsigned m_timestamp
QAction * m_action_openVP1Site
void request_loadConfig()
QAction * m_actionAdd_empty_tab
void getAllChannelsIntoSnapshots(QList< QPixmap > &list, QStringList &listNames)
QString request_saveChannelSnapshot(const QString &xLabel="")
void inputDirectoryActionTriggered()
void loadConfigurationFromFile(const QString &file)
VP1PluginDialog * m_plugindialog
void closeEvent(QCloseEvent *event)
void channelAddToMessageBox(const QString &)
VP1DirStatuses m_inputdirstatuses
void request_printChannel()
VP1TcpServer m_tcpserver
QList< QAction * > m_inputdiractions
QAction * m_actionEnableExpertSettings
QStringList m_currentunloadpluginfiles
void loadPluginFile(const QString &filename)
VP1StreamMenuUpdater * m_streamMenuUpdater
void request_channelInformation()
VP1ExecutionScheduler * m_scheduler
void pluginDialogClosed()
void makeAllChannelsEventDisplay()
QAction * m_action_addEventFile
void changeFontSizeActionTriggered()
void selectedChannelChanged(IVP1ChannelWidget *)
void request_addEmptyTab()
void tabListChanged(const QStringList &)
QAction * m_action_openAbout
void launch3DstereoEditor()
void updateInputDirectoriesStatus()
void request_saveConfig()
void showMenu_loadConfFile()
void help_openVP1WebSite()
QList< QString > m_messages_blockedsenders
void showMenu_loadPluginItemSelected()
QMenu * m_menu_changeStyle
QPixmap getSingleChannelCustomSnapshot(IVP1ChannelWidget *tab, int width=0)
static bool debug()
Definition VP1Msg.h:32
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
static const char * prefix_msg()
Definition VP1Msg.h:56
static bool environmentVariableIsOn(const QString &name)
static bool expertSettingIsSet(const QString &type, const QString &name)
static QString expertSettingValue(const QString &type, const QString &name)
static bool environmentVariableIsSet(const QString &name)
static QString defaultFileSelectDirectory()
int r
Definition globals.cxx:22
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:312
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
std::string base
Definition hcg.cxx:83
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179
output
Definition merge.py:16
TFile * file
std::string dirname(std::string name)
Definition utils.cxx:200