00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4MainWindow.h"
00015
00016 #include "qaction.h"
00017 #include "qimage.h"
00018 #include "qpixmap.h"
00019 #include "qclipboard.h"
00020 #include "qstylefactory.h"
00021 #include "qfileinfo.h"
00022
00023 #include <QtCore/QString>
00024 #include <QtCore/QDateTime>
00025 #include <QtCore/QTimer>
00026 #include <QtCore/QProcess>
00027 #include <QtCore/QHash>
00028 #include <QtCore/QSignalMapper>
00029 #include <QtCore/QDir>
00030
00031 #include <QApplication>
00032 #include <QMenuBar>
00033 #include <QDockWidget>
00034 #include <QToolBar>
00035 #include <QComboBox>
00036 #include <QAction>
00037 #include <QStatusBar>
00038 #include <QStyle>
00039 #include <QColor>
00040 #include <QToolTip>
00041 #include <QToolButton>
00042 #include <QMessageBox>
00043 #include <QColorDialog>
00044 #include <QFileDialog>
00045 #include <QFontDialog>
00046 #include <QInputDialog>
00047 #include <QMdiSubWindow>
00048 #include <QMimeData>
00049 #include <QDesktopServices>
00050 #include <QUrl>
00051
00052
00054 #include "Riostream.h"
00055 #include "TSystem.h"
00056 #include "TROOT.h"
00057 #include "TMath.h"
00058 #include "TStyle.h"
00059 #include "TH1.h"
00060 #include "TH2.h"
00061 #include "TTree.h"
00062 #include "TColor.h"
00063 #include "TCanvas.h"
00064 #include "TList.h"
00065
00067 #include "QRootApplication.h"
00068 #include "TGo4Version.h"
00069 #include "TGo4Log.h"
00070 #include "TGo4LockGuard.h"
00071 #include "TGo4Parameter.h"
00072 #include "TGo4Condition.h"
00073 #include "TGo4Marker.h"
00074 #include "TGo4MdiArea.h"
00075 #include "TGo4Fitter.h"
00076 #include "TGo4FitPanel.h"
00077 #include "TGo4DynamicEntry.h"
00078 #include "TGo4AnalysisStatus.h"
00079
00080 #include "TGo4ObjectManager.h"
00081 #include "TGo4ObjectProxy.h"
00082 #include "TGo4BrowserProxy.h"
00083 #include "TGo4DabcProxy.h"
00084 #include "TGo4AnalysisProxy.h"
00085 #include "TGo4WidgetProxy.h"
00086
00088 #include "QGo4Widget.h"
00089 #include "TGo4QSettings.h"
00090 #include "TGo4TreeViewer.h"
00091 #include "TGo4Browser.h"
00092 #include "TGo4BrowserOptions.h"
00093 #include "TGo4Style.h"
00094 #include "TGo4ViewPanel.h"
00095 #include "TGo4AnalysisConfiguration.h"
00096 #include "TGo4AnalysisWindow.h"
00097 #include "TGo4StartClient.h"
00098 #include "TGo4HisDrawOptions.h"
00099 #include "TGo4HisDrawOptionsShort.h"
00100 #include "TGo4ScaleOptions.h"
00101 #include "TGo4DividePad.h"
00102 #include "TGo4CreateNewHistogram.h"
00103 #include "TGo4CreateNewCondition.h"
00104 #include "TGo4CreateNewDynEntry.h"
00105 #include "TGo4ConditionInfo.h"
00106 #include "TGo4HistogramInfo.h"
00107 #include "TGo4EventInfo.h"
00108 #include "TGo4LoadedLibraries.h"
00109 #include "TGo4EditDynEntry.h"
00110 #include "TGo4ParaEdit.h"
00111 #include "TGo4AnalysisStatusMonitor.h"
00112 #include "TGo4ConditionEditor.h"
00113 #include "TGo4LogSettings.h"
00114 #include "TGo4LogInfo.h"
00115 #include "TGo4OpenRemoteDialog.h"
00116 #include "TGo4ConnectServer.h"
00117 #include "TGo4MBSViewer.h"
00118 #include "TGo4SetScaleValues.h"
00119 #include "TGo4CommandLine.h"
00120 #include "TGo4MarkerSettings.h"
00121 #include "TGo4OptStatsSettings.h"
00122
00123 #ifdef __GO4DIM__
00124 #include "TGo4DabcMonitor.h"
00125 #endif
00126
00127
00128 #include "TGo4Script.h"
00129
00130 #include "TGo4HServerConnection.h"
00131
00132 using namespace Qt;
00133
00134 TGo4MainWindow::TGo4MainWindow(QApplication* app) :
00135 QMainWindow(),
00136 fApp(app)
00137 {
00138
00139
00140 resize( 1152, 864 );
00141
00142 setWindowIcon(QIcon(":/icons/go4logo2_big.png"));
00143
00144
00145
00146
00147 fxOM = new TGo4ObjectManager("GUI_OM","Gui object manager");
00148 fOMDataPath = "data";
00149 fOMBrowserPath = "gui";
00150 fOMEditorsPath = "editors";
00151
00152 fNewWidgetX = 0;
00153 fNewWidgetY = 0;
00154
00155 fKillCommand = "";
00156 fLastPassword = "";
00157 fLastFileDir = QDir::currentPath();
00158
00159 fCloseCounter = 0;
00160 fConnectingCounter = 0;
00161
00162 fbPanelTimerActive = false;
00163 winMapper = 0;
00164
00165 fbFullScreen = false;
00166
00167
00168 fxOM->MakeFolder(fOMDataPath.toLatin1().constData());
00169
00170
00171 TGo4BrowserProxy* br = new TGo4BrowserProxy(fOMDataPath.toLatin1().constData(), fOMEditorsPath.toLatin1().constData(), kFALSE);
00172 fxOM->AddProxy("", br, fOMBrowserPath.toLatin1().constData(), "Place for gui slots");
00173 br->CreateMemoryFolder();
00174
00175 TH1I* h1 = new TH1I("histo1","histo title", 100, -10., 10.);
00176 h1->FillRandom("gaus",10000);
00177 h1->SetDirectory(0);
00178 br->SaveToMemory("", h1, kTRUE);
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 new TGo4Script(this);
00189
00190 gStyle->SetPalette(1);
00191 gStyle->SetCanvasColor(10);
00192 gStyle->SetPadColor(10);
00193 gStyle->SetFrameFillColor(10);
00194 gStyle->SetStatColor(0);
00195
00196
00197 gStyle->SetOptStat(go4sett->getOptStat());
00198
00199 fxMdiArea = new TGo4MdiArea(this);
00200 fxMdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
00201 fxMdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
00202 setCentralWidget(fxMdiArea);
00203 fxMdiArea->setFocus();
00204
00205 AddFileMenu();
00206 AddFileToolBar();
00207
00208 AddToolsMenu();
00209 AddToolsBar();
00210
00211 AddAnalysisMenu();
00212 AddAnalysisBar();
00213
00214 UpdateCaptionButtons();
00215
00216 QDockWidget* BrowserDockWin = new QDockWidget("Browser", this);
00217 BrowserDockWin->setObjectName("BrowserDock");
00218 TGo4Browser* browser = new TGo4Browser(BrowserDockWin,"Browser");
00219 browser->setWindowFlags(Qt::Widget);
00220 ConnectGo4Widget(browser);
00221 browser->StartWorking();
00222 BrowserDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
00223 BrowserDockWin->setWidget(browser);
00224 BrowserDockWin->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
00225 addDockWidget(Qt::LeftDockWidgetArea, BrowserDockWin);
00226
00227 QAction* BrowserDockAction=BrowserDockWin->toggleViewAction();
00228 BrowserDockAction->setShortcut(QKeySequence("F6"));
00229
00230
00231 #if (QT_VERSION >= 0x040700) && (QT_VERSION <= 0x040909)
00232 browser->setMinimumWidth(230);
00233 #endif
00234
00235 QDockWidget* LogDockWin = new QDockWidget("Log window", this);
00236 LogDockWin->setObjectName("LogInfoDock");
00237 TGo4LogInfo* loginfo = new TGo4LogInfo(this, "LogInfo");
00238 ConnectGo4Widget(loginfo);
00239 LogDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
00240 LogDockWin->setWidget(loginfo);
00241 LogDockWin->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
00242 addDockWidget(Qt::BottomDockWidgetArea, LogDockWin);
00243
00244 QAction* LogDockWinAction=LogDockWin->toggleViewAction();
00245 LogDockWinAction->setShortcut(QKeySequence("F7"));
00246
00247 QDockWidget* MBSDockWin = new QDockWidget("MBS monitor", this);
00248 MBSDockWin->setObjectName("MbsViewerDock");
00249 TGo4MBSViewer* mbs = new TGo4MBSViewer(MBSDockWin, "MBSViewer");
00250 mbs->setWindowFlags(Qt::Widget);
00251 ConnectGo4Widget(mbs);
00252 MBSDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
00253 MBSDockWin->setWidget(mbs);
00254 MBSDockWin->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
00255 addDockWidget(Qt::BottomDockWidgetArea, MBSDockWin);
00256
00257 QAction* MBSDockAction=MBSDockWin->toggleViewAction();
00258 MBSDockAction->setShortcut(QKeySequence("F8"));
00259
00260
00261 #ifdef __GO4DIM__
00262 QDockWidget* DABCDockWin = new QDockWidget("DABC monitor", this);
00263 DABCDockWin->setObjectName("DABCMonitorDock");
00264 TGo4DabcMonitor* dabc = new TGo4DabcMonitor(DABCDockWin, "DabcMonitor");
00265 dabc->setWindowFlags(Qt::Widget);
00266 ConnectGo4Widget(dabc);
00267 DABCDockWin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
00268 DABCDockWin->setWidget(dabc);
00269 DABCDockWin->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
00270 addDockWidget(Qt::BottomDockWidgetArea, DABCDockWin);
00271 QAction* DABCDockWinAction=DABCDockWin->toggleViewAction();
00272 DABCDockWinAction->setShortcut(QKeySequence("F9"));
00273
00274
00275 #endif
00276
00277 QToolBar* DividePanelBar = addToolBar("Canvas Tools");
00278 DividePanelBar->setObjectName("DividePadDock");
00279 TGo4DividePad* dividepanel = new TGo4DividePad(this, "DividePad");
00280 DividePanelBar->addWidget(dividepanel);
00281
00282 QToolBar* stylebar = addToolBar("Color Tools");
00283 stylebar->setObjectName("Go4StyleDock");
00284 TGo4Style* style = new TGo4Style(this, "Go4Style");
00285 stylebar->addWidget(style);
00286
00287 QToolBar* BrowserOptionsPanel = addToolBar("Browser Options");
00288 BrowserOptionsPanel->setObjectName("BrowserOptionsDock");
00289 TGo4BrowserOptions* bropt = new TGo4BrowserOptions(this, "BrowserOptions");
00290 ConnectGo4Widget(bropt);
00291 BrowserOptionsPanel->addWidget(bropt);
00292 bropt->StartWorking();
00293
00294 QToolBar* DrawOptionPanel = addToolBar("Draw Options");
00295 DrawOptionPanel->setObjectName("DrawOptionsDock");
00296 TGo4HisDrawOptions* drawopt = new TGo4HisDrawOptions(this, "DrawOptions");
00297 DrawOptionPanel->addWidget(drawopt);
00298 DrawOptionPanel->adjustSize();
00299
00300 QToolBar* DrawOptionShortPanel = addToolBar("Hist Draw Options");
00301 DrawOptionShortPanel->setObjectName("HisDrawOptionsDock");
00302 TGo4HisDrawOptionsShort* drawopts = new TGo4HisDrawOptionsShort(this, "HisDrawOptions");
00303 DrawOptionShortPanel->addWidget(drawopts);
00304 DrawOptionShortPanel->adjustSize();
00305
00306 QToolBar* ScaleOptionBar = addToolBar("Zoom Tools");
00307 ScaleOptionBar->setObjectName("ScaleOptionsDock");
00308 TGo4ScaleOptions* scopt = new TGo4ScaleOptions(this, "ScaleOptions");
00309 ConnectGo4Widget(scopt);
00310 ScaleOptionBar->addWidget(scopt);
00311 ScaleOptionBar->adjustSize();
00312
00313 QToolBar* commandlinebar = addToolBar("Go4 Command Line");
00314 commandlinebar->setObjectName("CommandLineDock");
00315 TGo4CommandLine* cli = new TGo4CommandLine(this, "CommandLine");
00316 ConnectGo4Widget(cli);
00317 commandlinebar->addWidget(cli);
00318
00319 QToolBar* tviewerdock = addToolBar("Tree viewer");
00320 tviewerdock->setObjectName("TreeViewerDock");
00321 TGo4TreeViewer* tviewer = new TGo4TreeViewer(this, "TreeViewer");
00322 ConnectGo4Widget(tviewer);
00323 tviewerdock->addWidget(tviewer);
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 AddSettingMenu();
00334
00335 windowsMenu = menuBar()->addMenu("&Windows");
00336 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
00337
00338 windowsMenuAboutToShow();
00339
00340 menuBar()->addSeparator();
00341
00342 QMenu* helpMenu = menuBar()->addMenu("&Help");
00343 helpMenu->addAction("&Introduction (user manual)", this, SLOT(IntroHelpSlot()), Key_F1);
00344 helpMenu->addAction("&Reference manual", this, SLOT(RefHelpSlot()));
00345 helpMenu->addAction("&Fit Tutorial", this, SLOT(FitHelpSlot()));
00346 helpMenu->addSeparator();
00347 helpMenu->addAction("About &Qt", this, SLOT(aboutQt()), Key_F2 );
00348 helpMenu->addAction("About R&OOT", this, SLOT(aboutROOT()), Key_F3);
00349 if (TGo4DabcProxy::GetDabcVersion())
00350 helpMenu->addAction("About &DABC", this, SLOT(aboutDABC()));
00351 helpMenu->addAction("About &Go4", this, SLOT(about()), Key_F4);
00352
00353 const char* libs = gSystem->Getenv("GO4USERLIBRARY");
00354
00355 if (libs!=0) {
00356 QStringList LibList = QString(libs).split(":",QString::SkipEmptyParts);
00357
00358 for (QStringList::Iterator it=LibList.begin(); it!=LibList.end(); ++it)
00359 gSystem->Load((*it).toLatin1().constData());
00360 }
00361
00362 go4sett->restoreMainWindowState(this);
00363
00364 QApplication::setStyle(go4sett->getAppStyle());
00365
00366 faCrosshair->setChecked(go4sett->getPadCrosshair());
00367 faEventstatus->setChecked(go4sett->getPadEventStatus());
00368
00369 go4sett->getBasicSettings();
00370 go4sett->getAppFont();
00371
00372
00373 if(go4sett->getMbsMonitorMonitorActive()) mbs->TimerStart();
00374
00375 std::cout <<"Using Qt settings at "<< go4sett->GetSettLoaction().toLatin1().constData() << std::endl;
00376
00377 statusBar()->showMessage("Ready");
00378 statusBar()->setSizeGripEnabled(true);
00379
00380 QString sfmt = go4sett->getGStyleStatFormat();
00381 if (!sfmt.isEmpty()) gStyle->SetStatFormat(sfmt.toLatin1().constData());
00382 }
00383
00384 TGo4MainWindow::~TGo4MainWindow()
00385 {
00386 TGo4Script::DeleteInstance();
00387
00388 delete fxOM;
00389 }
00390
00391 const char* TGo4MainWindow::LastTypedPassword() const
00392 {
00393 return fLastPassword.toLatin1().constData();
00394 }
00395
00396
00397 void TGo4MainWindow::about()
00398 {
00399 QString GO4STR("Go4 ");
00400 GO4STR.append ( __GO4RELEASE__);
00401 QString GO4STR1 = GO4STR;
00402 GO4STR1.append("<br>");
00403 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") ;
00404
00405 QMessageBox AboutGo4(GO4STR, GO4STR1, QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton ,this);
00406 AboutGo4.setIconPixmap(QPixmap( ":/icons/go4logo2_big.png"));
00407 AboutGo4.setTextFormat(Qt::RichText);
00408 AboutGo4.exec();
00409 }
00410
00411 void TGo4MainWindow::aboutQt()
00412 {
00413 QMessageBox::aboutQt(this, "Qt");
00414 }
00415
00416 void TGo4MainWindow::aboutROOT()
00417 {
00418 QString mestring("This Go4 uses ROOT ");
00419 mestring.append(gROOT->GetVersion());
00420 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");
00421 QMessageBox AboutRoot("ROOT", mestring,
00422 QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton ,this);
00423 AboutRoot.setIconPixmap(QPixmap( ":/icons/root.png"));
00424 AboutRoot.setTextFormat(Qt::RichText);
00425 AboutRoot.exec();
00426 }
00427
00428 void TGo4MainWindow::aboutDABC()
00429 {
00430 QString mestring("This Go4 uses DABC ");
00431 if (TGo4DabcProxy::GetDabcVersion())
00432 mestring.append(TGo4DabcProxy::GetDabcVersion());
00433 else
00434 mestring.append("<undef>");
00435 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");
00436 QMessageBox AboutDabc("DABC", mestring,
00437 QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton ,this);
00438 AboutDabc.setIconPixmap(QPixmap( ":/icons/dabc.png"));
00439 AboutDabc.setTextFormat(Qt::RichText);
00440 AboutDabc.exec();
00441 }
00442
00443 void TGo4MainWindow::AddSettingMenu()
00444 {
00445 QMenu* settMenu = menuBar()->addMenu("&Settings");
00446
00447 QMenu* sub = createPopupMenu();
00448 sub->setTitle("Sh&ow/hide");
00449 settMenu->addMenu(sub);
00450
00451 settMenu->addAction("&Font...", this, SLOT(ChangeFontSlot()));
00452
00453 QMenu *style = settMenu->addMenu("St&yle");
00454
00455 QMenu* prefMenu = settMenu->addMenu("&Preferences");
00456
00457 faFetchWhenDraw = AddChkAction(prefMenu, "Fetch when drawing",
00458 go4sett->getFetchDataWhenDraw(), this, SLOT(ChangeFetchWhenDrawSlot()));
00459
00460 faFetchWhenCopy = AddChkAction(prefMenu, "Fetch when copying",
00461 go4sett->getFetchDataWhenCopy(), this, SLOT(ChangeFetchWhenCopySlot()));
00462
00463 faFetchWhenSave = AddChkAction(prefMenu, "Fetch when saving",
00464 go4sett->getFetchDataWhenSave(), this, SLOT(ChangeFetchWhenSaveSlot()));
00465
00466 faHideEventElement = AddChkAction(prefMenu, "Hide TGo4EventElement",
00467 go4sett->getHideTGo4EventElement(), this, SLOT(ChangeHideEventElement()));
00468
00469 faDrawOnce = AddChkAction(prefMenu, "Draw item once",
00470 go4sett->getDrawOnceFlag(), this, SLOT(ChangeDrawOnceSlot()));
00471
00472
00473 QMenu* panelMenu = settMenu->addMenu("&Panel defaults");
00474
00475 panelMenu->addAction("&Canvas color...", this, SLOT(CanvasColorSlot()));
00476 panelMenu->addAction("Marker labels...", this, SLOT(MarkerSettingsSlot()));
00477 panelMenu->addAction("Statistics box...", this, SLOT(OptStatsSlot()));
00478
00479 faCrosshair = AddChkAction(panelMenu, "Cross(&X)hair mode",
00480 go4sett->getPadCrosshair(), this, SLOT(CrosshairSlot()));
00481
00482 faEventstatus = AddChkAction(panelMenu, "Show Event Status",
00483 go4sett->getPadEventStatus(), this, SLOT(EventStatusSlot()));
00484
00485 faClone = AddChkAction(panelMenu, "Objects cloning",
00486 go4sett->getCloneFlag(), this, SLOT(ChangeCloneFlagSlot()));
00487
00488 faDrawTime = AddChkAction(panelMenu, "Draw time",
00489 go4sett->getDrawTimeFlag(), this, SLOT(ChangeDrawTimeFlagSlot()));
00490 faDrawTime->setEnabled(go4sett->getCloneFlag());
00491
00492 faDrawDate = AddChkAction(panelMenu, "Draw date",
00493 go4sett->getDrawDateFlag(), this, SLOT(ChangeDrawDateFlagSlot()));
00494 faDrawDate->setEnabled(go4sett->getCloneFlag());
00495
00496 faDrawItem = AddChkAction(panelMenu, "Draw item name",
00497 go4sett->getDrawItemFlag(), this, SLOT(ChangeDrawItemFlagSlot()));
00498 panelMenu->addAction(faDrawItem);
00499 faDrawItem->setEnabled(go4sett->getCloneFlag());
00500
00501 panelMenu->addAction("TH1 draw opt ...", this, SLOT(TH1DrawOptSlot()));
00502 panelMenu->addAction("TH2 draw opt ...", this, SLOT(TH2DrawOptSlot()));
00503 panelMenu->addAction("TH3 draw opt ...", this, SLOT(TH3DrawOptSlot()));
00504 panelMenu->addAction("TGraph draw opt ...", this, SLOT(TGraphDrawOptSlot()));
00505 panelMenu->addAction("Printf format ...", this, SLOT(GStyleStatFormatSlot()));
00506
00507 settMenu->addAction("&Log actions...", this, SLOT(LogSettingsSlot()));
00508
00509 settMenu->addAction("Generate &hotstart", this, SLOT(CreateGUIScriptSlot()));
00510 settMenu->addAction("&Break hotstart execution", this, SLOT(StopGUIScriptSlot()));
00511
00512 settMenu->addAction("&Terminal history", this, SLOT(InputTerminalParametersSlot()));
00513 settMenu->addAction("&Terminal font...", this, SLOT(ChangeTerminalFontSlot()));
00514
00515 settMenu->addAction("&Save settings", this, SLOT(SaveSettingsSlot()));
00516
00517 QActionGroup *ag = new QActionGroup(this);
00518 ag->setExclusive( true );
00519 QSignalMapper *styleMapper = new QSignalMapper( this );
00520 connect(styleMapper, SIGNAL(mapped(const QString&)), this, SLOT(SetStyleSlot(const QString&)));
00521
00522 QStringList list = QStyleFactory::keys();
00523 list.sort();
00524 QHash<QString, int> stylesDict;
00525 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
00526 QString styleStr = *it;
00527 QString styleAccel = styleStr;
00528 if ( stylesDict[styleAccel.left(1)] ) {
00529 for ( uint i = 0; i < styleAccel.length(); i++ ) {
00530 if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
00531 stylesDict.insert(styleAccel.mid( i, 1 ), 1);
00532 styleAccel = styleAccel.insert( i, '&' );
00533 break;
00534 }
00535 }
00536 } else {
00537 stylesDict.insert(styleAccel.left(1), 1);
00538 styleAccel = "&"+styleAccel;
00539 }
00540 QAction *act = new QAction(styleAccel, this);
00541 act->setCheckable(true);
00542 if (go4sett->getAppStyle() == styleStr)
00543 act->setChecked(true);
00544
00545 connect( act, SIGNAL(triggered()), styleMapper, SLOT(map()) );
00546 styleMapper->setMapping(act, styleStr);
00547
00548 ag->addAction(act);
00549 style->addAction(act);
00550 }
00551 }
00552
00553 void TGo4MainWindow::AddFileMenu()
00554 {
00555 QMenu* fileMenu = menuBar()->addMenu("&File");
00556
00557 fileMenu->addAction(QIcon( ":/icons/open.png" ), "&Open...",
00558 this, SLOT(OpenFileSlot()), CTRL+Key_O );
00559 fileMenu->addAction(QIcon( ":/icons/network.png" ), "Open &Remote...",
00560 this, SLOT(OpenRemoteFileSlot()), CTRL+Key_R );
00561 fileMenu->addAction(QIcon( ":/icons/dabc.png" ), "Connect &DABC...",
00562 this, SLOT(ConnectDabcSlot()) );
00563 fileMenu->addAction(QIcon( ":/icons/histserv.png" ), "Open &HServer...",
00564 this, SLOT(ConnectHServerSlot()) );
00565 fileMenu->addAction(QIcon( ":/icons/filesave.png" ), "Save memor&y...",
00566 this, SLOT(SaveFileSlot()), CTRL+Key_Y );
00567 fileMenu->addAction(QIcon( ":/icons/close.png" ),"Close all files",
00568 this, SLOT(CloseAllFilesSlot()), CTRL+Key_Q);
00569 fileMenu->addAction(QIcon( ":/icons/exit.png" ), "E&xit",
00570 this, SLOT(close()), CTRL+Key_X );
00571 }
00572
00573 void TGo4MainWindow::AddFileToolBar()
00574 {
00575 QToolBar *FileBar = addToolBar( "File Toolbar" );
00576 FileBar->setObjectName("FileToolBar");
00577
00578 FileBar->addAction( QIcon( ":/icons/open.png" ), "Open a local file from disk",
00579 this, SLOT(OpenFileSlot()));
00580
00581 FileBar->addAction( QIcon( ":/icons/network.png" ), "Open a remote file from server",
00582 this, SLOT(OpenRemoteFileSlot()));
00583
00584 FileBar->addAction( QIcon( ":/icons/dabc.png" ), "Connect to dabc server",
00585 this, SLOT(ConnectDabcSlot()));
00586
00587 FileBar->addAction( QIcon( ":/icons/histserv.png" ), "Connect to running histogram server",
00588 this, SLOT(ConnectHServerSlot()));
00589
00590 FileBar->addAction( QIcon( ":/icons/filesave.png" ), "Save the content of the browser to a root file",
00591 this, SLOT(SaveFileSlot()));
00592
00593 FileBar->addAction( QIcon( ":/icons/close.png" ), "Close all root files in file browser",
00594 this, SLOT(CloseAllFilesSlot() ));
00595
00596 FileBar->addAction( QIcon( ":/icons/exit.png" ), "Exit the Go4",
00597 this, SLOT(close()));
00598 }
00599
00600 void TGo4MainWindow::AddToolsMenu()
00601 {
00602 QMenu* toolMenu = menuBar()->addMenu("&Tools");
00603
00604 toolMenu->addAction(QIcon(":/icons/chart.png" ), "&View panel",
00605 this, SLOT(MakeNewPanel()), CTRL+Key_V );
00606 toolMenu->addAction(QIcon(":/icons/fitpanel.png" ), "&Fit panel...",
00607 this, SLOT(StartFitPanel()), CTRL+Key_F );
00608 toolMenu->addAction(QIcon(":/icons/hislist.png" ),"&Histogram properties...",
00609 this, SLOT(StartHistogramInfo()));
00610 toolMenu->addAction(QIcon(":/icons/hiscre.png" ), "Create New H&istogram...",
00611 this, SLOT(CreateNewHistSlot()), CTRL+Key_I );
00612 toolMenu->addAction(QIcon(":/icons/condlist.png" ),"C&ondition properties...",
00613 this, SLOT(StartConditionInfo()));
00614 toolMenu->addAction(QIcon(":/icons/condcre.png" ),"Create new &condition...",
00615 this, SLOT(CreateNewConditionSlot()));
00616 toolMenu->addAction(QIcon(":/icons/zoom.png" ),"&Event printout...",
00617 this, SLOT(StartEventInfo()));
00618 toolMenu->addAction(QIcon(":/icons/dynlist.png" ),"Create &dyn. list entry ...",
00619 this, SLOT(CreateNewDynEntrySlot()), CTRL+Key_D);
00620 toolMenu->addAction(QIcon(":/icons/dllicon.png" ), "Load li&braries ...",
00621 this, SLOT(LoadLibrarySlot()), CTRL+Key_B);
00622 toolMenu->addAction(QIcon(":/icons/user.png" ), "&User GUI ...",
00623 this, SLOT(UserPanelSlot()), CTRL+Key_U);
00624 }
00625
00626 void TGo4MainWindow::AddToolsBar()
00627 {
00628 QToolBar *ToolBar = addToolBar("Go4 tools");
00629 ToolBar->setObjectName("Go4ToolsBar");
00630
00631 ToolBar->addAction( QIcon( ":/icons/chart.png" ), "Create a new view panel",
00632 this, SLOT(MakeNewPanel()));
00633
00634 ToolBar->addAction( QIcon( ":/icons/fitpanel.png" ), "Show/hide the Go4 Fit Panel",
00635 this, SLOT(StartFitPanel()));
00636
00637 ToolBar->addAction( QIcon( ":/icons/hislist.png" ), "Show histogram properties window",
00638 this, SLOT(StartHistogramInfo()));
00639
00640 ToolBar->addAction( QIcon( ":/icons/hiscre.png" ), "Create new ROOT Histogram",
00641 this, SLOT(CreateNewHistSlot()));
00642
00643 ToolBar->addAction( QIcon( ":/icons/condlist.png" ), "Show condition properties window",
00644 this, SLOT(StartConditionInfo()));
00645
00646 ToolBar->addAction( QIcon( ":/icons/condcre.png" ), "Create new condition in analysis",
00647 this, SLOT(CreateNewConditionSlot()));
00648
00649 ToolBar->addAction( QIcon( ":/icons/zoom.png" ), "Event printout and examination window",
00650 this, SLOT(StartEventInfo()));
00651
00652 ToolBar->addAction( QIcon( ":/icons/dynlist.png" ), "Create new Dynamic list entry",
00653 this, SLOT(CreateNewDynEntrySlot()));
00654
00655 ToolBar->addAction( QIcon( ":/icons/dllicon.png" ), "Load Libraries",
00656 this, SLOT(LoadLibrarySlot() ));
00657
00658 ToolBar->addAction( QIcon( ":/icons/user.png" ), "Start user panel",
00659 this, SLOT(UserPanelSlot()));
00660 }
00661
00662 void TGo4MainWindow::AddAnalysisMenu()
00663 {
00664 QMenu* anMenu = menuBar()->addMenu("&Analysis");
00665
00666 faLaunchAnal =
00667 anMenu->addAction(QIcon(":/icons/launchanal.png" ), "Lau&nch analysis...",
00668 this, SLOT(LaunchClientSlot()), CTRL+Key_N);
00669 faConnectAnal =
00670 anMenu->addAction(QIcon(":/icons/connect.png"), "&Connect to running server...",
00671 this, SLOT(ConnectServerSlot()), CTRL+Key_C);
00672
00673 faPrepareAnal =
00674 anMenu->addAction(QIcon(":/icons/connect.png" ), "&Prepare for client connection...",
00675 this, SLOT(PrepareForClientConnectionSlot()));
00676
00677 faDisconnectAnal =
00678 anMenu->addAction(QIcon(":/icons/disconnect.png"), "Disconnect from analysis",
00679 this, SLOT(DisconnectAnalysisSlot()), CTRL+Key_M);
00680
00681 faShutdownAnal =
00682 anMenu->addAction(QIcon(":/icons/shutanal.png"), "Shutdown analysis",
00683 this, SLOT(ShutdownAnalysisSlot()), CTRL+Key_M);
00684
00685 faSumbStartAnal =
00686 anMenu->addAction(QIcon(":/icons/restart.png"), "Submit+S&tart",
00687 this, SLOT(SubmitStartAnalysisSlot()), CTRL+Key_T);
00688
00689 faStartAnal =
00690 anMenu->addAction(QIcon(":/icons/start.png"), "&Start",
00691 this, SLOT(StartAnalysisSlot()), CTRL+Key_S);
00692
00693 faStopAnal =
00694 anMenu->addAction(QIcon(":/icons/Stop.png"), "Stop (&Halt)",
00695 this, SLOT(StopAnalysisSlot()), CTRL+Key_H);
00696
00697 faAnalConfig =
00698 anMenu->addAction(QIcon(":/icons/control.png"), "Confi&guration...",
00699 this, SLOT(ToggleAnalysisConfiguration()), CTRL+Key_G);
00700
00701 faAnalTermin =
00702 anMenu->addAction(QIcon(":/icons/analysiswin.png"), "Analysis &Window",
00703 this, SLOT(ToggleAnalysisWindow()), CTRL+Key_W);
00704 }
00705
00706 void TGo4MainWindow::AddAnalysisBar()
00707 {
00708 QToolBar *AnalBar = addToolBar("Analysis Toolbar");
00709 AnalBar->setObjectName("AnalysisToolBar");
00710 AnalBar->setToolTip("Analysis related tool buttons");
00711
00712 AnalBar->addAction(faLaunchAnal);
00713 AnalBar->addAction(faConnectAnal);
00714 AnalBar->addAction(faDisconnectAnal);
00715 AnalBar->addAction(faShutdownAnal);
00716
00717 AnalBar->addAction(faSumbStartAnal);
00718
00719 AnalBar->addAction(faStartAnal);
00720
00721 AnalBar->addAction(faStopAnal);
00722 AnalBar->addAction(faAnalConfig);
00723 AnalBar->addAction(faAnalTermin);
00724 }
00725
00726 void TGo4MainWindow::windowsMenuAboutToShow()
00727 {
00728 windowsMenu->clear();
00729
00730 bool on = ! fxMdiArea->subWindowList().isEmpty();
00731
00732 windowsMenu->addAction("Ca&scade", this, SLOT(CascadeSubWindows()))->setEnabled(on);
00733 windowsMenu->addAction("&Tile", fxMdiArea, SLOT(tileSubWindows()))->setEnabled(on);
00734 windowsMenu->addAction("&Close all", fxMdiArea, SLOT(closeAllSubWindows()))->setEnabled(on);
00735 windowsMenu->addAction("&Minimize all", this, SLOT(MinAllWindows()))->setEnabled(on);
00736
00737 windowsMenu->addAction((fbFullScreen ? "&Normal window" : "&Full screen"), this, SLOT(ToggleFullScreenSlot()), Key_F11);
00738
00739 windowsMenu->addSeparator();
00740
00741 QGo4Widget* loginfo = FindGo4Widget("LogInfo", false);
00742 if (loginfo!=0) {
00743 windowsMenu->addAction("Save L&ogwindow", loginfo, SLOT(SaveLogInfo()));
00744 windowsMenu->addAction("Clear &Logwindow", loginfo, SLOT(ClearLogInfo()));
00745 } else {
00746 windowsMenu->addAction("Save L&ogwindow")->setEnabled(false);
00747 windowsMenu->addAction("Clear &Logwindow")->setEnabled(false);
00748 }
00749
00750 QGo4Widget* anw = FindGo4Widget("AnalysisWindow", false);
00751 if (anw!=0) {
00752 windowsMenu->addAction("Save &Analysis window", anw, SLOT(SaveAnalysisOutput()));
00753 windowsMenu->addAction("Clear Analysis &window", anw, SLOT(ClearAnalysisOutput()));
00754 } else {
00755 windowsMenu->addAction("Save &Analysis window")->setEnabled(false);
00756 windowsMenu->addAction("Clear Analysis &window")->setEnabled(false);
00757 }
00758
00759 windowsMenu->addSeparator();
00760
00761 delete winMapper;
00762 winMapper = new QSignalMapper(this);
00763 connect(winMapper, SIGNAL(mapped(int)), this, SLOT(windowsMenuActivated(int)));
00764
00765 QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
00766 for (int i=0; i< windows.count(); i++ ) {
00767 QAction* act = new QAction(windows.at(i)->widget()->windowTitle(), winMapper);
00768 act->setCheckable(true);
00769 act->setChecked(fxMdiArea->activeSubWindow() == windows.at(i));
00770
00771 windowsMenu->addAction(act);
00772
00773 connect(act, SIGNAL(triggered()), winMapper, SLOT(map()) );
00774 winMapper->setMapping(act, i);
00775 }
00776 }
00777
00778 void TGo4MainWindow::MinAllWindows()
00779 {
00780 QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
00781 for ( int i = 0; i < windows.count(); i++ )
00782 windows.at(i)->widget()->showMinimized();
00783 }
00784
00785 void TGo4MainWindow::CascadeSubWindows()
00786 {
00787 QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
00788
00789 int x(15),y(15);
00790
00791 for ( int i = 0; i < windows.count(); i++ ) {
00792 windows.at(i)->move(x, y);
00793 x+=25; y+=25;
00794 }
00795 }
00796
00797
00798 void TGo4MainWindow::ToggleFullScreenSlot()
00799 {
00800 if (fbFullScreen) showNormal();
00801 else showFullScreen();
00802 fbFullScreen = !fbFullScreen;
00803 }
00804
00805
00806 void TGo4MainWindow::windowsMenuActivated( int id )
00807 {
00808 QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
00809 if ((id>=0) && (id<windows.count())) {
00810 windows.at(id)->widget()->showNormal();
00811 windows.at(id)->widget()->setFocus();
00812 }
00813 }
00814
00815 typedef void* (*TStartUserGuiFunc)(QWidget* parent);
00816
00817 bool TGo4MainWindow::startUserGUI(const char* usergui)
00818 {
00819 QString dirname, libname;
00820
00821 bool result = false;
00822
00823 if ((usergui!=0) && (strlen(usergui)>0)) {
00824 QFileInfo info(usergui);
00825 if (info.exists())
00826 if (info.isFile()) {
00827 dirname = info.path();
00828 libname = info.fileName();
00829
00830 } else
00831 if (info.isDir()) {
00832 dirname = usergui;
00833 }
00834 if ((dirname.length()>0) && (dirname[dirname.length()-1]!='/')) dirname+="/";
00835 }
00836
00837 bool defaultnames = libname.length()==0;
00838 if (defaultnames)
00839 libname = "libGo4UserGui";
00840
00841 TStartUserGuiFunc startfunc = 0;
00842
00843 libname = dirname + libname;
00844
00845 std::cout << "Try usergui: " << libname.toLatin1().constData() << std::endl;
00846
00847 bool loaded = false;
00848
00849 if (gSystem->Load(libname.toLatin1().constData())>=0) {
00850 loaded = true;
00851 startfunc = (TStartUserGuiFunc) gSystem->DynFindSymbol(libname.toLatin1().constData(), "StartUserPanel");
00852 }
00853
00854 if (startfunc!=0) {
00855 QGo4Widget* userpanel = (QGo4Widget*) startfunc(fxMdiArea);
00856 if (userpanel!=0) {
00857 userpanel->setObjectName("UserPanel");
00858
00859 QMdiSubWindow* sub = fxMdiArea->addSubWindow(userpanel);
00860 CascadeMdiPosition(sub);
00861 ConnectGo4Widget(userpanel);
00862 userpanel->ensurePolished();
00863 sub->show();
00864 result = true;
00865 } else
00866 StatusMessage("StartUserPanel() function did not create user widget");
00867 }
00868
00869 if (result) {
00870 std::cout << "Start user GUI from ";
00871 if (dirname.length()>0)
00872 std::cout << dirname.toLatin1().constData() << std::endl;
00873 else
00874 std::cout << "$LD_LIBRARY_PATH=" << gSystem->Getenv("LD_LIBRARY_PATH") << std::endl;
00875 } else {
00876 if (loaded) gSystem->Unload(libname.toLatin1().constData());
00877 }
00878
00879 return result;
00880 }
00881
00882 void TGo4MainWindow::UserPanelSlot()
00883 {
00884 QGo4Widget* userpanel = FindGo4Widget("UserPanel", true);
00885 if (userpanel!=0) return;
00886
00887
00888 if (gSystem->Getenv("GO4USERGUI")!=0)
00889 if (startUserGUI(gSystem->Getenv("GO4USERGUI"))) return;
00890
00891
00892 if (startUserGUI(0)) return;
00893
00894 if (startUserGUI(TGo4Log::subGO4SYS("qt4/Go4UserGUI").Data())) return;
00895
00896 QMessageBox::critical(this,"Starting user GUI", "No suitable libraries found");
00897 }
00898
00899
00900 TGo4ViewPanel* TGo4MainWindow::MakeNewPanel(int ndiv)
00901 {
00902 QString name;
00903
00904 TGo4Slot* edslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
00905
00906 int n = 0;
00907 do {
00908 n++;
00909 name = QString("Panel") + QString::number(n);
00910 } while ((edslot!=0) && (edslot->FindChild(name.toLatin1().constData())!=0));
00911
00912 TGo4ViewPanel* panel = new TGo4ViewPanel(fxMdiArea, name.toLatin1().constData());
00913 QMdiSubWindow* sub = fxMdiArea->addSubWindow(panel);
00914
00915
00916 sub->resize(go4sett->lastPanelSize("ViewPanel"));
00917
00918 CascadeMdiPosition(sub);
00919
00920 ConnectGo4Widget(panel);
00921 panel->update();
00922 panel->show();
00923 panel->ensurePolished();
00924 panel->CompleteInitialization();
00925
00926 if(ndiv>1) {
00927
00928 int DivX(1), DivY(1);
00929
00930 TGo4DividePad* divpad = findChild<TGo4DividePad*>("DividePad");
00931
00932 if (divpad!=0) {
00933 DivX = divpad->SpinBoxX->value();
00934 DivY = divpad->SpinBoxY->value();
00935 }
00936 if (DivX * DivY < ndiv) {
00937 DivX = (int) TMath::Sqrt(ndiv*1.);
00938 DivY = DivX;
00939 while (DivX*DivY<ndiv) DivY++;
00940 }
00941 panel->Divide(DivX, DivY);
00942 }
00943
00944 return panel;
00945 }
00946
00947 void TGo4MainWindow::CascadeMdiPosition(QWidget* sub)
00948 {
00949
00950
00951
00952 int newx = fNewWidgetX;
00953 int newy = fNewWidgetY;
00954 if (newx + sub->width() > fxMdiArea->width()) newx = 0;
00955 if (newy + sub->height() > fxMdiArea->height()) newy = 0;
00956 sub->move(newx, newy);
00957 fNewWidgetX = sub->x() + 30;
00958 fNewWidgetY = sub->y() + 30;
00959 }
00960
00961
00962 void TGo4MainWindow::closeEvent( QCloseEvent* ce)
00963 {
00964 if (fCloseCounter!=0) return;
00965
00966
00967 if(QMessageBox::question( this, "Go4 GUI", "Really Exit Go4?",
00968 QMessageBox::Yes | QMessageBox::No ,
00969 QMessageBox::Yes) != QMessageBox::Yes ) {
00970
00971 ce->ignore();
00972 return;
00973 }
00974
00975 fxMdiArea->closeAllSubWindows();
00976
00977 Browser()->ToggleMonitoring(0);
00978
00979 CloseAllFilesSlot();
00980
00981 StopGUIScriptSlot();
00982 int waitsecs=180;
00983 if(!RemoveAnalysisProxy(waitsecs)) {
00984
00985 fCloseCounter = (waitsecs+10) *10;
00986 statusBar()->showMessage("Exit.... please wait");
00987 QApplication::setOverrideCursor(Qt::WaitCursor);
00988 QTimer::singleShot(100, this, SLOT(ForseCloseSlot()));
00989
00990 ce->ignore();
00991 } else {
00992 statusBar()->showMessage("Closing GUI...");
00993
00994 ce->accept();
00995
00996 }
00997 }
00998
00999 void TGo4MainWindow::ForseCloseSlot()
01000 {
01001
01002
01003 if (Browser()->FindAnalysis()!=0) {
01004
01005 if (fCloseCounter>0) {
01006 fCloseCounter--;
01007 QTimer::singleShot(100, this, SLOT(ForseCloseSlot()));
01008 return;
01009 }
01010
01011 QMessageBox box(QMessageBox::Critical, "Exit GUI", "Analysis is not (yet) shutdown correctly");
01012 QPushButton *wait_btn = box.addButton("Wait 10 s more", QMessageBox::AcceptRole);
01013 QAbstractButton *kill_btn = box.addButton("Kill analysis", QMessageBox::DestructiveRole);
01014 QAbstractButton *exit_btn = box.addButton("Exit immediately", QMessageBox::DestructiveRole);
01015 QAbstractButton *cancel_btn = box.addButton("Cancel quit", QMessageBox::RejectRole);
01016 box.setDefaultButton(wait_btn);
01017
01018 box.exec();
01019
01020 if (box.clickedButton() == wait_btn) {
01021 fCloseCounter = 100;
01022 QTimer::singleShot(100, this, SLOT(ForseCloseSlot()));
01023 return;
01024 }
01025
01026 if ((box.clickedButton() == cancel_btn) || (box.clickedButton() == 0)) {
01027 std::cout << "Keep GUI running, press exit once again" << std::endl;
01028 return;
01029 }
01030
01031 if (box.clickedButton() == kill_btn) {
01032 std::cout << "Killing analysis" << std::endl;
01033 TerminateAnalysis(false);
01034 }
01035
01036 if (box.clickedButton() == exit_btn) {
01037 std::cout << "GUI closed with analysis still running - may lead to analysis task running forever" << std::endl;
01038 std::cout << "Please check running processes with \"ps\" and probably, kill analysis with \"killall go4analysis\" command" << std::endl;
01039 }
01040 }
01041 std::cout << "----- Exiting Go4 GUI now -----" << std::endl;
01042 gSystem->Exit( 0 );
01043 }
01044
01045 void TGo4MainWindow::OpenFileSlot()
01046 {
01047 QFileDialog fd( this,
01048 "Select a ROOT file to open it in the Go4 Disk Browser",
01049 fLastFileDir,
01050 QString("Root files (*.root);;Root xml files (*.xml);;All files (*.*)"));
01051
01052 fd.setFileMode( QFileDialog::ExistingFiles);
01053
01054 if ( fd.exec() != QDialog::Accepted ) return;
01055
01056 QStringList list = fd.selectedFiles();
01057 QStringList::Iterator it = list.begin();
01058 while( it != list.end() ) {
01059 QString fileName = *it;
01060 fLastFileDir = QFileInfo(fileName).absolutePath();
01061 Browser()->OpenFile(fileName.toLatin1().constData());
01062 ++it;
01063 }
01064 }
01065
01066 void TGo4MainWindow::OpenRemoteFileSlot()
01067 {
01068 TGo4OpenRemoteDialog fd( this);
01069 if (fd.exec() != QDialog::Accepted) return;
01070
01071 QString ftype = fd.GetFileType();
01072 QString host = fd.GetServer();
01073
01074 QString urlpath;
01075 if(ftype.contains("root:"))
01076 urlpath = "root://" + host + "/";
01077 else
01078 if (ftype.contains("rfio:")) {
01079 if(!host.isEmpty())
01080 urlpath="rfio:" + host + ":/";
01081 else
01082 urlpath="rfio:/";
01083 } else
01084 if (ftype.contains("http:")) {
01085 if(!host.isEmpty())
01086 urlpath="http://" + host + "/";
01087 else
01088 urlpath="http://";
01089 }
01090
01091 QString fileName = fd.GetFileName();
01092
01093 if(!fileName.isEmpty() && !fileName.contains(".root"))
01094 fileName.append(".root");
01095
01096 fileName = urlpath + fileName;
01097
01098 fxOM->AddFile(fOMDataPath.toLatin1().constData(), fileName.toLatin1().constData());
01099 }
01100
01101 void TGo4MainWindow::ConnectDabcSlot()
01102 {
01103 bool ok = false;
01104 QString dabcnode = QInputDialog::getText(
01105 this, "Establish connection with DABC", "Provide dabc server name",
01106 QLineEdit::Normal, QString::null, &ok);
01107 if (!ok) return;
01108
01109 if (!Browser()->ConnectDabc(dabcnode.toLatin1().constData()))
01110 QMessageBox::warning(0, "DABC server", "Cannot connect to DABC server");
01111 }
01112
01113
01114 void TGo4MainWindow::ConnectHServerSlot()
01115 {
01116 TGo4HServerConnection dlg( this, "Connect to remote HServer", true );
01117
01118 dlg.ServerName->setText(go4sett->getHServName());
01119 dlg.BaseName->setText(go4sett->getHServBase());
01120 dlg.FilterList->setText(go4sett->getHServFilter());
01121 dlg.PortNumberSpin->setValue(go4sett->getHServPort());
01122
01123 if (dlg.exec() != QDialog::Accepted) return;
01124
01125 go4sett->setHServName(dlg.ServerName->text());
01126 go4sett->setHServBase(dlg.BaseName->text());
01127 go4sett->setHServFilter(dlg.FilterList->text());
01128 go4sett->setHServPort(dlg.PortNumberSpin->value());
01129
01130 if (!Browser()->ConnectHServer(dlg.ServerName->text().toLatin1().constData(),
01131 dlg.PortNumberSpin->value(),
01132 dlg.BaseName->text().toLatin1().constData(),
01133 dlg.UserPassEdt->text().toLatin1().constData(),
01134 dlg.FilterList->text().toLatin1().constData()))
01135 QMessageBox::warning(0, "HServer", "Cannot connect to histogram server");
01136 }
01137
01138 void TGo4MainWindow::SaveFileSlot()
01139 {
01140 QFileDialog fd(this,
01141 go4sett->getFetchDataWhenSave() ?
01142 "Select root file to fetch and export all browser objects" :
01143 "Select root file to export all local browser objects",
01144 fLastFileDir, "ROOT (*.root)");
01145
01146 fd.setFileMode( QFileDialog::AnyFile);
01147 fd.setAcceptMode(QFileDialog::AcceptSave);
01148 fd.selectFile("export.root");
01149
01150 if (fd.exec() != QDialog::Accepted) return;
01151
01152 QStringList flst = fd.selectedFiles();
01153 if (flst.isEmpty()) return;
01154
01155 QString fname = flst[0];
01156 fLastFileDir = fd.directory().path();
01157 if (fname.indexOf(".root", 0, Qt::CaseInsensitive)<0) fname+=".root";
01158
01159 if (!Browser()->SaveBrowserToFile(fname.toLatin1().constData(), go4sett->getFetchDataWhenSave()))
01160 QMessageBox::warning(this, "Save data to file", "Specified file can not be created");
01161 }
01162
01163 void TGo4MainWindow::CloseAllFilesSlot()
01164 {
01165 fxOM->CloseFiles(fOMDataPath.toLatin1().constData());
01166 }
01167
01168 void TGo4MainWindow::InputTerminalParametersSlot()
01169 {
01170 int size = go4sett->getTermHistorySize();
01171
01172 bool ok;
01173
01174 size = QInputDialog::getInt(this,
01175 "Analysis terminal history size in bytes (minimum 10000 bytes)",
01176 "Input 0 if full analysis history should be preserved",
01177 size, 0, 100000000, 10000, &ok);
01178
01179 if ((size>0) && (size<10000)) size = 10000;
01180
01181 if (ok) {
01182 go4sett->setTermHistorySize(size);
01183 TGo4AnalysisWindow* anw = FindAnalysisWindow();
01184 if (anw!=0)
01185 anw->SetHistorySize(size);
01186 }
01187 }
01188
01189 void TGo4MainWindow::LogSettingsSlot()
01190 {
01191 TGo4LogSettings dlg;
01192 if (dlg.exec() != QDialog::Accepted) return;
01193
01194 if(dlg.LogfileWrite->isChecked())
01195 TGo4Log::OpenLogfile(dlg.LogfileName->text().toLatin1().constData(), "Logfile for Go4 GUI", true);
01196
01197 TGo4Log::LogfileEnable(dlg.LogfileWrite->isChecked());
01198 TGo4Log::OutputEnable(dlg.LogfilePrint->isChecked());
01199 TGo4Log::SetIgnoreLevel(dlg.IgnoreCombo->currentIndex());
01200 TGo4Log::AutoEnable(dlg.ModeCombo->currentIndex());
01201 }
01202
01203 void TGo4MainWindow::HelpWindow(const char* filename, const char* msg)
01204 {
01205 QApplication::setOverrideCursor( Qt::WaitCursor );
01206
01207 QString surl("file://");
01208 surl.append(TGo4Log::subGO4SYS(filename).Data());
01209
01210 bool result = QDesktopServices::openUrl(QUrl(surl));
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 if(result)
01226 StatusMessage(msg ? QString(msg) : QString("Show ") + filename);
01227 else
01228 StatusMessage(QString("Fail to display ") + filename);
01229
01230 QApplication::restoreOverrideCursor();
01231 }
01232
01233 void TGo4MainWindow::IntroHelpSlot()
01234 {
01235 HelpWindow("docs/Go4Introduction.pdf", "Show Go4 Introduction manual...");
01236 }
01237
01238 void TGo4MainWindow::RefHelpSlot()
01239 {
01240 HelpWindow("docs/Go4Reference.pdf", "Show Go4 Reference manual...");
01241 }
01242
01243 void TGo4MainWindow::FitHelpSlot()
01244 {
01245 HelpWindow("docs/Go4FitTutorial.pdf", "Show Go4 Fit tutorial...");
01246 }
01247
01248 void TGo4MainWindow::SaveSettingsSlot()
01249 {
01250 go4sett->setBasicSettings();
01251 go4sett->setAppFont(QApplication::font());
01252
01253 go4sett->setAppStyle(QApplication::style()->objectName());
01254
01255 go4sett->storeMainWindowState(this);
01256
01257 go4sett->Store();
01258
01259 std::cout <<"Save Qt settings to "<< go4sett->GetSettLoaction().toLatin1().constData() << std::endl;
01260 }
01261
01262 void TGo4MainWindow::ChangeFontSlot()
01263 {
01264 bool ok = false;
01265 QFont font= QFontDialog::getFont(&ok, QApplication::font(), this);
01266 if (!ok) return;
01267
01268 go4sett->setAppFont(font);
01269
01270 QApplication::setFont(font);
01271 }
01272
01273 void TGo4MainWindow::ChangeTerminalFontSlot()
01274 {
01275
01276 bool ok = false;
01277 QFont font= QFontDialog::getFont(&ok, go4sett->getTermFont(), this);
01278 if (!ok) return;
01279
01280 go4sett->setTermFont(font);
01281
01282 TGo4AnalysisWindow* anw = FindAnalysisWindow();
01283 if (anw) anw->setFont(font);
01284 }
01285
01286 void TGo4MainWindow::SetStyleSlot(const QString &style)
01287 {
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300 go4sett->setAppStyle(style);
01301 go4sett->Store();
01302
01303
01304 QApplication::setStyle(style);
01305 }
01306
01307 void TGo4MainWindow::StatusMessage(const QString& mess)
01308 {
01309 QString output = QDateTime::currentDateTime().toString(Qt::ISODate);
01310 output.append(": ");
01311 output.append(mess);
01312 statusBar()->showMessage(output, 3000);
01313 if(TGo4Log::IsAutoEnabled())
01314 TGo4Log::Message(1,output.toLatin1().constData());
01315
01316 UpdateCaptionButtons();
01317 }
01318
01319 void TGo4MainWindow::UpdateCaptionButtons()
01320 {
01321 TGo4AnalysisProxy* pr = Browser()->FindAnalysis();
01322
01323 QString capt = "Go4 ";
01324 capt += __GO4RELEASE__;
01325 capt += " @";
01326 capt += gSystem->HostName();
01327 if ((pr!=0) && pr->IsConnected()) {
01328 capt += " <";
01329 capt += pr->GetContainedObjectInfo();
01330 capt += ">";
01331 }
01332 setWindowTitle(capt);
01333
01334 bool flag = (pr==0);
01335 faLaunchAnal->setEnabled(flag);
01336
01337 if (pr==0) flag = (pr==0);
01338 else flag = (fConnectingCounter<=0) && pr->IsAnalysisServer() && !pr->IsConnected();
01339 faConnectAnal->setEnabled(flag);
01340
01341 faPrepareAnal->setEnabled(flag);
01342
01343 if (pr==0) flag = false;
01344 else flag = pr->IsAnalysisServer() &&
01345 (pr->IsConnected() || (fConnectingCounter<=0));
01346 faDisconnectAnal->setEnabled(flag);
01347
01348 if (pr==0) flag = false;
01349 else flag = !pr->IsAnalysisServer() ||
01350 (pr->IsConnected() && pr->IsAdministrator());
01351 faShutdownAnal->setEnabled(flag);
01352
01353 bool iscontrolling = false;
01354 if (pr!=0)
01355 iscontrolling = pr->IsConnected() && (pr->IsAdministrator() || pr->IsController());
01356 faSumbStartAnal->setEnabled(iscontrolling);
01357
01358 faStartAnal->setEnabled(iscontrolling);
01359
01360 faStopAnal->setEnabled(iscontrolling);
01361
01362 faAnalConfig->setEnabled(iscontrolling);
01363
01364 flag = (FindAnalysisWindow()!=0);
01365 faAnalTermin->setEnabled(flag);
01366 }
01367
01368 void TGo4MainWindow::ChangeFetchWhenDrawSlot()
01369 {
01370 go4sett->setFetchDataWhenDraw(faFetchWhenDraw->isChecked());
01371 }
01372
01373 void TGo4MainWindow::ChangeFetchWhenCopySlot()
01374 {
01375 go4sett->setFetchDataWhenCopy(faFetchWhenCopy->isChecked());
01376 }
01377
01378 void TGo4MainWindow::ChangeFetchWhenSaveSlot()
01379 {
01380 go4sett->setFetchDataWhenSave(faFetchWhenSave->isChecked());
01381 }
01382
01383 void TGo4MainWindow::ChangeHideEventElement()
01384 {
01385 go4sett->setHideTGo4EventElement(faHideEventElement->isChecked());
01386 UpdateBrowser();
01387 }
01388
01389 void TGo4MainWindow::ChangeDrawOnceSlot()
01390 {
01391 go4sett->setDrawOnceFlag(faDrawOnce->isChecked());
01392
01393 }
01394
01395 void TGo4MainWindow::CanvasColorSlot()
01396 {
01397 QColor c = QColorDialog::getColor();
01398 if (c.isValid())
01399 go4sett->setCanvasColor(c.red(), c.green(), c.blue());
01400 }
01401
01402 void TGo4MainWindow::MarkerSettingsSlot()
01403 {
01404 TGo4MarkerSettings mset;
01405 if (mset.exec() != QDialog::Accepted) return;
01406
01407 }
01408
01409 void TGo4MainWindow::OptStatsSlot()
01410 {
01411 TGo4OptStatsSettings stset;
01412 if (stset.exec() != QDialog::Accepted) return;
01413
01414 }
01415
01416 void TGo4MainWindow::CrosshairSlot()
01417 {
01418 go4sett->setPadCrosshair(faCrosshair->isChecked());
01419 }
01420
01421 void TGo4MainWindow::EventStatusSlot()
01422 {
01423 go4sett->setPadEventStatus(faEventstatus->isChecked());
01424 }
01425
01426 void TGo4MainWindow::ChangeCloneFlagSlot()
01427 {
01428 bool s = faClone->isChecked();
01429 faDrawTime->setEnabled(s);
01430 faDrawDate->setEnabled(s);
01431 faDrawItem->setEnabled(s);
01432 go4sett->setCloneFlag(s);
01433 }
01434
01435 void TGo4MainWindow::ChangeDrawTimeFlagSlot()
01436 {
01437 go4sett->setDrawTimeFlag(faDrawTime->isChecked());
01438 }
01439
01440 void TGo4MainWindow::ChangeDrawItemFlagSlot()
01441 {
01442 go4sett->setDrawItemFlag(faDrawItem->isChecked());
01443 }
01444
01445 void TGo4MainWindow::ChangeDrawDateFlagSlot()
01446 {
01447 go4sett->setDrawDateFlag(faDrawDate->isChecked());
01448 }
01449
01450 void TGo4MainWindow::TH1DrawOptSlot()
01451 {
01452 bool ok = false;
01453 QString str = QInputDialog::getText(this,
01454 "Default draw options for TH1 class",
01455 "Input draw options",
01456 QLineEdit::Normal, go4sett->getTH1DrawOpt(), &ok);
01457 if (ok) go4sett->setTH1DrawOpt(str);
01458 }
01459
01460 void TGo4MainWindow::TH2DrawOptSlot()
01461 {
01462 bool ok = false;
01463 QString str = QInputDialog::getText(this,
01464 "Default draw options for TH2 class",
01465 "Input draw options",
01466 QLineEdit::Normal, go4sett->getTH2DrawOpt(), &ok);
01467 if (ok) go4sett->setTH2DrawOpt(str);
01468 }
01469
01470 void TGo4MainWindow::TH3DrawOptSlot()
01471 {
01472 bool ok = false;
01473 QString str = QInputDialog::getText(this,
01474 "Default draw options for TH3 class",
01475 "Input draw options",
01476 QLineEdit::Normal, go4sett->getTH3DrawOpt(), &ok);
01477 if (ok) go4sett->setTH3DrawOpt(str);
01478 }
01479
01480 void TGo4MainWindow::TGraphDrawOptSlot()
01481 {
01482 bool ok = false;
01483 QString str = QInputDialog::getText(this,
01484 "Default draw options for TGraph class",
01485 "Input draw options",
01486 QLineEdit::Normal, go4sett->getTGraphDrawOpt(), &ok);
01487 if (ok)
01488 go4sett->setTGraphDrawOpt(str);
01489 }
01490
01491
01492 void TGo4MainWindow::GStyleStatFormatSlot()
01493 {
01494 bool ok = false;
01495 QString s0 = go4sett->getGStyleStatFormat();
01496 if (s0.isEmpty()) s0 = gStyle->GetStatFormat();
01497
01498 QString str = QInputDialog::getText(this,
01499 "Printf argument for float values - gStyle->GetStatFormat()",
01500 "Input format string like 6.4g (empty - ROOT default)",
01501 QLineEdit::Normal, s0, &ok);
01502 if (ok) {
01503 go4sett->setGStyleStatFormat(str);
01504 if (str.isEmpty())
01505 gStyle->SetStatFormat();
01506 else
01507 gStyle->SetStatFormat(str.toLatin1().constData());
01508 }
01509 }
01510
01511
01512 void TGo4MainWindow::LaunchClientSlot(bool interactive)
01513 {
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01529 if (anal!=0) {
01530 QMessageBox::warning(this, "Launch analysis", "Please disconnect analysis first");
01531 return;
01532 }
01533
01534 if (interactive) {
01535 TGo4StartClient dlg;
01536 if (dlg.exec()!=QDialog::Accepted) return;
01537 dlg.getResults();
01538 }
01539
01540 int shellmode = go4sett->getClientShellMode();
01541 int termmode = go4sett->getClientTermMode();
01542 bool isserver = go4sett->getClientIsServer();
01543
01544 TString launchcmd, killcmd;
01545 Bool_t res = kFALSE;
01546
01547 QString workdir = go4sett->getClientDir();
01548
01549 if (!isserver) {
01550 TGo4AnalysisProxy* anal = AddAnalysisProxy(false, (termmode==1));
01551 if (anal!=0)
01552 res = anal->LaunchAsClient(launchcmd, killcmd,
01553 shellmode,
01554 termmode,
01555 go4sett->getClientName().toLatin1().constData(),
01556 go4sett->getClientNode().toLatin1().constData(),
01557 workdir.toLatin1().constData(),
01558 go4sett->getClientExec().toLatin1().constData(),
01559 go4sett->getClientExeMode(),
01560 go4sett->getClientArgs().toLatin1().constData());
01561 TGo4AnalysisWindow* anw = FindAnalysisWindow();
01562 if (res && (anw!=0) && (termmode==1)) {
01563 anw->StartAnalysisShell(launchcmd.Data(), (shellmode==0) ? workdir.toLatin1().constData() : 0);
01564 }
01565 } else
01566 res = TGo4AnalysisProxy::LaunchAsServer(launchcmd, killcmd,
01567 shellmode,
01568 termmode,
01569 go4sett->getClientName().toLatin1().constData(),
01570 go4sett->getClientNode().toLatin1().constData(),
01571 workdir.toLatin1().constData(),
01572 go4sett->getClientExec().toLatin1().constData(),
01573 go4sett->getClientExeMode(),
01574 go4sett->getClientArgs().toLatin1().constData());
01575
01576 if (res) fKillCommand = killcmd.Data();
01577 else fKillCommand = "";
01578
01579 StatusMessage("Starting Analysis.... Please wait");
01580
01581 if (isserver && interactive)
01582 ConnectServerSlot(true, "");
01583 }
01584
01585 void TGo4MainWindow::PrepareForClientConnectionSlot(bool interactive)
01586 {
01587 TGo4AnalysisProxy* ana = AddAnalysisProxy(false, false);
01588 if ((ana!=0) && interactive)
01589 QMessageBox::information(this,"Prepare for client connection",
01590 "Now you can start client from other shell (node) and connect to port " +
01591 QString::number(ana->ConnectorPort()), "Ok");
01592 }
01593
01594 TGo4AnalysisProxy* TGo4MainWindow::AddAnalysisProxy(bool isserver, bool needoutput)
01595 {
01596 const char* analisysitem = "Analysis";
01597
01598 TGo4Slot* analslot = Browser()->DataSlot(analisysitem);
01599
01600 if (analslot==0) {
01601 TGo4AnalysisProxy* anal = new TGo4AnalysisProxy(isserver);
01602 fxOM->AddProxy(fOMDataPath.toLatin1().constData(), anal, analisysitem, "Analysis proxy");
01603 analslot = Browser()->DataSlot(analisysitem);
01604 anal->SetDefaultReceiver(fxOM, TString("gui/") + analisysitem + "/");
01605 }
01606
01607 TGo4AnalysisProxy* anal = (analslot==0) ? 0 :
01608 dynamic_cast<TGo4AnalysisProxy*> (analslot->GetProxy());
01609
01610 if (anal==0) return 0;
01611
01612 anal->SetAnalysisReady(kFALSE);
01613
01614 TGo4LogInfo* loginfo = (TGo4LogInfo*) FindGo4Widget("LogInfo", false);
01615 if (loginfo!=0)
01616 loginfo->WorkWithInfo(anal->LoginfoSlot());
01617
01618 if (anal->IsAnalysisServer()) {
01619 EstablishRatemeter(anal->IsConnected() ? 2 : 0);
01620 } else
01621 EstablishRatemeter(1);
01622
01623 EstablishAnalysisConfiguration(2);
01624
01625 FindAnalysisConfiguration();
01626
01627 TGo4AnalysisWindow* anw = FindAnalysisWindow();
01628 if (anw!=0)
01629 if (anw->HasOutput() && !needoutput) {
01630 delete anw;
01631 anw = 0;
01632 }
01633
01634 if(anw==0)
01635 if (needoutput) {
01636 anw = new TGo4AnalysisWindow(fxMdiArea, "AnalysisWindow", true);
01637 QMdiSubWindow* sub = fxMdiArea->addSubWindow(anw);
01638 sub->resize(go4sett->lastPanelSize("AnalysisWindow", 700, 500));
01639 CascadeMdiPosition(sub);
01640 ConnectGo4Widget(anw);
01641 anw->ensurePolished();
01642 sub->show();
01643 anw->WorkWithUpdateObjectCmd(anal->UpdateObjectSlot());
01644 } else {
01645 UpdateDockAnalysisWindow();
01646 }
01647
01648 return anal;
01649 }
01650
01651 bool TGo4MainWindow::RemoveAnalysisProxy(int waittime, bool servershutdown)
01652 {
01653 EstablishAnalysisConfiguration(0);
01654
01655 EstablishRatemeter(0);
01656
01657 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01658 if (anal!=0)
01659 anal->DisconnectAnalysis(waittime, servershutdown);
01660
01661 return Browser()->FindAnalysis()==0;
01662 }
01663
01664 void TGo4MainWindow::UpdateDockAnalysisWindow()
01665 {
01666 TGo4AnalysisWindow* anw = FindAnalysisWindow();
01667 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01668
01669 if ((anw!=0) && anw->HasOutput()) return;
01670
01671 bool shouldexists = false;
01672 if (anal!=0)
01673 if (anal->IsAnalysisServer()) {
01674 if (anal->IsConnected() && (anal->IsController() || anal->IsAdministrator()))
01675 shouldexists = true;
01676 } else
01677 shouldexists = true;
01678
01679 if (shouldexists && (anw==0)) {
01680 QToolBar* dock = addToolBar("Analysis control");
01681 dock->setObjectName("AnalysisControlBar");
01682 bool showkill = !anal->IsAnalysisServer() || fKillCommand.length()>0;
01683 anw = new TGo4AnalysisWindow(this, "AnalysisWindow", false, showkill);
01684 ConnectGo4Widget(anw);
01685 dock->addWidget(anw);
01686 anw->WorkWithUpdateObjectCmd(anal->UpdateObjectSlot());
01687 }
01688 }
01689
01690 TGo4AnalysisStatusMonitor* TGo4MainWindow::EstablishRatemeter(int level)
01691
01692
01693
01694 {
01695 TGo4AnalysisStatusMonitor* status =
01696 dynamic_cast<TGo4AnalysisStatusMonitor*>
01697 (FindGo4Widget("AnalysisStatusMonitor", false));
01698
01699 if (level==2) {
01700 if (status==0) {
01701 status = new TGo4AnalysisStatusMonitor(statusBar(), "AnalysisStatusMonitor");
01702 ConnectGo4Widget(status);
01703 statusBar()->addWidget(status);
01704 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01705 if (anal!=0)
01706 status->WorkWithRatemeter(anal->RatemeterSlot());
01707 }
01708 } else
01709 if (level==0) {
01710 if (status!=0) {
01711 statusBar()->removeWidget(status);
01712 delete status;
01713 }
01714 status = 0;
01715 }
01716
01717 if (status!=0)
01718 status->show();
01719
01720 return status;
01721 }
01722
01723 TGo4AnalysisConfiguration* TGo4MainWindow::EstablishAnalysisConfiguration(int level)
01724 {
01725
01726
01727 TGo4AnalysisConfiguration* conf = FindAnalysisConfiguration();
01728
01729 if (level==0) {
01730 if (conf!=0) {
01731 delete conf->parentWidget();
01732 conf = 0;
01733 }
01734 } else
01735 if (level>=2) {
01736 if (conf==0) {
01737 conf = new TGo4AnalysisConfiguration(fxMdiArea, "AnalysisConfiguration");
01738 QMdiSubWindow* sub = fxMdiArea->addSubWindow(conf);
01739 CascadeMdiPosition(sub);
01740 ConnectGo4Widget(conf);
01741
01742
01743
01744 }
01745 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01746 if (anal!=0) {
01747 conf->WorkWithAnalysis(anal);
01748 if (level>2) anal->RequestAnalysisSettings();
01749 }
01750 }
01751
01752 return conf;
01753 }
01754
01755
01756 void TGo4MainWindow::ConnectServerSlot(bool interactive, const char* password)
01757 {
01758 if (fConnectingCounter>0) return;
01759
01760 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01761 if (anal!=0) {
01762 if (anal->IsConnected() || !anal->IsAnalysisServer()) {
01763 if (interactive)
01764 QMessageBox::warning(this, "Connect client", "Analysis task is already connected");
01765 return;
01766 }
01767 }
01768
01769 QString pass = password;
01770 if (interactive) {
01771 TGo4ConnectServer dlg;
01772 if (fLastPassword.length()>0)
01773 dlg.setPassword(fLastPassword.toLatin1().constData());
01774 if (dlg.exec()!=QDialog::Accepted) return;
01775 pass = dlg.getInput();
01776 }
01777
01778 if (anal==0) anal = AddAnalysisProxy(true, false);
01779 bool def = go4sett->getClientDefaultPass();
01780 if (!def) fLastPassword = pass;
01781
01782 if (anal!=0)
01783 anal->ConnectToServer(go4sett->getClientNode().toLatin1().constData(),
01784 go4sett->getClientPort(),
01785 go4sett->getClientControllerMode(),
01786 def ? 0 : pass.toLatin1().constData());
01787 StatusMessage("Connecting running analysis.... Please wait");
01788
01789
01790 fConnectingCounter = 41;
01791 UpdateCaptionButtons();
01792 CheckConnectingCounterSlot();
01793 }
01794
01795 void TGo4MainWindow::CheckConnectingCounterSlot()
01796 {
01797 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01798
01799 if ((anal==0) || anal->IsConnected() || (--fConnectingCounter<=0)) {
01800 if (fConnectingCounter<=0)
01801 StatusMessage("Analysis refused connection. Try again");
01802 fConnectingCounter = 0;
01803 EstablishRatemeter((anal!=0) && anal->IsConnected() ? 2 : 0);
01804 EstablishAnalysisConfiguration((anal!=0) && anal->IsConnected() && (anal->IsController() || anal->IsAdministrator()) ? 3 : 0);
01805 UpdateDockAnalysisWindow();
01806 UpdateCaptionButtons();
01807 if ((anal!=0) && !anal->IsConnected()) RemoveAnalysisProxy(1);
01808 return;
01809 }
01810 QTimer::singleShot(100, this, SLOT(CheckConnectingCounterSlot()));
01811 }
01812
01813 void TGo4MainWindow::DisconnectAnalysisSlot(bool interactive)
01814 {
01815 if (interactive) {
01816 int res = QMessageBox::warning(this, "Disconnect analysis",
01817 QString("Really disconnect from analysis task?"),
01818 QString("Disconnect"),
01819 QString("Cancel"),
01820 QString::null, 0);
01821 if (res!=0) return;
01822 }
01823 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01824 if (anal==0) return;
01825
01826 Browser()->ToggleMonitoring(0);
01827
01828 RemoveAnalysisProxy(30, false);
01829
01830 StatusMessage("Disconnect analysis");
01831 }
01832
01833 void TGo4MainWindow::ShutdownAnalysisSlot(bool interactive)
01834 {
01835 if (interactive) {
01836 int res = QMessageBox::warning(this, "Shutdown analysis",
01837 QString("Really shutdown analysis task?"),
01838 QString("Shutdown"),
01839 QString("Cancel"),
01840 QString::null, 0);
01841 if (res!=0) return;
01842 }
01843
01844 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01845 if (anal==0) return;
01846
01847 Browser()->ToggleMonitoring(0);
01848
01849 bool realshutdown = anal->IsAnalysisServer() &&
01850 anal->IsConnected() &&
01851 anal->IsAdministrator();
01852
01853 RemoveAnalysisProxy(30, realshutdown);
01854
01855 StatusMessage("Shutdown analysis");
01856 }
01857
01858 void TGo4MainWindow::SubmitAnalysisSettings()
01859 {
01860 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01861 if (anal==0) return;
01862
01863 anal->SubmitAnalysisSettings();
01864 anal->RefreshNamesList();
01865 StatusMessage("Press Ctrl+S or choose Analysis->Start from the Menu to start the analysis");
01866 }
01867
01868 void TGo4MainWindow::SubmitStartAnalysisSlot()
01869 {
01870 SubmitAnalysisSettings();
01871 StartAnalysisSlot();
01872 }
01873
01874 void TGo4MainWindow::StartAnalysisSlot()
01875 {
01876 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01877
01878 if (anal==0) return;
01879
01880 anal->StartAnalysis();
01881 anal->RefreshNamesList();
01882 anal->DelayedRefreshNamesList(4);
01883
01884 EstablishRatemeter(2);
01885 }
01886
01887 void TGo4MainWindow::StopAnalysisSlot()
01888 {
01889 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
01890
01891 if (anal!=0)
01892 anal->StopAnalysis();
01893 }
01894
01895 void TGo4MainWindow::TerminateAnalysis(bool interactive)
01896 {
01897 if (interactive) {
01898 int res = QMessageBox::warning(this, "Kill analysis process",
01899 QString("Kill analysis by shell command: ") +fKillCommand + " ?",
01900 QString("Kill"),
01901 QString("Cancel"),
01902 QString::null, 0);
01903 if (res!=0) return;
01904 }
01905
01906 TGo4AnalysisWindow* anw = FindAnalysisWindow();
01907 if (anw!=0) anw->TerminateAnalysisProcess();
01908
01909
01910
01911
01912 anw = FindAnalysisWindow();
01913 if (anw!=0)
01914 anw->AppendOutputBuffer(QString("\nKilling analysis client: \n ")+fKillCommand);
01915 else
01916 StatusMessage(QString("Killing analysis client with: ")+fKillCommand);
01917
01918 if (fKillCommand.length()>0) {
01919 QProcess* killprocess = new QProcess;
01920 killprocess->start(fKillCommand);
01921 QTimer::singleShot(10000, killprocess, SLOT(deleteLater()));
01922 } else
01923 StatusMessage("Can not kill analysis. Do it by OS commands");
01924
01925 EstablishAnalysisConfiguration(0);
01926
01927 EstablishRatemeter(0);
01928 }
01929
01930 QGo4Widget* TGo4MainWindow::FindGo4Widget(const char* name, bool activate)
01931 {
01932 if (fxOM==0) return 0;
01933
01934 TGo4Slot* slot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
01935
01936 TGo4Slot* widgslot = slot==0 ? 0 : slot->FindChild(name);
01937 if (widgslot==0) return 0;
01938
01939 TGo4WidgetProxy* wproxy = (TGo4WidgetProxy*) widgslot->GetProxy();
01940
01941 QGo4Widget* widg = wproxy->GetWidget();
01942 if ((widg!=0) && activate) {
01943 if(!widg->isVisible()){
01944 widg->raise();
01945 widg->show();
01946 widg->setFocus();
01947 }
01948 }
01949
01950 return widg;
01951 }
01952
01953
01954 TGo4FitPanel* TGo4MainWindow::StartFitPanel()
01955 {
01956 TGo4FitPanel* fitpanel = (TGo4FitPanel*) FindGo4Widget("FitPanel", true);
01957
01958 if (fitpanel==0) {
01959 fitpanel = new TGo4FitPanel(fxMdiArea,"FitPanel");
01960 QMdiSubWindow* sub = fxMdiArea->addSubWindow(fitpanel);
01961 CascadeMdiPosition(sub);
01962 ConnectGo4Widget(fitpanel);
01963 fitpanel->ensurePolished();
01964 sub->show();
01965 } else {
01966 fitpanel->parentWidget()->showNormal();
01967 fitpanel->setFocus();
01968 }
01969 return fitpanel;
01970 }
01971
01972 TGo4HistogramInfo* TGo4MainWindow::StartHistogramInfo()
01973 {
01974 TGo4HistogramInfo* hinfo = (TGo4HistogramInfo*) FindGo4Widget("HistogramInfo", true);
01975 if (hinfo==0) {
01976 hinfo = new TGo4HistogramInfo(fxMdiArea, "HistogramInfo");
01977 QMdiSubWindow* sub = fxMdiArea->addSubWindow(hinfo);
01978 CascadeMdiPosition(sub);
01979 ConnectGo4Widget(hinfo);
01980 hinfo->ensurePolished();
01981 hinfo->adjustSize();
01982 sub->show();
01983 }
01984 return hinfo;
01985 }
01986
01987 TGo4ConditionInfo* TGo4MainWindow::StartConditionInfo()
01988 {
01989 TGo4ConditionInfo* cinfo = (TGo4ConditionInfo*) FindGo4Widget("ConditionInfo", true);
01990 if (cinfo==0) {
01991 cinfo = new TGo4ConditionInfo(fxMdiArea, "ConditionInfo");
01992 QMdiSubWindow* sub = fxMdiArea->addSubWindow(cinfo);
01993 CascadeMdiPosition(sub);
01994 ConnectGo4Widget(cinfo);
01995 cinfo->ensurePolished();
01996 cinfo->adjustSize();
01997 sub->show();
01998 }
01999 return cinfo;
02000 }
02001
02002 void TGo4MainWindow::LoadLibrarySlot()
02003 {
02004 TGo4LoadedLibraries llib(this);
02005 llib.exec();
02006
02007 UpdateBrowser();
02008 }
02009
02010 void TGo4MainWindow::UpdateBrowser()
02011 {
02012 TGo4Browser* br = (TGo4Browser*) FindGo4Widget("Browser", false);
02013 if (br!=0) br->ShootUpdateTimer();
02014 }
02015
02016
02017 TGo4ParaEdit* TGo4MainWindow::StartParaEdit(const char* itemname)
02018 {
02019 TGo4ParaEdit* pedit = (TGo4ParaEdit*) FindGo4Widget("ParaEdit", true);
02020
02021 if (itemname!=0) {
02022 TClass* cl = Browser()->ItemClass(itemname);
02023 if (cl!=0)
02024 if (!cl->IsLoaded()) {
02025 QMessageBox::warning(0, "Parameter editor", QString("Cannot start parameter editor for incomplete class ") + cl->GetName());
02026 return pedit;
02027 }
02028 }
02029
02030 if (pedit==0) {
02031 pedit = new TGo4ParaEdit(fxMdiArea, "ParaEdit");
02032 QMdiSubWindow* sub = fxMdiArea->addSubWindow(pedit);
02033 ConnectGo4Widget(pedit);
02034 pedit->ensurePolished();
02035 sub->show();
02036 CascadeMdiPosition(sub);
02037 }
02038
02039 if (itemname!=0)
02040 pedit->WorkWithParameter(itemname, false);
02041
02042 return pedit;
02043 }
02044
02045 TGo4EditDynEntry* TGo4MainWindow::StartEditDynEntry()
02046 {
02047 TGo4EditDynEntry* dedit = (TGo4EditDynEntry*) FindGo4Widget("EditDynEntry", true);
02048
02049 if (dedit==0) {
02050 dedit = new TGo4EditDynEntry(fxMdiArea, "EditDynEntry");
02051 QMdiSubWindow* sub = fxMdiArea->addSubWindow(dedit);
02052 CascadeMdiPosition(sub);
02053 ConnectGo4Widget(dedit);
02054 dedit->ensurePolished();
02055 sub->show();
02056 }
02057
02058 return dedit;
02059 }
02060
02061 TGo4ConditionEditor* TGo4MainWindow::StartConditionEditor()
02062 {
02063 TGo4ConditionEditor* wedit = (TGo4ConditionEditor*) FindGo4Widget("ConditionEditor", true);
02064 if (wedit==0) {
02065 wedit = new TGo4ConditionEditor(fxMdiArea, "ConditionEditor");
02066 QMdiSubWindow* sub = fxMdiArea->addSubWindow(wedit);
02067 CascadeMdiPosition(sub);
02068 ConnectGo4Widget(wedit);
02069 wedit->ensurePolished();
02070 sub->show();
02071 }
02072 return wedit;
02073 }
02074
02075 TGo4EventInfo* TGo4MainWindow::StartEventInfo()
02076 {
02077 TGo4EventInfo* einfo = (TGo4EventInfo*) FindGo4Widget("EventInfo", true);
02078
02079 if (einfo==0) {
02080 einfo = new TGo4EventInfo(fxMdiArea, "EventInfo");
02081 QMdiSubWindow* sub = fxMdiArea->addSubWindow(einfo);
02082 CascadeMdiPosition(sub);
02083 ConnectGo4Widget(einfo);
02084 einfo->ensurePolished();
02085 sub->show();
02086 }
02087
02088 return einfo;
02089 }
02090
02091 TGo4AnalysisConfiguration* TGo4MainWindow::FindAnalysisConfiguration()
02092 {
02093 return (TGo4AnalysisConfiguration*) FindGo4Widget("AnalysisConfiguration", false);
02094 }
02095
02096 void TGo4MainWindow::ToggleAnalysisConfiguration()
02097 {
02098 TGo4AnalysisConfiguration* conf = FindAnalysisConfiguration();
02099 QWidget* mdi = conf ? conf->parentWidget() : 0;
02100
02101 if (mdi==0) return;
02102
02103 if (mdi->isVisible()) {
02104 mdi->hide();
02105 } else {
02106 mdi->raise();
02107 mdi->show();
02108 if (mdi->isMinimized()) mdi->showNormal();
02109 }
02110 }
02111
02112 TGo4AnalysisWindow* TGo4MainWindow::FindAnalysisWindow()
02113 {
02114 return (TGo4AnalysisWindow*) FindGo4Widget("AnalysisWindow", false);
02115 }
02116
02117 void TGo4MainWindow::ToggleAnalysisWindow()
02118 {
02119 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02120 if (anw==0) return;
02121
02122 if (anw->HasOutput()) {
02123 QWidget* mdi = anw->parentWidget();
02124
02125 if (mdi->isVisible()) {
02126 mdi->hide();
02127 } else {
02128 mdi->raise();
02129 mdi->show();
02130 if (mdi->isMinimized()) mdi->showNormal();
02131 }
02132 } else {
02133 QToolBar* dock = dynamic_cast<QToolBar*> (anw->parentWidget());
02134 if (dock->isVisible())
02135 dock->hide();
02136 else
02137 dock->show();
02138 }
02139 }
02140
02141 void TGo4MainWindow::CloseAnalysisWindow()
02142 {
02143 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02144 if (anw==0) return;
02145
02146 if (anw->HasOutput()) {
02147 anw->parentWidget()->close();
02148 } else {
02149 QToolBar* bar = dynamic_cast<QToolBar*> (anw->parentWidget());
02150 removeToolBar(bar);
02151 delete bar;
02152 }
02153 }
02154
02155
02156 void TGo4MainWindow::ToggleMbsMonitor(const char* nodename)
02157 {
02158 TGo4MBSViewer* mbs =
02159 dynamic_cast<TGo4MBSViewer*> (FindGo4Widget("MBSViewer", false));
02160 if (mbs==0) return;
02161 if (mbs->parentWidget()->isVisible()) {
02162 mbs->parentWidget()->hide();
02163 } else {
02164 mbs->SetNode(nodename);
02165 mbs->parentWidget()->show();
02166 }
02167 }
02168
02169
02170 TGo4SetScaleValues* TGo4MainWindow::ToggleScaleValues()
02171 {
02172 TGo4SetScaleValues* scl = 0;
02173
02174 QList<QMdiSubWindow *> windows = fxMdiArea->subWindowList();
02175 for (int i=0; i < windows.count(); ++i ) {
02176 scl = dynamic_cast<TGo4SetScaleValues*> (windows.at(i)->widget());
02177 if (scl!=0) break;
02178 }
02179
02180 if (scl==0) {
02181 scl = new TGo4SetScaleValues(fxMdiArea, "ScaleValues", Qt::WindowStaysOnTopHint);
02182 QMdiSubWindow* sub = fxMdiArea->addSubWindow(scl);
02183 CascadeMdiPosition(sub);
02184 scl->ensurePolished();
02185 sub->show();
02186 } else {
02187 scl->parentWidget()->close();
02188 scl = 0;
02189 }
02190 return scl;
02191 }
02192
02193 void TGo4MainWindow::CreateNewHistSlot(int isremote)
02194 {
02195 TGo4CreateNewHistogram dlg(this);
02196 TGo4AnalysisProxy* an = Browser()->FindAnalysis();
02197
02198 dlg.SetAnalysisAvaliable((isremote!=0) && (an!=0) && an->IsAnalysisSettingsReady());
02199 dlg.SetLocalAvaliable(isremote!=1);
02200
02201 if (dlg.exec() != QDialog::Accepted) return;
02202 TH1* h1 = dlg.MakeHistogram();
02203 if (h1==0) return;
02204
02205 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02206
02207 if (dlg.GetSelectedCmd()==1) {
02208 TString newitem = Browser()->SaveToMemory("", h1, kTRUE);
02209
02210 if (newitem.Length()>0)
02211 editorServiceSlot(anw,
02212 QGo4Widget::service_ObjectCreated,
02213 newitem.Data(), h1->IsA());
02214 h1 = 0;
02215 } else
02216 if ((dlg.GetSelectedCmd()==2) && (an!=0)) {
02217 h1->SetBit(TGo4Status::kGo4CanDelete);
02218 an->UpdateAnalysisObject("", h1);
02219 if (anw!=0) anw->WaitForNewObject(isremote==1);
02220 }
02221 if (h1!=0) delete h1;
02222 }
02223
02224 void TGo4MainWindow::CreateNewConditionSlot(bool forothereditor)
02225 {
02226 TGo4AnalysisProxy* an = Browser()->FindAnalysis();
02227 if ((an==0) || !an->IsAnalysisSettingsReady()) {
02228 QMessageBox::information(this,"Create new condition","Cannot create new condition before analysis setup");
02229 return;
02230 }
02231
02232 TGo4CreateNewCondition dlg(this);
02233
02234 if (dlg.exec() != QDialog::Accepted) return;
02235
02236 TGo4Condition* cond = dlg.MakeCondition();
02237 if (cond==0) return;
02238
02239 cond->SetBit(TGo4Status::kGo4CanDelete);
02240 an->UpdateAnalysisObject("", cond);
02241 delete cond;
02242
02243 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02244 if(anw!=0) anw->WaitForNewObject(forothereditor);
02245 }
02246
02247 void TGo4MainWindow::CreateNewDynEntrySlot(bool forothereditor)
02248 {
02249 TGo4AnalysisProxy* an = Browser()->FindAnalysis();
02250 if ((an==0) || !an->IsAnalysisSettingsReady()) {
02251 QMessageBox::information(this,"Create new dynamic entry","Cannot create new entry before analysis setup");
02252 return;
02253 }
02254
02255 TGo4CreateNewDynEntry dlg(this);
02256
02257 if (dlg.exec() != QDialog::Accepted) return;
02258
02259 TGo4DynamicEntry* entry = dlg.MakeEntry();
02260 if (entry==0) return;
02261
02262 entry->SetBit(TGo4Status::kGo4CanDelete);
02263 an->UpdateAnalysisObject("", entry);
02264 delete entry;
02265
02266 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02267 if (anw!=0) anw->WaitForNewObject(forothereditor);
02268 }
02269
02270 void TGo4MainWindow::ConnectGo4Widget(QGo4Widget* editor)
02271 {
02272 if (editor==0) return;
02273 connect(editor, SIGNAL(widgetService(QGo4Widget*, int, const char*, void*)),
02274 this, SLOT(editorServiceSlot(QGo4Widget*, int, const char*, void*)));
02275 GetWidgetTopSlot(editor, true);
02276 }
02277
02278 TGo4ViewPanel* TGo4MainWindow::DisplayBrowserItem(const char* itemname, TGo4ViewPanel* panel, TPad* pad, bool activate, int updatelevel, const char* drawopt)
02279 {
02280 TGo4BrowserProxy* br = Browser();
02281 if ((br==0) || (itemname==0) || strlen(itemname)==0 ) return 0;
02282
02283 TGo4Slot* guislot = br->BrowserSlot(itemname);
02284
02285 if (guislot==0) return 0;
02286 if (guislot->GetProxy()==0) {
02287 std::cerr << " Problem with gui slots" << std::endl;
02288 return 0;
02289 }
02290
02291 if (panel==0) {
02292 panel = MakeNewPanel();
02293 pad = panel->GetCanvas();
02294 } else
02295 if (pad==0) pad = panel->GetActivePad();
02296
02297 if (panel->AddDrawObject(pad, TGo4ViewPanel::kind_Link, itemname, 0, false, drawopt)==0) return 0;
02298
02299 if (activate) {
02300 panel->SetActivePad(pad);
02301 panel->ShootRepaintTimer();
02302 }
02303
02304 if (updatelevel<0)
02305 if (go4sett->getFetchDataWhenDraw())
02306 updatelevel = 2;
02307 else
02308 updatelevel = 1;
02309
02310 br->GetBrowserObject(itemname, updatelevel);
02311
02312 return panel;
02313 }
02314
02315 bool TGo4MainWindow::SaveBrowserItemToFile(const char* itemname, const char* subfolder)
02316 {
02317 TGo4BrowserProxy* br = Browser();
02318 if ((br==0) || (itemname==0)) return 0;
02319
02320 TString fileslotname;
02321 const char* filepath = 0;
02322
02323 bool res = false;
02324
02325 if (br->DefineFileObject(itemname, fileslotname, &filepath)) {
02326 int answer = QMessageBox::question(this, "Writing object to file",
02327 QString("Overwrite ") + filepath + " in file " + fileslotname.Data(),
02328 "Overwrite", "Save to other file", "Cancel");
02329 if (answer==2) return false;
02330 if (answer==0)
02331 res = br->UpdateObjectInFile(itemname, fileslotname.Data(), filepath);
02332 }
02333
02334 if (!res) {
02335 QString root_fmt = "ROOT (*.root)";
02336 QString xml_fmt = "ROOT XML (*.xml)";
02337
02338 QFileDialog fd(this, QString("Save ") + itemname + " in root file", fLastFileDir);
02339 fd.setFileMode(QFileDialog::AnyFile);
02340 fd.setAcceptMode(QFileDialog::AcceptSave);
02341 fd.setNameFilters(QStringList() << root_fmt << xml_fmt);
02342
02343 if (fd.exec() == QDialog::Accepted) {
02344 QStringList flst = fd.selectedFiles();
02345 if (!flst.isEmpty()) {
02346 QString filename = flst[0];
02347 if (fd.selectedNameFilter()==xml_fmt) {
02348 if (!filename.endsWith(".xml")) filename.append(".xml");
02349 } else {
02350 if (!filename.endsWith(".root")) filename.append(".root");
02351 }
02352 res = br->SaveItemToFile(itemname, filename.toLatin1().constData(), subfolder);
02353 fLastFileDir = fd.directory().path();
02354 }
02355 }
02356 }
02357
02358 return res;
02359 }
02360
02361 void TGo4MainWindow::SavePanelCanvas(TGo4ViewPanel* panel)
02362 {
02363 if (panel==0) return;
02364
02365 TCanvas* can = panel->GetCanvas();
02366
02367 QFileDialog fd( this, QString("Save ") + panel->objectName() + " As", fLastFileDir);
02368 fd.setFileMode( QFileDialog::AnyFile );
02369 fd.setAcceptMode(QFileDialog::AcceptSave);
02370
02371 QString PS = "Post Script (*.ps)";
02372 QString PS_Portrait = "Post Script Portrait (*.ps)";
02373 QString PS_Landscape = "Post Script Landscape (*.ps)";
02374 QString EPS = "Encapsulated Post Script (*.eps)";
02375 QString EPS_Preview = "Encapsulated Post Script previw (*.eps)";
02376 QString GIF = "GIF format (*.gif)";
02377 QString PDF = "PDF format (*.pdf)";
02378 QString SVG = "SVG format (*.svg)";
02379 QString XPM = "XPM format (*.xpm)";
02380 QString PNG = "PNG format (*.png)";
02381 QString JPG = "JPG format (*.jpg)";
02382 QString TIFF = "TIFF format (*.tiff)";
02383
02384 QString CXXM = "C++ Macro (*.C)";
02385 QString ROOTM = "root file (*.root)";
02386
02387 QStringList flt;
02388
02389 flt << PS;
02390 flt << PS_Portrait;
02391 flt << PS_Landscape;
02392 flt << EPS;
02393 flt << EPS_Preview;
02394 flt << PDF;
02395 flt << SVG;
02396 flt << GIF;
02397
02398 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,4,2)
02399 flt << XPM;
02400 flt << PNG;
02401 flt << JPG;
02402 flt << TIFF;
02403 #endif
02404
02405 flt << CXXM;
02406 flt << ROOTM;
02407
02408 fd.setNameFilters(flt);
02409
02410 if (fd.exec() != QDialog::Accepted) return;
02411
02412 QStringList flst = fd.selectedFiles();
02413 if (flst.isEmpty()) return;
02414
02415 QString filename = flst[0];
02416 QString filter = fd.selectedNameFilter();
02417
02418 fLastFileDir = fd.directory().path();
02419
02420 const char* opt = "ps";
02421
02422 if(filter==EPS) {
02423 opt = "eps";
02424 if (!filename.endsWith(".eps")) filename.append(".eps");
02425 } else
02426 if(filter==EPS_Preview) {
02427 opt = "Preview";
02428 if (!filename.endsWith(".eps")) filename.append(".eps");
02429 } else
02430 if(filter==PS) {
02431 opt = "ps";
02432 if (!filename.endsWith(".ps")) filename.append(".ps");
02433 } else
02434 if(filter==PS_Portrait) {
02435 opt = "Portrait";
02436 if (!filename.endsWith(".ps")) filename.append(".ps");
02437 } else
02438 if(filter==PS_Landscape) {
02439 opt = "Landscape";
02440 if (!filename.endsWith(".ps")) filename.append(".ps");
02441 } else
02442 if(filter==GIF) {
02443 opt = "gif";
02444 if (!filename.endsWith(".gif")) filename.append(".gif");
02445 } else
02446 if(filter==PDF) {
02447 opt = "pdf";
02448 if (!filename.endsWith(".pdf")) filename.append(".pdf");
02449 } else
02450 if(filter==SVG) {
02451 opt = "svg";
02452 if (!filename.endsWith(".svg")) filename.append(".svg");
02453 } else
02454 if(filter==XPM) {
02455 opt = "xpm";
02456 if (!filename.endsWith(".xpm")) filename.append(".xpm");
02457 } else
02458 if(filter==PNG) {
02459 opt = "png";
02460 if (!filename.endsWith(".png")) filename.append(".png");
02461 } else
02462 if(filter==JPG) {
02463 opt = "jpg";
02464 if (!filename.endsWith(".jpg")) filename.append(".jpg");
02465 } else
02466 if(filter==TIFF) {
02467 opt = "tiff";
02468 if (!filename.endsWith(".tiff")) filename.append(".tiff");
02469 } else
02470 if(filter==CXXM) {
02471 opt = "cxx";
02472 if (!filename.endsWith(".C")) filename.append(".C");
02473 } else
02474 if (filter==ROOTM) {
02475 opt = "root";
02476 if (!filename.endsWith(".root")) filename.append(".root");
02477
02478
02479
02480 panel->ResetPadFillColors(can,0);
02481 }
02482
02483
02484
02485 can->Print(filename.toLatin1().constData(), opt);
02486 }
02487
02488 TGo4ObjectManager* TGo4MainWindow::OM()
02489 {
02490 return fxOM;
02491 }
02492
02493 TGo4BrowserProxy* TGo4MainWindow::Browser()
02494 {
02495 return (TGo4BrowserProxy*) fxOM->GetProxy(fOMBrowserPath.toLatin1().constData());
02496 }
02497
02498 TGo4Slot* TGo4MainWindow::GetWidgetTopSlot(QGo4Widget* widget, bool force)
02499 {
02500 if (widget==0) return 0;
02501
02502 QString EditorName = widget->objectName();
02503
02504 QString editorslotname = fOMEditorsPath;
02505 editorslotname += "/";
02506 editorslotname += EditorName;
02507 TGo4Slot* edslot = fxOM->GetSlot(editorslotname.toLatin1().constData());
02508 if ((edslot==0) && force) {
02509 fxOM->AddProxy(fOMEditorsPath.toLatin1().constData(), new TGo4WidgetProxy(widget), EditorName.toLatin1().constData(), "Links for Go4 widget");
02510 edslot = fxOM->GetSlot(editorslotname.toLatin1().constData());
02511 }
02512 return edslot;
02513 }
02514
02515 void TGo4MainWindow::checkPanelRepaintSlot()
02516 {
02517
02518 Browser()->SetMonitorBlockingFlag(kTRUE);
02519
02520 fbPanelTimerActive = false;
02521
02522
02523 TGo4ViewPanel* actpanel = fxMdiArea->GetActivePanel();
02524 if ((actpanel!=0) && actpanel->IsRepaintTimerActive())
02525 actpanel->checkRepaintSlot();
02526
02527 if (fbPanelTimerActive) return;
02528
02529
02530 TGo4Slot* topslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
02531 for (int n=0;n<topslot->NumChilds();n++) {
02532 TGo4Slot* subslot = topslot->GetChild(n);
02533
02534 TGo4WidgetProxy* wproxy =
02535 dynamic_cast<TGo4WidgetProxy*> (subslot->GetProxy());
02536 if (wproxy==0) continue;
02537
02538 TGo4ViewPanel* panel =
02539 dynamic_cast<TGo4ViewPanel*> (wproxy->GetWidget());
02540
02541 if ((panel!=0) && (panel!=actpanel))
02542 if (panel->IsRepaintTimerActive()) {
02543 panel->checkRepaintSlot();
02544 if (fbPanelTimerActive) return;
02545 }
02546 }
02547
02548
02549 Browser()->SetMonitorBlockingFlag(kFALSE);
02550 }
02551
02552
02553
02554 void TGo4MainWindow::editorServiceSlot(QGo4Widget* editor, int serviceid, const char* str, void* par)
02555 {
02556 if (editor==0) return;
02557
02558 TGo4LockGuard lock(0,true);
02559
02560 TGo4Slot* edslot = GetWidgetTopSlot(editor, false);
02561 if (edslot==0) return;
02562
02563 switch (serviceid) {
02564 case QGo4Widget::service_DragEnter: {
02565 QDragEnterEvent* event = (QDragEnterEvent*) par;
02566 if ((event==0) || !event->mimeData()->hasText()) return;
02567
02568 QString eventstr = event->mimeData()->text();
02569
02570 bool accept = false;
02571 if (event->source()==FindGo4Widget("Browser",false)) {
02572 int kind = Browser()->ItemKind(eventstr.toLatin1().constData());
02573 TClass* cl = Browser()->ItemClass(eventstr.toLatin1().constData());
02574 accept = editor->IsAcceptDrag(eventstr.toLatin1().constData(), cl, kind);
02575 }
02576
02577 if (accept) event->acceptProposedAction();
02578 break;
02579 }
02580
02581 case QGo4Widget::service_DropEvent: {
02582 QDropEvent* event = (QDropEvent*) par;
02583
02584 if ((event==0) || !event->mimeData()->hasText()) return;
02585
02586 QString eventstr = event->mimeData()->text();
02587 event->acceptProposedAction();
02588
02589 if (event->source()==FindGo4Widget("Browser",false)) {
02590 int kind = Browser()->ItemKind(eventstr.toLatin1().constData());
02591 TClass* cl = Browser()->ItemClass(eventstr.toLatin1().constData());
02592
02593 TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (editor);
02594 TGo4FitPanel* fitpanel = dynamic_cast<TGo4FitPanel*> (editor);
02595 if (panel!=0)
02596 panel->DropOnPad((TPad*)str, eventstr.toLatin1().constData(), cl, kind);
02597 else
02598 if (fitpanel!=0)
02599 fitpanel->DropOnPanel(event, eventstr.toLatin1().constData(), cl, kind);
02600 else
02601 editor->DropItem(eventstr.toLatin1().constData(), cl, kind);
02602 }
02603 break;
02604 }
02605
02606 case QGo4Widget::service_CreateItem: {
02607 TClass* cl = (TClass*) par;
02608 int id = str!=0 ? QString(str).toInt() : 0;
02609 if (cl!=0)
02610 if (cl->InheritsFrom(TH1::Class()))
02611 CreateNewHistSlot(id);
02612 else
02613 if (cl->InheritsFrom(TGo4Condition::Class()) && (id!=0))
02614 CreateNewConditionSlot(id==1);
02615 else
02616 if (cl->InheritsFrom(TGo4DynamicEntry::Class()) && (id!=0))
02617 CreateNewDynEntrySlot(id==1);
02618 break;
02619 }
02620 case QGo4Widget::service_DrawItem: {
02621 void** res = (void**) par;
02622 res[0] = DisplayBrowserItem(str, (TGo4ViewPanel*) res[0], (TPad*) res[1], *((bool*)res[2]), *((int*) res[3]), 0);
02623 break;
02624 }
02625
02626 case QGo4Widget::service_WhereItemDrawn: {
02627 TGo4ViewPanel** res = (TGo4ViewPanel**) par;
02628 *res = 0;
02629 TGo4Slot* topslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
02630 for (int n=0;n<topslot->NumChilds();n++) {
02631 TGo4Slot* subslot = topslot->GetChild(n);
02632
02633 TGo4WidgetProxy* wproxy =
02634 dynamic_cast<TGo4WidgetProxy*> (subslot->GetProxy());
02635 if (wproxy==0) continue;
02636
02637 TGo4ViewPanel* panel =
02638 dynamic_cast<TGo4ViewPanel*> (wproxy->GetWidget());
02639
02640 if (panel!=0)
02641 if (panel->FindPadWithItem(str)!=0) {
02642 *res = panel;
02643 break;
02644 }
02645 }
02646 break;
02647 }
02648
02649 case QGo4Widget::service_UndrawItem: {
02650 TGo4Slot* topslot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
02651
02652 for (int n=0;n<topslot->NumChilds();n++) {
02653 TGo4Slot* subslot = topslot->GetChild(n);
02654
02655 TGo4WidgetProxy* wproxy =
02656 dynamic_cast<TGo4WidgetProxy*> (subslot->GetProxy());
02657 if (wproxy==0) continue;
02658
02659 TGo4ViewPanel* panel =
02660 dynamic_cast<TGo4ViewPanel*> (wproxy->GetWidget());
02661
02662 if (panel!=0)
02663 panel->UndrawItemOnPanel(str);
02664 }
02665
02666 break;
02667 }
02668
02669 case QGo4Widget::service_EditItem: {
02670 TClass* cl = Browser()->ItemClass(str);
02671 Int_t kind = Browser()->ItemKind(str);
02672
02673 if (kind==TGo4Access::kndGo4Param) {
02674 TGo4ParaEdit* paredit = StartParaEdit(str);
02675 break;
02676 } else
02677 if (kind==TGo4Access::kndTreeLeaf) {
02678 TGo4TreeViewer* tviewer =
02679 dynamic_cast<TGo4TreeViewer*> (FindGo4Widget("TreeViewer", false));
02680 if (tviewer!=0) {
02681 tviewer->WorkWithLeaf(str);
02682 tviewer->parentWidget()->show();
02683 }
02684 break;
02685 }
02686
02687 if (cl==0) return;
02688
02689 if (cl->InheritsFrom(TGo4Fitter::Class())) {
02690 TGo4FitPanel* fitpanel = StartFitPanel();
02691 TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (editor);
02692 fitpanel->WorkWithFitter(str, panel, panel==0 ? 0 : panel->GetActivePad());
02693 } else
02694 if (cl->InheritsFrom(TGo4Parameter::Class())) {
02695 TGo4ParaEdit* paredit = StartParaEdit(str);
02696 } else
02697 if (cl->InheritsFrom(TH1::Class())) {
02698 TGo4HistogramInfo* hinfo = StartHistogramInfo();
02699 hinfo->WorkWithHistogram(str);
02700 } else
02701 if (cl->InheritsFrom(TGo4Condition::Class())) {
02702 TGo4ConditionEditor* wedit = StartConditionEditor();
02703 wedit->WorkWithCondition(str);
02704 } else
02705 if (cl->InheritsFrom(TGo4DynamicEntry::Class())) {
02706 TGo4EditDynEntry* dedit = StartEditDynEntry();
02707 dedit->WorkWithEntry(str);
02708 }
02709 break;
02710 }
02711
02712 case QGo4Widget::service_ShowInfo: {
02713 TClass* cl = Browser()->ItemClass(str);
02714 int kind = Browser()->ItemKind(str);
02715 if (kind==TGo4Access::kndEventElement) {
02716 TGo4EventInfo* einfo = StartEventInfo();
02717 einfo->WorkWithEvent(str);
02718 break;
02719 }
02720 if (cl==0) return;
02721 if (cl->InheritsFrom(TH1::Class())) {
02722 TGo4HistogramInfo* hinfo = StartHistogramInfo();
02723 hinfo->WorkWithHistogram(str);
02724 } else
02725 if (cl->InheritsFrom(TGo4Condition::Class())) {
02726 TGo4ConditionInfo* cinfo = StartConditionInfo();
02727 cinfo->WorkWithCondition(str);
02728 }
02729 break;
02730 }
02731
02732 case QGo4Widget::service_EditInSlot: {
02733 TGo4Slot* slot = (TGo4Slot*) par;
02734 if (slot==0) break;
02735 TObject* obj = slot->GetAssignedObject();
02736 if (obj==0) break;
02737 if (obj->InheritsFrom(TGo4Fitter::Class())) {
02738 TGo4FitPanel* fitpanel = StartFitPanel();
02739 fitpanel->WorkWithFitterInSlot(slot);
02740 }
02741 break;
02742 }
02743
02744 case QGo4Widget::service_SaveItem: {
02745 const char* subfolder = (const char*) par;
02746 bool* replace = (bool*) par;
02747 bool res = SaveBrowserItemToFile(str, subfolder);
02748 * ((char*) par) = res ? 1 : 0;
02749 break;
02750 }
02751
02752 case QGo4Widget::service_UpdateAnalysisItem: {
02753 TObject** obj = (TObject**) par;
02754 Bool_t res = Browser()->UpdateAnalysisItem(str, *obj);
02755 if (res) *obj = (TObject*) 1; else *obj = 0;
02756 break;
02757 }
02758
02759 case QGo4Widget::service_StatusMessage: {
02760 StatusMessage(str);
02761 break;
02762 }
02763
02764 case QGo4Widget::service_CreateViewPanel: {
02765 TGo4ViewPanel** res = (TGo4ViewPanel**) par;
02766 *res = MakeNewPanel(QString(str).toInt());
02767 break;
02768 }
02769
02770 case QGo4Widget::service_BrowserItemRemote: {
02771 bool* res = (bool*) par;
02772 *res = Browser()->IsItemRemote(str);
02773 break;
02774 }
02775
02776 case QGo4Widget::service_Browser: {
02777 TGo4BrowserProxy** res = (TGo4BrowserProxy**) par;
02778 *res= Browser();
02779 break;
02780 }
02781
02782 case QGo4Widget::service_SaveToMemory: {
02783 TObject** obj = (TObject**) par;
02784 TString itemname = Browser()->SaveToMemory(str, *obj, true);
02785 QString** res = (QString**) par;
02786 *res = 0;
02787 if (itemname.Length()>0)
02788 *res = new QString(itemname.Data());
02789 break;
02790 }
02791
02792 case QGo4Widget::service_GetAnalysis: {
02793 TGo4AnalysisProxy** res = (TGo4AnalysisProxy**) par;
02794 *res = Browser()->FindAnalysis(str);
02795 break;
02796 }
02797
02798 case QGo4Widget::service_AddEditorLink: {
02799 TGo4Slot* brslot = Browser()->BrowserSlot((const char*)par);
02800
02801 QByteArray ba = editor->objectName().toLatin1();
02802
02803 if (str==0) str = ba.constData();
02804
02805 TGo4Slot* link = fxOM->AddLink(brslot, edslot->GetFullName(),
02806 str, "link to browser item");
02807 if (link!=0)
02808 editor->SetLinkedName(link, (const char*)par);
02809
02810 break;
02811 }
02812
02813 case QGo4Widget::service_AddDirectLink: {
02814
02815 QByteArray ba = editor->objectName().toLatin1();
02816 if (str==0) str = ba.constData();
02817 TGo4Slot* slot = (TGo4Slot*) par;
02818 if (slot!=0) {
02819
02820 fxOM->AddLink(slot, edslot->GetFullName(),
02821 str, "direct link to OM slot");
02822
02823 }
02824 break;
02825 }
02826
02827 case QGo4Widget::service_AddLinkInSlot: {
02828
02829
02830 TGo4Slot** res = (TGo4Slot**) par;
02831
02832 TGo4Slot* parent = *res;
02833 *res = 0;
02834 if (parent==0) parent = edslot;
02835 TGo4Slot* brslot = Browser()->BrowserSlot(str);
02836
02837 if (brslot!=0) {
02838 *res = fxOM->AddLink(brslot, parent->GetFullName(),
02839 brslot->GetName(), "link in specific subfolder");
02840 if (*res!=0)
02841 editor->SetLinkedName(*res, str);
02842 }
02843 break;
02844 }
02845
02846 case QGo4Widget::service_GetTopSlot: {
02847 TGo4Slot** res = (TGo4Slot**) par;
02848 *res = edslot;
02849 break;
02850 }
02851
02852 case QGo4Widget::service_AddEditorSlot: {
02853 TGo4Slot* objslot = edslot->FindChild(str);
02854
02855 if (objslot==0)
02856 objslot = fxOM->MakeObjSlot(edslot->GetFullName(), str, "Place for editor object");
02857 if (objslot!=0)
02858 objslot->SetProxy(new TGo4ObjectProxy);
02859
02860 TGo4Slot** res = (TGo4Slot**) par;
02861 *res = objslot;
02862 break;
02863 }
02864
02865 case QGo4Widget::service_SetLinkedName: {
02866 TGo4BrowserProxy::SetLinkedName((TGo4Slot*) par, str);
02867 break;
02868 }
02869
02870 case QGo4Widget::service_GetLinkedName: {
02871 if (edslot==0) return;
02872 const char** res = (const char**) par;
02873 *res = TGo4BrowserProxy::GetLinkedName(edslot->FindChild(str));
02874 break;
02875 }
02876
02877 case QGo4Widget::service_GetLinkedName2: {
02878 void** res = (void**) par;
02879 TGo4Slot* link = (TGo4Slot*) *res;
02880 *res = (void*) TGo4BrowserProxy::GetLinkedName(link);
02881 break;
02882 }
02883
02884 case QGo4Widget::service_GetLinked0:
02885 case QGo4Widget::service_GetLinked1:
02886 case QGo4Widget::service_GetLinked2: {
02887 if (edslot==0) return;
02888 TGo4Slot* link = edslot->FindChild(str);
02889 if (link==0) return;
02890 const char* itemname = TGo4BrowserProxy::GetLinkedName(link);
02891 TObject** res = (TObject**) par;
02892 int updatelevel = serviceid - QGo4Widget::service_GetLinked0;
02893 if (itemname!=0)
02894 *res = Browser()->GetBrowserObject(itemname, updatelevel);
02895 else
02896 *res = link->GetAssignedObject();
02897 break;
02898 }
02899
02900 case QGo4Widget::service_RemoveLink: {
02901 if (edslot==0) return;
02902 TGo4Slot* link = edslot->FindChild(str);
02903 if (link!=0) link->Delete();
02904 break;
02905 }
02906
02907 case QGo4Widget::service_RemoveAllLinks: {
02908 if ((str==0) || (strcmp(str,"complete")!=0))
02909 edslot->DeleteChilds(str);
02910 else
02911 edslot->Delete();
02912 break;
02913 }
02914
02915 case QGo4Widget::service_ObjectCreated: {
02916 TGo4Slot* slot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
02917 for (int n=0;n<slot->NumChilds();n++) {
02918 TGo4Slot* subslot = slot->GetChild(n);
02919 if (edslot==subslot) continue;
02920
02921 TGo4WidgetProxy* wproxy =
02922 dynamic_cast<TGo4WidgetProxy*>
02923 (subslot->GetProxy());
02924
02925 if (wproxy!=0)
02926 wproxy->GetWidget()->ObjectCreatedByWidget(str, (TClass*) par);
02927 }
02928 break;
02929 }
02930
02931 case QGo4Widget::service_ConnectPad: {
02932 if (edslot==0) break;
02933
02934 TGo4WidgetProxy* proxy =
02935 dynamic_cast<TGo4WidgetProxy*> (edslot->GetProxy());
02936 if (proxy!=0)
02937 proxy->ConnectPad((TPad*) par);
02938 break;
02939 }
02940
02941 case QGo4Widget::service_LastActivePanel: {
02942 TGo4ViewPanel** res = (TGo4ViewPanel**) par;
02943 *res = fxMdiArea->GetActivePanel();
02944 break;
02945 }
02946
02947 case QGo4Widget::service_General: {
02948 if (strcmp(str,"CloseAnalysisWindow")==0) {
02949
02950
02951 QTimer::singleShot(100, this, SLOT(CloseAnalysisWindow()));
02952 } else
02953
02954 if (strcmp(str,"PrintAnalysisHistograms")==0) {
02955 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02956 if (anw!=0) anw->PrintHistograms();
02957 } else
02958
02959 if (strcmp(str,"PrintAnalysisConditions")==0) {
02960 TGo4AnalysisWindow* anw = FindAnalysisWindow();
02961 if (anw!=0) anw->PrintConditions();
02962 } else
02963
02964 if (strcmp(str,"DisplayMbsMonitor")==0) {
02965 ToggleMbsMonitor((const char*) par);
02966 } else
02967
02968 if (strcmp(str,"SubmitAnalysisSettings")==0) {
02969 SubmitAnalysisSettings();
02970 } else
02971
02972 if (strcmp(str,"CloseAnalysisSettings")==0) {
02973 TGo4AnalysisProxy* anal = Browser()->FindAnalysis();
02974 if (anal!=0) {
02975 anal->CloseAnalysisSettings();
02976 anal->RefreshNamesList();
02977 }
02978 } else
02979
02980 if (strcmp(str,"SubmitStartAnalysis")==0) {
02981 SubmitStartAnalysisSlot();
02982 } else
02983
02984 if (strcmp(str,"StartAnalysis")==0) {
02985 StartAnalysisSlot();
02986 } else
02987
02988 if (strcmp(str,"StopAnalysis")==0) {
02989 StopAnalysisSlot();
02990 } else
02991
02992 if (strcmp(str,"TerminateAnalysis")==0) {
02993 TerminateAnalysis(true);
02994 } else
02995
02996 if (strcmp(str,"UpdateGuiLayout")==0) {
02997 UpdateCaptionButtons();
02998 } else
02999
03000 if (strcmp(str, "StartEventInfo")==0) {
03001 StartEventInfo();
03002 } else
03003
03004 if (strcmp(str, "ActivateConditionEditor")==0) {
03005 TGo4ConditionEditor* w =
03006 (TGo4ConditionEditor*) FindGo4Widget("ConditionEditor", true);
03007 if (w!=0) {
03008 w->setFocus();
03009 w->RefreshWidget(true);
03010 }
03011 } else
03012
03013 if (strcmp(str, "SavePanelCanvas")==0) {
03014 SavePanelCanvas(dynamic_cast<TGo4ViewPanel*>(editor));
03015 } else
03016
03017 if (strcmp(str, "ToggleScaleValues")==0) {
03018 ToggleScaleValues();
03019 } else
03020
03021 if (strcmp(str, "GetFitterFromFitPanel")==0) {
03022 TGo4FitPanel* panel = (TGo4FitPanel*) FindGo4Widget("FitPanel", false);
03023 TGo4Fitter** res = (TGo4Fitter**) par;
03024 if ((panel!=0) && (res!=0))
03025 *res = panel->GetFitter();
03026 } else
03027
03028 if (strcmp(str, "CloneFitterFromFitPanel")==0) {
03029 TGo4FitPanel* panel = (TGo4FitPanel*) FindGo4Widget("FitPanel", false);
03030 TGo4Fitter** res = (TGo4Fitter**) par;
03031 if ((panel!=0) && (res!=0))
03032 *res = panel->CloneFitter();
03033 }
03034
03035 break;
03036 }
03037
03038 case QGo4Widget::service_PanelTimer: {
03039 TGo4ViewPanel* panel = (TGo4ViewPanel*) editor;
03040 if (!fbPanelTimerActive) {
03041 fbPanelTimerActive = true;
03042 QTimer::singleShot(0, this, SLOT(checkPanelRepaintSlot()));
03043 }
03044
03045 break;
03046 }
03047
03048 case QGo4Widget::service_HelpWindow: {
03049 HelpWindow(str, (const char*) par);
03050 break;
03051 }
03052
03053 case QGo4Widget::service_HotStart: {
03054 HotStart(str);
03055 break;
03056 }
03057
03058 case QGo4Widget::panel_Activated:
03059 case QGo4Widget::panel_Modified:
03060 case QGo4Widget::panel_Updated:
03061 case QGo4Widget::panel_ActiveUpdated:
03062 case QGo4Widget::panel_PadDeleted:
03063 case QGo4Widget::panel_Deleted: {
03064 TGo4ViewPanel* panel = (TGo4ViewPanel*) editor;
03065 TPad* pad = (TPad*) par;
03066 fxMdiArea->ResponseOnPanelEvent(serviceid, panel, pad);
03067 break;
03068 }
03069
03070 }
03071 }
03072
03073
03074
03075 void TGo4MainWindow::HotStart(const char* fname)
03076 {
03077 if (fname==0) return;
03078
03079 TGo4Script* exec = TGo4Script::ScriptInstance();
03080 if(exec==0) return;
03081
03082 if (!exec->StartScriptExecution(fname)) return;
03083
03084 QTimer::singleShot(TGo4AbstractInterface::DelayMillisec(), this, SLOT(ProcessHotStart()));
03085 }
03086
03087 void TGo4MainWindow::ProcessHotStart()
03088 {
03089 TGo4Script* exec = TGo4Script::ScriptInstance();
03090 if (exec==0) return;
03091
03092 Bool_t res = kTRUE;
03093 do {
03094 res = exec->ContinueExecution();
03095 } while(res && !exec->IsWaitSomething());
03096
03097 if (res) {
03098 QTimer::singleShot(TGo4AbstractInterface::DelayMillisec(), this, SLOT(ProcessHotStart()));
03099 if (QApplication::overrideCursor()==0)
03100 QApplication::setOverrideCursor(Qt::WaitCursor);
03101 } else {
03102 exec->FinishExecution();
03103 StatusMessage("Script execution done");
03104 QApplication::restoreOverrideCursor();
03105 }
03106 }
03107
03108 void TGo4MainWindow::StopGUIScriptSlot()
03109 {
03110 TGo4Script* exec = TGo4Script::ScriptInstance();
03111 if (exec!=0) exec->FinishExecution();
03112 }
03113
03114 void TGo4MainWindow::CreateGUIScriptSlot()
03115 {
03116 QString ext = TGo4AbstractInterface::FileExtension();
03117 QString fileName =
03118 QFileDialog::getSaveFileName(this,
03119 "Create GUI script dialog",
03120 fLastFileDir,
03121 QString("GUI hotstart script (*") + ext + ")");
03122 if (fileName.length()==0) return;
03123
03124 int pos = fileName.indexOf(ext);
03125
03126 if ((pos<0) || (pos!=fileName.length()-ext.length()))
03127 fileName+=ext;
03128
03129 StatusMessage(QString("Generate script ")+fileName);
03130
03131 TGo4Script::ProduceScript(fileName.toLatin1().constData(), this);
03132 }
03133
03134 void TGo4MainWindow::ProcessQtEvents()
03135 {
03136 if (fApp!=0) fApp->processEvents(QEventLoop::AllEvents, TGo4AbstractInterface::DelayMillisec());
03137 }
03138
03139 TGo4ViewPanel* TGo4MainWindow::FindViewPanel(const char* name)
03140 {
03141 if ((name==0) || (*name==0)) return 0;
03142
03143 TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (FindGo4Widget(name, false));
03144
03145 if (panel!=0) return panel;
03146
03147 TGo4Slot* slot = fxOM->GetSlot(fOMEditorsPath.toLatin1().constData());
03148
03149 for (Int_t n=0;n<slot->NumChilds();n++) {
03150 TGo4Slot* widgslot = slot->GetChild(n);
03151 TGo4WidgetProxy* wproxy = widgslot==0 ? 0 : dynamic_cast<TGo4WidgetProxy*> (widgslot->GetProxy());
03152 panel = wproxy==0 ? 0 : dynamic_cast<TGo4ViewPanel*> (wproxy->GetWidget());
03153
03154 if (panel!=0)
03155 if (strcmp(panel->GetPanelName(), name)==0) return panel;
03156 }
03157
03158 return 0;
03159 }