GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4MainWindow.cpp
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4MainWindow.h"
15 
16 #include <QtCore/QString>
17 #include <QtCore/QDateTime>
18 #include <QtCore/QTimer>
19 #include <QtCore/QProcess>
20 #include <QtCore/QHash>
21 #include <QtCore/QDir>
22 
23 #include <QApplication>
24 #include <QMenuBar>
25 #include <QDockWidget>
26 #include <QToolBar>
27 #include <QAction>
28 #include <QActionGroup>
29 #include <QStatusBar>
30 #include <QStyleFactory>
31 #include <QColor>
32 #include <QMessageBox>
33 #include <QColorDialog>
34 #include <QFileDialog>
35 #include <QFontDialog>
36 #include <QInputDialog>
37 #include <QMdiSubWindow>
38 #include <QMimeData>
39 #include <QDesktopServices>
40 #include <QUrl>
41 
43 #include "TSystem.h"
44 #include "TROOT.h"
45 #include "TMath.h"
46 #include "TStyle.h"
47 #include "TH1.h"
48 #include "TClass.h"
49 #include "TCanvas.h"
50 
52 #include "TGo4Version.h"
53 #include "TGo4Log.h"
54 #include "TGo4LockGuard.h"
55 #include "TGo4Parameter.h"
56 #include "TGo4Condition.h"
57 #include "TGo4MdiArea.h"
58 #include "TGo4Fitter.h"
59 #include "TGo4FitPanel.h"
60 #include "TGo4DynamicEntry.h"
61 #include "TGo4AnalysisStatus.h"
62 
63 #include "TGo4ObjectManager.h"
64 #include "TGo4ObjectProxy.h"
65 #include "TGo4BrowserProxy.h"
66 #include "TGo4DabcProxy.h"
67 #include "TGo4AnalysisProxy.h"
68 #include "TGo4WidgetProxy.h"
69 
71 #include "TGo4QSettings.h"
72 #include "TGo4TreeViewer.h"
73 #include "TGo4Browser.h"
74 #include "TGo4BrowserOptions.h"
75 #include "TGo4Style.h"
76 #include "TGo4ViewPanel.h"
78 #include "TGo4AnalysisWindow.h"
79 #include "TGo4StartClient.h"
80 #include "TGo4HisDrawOptions.h"
82 #include "TGo4ScaleOptions.h"
83 #include "TGo4DividePad.h"
84 #include "TGo4CreateNewHistogram.h"
85 #include "TGo4CreateNewCondition.h"
86 #include "TGo4CreateNewDynEntry.h"
87 #include "TGo4ConditionInfo.h"
88 #include "TGo4HistogramInfo.h"
89 #include "TGo4EventInfo.h"
90 #include "TGo4LoadedLibraries.h"
91 #include "TGo4EditDynEntry.h"
92 #include "TGo4ParaEdit.h"
94 #include "TGo4ConditionEditor.h"
95 #include "TGo4LogSettings.h"
96 #include "TGo4LogInfo.h"
97 #include "TGo4OpenRemoteDialog.h"
98 #include "TGo4ConnectServer.h"
99 #include "TGo4MBSViewer.h"
100 #include "TGo4SetScaleValues.h"
101 #include "TGo4CommandLine.h"
102 #include "TGo4MarkerSettings.h"
103 #include "TGo4OptStatsSettings.h"
104 #include "TGo4HttpProxy.h"
105 
106 #include "TGo4UserCommands.h"
107 
108 #include "TGo4Script.h"
109 
110 #include "TGo4HServerConnection.h"
111 
112 using namespace Qt;
113 
114 TGo4MainWindow::TGo4MainWindow(QApplication* app) :
115  QMainWindow(),
116  fApp(app)
117 {
118  // setDockWindowsMovable(true);
119  // statusBar();
120  resize( 1152, 864 );
121 
122  setWindowIcon(QIcon(":/icons/go4logo2_big.png"));
123  // setRightJustification( true );
124  // setUsesTextLabel(true);
125  // setOpaqueMoving(false);
126 
127  fxOM = new TGo4ObjectManager("GUI_OM","Gui object manager");
128  fOMDataPath = "data";
129  fOMBrowserPath = "gui";
130  fOMEditorsPath = "editors";
131 
132  fNewWidgetX = 0;
133  fNewWidgetY = 0;
134 
135  fKillCommand = "";
136  fLastPassword = "";
137  fLastFileDir = QDir::currentPath();
138 
139  fCloseCounter = 0;
140  fConnectingCounter = 0;
141  fConnectingHttp = "";
142 
143  fbGetAnalysisConfig = true;
144 
145  fbPanelTimerActive = false;
146 
147  fbFullScreen = false;
148 
149 
150  // create mount point for all data sources
151  fxOM->MakeFolder(fOMDataPath.toLatin1().constData());
152 
153  // create entry for browser
154  TGo4BrowserProxy *br = new TGo4BrowserProxy(fOMDataPath.toLatin1().constData(), fOMEditorsPath.toLatin1().constData(), kFALSE);
155  fxOM->AddProxy("", br, fOMBrowserPath.toLatin1().constData(), "Place for gui slots");
156  br->CreateMemoryFolder();
157 
158  TH1I* h1 = new TH1I("histo1","histo title", 100, -10., 10.);
159  h1->FillRandom("gaus",10000);
160  h1->SetDirectory(nullptr);
161  br->SaveToMemory("", h1, kTRUE);
162 
163 /* TH2I* h2 = new TH2I("histo2","histo 2 title", 100, -10., 10., 100, -10., 10.);
164  h2->FillRandom("gaus",100000);
165  h2->SetDrawOption("hist");
166  h2->SetDirectory(nullptr);
167  br->SaveToMemory("", h2, kTRUE);
168 */
169  // br->OpenFile("asf.root");
170 
171  new TGo4Script(this);
172 
173  gStyle->SetPalette(1);
174  gStyle->SetCanvasColor(10); // no effect, can be set in settings
175  gStyle->SetPadColor(10); // no effect
176  gStyle->SetFrameFillColor(10); // works if not 0
177  gStyle->SetStatColor(0); // works
178 
179  //gStyle->SetOptStat(11111111);
180  gStyle->SetOptStat(go4sett->getOptStat());
181 
182  fxMdiArea = new TGo4MdiArea(this);
183  fxMdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
184  fxMdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
185  setCentralWidget(fxMdiArea);
186  fxMdiArea->setFocus();
187 
188  menuBar()->setNativeMenuBar(kFALSE);
189 
190  AddFileMenu();
191  AddFileToolBar();
192 
193  AddToolsMenu();
194  AddToolsBar();
195 
196  AddAnalysisMenu();
197  AddAnalysisBar();
198 
200 
201  QDockWidget* BrowserDockWin = new QDockWidget("Browser", this);
202  BrowserDockWin->setObjectName("BrowserDock");
203  TGo4Browser* browser = new TGo4Browser(BrowserDockWin,"Browser");
204  browser->setWindowFlags(Qt::Widget);
205  ConnectGo4Widget(browser);
206  browser->StartWorking();
207  BrowserDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
208  BrowserDockWin->setWidget(browser);
209  BrowserDockWin->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
210  addDockWidget(Qt::LeftDockWidgetArea, BrowserDockWin);
211 
212  QAction* BrowserDockAction = BrowserDockWin->toggleViewAction();
213  BrowserDockAction->setShortcut(QKeySequence("F6"));
214 
215  QDockWidget* LogDockWin = new QDockWidget("Log window", this);
216  LogDockWin->setObjectName("LogInfoDock");
217  TGo4LogInfo* loginfo = new TGo4LogInfo(this, "LogInfo");
218  ConnectGo4Widget(loginfo);
219  LogDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
220  LogDockWin->setWidget(loginfo);
221  LogDockWin->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
222  addDockWidget(Qt::BottomDockWidgetArea, LogDockWin);
223 
224  QAction* LogDockWinAction=LogDockWin->toggleViewAction();
225  LogDockWinAction->setShortcut(QKeySequence("F7"));
226 
227  QDockWidget* MBSDockWin = new QDockWidget("MBS monitor", this);
228  MBSDockWin->setObjectName("MbsViewerDock");
229  TGo4MBSViewer* mbs = new TGo4MBSViewer(MBSDockWin, "MBSViewer");
230  mbs->setWindowFlags(Qt::Widget);
231  ConnectGo4Widget(mbs);
232  MBSDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
233  MBSDockWin->setWidget(mbs);
234  MBSDockWin->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
235  addDockWidget(Qt::BottomDockWidgetArea, MBSDockWin);
236 
237  QAction* MBSDockAction=MBSDockWin->toggleViewAction();
238  MBSDockAction->setShortcut(QKeySequence("F8"));
239 
240  QToolBar* DividePanelBar = addToolBar("Canvas Tools");
241  DividePanelBar->setObjectName("DividePadDock");
242  TGo4DividePad* dividepanel = new TGo4DividePad(this, "DividePad");
243  DividePanelBar->addWidget(dividepanel);
244 
245  QToolBar* stylebar = addToolBar("Color Tools");
246  stylebar->setObjectName("Go4StyleDock");
247  fxStyle = new TGo4Style(this, "Go4Style");
248  stylebar->addWidget(fxStyle);
249 
250  QToolBar* BrowserOptionsPanel = addToolBar("Browser Options");
251  BrowserOptionsPanel->setObjectName("BrowserOptionsDock");
252  TGo4BrowserOptions* bropt = new TGo4BrowserOptions(this, "BrowserOptions");
253  ConnectGo4Widget(bropt);
254  BrowserOptionsPanel->addWidget(bropt);
255  bropt->StartWorking();
256 
257  QToolBar* DrawOptionPanel = addToolBar("Draw Options");
258  DrawOptionPanel->setObjectName("DrawOptionsDock");
259  TGo4HisDrawOptions* drawopt = new TGo4HisDrawOptions(this, "DrawOptions");
260  DrawOptionPanel->addWidget(drawopt);
261  DrawOptionPanel->adjustSize();
262 
263  QToolBar* DrawOptionShortPanel = addToolBar("Hist Draw Options");
264  DrawOptionShortPanel->setObjectName("HisDrawOptionsDock");
265  TGo4HisDrawOptionsShort* drawopts = new TGo4HisDrawOptionsShort(this, "HisDrawOptions");
266  DrawOptionShortPanel->addWidget(drawopts);
267  DrawOptionShortPanel->adjustSize();
268 
269  QToolBar* ScaleOptionBar = addToolBar("Zoom Tools");
270  ScaleOptionBar->setObjectName("ScaleOptionsDock");
271  TGo4ScaleOptions* scopt = new TGo4ScaleOptions(this, "ScaleOptions");
272  ConnectGo4Widget(scopt);
273  ScaleOptionBar->addWidget(scopt);
274  ScaleOptionBar->adjustSize();
275 
276  QToolBar* commandlinebar = addToolBar("Go4 Command Line");
277  commandlinebar->setObjectName("CommandLineDock");
278  TGo4CommandLine* cli = new TGo4CommandLine(this, "CommandLine");
279  ConnectGo4Widget(cli);
280  commandlinebar->addWidget(cli);
281 
282  QToolBar* tviewerdock = addToolBar("Tree viewer");
283  tviewerdock->setObjectName("TreeViewerDock");
284  TGo4TreeViewer* tviewer = new TGo4TreeViewer(this, "TreeViewer");
285  ConnectGo4Widget(tviewer);
286  tviewerdock->addWidget(tviewer);
287 
288  AddAnalysisMacrosBar(); // new 2016
289 
290 
291  // test: can we implement shortcuts to enable specific dock windows JAM?
292 // QMenu* dockMenu = menuBar()->addMenu("&Docks");
293 // dockMenu->addAction(BrowserDockAction);
294 // dockMenu->addAction(LogDockWinAction);
295 // dockMenu->addAction(MBSDockAction);
296 // do not need this, since shortcuts also work in default dock menu :)
297 
298  // make it here while only here exists all toolbars and dock widgets
299  AddSettingMenu();
300 
301  windowsMenu = menuBar()->addMenu("&Windows");
302  QObject::connect(windowsMenu, &QMenu::aboutToShow, this, &TGo4MainWindow::windowsMenuAboutToShow);
303  // need to create menu item with F11
305 
306  menuBar()->addSeparator();
307 
308  QMenu* helpMenu = menuBar()->addMenu("&Help");
309  helpMenu->addAction("&Introduction (user manual)", this, &TGo4MainWindow::IntroHelpSlot)->setShortcut(Qt::Key_F1);
310  helpMenu->addAction("&Reference manual", this, &TGo4MainWindow::RefHelpSlot);
311  helpMenu->addAction("&Fit Tutorial", this, &TGo4MainWindow::FitHelpSlot);
312  helpMenu->addSeparator();
313  helpMenu->addAction("About &Qt", this, &TGo4MainWindow::aboutQt)->setShortcut(Qt::Key_F2);
314  helpMenu->addAction("About R&OOT", this, &TGo4MainWindow::aboutROOT)->setShortcut(Qt::Key_F3);
316  helpMenu->addAction("About &DABC", this, &TGo4MainWindow::aboutDABC);
317  helpMenu->addAction("About &Go4", this, &TGo4MainWindow::about)->setShortcut(Qt::Key_F4);
318 
319  const char *libs = gSystem->Getenv("GO4USERLIBRARY");
320 
321  if (libs) {
322 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
323  QStringList LibList = QString(libs).split(":", QString::SkipEmptyParts);
324 #else
325  QStringList LibList = QString(libs).split(":", Qt::SkipEmptyParts);
326 #endif
327 
328  for (auto it = LibList.begin(); it != LibList.end(); ++it)
329  gSystem->Load((*it).toLatin1().constData());
330  }
331 
333 
334  QApplication::setStyle(go4sett->getAppStyle());
335 
336  faSuperimpose->setChecked(go4sett->getPadSuperimpose());
337  faCrosshair->setChecked(go4sett->getPadCrosshair());
338  faEventstatus->setChecked(go4sett->getPadEventStatus());
339 
341  go4sett->getAppFont();
342 
343  // start mbs monitoring only after browser etc. is fully there:
344  if(go4sett->getMbsMonitorMonitorActive()) mbs->TimerStart();
345 
346  std::cout <<"Using Qt settings at "<< go4sett->GetSettLoaction().toLatin1().constData() << std::endl;
347 
348  statusBar()->showMessage("Ready");
349  statusBar()->setSizeGripEnabled(true);
350 
351  QString sfmt = go4sett->getGStyleStatFormat();
352  if (!sfmt.isEmpty()) gStyle->SetStatFormat(sfmt.toLatin1().constData());
353 }
354 
356 {
358 
359  delete fxOM;
360 }
361 
363 {
364  return fLastPassword.toLatin1().constData();
365 }
366 
367 void TGo4MainWindow::ShowAboudDialog(const QString &title, const QString &text, const QString &icon)
368 {
369  QMessageBox AboutDialog(QMessageBox::NoIcon, title, text, QMessageBox::Ok, this);
370  AboutDialog.setIconPixmap(QPixmap(icon));
371  AboutDialog.setTextFormat(Qt::RichText);
372  AboutDialog.exec();
373 }
374 
376 {
377  QString GO4STR("Go4 ");
378  GO4STR.append ( __GO4RELEASE__);
379  QString GO4STR1 = GO4STR;
380  GO4STR1.append("<br>");
381  GO4STR1.append("The Go4 (GSI Object Oriented On-line Off-line system) is based on ROOT<br> with the specific requirements of the low and medium energy nuclear and atomic<br> physics experiments implemented as extensions.<br> See <a href='http://go4.gsi.de'>http://go4.gsi.de</a> for more information");
382 
383  ShowAboudDialog(GO4STR, GO4STR1, ":/icons/go4logo2_big.png");
384 }
385 
387 {
388  QMessageBox::aboutQt(this, "Qt");
389 }
390 
392 {
393  QString mestring("This Go4 uses ROOT ");
394  mestring.append(gROOT->GetVersion());
395  mestring.append("<br> ROOT is an object-oriented framework <br>for large scale scientific <br>data analysis and data mining.<br> It has been developed at CERN<br> See <a href='http://root.cern.ch'>http://root.cern.ch</a> for more information");
396  ShowAboudDialog("ROOT", mestring, ":/icons/root.png");
397 }
398 
400 {
401  QString mestring("This Go4 uses DABC ");
403  mestring.append(TGo4DabcProxy::GetDabcVersion());
404  else
405  mestring.append("<undef>");
406  mestring.append("<br>DABC (Data Acquisition Backbone Core) is <br> framework to build multi-threaded multi-node DAQ applications.<br> It is developed in GSI.<br> See <a href='http://dabc.gsi.de'>http://dabc.gsi.de</a> for more information");
407  ShowAboudDialog("DABC", mestring, ":/icons/dabc.png");
408 }
409 
411 {
412  QMenu* settMenu = menuBar()->addMenu("&Settings");
413 
414  QMenu* sub = createPopupMenu();
415  sub->setTitle("Sh&ow/hide");
416  settMenu->addMenu(sub);
417 
418  settMenu->addAction("&Font...", this, &TGo4MainWindow::ChangeFontSlot);
419 
420  QMenu *styleMenu = settMenu->addMenu("St&yle");
421 
422  QMenu* prefMenu = settMenu->addMenu("&Preferences");
423 
424  QObject::connect(QGo4Widget::CreateChkAction(prefMenu, "Fetch when drawing", go4sett->getFetchDataWhenDraw()),
425  &QAction::toggled, this, &TGo4MainWindow::ChangeFetchWhenDrawSlot);
426 
427  QObject::connect(QGo4Widget::CreateChkAction(prefMenu, "Fetch when copying", go4sett->getFetchDataWhenCopy()),
428  &QAction::toggled, this, &TGo4MainWindow::ChangeFetchWhenCopySlot);
429 
430  QObject::connect(QGo4Widget::CreateChkAction(prefMenu, "Fetch when saving", go4sett->getFetchDataWhenSave()),
431  &QAction::toggled, this, &TGo4MainWindow::ChangeFetchWhenSaveSlot);
432 
433  QObject::connect(QGo4Widget::CreateChkAction(prefMenu, "Hide TGo4EventElement", go4sett->getHideTGo4EventElement()),
434  &QAction::toggled, this, &TGo4MainWindow::ChangeHideEventElement);
435 
436  QObject::connect(QGo4Widget::CreateChkAction(prefMenu, "Draw item once", go4sett->getDrawOnceFlag()),
437  &QAction::toggled, this, &TGo4MainWindow::ChangeDrawOnceSlot);
438 
439  QObject::connect(QGo4Widget::CreateChkAction(prefMenu, "Rubberband when moving windows", go4sett->getMoveSubwindowRubberBand()),
440  &QAction::toggled, this, &TGo4MainWindow::ChangeWindowRubberBandSlot);
441 
442  prefMenu->addAction("GUI HighDPI Scale factor...", this, &TGo4MainWindow::ScaleFactorSlot);
443 
444  QMenu* panelMenu = settMenu->addMenu("&Panel defaults");
445 
446  panelMenu->addAction("&Canvas color...", this, &TGo4MainWindow::CanvasColorSlot);
447 
448  QObject::connect(QGo4Widget::CreateChkAction(panelMenu, "White canvas for saved images", go4sett->getSavePadWhiteBackground()),
449  &QAction::toggled, this, &TGo4MainWindow::ChangeSaveWhiteBackgroundSlot);
450 
451  panelMenu->addAction("Marker labels...", this, &TGo4MainWindow::MarkerSettingsSlot);
452  panelMenu->addAction("Statistics box...", this, &TGo4MainWindow::OptStatsSlot);
453 
454  faSuperimpose = QGo4Widget::CreateChkAction(panelMenu, "&Superimpose mode", go4sett->getPadSuperimpose());
455  QObject::connect(faSuperimpose, &QAction::toggled, this, &TGo4MainWindow::SuperimposeSlot);
456 
457  faCrosshair = QGo4Widget::CreateChkAction(panelMenu, "Cross(&X)hair mode", go4sett->getPadCrosshair());
458  QObject::connect(faCrosshair, &QAction::toggled, this, &TGo4MainWindow::CrosshairSlot);
459 
460  faEventstatus = QGo4Widget::CreateChkAction(panelMenu, "Show Event Status", go4sett->getPadEventStatus());
461  QObject::connect(faEventstatus, &QAction::toggled, this, &TGo4MainWindow::EventStatusSlot);
462 
463  QObject::connect(QGo4Widget::CreateChkAction(panelMenu, "Objects cloning", go4sett->getCloneFlag()),
464  &QAction::toggled, this, &TGo4MainWindow::ChangeCloneFlagSlot);
465 
467  QObject::connect(faDrawTime, &QAction::toggled, this, &TGo4MainWindow::ChangeDrawTimeFlagSlot);
468 
470  QObject::connect(faDrawDate, &QAction::toggled, this, &TGo4MainWindow::ChangeDrawDateFlagSlot);
471 
472  faDrawItem = QGo4Widget::CreateChkAction(panelMenu, "Draw item name", go4sett->getDrawItemFlag(), go4sett->getCloneFlag());
473  QObject::connect(faDrawItem, &QAction::toggled, this, &TGo4MainWindow::ChangeDrawItemFlagSlot);
474 
475  panelMenu->addAction("Draw line &width ...", this, &TGo4MainWindow::DrawLineWidthSlot);
476  panelMenu->addAction("Draw fill color ...", this, &TGo4MainWindow::DrawFillColorSlot);
477  panelMenu->addAction("Draw fill style ...", this, &TGo4MainWindow::DrawFillStyleSlot);
478  panelMenu->addAction("TH1 draw opt ...", this, &TGo4MainWindow::TH1DrawOptSlot);
479  panelMenu->addAction("TH2 draw opt ...", this, &TGo4MainWindow::TH2DrawOptSlot);
480  panelMenu->addAction("TH3 draw opt ...", this, &TGo4MainWindow::TH3DrawOptSlot);
481  panelMenu->addAction("TGraph draw opt ...", this, &TGo4MainWindow::TGraphDrawOptSlot);
482  panelMenu->addAction("Printf format ...", this, &TGo4MainWindow::GStyleStatFormatSlot);
483  panelMenu->addAction("Palette settings ...", this, &TGo4MainWindow::PaletteSettingsSlot);
484 
485 
486  settMenu->addAction("&Log actions...", this, &TGo4MainWindow::LogSettingsSlot);
487  QMenu* termMenu = settMenu->addMenu("&Terminal");
488  QObject::connect(QGo4Widget::CreateChkAction(termMenu, "Print timestamps", go4sett->getTermShowTimestamp()), &QAction::toggled, this, &TGo4MainWindow::ChangeTerminalTimeStampSlot);
489  termMenu->addAction("&Timestamp Format...", this, &TGo4MainWindow::ChangeTerminalTimeStampFormatSlot);
490  termMenu->addAction("&History...", this, &TGo4MainWindow::InputTerminalParametersSlot);
491  termMenu->addAction("&Font...", this, &TGo4MainWindow::ChangeTerminalFontSlot);
492 
493 
494  settMenu->addAction("Generate &hotstart", this, &TGo4MainWindow::CreateGUIScriptSlot);
495  settMenu->addAction("&Break hotstart execution", this, &TGo4MainWindow::StopGUIScriptSlot);
496 
497 
498  settMenu->addAction("&Save settings", this, &TGo4MainWindow::SaveSettingsSlot);
499 
500  QActionGroup *ag = new QActionGroup(this);
501  ag->setExclusive(true);
502 
503  QStringList list = QStyleFactory::keys();
504  list.sort();
505  QHash<QString, int> stylesDict;
506  for (auto styleStr : list) {
507  QString styleAccel = styleStr;
508  if ( stylesDict[styleAccel.left(1)] ) {
509  for (int i = 0; i < styleAccel.length(); i++ ) {
510  if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
511  stylesDict.insert(styleAccel.mid( i, 1 ), 1);
512  styleAccel = styleAccel.insert( i, '&' );
513  break;
514  }
515  }
516  } else {
517  stylesDict.insert(styleAccel.left(1), 1);
518  styleAccel = "&"+styleAccel;
519  }
520  QAction *act = new QAction(styleAccel, this);
521  act->setCheckable(true);
522  act->setChecked(go4sett->getAppStyle() == styleStr);
523 
524  QObject::connect(act, &QAction::triggered, [&, styleStr]() { SetStyleSlot(styleStr); });
525 
526  ag->addAction(act);
527  styleMenu->addAction(act);
528  }
529 }
530 
531 #define CtrlKey(key) ((int)Qt::CTRL | key)
532 
533 
535 {
536  QMenu* fileMenu = menuBar()->addMenu("&File");
537 
538  fileMenu->addAction(QIcon( ":/icons/open.png" ), "&Open...",
539  this, &TGo4MainWindow::OpenFileSlot)->setShortcut(CtrlKey(Qt::Key_O));
540  fileMenu->addAction(QIcon( ":/icons/network.png" ), "Open &Remote...",
541  this, &TGo4MainWindow::OpenRemoteFileSlot)->setShortcut(CtrlKey(Qt::Key_R) );
543  fileMenu->addAction(QIcon( ":/icons/dabc.png" ), "Connect &DABC...",
545  fileMenu->addAction(QIcon( ":/icons/http.png" ), "Connect &HTTP...",
547  fileMenu->addAction(QIcon( ":/icons/histserv.png" ), "Open HIST &Server...",
549  fileMenu->addAction(QIcon( ":/icons/filesave.png" ), "Save memor&y...",
550  this, &TGo4MainWindow::SaveFileSlot)->setShortcut(CtrlKey(Qt::Key_Y) );
551  fileMenu->addAction(QIcon( ":/icons/close.png" ),"Close all files",
552  this, &TGo4MainWindow::CloseAllFilesSlot)->setShortcut(CtrlKey(Qt::Key_Q));
553  fileMenu->addAction(QIcon( ":/icons/exit.png" ), "E&xit",
554  this, &TGo4MainWindow::close)->setShortcut(CtrlKey(Qt::Key_X));
555 }
556 
558 {
559  QToolBar *FileBar = addToolBar( "File Toolbar" );
560  FileBar->setObjectName("FileToolBar");
561 
562  FileBar->addAction( QIcon( ":/icons/open.png" ), "Open a local file from disk",
564 
565  FileBar->addAction( QIcon( ":/icons/network.png" ), "Open a remote file from server",
567 
569  FileBar->addAction( QIcon( ":/icons/dabc.png" ), "Connect to DABC server",
571 
572  FileBar->addAction( QIcon( ":/icons/http.png" ), "Connect to HTTP server",
574 
575  FileBar->addAction( QIcon( ":/icons/histserv.png" ), "Connect to running histogram server",
577 
578  FileBar->addAction( QIcon( ":/icons/filesave.png" ), "Save the content of the browser to a root file",
580 
581  FileBar->addAction( QIcon( ":/icons/close.png" ), "Close all root files in file browser",
583 
584  FileBar->addAction( QIcon( ":/icons/exit.png" ), "Exit the Go4",
585  this, &TGo4MainWindow::close);
586 }
587 
589 {
590  QMenu* toolMenu = menuBar()->addMenu("&Tools");
591 
592  toolMenu->addAction(QIcon(":/icons/chart.png" ), "&View panel",
593  [this]() { MakeNewPanel(); })->setShortcut(CtrlKey(Qt::Key_V) );
594  toolMenu->addAction(QIcon(":/icons/fitpanel.png" ), "&Fit panel...",
595  [this]() { StartFitPanel(); })->setShortcut(CtrlKey(Qt::Key_F) );
596  toolMenu->addAction(QIcon(":/icons/hislist.png" ),"&Histogram properties...",
598  toolMenu->addAction(QIcon(":/icons/hiscre.png" ), "Create New H&istogram...",
599  [this]() { CreateNewHist(); })->setShortcut(CtrlKey(Qt::Key_I) );
600  toolMenu->addAction(QIcon(":/icons/condlist.png" ),"C&ondition properties...",
602  toolMenu->addAction(QIcon(":/icons/condcre.png" ),"Create new &condition...",
603  [this]() { CreateNewCondition(); });
604  toolMenu->addAction(QIcon(":/icons/zoom.png" ),"&Event printout...",
606  toolMenu->addAction(QIcon(":/icons/dynlist.png" ),"Create &dyn. list entry ...",
607  [this]() { CreateNewDynEntry(); })->setShortcut(CtrlKey(Qt::Key_D) );
608  toolMenu->addAction(QIcon(":/icons/dllicon.png" ), "Load li&braries ...",
609  this, &TGo4MainWindow::LoadLibrarySlot)->setShortcut(CtrlKey(Qt::Key_B) );
610  toolMenu->addAction(QIcon(":/icons/user.png" ), "&User GUI ...",
611  this, &TGo4MainWindow::UserPanelSlot)->setShortcut(CtrlKey(Qt::Key_U));
612 }
613 
615 {
616  QToolBar *ToolBar = addToolBar("Go4 tools");
617  ToolBar->setObjectName("Go4ToolsBar");
618 
619  ToolBar->addAction( QIcon( ":/icons/chart.png" ), "Create a new view panel",
620  [this]() { MakeNewPanel(); });
621 
622  ToolBar->addAction( QIcon( ":/icons/fitpanel.png" ), "Show/hide the Go4 Fit Panel",
623  [this]() { StartFitPanel(); });
624 
625  ToolBar->addAction( QIcon( ":/icons/hislist.png" ), "Show histogram properties window",
627 
628  ToolBar->addAction( QIcon( ":/icons/hiscre.png" ), "Create new ROOT Histogram",
630 
631  ToolBar->addAction( QIcon( ":/icons/condlist.png" ), "Show condition properties window",
633 
634  ToolBar->addAction( QIcon( ":/icons/condcre.png" ), "Create new condition in analysis",
635  [this]() { CreateNewCondition(); });
636 
637  ToolBar->addAction( QIcon( ":/icons/zoom.png" ), "Event printout and examination window",
639 
640  ToolBar->addAction( QIcon( ":/icons/dynlist.png" ), "Create new Dynamic list entry",
641  [this]() { CreateNewDynEntry(); });
642 
643  ToolBar->addAction( QIcon( ":/icons/dllicon.png" ), "Load Libraries",
645 
646  ToolBar->addAction( QIcon( ":/icons/user.png" ), "Start user panel",
648 }
649 
651 {
652  QMenu* anMenu = menuBar()->addMenu("&Analysis");
653 
654  faLaunchAnal =
655  anMenu->addAction(QIcon(":/icons/launchanal.png"), "Lau&nch analysis...", [this]() { LaunchClient(); });
656  faLaunchAnal->setShortcut(CtrlKey(Qt::Key_N));
657  faConnectAnal =
658  anMenu->addAction(QIcon(":/icons/connect.png"), "&Connect to running server...", [this]() { ConnectServer(); });
659  faConnectAnal->setShortcut(CtrlKey(Qt::Key_C));
660 
661  faPrepareAnal = anMenu->addAction(QIcon(":/icons/connect.png"), "&Prepare for client connection...",
662  [this]() { PrepareForClientConnection(); });
663 
664  faDisconnectAnal = anMenu->addAction(QIcon(":/icons/disconnect.png"), "Disconnect from analysis",
665  [this]() { DisconnectAnalysis(); });
666  faDisconnectAnal->setShortcut(CtrlKey(Qt::Key_M));
667 
668  faShutdownAnal = anMenu->addAction(QIcon(":/icons/shutanal.png"), "Shutdown analysis",
669  [this]() { ShutdownAnalysis(); });
670  faShutdownAnal->setShortcut(CtrlKey(Qt::Key_M));
671 
673  anMenu->addAction(QIcon(":/icons/restart.png"), "Submit+S&tart", this, &TGo4MainWindow::SubmitStartAnalysisSlot);
674  faSumbStartAnal->setShortcut(CtrlKey(Qt::Key_T));
675 
676  faStartAnal = anMenu->addAction(QIcon(":/icons/start.png"), "&Start", this, &TGo4MainWindow::StartAnalysisSlot);
677  faStartAnal->setShortcut(CtrlKey(Qt::Key_S));
678 
679  faStopAnal = anMenu->addAction(QIcon(":/icons/Stop.png"), "Stop (&Halt)", this, &TGo4MainWindow::StopAnalysisSlot);
680  faStopAnal->setShortcut(CtrlKey(Qt::Key_H));
681 
682  faAnalConfig = anMenu->addAction(QIcon(":/icons/control.png"), "Confi&guration...", this,
684  faAnalConfig->setShortcut(CtrlKey(Qt::Key_G));
685 
686  faAnalTermin = anMenu->addAction(QIcon(":/icons/analysiswin.png"), "Analysis &Window", this,
688  faAnalTermin->setShortcut(CtrlKey(Qt::Key_W));
689 }
690 
692 {
693  QToolBar *AnalBar = addToolBar("Analysis Toolbar");
694  AnalBar->setObjectName("AnalysisToolBar");
695  AnalBar->setToolTip("Analysis related tool buttons");
696 
697  AnalBar->addAction(faLaunchAnal);
698  AnalBar->addAction(faConnectAnal);
699  AnalBar->addAction(faDisconnectAnal);
700  AnalBar->addAction(faShutdownAnal);
701 
702  AnalBar->addAction(faSumbStartAnal);
703 
704  AnalBar->addAction(faStartAnal);
705 
706  AnalBar->addAction(faStopAnal);
707  AnalBar->addAction(faAnalConfig);
708  AnalBar->addAction(faAnalTermin);
709 }
710 
712 {
713  windowsMenu->clear();
714 
715  bool on = ! fxMdiArea->subWindowList().isEmpty();
716 
717  windowsMenu->addAction("Ca&scade", fxMdiArea, &TGo4MdiArea::cascadeSubWindows)->setEnabled(on);
718  windowsMenu->addAction("&Tile", fxMdiArea, &TGo4MdiArea::tileSubWindows)->setEnabled(on);
719  windowsMenu->addAction("&Close all", fxMdiArea, &TGo4MdiArea::closeAllSubWindows)->setEnabled(on);
720  windowsMenu->addAction("&Minimize all", this, &TGo4MainWindow::MinAllWindows)->setEnabled(on);
721 
722  windowsMenu->addAction((fbFullScreen ? "&Normal window" : "&Full screen"), this, &TGo4MainWindow::ToggleFullScreenSlot)->setShortcut(Qt::Key_F11);
723 
724  windowsMenu->addSeparator();
725 
726  auto loginfo = (TGo4LogInfo *) FindGo4Widget("LogInfo", false);
727  if (loginfo) {
728  windowsMenu->addAction("Save L&ogwindow", loginfo, &TGo4LogInfo::SaveLogInfo);
729  windowsMenu->addAction("Clear &Logwindow", loginfo, &TGo4LogInfo::ClearLogInfo);
730  } else {
731  windowsMenu->addAction("Save L&ogwindow")->setEnabled(false);
732  windowsMenu->addAction("Clear &Logwindow")->setEnabled(false);
733  }
734 
735  auto anw = FindAnalysisWindow();
736  if (anw) {
737  windowsMenu->addAction("Save &Analysis window", anw, &TGo4AnalysisWindow::SaveAnalysisOutput);
738  windowsMenu->addAction("Clear Analysis &window", anw, &TGo4AnalysisWindow::ClearAnalysisOutput);
739  } else {
740  windowsMenu->addAction("Save &Analysis window")->setEnabled(false);
741  windowsMenu->addAction("Clear Analysis &window")->setEnabled(false);
742  }
743 
744  windowsMenu->addSeparator();
745 
746  QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
747  for (int i = 0; i < windows.count(); i++) {
748  QAction *act = new QAction(windows.at(i)->widget()->windowTitle(), this);
749  act->setCheckable(true);
750  act->setChecked(fxMdiArea->activeSubWindow() == windows.at(i));
751 
752  windowsMenu->addAction(act);
753 
754  QObject::connect(act, &QAction::triggered, [this, i]() { WindowActivated(i); });
755  }
756 }
757 
759 {
760  QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
761  for ( int i = 0; i < windows.count(); i++ )
762  windows.at(i)->widget()->showMinimized();
763 }
764 
766 {
767  QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
768 
769  int x(15),y(15);
770 
771  for ( int i = 0; i < windows.count(); i++ ) {
772  windows.at(i)->move(x, y);
773  x+=25; y+=25;
774  }
775 }
776 
778 {
779  if (fbFullScreen) showNormal();
780  else showFullScreen();
782 }
783 
785 {
786  QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
787  if ((id >= 0) && (id < windows.count())) {
788  windows.at(id)->widget()->showNormal();
789  windows.at(id)->widget()->setFocus();
790  }
791 }
792 
793 typedef void *(*TStartUserGuiFunc)(QWidget *parent);
794 
795 bool TGo4MainWindow::startUserGUI(const char *usergui)
796 {
797  QString dirname, libname;
798 
799  bool result = false;
800 
801  if (usergui && (strlen(usergui) > 0)) {
802  QFileInfo info(usergui);
803  if (info.exists()) {
804  if (info.isFile()) {
805  dirname = info.path();
806  libname = info.fileName();
807  } else if (info.isDir()) {
808  dirname = usergui;
809  }
810  }
811  if ((dirname.length()>0) && (dirname[dirname.length()-1]!='/')) dirname+="/";
812  }
813 
814  bool defaultnames = libname.isEmpty();
815  if (defaultnames)
816  libname = "libGo4UserGui";
817 
818  TStartUserGuiFunc startfunc = nullptr;
819 
820  libname = dirname + libname;
821 
822  std::cout << "Try usergui: " << libname.toLatin1().constData() << std::endl;
823 
824  bool loaded = false;
825 
826  if (gSystem->Load(libname.toLatin1().constData()) >= 0) {
827  loaded = true;
828  startfunc = (TStartUserGuiFunc) gSystem->DynFindSymbol(libname.toLatin1().constData(), "StartUserPanel");
829  }
830 
831  if (startfunc) {
832  QGo4Widget* userpanel = (QGo4Widget*) startfunc(fxMdiArea);
833  if (userpanel) {
834  userpanel->setObjectName("UserPanel");
835 
836  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(userpanel);
837  CascadeMdiPosition(sub);
838  ConnectGo4Widget(userpanel);
839  userpanel->ensurePolished();
840  sub->show();
841  result = true;
842  } else
843  StatusMessage("StartUserPanel() function did not create user widget");
844  }
845 
846  if (result) {
847  std::cout << "Start user GUI from ";
848  if (dirname.length()>0)
849  std::cout << dirname.toLatin1().constData() << std::endl;
850  else
851  std::cout << "$LD_LIBRARY_PATH=" << gSystem->Getenv("LD_LIBRARY_PATH") << std::endl;
852  } else {
853  if (loaded) gSystem->Unload(libname.toLatin1().constData());
854  }
855 
856  return result;
857 }
858 
860 {
861  QGo4Widget* userpanel = FindGo4Widget("UserPanel", true);
862  if (userpanel) return;
863 
864  // check GO4USERGUI variable
865  if (gSystem->Getenv("GO4USERGUI"))
866  if (startUserGUI(gSystem->Getenv("GO4USERGUI"))) return;
867 
868  // check from standard LD_LIBRARY_PATHS
869  if (startUserGUI(nullptr)) return;
870 
871  TString usergui;
872 
873  if (go4sett->getWebBasedCanvas())
874  usergui = TGo4Log::subGO4SYS("qt4/WebUserGUI");
875  else
876  usergui = TGo4Log::subGO4SYS("qt4/Go4UserGUI");
877 
878  if (startUserGUI(usergui.Data())) return;
879 
880  QMessageBox::critical(this,"Starting user GUI", "No suitable libraries found");
881 }
882 
883 TGo4ViewPanel *TGo4MainWindow::MakeNewPanel(int ndiv)
884 {
885  QString name;
886 
887  TGo4Slot *edslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
888 
889  int n = 0;
890  do {
891  n++;
892  name = QString("Panel") + QString::number(n);
893  } while (edslot && edslot->FindChild(name.toLatin1().constData()));
894 
895  TGo4ViewPanel *panel = new TGo4ViewPanel(fxMdiArea, name.toLatin1().constData());
896  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(panel); // warning: Qt may exchange the winId here!
897  // panel->GetQCanvas()->performResize(); // may register new winId for TCanvas here
898 
899 
900  sub->resize(go4sett->lastPanelSize("ViewPanel"));
901 
902  CascadeMdiPosition(sub);
903 
904  ConnectGo4Widget(panel);
905  panel->update();
906  panel->show();
907  panel->ensurePolished();
908  panel->CompleteInitialization();
909 
910  if(ndiv>1) {
911 
912  int DivX = 1, DivY = 1;
913 
914  TGo4DividePad* divpad = findChild<TGo4DividePad*>("DividePad");
915 
916  if (divpad) {
917  DivX = divpad->SpinBoxX->value();
918  DivY = divpad->SpinBoxY->value();
919  }
920  if (DivX * DivY < ndiv) {
921  DivX = (int) TMath::Sqrt(ndiv*1.);
922  DivY = DivX;
923  while (DivX*DivY<ndiv) DivY++;
924  }
925  panel->Divide(DivX, DivY);
926  }
927 
928  return panel;
929 }
930 
932 {
933  //if ((sub->x() + sub->width() < fxMdiArea->viewport()->width()) &&
934  //(sub->y() + sub->height() < fxMdiArea->viewport()->height())) return;
935 
936  int newx = fNewWidgetX;
937  int newy = fNewWidgetY;
938  if (newx + sub->width() > fxMdiArea->width()) newx = 0;
939  if (newy + sub->height() > fxMdiArea->height()) newy = 0;
940  sub->move(newx, newy);
941  fNewWidgetX = sub->x() + 30;
942  fNewWidgetY = sub->y() + 30;
943 }
944 
945 
946 void TGo4MainWindow::closeEvent(QCloseEvent *ce)
947 {
948  if (fCloseCounter != 0) return;
949 
950  if(QMessageBox::question( this, "Go4 GUI", "Really Exit Go4?",
951  QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) {
952  ce->ignore();
953  return;
954  }
955 
956  TGo4FitPanel* panel = (TGo4FitPanel*) FindGo4Widget("FitPanel", false);
957  if (panel) panel->close();
958 
959  //fxMdiArea->closeAllSubWindows();
960 
962  fxMdiArea->closeAllSubWindows();
964 
965  bool realshutdown = false;
966 
967  // TODO: terminate HTTP server running in Qt window
969  if (an && an->TerminateOnClose()) realshutdown = true;
970 
972  int waitsecs = 180;
973  if(!RemoveAnalysisProxy(waitsecs, realshutdown)) {
974  fCloseCounter = (waitsecs+10) *10; // was 100 gui waits about 10 second to close analysis
975  statusBar()->showMessage("Exit.... please wait");
976  QApplication::setOverrideCursor(Qt::WaitCursor);
977  QTimer::singleShot(100, this, &TGo4MainWindow::ForseCloseSlot);
978  ce->ignore();
979  } else {
980  statusBar()->showMessage("Closing GUI...");
981  // JAM: due to problems with Qt5, we just use delayed exit here
982  // note that calling directly gSystem->Exit gives crash in ROOT object/pad cleanup...
983  // probably because fxMdiArea->closeAllSubWindows() will have effect only after this event handler returns
984  QTimer::singleShot(100, this, &TGo4MainWindow::ForseCloseSlot);
985  ce->ignore();
986  }
987 }
988 
990 {
991  // if (!RemoveAnalysisProxy(30) && (fCloseCounter>0)) {
992 
993  if (Browser()->FindServer()) {
994 
995  if (fCloseCounter>0) {
996  fCloseCounter--;
997  QTimer::singleShot(100, this, &TGo4MainWindow::ForseCloseSlot);
998  return;
999  }
1000 
1001  QMessageBox box(QMessageBox::Critical, "Exit GUI", "Analysis is not (yet) shutdown correctly");
1002  auto wait_btn = box.addButton("Wait 10 s more", QMessageBox::AcceptRole);
1003  auto kill_btn = box.addButton("Kill analysis", QMessageBox::DestructiveRole);
1004  auto exit_btn = box.addButton("Exit immediately", QMessageBox::DestructiveRole);
1005  auto cancel_btn = box.addButton("Cancel quit", QMessageBox::RejectRole);
1006  box.setDefaultButton(wait_btn);
1007 
1008  box.exec();
1009 
1010  if (box.clickedButton() == wait_btn) {
1011  fCloseCounter = 100;
1012  QTimer::singleShot(100, this, &TGo4MainWindow::ForseCloseSlot);
1013  return;
1014  }
1015 
1016  if ((box.clickedButton() == cancel_btn) || !box.clickedButton()) {
1017  std::cout << "Keep GUI running, press exit once again" << std::endl;
1018  return;
1019  }
1020 
1021  if (box.clickedButton() == kill_btn) {
1022  std::cout << "Killing analysis" << std::endl;
1023  TerminateAnalysis(false);
1024  }
1025 
1026  if (box.clickedButton() == exit_btn) {
1027  std::cout << "GUI closed with analysis still running - may lead to analysis task running forever" << std::endl;
1028  std::cout << "Please check running processes with \"ps\" and probably, kill analysis with \"killall go4analysis\" command" << std::endl;
1029  }
1030  }
1031  std::cout << "----- Exiting Go4 GUI now -----" << std::endl;
1032  gSystem->Exit(0);
1033 }
1034 
1036 {
1037  QFileDialog fd( this,
1038  "Select a ROOT file to open it in the Go4 Disk Browser",
1039  fLastFileDir,
1040  QString("Root files (*.root);;Root xml files (*.xml);;All files (*.*)"));
1041 
1042  fd.setFileMode( QFileDialog::ExistingFiles);
1043 
1044  if ( fd.exec() != QDialog::Accepted ) return;
1045 
1046  QStringList list = fd.selectedFiles();
1047  QStringList::Iterator it = list.begin();
1048  while( it != list.end() ) {
1049  QString fileName = *it;
1050  fLastFileDir = QFileInfo(fileName).absolutePath();
1051  Browser()->OpenFile(fileName.toLatin1().constData());
1052  ++it;
1053  }
1054 }
1055 
1057 {
1058  TGo4OpenRemoteDialog fd( this);
1059  if (fd.exec() != QDialog::Accepted) return;
1060 
1061  QString ftype = fd.GetFileType();
1062  QString host = fd.GetServer();
1063 
1064  QString urlpath;
1065  if(ftype.contains("root:"))
1066  urlpath = "root://" + host + "/";
1067  else
1068  if (ftype.contains("rfio:")) {
1069  if(!host.isEmpty())
1070  urlpath="rfio:" + host + ":/";
1071  else
1072  urlpath="rfio:/";
1073  } else
1074  if (ftype.contains("http:")) {
1075  if(!host.isEmpty())
1076  urlpath="http://" + host + "/";
1077  else
1078  urlpath="http://";
1079  }
1080 
1081  QString fileName = fd.GetFileName();
1082 
1083  if(!fileName.isEmpty() && !fileName.contains(".root"))
1084  fileName.append(".root");
1085 
1086  fileName = urlpath + fileName;
1087 
1088  fxOM->AddFile(fOMDataPath.toLatin1().constData(), fileName.toLatin1().constData());
1089 }
1090 
1092 {
1093  bool ok = false;
1094  QString dabcnode = QInputDialog::getText(
1095  this, "Establish connection with DABC", "Provide dabc server name",
1096  QLineEdit::Normal, QString(), &ok);
1097  if (!ok) return;
1098 
1099  if (!Browser()->ConnectDabc(dabcnode.toLatin1().constData()))
1100  QMessageBox::warning(this, "DABC server", "Cannot connect to DABC server");
1101 }
1102 
1104 {
1106 }
1107 
1108 TGo4ServerProxy *TGo4MainWindow::ConnectHttpServer(const char *addr, const char *user, const char *pass, bool with_qt_process, bool get_analysis_config)
1109 {
1110  QString httpaddr;
1111 
1112  if (!addr) {
1113  bool ok = false;
1114  QString portstring;
1115  QString fulladdress = go4sett->getClientNode().append(QString(":")).append(portstring.setNum(go4sett->getClientPort()));
1116  httpaddr = QInputDialog::getText(
1117  this, "Establish connection with HTTP", "Provide http server name",
1118  QLineEdit::Normal, fulladdress, &ok);
1119  if (!ok) return nullptr;
1120  QStringList nameportlist = httpaddr.split(":");
1121  int nameindex = 0;
1122  int portindex = 1;
1123  if(nameportlist.at(0).contains("http")) {
1124  nameindex = 1;
1125  portindex = 2;
1126  }
1127  // first check here if we have valid port number:
1128  if(nameportlist.size()<portindex+1 || nameportlist.at(portindex).isEmpty()){
1129  QMessageBox::warning(this, "HTTP server connection", "Could not connect. Please specify port number!");
1130  return nullptr;
1131  }
1132  QString host = nameportlist.at(nameindex);
1133  QStringList hostnamelist = nameportlist.at(nameindex).split("//");
1134  if(hostnamelist.size()>1) host = hostnamelist.at(1); // get rid of optional leading // of full http adress
1135  go4sett->setClientNode(host);
1136  go4sett->setClientPort(nameportlist.at(portindex).toInt());
1138 
1139  } else {
1140  httpaddr = addr;
1141  }
1142 
1144 
1145  if (!exec) return nullptr;
1146 
1147  TGo4ServerProxy *serv = exec->ConnectHttp(httpaddr.toLatin1().constData(), user, pass);
1148 
1149  if (serv) StatusMessage(QString("Connect with http server %1 %2").arg(httpaddr).arg(serv->IsGo4Analysis() ? " as GO4 analysis" : ""));
1150 
1151  if (serv && serv->IsGo4Analysis()) {
1152  EstablishRatemeter(2);
1153  if (!serv->IsViewer())
1154  EstablishAnalysisConfiguration(get_analysis_config ? 3 : 2);
1155 
1156  TGo4LogInfo* loginfo = (TGo4LogInfo*) FindGo4Widget("LogInfo", false);
1157  if (loginfo) loginfo->WorkWithInfo(serv->LoginfoSlot());
1158 
1159  if (!with_qt_process) EstablishAnalysisWindowForHttp();
1160  }
1161 
1162  return serv;
1163 }
1164 
1166 {
1167  TGo4HServerConnection dlg( this, "Connect to remote HServer", true );
1168 
1169  dlg.ServerName->setText(go4sett->getHServName());
1170  dlg.BaseName->setText(go4sett->getHServBase());
1171  dlg.FilterList->setText(go4sett->getHServFilter());
1172  dlg.PortNumberSpin->setValue(go4sett->getHServPort());
1173 
1174  if (dlg.exec() != QDialog::Accepted) return;
1175 
1176  go4sett->setHServName(dlg.ServerName->text());
1177  go4sett->setHServBase(dlg.BaseName->text());
1178  go4sett->setHServFilter(dlg.FilterList->text());
1179  go4sett->setHServPort(dlg.PortNumberSpin->value());
1180 
1181  if (!Browser()->ConnectHServer(dlg.ServerName->text().toLatin1().constData(),
1182  dlg.PortNumberSpin->value(),
1183  dlg.BaseName->text().toLatin1().constData(),
1184  dlg.UserPassEdt->text().toLatin1().constData(),
1185  dlg.FilterList->text().toLatin1().constData()))
1186  QMessageBox::warning(this, "HServer", "Cannot connect to histogram server");
1187 }
1188 
1190 {
1191  QFileDialog fd(this,
1193  "Select root file to fetch and export all browser objects" :
1194  "Select root file to export all local browser objects",
1195  fLastFileDir, "ROOT (*.root)");
1196 
1197  fd.setFileMode( QFileDialog::AnyFile);
1198  fd.setAcceptMode(QFileDialog::AcceptSave);
1199  fd.selectFile("export.root");
1200 
1201  if (fd.exec() != QDialog::Accepted) return;
1202 
1203  QStringList flst = fd.selectedFiles();
1204  if (flst.isEmpty()) return;
1205 
1206  QString fname = flst[0];
1207  fLastFileDir = fd.directory().path();
1208  if (fname.indexOf(".root", 0, Qt::CaseInsensitive)<0) fname += ".root";
1209 
1210  if (!Browser()->SaveBrowserToFile(fname.toLatin1().constData(), go4sett->getFetchDataWhenSave()))
1211  QMessageBox::warning(this, "Save data to file", "Specified file can not be created");
1212 }
1213 
1215 {
1216  fxOM->CloseFiles(fOMDataPath.toLatin1().constData());
1217 }
1218 
1220 {
1221  int size = go4sett->getTermHistorySize();
1222 
1223  bool ok = false;
1224 
1225  size = QInputDialog::getInt(this,
1226  "Analysis terminal history size in bytes (minimum 10000 bytes)",
1227  "Input 0 if full analysis history should be preserved",
1228  size, 0, 100000000, 10000, &ok);
1229 
1230  if ((size > 0) && (size < 10000)) size = 10000;
1231 
1232  if (ok) {
1233  go4sett->setTermHistorySize(size);
1235  if (anw)
1236  anw->SetHistorySize(size);
1237  }
1238 }
1239 
1241 {
1242  TGo4LogSettings dlg;
1243  if (dlg.exec() != QDialog::Accepted) return;
1244 
1245  if(dlg.LogfileWrite->isChecked())
1246  TGo4Log::OpenLogfile(dlg.LogfileName->text().toLatin1().constData(), "Logfile for Go4 GUI", true);
1247 
1248  TGo4Log::LogfileEnable(dlg.LogfileWrite->isChecked());
1249  TGo4Log::OutputEnable(dlg.LogfilePrint->isChecked());
1250  TGo4Log::SetIgnoreLevel(dlg.IgnoreCombo->currentIndex());
1251  TGo4Log::AutoEnable(dlg.ModeCombo->currentIndex());
1252 }
1253 
1254 void TGo4MainWindow::HelpWindow(const char *filename, const char *msg)
1255 {
1256  QApplication::setOverrideCursor( Qt::WaitCursor );
1257 
1258  QString surl = TGo4Log::subGO4SYS(filename).Data();
1259 
1260  bool result = QDesktopServices::openUrl(QUrl::fromLocalFile(surl));
1261 
1262  if(result)
1263  StatusMessage(msg ? QString(msg) : QString("Show ") + filename);
1264  else
1265  StatusMessage(QString("Fail to display ") + filename);
1266 
1267  QApplication::restoreOverrideCursor();
1268 }
1269 
1271 {
1272  HelpWindow("docs/Go4Introduction.pdf", "Show Go4 Introduction manual...");
1273 }
1274 
1276 {
1277  HelpWindow("docs/Go4Reference.pdf", "Show Go4 Reference manual...");
1278 }
1279 
1281 {
1282  HelpWindow("docs/Go4FitTutorial.pdf", "Show Go4 Fit tutorial...");
1283 }
1284 
1286 {
1288  go4sett->setAppFont(QApplication::font());
1289 
1290  go4sett->setAppStyle(QApplication::style()->objectName());
1291 
1293 
1294  go4sett->Store();
1295 
1296  std::cout <<"Save Qt settings to "<< go4sett->GetSettLoaction().toLatin1().constData() << std::endl;
1297 }
1298 
1300 {
1301  bool ok = false;
1302  QFont font= QFontDialog::getFont(&ok, QApplication::font(), this);
1303  if (!ok) return;
1304 
1305  go4sett->setAppFont(font);
1306 
1307  QApplication::setFont(font);
1308 }
1309 
1311 {
1312  bool ok = false;
1313  QFont font= QFontDialog::getFont(&ok, go4sett->getTermFont(), this);
1314  if (!ok) return;
1315 
1316  go4sett->setTermFont(font);
1317 
1319  if (anw) anw->setFont(font);
1320 }
1321 
1322 
1324 {
1327  if (anw)
1328  anw->UpdateTimeStampFormat();
1329 }
1330 
1332 {
1333  bool ok = false;
1334  QString str = QInputDialog::getText(this, "Analysis terminal timestamp format",
1335  "Time format (empty resets to yyyy-MM-dd hh:mm:ss.zzz)",
1336  QLineEdit::Normal, go4sett->getTermTimeFormat(), &ok);
1337  if (ok) {
1338  if (str.isEmpty())
1339  str = "yyyy-MM-dd hh:mm:ss.zzz";
1340  go4sett->setTermTimeFormat(str);
1342  if (anw)
1343  anw->UpdateTimeStampFormat();
1344  }
1345 }
1346 
1347 void TGo4MainWindow::SetStyleSlot(const QString &style)
1348 {
1349  // save settings anyway
1350  go4sett->setAppStyle(style);
1351  go4sett->Store();
1352 
1353  QApplication::setStyle(style);
1354 }
1355 
1356 void TGo4MainWindow::StatusMessage(const QString& mess)
1357 {
1358  QString output = QDateTime::currentDateTime().toString(Qt::ISODate);
1359  output.append(": ");
1360  output.append(mess);
1361  statusBar()->showMessage(output, 0); // JAM2016: do not clear message after 3s. ratemeter will clear message on each update.
1363  TGo4Log::Message(1, "%s", output.toLatin1().constData());
1364 }
1365 
1367 {
1368  // JAM note this function is called by update timer from TGo4Browser each second
1369  TGo4ServerProxy *root_serv = Browser()->FindServer(nullptr, kFALSE);
1370  TGo4ServerProxy *go4_serv = Browser()->FindServer();
1371  TGo4AnalysisProxy *pr = dynamic_cast<TGo4AnalysisProxy *>(go4_serv);
1372  TGo4HttpProxy *ht = dynamic_cast<TGo4HttpProxy *>(go4_serv);
1373 
1374  QString capt = "Go4 ";
1375  capt += __GO4RELEASE__;
1376  capt += " @";
1377  capt += gSystem->HostName();
1378  if (go4_serv && go4_serv->IsConnected() ) {
1379  capt += " <";
1380  capt += go4_serv->GetContainedObjectInfo();
1381  capt += ">";
1382  }
1383  setWindowTitle(capt);
1384 
1385  bool flag = false;
1386  if (!pr) flag = !ht ? true: false;
1387  faLaunchAnal->setEnabled(flag);
1388  // JAM here check again ratemeter connection, if http server was disconnected by browser popup close item:
1389  EstablishRatemeter(flag ? 0: 1);
1390  // need to check if the controller role has switched to another HTTP server here:
1391  static TGo4HttpProxy *oldhttp = nullptr;
1392  if (ht) {
1393  // check for server names may not be unique if connected twice by chance, better use proxy pointers!
1394  if(ht != oldhttp) {
1395  //printf("UpdateCaptionButtons sees new http server (0x%x), old (0x%x) \n", ht, oldhttp);
1396  oldhttp = ht;
1397  EstablishRatemeter(0);
1398  EstablishRatemeter(2);
1399  }
1400  }
1401 
1402  if (!pr)
1403  flag = !ht ? true : false;
1404  else
1405  flag = (fConnectingCounter <= 0) && pr->IsAnalysisServer() && !pr->IsConnected();
1406  faConnectAnal->setEnabled(flag);
1407 
1408  faPrepareAnal->setEnabled(flag);
1409 
1410  if (!pr)
1411  flag = !ht ? false : true;
1412  else
1413  flag = pr->IsAnalysisServer() && (pr->IsConnected() || (fConnectingCounter <= 0));
1414  faDisconnectAnal->setEnabled(flag);
1415 
1416  flag = false;
1417  if (go4_serv)
1418  flag = !go4_serv->IsAnalysisServer() || (go4_serv->IsConnected() && go4_serv->IsAdministrator());
1419  faShutdownAnal->setEnabled(flag);
1420 
1421  bool iscontrolling = false, issubmit = false;
1422  if (go4_serv) {
1423  iscontrolling = go4_serv->IsConnected() && (go4_serv->IsAdministrator() || go4_serv->IsController());
1424  if (iscontrolling)
1425  issubmit = go4_serv->CanSubmitObjects();
1426  }
1427 
1428  faSumbStartAnal->setEnabled(issubmit);
1429 
1430  faStartAnal->setEnabled(iscontrolling);
1431 
1432  faStopAnal->setEnabled(iscontrolling);
1433 
1434  faAnalConfig->setEnabled(iscontrolling);
1435 
1436  faAnalTermin->setEnabled(FindAnalysisWindow() != nullptr);
1437 
1438  if (!go4_serv && root_serv) {
1439  faStartAnal->setEnabled(root_serv->FindCommand("Start").Length()>0);
1440  faStopAnal->setEnabled(root_serv->FindCommand("Stop").Length()>0);
1441  }
1442 }
1443 
1445 {
1447 }
1448 
1450 {
1452 }
1453 
1455 {
1457 }
1458 
1460 {
1462  UpdateBrowser();
1463 }
1464 
1466 {
1467  go4sett->setDrawOnceFlag(flag);
1468 }
1469 
1471 {
1473 }
1474 
1476 {
1477  QColor c = QColorDialog::getColor();
1478  if (c.isValid())
1479  go4sett->setCanvasColor(c.red(), c.green(), c.blue());
1480 }
1481 
1483 {
1484  TGo4MarkerSettings mset;
1485  if (mset.exec() != QDialog::Accepted) return;
1486  // all work is done inside dialog.
1487 }
1488 
1490 {
1491  TGo4OptStatsSettings stset;
1492  stset.exec();
1493  // all work is done inside dialog.
1494 }
1495 
1497 {
1498  go4sett->setPadSuperimpose(flag);
1499 }
1500 
1502 {
1503  go4sett->setPadCrosshair(flag);
1504 }
1505 
1507 {
1508  go4sett->setPadEventStatus(flag);
1509 }
1510 
1512 {
1513  faDrawTime->setEnabled(flag);
1514  faDrawDate->setEnabled(flag);
1515  faDrawItem->setEnabled(flag);
1516  go4sett->setCloneFlag(flag);
1517 }
1518 
1520 {
1521  go4sett->setDrawTimeFlag(flag);
1522 }
1523 
1525 {
1526  go4sett->setDrawItemFlag(flag);
1527 }
1528 
1530 {
1531  go4sett->setDrawDateFlag(flag);
1532 }
1533 
1535 {
1537 }
1538 
1540 {
1541  int w = go4sett->getDrawLineWidth();
1542 
1543  bool ok = false;
1544 
1545  w = QInputDialog::getInt(this,
1546  "Default line width for object drawing",
1547  "Input 1 to preserve default value",
1548  w, 1, 10, 1, &ok);
1549 
1550  if (ok) go4sett->setDrawLineWidth(w);
1551 }
1552 
1553 
1555 {
1556  int w = go4sett->getDrawFillColor();
1557 
1558  bool ok = false;
1559 
1560  w = QInputDialog::getInt(this,
1561  "Default fill color for 1D objects (histogram and graph) drawing",
1562  "Input 0 for no fill",
1563  w, 0, 50, 1, &ok);
1564 
1565  if (ok) go4sett->setDrawFillColor(w);
1566 }
1567 
1569 {
1570  int w = go4sett->getDrawFillStyle();
1571 
1572  bool ok = false;
1573 
1574  w = QInputDialog::getInt(this,
1575  "Default fill style for 1D objects (histogram and graph) drawing",
1576  "Input 1001 for solid fill",
1577  w, 0, 4000, 1, &ok);
1578 
1579  if (ok) go4sett->setDrawFillStyle(w);
1580 }
1581 
1582 
1584 {
1585  bool ok = false;
1586  QString str = QInputDialog::getText(this,
1587  "Default draw options for TH1 class",
1588  "Input draw options",
1589  QLineEdit::Normal, go4sett->getTH1DrawOpt(), &ok);
1590  if (ok) go4sett->setTH1DrawOpt(str);
1591 }
1592 
1594 {
1595  bool ok = false;
1596  QString str = QInputDialog::getText(this,
1597  "Default draw options for TH2 class",
1598  "Input draw options",
1599  QLineEdit::Normal, go4sett->getTH2DrawOpt(), &ok);
1600  if (ok) go4sett->setTH2DrawOpt(str);
1601 }
1602 
1604 {
1605  bool ok = false;
1606  QString str = QInputDialog::getText(this,
1607  "Default draw options for TH3 class",
1608  "Input draw options",
1609  QLineEdit::Normal, go4sett->getTH3DrawOpt(), &ok);
1610  if (ok) go4sett->setTH3DrawOpt(str);
1611 }
1612 
1614 {
1615  bool ok = false;
1616  QString str = QInputDialog::getText(this,
1617  "Default draw options for TGraph class",
1618  "Input draw options",
1619  QLineEdit::Normal, go4sett->getTGraphDrawOpt(), &ok);
1620  if (ok)
1621  go4sett->setTGraphDrawOpt(str);
1622 }
1623 
1624 
1626 {
1627  bool ok = false;
1628  QString s0 = go4sett->getGStyleStatFormat();
1629  if (s0.isEmpty()) s0 = gStyle->GetStatFormat();
1630 
1631  QString str = QInputDialog::getText(this,
1632  "Printf argument for float values - gStyle->GetStatFormat()",
1633  "Input format string like 6.4g (empty - ROOT default)",
1634  QLineEdit::Normal, s0, &ok);
1635  if (ok) {
1637  if (str.isEmpty())
1638  gStyle->SetStatFormat();
1639  else
1640  gStyle->SetStatFormat(str.toLatin1().constData());
1641  }
1642 }
1643 
1644 
1646 {
1647  // JAM: later we might put some elaborate input dialog here. for the moment keep on with parsing a string-
1648  bool ok = false;
1649  int min = 0, def = 0, max = 0;
1650  go4sett->getPaletteOpt(min, def, max);
1651  QString palvals = QString("%1:%2:%3").arg(min).arg(def).arg(max);
1652  QString str = QInputDialog::getText(this,
1653  "Default Palette options",
1654  "Input - MinIndex:DefaultIndex:MaxIndex",
1655  QLineEdit::Normal, palvals, &ok);
1656  if (ok) {
1657  QStringList parts=str.split(":");
1658  min=parts[0].toInt();
1659  def=parts[1].toInt();
1660  max=parts[2].toInt();
1661 // std::cout <<"PaletteSettingsSlot has "<<min<<":"<<def<<":"<<max <<std::endl;
1662  go4sett->setPaletteOpt(min,def,max);
1663  // activate settings immediately, do not need to restart go4
1664  fxStyle->SetPaletteRange(min,def,max);
1665  }
1666 }
1667 
1668 
1670 {
1671  double w = go4sett->getScreenScaleFactor();
1672 
1673  bool ok = false;
1674 
1675  w = QInputDialog::getDouble(this, "HighDPI scaling", "Please set scale factor. Restart GUI to apply!", w, 0, 50, 1,
1676  &ok);
1677  if (ok)
1679 }
1680 
1681 void TGo4MainWindow::LaunchClient(bool interactive)
1682 {
1683  TGo4AnalysisProxy *anal = Browser()->FindAnalysis();
1684  if (anal) {
1685  QMessageBox::warning(this, "Launch analysis", "Please disconnect analysis first");
1686  return;
1687  }
1688 
1689  if (interactive) {
1690  TGo4StartClient dlg;
1691  if (dlg.exec()!=QDialog::Accepted) return;
1692  dlg.getResults();
1693  }
1694 
1695  int shellmode = go4sett->getClientShellMode();
1696  int termmode = go4sett->getClientTermMode();
1697  int isserver = go4sett->getClientIsServer();
1698 
1699  TString launchcmd, killcmd;
1700  Bool_t res = kFALSE;
1701 
1702  QString workdir = go4sett->getClientDir();
1703 
1704  if (isserver==2) {
1705  // first handle http connection
1706 
1707  QString addr = QString("%1:%2").arg(go4sett->getClientNode()).arg(go4sett->getClientPort());
1708 
1709  // first verify that http server already running with such address
1710  // need to request analysis status anyway
1711  if (ConnectHttpServer(addr.toLatin1().constData(), nullptr, nullptr, false, true)) {
1712  StatusMessage("Connected to existing analysis webserver!"); // JAM tell user that this is no analysis restart!
1713  std::cout<< "!!! Connected to existing analysis webserver "<<addr.toLatin1().constData()<< "!!! "<<std::endl; // status message is shadowed by ratemeters....
1714  return;
1715  }
1716 
1717  res = TGo4ServerProxy::GetLaunchString(launchcmd, killcmd,
1718  2, shellmode, termmode,
1719  go4sett->getClientName().toLatin1().constData(),
1720  go4sett->getClientNode().toLatin1().constData(),
1721  workdir.toLatin1().constData(),
1722  go4sett->getClientExec().toLatin1().constData(),
1725  go4sett->getClientArgs().toLatin1().constData());
1726 
1727  if (!res) return;
1728 
1729  fKillCommand = killcmd.Data();
1730 
1731  if ((termmode==2) || (termmode==3)) {
1732  gSystem->Exec(launchcmd.Data());
1733  } else {
1734  TGo4AnalysisWindow* anw = EstablishAnalysisWindow(true, true, true);
1735  anw->StartAnalysisShell(launchcmd.Data(), (shellmode == 0) ? workdir.toLatin1().constData() : nullptr, true);
1736  }
1737 
1738  fConnectingCounter = 100; // try next 10 seconds connect with the server
1739  fConnectingHttp = addr;
1740  fbGetAnalysisConfig = true; // pass to timer that we want to have analysis config window when ready JAM
1741  QTimer::singleShot(100, this, &TGo4MainWindow::CheckConnectingCounterSlot);
1742 
1743  return;
1744  }
1745 
1746  if (isserver == 0) {
1747  TGo4AnalysisProxy *anal = AddAnalysisProxy(false, (termmode==1));
1748  if (anal)
1749  res = anal->LaunchAsClient(launchcmd, killcmd,
1750  shellmode,
1751  termmode,
1752  go4sett->getClientName().toLatin1().constData(),
1753  go4sett->getClientNode().toLatin1().constData(),
1754  workdir.toLatin1().constData(),
1755  go4sett->getClientExec().toLatin1().constData(),
1757  go4sett->getClientArgs().toLatin1().constData());
1759  if (res && anw && (termmode==1)) {
1760  anw->StartAnalysisShell(launchcmd.Data(), (shellmode == 0) ? workdir.toLatin1().constData() : nullptr, false);
1761  }
1762  if (res && anal) anal->SetAnalysisLaunched(termmode==1 ? 2 : 1);
1763  } else {
1764  res = TGo4AnalysisProxy::LaunchAsServer(launchcmd, killcmd,
1765  shellmode,
1766  termmode,
1767  go4sett->getClientName().toLatin1().constData(),
1768  go4sett->getClientNode().toLatin1().constData(),
1770  workdir.toLatin1().constData(),
1771  go4sett->getClientExec().toLatin1().constData(),
1773  go4sett->getClientArgs().toLatin1().constData());
1774  }
1775 
1776  if (res)
1777  fKillCommand = killcmd.Data();
1778  else
1779  fKillCommand = "";
1780 
1781  StatusMessage("Starting Analysis.... Please wait");
1782 
1783  if ((isserver == 1) && interactive) {
1784  fbGetAnalysisConfig = true; // pass to timer that we want to have analysis config window when ready JAM
1785  ConnectServer(true, "");
1786  }
1787 }
1788 
1790 {
1791  TGo4AnalysisProxy *ana = AddAnalysisProxy(false, false);
1792  if (ana && interactive)
1793  QMessageBox::information(this, "Prepare for client connection",
1794  QString("Now you can start client from other shell (node) and connect to port ") + QString::number(ana->ConnectorPort()));
1795 }
1796 
1797 TGo4AnalysisWindow* TGo4MainWindow::EstablishAnalysisWindow(bool needoutput, bool withkillbnt, bool force_recreate)
1798 {
1800  if (anw)
1801  if (force_recreate || (anw->HasOutput() && !needoutput)) {
1802  delete anw;
1803  anw = nullptr;
1804  }
1805 
1806  if (!anw) {
1807  if (needoutput) {
1808  anw = new TGo4AnalysisWindow(fxMdiArea, "AnalysisWindow", true);
1809  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(anw);
1810  sub->resize(go4sett->lastPanelSize("AnalysisWindow", 700, 500));
1811  CascadeMdiPosition(sub);
1812  ConnectGo4Widget(anw);
1813  anw->ensurePolished();
1814  sub->show();
1815  } else {
1816  QToolBar* dock = addToolBar("Analysis control");
1817  dock->setObjectName("AnalysisControlBar");
1818  anw = new TGo4AnalysisWindow(this, "AnalysisWindow", false, withkillbnt || fKillCommand.length()>0);
1819  ConnectGo4Widget(anw);
1820  dock->addWidget(anw);
1821  }
1822  }
1823 
1824  return anw;
1825 }
1826 
1828 {
1829  // used together with http server connection
1830  // analysis window only created when not exists and http proxy is available
1831 
1832  auto serv = Browser()->FindServer();
1833  if (!serv || (dynamic_cast<TGo4AnalysisProxy *>(serv) != nullptr) || (serv->DebugOutputSlot() == nullptr)) return;
1834 
1835  auto anw = FindAnalysisWindow();
1836 
1837  if (anw) {
1838  if (anw->HasLink()) return;
1839  delete anw;
1840  anw = nullptr;
1841  }
1842 
1843  anw = EstablishAnalysisWindow(true, false);
1844  if (anw) anw->WorkWithDebugOutput(serv->DebugOutputSlot());
1845  serv->ResetDebugOutputRequests();
1846 }
1847 
1848 
1849 TGo4AnalysisProxy *TGo4MainWindow::AddAnalysisProxy(bool isserver, bool needoutput)
1850 {
1851  const char *analisysitem = "Analysis";
1852 
1853  TGo4Slot *analslot = Browser()->DataSlot(analisysitem);
1854 
1855  if (!analslot) {
1856  TGo4AnalysisProxy *anal = new TGo4AnalysisProxy(isserver);
1857  fxOM->AddProxy(fOMDataPath.toLatin1().constData(), anal, analisysitem, "Analysis proxy");
1858  analslot = Browser()->DataSlot(analisysitem);
1859  anal->SetDefaultReceiver(fxOM, TString("gui/") + analisysitem + "/");
1860  }
1861 
1862  TGo4AnalysisProxy *anal = !analslot ? nullptr :
1863  dynamic_cast<TGo4AnalysisProxy *> (analslot->GetProxy());
1864 
1865  if (!anal) return nullptr;
1866 
1867  anal->SetAnalysisReady(kFALSE);
1868 
1869  TGo4LogInfo *loginfo = (TGo4LogInfo *) FindGo4Widget("LogInfo", false);
1870  if (loginfo)
1871  loginfo->WorkWithInfo(anal->LoginfoSlot());
1872 
1873  if (anal->IsAnalysisServer())
1874  EstablishRatemeter(anal->IsConnected() ? 2 : 0);
1875  else
1876  EstablishRatemeter(1);
1877 
1879 
1881 
1882  auto anw = FindAnalysisWindow();
1883  if (anw)
1884  if (anw->HasOutput() && !needoutput) {
1885  delete anw;
1886  anw = nullptr;
1887  }
1888 
1889  if(!anw) {
1890  if (needoutput) {
1891  anw = EstablishAnalysisWindow(true);
1892  if (anw) anw->WorkWithUpdateObjectCmd(anal->UpdateObjectSlot());
1893  } else {
1895  }
1896  }
1897 
1898  return anal;
1899 }
1900 
1901 bool TGo4MainWindow::RemoveAnalysisProxy(int waittime, bool servershutdown)
1902 {
1903  // Browser()->ToggleMonitoring(0);
1905  EstablishRatemeter(0);
1906 
1907  // TGo4AnalysisProxy *anal = Browser()->FindAnalysis();
1908  TGo4ServerProxy *srv = Browser()->FindServer();
1909  if (srv) {
1910  srv->DisconnectAnalysis(waittime, servershutdown);
1911  }
1912  // TGo4Slot *slot = Browser()->FindServerSlot(kTRUE, 1);
1913  // it is allowed to delete slot directly
1914  //if (slot) delete slot;
1915 
1916  return !Browser()->FindServer();
1917 }
1918 
1920 {
1922  TGo4AnalysisProxy *anal = Browser()->FindAnalysis();
1923 
1924  if (anw && anw->HasOutput()) return;
1925 
1926  bool shouldexists = false;
1927  if (anal) {
1928  if (anal->IsAnalysisServer()) {
1929  if (anal->IsConnected() && (anal->IsController() || anal->IsAdministrator()))
1930  shouldexists = true;
1931  } else {
1932  shouldexists = true;
1933  }
1934  }
1935 
1936  if (shouldexists && !anw) {
1937  anw = EstablishAnalysisWindow(false, !anal->IsAnalysisServer());
1938  if (anw) anw->WorkWithUpdateObjectCmd(anal->UpdateObjectSlot());
1939  }
1940 }
1941 
1942 TGo4AnalysisStatusMonitor* TGo4MainWindow::EstablishRatemeter(int level)
1943 {
1944  // level = 0 - delete
1945  // level = 1 - as is
1946  // level = 2 - create
1947  TGo4AnalysisStatusMonitor* status =
1948  dynamic_cast<TGo4AnalysisStatusMonitor*>
1949  (FindGo4Widget("AnalysisStatusMonitor", false));
1950 
1951  if (level == 2) {
1952  if (!status) {
1953  status = new TGo4AnalysisStatusMonitor(statusBar(), "AnalysisStatusMonitor");
1954  ConnectGo4Widget(status);
1955  statusBar()->addWidget(status);
1956  TGo4ServerProxy *serv = Browser()->FindServer();
1957  if (serv)
1958  status->WorkWithRatemeter(serv->RatemeterSlot());
1959  }
1960  } else if (level == 0) {
1961  if (status) {
1962  status->RemoveLink("Ratemeter",true); // JAM: need to remove the update link before deleting!
1963  statusBar()->removeWidget(status);
1964  delete status;
1965  }
1966  status = nullptr;
1967  }
1968 
1969  if (status)
1970  status->show();
1971 
1972  return status;
1973 }
1974 
1975 TGo4AnalysisConfiguration* TGo4MainWindow::EstablishAnalysisConfiguration(int level)
1976 {
1977  // level: 0 - delete, 1 - keep as is, 2 - create, 3 - create + request status
1978 
1979  TGo4AnalysisConfiguration* conf = FindAnalysisConfiguration();
1980 
1981  if (level == 0) {
1982  if (conf) {
1983  delete conf->parentWidget();
1984  conf = nullptr;
1985  }
1986  } else if (level >= 2) {
1987  if (!conf) {
1988  conf = new TGo4AnalysisConfiguration(fxMdiArea, "AnalysisConfiguration");
1989  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(conf);
1990  CascadeMdiPosition(sub);
1991  ConnectGo4Widget(conf);
1992  // ! do not show configuration window before analysis settings requested
1993  // conf->ensurePolished();
1994  // sub->show();
1995  }
1996  TGo4ServerProxy *anal = Browser()->FindServer();
1997  if (anal) {
1998  conf->WorkWithAnalysis(anal);
1999  if (level > 2) anal->RequestAnalysisSettings();
2000  }
2001  }
2002 
2003  return conf;
2004 }
2005 
2006 
2007 void TGo4MainWindow::ConnectServer(bool interactive, const char *password)
2008 {
2009  if (fConnectingCounter > 0) return;
2010  TGo4AnalysisProxy *anal = Browser()->FindAnalysis();
2011  if (anal) {
2012  if (anal->IsConnected() || !anal->IsAnalysisServer()) {
2013  if (interactive)
2014  QMessageBox::warning(this, "Connect client", "Analysis task is already connected");
2015  return;
2016  }
2017  }
2018 
2019  QString pass = password;
2020  if (interactive) {
2021  TGo4ConnectServer dlg;
2022  if (fLastPassword.length() > 0)
2023  dlg.setPassword(fLastPassword.toLatin1().constData());
2024  if (dlg.exec()!=QDialog::Accepted) return;
2025  pass = dlg.getInput();
2026  }
2027  // here check if we want web server or regular connection:
2028 
2029  if(go4sett->getClientConnectMode() == 0) {
2030  if (!anal) anal = AddAnalysisProxy(true, false);
2031  bool def = go4sett->getClientDefaultPass();
2032  if (!def) fLastPassword = pass;
2033 
2034  if (anal)
2035  anal->ConnectToServer(go4sett->getClientNode().toLatin1().constData(),
2038  def ? nullptr : pass.toLatin1().constData());
2039  StatusMessage("Connecting running analysis.... Please wait");
2040 
2041  // wait about 4 sec that analysis is connected
2042  fConnectingCounter = 41;
2045  } else {
2046  QString fulladdress = go4sett->getClientNode();
2047  if ((go4sett->getClientPort() > 0) && (go4sett->getClientPort() != 80)) {
2048  QString portstring;
2049  portstring.setNum(go4sett->getClientPort());
2050  fulladdress.append(":");
2051  fulladdress.append(portstring);
2052  }
2053  QString msg("Connecting analysis http server at ");
2054  msg.append(fulladdress).append(QString(", Please wait"));
2055  StatusMessage(msg);
2056  ConnectHttpServer(fulladdress.toLatin1().constData(),
2057  go4sett->getClientAccountName().toLatin1().constData(),
2058  pass.toLatin1().constData(), false, false);
2060  }
2061 }
2062 
2064 {
2065  if (fConnectingHttp.length() > 0) {
2066  TGo4ServerProxy *serv =
2067  ConnectHttpServer(fConnectingHttp.toLatin1().constData(), nullptr, nullptr, go4sett->getClientTermMode() == 1, fbGetAnalysisConfig);
2068  if (serv) {
2069  serv->SetAnalysisLaunched(go4sett->getClientTermMode()==1 ? 2 : 1);
2070  fConnectingHttp = "";
2071  fConnectingCounter = 0;
2072  fbGetAnalysisConfig=false;
2073  return;
2074  }
2075  if (--fConnectingCounter <= 0) {
2076  StatusMessage(fConnectingHttp + " refused connection. Try again");
2077  fConnectingHttp = "";
2078  fConnectingCounter = 0;
2079  fbGetAnalysisConfig=false;
2080  return;
2081  }
2082  } else {
2083  TGo4AnalysisProxy *anal = Browser()->FindAnalysis();
2084  if (!anal || anal->IsConnected() || (--fConnectingCounter <= 0)) {
2085  if (fConnectingCounter <= 0)
2086  StatusMessage("Analysis refused connection. Try again");
2087  fConnectingCounter = 0;
2088  EstablishRatemeter(anal && anal->IsConnected() ? 2 : 0);
2089  int level = 0;
2090  if (anal && anal->IsConnected() && (anal->IsController() || anal->IsAdministrator())) {
2091  if (fbGetAnalysisConfig) {
2092  level = 3;
2093  fbGetAnalysisConfig = false;
2094  } else {
2095  level = 2;
2096  }
2097  }
2101  if (anal && !anal->IsConnected()) RemoveAnalysisProxy(1);
2102  return;
2103  }
2104  }
2105  QTimer::singleShot(100, this, &TGo4MainWindow::CheckConnectingCounterSlot);
2106 }
2107 
2109 {
2110  TGo4ServerProxy *serv = Browser()->FindServer();
2111  if (!serv) return;
2112 
2113  bool shutdown = serv->IsAnalysisLaunched() > 1;
2114 
2115  if (interactive) {
2116 
2117  if (shutdown) {
2118 
2119  QMessageBox msgBox(QMessageBox::Warning,
2120  "Disconnect from analysis",
2121  "Analysis runs inside go4 widget.\n"
2122  "If one only disconnects from the analysis,\n"
2123  "it remains invisible and difficult to stop.\n"
2124  "To shutdown it later, one need to reconnect with go4 gui again.\n"
2125  "It is recommended to shutdown analysis now");
2126 
2127  auto btnShutdown = msgBox.addButton("Shutdown", QMessageBox::DestructiveRole);
2128  auto btnDisconnect = msgBox.addButton("Disconnect", QMessageBox::ActionRole);
2129  auto btnCancel = msgBox.addButton("Cancel", QMessageBox::RejectRole);
2130  msgBox.setDefaultButton(btnShutdown);
2131 
2132  msgBox.exec();
2133  if (msgBox.clickedButton() == btnCancel)
2134  return;
2135  else if (msgBox.clickedButton() == btnShutdown)
2136  shutdown = true;
2137  else if (msgBox.clickedButton() == btnDisconnect)
2138  shutdown = false;
2139  } else {
2140  QMessageBox msgBox(QMessageBox::Question, "Disconnect analysis", "Really disconnect from analysis task?");
2141 
2142  auto btnDisconnect = msgBox.addButton("Disconnect", QMessageBox::DestructiveRole);
2143  auto btnCancel = msgBox.addButton("Cancel", QMessageBox::RejectRole);
2144  msgBox.setDefaultButton(btnDisconnect);
2145 
2146  msgBox.exec();
2147  if (msgBox.clickedButton() == btnCancel)
2148  return;
2149  }
2150  }
2151  RemoveAnalysisProxy(30, shutdown);
2152  StatusMessage("Disconnect analysis");
2153 }
2154 
2155 void TGo4MainWindow::ShutdownAnalysis(bool interactive)
2156 {
2157  if (interactive) {
2158  QMessageBox msgBox(QMessageBox::Question, "Shutdown analysis", "Really shutdown analysis task?");
2159 
2160  auto btnShutdown = msgBox.addButton("Shutdown", QMessageBox::DestructiveRole);
2161  auto btnCancel = msgBox.addButton("Cancel", QMessageBox::RejectRole);
2162  msgBox.setDefaultButton(btnShutdown);
2163 
2164  msgBox.exec();
2165  if (msgBox.clickedButton() == btnCancel)
2166  return;
2167  }
2168  TGo4ServerProxy *serv = Browser()->FindServer();
2169  if (!serv) return;
2170  bool realshutdown = false;
2171  TGo4AnalysisProxy *anal = dynamic_cast<TGo4AnalysisProxy *>(serv);
2172  TGo4HttpProxy *http = dynamic_cast<TGo4HttpProxy *>(serv);
2173  if (anal)
2174  realshutdown = anal->IsAnalysisServer() &&
2175  anal->IsConnected() &&
2176  anal->IsAdministrator();
2177  else if (http)
2178  realshutdown = http->IsConnected() && http->IsAdministrator();
2179 
2180  RemoveAnalysisProxy(30, realshutdown);
2181  StatusMessage("Shutdown analysis");
2182 }
2183 
2185 {
2186  TGo4ServerProxy *serv = Browser()->FindServer();
2187  if (!serv) return false;
2188 
2189  if (serv->IsConnected() && serv->CanSubmitObjects() &&
2190  (serv->IsAdministrator() || serv->IsController())) {
2191  serv->SubmitAnalysisSettings();
2192  serv->RefreshNamesList();
2193  StatusMessage("Press Ctrl+S or choose Analysis->Start from the Menu to start the analysis");
2194  return true;
2195  }
2196 
2197  return false;
2198 }
2199 
2201 {
2202  if (SubmitAnalysisSettings())
2204 }
2205 
2207 {
2208  TGo4ServerProxy *go4_serv = Browser()->FindServer();
2209  if (go4_serv) {
2210  go4_serv->StartAnalysis();
2211  go4_serv->RefreshNamesList();
2212  go4_serv->DelayedRefreshNamesList(4);
2213  EstablishRatemeter(2);
2214  } else {
2215  TGo4ServerProxy *root_serv = Browser()->FindServer(nullptr, kFALSE);
2216  if (root_serv) {
2217  TString cmd = root_serv->FindCommand("Start");
2218  if (cmd.Length() > 0) {
2219  root_serv->SubmitCommand(cmd);
2220  StatusMessage(TString::Format("Submit %s command to the server", cmd.Data()).Data());
2221  }
2222  }
2223  }
2224 }
2225 
2227 {
2228  TGo4ServerProxy *go4_serv = Browser()->FindServer();
2229  if (go4_serv) {
2230  go4_serv->StopAnalysis();
2231  } else {
2232  TGo4ServerProxy *root_serv = Browser()->FindServer(nullptr, kFALSE);
2233  if (root_serv) {
2234  TString cmd = root_serv->FindCommand("Stop");
2235  if (cmd.Length()>0) {
2236  root_serv->SubmitCommand(cmd);
2237  StatusMessage(TString::Format("Submit %s command to the server", cmd.Data()).Data());
2238  }
2239  }
2240  }
2241 }
2242 
2244 {
2245  if (interactive) {
2246  QMessageBox msgBox(QMessageBox::Question, "Kill analysis process",
2247  QString("Kill analysis by shell command: ") +fKillCommand + " ?");
2248 
2249  auto btnKill = msgBox.addButton("Kill", QMessageBox::DestructiveRole);
2250  auto btnCancel = msgBox.addButton("Cancel", QMessageBox::RejectRole);
2251  msgBox.setDefaultButton(btnKill);
2252 
2253  msgBox.exec();
2254  if (msgBox.clickedButton() == btnCancel)
2255  return;
2256  }
2257 
2259  if (anw) anw->TerminateAnalysisProcess();
2260 
2261  // proxy will be deleted after 7 seconds
2262  //RemoveAnalysisProxy(7);
2263 
2264  anw = FindAnalysisWindow();
2265  if (anw)
2266  anw->AppendOutputBuffer(QString("\nKilling analysis client: \n ")+fKillCommand, 2);
2267  else
2268  StatusMessage(QString("Killing analysis client with: ")+fKillCommand);
2269 
2270  if (fKillCommand.length() > 0) {
2271  QProcess* killprocess = new QProcess;
2272  QStringList args;
2273  QString progname = fKillCommand;
2274  TGo4AnalysisWindow::ExtractProgArgs(progname, args);
2275  killprocess->start(progname, args);
2276  QTimer::singleShot(10000, killprocess, &QProcess::deleteLater);
2277  } else
2278  StatusMessage("Can not kill analysis. Do it by OS commands");
2279 
2281 
2282  EstablishRatemeter(0);
2283 }
2284 
2285 QGo4Widget* TGo4MainWindow::FindGo4Widget(const char *name, bool activate)
2286 {
2287  if (!fxOM) return nullptr;
2288 
2289  TGo4Slot *slot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
2290 
2291  TGo4Slot *widgslot = !slot ? nullptr : slot->FindChild(name);
2292  if (!widgslot) return nullptr;
2293 
2294  TGo4WidgetProxy *wproxy = (TGo4WidgetProxy*) widgslot->GetProxy();
2295 
2296  QGo4Widget *widg = wproxy->GetWidget();
2297  if (widg && activate) {
2298  if(!widg->isVisible()){
2299  widg->raise();
2300  widg->show();
2301  widg->setFocus();
2302  }
2303  }
2304 
2305  return widg;
2306 }
2307 
2309 {
2310  TGo4FitPanel *fitpanel = (TGo4FitPanel*) FindGo4Widget("FitPanel", true);
2311 
2312  if (!fitpanel) {
2313  fitpanel = new TGo4FitPanel(fxMdiArea,"FitPanel");
2314  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(fitpanel);
2315  CascadeMdiPosition(sub);
2316  ConnectGo4Widget(fitpanel);
2317  fitpanel->ensurePolished();
2318  sub->show();
2319  } else {
2320  fitpanel->parentWidget()->showNormal();
2321  fitpanel->setFocus();
2322  }
2323  return fitpanel;
2324 }
2325 
2327 {
2328  TGo4HistogramInfo* hinfo = (TGo4HistogramInfo*) FindGo4Widget("HistogramInfo", true);
2329  if (!hinfo) {
2330  hinfo = new TGo4HistogramInfo(fxMdiArea, "HistogramInfo");
2331  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(hinfo);
2332  CascadeMdiPosition(sub);
2333  ConnectGo4Widget(hinfo);
2334  hinfo->ensurePolished();
2335  hinfo->adjustSize();
2336  sub->show();
2337  }
2338  return hinfo;
2339 }
2340 
2342 {
2343  TGo4ConditionInfo* cinfo = (TGo4ConditionInfo*) FindGo4Widget("ConditionInfo", true);
2344  if (!cinfo) {
2345  cinfo = new TGo4ConditionInfo(fxMdiArea, "ConditionInfo");
2346  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(cinfo);
2347  CascadeMdiPosition(sub);
2348  ConnectGo4Widget(cinfo);
2349  cinfo->ensurePolished();
2350  cinfo->adjustSize();
2351  sub->show();
2352  }
2353  return cinfo;
2354 }
2355 
2357 {
2358  TGo4LoadedLibraries llib(this);
2359  llib.exec();
2360 
2361  UpdateBrowser();
2362 }
2363 
2365 {
2366  TGo4Browser* br = (TGo4Browser*) FindGo4Widget("Browser", false);
2367  if (br) br->ShootUpdateTimer();
2368 }
2369 
2370 TGo4ParaEdit* TGo4MainWindow::StartParaEdit(const char *itemname)
2371 {
2372  TGo4ParaEdit* pedit = (TGo4ParaEdit*) FindGo4Widget("ParaEdit", true);
2373 
2374  if (itemname) {
2375  TClass *cl = Browser()->ItemClass(itemname);
2376  if (cl)
2377  if (!cl->IsLoaded()) {
2378  QMessageBox::warning(nullptr, "Parameter editor", QString("Cannot start parameter editor for incomplete class ") + cl->GetName());
2379  return pedit;
2380  }
2381  }
2382 
2383  if (!pedit) {
2384  pedit = new TGo4ParaEdit(fxMdiArea, "ParaEdit");
2385  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(pedit);
2386  ConnectGo4Widget(pedit);
2387  pedit->ensurePolished();
2388  sub->show();
2389  CascadeMdiPosition(sub);
2390  }
2391 
2392  if (itemname)
2393  pedit->WorkWithParameter(itemname, false);
2394 
2395  return pedit;
2396 }
2397 
2399 {
2400  TGo4EditDynEntry* dedit = (TGo4EditDynEntry*) FindGo4Widget("EditDynEntry", true);
2401 
2402  if (!dedit) {
2403  dedit = new TGo4EditDynEntry(fxMdiArea, "EditDynEntry");
2404  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(dedit);
2405  CascadeMdiPosition(sub);
2406  ConnectGo4Widget(dedit);
2407  dedit->ensurePolished();
2408  sub->show();
2409  }
2410 
2411  return dedit;
2412 }
2413 
2415 {
2416  TGo4ConditionEditor* wedit = (TGo4ConditionEditor*) FindGo4Widget("ConditionEditor", true);
2417  if (!wedit) {
2418  wedit = new TGo4ConditionEditor(fxMdiArea, "ConditionEditor");
2419  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(wedit);
2420  CascadeMdiPosition(sub);
2421  ConnectGo4Widget(wedit);
2422  wedit->ensurePolished();
2423  sub->show();
2424  }
2425  return wedit;
2426 }
2427 
2429 {
2430  TGo4EventInfo* einfo = (TGo4EventInfo*) FindGo4Widget("EventInfo", true);
2431 
2432  if (!einfo) {
2433  einfo = new TGo4EventInfo(fxMdiArea, "EventInfo");
2434  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(einfo);
2435  CascadeMdiPosition(sub);
2436  ConnectGo4Widget(einfo);
2437  einfo->ensurePolished();
2438  sub->show();
2439  }
2440 
2441  return einfo;
2442 }
2443 
2444 TGo4AnalysisConfiguration* TGo4MainWindow::FindAnalysisConfiguration()
2445 {
2446  return (TGo4AnalysisConfiguration *) FindGo4Widget("AnalysisConfiguration", false);
2447 }
2448 
2450 {
2451  TGo4AnalysisConfiguration* conf = FindAnalysisConfiguration();
2452  QWidget *mdi = conf ? conf->parentWidget() : nullptr;
2453 
2454  if (!mdi)
2455  return;
2456 
2457  if (mdi->isVisible()) {
2458  mdi->hide();
2459  } else {
2460  if (conf->GetNumSteps() == 0) {
2461  // this can happen when gui connected to server without requesting the setup. Do it when user wants to see
2462  // config:
2463  TGo4ServerProxy *anal = Browser()->FindServer();
2464  if (anal)
2465  anal->RequestAnalysisSettings();
2466  }
2467  mdi->raise();
2468  mdi->show();
2469  if (mdi->isMinimized())
2470  mdi->showNormal();
2471  }
2472 }
2473 
2475 {
2476  return (TGo4AnalysisWindow *) FindGo4Widget("AnalysisWindow", false);
2477 }
2478 
2480 {
2482  if (!anw) return;
2483 
2484  if (anw->HasOutput()) {
2485  QWidget *mdi = anw->parentWidget();
2486 
2487  if (mdi->isVisible()) {
2488  mdi->hide();
2489  } else {
2490  mdi->raise();
2491  mdi->show();
2492  if (mdi->isMinimized()) mdi->showNormal();
2493  }
2494  } else {
2495  QToolBar* dock = dynamic_cast<QToolBar*> (anw->parentWidget());
2496  if (dock->isVisible())
2497  dock->hide();
2498  else
2499  dock->show();
2500  }
2501 }
2502 
2504 {
2506 
2507  if (anw) {
2508  if (anw->HasOutput()) {
2509  anw->parentWidget()->close();
2510  } else {
2511  QToolBar* bar = dynamic_cast<QToolBar*> (anw->parentWidget());
2512  removeToolBar(bar);
2513  delete bar;
2514  }
2515  }
2516 
2517  // try to reestablish window for other server
2518  QTimer::singleShot(250, [this]() { EstablishAnalysisWindowForHttp(); });
2519 }
2520 
2521 
2522 void TGo4MainWindow::ToggleMbsMonitor(const char *nodename)
2523 {
2524  TGo4MBSViewer *mbs = dynamic_cast<TGo4MBSViewer *>(FindGo4Widget("MBSViewer", false));
2525  if (!mbs)
2526  return;
2527  if (mbs->parentWidget()->isVisible()) {
2528  mbs->parentWidget()->hide();
2529  } else {
2530  mbs->SetNode(nodename);
2531  mbs->parentWidget()->show();
2532  }
2533 }
2534 
2536 {
2537  TGo4SetScaleValues* scl = nullptr;
2538 
2539  QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
2540  for (int i = 0; i < windows.count(); ++i) {
2541  scl = dynamic_cast<TGo4SetScaleValues *>(windows.at(i)->widget());
2542  if (scl) break;
2543  }
2544 
2545  if (!scl) {
2546  scl = new TGo4SetScaleValues(fxMdiArea, "ScaleValues", Qt::WindowStaysOnTopHint);
2547  QMdiSubWindow* sub = fxMdiArea->AddGo4SubWindow(scl);
2548  CascadeMdiPosition(sub);
2549  scl->ensurePolished();
2550  sub->show();
2551  } else {
2552  scl->parentWidget()->close();
2553  scl = nullptr;
2554  }
2555  return scl;
2556 }
2557 
2559 {
2560  TGo4CreateNewHistogram dlg(this);
2561  TGo4ServerProxy *an = Browser()->FindServer();
2562 
2563  dlg.SetAnalysisAvaliable((isremote != 0) && an && an->IsAnalysisSettingsReady());
2564  dlg.SetLocalAvaliable(isremote != 1);
2565 
2566  if (dlg.exec() != QDialog::Accepted) return;
2567  TH1 *h1 = dlg.MakeHistogram();
2568  if (!h1) return;
2569 
2571 
2572  if (dlg.GetSelectedCmd()==1) {
2573  TString newitem = Browser()->SaveToMemory("", h1, kTRUE);
2574 
2575  if (newitem.Length()>0)
2576  editorServiceSlot(anw,
2578  newitem.Data(), h1->IsA());
2579  h1 = nullptr;
2580  } else
2581  if ((dlg.GetSelectedCmd() == 2) && an) {
2582  h1->SetBit(TGo4Status::kGo4CanDelete);
2583  an->UpdateAnalysisObject("", h1);
2584  if (anw) anw->WaitForNewObject(isremote==1);
2585  else an->RefreshNamesList();
2586  }
2587  if (h1) delete h1;
2588 }
2589 
2590 void TGo4MainWindow::CreateNewCondition(bool forothereditor)
2591 {
2592  TGo4ServerProxy *an = Browser()->FindServer();
2593  if (!an || !an->IsAnalysisSettingsReady()) {
2594  QMessageBox::information(this,"Create new condition","Cannot create new condition before analysis setup");
2595  return;
2596  }
2597 
2598  TGo4CreateNewCondition dlg(this);
2599 
2600  if (dlg.exec() != QDialog::Accepted) return;
2601 
2602  TGo4Condition *cond = dlg.MakeCondition();
2603  if (!cond) return;
2604 
2605  cond->SetBit(TGo4Status::kGo4CanDelete);
2606  an->UpdateAnalysisObject("", cond);
2607  delete cond;
2608 
2610  if(anw) anw->WaitForNewObject(forothereditor);
2611  else an->RefreshNamesList();
2612 }
2613 
2614 void TGo4MainWindow::CreateNewDynEntry(bool forothereditor)
2615 {
2616  TGo4ServerProxy *an = Browser()->FindServer();
2617  if (!an || !an->IsAnalysisSettingsReady()) {
2618  QMessageBox::information(this,"Create new dynamic entry","Cannot create new entry before analysis setup");
2619  return;
2620  }
2621 
2622  TGo4CreateNewDynEntry dlg(this);
2623 
2624  if (dlg.exec() != QDialog::Accepted) return;
2625 
2626  TGo4DynamicEntry *entry = dlg.MakeEntry();
2627  if (!entry) return;
2628 
2629  entry->SetBit(TGo4Status::kGo4CanDelete);
2630  an->UpdateAnalysisObject("", entry);
2631  delete entry;
2632 
2634  if (anw) anw->WaitForNewObject(forothereditor);
2635  else an->RefreshNamesList();
2636 }
2637 
2639 {
2640  if (!editor) return;
2641  QObject::connect(editor, &QGo4Widget::widgetService, this, &TGo4MainWindow::editorServiceSlot);
2642  GetWidgetTopSlot(editor, true);
2643 }
2644 
2645 TGo4ViewPanel *TGo4MainWindow::DisplayBrowserItem(const char *itemname, TGo4ViewPanel *panel, TPad *pad, bool activate, int updatelevel, const char *drawopt)
2646 {
2647  TGo4BrowserProxy *br = Browser();
2648  if (!br || !itemname || strlen(itemname) == 0) return nullptr;
2649 
2650  TGo4Slot *guislot = br->BrowserSlot(itemname);
2651 
2652  if (!guislot) return nullptr;
2653  if (!guislot->GetProxy()) {
2654  std::cerr << " Problem with gui slots" << std::endl;
2655  return nullptr;
2656  }
2657 
2658  if (!panel) {
2659  panel = MakeNewPanel();
2660  pad = panel->GetCanvas();
2661  } else if (!pad)
2662  pad = panel->GetActivePad();
2663 
2664  if (!panel->AddDrawObject(pad, TGo4ViewPanel::kind_Link, itemname, nullptr, false, drawopt)) return nullptr;
2665 
2666  if (activate) {
2667  panel->SetActivePad(pad);
2668  panel->ShootRepaintTimer();
2669  }
2670 
2671  if (updatelevel < 0) {
2673  updatelevel = 2;
2674  else
2675  updatelevel = 1;
2676  }
2677 
2678  br->GetBrowserObject(itemname, updatelevel);
2679 
2680  return panel;
2681 }
2682 
2683 bool TGo4MainWindow::SaveBrowserItemToFile(const char *itemname, const char *subfolder)
2684 {
2685  TGo4BrowserProxy *br = Browser();
2686  if (!br || !itemname) return false;
2687 
2688  TString fileslotname;
2689  const char *filepath = nullptr;
2690 
2691  bool res = false;
2692 
2693  if (br->DefineFileObject(itemname, fileslotname, &filepath)) {
2694  QMessageBox msgBox(QMessageBox::Question, "Writing object to file",
2695  QString("Overwrite ") + filepath + " in file " + fileslotname.Data());
2696  auto btnOverwrite = msgBox.addButton("Overwrite", QMessageBox::ActionRole);
2697  /* auto btnOther = */ msgBox.addButton("Save to other file", QMessageBox::ActionRole);
2698  auto btnCancel = msgBox.addButton("Cancel", QMessageBox::RejectRole);
2699  msgBox.setDefaultButton(btnOverwrite);
2700  msgBox.exec();
2701  if (msgBox.clickedButton() == btnCancel)
2702  return false;
2703  if (msgBox.clickedButton() == btnOverwrite)
2704  res = br->UpdateObjectInFile(itemname, fileslotname.Data(), filepath);
2705  }
2706 
2707  if (!res) {
2708  QString root_fmt = "ROOT (*.root)";
2709  QString xml_fmt = "ROOT XML (*.xml)";
2710 
2711  QFileDialog fd(this, QString("Save ") + itemname + " in root file", fLastFileDir);
2712  fd.setFileMode(QFileDialog::AnyFile);
2713  fd.setAcceptMode(QFileDialog::AcceptSave);
2714  fd.setNameFilters(QStringList() << root_fmt << xml_fmt);
2715 
2716  if (fd.exec() == QDialog::Accepted) {
2717  QStringList flst = fd.selectedFiles();
2718  if (!flst.isEmpty()) {
2719  QString filename = flst[0];
2720  if (fd.selectedNameFilter()==xml_fmt) {
2721  if (!filename.endsWith(".xml")) filename.append(".xml");
2722  } else {
2723  if (!filename.endsWith(".root")) filename.append(".root");
2724  }
2725  res = br->SaveItemToFile(itemname, filename.toLatin1().constData(), subfolder);
2726  fLastFileDir = fd.directory().path();
2727  }
2728  }
2729  }
2730 
2731  return res;
2732 }
2733 
2734 void TGo4MainWindow::SavePanelCanvas(TGo4ViewPanel *panel)
2735 {
2736  if (!panel) return;
2737 
2738  TCanvas *can = panel->GetCanvas();
2739 
2740  QFileDialog fd( this, QString("Save ") + panel->objectName() + " As", fLastFileDir);
2741  fd.setFileMode( QFileDialog::AnyFile );
2742  fd.setAcceptMode(QFileDialog::AcceptSave);
2743 
2744  QString PS = "Post Script (*.ps)";
2745  QString PS_Portrait = "Post Script Portrait (*.ps)";
2746  QString PS_Landscape = "Post Script Landscape (*.ps)";
2747  QString EPS = "Encapsulated Post Script (*.eps)";
2748  QString EPS_Preview = "Encapsulated Post Script preview (*.eps)";
2749  QString GIF = "GIF format (*.gif)";
2750  QString PDF = "PDF format (*.pdf)";
2751  QString SVG = "SVG format (*.svg)";
2752  QString XPM = "XPM format (*.xpm)";
2753  QString PNG = "PNG format (*.png)";
2754  QString JPG = "JPG format (*.jpg)";
2755  QString TIFF = "TIFF format (*.tiff)";
2756 
2757  QString CXXM = "C++ Macro (*.C)";
2758  QString JSONM = "json file (*.json)";
2759  QString ROOTM = "root file (*.root)";
2760 
2761  QStringList flt;
2762 
2763  flt << PS;
2764  flt << PS_Portrait;
2765  flt << PS_Landscape;
2766  flt << EPS;
2767  flt << EPS_Preview;
2768  flt << PDF;
2769  flt << SVG;
2770  flt << GIF;
2771 
2772  flt << XPM;
2773  flt << PNG;
2774  flt << JPG;
2775  flt << TIFF;
2776 
2777  flt << CXXM;
2778  flt << JSONM;
2779  flt << ROOTM;
2780 
2781  fd.setNameFilters(flt);
2782 
2783  if (fd.exec() != QDialog::Accepted) return;
2784 
2785 
2786  bool blankbg = go4sett->getSavePadWhiteBackground();
2787  if(blankbg) {
2788  can = (TCanvas *) panel->GetCanvas()->Clone();
2789  can->SetName("PrintoutPad");
2790  }
2791  QStringList flst = fd.selectedFiles();
2792  if (flst.isEmpty()) return;
2793 
2794  QString filename = flst[0];
2795  QString filter = fd.selectedNameFilter();
2796 
2797  fLastFileDir = fd.directory().path();
2798 
2799  const char *opt = "ps";
2800 
2801  if (filter == EPS) {
2802  opt = "eps";
2803  if (!filename.endsWith(".eps"))
2804  filename.append(".eps");
2805  } else if (filter == EPS_Preview) {
2806  opt = "Preview";
2807  if (!filename.endsWith(".eps"))
2808  filename.append(".eps");
2809  } else if (filter == PS) {
2810  opt = "ps";
2811  if (!filename.endsWith(".ps"))
2812  filename.append(".ps");
2813  } else if (filter == PS_Portrait) {
2814  opt = "Portrait";
2815  if (!filename.endsWith(".ps"))
2816  filename.append(".ps");
2817  } else if (filter == PS_Landscape) {
2818  opt = "Landscape";
2819  if (!filename.endsWith(".ps"))
2820  filename.append(".ps");
2821  } else if (filter == GIF) {
2822  opt = "gif";
2823  if (!filename.endsWith(".gif"))
2824  filename.append(".gif");
2825  } else if (filter == PDF) {
2826  opt = "pdf";
2827  if (!filename.endsWith(".pdf"))
2828  filename.append(".pdf");
2829  } else if (filter == SVG) {
2830  opt = "svg";
2831  if (!filename.endsWith(".svg"))
2832  filename.append(".svg");
2833  } else if (filter == XPM) {
2834  opt = "xpm";
2835  if (!filename.endsWith(".xpm"))
2836  filename.append(".xpm");
2837  } else if (filter == PNG) {
2838  opt = "png";
2839  if (!filename.endsWith(".png"))
2840  filename.append(".png");
2841  } else if (filter == JPG) {
2842  opt = "jpg";
2843  if (!filename.endsWith(".jpg"))
2844  filename.append(".jpg");
2845  } else if (filter == TIFF) {
2846  opt = "tiff";
2847  if (!filename.endsWith(".tiff"))
2848  filename.append(".tiff");
2849  } else if (filter == CXXM) {
2850  opt = "cxx";
2851  if (!filename.endsWith(".C"))
2852  filename.append(".C");
2853  } else if (filter == JSONM) {
2854  opt = "json";
2855  if (!filename.endsWith(".json"))
2856  filename.append(".json");
2857  } else if (filter == ROOTM) {
2858  opt = "root";
2859  if (!filename.endsWith(".root"))
2860  filename.append(".root");
2861  }
2862 
2863  if(blankbg) {
2864  panel->ResetPadFillColors(can,0);
2865  gROOT->SetBatch(kTRUE); // force ROOT to make memory print of canvas instead of using actual window display for image formats.
2866  }
2867 
2868  can->Print(filename.toLatin1().constData(), opt);
2869 
2870  if(blankbg) {
2871  gROOT->SetBatch(kFALSE);
2872  delete can;
2873  }
2874 }
2875 
2877 {
2878  return fxOM;
2879 }
2880 
2882 {
2883  return (TGo4BrowserProxy *) fxOM->GetProxy(fOMBrowserPath.toLatin1().constData());
2884 }
2885 
2887 {
2888  if (!widget) return nullptr;
2889 
2890  QString EditorName = widget->objectName();
2891 
2892  QString editorslotname = fOMEditorsPath;
2893  editorslotname += "/";
2894  editorslotname += EditorName;
2895  TGo4Slot *edslot = fxOM->GetSlot(editorslotname.toLatin1().constData());
2896  if (!edslot && force) {
2897  fxOM->AddProxy(fOMEditorsPath.toLatin1().constData(), new TGo4WidgetProxy(widget), EditorName.toLatin1().constData(), "Links for Go4 widget");
2898  edslot = fxOM->GetSlot(editorslotname.toLatin1().constData());
2899  }
2900  return edslot;
2901 }
2902 
2904 {
2905  // block monitoring when start panel updates
2906  Browser()->SetMonitorBlockingFlag(kTRUE);
2907 
2908  fbPanelTimerActive = false;
2909 
2910  // first check if active viewpnael need update its content
2911  TGo4ViewPanel *actpanel = fxMdiArea->GetActivePanel();
2912  if (actpanel && actpanel->IsRepaintTimerActive())
2913  actpanel->checkRepaintSlot();
2914 
2915  if (fbPanelTimerActive) return;
2916 
2917  // now check if any other panel shold be repainted
2918  TGo4Slot *topslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
2919  for (int n = 0; n < topslot->NumChilds(); n++) {
2920  TGo4Slot *subslot = topslot->GetChild(n);
2921 
2922  TGo4WidgetProxy *wproxy =
2923  dynamic_cast<TGo4WidgetProxy*> (subslot->GetProxy());
2924  if (!wproxy) continue;
2925 
2926  TGo4ViewPanel *panel =
2927  dynamic_cast<TGo4ViewPanel *> (wproxy->GetWidget());
2928 
2929  if (panel && (panel != actpanel))
2930  if (panel->IsRepaintTimerActive()) {
2931  panel->checkRepaintSlot();
2932  if (fbPanelTimerActive) return;
2933  }
2934  }
2935 
2936  // enable monitoring only when all drawing are finished
2937  Browser()->SetMonitorBlockingFlag(kFALSE);
2938 }
2939 
2940 void TGo4MainWindow::editorServiceSlot(QGo4Widget* editor, int serviceid, const char *str, void *par)
2941 {
2942  if (!editor) return;
2943 
2944  TGo4LockGuard lock;
2945 
2946  TGo4Slot *edslot = GetWidgetTopSlot(editor, false);
2947  if (!edslot) return;
2948 
2949  switch (serviceid) {
2951  QDragMoveEvent *event = (QDragMoveEvent *) par;
2952  if (!event || !event->mimeData()->hasText()) return;
2953 
2954  QString eventstr = event->mimeData()->text();
2955 
2956  bool accept = false;
2957  if (event->source() == FindGo4Widget("Browser",false)) {
2958  int kind = Browser()->ItemKind(eventstr.toLatin1().constData());
2959  TClass *cl = Browser()->ItemClass(eventstr.toLatin1().constData());
2960  accept = editor->IsAcceptDrag(eventstr.toLatin1().constData(), cl, kind);
2961  }
2962 
2963  if (accept) event->acceptProposedAction();
2964  break;
2965  }
2966 
2968  QDropEvent *event = (QDropEvent *) par;
2969 
2970  if (!event || !event->mimeData()->hasText()) return;
2971 
2972  QString eventstr = event->mimeData()->text();
2973  event->acceptProposedAction();
2974 
2975  if (event->source() == FindGo4Widget("Browser",false)) {
2976  int kind = Browser()->ItemKind(eventstr.toLatin1().constData());
2977  TClass *cl = Browser()->ItemClass(eventstr.toLatin1().constData());
2978 
2979  auto panel = dynamic_cast<TGo4ViewPanel *>(editor);
2980  auto fitpanel = dynamic_cast<TGo4FitPanel *>(editor);
2981  if (panel)
2982  panel->DropOnPad((TPad *)str, eventstr.toLatin1().constData(), cl, kind);
2983  else if (fitpanel)
2984  fitpanel->DropOnPanel(event, eventstr.toLatin1().constData(), cl, kind);
2985  else
2986  editor->DropItem(eventstr.toLatin1().constData(), cl, kind);
2987  }
2988  break;
2989  }
2990 
2992  TClass *cl = (TClass *) par;
2993  int id = str ? QString(str).toInt() : 0;
2994  if (cl) {
2995  if (cl->InheritsFrom(TH1::Class()))
2996  CreateNewHist(id);
2997  else if (cl->InheritsFrom(TGo4Condition::Class()) && (id != 0))
2998  CreateNewCondition(id==1);
2999  else if (cl->InheritsFrom(TGo4DynamicEntry::Class()) && (id != 0))
3000  CreateNewDynEntry(id==1);
3001  }
3002  break;
3003  }
3005  void ** res = (void **) par;
3006  res[0] = DisplayBrowserItem(str, (TGo4ViewPanel *) res[0], (TPad *) res[1], *((bool *)res[2]), *((int *) res[3]), nullptr);
3007  break;
3008  }
3009 
3011  TGo4ViewPanel **res = (TGo4ViewPanel **) par;
3012  *res = nullptr;
3013  TGo4Slot *topslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
3014  for (int n = 0; n < topslot->NumChilds(); n++) {
3015  TGo4Slot *subslot = topslot->GetChild(n);
3016 
3017  TGo4WidgetProxy *wproxy =
3018  dynamic_cast<TGo4WidgetProxy *> (subslot->GetProxy());
3019  if (!wproxy) continue;
3020 
3021  TGo4ViewPanel *panel =
3022  dynamic_cast<TGo4ViewPanel *> (wproxy->GetWidget());
3023 
3024  if (panel)
3025  if (panel->FindPadWithItem(str)) {
3026  *res = panel;
3027  break;
3028  }
3029  }
3030  break;
3031  }
3032 
3034  TGo4Slot *topslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
3035 
3036  for (int n = 0; n < topslot->NumChilds(); n++) {
3037  TGo4Slot *subslot = topslot->GetChild(n);
3038 
3039  auto wproxy = dynamic_cast<TGo4WidgetProxy *> (subslot->GetProxy());
3040  if (!wproxy) continue;
3041 
3042  auto panel = dynamic_cast<TGo4ViewPanel *> (wproxy->GetWidget());
3043  if (panel)
3044  panel->UndrawItemOnPanel(str);
3045  }
3046 
3047  break;
3048  }
3049 
3051  TClass *cl = Browser()->ItemClass(str);
3052  Int_t kind = Browser()->ItemKind(str);
3053 
3054  if (kind == TGo4Access::kndGo4Param) {
3055  StartParaEdit(str);
3056  break;
3057  } else if (kind==TGo4Access::kndTreeLeaf) {
3058  TGo4TreeViewer* tviewer =
3059  dynamic_cast<TGo4TreeViewer*> (FindGo4Widget("TreeViewer", false));
3060  if (tviewer) {
3061  tviewer->WorkWithLeaf(str);
3062  tviewer->parentWidget()->show();
3063  }
3064  break;
3065  }
3066 
3067  if (!cl) return;
3068 
3069  if (cl->InheritsFrom(TGo4Fitter::Class())) {
3070  TGo4FitPanel *fitpanel = StartFitPanel();
3071  TGo4ViewPanel *panel = dynamic_cast<TGo4ViewPanel *> (editor);
3072  fitpanel->WorkWithFitter(str, panel, !panel ? nullptr : panel->GetActivePad());
3073  } else if (cl->InheritsFrom(TGo4Parameter::Class())) {
3074  StartParaEdit(str);
3075  } else if (cl->InheritsFrom(TH1::Class())) {
3076  auto hinfo = StartHistogramInfo();
3077  hinfo->WorkWithHistogram(str);
3078  } else if (cl->InheritsFrom(TGo4Condition::Class())) {
3079  auto wedit = StartConditionEditor();
3080  wedit->WorkWithCondition(str);
3081  } else if (cl->InheritsFrom(TGo4DynamicEntry::Class())) {
3082  auto dedit = StartEditDynEntry();
3083  dedit->WorkWithEntry(str);
3084  } else if (cl->InheritsFrom(TGo4AnalysisStatus::Class())) {
3085  // use central editor, later can control many analysis at once
3087  }
3088 
3089  break;
3090  }
3091 
3093  TClass *cl = Browser()->ItemClass(str);
3094  int kind = Browser()->ItemKind(str);
3095  if (kind == TGo4Access::kndEventElement) {
3096  TGo4EventInfo* einfo = StartEventInfo();
3097  einfo->WorkWithEvent(str);
3098  break;
3099  }
3100  if (!cl) return;
3101  if (cl->InheritsFrom(TH1::Class())) {
3102  TGo4HistogramInfo* hinfo = StartHistogramInfo();
3103  hinfo->WorkWithHistogram(str);
3104  } else if (cl->InheritsFrom(TGo4Condition::Class())) {
3105  TGo4ConditionInfo* cinfo = StartConditionInfo();
3106  cinfo->WorkWithCondition(str);
3107  }
3108  break;
3109  }
3110 
3112  TGo4Slot *slot = (TGo4Slot *) par;
3113  if (!slot) break;
3114  TObject *obj = slot->GetAssignedObject();
3115  if (!obj) break;
3116  if (obj->InheritsFrom(TGo4Fitter::Class())) {
3117  TGo4FitPanel* fitpanel = StartFitPanel();
3118  fitpanel->WorkWithFitterInSlot(slot);
3119  }
3120  break;
3121  }
3122 
3124  const char *subfolder = (const char *) par;
3125  bool res = SaveBrowserItemToFile(str, subfolder);
3126  *((char *) par) = res ? 1 : 0;
3127  break;
3128  }
3129 
3131  TObject **obj = (TObject **) par;
3132  Bool_t res = Browser()->UpdateAnalysisItem(str, *obj);
3133  *obj = res ? (TObject *) 1 : nullptr;
3134  break;
3135  }
3136 
3138  StatusMessage(str);
3139  break;
3140  }
3141 
3143  TGo4ViewPanel **res = (TGo4ViewPanel **) par;
3144  *res = MakeNewPanel(QString(str).toInt());
3145  break;
3146  }
3147 
3149  bool* res = (bool*) par;
3150  *res = Browser()->IsItemRemote(str);
3151  break;
3152  }
3153 
3155  TGo4BrowserProxy **res = (TGo4BrowserProxy **) par;
3156  *res= Browser();
3157  break;
3158  }
3159 
3161  TObject **obj = (TObject **) par;
3162  TString itemname = Browser()->SaveToMemory(str, *obj, true);
3163  QString **res = (QString **) par;
3164  *res = nullptr;
3165  if (itemname.Length() > 0)
3166  *res = new QString(itemname.Data());
3167  break;
3168  }
3169 
3171  TGo4ServerProxy ** res = (TGo4ServerProxy **) par;
3172  *res = Browser()->FindServer(str);
3173  break;
3174  }
3175 
3177  TGo4Slot *brslot = Browser()->BrowserSlot((const char *)par);
3178 
3179  QByteArray ba = editor->objectName().toLatin1();
3180 
3181  if (!str) str = ba.constData();
3182 
3183  TGo4Slot *link = fxOM->AddLink(brslot, edslot->GetFullName(),
3184  str, "link to browser item");
3185  if (link)
3186  editor->SetLinkedName(link, (const char *)par);
3187 
3188  break;
3189  }
3190 
3192  QByteArray ba = editor->objectName().toLatin1();
3193  if (!str) str = ba.constData();
3194  TGo4Slot *slot = (TGo4Slot *) par;
3195  if (slot)
3196  fxOM->AddLink(slot, edslot->GetFullName(), str, "direct link to OM slot");
3197  break;
3198  }
3199 
3201  TGo4Slot **res = (TGo4Slot **) par;
3202 
3203  TGo4Slot *parent = *res;
3204  *res = nullptr;
3205  if (!parent) parent = edslot;
3206  TGo4Slot *brslot = Browser()->BrowserSlot(str);
3207 
3208  if (brslot) {
3209  *res = fxOM->AddLink(brslot, parent->GetFullName(),
3210  brslot->GetName(), "link in specific subfolder");
3211  if (*res)
3212  editor->SetLinkedName(*res, str);
3213  }
3214  break;
3215  }
3216 
3218  TGo4Slot **res = (TGo4Slot **) par;
3219  *res = edslot;
3220  break;
3221  }
3222 
3224  TGo4Slot *objslot = edslot->FindChild(str);
3225 
3226  if (!objslot)
3227  objslot = fxOM->MakeObjSlot(edslot->GetFullName(), str, "Place for editor object");
3228  if (objslot)
3229  objslot->SetProxy(new TGo4ObjectProxy);
3230 
3231  TGo4Slot **res = (TGo4Slot **)par;
3232  *res = objslot;
3233  break;
3234  }
3235 
3238  break;
3239  }
3240 
3242  if (!edslot) return;
3243  const char **res = (const char **) par;
3244  *res = TGo4BrowserProxy::GetLinkedName(edslot->FindChild(str));
3245  break;
3246  }
3247 
3249  void ** res = (void **) par;
3250  TGo4Slot *link = (TGo4Slot *) *res;
3251  *res = (void *) TGo4BrowserProxy::GetLinkedName(link);
3252  break;
3253  }
3254 
3258  if (!edslot) return;
3259  TGo4Slot *link = edslot->FindChild(str);
3260  if (!link) return;
3261  const char *itemname = TGo4BrowserProxy::GetLinkedName(link);
3262  TObject **res = (TObject **) par;
3263  int updatelevel = serviceid - QGo4Widget::service_GetLinked0;
3264  if (itemname)
3265  *res = Browser()->GetBrowserObject(itemname, updatelevel);
3266  else
3267  *res = link->GetAssignedObject();
3268  break;
3269  }
3270 
3272  if (!edslot) return;
3273  TGo4Slot *link = edslot->FindChild(str);
3274  if (link) link->Delete();
3275  break;
3276  }
3277 
3279  if (!str || (strcmp(str,"complete") != 0))
3280  edslot->DeleteChilds(str);
3281  else
3282  edslot->Delete();
3283  break;
3284  }
3285 
3287  TGo4Slot *slot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
3288  for (int n = 0; n < slot->NumChilds(); n++) {
3289  TGo4Slot *subslot = slot->GetChild(n);
3290  if (edslot == subslot)
3291  continue;
3292 
3293  TGo4WidgetProxy *wproxy = dynamic_cast<TGo4WidgetProxy *>(subslot->GetProxy());
3294 
3295  if (wproxy)
3296  wproxy->GetWidget()->ObjectCreatedByWidget(str, (TClass *)par);
3297  }
3298  break;
3299  }
3300 
3302  if (!edslot) break;
3303 
3304  TGo4WidgetProxy* proxy =
3305  dynamic_cast<TGo4WidgetProxy *> (edslot->GetProxy());
3306  if (proxy)
3307  proxy->ConnectPad((TPad *) par);
3308  break;
3309  }
3310 
3312  TGo4ViewPanel **res = (TGo4ViewPanel **) par;
3313  *res = fxMdiArea->GetActivePanel();
3314  break;
3315  }
3316 
3318  if (strcmp(str,"CloseAnalysisWindow") == 0) {
3319  // we should postpone window closing, while it is called from inside window itself
3320  // and it is create problem in sequence,
3321  QTimer::singleShot(100, this, &TGo4MainWindow::CloseAnalysisWindow);
3322  } else if (strcmp(str,"PrintAnalysisHistograms") == 0) {
3323  auto anw = FindAnalysisWindow();
3324  if (anw) anw->PrintHistograms();
3325  } else if (strcmp(str,"PrintAnalysisConditions") == 0) {
3326  auto anw = FindAnalysisWindow();
3327  if (anw) anw->PrintConditions();
3328  } else if (strcmp(str,"DisplayMbsMonitor") == 0) {
3329  ToggleMbsMonitor((const char *) par);
3330  } else if (strcmp(str,"SubmitAnalysisSettings") == 0) {
3332  } else if (strcmp(str,"CloseAnalysisSettings") == 0) {
3333  auto anal = Browser()->FindServer();
3334  if (anal) {
3335  anal->CloseAnalysisSettings();
3336  anal->RefreshNamesList();
3337  }
3338  } else if (strcmp(str,"SubmitStartAnalysis") == 0) {
3340  } else if (strcmp(str,"StartAnalysis") == 0) {
3342  } else if (strcmp(str,"StopAnalysis") == 0) {
3343  StopAnalysisSlot();
3344  } else if (strcmp(str,"TerminateAnalysis") == 0) {
3345  TerminateAnalysis(true);
3346  } else if (strcmp(str,"UpdateGuiLayout") == 0) {
3348  } else if (strcmp(str, "StartEventInfo") == 0) {
3349  StartEventInfo();
3350  } else if(strcmp(str, "ActivateConditionEditor") == 0) {
3351  TGo4ConditionEditor* w =
3352  (TGo4ConditionEditor*) FindGo4Widget("ConditionEditor", true);
3353  if (w) {
3354  w->setFocus();
3355  w->RefreshWidget(true);
3356  }
3357  } else if (strcmp(str, "SavePanelCanvas") == 0) {
3358  SavePanelCanvas(dynamic_cast<TGo4ViewPanel *>(editor));
3359  } else if (strcmp(str, "ToggleScaleValues") == 0) {
3361  } else if (strcmp(str, "GetFitterFromFitPanel") == 0) {
3362  TGo4FitPanel *panel = (TGo4FitPanel *) FindGo4Widget("FitPanel", false);
3363  TGo4Fitter **res = (TGo4Fitter **) par;
3364  if (panel && res)
3365  *res = panel->GetFitter();
3366  } else if (strcmp(str, "CloneFitterFromFitPanel") == 0) {
3367  auto panel = (TGo4FitPanel *) FindGo4Widget("FitPanel", false);
3368  TGo4Fitter **res = (TGo4Fitter **) par;
3369  if (panel && res)
3370  *res = panel->CloneFitter();
3371  }
3372 
3373  break;
3374  }
3375 
3377  // TGo4ViewPanel *panel = (TGo4ViewPanel *) editor;
3378  if (!fbPanelTimerActive) {
3379  fbPanelTimerActive = true;
3380  QTimer::singleShot(0, this, &TGo4MainWindow::checkPanelRepaintSlot);
3381  }
3382 
3383  break;
3384  }
3385 
3387  HelpWindow(str, (const char *) par);
3388  break;
3389  }
3390 
3392  HotStart(str);
3393  break;
3394  }
3395 
3402  TGo4ViewPanel *panel = (TGo4ViewPanel *) editor;
3403  TPad *pad = (TPad *) par;
3404  fxMdiArea->ResponseOnPanelEvent(serviceid, panel, pad);
3405  break;
3406  }
3407 
3408  }
3409 }
3410 
3411 // ******************** hot start functions *********************
3412 
3413 void TGo4MainWindow::HotStart(const char *fname)
3414 {
3415  if (!fname) return;
3416 
3418  if(!exec) return;
3419 
3420  if (!exec->StartScriptExecution(fname)) return;
3421 
3423 }
3424 
3426 {
3428  if (!exec) return;
3429 
3430  Bool_t res = kTRUE;
3431  do {
3432  res = exec->ContinueExecution();
3433  } while(res && !exec->IsWaitSomething());
3434 
3435  if (res) {
3437  if (!QApplication::overrideCursor())
3438  QApplication::setOverrideCursor(Qt::WaitCursor);
3439  } else {
3440  exec->FinishExecution();
3441  StatusMessage("Script execution done");
3442  QApplication::restoreOverrideCursor();
3443  }
3444 }
3445 
3447 {
3449  if (exec) exec->FinishExecution();
3450 }
3451 
3453 {
3454  QString ext = TGo4AbstractInterface::FileExtension();
3455  QString fileName =
3456  QFileDialog::getSaveFileName(this,
3457  "Create GUI script dialog",
3458  fLastFileDir,
3459  QString("GUI hotstart script (*") + ext + ")");
3460  if (fileName.isEmpty()) return;
3461 
3462  int pos = fileName.indexOf(ext);
3463 
3464  if ((pos<0) || (pos!=fileName.length()-ext.length()))
3465  fileName+=ext;
3466 
3467  StatusMessage(QString("Generate script ")+fileName);
3468 
3469  TGo4Script::ProduceScript(fileName.toLatin1().constData(), this);
3470 }
3471 
3473 {
3474  QToolBar* AnalysisMacroBar = addToolBar("Analysis Command Buttons");
3475  AnalysisMacroBar->setObjectName("AnalysisCommandToolBar");
3476 
3477  // new: everything is in dedicated class
3478  TGo4UserCommands* companel = new TGo4UserCommands(this, "UserCommands");
3479  ConnectGo4Widget(companel);
3480  AnalysisMacroBar->addWidget(companel);
3481  AnalysisMacroBar->adjustSize();
3482 }
3483 
3485 {
3486  if (fApp) fApp->processEvents(QEventLoop::AllEvents, TGo4AbstractInterface::DelayMillisec());
3487 }
3488 
3489 TGo4ViewPanel *TGo4MainWindow::FindViewPanel(const char *name)
3490 {
3491  if (!name || !*name) return nullptr;
3492 
3493  TGo4ViewPanel *panel = dynamic_cast<TGo4ViewPanel *> (FindGo4Widget(name, false));
3494 
3495  if (panel) return panel;
3496 
3497  TGo4Slot *slot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
3498 
3499  for (Int_t n = 0; n < slot->NumChilds(); n++) {
3500  TGo4Slot *widgslot = slot->GetChild(n);
3501  TGo4WidgetProxy *wproxy = !widgslot ? nullptr : dynamic_cast<TGo4WidgetProxy *>(widgslot->GetProxy());
3502  panel = !wproxy ? nullptr : dynamic_cast<TGo4ViewPanel *>(wproxy->GetWidget());
3503 
3504  if (panel)
3505  if (strcmp(panel->GetPanelName(), name) == 0)
3506  return panel;
3507  }
3508 
3509  return nullptr;
3510 }
TGo4ConditionEditor * StartConditionEditor()
void setDrawDateFlag(bool on=true)
QString getClientDir()
QString GetSettLoaction()
void setScreenScaleFactor(double factor)
TGo4Proxy * GetProxy(const char *name)
QAction * faDisconnectAnal
TGo4ServerProxy * ConnectHttpServer(const char *addr=nullptr, const char *user=nullptr, const char *pass=nullptr, bool with_qt_process=false, bool get_analysis_config=false)
bool getSavePadWhiteBackground()
TGo4Slot * GetChild(Int_t n) const
Definition: TGo4Slot.h:77
void OpenFile(const char *fname)
QString getAppStyle()
Bool_t IsAdministrator() const override
QAction * faEventstatus
Bool_t ContinueExecution()
Definition: TGo4Script.cxx:94
void HotStart(const char *fname)
QString getTGraphDrawOpt()
Int_t NumChilds() const
Definition: TGo4Slot.h:76
int getClientShellMode()
QString getClientAccountName()
QAction * faSuperimpose
void EstablishAnalysisWindowForHttp()
void PrepareForClientConnection(bool interactive=true)
void StartAnalysisShell(const char *cmd, const char *workdir=nullptr, bool aschildprocess=false)
void storeMainWindowState(QMainWindow *src)
void StatusMessage(const QString &mess)
QAction * faCrosshair
QMdiSubWindow * AddGo4SubWindow(QWidget *widget, Qt::WindowFlags flags=Qt::Widget)
Definition: TGo4MdiArea.cpp:65
void ChangeTerminalFontSlot()
TGo4AnalysisProxy * AddAnalysisProxy(bool isserver, bool needoutput)
Bool_t IsController() const override
void setTH1DrawOpt(const QString &value)
void HelpWindow(const char *filename, const char *msg=nullptr)
void setHideTGo4EventElement(bool on=true)
TString SaveToMemory(const char *pathname, TObject *obj, Bool_t ownership, Bool_t overwrite=kFALSE)
bool getDrawOnceFlag()
TObject * GetBrowserObject(const char *name, Int_t update=0)
double getScreenScaleFactor()
void SetProxy(TGo4Proxy *cont)
Definition: TGo4Slot.cxx:296
#define CtrlKey(key)
void CreateNewHist(int isremote=-1)
TGo4Slot * LoginfoSlot()
void CreateMemoryFolder(const char *foldername=nullptr)
TGo4Slot * UpdateObjectSlot()
void ToggleFullScreenSlot()
void setFetchDataWhenCopy(bool on=true)
void ConnectServer(bool interactive=true, const char *password="")
virtual void ClearLogInfo()
void EventStatusSlot(bool)
Int_t ItemKind(const char *name)
bool SaveBrowserItemToFile(const char *itemname, const char *subfolder)
QString getClientName()
void setPadEventStatus(bool on)
bool getFetchDataWhenCopy()
TGo4MainWindow(QApplication *)
void AddFile(const char *pathname, const char *filename)
QAction * faShutdownAnal
QAction * faConnectAnal
static void ExtractProgArgs(QString &prog, QStringList &args)
QString getTermTimeFormat()
Bool_t IsItemRemote(const char *name)
QString fConnectingHttp
void checkPanelRepaintSlot()
QAction * faPrepareAnal
void ChangeDrawTimeFlagSlot(bool)
void setDrawFillColor(int col)
void ConnectGo4Widget(QGo4Widget *editor)
void setPaletteOpt(int min, int def, int max)
void ToggleAnalysisConfiguration()
TGo4Slot * FindChild(const char *name) const
Definition: TGo4Slot.cxx:245
void LaunchClient(bool interactive=true)
bool getDrawItemFlag()
TGo4AnalysisConfiguration * EstablishAnalysisConfiguration(int level)
void MakeFolder(const char *pathname)
QString fOMBrowserPath
void SetLinkedName(TGo4Slot *slot, const char *itemname)
Definition: QGo4Widget.cpp:148
virtual Bool_t IsViewer() const
void setHServFilter(const QString &)
TGo4AnalysisProxy * FindAnalysis(const char *itemname=nullptr)
void ChangeHideEventElement(bool)
TGo4Proxy * GetProxy() const
Definition: TGo4Slot.h:93
void widgetService(QGo4Widget *editor, int serviceid, const char *str, void *par)
static void OpenLogfile(const char *name=nullptr, const char *headercomment=nullptr, Bool_t appendmode=kFALSE)
Definition: TGo4Log.cxx:383
virtual void CloseAnalysisSettings()
TClass * ItemClass(const char *name)
Bool_t IsConnected() const override
static const char * FileExtension()
virtual Bool_t CanSubmitObjects() const
QString getClientExec(int mode=-1)
TGo4AnalysisStatusMonitor * EstablishRatemeter(int level)
static void SetIgnoreLevel(Int_t level)
Definition: TGo4Log.cxx:332
void SetAnalysisLaunched(Int_t on=1)
void UpdateDockAnalysisWindow()
bool getWebBasedCanvas()
bool SubmitAnalysisSettings()
void ToggleMbsMonitor(const char *nodename)
void CreateNewCondition(bool forothereditor=false)
void setBasicSettings()
virtual Bool_t RefreshNamesList()
static void OutputEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:353
static Bool_t GetLaunchString(TString &launchcmd, TString &killcmd, Int_t serverkind, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, const char *remotedir, const char *remoteexe, Int_t guiport, Int_t exe_kind=0, const char *exeargs=nullptr)
void ChangeTerminalTimeStampSlot(bool)
void closeEvent(QCloseEvent *ce) override
virtual void RequestAnalysisSettings()
TGo4Slot * BrowserSlot(const char *item=nullptr)
virtual Bool_t IsAdministrator() const
bool getPadCrosshair()
void setTH3DrawOpt(const QString &value)
void ShowAboudDialog(const QString &title, const QString &text, const QString &icon)
virtual Bool_t IsController() const
virtual void SaveLogInfo()
Bool_t ConnectHServer(const char *servername, Int_t portnumber, const char *basename, const char *userpass, const char *filter)
void CheckConnectingCounterSlot()
QAction * faAnalConfig
virtual Bool_t SubmitCommand(const char *name, Int_t waitres=-1, const char *arg1=nullptr, const char *arg2=nullptr, const char *arg3=nullptr)
QAction * faStartAnal
QString getTH2DrawOpt()
void setSavePadWhiteBackground(bool on)
int getClientControllerMode()
virtual void StartAnalysis()
void setTermHistorySize(int sz)
static TGo4Script * ScriptInstance()
Definition: TGo4Script.cxx:44
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
Definition: QGo4Widget.cpp:84
void FinishExecution()
Definition: TGo4Script.cxx:124
TGo4FitPanel * StartFitPanel()
TGo4Slot * DataSlot(const char *item)
TString GetFullName(TGo4Slot *toparent=nullptr)
Definition: TGo4Slot.cxx:274
TGo4ParaEdit * StartParaEdit(const char *itemname=nullptr)
QString getHServName()
QString fLastFileDir
Bool_t ConnectToServer(const char *remotehost, Int_t remoteport, Int_t ascontroller, const char *accesspass)
TGo4BrowserProxy * Browser()
QAction * faAnalTermin
TGo4Slot * RatemeterSlot()
QAction * faDrawItem
bool getPadSuperimpose()
bool getDrawTimeFlag()
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Definition: TGo4Log.cxx:206
void InputTerminalParametersSlot()
TObject * GetAssignedObject()
Definition: TGo4Slot.cxx:356
TGo4SetScaleValues * ToggleScaleValues()
void SetDefaultReceiver(TGo4ObjectManager *rcv, const char *path)
QString fOMEditorsPath
QString getHServFilter()
void SavePanelCanvas(TGo4ViewPanel *panel)
void SetAnalysisReady(Bool_t on=kTRUE)
Bool_t UpdateAnalysisItem(const char *itemname, TObject *obj=nullptr)
void setFetchDataWhenDraw(bool on=true)
void setCloneFlag(bool on=true)
void setClientPort(int)
#define __GO4RELEASE__
Definition: TGo4Version.h:25
void setPadCrosshair(bool on)
void ObjectCreatedByWidget(const char *itemname, TClass *cl)
Definition: QGo4Widget.cpp:42
Bool_t IsConnected() const override
void ConnectPad(TPad *pad)
void ResponseOnPanelEvent(int funcid, TGo4ViewPanel *panel, TPad *pad)
Definition: TGo4MdiArea.cpp:95
void windowsMenuAboutToShow()
Bool_t DefineFileObject(const char *itemname, TString &filedataslot, const char **filepath)
TGo4HistogramInfo * StartHistogramInfo()
void ChangeFetchWhenSaveSlot(bool)
void getBasicSettings()
bool getMbsMonitorMonitorActive()
void setHServPort(int port)
virtual Bool_t IsConnected() const
bool getTermShowTimestamp()
TGo4Slot * MakeObjSlot(const char *foldername, const char *name=nullptr, const char *title=nullptr)
QString fLastPassword
QString getClientArgs()
void SuperimposeSlot(bool)
void setTermFont(const QFont &)
QAction * faDrawDate
QAction * faLaunchAnal
TGo4AnalysisWindow * EstablishAnalysisWindow(bool needoutput, bool withkillbnt=false, bool force_recreate=false)
virtual Bool_t UpdateAnalysisObject(const char *objectname, TObject *obj)
Bool_t SaveItemToFile(const char *itemname, const char *filename, const char *subfolder=nullptr)
void setAppStyle(const QString &)
TGo4Slot * GetSlot(const char *name, Bool_t force=kFALSE)
Definition: TGo4Slot.cxx:451
void setDrawLineWidth(int w=1)
void ChangeDrawDateFlagSlot(bool)
int getClientConnectMode()
TGo4EventInfo * StartEventInfo()
QAction * faSumbStartAnal
Bool_t IsAnalysisSettingsReady() const
void setDrawOnceFlag(bool on=true)
TGo4QSettings * go4sett
TGo4ViewPanel * GetActivePanel()
Definition: TGo4MdiArea.cpp:60
void WorkWithUpdateObjectCmd(TGo4Slot *slot)
TGo4MdiArea * fxMdiArea
bool getFetchDataWhenSave()
void SetMonitorBlockingFlag(Bool_t blocked=kFALSE)
void setFetchDataWhenSave(bool on=true)
bool getPadEventStatus()
static QAction * CreateChkAction(QMenu *menu, const QString &text, bool checked, bool enabled=true)
Definition: QGo4Widget.cpp:403
static void ProduceScript(const char *filename, TGo4MainWindow *main)
Definition: TGo4Script.cxx:877
void restoreMainWindowState(QMainWindow *tgt)
void ChangeFetchWhenCopySlot(bool)
void WindowActivated(int id)
virtual ~TGo4MainWindow()
QString getTH1DrawOpt()
void ChangeSaveWhiteBackgroundSlot(bool)
TGo4ViewPanel * FindViewPanel(const char *name)
bool startUserGUI(const char *)
void AddProxy(const char *pathname, TGo4Proxy *cont, const char *name, const char *title="title")
bool getFetchDataWhenDraw()
virtual void SubmitAnalysisSettings()
QAction * faStopAnal
void ChangeFetchWhenDrawSlot(bool)
void setMoveSubwindowRubberBand(bool on=true)
QGo4Widget * FindGo4Widget(const char *name, bool activate)
static const char * GetLinkedName(TGo4Slot *slot)
const char * LastTypedPassword() const
Bool_t IsAnalysisServer() const override
TGo4ObjectManager * OM()
void CloseFiles(const char *pathname)
TGo4EditDynEntry * StartEditDynEntry()
void setDrawTimeFlag(bool on=true)
Bool_t StartScriptExecution(const char *fname)
Definition: TGo4Script.cxx:67
bool getDrawDateFlag()
void SetStyleSlot(const QString &)
bool TerminateOnClose() const
const char * GetContainedObjectInfo() override
void *(* TStartUserGuiFunc)(QWidget *parent)
QSize lastPanelSize(const QString &kind="ViewPanel", int dfltwidth=450, int dfltheight=250)
virtual Bool_t IsAnalysisServer() const
void editorServiceSlot(QGo4Widget *editor, int serviceid, const char *str, void *par)
void setTH2DrawOpt(const QString &value)
QString fKillCommand
void setHServName(const QString &)
void ChangeDrawItemFlagSlot(bool)
void SubmitStartAnalysisSlot()
void CreateNewDynEntry(bool forothereditor=false)
void ChangeCloneFlagSlot(bool)
virtual void StopAnalysis()
bool getClientDefaultPass()
static TString subGO4SYS(const char *subdir)
Definition: TGo4Log.cxx:189
Bool_t IsAdministrator() const override
void setClientNode(const QString &)
void ShutdownAnalysis(bool interactive=true)
QApplication * fApp
QString getTH3DrawOpt()
virtual Bool_t DelayedRefreshNamesList(Int_t delay_sec)
void getPaletteOpt(int &min, int &def, int &max)
static void SetLinkedName(TGo4Slot *slot, const char *itemname)
void setTermShowTimestamp(bool on)
void setDrawFillStyle(int style)
void setDrawItemFlag(bool on=true)
void setCanvasColor(int red, int green, int blue)
bool getMoveSubwindowRubberBand()
TGo4ViewPanel * DisplayBrowserItem(const char *itemname, TGo4ViewPanel *panel, TPad *pad, bool activate, int updatelevel, const char *drawopt)
static const char * GetDabcVersion()
void DeleteChilds(const char *startedwith=nullptr)
Definition: TGo4Slot.cxx:202
void AppendOutputBuffer(const QString &value, int prio=0)
virtual Bool_t IsGo4Analysis() const
TGo4AnalysisConfiguration * FindAnalysisConfiguration()
virtual TString FindCommand(const char *name)
Int_t IsAnalysisLaunched() const
QString getGStyleStatFormat()
TGo4ViewPanel * MakeNewPanel(int div=0)
void TerminateAnalysis(bool interactive=true)
Bool_t UpdateObjectInFile(const char *itemname, const char *fileslotname, const char *filepath)
static void AutoEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:373
void Delete(Option_t *opt="") override
Definition: TGo4Slot.cxx:171
void DisconnectAnalysis(bool interactive=true)
TGo4AnalysisWindow * FindAnalysisWindow()
void setClientConnectMode(int)
virtual void DropItem(const char *itemname, TClass *cl, int kind)
Definition: QGo4Widget.cpp:89
void CrosshairSlot(bool)
bool getHideTGo4EventElement()
void setHServBase(const QString &)
bool RemoveAnalysisProxy(int waittime=30, bool servershutdown=false)
void setGStyleStatFormat(const QString &)
QAction * faDrawTime
virtual void DisconnectAnalysis(Int_t waittime=30, Bool_t servershutdown=kFALSE)
QString getHServBase()
TGo4ServerProxy * FindServer(const char *itemname=nullptr, Bool_t asanalysis=kTRUE)
TGo4Style * fxStyle
TGo4ServerProxy * ConnectHttp(const char *servername, const char *account=nullptr, const char *pass=nullptr) override
Definition: TGo4Script.cxx:850
void CascadeMdiPosition(QWidget *sub)
void setTermTimeFormat(const QString &form)
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:378
void ChangeDrawOnceSlot(bool)
QString getClientNode()
void ChangeTerminalTimeStampFormatSlot()
void setAppFont(const QFont &)
TGo4ObjectManager * fxOM
void setPadSuperimpose(bool on)
void ToggleMonitoring(Int_t period)
Bool_t LaunchAsClient(TString &launchcmd, TString &killcmd, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, const char *remotedir, const char *remoteexe, Int_t exe_kind=0, const char *exeargs=nullptr)
QGo4Widget * GetWidget() const
TGo4Slot * AddLink(TGo4Slot *source, const char *pathname, const char *linkname, const char *linktitle)
TGo4ConditionInfo * StartConditionInfo()
TGo4Slot * GetWidgetTopSlot(QGo4Widget *widget, bool force)
Bool_t IsWaitSomething() const
Definition: TGo4Script.cxx:132
void setTGraphDrawOpt(const QString &value)
void ChangeWindowRubberBandSlot(bool)
int getTermHistorySize()
static Bool_t LaunchAsServer(TString &launchcmd, TString &killcmd, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, Int_t remoteport, const char *remotedir, const char *remoteexe, Int_t exe_kind=0, const char *exeargs=nullptr)
string msg
Definition: go4init.py:11
void WaitForNewObject(bool isobjectforeditor)
Bool_t SaveBrowserToFile(const char *filename, Bool_t prefetch=kFALSE, const char *selectedpath=nullptr, const char *description=nullptr)
static void LogfileEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:363