Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4GUI/TGo4MainWindow.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4MainWindow.h"
00017 
00018 #include <dlfcn.h>
00019 #include <iostream.h>
00020 
00021 #include "qdockarea.h"
00022 #include "qcolor.h"
00023 #include "qcolordialog.h"
00024 #include "qnamespace.h"
00025 #include "qstring.h"
00026 #include "qvaluevector.h"
00027 #include "qtabwidget.h"
00028 #include "qvariant.h"
00029 #include "qmime.h"
00030 #include "qdragobject.h"
00031 #include "qlayout.h"
00032 #include "qtooltip.h"
00033 #include "qwhatsthis.h"
00034 #include "qaction.h"
00035 #include "qmenubar.h"
00036 #include "qpopupmenu.h"
00037 #include "qtoolbar.h"
00038 #include "qimage.h"
00039 #include "qpixmap.h"
00040 #include "qtextbrowser.h"
00041 #include "qfontdialog.h"
00042 #include "TGo4QSettings.h"
00043 #include "qapplication.h"
00044 #include "qclipboard.h"
00045 #include "qstatusbar.h"
00046 #include "qtoolbutton.h"
00047 #include "qsignalmapper.h"
00048 #include "qstylefactory.h"
00049 #include "qfiledialog.h"
00050 #include "qlayout.h"
00051 #include "qmessagebox.h"
00052 #include "qradiobutton.h"
00053 #include "qcombobox.h"
00054 #include "helpwindow.h"
00055 #include "qinputdialog.h"
00056 #include "qdir.h"
00057 #include "qfileinfo.h"
00058 
00059 
00061 #include "TSystem.h"
00062 #include "TH1.h"
00063 #include "TColor.h"
00064 #include "TList.h"
00065 
00067 #include "qtroot/interface/qrootapplication.h"
00068 #include "Go4LockGuard/TGo4LockGuard.h"
00069 #include "Go4TaskHandler/TGo4TaskHandler.h"
00070 #include "Go4Display/TGo4Display.h"
00071 #include "Go4Analysis/TGo4Version.h"
00072 #include "Go4Log/TGo4Log.h"
00073 #include "Go4ConditionsBase/TGo4Condition.h"
00074 #include "Go4ConditionsBase/TGo4Marker.h"
00075 #include "Go4QtBaseWidgets/wood.h"
00076 #include "Go4QtBaseWidgets/metal.h"
00077 #include "Go4QtBaseWidgets/TGo4QDockWindow.h"
00078 #include "Go4QtBaseWidgets/TGo4WorkSpace.h"
00079 #include "Go4FitGUI/TGo4FitPanel.h"
00080 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00081 
00082 #include "Go4QtBaseWidgets/TGo4QItem.h"
00083 
00085 #include "TGo4TreeViewer.h"
00086 #include "TGo4TreeViewerSlots.h"
00087 #include "TGo4DockBrowsers.h"
00088 #include "TGo4DiskFileBrowser.h"
00089 #include "TGo4DiskFileBrowserSlots.h"
00090 #include "TGo4Browser.h"
00091 #include "TGo4BrowserSlots.h"
00092 #include "TGo4RemoteBrowser.h"
00093 #include "TGo4RemoteBrowserSlots.h"
00094 #include "TGo4MonitoredList.h"
00095 #include "TGo4MonitoredListSlots.h"
00096 #include "TGo4MonitoredListStatus.h"
00097 #include "TGo4MonitoredObject.h"
00098 #include "TGo4Style.h"
00099 #include "TGo4PadOptions.h"
00100 #include "TGo4PreviewPanel.h"
00101 #include "TGo4QRootCanvas.h"
00102 #include "TGo4AnalysisConfigurationSlots.h"
00103 #include "TGo4AnalysisConfiguration.h"
00104 #include "TGo4AnalysisWindow.h"
00105 #include "TGo4StartClient.h"
00106 #include "TGo4StartClientSlots.h"
00107 #include "TGo4HisDrawOptions.h"
00108 #include "TGo4ScaleOptions.h"
00109 #include "TGo4DividePad.h"
00110 #include "TGo4CreateNewHistogram.h"
00111 #include "TGo4CreateNewHistogramSlots.h"
00112 #include "TGo4ConditionInfo.h"
00113 #include "TGo4ConditionInfoSlots.h"
00114 #include "TGo4HistogramInfo.h"
00115 #include "TGo4HistogramInfoSlots.h"
00116 #include "TGo4EventInfo.h"
00117 #include "TGo4EventInfoSlots.h"
00118 #include "TGo4LoadedLibrariesSlots.h"
00119 #include "TGo4LoadedLibraries.h"
00120 #include "TGo4EditDynEntry.h"
00121 #include "TGo4EditDynEntrySlots.h"
00122 #include "TGo4ParaEdit.h"
00123 #include "TGo4ParaEditSlots.h"
00124 #include "TGo4AnalysisStatusMonitor.h"
00125 #include "TGo4AnalysisStatusMonitorSlots.h"
00126 #include "TGo4WindowEdit.h"
00127 #include "TGo4WindowEditSlots.h"
00128 #include "TGo4LogSettings.h"
00129 #include "TGo4LogInfo.h"
00130 #include "TGo4ScriptWidget.h"
00131 #include "TGo4ScriptSlots.h"
00132 
00133 typedef void (*fxAction) ();
00134 
00135 QPixmap TGo4MainWindow::uic_load_pixmap( const QString &name )
00136 {
00137     const QMimeSource *m = QMimeSourceFactory::defaultFactory()->data( name );
00138     if ( !m )
00139    return QPixmap();
00140     QPixmap pix;
00141     QImageDrag::decode( m, pix );
00142     return pix;
00143 }
00144 
00145 
00146 
00147 TGo4MainWindow::TGo4MainWindow( QWidget* parent,  const char* name, WFlags fl, bool Local)
00148     : QMainWindow( parent, name, fl ),fbLocalMode(Local),fiMasterMode(0)
00149 {
00150     // TGo4LockGuard glob;
00151     fxToolsfile="/go4toolsrc";
00152     fxSettingsfolder="/.qt";
00153     setDockWindowsMovable(TRUE);
00154     bool con;
00155     statusBar();
00156     if ( !name ) setName( "TGo4MainWindow" );
00157     resize( 1152, 864 );
00158     SetMasterMode(-1); // will init window caption
00159     fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00160     setIcon( TGo4MainWindow::uic_load_pixmap( "go4logo2" ) );
00161     setRightJustification( TRUE );
00162     setUsesTextLabel( TRUE );
00163     setOpaqueMoving( FALSE );
00164     fiPadcolorR=255;
00165     fiPadcolorB=255;
00166     fiPadcolorG=255;
00167     fbCrosshairMode=false;
00168     fxTGo4WorkSpace = new TGo4WorkSpace(this);
00169     fxTGo4WorkSpace->setScrollBarsEnabled(TRUE);
00170     setCentralWidget( fxTGo4WorkSpace);
00171 
00172     fxTGo4GUIRegistry->SetMainWindow(this);
00173     fxTGo4GUIRegistry->SetCentralWindow(fxTGo4WorkSpace);
00174 //  fxTGo4WorkSpace->setPaletteBackgroundPixmap ( TGo4MainWindow::uic_load_pixmap( "go4logo2" )  );
00175     fxTGo4WorkSpace->setFocus();
00176     con= connect(fxTGo4WorkSpace,SIGNAL(windowActivated(QWidget*)), this, SLOT( WindowActivatedSlot(QWidget*)));
00177     con= connect(fxTGo4WorkSpace, SIGNAL(childRemoved(TGo4PreviewPanel *)), this, SLOT( WorkSpaceRemovedChild(TGo4PreviewPanel *)));
00178     con= connect(fxTGo4WorkSpace, SIGNAL(newChild(TGo4PreviewPanel *)), this, SLOT( WorkSpaceNewChild(TGo4PreviewPanel *)));
00179     con= connect(fxTGo4WorkSpace, SIGNAL(ActivePad(TGo4PreviewPanel *,TPad *)), this, SLOT(ActivePadChanged(TGo4PreviewPanel *,TPad *)));
00180     con= connect(fxTGo4WorkSpace, SIGNAL(PadMouseClick(TGo4PreviewPanel *,TPad *)), this, SLOT(MouseClick(TGo4PreviewPanel *,TPad *)));
00181 
00182 
00183     // menubar
00184     /* QMenuBar* menubar = */ new QMenuBar( this, "menubar" );
00185 
00186      /************ *********
00187        *File  Menu & Tools
00188        **********************/
00189      AddFileMenu();
00190      AddFileToolBar();
00191 
00192      /************ *********
00193        *Script  Menu & Tools
00194        **********************/
00195      // disabled for release JA
00196      //AddScriptToolBar();
00197 
00198     /************ *********
00199        *Tools Menu & Tools
00200     **********************/
00201 
00202     AddToolsMenu();
00203     AddToolsBar();
00204     /*********************
00205        * Analysis Menu & Tools
00206      **********************/
00207     if(!Local){
00208        AddAnalysisMenu();
00209        AddAnalysisBar();
00210     }
00211 
00212    /**************************
00213    Setting Menu
00214 
00215   ****************************/
00216      AddSettingMenu();
00217 
00218 
00219     /************ *********
00220        *window Menu
00221     **********************/
00222       windowsMenu = new QPopupMenu( this );
00223       connect( windowsMenu, SIGNAL( aboutToShow() ), this, SLOT( windowsMenuAboutToShow() ) );
00224       menuBar()->insertItem( "&Windows", windowsMenu );
00225 
00226 
00227     /********************
00228       *Status Bar
00229       ********************/
00230      statusBar()->message("Ready");
00231      statusBar()->setSizeGripEnabled (TRUE) ;
00232 
00233 
00234 
00235 
00236      fxTGo4HisDrawOptions=0;
00237      fxTGo4ScaleOptions=0;
00238      fxTGo4DividePad=0;
00239      fxTGo4Style=0;
00240      fxTGo4LogInfo=0;
00241      fxTGo4TreeViewer=0;
00242      fxTGo4FitPanel=0;
00243      fxTGo4DockBrowsers=0;
00244      fxAnalysisShell=0;
00245      fxTGo4AnalysisStatusMonitor=0;
00246      fxTGo4MainUserPanel=0;
00247      fxWinConSlotList= new TList;
00248      fxWinConIterator= fxWinConSlotList->MakeIterator();
00249      Go4BrowsersSlot(); //START THE BROWSER
00250      DivideCanvasSlot();
00251      StyleSlot();
00252      DrawOptionsSlot();
00253      ScaleOptionsSlot();
00254      Go4TreeViewerSlot();
00255      LogPanelSlot();
00256 
00257 
00258 
00259 
00260     menuBar()->insertSeparator();
00261     QPopupMenu *HelpMenu = new QPopupMenu( this );
00262     menuBar()->insertItem( "&Help",HelpMenu);
00263     HelpMenu->insertItem("&Introduction", this, SLOT(IntroHelpSlot()));
00264     HelpMenu->insertItem("&Reference", this, SLOT(RefHelpSlot()));
00265     HelpMenu->insertItem("&Fit Tutorial", this, SLOT(FitHelpSlot()));
00266     HelpMenu->insertSeparator();
00267     
00268     HelpMenu->insertItem( "About &Qt", this, SLOT(aboutQt()), Key_F2 );
00269     HelpMenu->insertItem( "About R&OOT", this, SLOT(aboutROOT()),Key_F3);
00270     HelpMenu->insertItem( "About &Go4", this, SLOT(about()), Key_F4);
00271          // note: connecting about() with Key_F1 did not work! now using F4 JA
00272 //   AddDrawBar();
00273 
00274    QString Env=getenv("GO4USERLIBRARY");
00275    QString SEP=":";
00276     QStringList LibList = QStringList::split(SEP,Env);
00277 
00278     for (QStringList::Iterator it=LibList.begin(); it!=LibList.end(); ++it){
00279           gSystem->Load((*it).data());
00280           cout << "Loading Library  " << *it << "   " <<endl;
00281     }
00282 
00283    init();
00284 }
00285 
00286 TGo4MainWindow::~TGo4MainWindow() {
00287    //cout <<"mainwindow dtor" << endl;
00288     // close fit panel before any other window will be closed
00289     if ((fxTGo4FitPanel!=0) && fxTGo4FitPanel->isVisible())
00290          fxTGo4FitPanel->close();
00291     // shutdown condition editors:
00292     fxWinConIterator->Reset();
00293       TObject* ob=0;
00294       while((ob=fxWinConIterator->Next()) !=0)
00295         {
00296             TGo4WindowEditSlots* ws=dynamic_cast<TGo4WindowEditSlots*>(ob);
00297             if(ws)
00298                {
00299                   TGo4WindowEdit* we=ws->GetGUI();
00300                   we->close();
00301                   //cout <<"deleted condition editor "<<we << endl;
00302                }
00303         }
00304     delete fxWinConIterator;
00305     delete fxWinConSlotList;
00306     //delete fxTGo4WorkSpace; // not necessary, since we are the Qt parent widget...
00307 //    delete fxTGo4HisDrawOptions;
00308 //    delete fxTGo4ScaleOptions;
00309 //    delete fxTGo4DividePad;
00310 //    delete fxTGo4Style;
00311 //    delete fxTGo4DockBrowsers;
00312 //    delete fxTGo4LogInfo;
00313 //    delete fxTGo4TreeViewer;
00314 }
00315 
00316 void TGo4MainWindow::HotStart(const char* fname) {
00317    if (fname==0) return;
00318 
00319 //   QString name(fname);
00320 //   if (name.find('.')<0) name+=".hotstart";
00321 
00322    TGo4ScriptWidget* widg = 0;
00323 
00324    TGo4ScriptSlots* sl = dynamic_cast<TGo4ScriptSlots*> (fxTGo4GUIRegistry->GetSlotClass("TGo4ScriptSlots"));
00325    if (sl!=0)
00326       widg = sl->GetGUI();
00327 
00328    if (widg==0) {
00329       widg = new TGo4ScriptWidget(fxTGo4WorkSpace);
00330       widg->polish();
00331    } else
00332        widg->raise();
00333 
00334     widg->show();
00335 
00336     widg->executeScript(fname);
00337 }
00338 
00339 
00340 void TGo4MainWindow::about()
00341 {
00342    QString GO4STR= "Go4  ";
00343    GO4STR.append ( __GO4RELEASE__);
00344    QString GO4STR1= GO4STR;
00345    GO4STR1.append("\n");
00346    GO4STR1.append("The Go4 (GSI Object Oriented On-line Off-line system)  is based on ROOT\n with the specific requirements of the low and medium energy nuclear and atomic\n physics experiments implemented as extensions.\n See  http://go4.gsi.de  for more information") ;
00347 
00348 
00349    QPixmap pic= TGo4MainWindow::uic_load_pixmap( "go4logo2");
00350     QMessageBox AboutGo4(GO4STR,GO4STR1, QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton ,this);
00351    AboutGo4.setIconPixmap(pic);
00352     AboutGo4.exec();
00353 
00354 //    QMessageBox::about( this, GO4STR, GO4STR1);
00355 
00356 }
00357 
00358 
00359 void TGo4MainWindow::aboutQt()
00360 {
00361     QMessageBox::aboutQt( this, "Qt" );
00362 }
00363 
00364 void TGo4MainWindow::aboutROOT()
00365 {
00366    QPixmap pic= TGo4MainWindow::uic_load_pixmap( "root.png");
00367    QString mestring="This Go4 uses ROOT Version ";
00368    mestring.append(gROOT->GetVersion());
00369    mestring.append("\n ROOT is an object-oriented framework for large\n scale scientific data analysis and data mining.\n It has been developed at CERN\n See http://root.cern.ch for more information");
00370    QMessageBox AboutRoot("ROOT", mestring,
00371                                   QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton ,this);
00372 
00373      AboutRoot.setIconPixmap(pic);
00374      AboutRoot.exec();
00375 }
00376 
00377 
00378 void TGo4MainWindow::init()
00379 {
00380 
00382    QString fn;
00383 //   if(TGo4QSettings::UsesCurrentDir())
00384 //         fn = QDir::currentDirPath() + fxSettingsfolder + fxToolsfile;
00385 //   else 
00386    
00387    if(TGo4QSettings::UsesUserPath())
00388          fn =TGo4QSettings::GetUserPath() + fxToolsfile;
00389    else
00390          fn = QDir::homeDirPath() + fxSettingsfolder+ fxToolsfile;
00391    QFile f( fn );
00392    QString fndefault = QString(getenv("GO4SYS")) + "/Go4Library/go4defaulttoolsrc.txt";
00393    QFile fdefault( fndefault );
00394    if ( f.open( IO_ReadOnly ) ) 
00395       {
00396          QTextStream ts( &f );
00397          ts >> *this;
00398          f.close();
00399          cout <<"Loaded Go4 toolbar settings from "<<fn << endl;
00400       }
00401    else if (fdefault.open( IO_ReadOnly ))
00402       {
00403          QTextStream ts( &fdefault );
00404          ts >> *this;
00405          fdefault.close();
00406          cout <<"Loaded Go4 toolbar settings from "<<fndefault << endl;
00407       }
00408    else 
00409       {
00410          cout <<"Could not load default toolbar settings from "<<fndefault << endl;
00411       }
00412 
00414 
00415 
00416     /*restore the last position and size of the Main window*/
00417    TGo4QSettings settings;
00418    int Width, Height, PosX, PosY;
00419    int ViewpanelWidth, ViewpanelHeight;
00420 
00421     Width    = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinWidth", 997 );
00422     Height    = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinHeight", 690 );
00423     PosX    = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinX", 129 );
00424     PosY    = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinY", 132 );
00425     resize( Width, Height );
00426     move( PosX, PosY );
00428     Width = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceWidth", 587);
00429     Height = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceHeight", 544);
00430     PosX = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceX", 410);
00431     PosY = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceY", 88);
00432 
00433     fxTGo4WorkSpace->resize( Width, Height );
00434     fxTGo4WorkSpace->move( PosX, PosY );
00435 
00436    QString AppStyle = settings.readEntry( TGo4QSettings::GetSettingsName()+"/Style/AppStyle", "windows");
00437    makeStyle(AppStyle);
00438 
00440     /*restore the user font*/
00441    //QString FontStr = settings.readEntry( TGo4QSettings::GetSettingsName()+"/Font", "Helvetica,10,-1,5,50,0,0,0,0,0" );
00442    QString FontStr = settings.readEntry( TGo4QSettings::GetSettingsName()+"/Font", "Fixed [Rfx],10,-1,5,50,0,0,0,1,0" );
00443    m_font.fromString( FontStr );
00444    QApplication::setFont( m_font, true );
00445 
00447 // restore default size of viewpanel from settings here:
00448    ViewpanelWidth = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelWidth", 300);
00449    ViewpanelHeight = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelHeight", 300);
00450 
00451    fxViewpanelSize.setWidth(ViewpanelWidth);
00452    fxViewpanelSize.setHeight(ViewpanelHeight);
00454    // restore crosshairmode here:
00455    fbCrosshairMode = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/Crosshairmode", 0);
00456    SettingMenu->setItemChecked(fiCrosshairId,fbCrosshairMode);
00458    // restore default canvas background here:
00459    fiPadcolorR = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelBackRed", 220);
00460    fiPadcolorB = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelBackBlu", 220);
00461    fiPadcolorG = settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelBackGrn", 220);
00463 // restore the marker label default setup here:
00464    TGo4Marker::fgbHASLABEL=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/Markerlabel", 1);
00465    TGo4Marker::fgbHASCONNECTOR=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/Connectorline", 1);;
00466    TGo4Marker::fgbXDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowX", 1);
00467    TGo4Marker::fgbYDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowY", 0);
00468    TGo4Marker::fgbXBINDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowXbin", 0);
00469    TGo4Marker::fgbYBINDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowYbin", 0);
00470    TGo4Marker::fgbCONTDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowBinContent", 1);
00471 
00472    TGo4Condition::fgbLABELDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/Conditionlabel", 1);
00473    TGo4Condition::fgbLIMITSDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowLimits", 1);
00474    TGo4Condition::fgbINTDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowIntegral", 1);
00475    TGo4Condition::fgbXMEANDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowXmean", 1);
00476    TGo4Condition::fgbYMEANDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowYmean", 0);
00477    TGo4Condition::fgbXRMSDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowXrms", 1);
00478    TGo4Condition::fgbYRMSDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowYrms", 0);
00479    TGo4Condition::fgbXMAXDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowXmax", 1);
00480    TGo4Condition::fgbYMAXDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowYmax", 0);
00481    TGo4Condition::fgbCMAXDRAW=settings.readNumEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowCmax", 1);
00482    settings.DumpSettingsLocation();
00483 }
00484 
00485 void TGo4MainWindow::AddSettingMenu()
00486 {
00487 
00488    SettingMenu = new QPopupMenu( this );
00489    menuBar()->insertItem( "&Settings",SettingMenu);
00490 
00491    SettingMenu->insertItem("Sh&ow/hide", createDockWindowMenu());
00492 
00493    SettingMenu->insertItem("&Fonts...",this, SLOT(setFonts()));
00494    QPopupMenu *style = new QPopupMenu( this );
00495    style->setCheckable( TRUE );
00496    SettingMenu->insertItem("St&yle", style);
00497 //   menuBar()->insertItem( "St&yle",style);
00498    SettingMenu->insertItem("&Canvas color...",this, SLOT(CanvasColorSlot()));
00499    fiCrosshairId = SettingMenu->insertItem("Cross(&X)hair mode",this, SLOT(CrosshairSlot()));
00500    SettingMenu->setItemChecked(fiCrosshairId, fbCrosshairMode);
00501    SettingMenu->insertItem("&Log actions...",this, SLOT(LogSettingsSlot()));
00502 
00503    SettingMenu->insertItem("Generate &hotstart", this, SLOT(CreateGUIScriptSlot()));
00504 
00505    SettingMenu->insertItem("&Terminal history", this, SLOT(InputTerminalParametersSlot()));
00506 
00507    SettingMenu->insertItem("&Save Settings", this, SLOT(saveOptions()));
00508 
00509    QActionGroup *ag = new QActionGroup( this, 0 );
00510    ag->setExclusive( TRUE );
00511    QSignalMapper *styleMapper = new QSignalMapper( this );
00512    connect( styleMapper, SIGNAL( mapped( const QString& ) ), this, SLOT( makeStyle( const QString& ) ) );
00513    QStringList list = QStyleFactory::keys();
00514    list.sort();
00515 #ifndef QT_NO_STYLE_WINDOWS
00516    list.insert(list.begin(), "Norwegian Wood");
00517    list.insert(list.begin(), "Metal");
00518 #endif
00519    QDict<int> stylesDict( 17, FALSE );
00520    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
00521       QString styleStr = *it;
00522       QString styleAccel = styleStr;
00523       if ( stylesDict[styleAccel.left(1)] ) {
00524          for ( uint i = 0; i < styleAccel.length(); i++ ) {
00525             if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
00526                stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1);
00527                styleAccel = styleAccel.insert( i, '&' );
00528                break;
00529              }
00530           }
00531        } else {
00532           stylesDict.insert(styleAccel.left(1), (const int *)1);
00533           styleAccel = "&"+styleAccel;
00534        }
00535        QAction *a = new QAction( styleStr, QIconSet(), styleAccel, 0, ag, 0, ag->isExclusive() );
00536        connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) );
00537        styleMapper->setMapping( a, a->text() );
00538    }
00539    ag->addTo(style);
00540    style->insertSeparator();
00541    QApplication::setColorSpec( QApplication::ManyColor );
00542 }
00543 
00544 void TGo4MainWindow::AddFileMenu() 
00545 {
00546     QPopupMenu *FileMenu = new QPopupMenu( this );
00547      menuBar()->insertItem( "&File",FileMenu);
00548 
00549      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "fileopen" ), "&Open...",
00550              this, SLOT(OpenFileSlot()), CTRL+Key_O );
00551      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "network.png" ), "Open &Remote...",
00552              this, SLOT(OpenRemoteFileSlot()), CTRL+Key_R );        
00553      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "filesave" ), "Save memor&y...",
00554              this, SLOT(SaveFileSlot()), CTRL+Key_Y );
00555      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "editcopy" ), "&Export...",
00556              this, SLOT(ExportSelectedObjectsSlot()), CTRL+Key_E );
00557      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "close1.png" ), "C&lose",
00558              this, SLOT(CloseFileSlot()), CTRL+Key_L );
00559      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "fileclose.png" ),"Close all files (&Q)", 
00560              this, SLOT(CloseAllFilesSlot()), CTRL+Key_Q);
00561 //     FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "savewin.png" ), "Save As...",
00562 //             this, SLOT(SaveWinSlot()), CTRL+Key_W );
00563 //     FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "savelog.png" ), "Save Log...",
00564 //             this, SLOT(SaveLogSlot()));
00565 
00566 //    FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "print" ), "&Print...",
00567 //             this, SLOT(PrintSlot()), CTRL+Key_P );
00568      FileMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "exit.png" ), "E&xit",
00569              this, SLOT(ExitSlot()), CTRL+Key_X );
00570 }
00571 
00572 void TGo4MainWindow::AddFileToolBar() {
00573     QToolBar *FileBar = new QToolBar( this, "File Toolbar" );
00574      addDockWindow(FileBar, tr( "File Toolbar" ), Qt::DockTop, TRUE );
00575      FileBar->setNewLine ( FALSE );
00576 
00577      QToolButton *FileOpenB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "fileopen" ), QString::null, QString::null,
00578                     this, SLOT(OpenFileSlot( )), FileBar, "Open Local File" );
00579      FileOpenB->setUsesTextLabel(FALSE);
00580      QToolTip::add(FileOpenB, tr("Open a local file from disk"));
00581 
00582      QToolButton *FileRemoteOpenB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "network.png" ), QString::null, QString::null,
00583                     this, SLOT(OpenRemoteFileSlot( )), FileBar, "Open Remote File" );
00584      FileRemoteOpenB->setUsesTextLabel(FALSE);
00585      QToolTip::add(FileRemoteOpenB, tr("Open a remote file from server"));  
00586 
00587      QToolButton *FileSaveB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "filesave" ), QString::null, QString::null,
00588                     this, SLOT(SaveFileSlot()), FileBar, "Save File" );
00589      FileSaveB->setUsesTextLabel(FALSE);
00590      QToolTip::add(FileSaveB, tr("Save the content of the memory browser to a root file"));
00591 
00592      QToolButton *ExportB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "editcopy" ), QString::null, QString::null,
00593                     this, SLOT(ExportSelectedObjectsSlot()), FileBar, "Export..." );
00594      ExportB->setUsesTextLabel(FALSE);
00595      QToolTip::add(ExportB, tr("Export selected objects in memory browser to file in various formats"));
00596 
00597      QToolButton *FileCloseB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "close1.png" ), QString::null, QString::null,
00598                     this, SLOT(CloseFileSlot() ), FileBar, "Close File" );
00599      FileCloseB->setUsesTextLabel(FALSE);
00600      QToolTip::add(FileCloseB, tr("Close the selected root file"));
00601 
00602      QToolButton *FileAllCloseB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "fileclose.png" ), QString::null, QString::null,
00603                     this, SLOT(CloseAllFilesSlot() ), FileBar, "Close All Files" );
00604      FileAllCloseB->setUsesTextLabel(FALSE);
00605      QToolTip::add(FileAllCloseB, tr("Close all root files in file browser"));
00606  
00607 
00608 //     QToolButton *FileSaveWinB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "savewin.png" ), QString::null, QString::null,
00609 //                    this, SLOT(SaveWinSlot( )), FileBar, "Save Window As" );
00610 //     FileSaveWinB->setUsesTextLabel(FALSE);
00611 //     QToolTip::add(FileSaveWinB, tr("Save selected window to a file"));
00612 //
00613 //     QToolButton *FileSaveLogB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "savelog.png" ), QString::null, QString::null,
00614 //                    this, SLOT(SaveLogSlot( )), FileBar, "Save Log Info" );
00615 //     FileSaveLogB->setUsesTextLabel(FALSE);
00616 //     QToolTip::add(FileSaveLogB, tr("Save log information to a file"));
00617 
00618 
00619 //    QToolButton *PrintB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "print" ), QString::null, QString::null,
00620 //                    this, SLOT(PrintSlot( )), FileBar, "Print" );
00621 //     PrintB->setUsesTextLabel(FALSE);
00622 //     QToolTip::add(PrintB, tr("Print the selected window"));
00623 
00624      QToolButton *FileExitB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "exit.png" ), QString::null, QString::null,
00625                     this, SLOT(ExitSlot( )), FileBar, "Exit" );
00626      FileExitB->setUsesTextLabel(FALSE);
00627      QToolTip::add(FileExitB , tr("Exit the Go4"));
00628 }
00629 
00630 void TGo4MainWindow::AddScriptToolBar() {
00631     QToolBar *ScriptBar = new QToolBar( this, "Script Toolbar" );
00632      addDockWindow(ScriptBar, tr( "Script Toolbar" ), Qt::DockTop, TRUE );
00633      ScriptBar->setNewLine ( FALSE );
00634 
00635      QToolButton *RunB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "start.png" ), QString::null, QString::null,
00636                     this, SLOT(StartGUIScriptSlot()), ScriptBar, "Run..." );
00637      RunB->setUsesTextLabel(FALSE);
00638      QToolTip::add(RunB, tr("Execute script under GUI eviroment"));
00639 
00640      QToolButton *StopB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "Stop.png" ), QString::null, QString::null,
00641                     this, SLOT(StopGUIScriptSlot()), ScriptBar, "Stop..." );
00642      StopB->setUsesTextLabel(FALSE);
00643      QToolTip::add(StopB, tr("Break execution of GUI script"));
00644 
00645      QToolButton *GenerateB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "savewin.png" ), QString::null, QString::null,
00646                     this, SLOT(CreateGUIScriptSlot()), ScriptBar, "Create script..." );
00647      GenerateB->setUsesTextLabel(FALSE);
00648      QToolTip::add(GenerateB, tr("Create autostart script"));
00649 }
00650 
00651 void TGo4MainWindow::AddToolsMenu() {
00652    QPopupMenu * Go4ToolMenu = new QPopupMenu( this );
00653    menuBar()->insertItem( "&Tools", Go4ToolMenu);
00654 
00655    Go4ToolMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "chart.png" ), "&View Panel",
00656                 this, SLOT(ViewPanelSlot()), CTRL+Key_V );
00657    Go4ToolMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "fitpanel.png" ), "&Fit Panel...",
00658                 this, SLOT(FitPanelSlot()), CTRL+Key_F );
00659    Go4ToolMenu->insertItem( TGo4MainWindow::uic_load_pixmap( "hislist.png" ),"&Histogram properties...",
00660                this, SLOT(HistogramInfoSlot()));
00661    Go4ToolMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "hiscre.png" ), "Create New H&is...",
00662                this, SLOT(CreateNewHist()), CTRL+Key_I );
00663    Go4ToolMenu->insertItem( TGo4MainWindow::uic_load_pixmap( "condlist.png" ),"C&ondition properties...",
00664                this, SLOT(ConditionInfoSlot()));
00665    Go4ToolMenu->insertItem( TGo4MainWindow::uic_load_pixmap( "condcre.png" ),"&Condition Editor...",
00666                this, SLOT(ConditionEditSlot()), CTRL+Key_C);
00667    Go4ToolMenu->insertItem( TGo4MainWindow::uic_load_pixmap( "zoom.png" ),"&Event Printout...",
00668                this, SLOT(EventInfoSlot()));
00669    Go4ToolMenu->insertItem( TGo4MainWindow::uic_load_pixmap( "dynlist.png" ),"&Dyn. List Editor ...",
00670                this, SLOT(StartDynEditor()), CTRL+Key_D);
00671    Go4ToolMenu->insertItem( TGo4MainWindow::uic_load_pixmap( "parabutton.png" ), "&Parameter Editor ...",
00672                this, SLOT(StartParaEdit()), CTRL+Key_P);
00673    Go4ToolMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "dllicon.png" ), "Load Li&braries ...",
00674                this, SLOT(LoadLibrarySlot()), CTRL+Key_B);
00675    Go4ToolMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "user.png" ), "&User GUI ...",
00676                this, SLOT(UserPanelSlot()), CTRL+Key_U);
00677 }
00678 
00679 
00680 
00681 void TGo4MainWindow::AddToolsBar()
00682 {
00683      QToolBar *Go4ToolBar = new QToolBar( this, "File operations" );
00684      addDockWindow(Go4ToolBar, tr( "Tools Toolbar" ), Qt::DockTop, TRUE );
00685      Go4ToolBar->setNewLine ( FALSE );
00686 
00687    QToolButton *ViewB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "chart.png" ), QString::null, QString::null,
00688                  this, SLOT(ViewPanelSlot()), Go4ToolBar, "View Panel" );
00689    ViewB->setUsesTextLabel(FALSE);
00690    QToolTip::add(ViewB , tr("Create a new view panel"));
00691 
00692      QToolButton *FitPanelB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "fitpanel.png" ), QString::null, QString::null,
00693                     this, SLOT(FitPanelSlot()), Go4ToolBar, "Fit Panel" );
00694    FitPanelB->setUsesTextLabel(FALSE);
00695    QToolTip::add(FitPanelB , tr("Show/hide the Go4 Fit Panel "));
00696 
00697    QToolButton *HisInfoB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "hislist.png" ), QString::null, QString::null,
00698                     this, SLOT(HistogramInfoSlot()), Go4ToolBar, "Histogram properties");
00699    HisInfoB->setUsesTextLabel(FALSE);
00700    QToolTip::add(HisInfoB , tr("Show histogram properties window"));
00701 
00702    QToolButton *CreatHisB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "hiscre.png" ), QString::null, QString::null,
00703                     this, SLOT(CreateNewHist()), Go4ToolBar, "Create New Histogram" );
00704    CreatHisB->setUsesTextLabel(FALSE);
00705    QToolTip::add(CreatHisB , tr("Create new ROOT Histogram"));
00706 
00707    QToolButton *ConInfoB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "condlist.png" ), QString::null, QString::null,
00708                     this, SLOT(ConditionInfoSlot()), Go4ToolBar, "Condition properties");
00709    ConInfoB->setUsesTextLabel(FALSE);
00710    QToolTip::add(ConInfoB , tr("Show condition properties window"));
00711 
00712    QToolButton *ConEditB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "condcre.png" ), QString::null, QString::null,
00713                     this, SLOT(ConditionEditSlot()), Go4ToolBar, "Condition editor");
00714    ConEditB->setUsesTextLabel(FALSE);
00715    QToolTip::add(ConEditB , tr("Condition editor"));
00716 
00717  QToolButton *EveInfoB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "zoom.png" ), QString::null, QString::null,
00718                     this, SLOT(EventInfoSlot()), Go4ToolBar, "Event printout");
00719    EveInfoB->setUsesTextLabel(FALSE);
00720    QToolTip::add(EveInfoB , tr("Event printout and examination window"));
00721 
00722 
00723    QToolButton *DynEditorB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "dynlist.png" ), QString::null, QString::null,
00724                     this, SLOT(StartDynEditor()), Go4ToolBar, "Dyn. List Editor");
00725    DynEditorB->setUsesTextLabel(FALSE);
00726    QToolTip::add(DynEditorB , tr("Start the Dynamic list Editor"));
00727 
00728    QToolButton *ParaEditB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "parabutton.png" ), QString::null, QString::null,
00729                     this, SLOT(StartParaEdit()), Go4ToolBar, " Parameter Editor" );
00730    ParaEditB->setUsesTextLabel(FALSE);
00731    QToolTip::add(ParaEditB , tr("Start the Parameter Editor"));
00732 
00733    QToolButton *LibB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "dllicon.png" ), QString::null, QString::null,
00734                     this, SLOT(LoadLibrarySlot() ), Go4ToolBar, "Load Libraries" );
00735    LibB->setUsesTextLabel(FALSE);
00736    QToolTip::add(LibB , tr("Load Libraries"));
00737 
00738    QToolButton *UsrB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "user.png" ), QString::null, QString::null,
00739                     this, SLOT(UserPanelSlot()), Go4ToolBar, "User GUI" );
00740    UsrB->setUsesTextLabel(FALSE);
00741    QToolTip::add(UsrB , tr("Start user panel"));
00742 }
00743 
00744 
00745 
00746 
00747 
00748 void TGo4MainWindow::AddAnalysisMenu()
00749 {
00750     TGo4Display* display=fxTGo4GUIRegistry->GetDisplay();
00751     QPopupMenu * AnalysisMenu  = new QPopupMenu( this );
00752      menuBar()->insertItem( "&Analysis", AnalysisMenu);
00753 
00754      AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "connect.png" ), "Lau&nch Analysis...",
00755              this, SLOT(launchClientSlot()), CTRL+Key_N );
00756      AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "disconnect.png" ), "Re&move Analysis",
00757              this, SLOT(RemoveClientSlot()), CTRL+Key_M );
00758      if(!display->IsServer())
00759       {           
00760          AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "killanal.png" ), "Shutdown Analysis server (&z)",
00761              this, SLOT(ShutdownSlaveSlot()), CTRL+Key_Z );         
00762              
00763       }      
00764      AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "restart.png" ), "Set+S&tart",
00765              this, SLOT(SubmitStartAnalysisSlot()), CTRL+Key_T );
00766      AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "start.png" ), "&Start",
00767              this, SLOT(StartAnalysisSlot()), CTRL+Key_S );
00768      AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "Stop.png" ), "Stop (&Halt)",
00769              this, SLOT(StopAnalysisSlot()), CTRL+Key_H );
00770      AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "control.png"), "Confi&guration...",
00771                this, SLOT(AnalysisConfigSlot()), CTRL+Key_G);
00772     AnalysisMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "analysiswin.png"), "Analysis &Window",
00773                this, SLOT(StartAnalysisWin()), CTRL+Key_W);
00774 
00775 
00776 }
00777 
00778 void TGo4MainWindow::AddAnalysisBar()
00779 {
00780     TGo4Display* display=fxTGo4GUIRegistry->GetDisplay();
00781     QToolBar *AnalysisToolBar = new QToolBar( this, "AnalysisToolBar" );
00782      addDockWindow(AnalysisToolBar, tr( "Analysis Toolbar" ), Qt::DockTop, TRUE );
00783      AnalysisToolBar->setNewLine ( FALSE );
00784 
00785      QToolButton *LaunchB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "connect.png" ), QString::null, QString::null,
00786                    this, SLOT(launchClientSlot()), AnalysisToolBar, "Launch Client" );
00787      LaunchB->setUsesTextLabel(FALSE);
00788      QToolTip::add(LaunchB, tr("Launch an analysis client"));
00789 
00790     
00791      QToolButton *RemoveB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "disconnect.png" ), QString::null, QString::null,
00792                    this, SLOT(RemoveClientSlot()), AnalysisToolBar, "Remove Client" );
00793      RemoveB->setUsesTextLabel(FALSE);
00794      QToolTip::add(RemoveB, tr("Stop and remove the connected analysis client"));
00795       
00796       
00797     if(!display->IsServer())
00798       {
00799          QToolButton *ShutdownB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "killanal.png" ), QString::null, QString::null,
00800                    this, SLOT(ShutdownSlaveSlot()), AnalysisToolBar, "Shutdown analysis server" );
00801          ShutdownB->setUsesTextLabel(FALSE);
00802          QToolTip::add(ShutdownB, tr("Shutdown the connected analysis slave (administrator mode only!)"));
00803       }
00804 
00805       QToolButton *SetStartB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "restart.png" ), QString::null, QString::null,
00806                     this, SLOT(SubmitStartAnalysisSlot()), AnalysisToolBar, "Set and Start Analysis" );
00807      SetStartB->setUsesTextLabel(FALSE);
00808      QToolTip::add(SetStartB, tr("Submit Settings and start the analysis client"));
00809 
00810      QToolButton *StartB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "start.png" ), QString::null, QString::null,
00811                     this, SLOT(StartAnalysisSlot()), AnalysisToolBar, "Start Analysis" );
00812      StartB->setUsesTextLabel(FALSE);
00813      QToolTip::add(StartB, tr("Start the analysis client"));
00814 
00815      QToolButton *StopB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "Stop.png" ), QString::null, QString::null,
00816                     this, SLOT(StopAnalysisSlot()), AnalysisToolBar, "Stop  Analysis" );
00817      StopB->setUsesTextLabel(FALSE);
00818      QToolTip::add(StopB, tr("Stop the analysis client"));
00819 
00820      QToolButton *ConfigB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "control.png" ), QString::null, QString::null,
00821                     this, SLOT(AnalysisConfigSlot()), AnalysisToolBar, "Analysis Configuration" );
00822      ConfigB->setUsesTextLabel(FALSE);
00823     QToolTip::add(ConfigB, tr("Show the analysis client configuration"));
00824 
00825     QToolButton *AnalysisWinB  = new QToolButton( TGo4MainWindow::uic_load_pixmap( "analysiswin.png" ), QString::null, QString::null,
00826                     this, SLOT(StartAnalysisWin()), AnalysisToolBar, "Analysis Window" );
00827      AnalysisWinB->setUsesTextLabel(FALSE);
00828     QToolTip::add(AnalysisWinB, tr("Show the analysis window"));
00829 
00830 
00831 }
00832 
00833 void TGo4MainWindow::windowsMenuAboutToShow()
00834 {
00835     int clearlogId=0;
00836     int savelogId=0;
00837     int clearAnaId=0;
00838     int saveAnaId=0;
00839     windowsMenu->clear();
00840     int cascadeId = windowsMenu->insertItem("Ca&scade", fxTGo4WorkSpace, SLOT(cascade() ) );
00841     int tileId = windowsMenu->insertItem("&Tile", fxTGo4WorkSpace, SLOT(tile() ) );
00842     int closallId =windowsMenu->insertItem("&Close all", this, SLOT(CloseAllWindows() ) );
00843     int minallId =windowsMenu->insertItem("&Minimize all", this, SLOT(MinAllWindows() ) );
00844     if (  fxTGo4WorkSpace->windowList().isEmpty() ) {
00845            windowsMenu->setItemEnabled( cascadeId, FALSE );
00846            windowsMenu->setItemEnabled( tileId, FALSE );
00847            windowsMenu->setItemEnabled( closallId, FALSE );
00848            windowsMenu->setItemEnabled( minallId, FALSE );
00849        }        
00851     windowsMenu->insertSeparator();
00852     savelogId=windowsMenu->insertItem("Save L&ogwindow",this, SLOT(SaveLogSlot()));
00853     clearlogId= windowsMenu->insertItem("Clear &Logwindow",this, SLOT(clearLog()));
00854     saveAnaId=windowsMenu->insertItem("Save &Analysis window",this, SLOT(SaveAnalysisWindow()));
00855     clearAnaId= windowsMenu->insertItem("Clear Analysis &window",this, SLOT(clearAnalysis()));
00856     windowsMenu->setItemEnabled( clearlogId, fxTGo4LogInfo);      
00857     windowsMenu->setItemEnabled( savelogId, fxTGo4LogInfo);  
00858     windowsMenu->setItemEnabled( saveAnaId, fxAnalysisShell);      
00859     windowsMenu->setItemEnabled( clearAnaId, fxAnalysisShell);  
00861     windowsMenu->insertSeparator();
00862     QWidgetList windows =  fxTGo4WorkSpace->windowList();
00863     for ( int i = 0; i < int(windows.count()); ++i ) {
00864         int id = windowsMenu->insertItem(windows.at(i)->caption(),
00865                                          this, SLOT( windowsMenuActivated( int ) ) );
00866         windowsMenu->setItemParameter( id, i );
00867         windowsMenu->setItemChecked( id, fxTGo4WorkSpace->activeWindow() == windows.at(i) );
00868     }
00869 }
00870 
00871 void TGo4MainWindow::CloseAllWindows()
00872 {
00873    QWidgetList windows =  fxTGo4WorkSpace->windowList();
00874     for ( int i = 0; i < int(windows.count()); ++i ) {
00875        windows.at(i)->close();
00876     }
00877 
00878 }
00879 
00880 
00881 void TGo4MainWindow::MinAllWindows()
00882 {
00883    QWidgetList windows =  fxTGo4WorkSpace->windowList();
00884     for ( int i = 0; i < int(windows.count()); ++i ) {
00885        windows.at(i)->showMinimized();
00886     }
00887 }
00888 
00889 void TGo4MainWindow::windowsMenuActivated( int id )
00890 {
00891    QWidget* w = fxTGo4WorkSpace->windowList().at( id );
00892     if ( w ) w->showNormal();
00893     w->setFocus();
00894 }
00895 
00896 void TGo4MainWindow::ShutdownSlaveSlot()
00897 {
00898 TGo4Display* display=fxTGo4GUIRegistry->GetDisplay();
00899 if(display->IsServer()) return; // only for gui as client
00900 int result=QMessageBox::information( this, "Go4 GUI",
00901         "Really Shutdown Analysis Server?",
00902          QMessageBox::Yes | QMessageBox::Default,// Enter == button 0
00903          QMessageBox::No | QMessageBox::Escape // Escape == button 1
00904          );   
00905 if(result!=QMessageBox::Yes) return;  
00906 
00907 AnalysisConfigAppearance(0);    
00908 TGo4RemoteBrowserSlots *fxRemote = (TGo4RemoteBrowserSlots *)fxTGo4GUIRegistry->GetSlotClass("TGo4RemoteBrowserSlots");
00909 if (fxRemote) fxRemote->ClearBrowser();
00910 TGo4MonitoredListSlots* moni = (TGo4MonitoredListSlots *)fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots");
00911 if (moni) moni->GetGUI()->StopMonitoring();
00912 statusBar()->message("Disconnected and shut down Analysis Slave.");
00913 fxTGo4GUIRegistry->SubmitCommand("SVQuit"); // is remote command now
00914 fxTGo4GUIRegistry->SetAnalysisReady(kFALSE);
00915 //SetMasterMode(0); // should be done by disconnect method on success
00916    
00917    
00918    
00919 }
00920 
00921 
00922 void TGo4MainWindow::RemoveClientSlot()
00923 {
00924     // TGo4LockGuard glob;
00925     fxTGo4GUIRegistry->SetAnalysisReady(kFALSE);    
00926     AnalysisConfigAppearance(0);
00927     StopMonitoring();
00928     statusBar()->message("Disconnecting Analysis Slave.");
00929     // note: prepare gui before putting command into background thread
00930     // avoid conflicts between gui and local command thread?
00931     TGo4ComDisconnectSlave* com= new TGo4ComDisconnectSlave() ;
00932     TGo4Display* display=fxTGo4GUIRegistry->GetDisplay();
00933     if(display->IsServer())
00934       com->SetSlave("current");
00935     else  
00936       com->SetSlave(display->GetName()); // use unique name of our threadmanager, for multiple clients connection!
00937     fxTGo4GUIRegistry->SubmitCommand(com);
00938     //SetMasterMode(0); // should be done by disconnect method on success
00939 }
00940 
00941 void TGo4MainWindow::launchClientSlot()
00942 {
00943     TGo4TaskHandler* currenttask=0;
00944     TGo4Display *fxDisplay=fxTGo4GUIRegistry->GetDisplay();
00945     //if(fxDisplay) currenttask=fxDisplay->GetTask()->GetTaskHandler();
00946     //if(currenttask==0)
00947     if(!fxDisplay->IsConnected())
00948          {
00949             if(fxAnalysisShell==0) StartAnalysisWin(true);
00950             TGo4StartClient* fxTGo4StartClient = new TGo4StartClient(0,"Start Client", TRUE);
00951             fxTGo4StartClient->SetServerMode(fxDisplay->IsServer());
00952             fxTGo4StartClient->polish();
00953             fxTGo4StartClient->show();
00954          }
00955     else
00956          {    
00957             QMessageBox::warning(this, "Slave is already connected", "Slave is already connected" );
00958          }
00959 }
00960 
00961 
00962 
00963 
00964 void TGo4MainWindow::AnalysisConfigAppearance(int mode)
00965 // mode = 0 close window, when analysis is disconnecetd
00966 // mode = 1 create and hide, when analysis is started
00967 // mode = 2 create and show when config is updated 
00968 {
00969    TGo4AnalysisConfigurationSlots* fxTGo4AnalysisConfigurationSlots = 
00970      dynamic_cast <TGo4AnalysisConfigurationSlots *> 
00971        (fxTGo4GUIRegistry->GetSlotClass("TGo4AnalysisConfigurationSlots"));
00972    
00973    TGo4AnalysisConfiguration* fxTGo4AnalysisConfiguration = 0;
00974    
00975    if (fxTGo4AnalysisConfigurationSlots!=0) 
00976       fxTGo4AnalysisConfiguration = dynamic_cast <TGo4AnalysisConfiguration*> 
00977           (fxTGo4GUIRegistry->GetGUIClass(fxTGo4AnalysisConfigurationSlots));
00978           
00979    if (fxTGo4AnalysisConfiguration==0) {
00980       if (mode==0) return; 
00981       fxTGo4AnalysisConfiguration = new TGo4AnalysisConfiguration(fxTGo4WorkSpace);
00982       fxTGo4AnalysisConfiguration->adjustSize();
00983       fxTGo4AnalysisConfiguration->polish();
00984    } 
00985    
00986    if (mode==2) {
00987      fxTGo4AnalysisConfiguration->raise();  
00988      fxTGo4AnalysisConfiguration->show();
00989    }
00990    else
00991      fxTGo4AnalysisConfiguration->hide();
00992 }
00993 
00994 
00995 void TGo4MainWindow::AnalysisConfigSlot()
00996 {
00997 //   if (!fxTGo4GUIRegistry->IsAnalysisReady()) return;
00998     
00999    TGo4AnalysisConfigurationSlots* fxTGo4AnalysisConfigurationSlots = 
01000      dynamic_cast <TGo4AnalysisConfigurationSlots*> 
01001       (fxTGo4GUIRegistry->GetSlotClass("TGo4AnalysisConfigurationSlots"));
01002    TGo4AnalysisConfiguration* win = 0;   
01003       
01004    if (fxTGo4AnalysisConfigurationSlots!=0) 
01005      win =  dynamic_cast <TGo4AnalysisConfiguration*> 
01006        (fxTGo4GUIRegistry->GetGUIClass(fxTGo4AnalysisConfigurationSlots));
01007    if (win==0) {
01008       win = new TGo4AnalysisConfiguration(fxTGo4WorkSpace);
01009       win->adjustSize();
01010       win->polish();
01011       win->show();
01012    } else
01013    if (win->isVisible()) {
01014       win->hide();
01015    } else {
01016       win->raise();
01017       win->show();
01018       if (win->isMinimized()) win->showNormal();
01019    }
01020 }
01021 
01022 
01023 /*
01024 
01025 void TGo4MainWindow::AnalysisConfigSlot()
01026 {
01027     // TGo4LockGuard glob;
01028    TGo4AnalysisConfiguration *fxTGo4AnalysisConfiguration;
01029    TGo4AnalysisConfigurationSlots *fxTGo4AnalysisConfigurationSlots;
01030    fxTGo4AnalysisConfigurationSlots = dynamic_cast <TGo4AnalysisConfigurationSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4AnalysisConfigurationSlots"));
01031    if (fxTGo4AnalysisConfigurationSlots ==0){
01032       fxTGo4AnalysisConfiguration = new TGo4AnalysisConfiguration(fxTGo4WorkSpace);
01033       fxTGo4AnalysisConfiguration->adjustSize();
01034       fxTGo4AnalysisConfiguration->polish();
01035       fxTGo4AnalysisConfiguration->show();
01036       fxTGo4AnalysisConfiguration->hide();
01037    }else {
01038       fxTGo4AnalysisConfiguration  = dynamic_cast <TGo4AnalysisConfiguration *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4AnalysisConfigurationSlots));
01039       if (fxTGo4AnalysisConfiguration ==0){
01040          fxTGo4AnalysisConfiguration = new TGo4AnalysisConfiguration(fxTGo4WorkSpace);
01041          fxTGo4AnalysisConfiguration->polish();
01042          fxTGo4AnalysisConfiguration->show();
01043       }else if (fxTGo4AnalysisConfiguration->isVisible()){
01044          fxTGo4AnalysisConfiguration->hide();
01045       }else if(!fxTGo4AnalysisConfiguration->isVisible()){
01046          fxTGo4AnalysisConfiguration->raise();
01047          fxTGo4AnalysisConfiguration->show();
01048       }
01049    }
01050 }
01051 */
01052 
01053 
01054 TGo4AnalysisStatusMonitor* TGo4MainWindow::AnalysisStatusSlot()
01055 {
01056    if(fxTGo4AnalysisStatusMonitor==0) {
01057       TGo4AnalysisStatusMonitorSlots* fxTGo4AnalysisStatusMonitorSlots = 
01058         dynamic_cast <TGo4AnalysisStatusMonitorSlots *> 
01059           (fxTGo4GUIRegistry->GetSlotClass("TGo4AnalysisStatusMonitorSlots"));
01060         if (fxTGo4AnalysisStatusMonitorSlots==0) {
01061             fxTGo4AnalysisStatusMonitor = new TGo4AnalysisStatusMonitor(statusBar());
01062             statusBar()->addWidget(fxTGo4AnalysisStatusMonitor);
01063         } else {
01064           fxTGo4AnalysisStatusMonitor = dynamic_cast <TGo4AnalysisStatusMonitor*> 
01065             (fxTGo4GUIRegistry->GetGUIClass(fxTGo4AnalysisStatusMonitorSlots));
01066           if (fxTGo4AnalysisStatusMonitor==0) {
01067             fxTGo4AnalysisStatusMonitor= new TGo4AnalysisStatusMonitor(statusBar());
01068             statusBar()->addWidget(fxTGo4AnalysisStatusMonitor);
01069           }
01070         }
01071    }
01072    fxTGo4AnalysisStatusMonitor->polish();
01073    fxTGo4AnalysisStatusMonitor->show();
01074    return fxTGo4AnalysisStatusMonitor;
01075 }
01076 
01077 void TGo4MainWindow::KillAnalysisSlot()
01078 {
01079     // TGo4LockGuard glob;
01080     fxTGo4GUIRegistry->SubmitEmergencyCommand(kComKillMain);
01081 }
01082 
01083 void TGo4MainWindow::RestartAnalysisSlot()
01084 {
01085     // TGo4LockGuard glob;
01086     fxTGo4GUIRegistry->SubmitCommand("THEMRestart");
01087 }
01088 
01089 void TGo4MainWindow::SubmitStartAnalysisSlot()
01090 {
01091    // submit settings here first:
01092    TGo4AnalysisConfigurationSlots *analysisconfiguration = dynamic_cast <TGo4AnalysisConfigurationSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4AnalysisConfigurationSlots"));
01093    if (analysisconfiguration)
01094          analysisconfiguration->SubmitConfiguration();
01095    StartAnalysisSlot();
01096 }
01097 
01098 void TGo4MainWindow::StartAnalysisSlot()
01099 {
01100     // TGo4LockGuard glob;
01101    fxTGo4GUIRegistry->SubmitCommand("THStart");
01102    AnalysisStatusSlot();
01103       TGo4RemoteBrowserSlots *fxRemote= (TGo4RemoteBrowserSlots *)fxTGo4GUIRegistry->GetSlotClass("TGo4RemoteBrowserSlots");
01104     fxRemote->Refresh(kTRUE);
01105 //      fxTGo4DockBrowsers->BrowsersTabWidget->setCurrentPage(3);
01106 
01107 }
01108 
01109 void TGo4MainWindow::StopAnalysisSlot()
01110 {
01111     // TGo4LockGuard glob;
01112     fxTGo4GUIRegistry->SubmitCommand("THStop");
01113 }
01114 
01115 typedef void* (*TUserGuiConstructor)(void* objptr, QWidget* parent, const char* name, int fl);
01116 typedef void* (*TStartUserGuiFunc)(const char* path, QWidget* parent);
01117 
01118 bool TGo4MainWindow::startUserGUI(const char* usergui)
01119 {
01120    QString dirname, libname;
01121    
01122    bool result = false;
01123 
01124    if ((usergui!=0) && (strlen(usergui)>0)) {
01125       QFileInfo info(usergui);
01126       if (info.exists()) 
01127         if (info.isFile()) {
01128            dirname = info.dirPath();
01129            libname = info.fileName();
01130             
01131         } else
01132         if (info.isDir()) {
01133            dirname = usergui;
01134         }
01135      if ((dirname.length()>0) && (dirname[dirname.length()-1]!='/')) dirname+="/";
01136    }
01137    
01138    bool defaultnames = libname.length()==0;
01139    if (defaultnames) 
01140      libname = "libGo4ROOTUserGui.so";
01141 
01142 //   cout << "Try : " << dirname+libname << endl;
01143    void* lib1 = ::dlopen(dirname+libname, RTLD_LAZY | RTLD_GLOBAL);
01144    void* lib2 = 0;
01145    
01146    if (lib1!=0) {
01147        
01148       // first test start function   
01149       TStartUserGuiFunc startfunc = (TStartUserGuiFunc) ::dlsym(lib1,"StartUserGui");
01150 //      startfunc = 0;
01151       
01152       if (startfunc!=0) {
01153          fxTGo4MainUserPanel = (QWidget*) startfunc(dirname.ascii(),fxTGo4GUIRegistry->GetCentralWindow());
01154          if (fxTGo4MainUserPanel) {
01155            fxTGo4MainUserPanel->show();
01156            result = true;
01157          } else {
01158            cout << "!!! StartUserGui() function didnot create user widget" << endl;
01159          }
01160       } else 
01161       if (defaultnames) {
01162 //         cout << "Try : " << dirname + "libGo4UserGui.so" << endl;
01163          lib2 = ::dlopen(dirname+"libGo4UserGui.so", RTLD_LAZY | RTLD_GLOBAL); 
01164          TUserGuiConstructor constr = (lib2==0) ? 0 :
01165            (TUserGuiConstructor) ::dlsym(lib2,"__17TGo4MainUserPanelP7QWidgetPCcUi");
01166           
01167         if (constr!=0) {
01168           void* obj = malloc(1000);
01169           fxTGo4MainUserPanel = (QWidget*) 
01170              constr(obj, fxTGo4GUIRegistry->GetCentralWindow() , 0, 0);
01171           if (fxTGo4MainUserPanel!=0) {
01172             fxTGo4MainUserPanel->show();
01173             result = true;
01174           }
01175         }
01176       }
01177    }
01178 
01179    if (result) {
01180      cout << "Start user GUI from "; 
01181      if (dirname.length()>0) cout << dirname << endl; else
01182         cout << "$LD_LIBRARY_PATH=" << ::getenv("LD_LIBRARY_PATH") << endl;
01183      if (lib2!=0) {
01184         cout << "!!! This is depricated style of user gui for Go4" << endl;
01185         cout << "!!! Please update your code, adding StartUserGui() function to your " << libname << " library" << endl;
01186         cout << "!!! For more details look into current $GO4SYS/Go4UserGUI project or contact S.Linev@gsi.de" << endl;
01187      }
01188    } else {
01189       if (lib1!=0) dlclose(lib1);
01190       if (lib2!=0) dlclose(lib2);
01191    }
01192 
01193    return result;
01194         
01195 }
01196 
01197 void TGo4MainWindow::UserPanelSlot()
01198 {
01199    // TGo4LockGuard glob;
01200    if(fxTGo4MainUserPanel==0) {
01201       
01202       // check GO4USERGUI variable
01203       QString usergui = getenv("GO4USERGUI");
01204       if (usergui.length()>0)
01205         if (startUserGUI(usergui)) return;
01206       
01207       // check from standard LD_LIBRARY_PATHS 
01208       if (startUserGUI(0)) return;
01209       
01210       usergui = getenv("GO4SYS");
01211       if (usergui.length()>0) {
01212          if (usergui[usergui.length()-1]!='/') usergui+="/";
01213          usergui+="Go4UserGUI";
01214          if (startUserGUI(usergui)) return;
01215       }
01216 
01217       QMessageBox::critical(this,"Starting user GUI", "No suitable libraries found");
01218 //      fxTGo4MainUserPanel = new TGo4MainUserPanel(fxTGo4GUIRegistry->GetCentralWindow());
01219 //      fxTGo4MainUserPanel->show();
01220    } else {
01221       fxTGo4MainUserPanel->raise();
01222       fxTGo4MainUserPanel->show();
01223    }
01224 }
01225 
01226 TGo4PreviewPanel *TGo4MainWindow::ViewPanelSlot(int div)
01227 {
01228    TGo4PreviewPanel *fxTGo4PreviewPanel;
01229    char SlotName[256];
01230    char PanelName[256];
01231    int i=0;
01232    int DivX=0;
01233    int DivY=0;
01234    do {
01235       snprintf(PanelName,255,"%s %d %s","V ",i++," :");
01236       snprintf(SlotName,255,"%s%s",PanelName,"_Slots");
01237    }while(fxTGo4GUIRegistry->GetSlotClass(SlotName)!=0);
01238    fxTGo4PreviewPanel = new TGo4PreviewPanel(fxTGo4WorkSpace,PanelName);
01239    fxTGo4PreviewPanel->SetCrosshairDefault(fbCrosshairMode);
01240    int pcol=AssignRootColors();
01241    fxTGo4PreviewPanel->SetPadFillColor(pcol);
01242    fxTGo4PreviewPanel->InitPad(fxTGo4PreviewPanel->GetActivePad()); //need this to apply new defaults
01243    if(div>1){
01244       DivX=(int)sqrt((double)div);
01245       DivY=DivX;
01246       if(DivX*DivY<div){
01247          do{
01248             DivX=DivX+1;
01249          }while(DivX*DivY<div);
01250       }
01251          fxTGo4PreviewPanel->Divide(DivX,DivY);
01252      }
01253    fxTGo4PreviewPanel->resize(fxViewpanelSize);
01254    fxTGo4PreviewPanel->polish();
01255    fxTGo4PreviewPanel->show();
01256 //   fxTGo4PreviewPanel->showMaximized();
01257    return fxTGo4PreviewPanel;
01258 
01259 }
01260 
01261 
01262 void TGo4MainWindow::closeEvent( QCloseEvent* ce)
01263 {
01264      int result=QMessageBox::information( this, "Go4 GUI",
01265         "Really Exit Go4?",
01266          QMessageBox::Yes | QMessageBox::Default,// Enter == button 0
01267          QMessageBox::No | QMessageBox::Escape // Escape == button 1
01268          );
01269      
01270 //     switch( QMessageBox::information( this, "Go4 GUI",
01271 //        "Really Exit Go4?",
01272 //         QMessageBox::Yes | QMessageBox::Default,// Enter == button 0
01273 //         QMessageBox::No | QMessageBox::Escape // Escape == button 1
01274 //         ) )
01275 //   cout <<"result is "<<result << endl;
01276 //   cout <<"QMessageBox::Yes is "<<QMessageBox::Yes << endl;
01277 //   cout <<"QMessageBox::No is "<<QMessageBox::No << endl;
01278    switch(result)
01279     {
01280     case QMessageBox::Yes: // Yes clicked or Alt+Y pressed or Enter pressed.
01281           //    saveOptions(); // do not save on exit anymore!        
01282           // need to close files first, since netfile threads might cause some trouble in garbage collection cleanup
01283         statusBar()->message("Stop monitoring...");
01284         if (fxTGo4DockBrowsers!=0) fxTGo4DockBrowsers->StopAllMonitoring();
01285           
01286         statusBar()->message("Closing all files...");
01287         CloseAllFilesSlot(); 
01288         if(!fbLocalMode) {
01289            //fxTGo4GUIRegistry->SubmitCommand("SVQuit");
01290            fxTGo4GUIRegistry->SubmitCommand("MRQuit");
01291            statusBar()->message("Exit....  please wait");
01292         } else {
01293            statusBar()->message("Closing GUI...");
01294            ce->accept();
01295         }
01296         break;
01297     case QMessageBox::No: // No clicked or Alt+N pressed
01298         break;
01299     default: // Cancel clicked or Alt+C pressed or Escape pressed
01300         break;
01301     } //switch
01302 }
01303 
01304 
01305 void TGo4MainWindow::CloseBrowsers()
01306 {
01307     // TGo4LockGuard glob;
01308 }
01309 
01310 
01311 void TGo4MainWindow::LoadLibrarySlot()
01312 {
01313     // TGo4LockGuard glob;
01314    TGo4LoadedLibrariesSlots *fxTGo4LoadedLibrariesSlots;
01315    TGo4LoadedLibraries *fxTGo4LoadedLibraries;
01316 
01317    fxTGo4LoadedLibrariesSlots = dynamic_cast <TGo4LoadedLibrariesSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4LoadedLibrariesSlots"));
01318    if (fxTGo4LoadedLibrariesSlots ==0){
01319       fxTGo4LoadedLibraries = new TGo4LoadedLibraries(fxTGo4WorkSpace);
01320       fxTGo4LoadedLibraries->polish();
01321       fxTGo4LoadedLibraries->show();
01322    }else {
01323       fxTGo4LoadedLibraries  = dynamic_cast <TGo4LoadedLibraries *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4LoadedLibrariesSlots));
01324       if (fxTGo4LoadedLibraries ==0){
01325          fxTGo4LoadedLibraries = new TGo4LoadedLibraries(fxTGo4WorkSpace);
01326          fxTGo4LoadedLibraries->polish();
01327          fxTGo4LoadedLibraries->show();
01328       }else if (fxTGo4LoadedLibraries->isVisible()){
01329          fxTGo4LoadedLibraries->hide();
01330       }else if(!fxTGo4LoadedLibraries->isVisible()){
01331          fxTGo4LoadedLibraries->raise();
01332          fxTGo4LoadedLibraries->show();
01333 
01334       }
01335    }
01336 }
01337 
01338 void TGo4MainWindow::RemoteInfoSlot()
01339 {
01340     // TGo4LockGuard glob;
01341 
01342 }
01343 
01344 void TGo4MainWindow::CloseFileSlot()
01345 {
01346     // TGo4LockGuard glob;
01347    TGo4DiskFileBrowserSlots *fxTGo4DiskFileBrowserSlots = dynamic_cast <TGo4DiskFileBrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4DiskFileBrowserSlots"));
01348    TGo4DiskFileBrowser *fxTGo4DiskFileBrowser= dynamic_cast <TGo4DiskFileBrowser *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4DiskFileBrowserSlots));
01349    if (fxTGo4DiskFileBrowser!=0)fxTGo4DiskFileBrowser->CloseRootFile();
01350 }
01351 
01352 void TGo4MainWindow::CloseAllFilesSlot()
01353 {
01354     // TGo4LockGuard glob;
01355    TGo4DiskFileBrowserSlots *fxTGo4DiskFileBrowserSlots = dynamic_cast <TGo4DiskFileBrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4DiskFileBrowserSlots"));
01356    TGo4DiskFileBrowser *fxTGo4DiskFileBrowser= dynamic_cast <TGo4DiskFileBrowser *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4DiskFileBrowserSlots));
01357    if (fxTGo4DiskFileBrowser!=0)fxTGo4DiskFileBrowser->CloseAllFiles();
01358 }
01359 
01360 
01361 void TGo4MainWindow::OpenFileSlot()
01362 {
01363     // TGo4LockGuard glob;
01364    TGo4DiskFileBrowserSlots *fxTGo4DiskFileBrowserSlots = dynamic_cast <TGo4DiskFileBrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4DiskFileBrowserSlots"));
01365    TGo4DiskFileBrowser *fxTGo4DiskFileBrowser= dynamic_cast <TGo4DiskFileBrowser *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4DiskFileBrowserSlots));
01366    if (fxTGo4DiskFileBrowser!=0)fxTGo4DiskFileBrowser->OpenLocalFile();
01367 
01368 
01369 }
01370 
01371 void TGo4MainWindow::OpenRemoteFileSlot()
01372 {
01373     // TGo4LockGuard glob;
01374    TGo4DiskFileBrowserSlots *fxTGo4DiskFileBrowserSlots = dynamic_cast <TGo4DiskFileBrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4DiskFileBrowserSlots"));
01375    TGo4DiskFileBrowser *fxTGo4DiskFileBrowser= dynamic_cast <TGo4DiskFileBrowser *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4DiskFileBrowserSlots));
01376    if (fxTGo4DiskFileBrowser!=0)fxTGo4DiskFileBrowser->OpenRemoteFile();
01377 
01378 
01379 }
01380 
01381 
01382 void TGo4MainWindow::SaveFileSlot()
01383 {
01384     // TGo4LockGuard glob;
01385    TGo4BrowserSlots *fxTGo4BrowserSlots = dynamic_cast <TGo4BrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
01386    TGo4Browser *fxTGo4Browser= dynamic_cast <TGo4Browser *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4BrowserSlots));
01387    if(fxTGo4Browser!=0) fxTGo4Browser->SaveLocalListToRootFile();
01388 
01389 }
01390 
01391 void TGo4MainWindow::ExportSelectedObjectsSlot()
01392 {
01393     TGo4BrowserSlots *fxTGo4BrowserSlots = dynamic_cast <TGo4BrowserSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
01394    TGo4Browser *fxTGo4Browser= dynamic_cast <TGo4Browser *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4BrowserSlots));
01395    if(fxTGo4Browser!=0) fxTGo4Browser->ExportSelectedItems();
01396 }
01397 
01398 void TGo4MainWindow::StartGUIScriptSlot() {
01399     TGo4ScriptWidget* widg = 0;
01400 
01401     TGo4ScriptSlots* sl = dynamic_cast<TGo4ScriptSlots*> (fxTGo4GUIRegistry->GetSlotClass("TGo4ScriptSlots"));
01402     if (sl!=0)
01403       widg = sl->GetGUI();
01404 
01405     if (widg==0) {
01406        widg = new TGo4ScriptWidget(fxTGo4WorkSpace);
01407        widg->polish();
01408     } else
01409        widg->raise();
01410 
01411     widg->show();
01412 
01413     widg->executeScript(0);
01414 }
01415 
01416 void TGo4MainWindow::StopGUIScriptSlot() {
01417    TGo4ScriptSlots* sl = dynamic_cast<TGo4ScriptSlots*>
01418      (fxTGo4GUIRegistry->GetSlotClass("TGo4ScriptSlots"));
01419    if (sl==0) return;
01420 
01421    TGo4ScriptWidget* widg = sl->GetGUI();
01422    if (widg)
01423      widg->breakScript();
01424 }
01425 
01426 void TGo4MainWindow::CreateGUIScriptSlot() {
01427 
01428    QString fileName = QFileDialog::getSaveFileName(
01429         "",
01430         QString("GUI hotstart script (*") + TGo4ScriptSlots::GUIScriptExtension + ")",
01431         this,
01432         "Create GUI script dialog",
01433         "Choose a file to be created");
01434     if (fileName.length()==0) return;
01435 
01436     TGo4ScriptWidget* widg = 0;
01437 
01438     TGo4ScriptSlots* sl = dynamic_cast<TGo4ScriptSlots*> (fxTGo4GUIRegistry->GetSlotClass("TGo4ScriptSlots"));
01439     if (sl!=0)
01440       widg = sl->GetGUI();
01441 
01442     if (widg==0) {
01443        widg = new TGo4ScriptWidget(fxTGo4WorkSpace);
01444        widg->polish();
01445     } else
01446        widg->raise();
01447 
01448     widg->show();
01449 
01450     widg->produceScript(fileName);
01451 }
01452 
01453 void TGo4MainWindow::InputTerminalParametersSlot() 
01454 {
01455    TGo4QSettings settings;
01456    int size = settings.readNumEntry(TGo4QSettings::GetSettingsName()+"/AnalisysTerminal/HistorySize", 100000);
01457 
01458    bool ok;
01459 
01460    size = QInputDialog::getInteger("Analysis terminal history size in bytes (minimum 10000 bytes)",
01461                                    "Input 0 if full analysis history should be preserved",
01462                                    size, 0, 100000000, 10000, &ok, this);
01463 
01464    if ((size>0) && (size<10000)) size = 10000;
01465 
01466    if (ok) {
01467      settings.writeEntry(TGo4QSettings::GetSettingsName()+"/AnalisysTerminal/HistorySize", size);
01468      if (fxAnalysisShell)
01469        fxAnalysisShell->ReadHistorySize();
01470    }
01471 }
01472 
01473 
01474 //void TGo4MainWindow::SaveWinSlot()
01475 //{
01476 //    // TGo4LockGuard glob;
01477 //    QWidget *AW =fxTGo4WorkSpace->activeWindow();
01478 //    TGo4WindowEdit* conditioneditor=dynamic_cast<TGo4WindowEdit*>(AW);
01479 //    TGo4PreviewPanel *fxTGo4PreviewPanel= dynamic_cast <TGo4PreviewPanel *> (AW);
01480 //    if(AW==fxAnalysisShell)
01481 //       {
01482 //      QFileDialog* fd = new QFileDialog( this, "Save analysis information", TRUE );
01483 //       fd->setMode( QFileDialog::AnyFile );
01484 //       fd->setFilter( "Plain text (*.txt)" );
01485 //          if ( fd->exec() == QDialog::Accepted ){
01486 //             fd->setName( "Save analysis output");
01487 //             QString fileName=fd->selectedFile();
01488 //             if(!fileName.endsWith(".txt")) fileName.append(".txt");
01489 //            QFile NewFile(fileName);
01490 //            NewFile.open( IO_ReadWrite | IO_Append );
01491 //            QTextStream t( &NewFile );
01492 //            t << fxAnalysisShell->terminalOutputText() << endl;
01493 //            NewFile.close();
01494 //         }
01495 //       }
01496 //     else if (conditioneditor!=0)
01497 //        {
01498 //         conditioneditor->WriteToLogfile();
01499 //        }
01500 //     else if(fxTGo4PreviewPanel!=0)
01501 //        {
01502 //         fxTGo4PreviewPanel->SaveCanvas();
01503 //        }
01504 //     else {}
01505 //}
01506 
01507 void TGo4MainWindow::LogSettingsSlot()
01508 {
01509 TGo4LogSettings* fd = new TGo4LogSettings( this, "Logging setup for GUI:", TRUE );
01510 if ( fd->exec() == QDialog::Accepted )
01511    {
01512 
01513    QString fileName=fd->LogfileName->text();
01514    bool iswrite=fd->LogfileWrite->isChecked();
01515    bool isprint=fd->LogfilePrint->isChecked();
01516    int ignorelevel=fd->IgnoreCombo->currentItem();
01517    bool mode=fd->ModeCombo->currentItem();
01518    if(iswrite)
01519          TGo4Log::OpenLogfile(fileName,"Logfile for Go4 GUI",true);
01520    TGo4Log::LogfileEnable(iswrite);
01521    TGo4Log::OutputEnable(isprint);
01522    TGo4Log::SetIgnoreLevel(ignorelevel);
01523    TGo4Log::AutoEnable(mode);
01524    }
01525 delete fd;
01526 }
01527 
01528 void TGo4MainWindow::ExitSlot()
01529 {
01530    QWidget::close();
01531 }
01532 
01533 void TGo4MainWindow::SaveLogSlot()
01534 {
01535     // TGo4LockGuard glob;
01536    if(fxTGo4LogInfo!=0)fxTGo4LogInfo->SaveText();
01537 }
01538 
01539 //void TGo4MainWindow::PrintSlot()
01540 //{
01541 //   // TGo4LockGuard glob;
01542 //   QWidget *AW =fxTGo4WorkSpace->activeWindow();
01543 //   TGo4PreviewPanel *fxTGo4PreviewPanel= dynamic_cast <TGo4PreviewPanel *>   (AW);
01544 //   if(fxTGo4PreviewPanel!=0) fxTGo4PreviewPanel->PrintCanvas();
01545 //
01546 //}
01547 
01548 void TGo4MainWindow::EditCopySlot()
01549 {
01550        // TGo4LockGuard glob;
01551        QWidget *AW =fxTGo4WorkSpace->activeWindow();
01552        TGo4PreviewPanel *fxTGo4PreviewPanel= dynamic_cast <TGo4PreviewPanel *>   (AW);
01553 
01554        if(fxTGo4PreviewPanel!=0){
01555           TGo4QRootCanvas *fxCanvas= fxTGo4PreviewPanel->GetQCanvas();
01556           QPixmap Pic (fxCanvas->width(), fxCanvas->height() );
01557           bitBlt(&Pic,0,0, fxCanvas,0,0, fxCanvas->width(), fxCanvas->height(), Qt::CopyROP );
01558           QClipboard *cb = QApplication::clipboard();
01559           cb->clear () ;
01560           cb->setSelectionMode(TRUE);
01561           cb->setPixmap(Pic);
01562        }
01563 
01564 }
01565 
01566 void TGo4MainWindow::DrawOptionsSlot()
01567 {
01568    // TGo4LockGuard glob;
01569    if (fxTGo4HisDrawOptions==0){
01570       QToolBar *DrawOptionPanel = new QToolBar(this,"Histogram Draw Options" );
01571       addDockWindow(DrawOptionPanel, tr( "Draw Options " ), Qt::DockTop, TRUE );
01572       DrawOptionPanel->setResizeEnabled(TRUE);
01573       fxTGo4HisDrawOptions = new TGo4HisDrawOptions(DrawOptionPanel);
01574       fxTGo4HisDrawOptions->polish();
01575       fxTGo4HisDrawOptions->show();
01576    }
01577 }
01578 
01579 void TGo4MainWindow::ScaleOptionsSlot()
01580 {
01581    // TGo4LockGuard glob;
01582    if (fxTGo4ScaleOptions==0){
01583       QToolBar *ScaleOptionPanel = new QToolBar(this, "Zoom Tools" );
01584       addDockWindow(ScaleOptionPanel, tr( "Zoom Tools" ), Qt::DockTop, TRUE );
01585       fxTGo4ScaleOptions = new TGo4ScaleOptions(ScaleOptionPanel);
01586       fxTGo4ScaleOptions->polish();
01587       fxTGo4ScaleOptions->show();
01588       setAppropriate ( ScaleOptionPanel, TRUE);
01589    }
01590 
01591 }
01592 
01593 void TGo4MainWindow::DivideCanvasSlot()
01594 {
01595    // TGo4LockGuard glob;
01596    if (fxTGo4DividePad==0){
01597       QToolBar *DivideOptionPanel = new QToolBar (this, "Canvas Tools" );
01598       addDockWindow(DivideOptionPanel, tr( "Canvas Tools" ), Qt::DockTop, TRUE );
01599       setAppropriate ( DivideOptionPanel, true);
01600       DivideOptionPanel->setHorizontallyStretchable (FALSE);
01601       fxTGo4DividePad = new TGo4DividePad(DivideOptionPanel);
01602       fxTGo4DividePad->polish();
01603       fxTGo4DividePad->show();
01604    }
01605 
01606 
01607 }
01608 
01609 void TGo4MainWindow::StyleSlot()
01610 {
01611    // TGo4LockGuard glob;
01612    if (fxTGo4Style==0){
01613       QToolBar *StyleOptionPanel = new  QToolBar(this, "Color Tools" );
01614       addDockWindow(StyleOptionPanel, tr( "Color Tools" ), Qt::DockTop, TRUE );
01615       setAppropriate ( StyleOptionPanel, true);
01616 //      StyleOptionPanel->setHorizontallyStretchable (TRUE);
01617       fxTGo4Style  = new TGo4Style(StyleOptionPanel);
01618       fxTGo4Style->polish();
01619       fxTGo4Style->show();
01620    }
01621 
01622 
01623 }
01624 
01625 void TGo4MainWindow::Go4BrowsersSlot()
01626 {
01627     // TGo4LockGuard glob;
01628     if(fxTGo4DockBrowsers==0){
01629       QDockWindow *BrowserDockWin = new QDockWindow();
01630       BrowserDockWin->setResizeEnabled( TRUE );
01631       BrowserDockWin->setCaption( tr( "Browser Pads" ) );
01632         setAppropriate ( BrowserDockWin, true);
01633        fxTGo4DockBrowsers = new TGo4DockBrowsers(BrowserDockWin);
01634        connect(fxTGo4DockBrowsers, SIGNAL(Go4BrowsersClosed()), this, SLOT(CloseBrowsers()));
01635        BrowserDockWin->setWidget(fxTGo4DockBrowsers );
01636       addDockWindow( BrowserDockWin, Qt::DockLeft );
01637       BrowserDockWin->show();
01638     }
01639 }
01640 
01641 void TGo4MainWindow::LogPanelSlot()
01642 {
01643     // TGo4LockGuard glob;
01644    if(fxTGo4LogInfo==0){
01645       QDockWindow *LogInfo  = new QDockWindow();
01646       LogInfo->setResizeEnabled( TRUE );
01647       LogInfo->setCaption( tr( "Log Window" ) );
01648       setAppropriate ( LogInfo, true);
01649       fxTGo4LogInfo = new TGo4LogInfo(LogInfo);
01650       LogInfo->setWidget(fxTGo4LogInfo );
01651       addDockWindow(LogInfo, Qt::DockBottom);
01652       LogInfo->show();
01653    }
01654 }
01655 
01656 void TGo4MainWindow::Go4TreeViewerSlot()
01657 {
01658     // TGo4LockGuard glob;
01659     if(fxTGo4TreeViewer==0){
01660       QDockWindow *TreeViewer= new QDockWindow();
01661       TreeViewer->setResizeEnabled( TRUE );
01662       TreeViewer->setCaption( tr( "Tree Viewer" ) );
01663 //      setAppropriate ( TreeViewer, true);
01664       fxTGo4TreeViewer = new   TGo4TreeViewer  (TreeViewer);
01665 
01666       TreeViewer->setWidget(fxTGo4TreeViewer  );
01667       TreeViewer->setCloseMode(2);
01668       addDockWindow(TreeViewer, Qt::DockBottom);
01669         TreeViewer->show();
01670     }else {
01671 
01672 
01673     }
01674 
01675 }
01676 
01677 void TGo4MainWindow::WindowActivatedSlot(QWidget * w)
01678 {
01679    // TGo4LockGuard glob;
01680    SetMainCaption(fiMasterMode); 
01681    TGo4PreviewPanel *fxView= dynamic_cast <TGo4PreviewPanel *> (w);
01682    if(fxView !=0){
01683       TPad *ActivePad = fxView->GetActivePad();
01684       ActivePad->cd();
01685       fxTGo4WorkSpace->ViewPanelActivated(fxView);
01686       if(fxTGo4ScaleOptions!=0)  fxTGo4ScaleOptions->SetViewPanel(fxView );
01687       if(fxTGo4HisDrawOptions!=0)  fxTGo4HisDrawOptions->SetViewPanel(fxView );
01688       if(fxTGo4DividePad!=0)  fxTGo4DividePad->SetViewPanel(fxView );
01689       if(fxTGo4Style!=0) fxTGo4Style->SetViewPanel(fxView );
01690       if (fxTGo4FitPanel!=0 ) fxTGo4FitPanel->SetViewPanel(fxView);
01691        // now inform all exisiting condition editor slots:
01692       fxWinConIterator->Reset();
01693       TObject* ob=0;
01694       while((ob=fxWinConIterator->Next()) !=0)
01695         {
01696             TGo4WindowEditSlots* ws=dynamic_cast<TGo4WindowEditSlots*>(ob);
01697             if(ws)
01698                   ws->SetViewPanel(fxView);
01699         }
01700       RememberViewpanelSize(fxView);
01701    }
01702 
01703 }
01704 
01705 
01706 void TGo4MainWindow::ActivePadChanged(TGo4PreviewPanel *fxView, TPad *)
01707 {
01708    if(fxTGo4ScaleOptions!=0)  fxTGo4ScaleOptions->SetViewPanel(fxView );
01709    if(fxTGo4HisDrawOptions!=0)  fxTGo4HisDrawOptions->SetViewPanel(fxView );
01710    if(fxTGo4DividePad!=0)  fxTGo4DividePad->SetViewPanel(fxView );
01711    if(fxTGo4Style!=0) fxTGo4Style->SetViewPanel(fxView );
01712    if (fxTGo4FitPanel!=0 ) fxTGo4FitPanel->SetViewPanel(fxView);
01713    // now inform all exisiting condition editor slots:
01714    fxWinConIterator->Reset();
01715    TObject* ob=0;
01716    while((ob=fxWinConIterator->Next()) !=0)
01717      {
01718          TGo4WindowEditSlots* ws=dynamic_cast<TGo4WindowEditSlots*>(ob);
01719          if(ws)
01720             ws->SetViewPanel(fxView);
01721      }
01722 }
01723 
01724 void TGo4MainWindow::MouseClick(TGo4PreviewPanel* view, TPad* pad)
01725 {
01726    fxWinConIterator->Reset();
01727    TObject* ob=0;
01728    while((ob=fxWinConIterator->Next()) !=0)
01729      {
01730          TGo4WindowEditSlots* ws=dynamic_cast<TGo4WindowEditSlots*>(ob);
01731          if(ws)
01732             ws->Click(view,pad);
01733      }
01734 }
01735 
01736 
01737 void  TGo4MainWindow::WorkSpaceRemovedChild(TGo4PreviewPanel *Obj)
01738 {
01739    // TGo4LockGuard glob;
01740    SetMainCaption(fiMasterMode); 
01741    if(Obj !=0){
01742       //TPad *ActivePad = Obj->GetActivePad();
01743       if(fxTGo4ScaleOptions!=0)  fxTGo4ScaleOptions->SetViewPanel(0 );
01744       if(fxTGo4HisDrawOptions!=0)  fxTGo4HisDrawOptions->SetViewPanel(0 );
01745       if(fxTGo4DividePad!=0)  fxTGo4DividePad->SetViewPanel(0 );
01746       if(fxTGo4Style!=0) fxTGo4Style->SetViewPanel(0);
01747       if (fxTGo4FitPanel!=0) fxTGo4FitPanel->PanelRemoved(Obj);
01748       // now inform all exisiting condition editor slots:
01749       fxWinConIterator->Reset();
01750       TObject* ob=0;
01751       while((ob=fxWinConIterator->Next()) !=0)
01752         {
01753             TGo4WindowEditSlots* ws=dynamic_cast<TGo4WindowEditSlots*>(ob);
01754             if(ws)
01755                ws->RemoveViewPanel(Obj);
01756         }
01757 
01758    }
01759 }
01760 void  TGo4MainWindow::WorkSpaceNewChild(TGo4PreviewPanel *fxView)
01761 {
01762    // TGo4LockGuard glob;
01763    SetMainCaption(fiMasterMode); 
01764    if(fxView!=0){
01765       if(fxTGo4ScaleOptions!=0)  fxTGo4ScaleOptions->SetViewPanel(fxView );
01766       if(fxTGo4HisDrawOptions!=0)  fxTGo4HisDrawOptions->SetViewPanel(fxView );
01767       if(fxTGo4DividePad!=0)  fxTGo4DividePad->SetViewPanel(fxView );
01768       if(fxTGo4Style!=0) fxTGo4Style->SetViewPanel(fxView );
01769       if (fxTGo4FitPanel!=0)fxTGo4FitPanel->SetViewPanel(fxView);
01770       // now inform all exisiting condition editor slots:
01771       fxWinConIterator->Reset();
01772       TObject* ob=0;
01773       while((ob=fxWinConIterator->Next()) !=0)
01774         {
01775 
01776             TGo4WindowEditSlots* ws=dynamic_cast<TGo4WindowEditSlots*>(ob);
01777             if(ws)
01778                ws->SetViewPanel(fxView);
01779         }
01780 
01781    }
01782 
01783 }
01784 
01785 
01786 void  TGo4MainWindow::IntroHelpSlot()
01787 {
01788 QApplication::setOverrideCursor( Qt::WaitCursor );
01789 StatusMessage("Loading Go4 Introduction manual..."); 
01790 QString fxPath=gSystem->Getenv("GO4SYS");
01791 fxPath.append("/Go4Library/Go4Doc");
01792 TGo4HelpWindow *  fxTGo4HelpWindow =  new TGo4HelpWindow("Go4introV2.htm", fxPath, fxTGo4WorkSpace) ;
01793 fxTGo4HelpWindow->show();
01794 QApplication::restoreOverrideCursor();
01795 
01796 }
01797 
01798 void  TGo4MainWindow::RefHelpSlot()
01799 {
01800 QApplication::setOverrideCursor( Qt::WaitCursor );
01801 StatusMessage("Loading Go4 Reference manual...");
01802 QString fxPath=gSystem->Getenv("GO4SYS");
01803 fxPath.append("/Go4Library/Go4Doc");
01804 TGo4HelpWindow *  fxTGo4HelpWindow =  new TGo4HelpWindow("Go4refV2.htm", fxPath, fxTGo4WorkSpace) ;
01805 fxTGo4HelpWindow->show();
01806 QApplication::restoreOverrideCursor();
01807 }
01808 
01809 void  TGo4MainWindow::FitHelpSlot()
01810 {
01811 QApplication::setOverrideCursor( Qt::WaitCursor );
01812 StatusMessage("Loading Go4 Fit tutorial...");
01813 QString fxPath=gSystem->Getenv("GO4SYS");
01814 fxPath.append("/Go4Library/Go4Doc");
01815 TGo4HelpWindow *  fxTGo4HelpWindow =  new TGo4HelpWindow("Go4FitTutorial.htm", fxPath, fxTGo4WorkSpace) ;
01816 fxTGo4HelpWindow->show();
01817 QApplication::restoreOverrideCursor();
01818 
01819 }
01820 
01821 void TGo4MainWindow::ShowAnylsisOutput(const char* commandline) {
01822   // TGo4LockGuard glob;
01823    if(fxAnalysisShell!=0)
01824      fxAnalysisShell->StartAnalysisShell(commandline);
01825 }
01826 
01827 TGo4FitPanel * TGo4MainWindow::FitPanelSlot()
01828 {
01829    // TGo4LockGuard glob;
01830    if (fxTGo4FitPanel ==0){
01831       fxTGo4FitPanel = new TGo4FitPanel(fxTGo4WorkSpace);
01832       fxTGo4FitPanel->polish();
01833       fxTGo4FitPanel->show();
01834    }else if(!fxTGo4FitPanel->isVisible()){
01835       fxTGo4FitPanel->raise();
01836       fxTGo4FitPanel->show();
01837 
01838    }
01839    return fxTGo4FitPanel;
01840 
01841 }
01842 
01843 void TGo4MainWindow::StartAnalysisWin(bool force)
01844 {
01845     // TGo4LockGuard glob;
01846    if(fxAnalysisShell==0){
01847       fxAnalysisShell = new  TGo4AnalysisWindow(fxTGo4WorkSpace);
01848       fxAnalysisShell->show();
01849    }else
01850 //   {
01851 //      fxAnalysisShell->raise();
01852 //      fxAnalysisShell->show();
01853 //   }
01854    
01855    if (fxAnalysisShell->isVisible() && !force) {
01856       fxAnalysisShell->hide();
01857    } else {
01858       fxAnalysisShell->raise();
01859       fxAnalysisShell->show();
01860       if (fxAnalysisShell->isMinimized()) fxAnalysisShell->showNormal();
01861    }
01862 }
01863 
01864 void TGo4MainWindow::saveOptions()
01865 {
01866     TGo4QSettings settings;
01867     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinWidth", width() );
01868     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinHeight", height() );
01869     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinX", x() );
01870     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/MainWinY", y() );
01871 
01872     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/Font", m_font.toString() );
01873 
01874     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceWidth", fxTGo4WorkSpace->width() );
01875     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceHeight",fxTGo4WorkSpace->height() );
01876     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceX", fxTGo4WorkSpace->x() );
01877     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/WorkSpaceY", fxTGo4WorkSpace->y() );
01878 
01879     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelWidth", fxViewpanelSize.width() );
01880     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelHeight", fxViewpanelSize.height() );
01881 
01882     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/Crosshairmode", (int) fbCrosshairMode );
01883 
01884     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelBackRed", (int) fiPadcolorR );
01885     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelBackBlu", (int) fiPadcolorB );
01886     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/geometry/ViewPanelBackGrn", (int) fiPadcolorG );
01887 
01888     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/Markerlabel", (int) TGo4Marker::fgbHASLABEL);
01889     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/Connectorline", (int) TGo4Marker::fgbHASCONNECTOR);
01890     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowX", (int) TGo4Marker::fgbXDRAW);
01891     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowY", (int) TGo4Marker::fgbYDRAW);
01892     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowXbin", (int) TGo4Marker::fgbXBINDRAW);
01893     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowYbin", (int)TGo4Marker::fgbYBINDRAW);
01894     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/markers/ShowBinContent", (int) TGo4Marker::fgbCONTDRAW);
01895 
01896     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/Conditionlabel", (int) TGo4Condition::fgbLABELDRAW);
01897     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowLimits", (int) TGo4Condition::fgbLIMITSDRAW);
01898     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowIntegral", (int) TGo4Condition::fgbINTDRAW);
01899     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowXmean", (int) TGo4Condition::fgbXMEANDRAW);
01900     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowYmean", (int) TGo4Condition::fgbYMEANDRAW);
01901     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowXrms", (int) TGo4Condition::fgbXRMSDRAW);
01902     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowYrms", (int) TGo4Condition::fgbYRMSDRAW);
01903     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowXmax", (int) TGo4Condition::fgbXMAXDRAW);
01904     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowYmax", (int) TGo4Condition::fgbYMAXDRAW);
01905     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/conditions/ShowCmax", (int) TGo4Condition::fgbCMAXDRAW);
01906 
01907     settings.writeEntry( TGo4QSettings::GetSettingsName()+"/Style/AppStyle", QApplication::style().name());
01908    
01909    QString fn;
01910 //   if(TGo4QSettings::UsesCurrentDir())
01911 //         fn = QDir::currentDirPath() + fxSettingsfolder + fxToolsfile;
01912 //   else 
01913    if(TGo4QSettings::UsesUserPath())
01914       fn =TGo4QSettings::GetUserPath() + fxToolsfile;
01915    else
01916       fn = QDir::homeDirPath() + fxSettingsfolder + fxToolsfile;
01917    QFile f( fn );
01918    f.open( IO_WriteOnly );
01919    QTextStream ts( &f );
01920    ts << *this;
01921    f.close();
01922    cout <<"Saved Go4 toolbar settings to " << fn << endl;
01923    settings.DumpSettingsLocation();
01924 }
01925 
01926 void TGo4MainWindow::setFonts()
01927 {
01928     bool ok;
01929     QFont font = QFontDialog::getFont( &ok, m_font, this );
01930     if ( ok ) {
01931         // font is set to the font the user selected
01932         m_font= font;
01933         QApplication::setFont( font, true );
01934     } else {
01935         // the user cancelled the dialog; font is set to the initial value,
01936     }
01937 
01938 
01939 
01940 
01941 }
01942 
01943 
01944 void TGo4MainWindow::makeStyle(const QString &style)
01945 {
01946     if(style == "Norwegian Wood") {
01947 #ifndef QT_NO_STYLE_WINDOWS
01948    QWindowsStyle *Wood = new NorwegianWoodStyle();
01949    Wood->setName("Norwegian Wood");
01950    QApplication::setStyle( Wood );
01951 #endif
01952     } else if( style == "Metal" ) {
01953 #ifndef QT_NO_STYLE_WINDOWS
01954    QWindowsStyle *Metal = new MetalStyle();
01955    Metal->setName("Metal");
01956    QApplication::setStyle(Metal);
01957 #endif
01958     } else {
01959       QApplication::setStyle(style);
01960       if(style == "Platinum") {
01961           QPalette p( QColor( 239, 239, 239 ) );
01962           QApplication::setPalette( p, TRUE );
01963           QApplication::setFont( m_font, TRUE );
01964       } else if(style == "Windows") {
01965           QApplication::setFont( m_font, TRUE );
01966       } else if(style == "CDE") {
01967           QPalette p( QColor( 75, 123, 130 ) );
01968           p.setColor( QPalette::Active, QColorGroup::Base, QColor( 55, 77, 78 ) );
01969           p.setColor( QPalette::Inactive, QColorGroup::Base, QColor( 55, 77, 78 ) );
01970           p.setColor( QPalette::Disabled, QColorGroup::Base, QColor( 55, 77, 78 ) );
01971           p.setColor( QPalette::Active, QColorGroup::Highlight, Qt::white );
01972           p.setColor( QPalette::Active, QColorGroup::HighlightedText, QColor( 55, 77, 78 ) );
01973           p.setColor( QPalette::Inactive, QColorGroup::Highlight, Qt::white );
01974           p.setColor( QPalette::Inactive, QColorGroup::HighlightedText, QColor( 55, 77, 78 ) );
01975           p.setColor( QPalette::Disabled, QColorGroup::Highlight, Qt::white );
01976           p.setColor( QPalette::Disabled, QColorGroup::HighlightedText, QColor( 55, 77, 78 ) );
01977           p.setColor( QPalette::Active, QColorGroup::Foreground, Qt::white );
01978           p.setColor( QPalette::Active, QColorGroup::Text, Qt::white );
01979           p.setColor( QPalette::Active, QColorGroup::ButtonText, Qt::white );
01980           p.setColor( QPalette::Inactive, QColorGroup::Foreground, Qt::white );
01981           p.setColor( QPalette::Inactive, QColorGroup::Text, Qt::white );
01982           p.setColor( QPalette::Inactive, QColorGroup::ButtonText, Qt::white );
01983           p.setColor( QPalette::Disabled, QColorGroup::Foreground, Qt::lightGray );
01984           p.setColor( QPalette::Disabled, QColorGroup::Text, Qt::lightGray );
01985           p.setColor( QPalette::Disabled, QColorGroup::ButtonText, Qt::lightGray );
01986           QApplication::setPalette( p, TRUE );
01987           QApplication::setFont( QFont( "times", m_font.pointSize() ), TRUE );
01988       } else if(style == "Motif" || style == "MotifPlus") {
01989           QPalette p( QColor( 192, 192, 192 ) );
01990           QApplication::setPalette( p, TRUE );
01991           QApplication::setFont( m_font, TRUE );
01992       }
01993     }
01994 //    TGo4QSettings settings;
01995 //    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/Style/AppStyle", QApplication::style().name());
01996 
01997 }
01998 
01999 void TGo4MainWindow::clearAnalysis()
02000 {
02001 
02002    if(fxAnalysisShell!=0)fxAnalysisShell->clearOutput();
02003 }
02004 
02005 void TGo4MainWindow::clearLog()
02006 {
02007    if(fxTGo4LogInfo!=0){
02008       fxTGo4LogInfo->ClearText();
02009    }
02010 }
02011 void TGo4MainWindow::SaveAnalysisWindow()
02012 {
02013 if(fxAnalysisShell)
02014 {
02015    QFileDialog* fd = new QFileDialog( this, "Save analysis terminal output", TRUE );
02016    fd->setMode( QFileDialog::AnyFile );
02017    fd->setFilter( "Plain text (*.txt)" );
02018    fd->setName( "Save analysis output");
02019    fd->setCaption( "Save analysis terminal output");
02020    if ( fd->exec() == QDialog::Accepted ){       
02021       QString fileName=fd->selectedFile();
02022       if(!fileName.endsWith(".txt")) fileName.append(".txt");
02023       QFile NewFile(fileName);
02024       NewFile.open( IO_ReadWrite | IO_Append );
02025       QTextStream t( &NewFile );
02026       t << fxAnalysisShell->terminalOutputText() << endl;
02027       NewFile.close();
02028    }
02029    delete fd;
02030 }   
02031    
02032 }
02033 
02034 
02035 
02036 void TGo4MainWindow::AddDrawBar()
02037 {
02038 //    QToolBar *DrawBar = new QToolBar( this, "File Toolbar" );
02039 //     addDockWindow(DrawBar, tr( "Draw Toolbar" ), Qt::Top, TRUE );
02040 //     DrawBar->setNewLine ( FALSE );
02041 //
02042 //     QToolButton *DrawArc  = new QToolButton( DrawBar,"Arc");
02043 //     QToolTip::add(DrawArc, tr("Draw Arc"));
02044 
02045 }
02046 
02047 
02048 
02049 
02050 void TGo4MainWindow::CreateNewHist()
02051 {
02052      // TGo4LockGuard Global;
02053    TGo4CreateNewHistogram *fxTGo4CreateNewHistogram;
02054    TGo4CreateNewHistogramSlots *fxTGo4CreateNewHistogramSlots;
02055 
02056    fxTGo4CreateNewHistogramSlots = dynamic_cast <TGo4CreateNewHistogramSlots *> (fxTGo4GUIRegistry->GetSlotClass("TGo4CreateNewHistogramSlots"));
02057    if (fxTGo4CreateNewHistogramSlots ==0){
02058       fxTGo4CreateNewHistogram = new TGo4CreateNewHistogram(fxTGo4GUIRegistry->GetCentralWindow());
02059       fxTGo4CreateNewHistogram->polish();
02060       fxTGo4CreateNewHistogram->show();
02061    }else {
02062       fxTGo4CreateNewHistogram  = dynamic_cast <TGo4CreateNewHistogram *> (fxTGo4GUIRegistry->GetGUIClass(fxTGo4CreateNewHistogramSlots));
02063       if (fxTGo4CreateNewHistogram ==0){
02064          fxTGo4CreateNewHistogram = new TGo4CreateNewHistogram(fxTGo4GUIRegistry->GetCentralWindow());
02065          fxTGo4CreateNewHistogram->polish();
02066          fxTGo4CreateNewHistogram->show();
02067       }else{
02068          fxTGo4CreateNewHistogram->raise();
02069          fxTGo4CreateNewHistogram->show();
02070       }
02071    }
02072 }
02073 void TGo4MainWindow::StartParaEdit()
02074 {
02075    // TGo4LockGuard Global;
02076     const Text_t* name="New Parameter";
02077     Text_t slotname[256];
02078     snprintf(slotname,256,"%s_Slots",name);
02079    TGo4ParaEdit* neditor=0;
02080     TGo4ParaEditSlots* nslots=0;
02081     nslots = dynamic_cast <TGo4ParaEditSlots *> (fxTGo4GUIRegistry->GetSlotClass(slotname));
02082    if (nslots ==0)
02083         {
02084       //cout <<"########## slot not found, creating new" << endl;
02085         neditor=new TGo4ParaEdit(fxTGo4GUIRegistry->GetCentralWindow(),
02086                                            name);
02087         }
02088     else
02089         {
02090         //cout <<"########## slot found "<< (int*) nslots << endl;
02091         neditor  = dynamic_cast <TGo4ParaEdit *> (fxTGo4GUIRegistry->GetGUIClass(nslots));
02092         if (neditor==0)
02093             {
02094                 //cout <<"########## gui not found, new "<< endl;
02095                 neditor=new TGo4ParaEdit(fxTGo4GUIRegistry->GetCentralWindow(),
02096                                            name);
02097             }
02098         else {} //if (neditor ==0)
02099          } //if (nslots ==0)
02100 
02101     neditor->SetNewParaMode(true);
02102     neditor->RefreshDisplay(0);
02103     neditor->polish();
02104     neditor->update();
02105     neditor->show();
02106     neditor->raise();
02107 
02108 
02109 }
02110 void TGo4MainWindow::StartDynEditor()
02111 {
02112    // TGo4LockGuard Global;
02113    const Text_t* name="NewEntry";
02114     Text_t slotname[256];
02115     snprintf(slotname,256,"%s_Slots",name);
02116    TGo4EditDynEntry* neditor=0;
02117     TGo4EditDynEntrySlots* nslots=0;
02118    nslots = dynamic_cast <TGo4EditDynEntrySlots *> (fxTGo4GUIRegistry->GetSlotClass(slotname));
02119    if (nslots ==0)
02120         {
02121       //cout <<"########## slot not found, creating new" << endl;
02122         neditor=new TGo4EditDynEntry(fxTGo4GUIRegistry->GetCentralWindow(),
02123                                            name);
02124         }
02125     else
02126         {
02127         //cout <<"########## slot found "<< (int*) nslots << endl;
02128         neditor  = dynamic_cast <TGo4EditDynEntry *> (fxTGo4GUIRegistry->GetGUIClass(nslots));
02129         if (neditor==0)
02130             {
02131                 //cout <<"########## gui not found, new "<< endl;
02132                 neditor=new TGo4EditDynEntry(fxTGo4GUIRegistry->GetCentralWindow(),
02133                                            name);
02134             }
02135         else {} //if (neditor ==0)
02136          } //if (nslots ==0)
02137     neditor->SetEntryEdit(true);
02138     neditor->SetEntryType("TreeDrawEntry");
02139     neditor->polish();
02140     neditor->update();
02141     neditor->showNormal();
02142     neditor->adjustSize();
02143     neditor->raise();
02144 
02145 }
02146 
02147 void TGo4MainWindow::RegisterWindowEditSlots(TGo4WindowEditSlots* slot)
02148 {
02149 if(slot)
02150    {
02151       fxWinConSlotList->Add(slot);
02152       slot->SetViewPanel(fxTGo4WorkSpace->GetLastActiveViewPanel());
02153    }
02154 }
02155 
02156 
02157 void TGo4MainWindow::UnregisterWindowEditSlots(TGo4WindowEditSlots* slot)
02158 {
02159    fxWinConSlotList->Remove(slot);
02160 }
02161 
02162 
02163 TGo4HistogramInfo* TGo4MainWindow::HistogramInfoSlot(const char* hisname)
02164 {
02165    // TGo4LockGuard Global;
02166    const Text_t* name="Go4HistogramInfo";
02167    Text_t slotname[256];
02168    snprintf(slotname,256,"%s_Slots",name);
02169    TGo4HistogramInfo* neditor=0;
02170    TGo4HistogramInfoSlots* nslots=0;
02171    nslots = dynamic_cast <TGo4HistogramInfoSlots *> (fxTGo4GUIRegistry->GetSlotClass(slotname));
02172    if (nslots ==0)
02173         {
02174         neditor=new TGo4HistogramInfo(fxTGo4GUIRegistry->GetCentralWindow(),
02175                                            name);
02176         }
02177     else
02178         {
02179         neditor  = dynamic_cast <TGo4HistogramInfo *> (fxTGo4GUIRegistry->GetGUIClass(nslots));
02180         if (neditor==0)
02181             {
02182                 neditor=new TGo4HistogramInfo(fxTGo4GUIRegistry->GetCentralWindow(),
02183                                            name);
02184             }
02185         else {} //if (neditor ==0)
02186          } //if (nslots ==0)
02187     if(hisname)
02188        neditor->SetHistogramName(hisname);
02189     neditor->polish();
02190     neditor->update();
02191     neditor->showNormal();
02192     neditor->adjustSize();
02193     neditor->raise();
02194     if(hisname)
02195        neditor->HistogramInfo();
02196 
02197 return neditor;
02198 }
02199 
02200 
02201 TGo4ConditionInfo* TGo4MainWindow::ConditionInfoSlot(const char* condname)
02202 {
02203    // TGo4LockGuard Global;
02204    const Text_t* name="Go4ConditionInfo";
02205    Text_t slotname[256];
02206    snprintf(slotname,256,"%s_Slots",name);
02207    TGo4ConditionInfo* neditor=0;
02208    TGo4ConditionInfoSlots* nslots=0;
02209    nslots = dynamic_cast <TGo4ConditionInfoSlots *> (fxTGo4GUIRegistry->GetSlotClass(slotname));
02210    if (nslots ==0)
02211         {
02212         neditor=new TGo4ConditionInfo(fxTGo4GUIRegistry->GetCentralWindow(),
02213                                            name);
02214         }
02215     else
02216         {
02217         neditor  = dynamic_cast <TGo4ConditionInfo *> (fxTGo4GUIRegistry->GetGUIClass(nslots));
02218         if (neditor==0)
02219             {
02220                 neditor=new TGo4ConditionInfo(fxTGo4GUIRegistry->GetCentralWindow(),
02221                                            name);
02222             }
02223         else {} //if (neditor ==0)
02224          } //if (nslots ==0)
02225 
02226     if(condname)
02227        neditor->SetConditionName(condname);
02228     neditor->polish();
02229     neditor->update();
02230     neditor->showNormal();
02231     neditor->adjustSize();
02232     neditor->raise();
02233     if(condname)
02234        neditor->ConditionInfo();
02235 return neditor;
02236 }
02237 
02238 void TGo4MainWindow::ConditionEditSlot(const char* condname, TGo4PreviewPanel* pan)
02239 {
02240    TGo4LockGuard Global;
02241    const Text_t* name;
02242    if(condname)
02243       name=condname;
02244    else
02245       name="General Editor";
02246    Text_t slotname[256];
02247    snprintf(slotname,256,"%s_Slots",name);
02248    TGo4WindowEdit* neditor=0;
02249    TGo4WindowEditSlots* nslots=0;
02250    nslots = dynamic_cast <TGo4WindowEditSlots *> (fxTGo4GUIRegistry->GetSlotClass(slotname));
02251    if (nslots ==0)
02252         {
02253         neditor=new TGo4WindowEdit(fxTGo4GUIRegistry->GetCentralWindow(),
02254                                            name);
02255         }
02256     else
02257         {
02258         neditor  = dynamic_cast <TGo4WindowEdit *> (fxTGo4GUIRegistry->GetGUIClass(nslots));
02259         if (neditor==0)
02260             {
02261                 neditor=new TGo4WindowEdit(fxTGo4GUIRegistry->GetCentralWindow(),
02262                                            name);
02263             }
02264         else {} //if (neditor ==0)
02265          } //if (nslots ==0)
02266 
02267     if(condname)
02268        {
02269           neditor->SetCentralMode(false);
02270        }
02271     else
02272        {
02273           neditor->SetCentralMode(true);
02274           neditor->SetWorkViewPanel(pan); // if pan=0, use active viewpanel
02275         }
02276     neditor->polish();
02277     neditor->update();
02278     neditor->show();
02279     //neditor->adjustSize();
02280     neditor->raise();
02281     neditor->RefreshDisplay();
02282 }
02283 
02284 void TGo4MainWindow::EventInfoSlot(const char* evename)
02285 {
02286    // TGo4LockGuard Global;
02287    QString eve=evename;
02288    const Text_t* name="Go4EventInfo";
02289    Text_t slotname[256];
02290    snprintf(slotname,256,"%s_Slots",name);
02291    TGo4EventInfo* neditor=0;
02292    TGo4EventInfoSlots* nslots=0;
02293    nslots = dynamic_cast <TGo4EventInfoSlots *> (fxTGo4GUIRegistry->GetSlotClass(slotname));
02294    if (nslots ==0)
02295         {
02296         neditor=new TGo4EventInfo(fxTGo4GUIRegistry->GetCentralWindow(),
02297                                            name);
02298         }
02299     else
02300         {
02301         neditor  = dynamic_cast <TGo4EventInfo *> (fxTGo4GUIRegistry->GetGUIClass(nslots));
02302         if (neditor==0)
02303             {
02304                 neditor=new TGo4EventInfo(fxTGo4GUIRegistry->GetCentralWindow(),
02305                                            name);
02306             }
02307         else {} //if (neditor ==0)
02308          } //if (nslots ==0)
02309     if(evename)
02310        neditor->SetEventName(eve);
02311     neditor->polish();
02312     neditor->update();
02313     neditor->showNormal();
02314     neditor->adjustSize();
02315     neditor->raise();
02316     if(evename)
02317        neditor->RefreshClicked();
02318 
02319 
02320 }
02321 
02322 
02323 
02324 void TGo4MainWindow::StatusMessage(const QString& mess) {
02325    QString output = QDateTime::currentDateTime().toString(Qt::ISODate);
02326    output.append(": ");
02327    output.append(mess);
02328    statusBar()->message(output, 3000);
02329    if(TGo4Log::IsAutoEnabled())
02330       TGo4Log::Message(1,output);
02331 }
02332 
02333 void TGo4MainWindow::RememberViewpanelSize(TGo4PreviewPanel* panel)
02334 {
02335 if(panel==0) return;
02336 // remember size of last active viewpanel:
02337 fxViewpanelSize.setWidth(panel->width());
02338 fxViewpanelSize.setHeight(panel->height());
02339 //cout <<"RememberViewpanelSize set viewpanelsize to "<<panel->width()<<":"<<panel->height() << endl;
02340 }
02341 
02342 bool TGo4MainWindow::CheckViewpanel(TGo4PreviewPanel* pan)
02343 {
02344 if(pan==0) return false;
02345 QWidgetList windows = fxTGo4WorkSpace->windowList();
02346 QWidgetListIt it(windows);
02347 QWidget * w;
02348 while ( (w=it.current()) != 0 )
02349    {
02350       ++it;
02351       TGo4PreviewPanel* pp=dynamic_cast<TGo4PreviewPanel*>(w);
02352       if(pp==pan)
02353         {
02354             //cout <<"TGo4MainWindow::CheckViewpanel found "<<(int) pp << endl;
02355             return true;
02356         }
02357    }
02358 return false;
02359 }
02360 
02361 
02362 bool TGo4MainWindow::CheckHistogram(const char* name, TH1* histo)
02363 {
02364 if(histo==0 || name==0) return false;
02365 TGo4QItem* hitem=0;
02366 bool histogramexists=false;
02367 TGo4BrowserSlots* brslot=dynamic_cast<TGo4BrowserSlots*>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
02368 if(brslot)
02369    {
02370    TGo4Browser* brgui=brslot->GetBrowserGUI();
02371    hitem= (TGo4QItem*)  brgui->ListViewLocal->findItem(name,0);
02372    }
02373 if(hitem)
02374   {
02375       TObject* oldob=hitem->GetWorkObject();
02376       if(histo==oldob)
02377           {
02378               histogramexists=true;
02379           }
02380       else
02381           {
02382            //cout <<"Oldobject of right name, but wrong address!!" << endl;
02383           }
02384   }
02385 else
02386    {
02387      //cout <<"sorry item in local list has gone. try monitor:" << endl;
02388      TGo4MonitoredListSlots* mslot=dynamic_cast<TGo4MonitoredListSlots*>(fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots"));
02389      if(mslot)
02390        {
02391          TGo4MonitoredListStatus* mstat=(TGo4MonitoredListStatus*) mslot->GetStatus();
02392          TGo4MonitoredObject* monob=mstat->GetMonitoredObject(name);
02393          if(monob)
02394            {
02395              TObject* oldmob=monob->GetMonitoredObject();
02396              if(histo==oldmob)
02397                   {
02398                       histogramexists=true;
02399                   }
02400              else
02401                {
02402                  //cout <<"Oldmonitored of right name, but wrong address!!" << endl;
02403                }
02404            } //if(monob)
02405        }//if(mslot)
02406    }//if(hitem)
02407 //cout <<"histogramexists is "<< histogramexists << endl;
02408 return histogramexists;
02409 }
02410 
02411 void TGo4MainWindow::CanvasColorSlot()
02412 {
02413 QColor c = QColorDialog::getColor();
02414 if ( c.isValid())
02415    {
02416       fiPadcolorR=c.red();
02417       fiPadcolorG=c.green();
02418       fiPadcolorB=c.blue();
02419    }
02420 }
02421 
02422 int TGo4MainWindow::AssignRootColors()
02423 {
02424    int pcol =  TColor::GetColor(fiPadcolorR, fiPadcolorG, fiPadcolorB);
02425    if(pcol==0) return pcol; // do not reassign background color
02426    // now define associated colors for WBOX shading
02427    // note: root restricts this mechanism to number<50
02428    // we extend it since TGX11ttf expects the shadow color
02429    // the following are copies from TColor code:
02430    Int_t nplanes = 16;
02431    if (gVirtualX) gVirtualX->GetPlanes(nplanes);
02432    if (nplanes == 0) nplanes = 16;
02433    TColor *normal = gROOT->GetColor(pcol);
02434    if(normal)
02435    {
02436       Float_t h,l,s;
02437       normal->GetHLS(h,l,s);
02438       const Text_t* cname=normal->GetName();
02439       Text_t aname[64];
02440       // assign the color numbers and names for shading:
02441       Float_t dr, dg, db, lr, lg, lb;
02442        TColor *dark = gROOT->GetColor(100+pcol);
02443        if(dark==0)
02444           {
02445              snprintf(aname,64,"%s%s",cname,"_dark");
02446              new TColor(100+pcol, -1, -1, -1, aname);
02447              dark = gROOT->GetColor(100+pcol);
02448           }
02449        TColor *light = gROOT->GetColor(150+pcol);
02450        if(light==0)
02451           {
02452              snprintf(aname,64,"%s%s",cname,"_bright");
02453              new TColor(150+pcol, -1, -1, -1, aname);
02454              light = gROOT->GetColor(150+pcol);
02455           }
02456 
02457       // set dark color
02458       TColor::HLStoRGB(h, 0.7*l, s, dr, dg, db);
02459       if (dark) {
02460          if (nplanes > 8) dark->SetRGB(dr, dg, db);
02461          else             dark->SetRGB(0.3,0.3,0.3);
02462       }
02463 
02464       // set light color
02465       TColor::HLStoRGB(h, 1.2*l, s, lr, lg, lb);
02466       if (light) {
02467          if (nplanes > 8) light->SetRGB(lr, lg, lb);
02468          else             light->SetRGB(0.8,0.8,0.8);
02469       }
02470 
02471    } // if(normal)
02472    else
02473       {
02474           cerr <<"TGo4MainWindow::Could not assign root shadow colors for number "<<pcol << endl;
02475           cerr <<"Never come here!!!" <<endl;
02476       }
02477 return pcol;
02478 }
02479 
02480 
02481 void TGo4MainWindow::CrosshairSlot()
02482 {
02483 bool s = !SettingMenu->isItemChecked(fiCrosshairId);
02484 SettingMenu->setItemChecked(fiCrosshairId,s);
02485 fbCrosshairMode=s;
02486 }
02487 
02488 void TGo4MainWindow::SetMasterMode(int mode)
02489 {
02490 fiMasterMode=mode;
02491 SetMainCaption(fiMasterMode);   
02492 }
02493 
02494 void TGo4MainWindow::SetMainCaption(int mode)
02495 {
02496  QString caption= "Go4 ";
02497  caption.append(__GO4RELEASE__);
02498  QString hostname=gSystem->HostName();
02499  caption.append(" @");
02500  caption.append(hostname);
02501  switch(mode)
02502    {
02503       case 0:      
02504          caption.append(" [disconnected]");
02505          break;
02506       
02507       case 1:
02508          caption.append(" (Observer)");
02509          break;
02510       
02511       case 2:
02512          caption.append(" <CONTROLLER>");   
02513          break;
02514       
02515       case 3:
02516          caption.append(" <<ADMINISTRATOR>>");   
02517          break;
02518       
02519       default:
02520       
02521          break;
02522          
02523    };
02524 setCaption( trUtf8(caption.data()) );
02525 setName(trUtf8(caption.data()));   
02526    
02527    
02528 }
02529 
02530 void TGo4MainWindow::StopMonitoring()
02531 {
02532 TGo4RemoteBrowserSlots *fxRemote = (TGo4RemoteBrowserSlots *)fxTGo4GUIRegistry->GetSlotClass("TGo4RemoteBrowserSlots");
02533 if (fxRemote) fxRemote->ClearBrowser();
02534 TGo4MonitoredListSlots* moni = (TGo4MonitoredListSlots *)fxTGo4GUIRegistry->GetSlotClass("TGo4MonitoredListSlots");
02535 if (moni) moni->GetGUI()->StopMonitoring();   
02536    
02537    
02538 }
02539 
02540 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:01 2005 for Go4-v2.10-5 by doxygen1.2.15