SplitGLView.C

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: SplitGLView.C 32183 2010-02-02 11:18:27Z bellenot $
00002 // Author: Bertrand Bellenot
00003 
00004 // Helper classes for the alice_esd_split.C demo.
00005 
00006 #include "TApplication.h"
00007 #include "TSystem.h"
00008 #include "TGFrame.h"
00009 #include "TGLayout.h"
00010 #include "TGSplitter.h"
00011 #include "TGLWidget.h"
00012 #include "TEvePad.h"
00013 #include "TGeoManager.h"
00014 #include "TString.h"
00015 #include "TGMenu.h"
00016 #include "TGStatusBar.h"
00017 #include "TGFileDialog.h"
00018 #include "TGMsgBox.h"
00019 #include "TGLPhysicalShape.h"
00020 #include "TGLLogicalShape.h"
00021 #include "HelpText.h"
00022 #include "TClass.h"
00023 #include "Riostream.h"
00024 #include "TEnv.h"
00025 #include "TGListTree.h"
00026 #include "TOrdCollection.h"
00027 #include "TArrayF.h"
00028 #include "TGHtml.h"
00029 #include "TPRegexp.h"
00030 
00031 #include "TEveManager.h"
00032 #include "TEveViewer.h"
00033 #include "TEveBrowser.h"
00034 #include "TEveProjectionManager.h"
00035 #include "TEveProjectionAxes.h"
00036 #include "TEveScene.h"
00037 #include "TEveGeoNode.h"
00038 #include "TEveEventManager.h"
00039 #include "TEveTrack.h"
00040 #include "TEveSelection.h"
00041 
00042 #include "TRootEmbeddedCanvas.h"
00043 #include "TGSplitFrame.h"
00044 #include "TGLOverlayButton.h"
00045 #include "TGLEmbeddedViewer.h"
00046 #include "TGDockableFrame.h"
00047 #include "TGShapedFrame.h"
00048 #include "TGButton.h"
00049 #include "TGTab.h"
00050 #include "TEnv.h"
00051 
00052 #include "TCanvas.h"
00053 #include "TFormula.h"
00054 #include "TF1.h"
00055 #include "TH1F.h"
00056 
00057 #ifdef WIN32
00058 #include <TWin32SplashThread.h>
00059 #endif
00060 
00061 const char *filetypes[] = { 
00062    "ROOT files",    "*.root",
00063    "All files",     "*",
00064    0,               0 
00065 };
00066 
00067 const char *rcfiletypes[] = { 
00068    "All files",     "*",
00069    0,               0 
00070 };
00071 
00072 ////////////////////////////////////////////////////////////////////////////////
00073 class TGShapedToolTip : public TGShapedFrame {
00074 
00075 private:
00076    TGShapedToolTip(const TGShapedToolTip&); // Not implemented
00077    TGShapedToolTip& operator=(const TGShapedToolTip&); // Not implemented
00078 
00079 protected:
00080    Int_t                 fTextX, fTextY, fTextH;
00081    TString               fTextCol;
00082 
00083    TRootEmbeddedCanvas  *fEc;       // embedded canvas for histogram
00084    TH1                  *fHist;     // user histogram
00085    TString               fText;     // info (as tool tip) text
00086 
00087    virtual void          DoRedraw() {}
00088 
00089 public:
00090    TGShapedToolTip(const char *picname, Int_t cx=0, Int_t cy=0, Int_t cw=0, 
00091                    Int_t ch=0, Int_t tx=0, Int_t ty=0, Int_t th=0, 
00092                    const char *col="#ffffff");
00093    virtual ~TGShapedToolTip();
00094 
00095    virtual void   CloseWindow();
00096    void           CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch);
00097    void           CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints);
00098    TH1           *GetHisto() const { return fHist; }
00099    const char    *GetText() const { return fText.Data(); }
00100    void           Refresh();
00101    void           SetHisto(TH1 *hist);
00102    void           SetText(const char *text);
00103    void           SetTextColor(const char *col);
00104    void           SetTextAttributes(Int_t tx, Int_t ty, Int_t th, const char *col=0);
00105    void           Show(Int_t x, Int_t y, const char *text = 0, TH1 *hist = 0);
00106 
00107    ClassDef(TGShapedToolTip, 0) // Shaped composite frame
00108 };
00109 
00110 ////////////////////////////////////////////////////////////////////////////////
00111 class HtmlObjTable : public TObject {
00112 public:                     // make them public for shorter code
00113 
00114    TString   fName;
00115    Int_t     fNValues;      // number of values
00116    Int_t     fNFields;      // number of fields
00117    TArrayF  *fValues;
00118    TString  *fLabels;
00119    Bool_t    fExpand;
00120 
00121    TString   fHtml;         // HTML output code
00122 
00123    void Build();
00124    void BuildTitle();
00125    void BuildLabels();
00126    void BuildTable();
00127 
00128 public:
00129    HtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
00130    virtual ~HtmlObjTable();
00131 
00132    void     SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
00133    void     SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
00134    TString  Html() const { return fHtml; }
00135 
00136    ClassDef(HtmlObjTable, 0);
00137 };
00138 
00139 ////////////////////////////////////////////////////////////////////////////////
00140 class HtmlSummary {
00141 public:                           // make them public for shorter code
00142    Int_t           fNTables;
00143    TOrdCollection *fObjTables;    // ->array of object tables
00144    TString         fHtml;         // output HTML string
00145    TString         fTitle;        // page title
00146    TString         fHeader;       // HTML header
00147    TString         fFooter;       // HTML footer
00148 
00149    void     MakeHeader();
00150    void     MakeFooter();
00151 
00152 public:
00153    HtmlSummary(const char *title);
00154    virtual ~HtmlSummary();
00155 
00156    HtmlObjTable  *AddTable(const char *name, Int_t nfields, Int_t nvals, 
00157                            Bool_t exp=kTRUE, Option_t *opt="");
00158    HtmlObjTable  *GetTable(Int_t at) const { return (HtmlObjTable *)fObjTables->At(at); }
00159    void           Build();
00160    void           Clear(Option_t *option="");
00161    void           Reset(Option_t *option="");
00162    TString        Html() const { return fHtml; }
00163 
00164    ClassDef(HtmlSummary, 0);
00165 };
00166 
00167 ////////////////////////////////////////////////////////////////////////////////
00168 class SplitGLView : public TGMainFrame {
00169 
00170 public:
00171    enum EMyCommands {
00172       kFileOpen, kFileExit, kFileLoadConfig, kFileSaveConfig,
00173       kHelpAbout, kGLPerspYOZ, kGLPerspXOZ, kGLPerspXOY, kGLXOY,
00174       kGLXOZ, kGLZOY, kGLOrthoRotate, kGLOrthoDolly, kSceneUpdate, 
00175       kSceneUpdateAll, kSummaryUpdate
00176    };
00177 
00178 private:
00179    TEvePad               *fPad;           // pad used as geometry container
00180    TGSplitFrame          *fSplitFrame;    // main (first) split frame
00181    TGLEmbeddedViewer     *fViewer0;       // main GL viewer
00182    TGLEmbeddedViewer     *fViewer1;       // first GL viewer
00183    TGLEmbeddedViewer     *fViewer2;       // second GL viewer
00184    TGLEmbeddedViewer     *fActViewer;     // actual (active) GL viewer
00185    static HtmlSummary    *fgHtmlSummary;  // summary HTML table
00186    static TGHtml         *fgHtml;
00187    TGMenuBar             *fMenuBar;       // main menu bar
00188    TGPopupMenu           *fMenuFile;      // 'File' popup menu
00189    TGPopupMenu           *fMenuHelp;      // 'Help' popup menu
00190    TGPopupMenu           *fMenuCamera;    // 'Camera' popup menu
00191    TGPopupMenu           *fMenuScene;     // 'Scene' popup menu
00192    TGStatusBar           *fStatusBar;     // status bar
00193    TGShapedToolTip       *fShapedToolTip; // shaped tooltip
00194    Bool_t                 fIsEmbedded;
00195 
00196    TEveViewer            *fViewer[3];
00197    TEveProjectionManager *fRPhiMgr;
00198    TEveProjectionManager *fRhoZMgr;
00199 
00200 public:
00201    SplitGLView(const TGWindow *p=0, UInt_t w=800, UInt_t h=600, Bool_t embed=kFALSE);
00202    virtual ~SplitGLView();
00203 
00204    void           ItemClicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
00205    void           HandleMenu(Int_t id);
00206    void           OnClicked(TObject *obj);
00207    void           OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy);
00208    void           OnMouseOver(TGLPhysicalShape *shape);
00209    void           OnViewerActivated();
00210    void           OpenFile(const char *fname);
00211    void           SwapToMainView(TGLViewerBase *viewer);
00212    void           ToggleOrthoRotate();
00213    void           ToggleOrthoDolly();
00214    void           UnDock(TGLViewerBase *viewer);
00215    void           LoadConfig(const char *fname);
00216    void           SaveConfig(const char *fname);
00217    static void    UpdateSummary();
00218 
00219    TEveProjectionManager *GetRPhiMgr() const { return fRPhiMgr; }
00220    TEveProjectionManager *GetRhoZMgr() const { return fRhoZMgr; }
00221 
00222    ClassDef(SplitGLView, 0)
00223 };
00224 
00225 TEveProjectionManager *gRPhiMgr = 0;
00226 TEveProjectionManager *gRhoZMgr = 0;
00227 
00228 ClassImp(TGShapedToolTip)
00229 ClassImp(HtmlObjTable)
00230 ClassImp(HtmlSummary)
00231 ClassImp(SplitGLView)
00232 
00233 HtmlSummary *SplitGLView::fgHtmlSummary = 0;
00234 TGHtml *SplitGLView::fgHtml = 0;
00235 
00236 //______________________________________________________________________________
00237 TGShapedToolTip::TGShapedToolTip(const char *pname, Int_t cx, Int_t cy, Int_t cw, 
00238                              Int_t ch, Int_t tx, Int_t ty, Int_t th, 
00239                              const char *col) : 
00240    TGShapedFrame(pname, gClient->GetDefaultRoot(), 400, 300, kTempFrame | 
00241                  kHorizontalFrame), fEc(0), fHist(0)
00242 {
00243    // Shaped window constructor
00244 
00245    fTextX = tx; fTextY = ty; fTextH = th;
00246    if (col)
00247       fTextCol = col;
00248    else
00249       fTextCol = "0x000000";
00250 
00251    // create the embedded canvas
00252    if ((cx > 0) && (cy > 0) && (cw > 0) && (ch > 0)) {
00253       Int_t lhRight  = fWidth-cx-cw;
00254       Int_t lhBottom = fHeight-cy-ch;
00255       fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
00256       AddFrame(fEc, new TGLayoutHints(kLHintsTop | kLHintsLeft, cx, 
00257                                       lhRight, cy, lhBottom));
00258    }
00259    MapSubwindows();
00260    Resize();
00261    Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
00262 }
00263 
00264 //______________________________________________________________________________
00265 TGShapedToolTip::~TGShapedToolTip() 
00266 {
00267    // Destructor.
00268 
00269    if (fHist)
00270       delete fHist;
00271    if (fEc)
00272       delete fEc;
00273 }
00274 
00275 //______________________________________________________________________________
00276 void TGShapedToolTip::CloseWindow() 
00277 {
00278    // Close shaped window.
00279    
00280    DeleteWindow();
00281 }
00282 
00283 //______________________________________________________________________________
00284 void TGShapedToolTip::Refresh()
00285 {
00286    // Redraw the window with current attributes.
00287 
00288    const char *str = fText.Data();
00289    char *string = strdup(str);
00290    Int_t nlines = 0, size = fTextH;
00291    TString fp = gEnv->GetValue("Root.TTFontPath", "");
00292    TString ar = fp + "/arial.ttf";
00293    char *s = strtok((char *)string, "\n");
00294    TImage *img = (TImage*)fImage->Clone("img");
00295    img->DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
00296    while ((s = strtok(0, "\n"))) {
00297       nlines++;
00298       img->DrawText(fTextX, fTextY+(nlines*size), s, size, fTextCol, ar);
00299    }
00300    img->PaintImage(fId, 0, 0, 0, 0, 0, 0, "opaque");
00301    free(string);
00302    delete img;
00303    gVirtualX->Update();
00304 }
00305 
00306 //______________________________________________________________________________
00307 void TGShapedToolTip::CreateCanvas(Int_t cx, Int_t cy, Int_t cw, Int_t ch)
00308 {
00309 
00310    // create the embedded canvas
00311    Int_t lhRight  = fWidth-cx-cw;
00312    Int_t lhBottom = fHeight-cy-ch;
00313    fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
00314    AddFrame(fEc, new TGLayoutHints(kLHintsTop | kLHintsLeft, cx, 
00315                                    lhRight, cy, lhBottom));
00316    MapSubwindows();
00317    Resize();
00318    Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
00319    if (IsMapped()) {
00320       Refresh();
00321    }
00322 }
00323 
00324 //______________________________________________________________________________
00325 void TGShapedToolTip::CreateCanvas(Int_t cw, Int_t ch, TGLayoutHints *hints)
00326 {
00327    // Create the embedded canvas.
00328 
00329    fEc = new TRootEmbeddedCanvas("ec", this, cw, ch, 0);
00330    AddFrame(fEc, hints);
00331    MapSubwindows();
00332    Resize();
00333    Resize(fBgnd->GetWidth(), fBgnd->GetHeight());
00334    if (IsMapped()) {
00335       Refresh();
00336    }
00337 }
00338 
00339 //______________________________________________________________________________
00340 void TGShapedToolTip::SetHisto(TH1 *hist)
00341 {
00342    // Set which histogram has to be displayed in the embedded canvas.
00343 
00344    if (hist) {
00345       if (fHist) {
00346          delete fHist;
00347          if (fEc)
00348             fEc->GetCanvas()->Clear();
00349       }
00350       fHist = (TH1 *)hist->Clone();
00351       if (fEc) {
00352          fEc->GetCanvas()->SetBorderMode(0);
00353          fEc->GetCanvas()->SetFillColor(10);
00354          fEc->GetCanvas()->cd();
00355          fHist->Draw();
00356          fEc->GetCanvas()->Update();
00357       }
00358    }
00359 }
00360 
00361 //______________________________________________________________________________
00362 void TGShapedToolTip::SetText(const char *text)
00363 {
00364    // Set which text has to be displayed.
00365 
00366    if (text) {
00367       fText = text;
00368    }
00369    if (IsMapped())
00370       Refresh();
00371 }
00372 
00373 //______________________________________________________________________________
00374 void TGShapedToolTip::SetTextColor(const char *col)
00375 {
00376    // Set text color.
00377 
00378    fTextCol = col;
00379    if (IsMapped())
00380       Refresh();
00381 }
00382 
00383 //______________________________________________________________________________
00384 void TGShapedToolTip::SetTextAttributes(Int_t tx, Int_t ty, Int_t th, 
00385                                         const char *col)
00386 {
00387    // Set text attributes (position, size and color).
00388 
00389    fTextX = tx; fTextY = ty; fTextH = th;
00390    if (col)
00391       fTextCol = col;
00392    if (IsMapped())
00393       Refresh();
00394 }
00395 
00396 //______________________________________________________________________________
00397 void TGShapedToolTip::Show(Int_t x, Int_t y, const char *text, TH1 *hist)
00398 {
00399    // Show (popup) the shaped window at location x,y and possibly
00400    // set the text and histogram to be displayed.
00401 
00402    Move(x, y);
00403    MapWindow();
00404 
00405    if (text)
00406       SetText(text);
00407    if (hist)
00408       SetHisto(hist);
00409    // end of demo code -------------------------------------------
00410    if (fHist) {
00411       fEc->GetCanvas()->SetBorderMode(0);
00412       fEc->GetCanvas()->SetFillColor(10);
00413       fEc->GetCanvas()->cd();
00414       fHist->Draw();
00415       fEc->GetCanvas()->Update();
00416    }
00417    Refresh();
00418 }
00419 
00420 //______________________________________________________________________________
00421 HtmlObjTable::HtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) : 
00422    fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
00423 {
00424    // Constructor.
00425 
00426    fValues = new TArrayF[fNFields];
00427    for (int i=0;i<fNFields;i++)
00428       fValues[i].Set(nvals);
00429    fLabels = new TString[fNFields];
00430 }
00431 
00432 //______________________________________________________________________________
00433 HtmlObjTable::~HtmlObjTable()
00434 {
00435    // Destructor.
00436 
00437    delete [] fValues;
00438    delete [] fLabels;
00439 }
00440 
00441 //______________________________________________________________________________
00442 void HtmlObjTable::Build()
00443 {
00444    // Build HTML code.
00445 
00446    fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
00447 
00448    BuildTitle();
00449    if (fExpand && (fNFields > 0) && (fNValues > 0)) {
00450       BuildLabels();
00451       BuildTable();
00452    }
00453 
00454    fHtml += "</table>";
00455 }
00456 
00457 //______________________________________________________________________________
00458 void HtmlObjTable::BuildTitle()
00459 {
00460    // Build table title.
00461    
00462    fHtml += "<tr><td colspan=";
00463    fHtml += Form("%d>", fNFields+1);
00464    fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
00465    fHtml += "<tr><td align=left>";
00466    fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
00467    fHtml += fName;
00468    fHtml += "</i></b></font></td>";
00469    fHtml += "<td>";
00470    fHtml += "<td align=right> ";
00471    fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
00472    fHtml += Form("Size = %d", fNValues);
00473    fHtml += "</i></b></font></td></tr>";
00474    fHtml += "</table>";
00475    fHtml += "</td></tr>";
00476 }
00477 
00478 //______________________________________________________________________________
00479 void HtmlObjTable::BuildLabels()
00480 {
00481    // Build table labels.
00482 
00483    Int_t i;
00484    fHtml += "<tr bgcolor=c0c0ff>";
00485    fHtml += "<th> </th>"; // for the check boxes
00486    for (i=0;i<fNFields;i++) {
00487       fHtml += "<th> ";
00488       fHtml += fLabels[i];
00489       fHtml += " </th>"; // for the check boxes
00490    }
00491    fHtml += "</tr>";
00492 }
00493 
00494 //______________________________________________________________________________
00495 void HtmlObjTable::BuildTable()
00496 {
00497    // Build part of table with values.
00498 
00499    for (int i = 0; i < fNValues; i++) {
00500       if (i%2)
00501          fHtml += "<tr bgcolor=e0e0ff>";
00502       else
00503          fHtml += "<tr bgcolor=ffffff>";
00504       
00505       TString name = fName;
00506       name.ReplaceAll(" ", "_");
00507       // checkboxes
00508       fHtml += "<td bgcolor=d0d0ff align=\"center\">";
00509       fHtml += "<input type=\"checkbox\" name=\"";
00510       fHtml += name;
00511       fHtml += Form("[%d]\">",i);
00512       fHtml += "</td>";
00513 
00514       for (int j = 0; j < fNFields; j++) {
00515          fHtml += "<td width=";
00516          fHtml += Form("%d%%", 100/fNFields);
00517          fHtml += " align=\"center\"";
00518          fHtml += ">";
00519          fHtml += Form("%1.4f", fValues[j][i]);
00520          fHtml += "</td>";
00521       }
00522       fHtml += "</tr> ";
00523    }
00524 }
00525 
00526 //______________________________________________________________________________
00527 HtmlSummary::HtmlSummary(const char *title) : fNTables(0), fTitle(title)
00528 {
00529    // Constructor.
00530 
00531    fObjTables = new TOrdCollection();
00532 }
00533 
00534 //______________________________________________________________________________
00535 HtmlSummary::~HtmlSummary()
00536 {
00537    // Destructor.
00538 
00539    Reset();
00540 }
00541 
00542 //______________________________________________________________________________
00543 HtmlObjTable *HtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
00544                                     Bool_t exp, Option_t *option)
00545 {
00546    // Add a new table in our list of tables.
00547 
00548    TString opt = option;
00549    opt.ToLower();
00550    HtmlObjTable *table = new HtmlObjTable(name, nfields, nvals, exp);
00551    fNTables++;
00552    if (opt.Contains("first"))
00553       fObjTables->AddFirst(table);
00554    else
00555       fObjTables->Add(table);
00556    return table;
00557 }
00558 
00559 //______________________________________________________________________________
00560 void HtmlSummary::Clear(Option_t *option)
00561 {
00562    // Clear the table list.
00563 
00564    if (option && option[0] == 'D')
00565       fObjTables->Delete(option);
00566    else
00567       fObjTables->Clear(option);
00568    fNTables = 0;
00569 }
00570 
00571 //______________________________________________________________________________
00572 void HtmlSummary::Reset(Option_t *)
00573 {
00574    // Reset (delete) the table list;
00575 
00576    delete fObjTables; fObjTables = 0;
00577    fNTables = 0;
00578 }
00579 
00580 //______________________________________________________________________________
00581 void HtmlSummary::Build()
00582 {
00583    // Build the summary.
00584 
00585    MakeHeader();
00586    for (int i=0;i<fNTables;i++) {
00587       GetTable(i)->Build();
00588       fHtml += GetTable(i)->Html();
00589    }
00590    MakeFooter();
00591 }
00592 
00593 //______________________________________________________________________________
00594 void HtmlSummary::MakeHeader()
00595 {
00596    // Make HTML header.
00597 
00598    fHeader  = "<html><head><title>";
00599    fHeader += fTitle;
00600    fHeader += "</title></head><body>";
00601    fHeader += "<center><h2><font color=#2222ee><i>";
00602    fHeader += fTitle;
00603    fHeader += "</i></font></h2></center>";
00604    fHtml    = fHeader;
00605 }
00606 
00607 //______________________________________________________________________________
00608 void HtmlSummary::MakeFooter()
00609 {
00610    // Make HTML footer.
00611 
00612    fFooter  = "<br><p><br><center><strong><font size=2 color=#2222ee>";
00613    fFooter += "Example of using Html widget to display tabular data";
00614    fFooter += "<br>";
00615    fFooter += "(c) 2007-2010 Bertrand Bellenot";
00616    fFooter += "</font></strong></center></body></html>";  
00617    fHtml   += fFooter;
00618 }
00619 
00620 //______________________________________________________________________________
00621 SplitGLView::SplitGLView(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
00622    TGMainFrame(p, w, h), fActViewer(0), fShapedToolTip(0), fIsEmbedded(embed)
00623 {
00624    // Main frame constructor.
00625 
00626    TGSplitFrame *frm;
00627    TEveScene *s = 0;
00628    TGHorizontalFrame *hfrm;
00629    TGDockableFrame *dfrm;
00630    TGPictureButton *button;
00631 
00632    // create the "file" popup menu
00633    fMenuFile = new TGPopupMenu(gClient->GetRoot());
00634    fMenuFile->AddEntry("&Open...", kFileOpen);
00635    fMenuFile->AddSeparator();
00636    fMenuFile->AddEntry( "&Update Summary", kSummaryUpdate);
00637    fMenuFile->AddSeparator();
00638    fMenuFile->AddEntry("&Load Config...", kFileLoadConfig);
00639    fMenuFile->AddEntry("&Save Config...", kFileSaveConfig);
00640    fMenuFile->AddSeparator();
00641    fMenuFile->AddEntry("E&xit", kFileExit);
00642 
00643    // create the "camera" popup menu
00644    fMenuCamera = new TGPopupMenu(gClient->GetRoot());
00645    fMenuCamera->AddEntry("Perspective (Floor XOZ)", kGLPerspXOZ);
00646    fMenuCamera->AddEntry("Perspective (Floor YOZ)", kGLPerspYOZ);
00647    fMenuCamera->AddEntry("Perspective (Floor XOY)", kGLPerspXOY);
00648    fMenuCamera->AddEntry("Orthographic (XOY)", kGLXOY);
00649    fMenuCamera->AddEntry("Orthographic (XOZ)", kGLXOZ);
00650    fMenuCamera->AddEntry("Orthographic (ZOY)", kGLZOY);
00651    fMenuCamera->AddSeparator();
00652    fMenuCamera->AddEntry("Ortho allow rotate", kGLOrthoRotate);
00653    fMenuCamera->AddEntry("Ortho allow dolly",  kGLOrthoDolly);
00654 
00655    fMenuScene = new TGPopupMenu(gClient->GetRoot());
00656    fMenuScene->AddEntry("&Update Current", kSceneUpdate);
00657    fMenuScene->AddEntry("Update &All", kSceneUpdateAll);
00658 
00659    // create the "help" popup menu
00660    fMenuHelp = new TGPopupMenu(gClient->GetRoot());
00661    fMenuHelp->AddEntry("&About", kHelpAbout);
00662 
00663    // create the main menu bar
00664    fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
00665    fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | 
00666                       kLHintsLeft, 0, 4, 0, 0));
00667    fMenuBar->AddPopup("&Camera", fMenuCamera, new TGLayoutHints(kLHintsTop | 
00668                       kLHintsLeft, 0, 4, 0, 0));
00669    fMenuBar->AddPopup("&Scene", fMenuScene, new TGLayoutHints(kLHintsTop | 
00670                       kLHintsLeft, 0, 4, 0, 0));
00671    fMenuBar->AddPopup("&Help", fMenuHelp, new TGLayoutHints(kLHintsTop | 
00672                       kLHintsRight));
00673 
00674    AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
00675 
00676    // connect menu signals to our menu handler slot
00677    fMenuFile->Connect("Activated(Int_t)", "SplitGLView", this,
00678                       "HandleMenu(Int_t)");
00679    fMenuCamera->Connect("Activated(Int_t)", "SplitGLView", this,
00680                         "HandleMenu(Int_t)");
00681    fMenuScene->Connect("Activated(Int_t)", "SplitGLView", this,
00682                        "HandleMenu(Int_t)");
00683    fMenuHelp->Connect("Activated(Int_t)", "SplitGLView", this,
00684                       "HandleMenu(Int_t)");
00685    
00686    if (fIsEmbedded && gEve) {
00687       // use status bar from the browser
00688       fStatusBar = gEve->GetBrowser()->GetStatusBar();
00689    }
00690    else {
00691       // create the status bar
00692       Int_t parts[] = {45, 15, 10, 30};
00693       fStatusBar = new TGStatusBar(this, 50, 10);
00694       fStatusBar->SetParts(parts, 4);
00695       AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 
00696                0, 0, 10, 0));
00697    }
00698 
00699    // create eve pad (our geometry container)
00700    fPad = new TEvePad();
00701    fPad->SetFillColor(kBlack);
00702 
00703    // create the split frames
00704    fSplitFrame = new TGSplitFrame(this, 800, 600);
00705    AddFrame(fSplitFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00706    // split it once
00707    fSplitFrame->HSplit(434);
00708    // then split each part again (this will make four parts)
00709    fSplitFrame->GetSecond()->VSplit(266);
00710    fSplitFrame->GetSecond()->GetSecond()->VSplit(266);
00711 
00712    TGLOverlayButton *but1, *but2, *but3, *but4, *but5, *but6;
00713    // get top (main) split frame
00714    frm = fSplitFrame->GetFirst();
00715    frm->SetName("Main_View");
00716 
00717    // create (embed) a GL viewer inside
00718    fViewer0 = new TGLEmbeddedViewer(frm, fPad);
00719    but1 = new TGLOverlayButton(fViewer0, "Swap", 10.0, -10.0, 55.0, 16.0);
00720    but1->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
00721    but2 = new TGLOverlayButton(fViewer0, "Undock", 70.0, -10.0, 55.0, 16.0);
00722    but2->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
00723    frm->AddFrame(fViewer0->GetFrame(), new TGLayoutHints(kLHintsExpandX | 
00724                  kLHintsExpandY));
00725    // set the camera to perspective (XOZ) for this viewer
00726    fViewer0->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
00727    // connect signal we are interested to
00728    fViewer0->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this, 
00729                       "OnMouseOver(TGLPhysicalShape*)");
00730    fViewer0->Connect("Activated()", "SplitGLView", this, 
00731                       "OnViewerActivated()");
00732    fViewer0->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", 
00733                       "SplitGLView", this, 
00734                       "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
00735    fViewer0->Connect("Clicked(TObject*)", "SplitGLView", this, 
00736                       "OnClicked(TObject*)");
00737    fViewer[0] = new TEveViewer("SplitGLViewer[0]");
00738    fViewer[0]->SetGLViewer(fViewer0, fViewer0->GetFrame());
00739    fViewer[0]->IncDenyDestroy();
00740    if (fIsEmbedded && gEve) {
00741       fViewer[0]->AddScene(gEve->GetGlobalScene());
00742       fViewer[0]->AddScene(gEve->GetEventScene());
00743       gEve->GetViewers()->AddElement(fViewer[0]);
00744       s = gEve->SpawnNewScene("Rho-Z Projection");
00745       // projections
00746       fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
00747       s->AddElement(fRhoZMgr);
00748       gEve->AddToListTree(fRhoZMgr, kTRUE);
00749       TEveProjectionAxes* a = new TEveProjectionAxes(fRhoZMgr);
00750       s->AddElement(a);
00751    }
00752 
00753    // get bottom left split frame
00754    frm = fSplitFrame->GetSecond()->GetFirst();
00755    frm->SetName("Bottom_Left");
00756 
00757    // create (embed) a GL viewer inside
00758    fViewer1 = new TGLEmbeddedViewer(frm, fPad);
00759    but3 = new TGLOverlayButton(fViewer1, "Swap", 10.0, -10.0, 55.0, 16.0);
00760    but3->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
00761    but4 = new TGLOverlayButton(fViewer1, "Undock", 70.0, -10.0, 55.0, 16.0);
00762    but4->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
00763    frm->AddFrame(fViewer1->GetFrame(), new TGLayoutHints(kLHintsExpandX | 
00764                   kLHintsExpandY));
00765 
00766    // set the camera to orthographic (XOY) for this viewer
00767    fViewer1->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00768    // connect signal we are interested to
00769    fViewer1->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this, 
00770                       "OnMouseOver(TGLPhysicalShape*)");
00771    fViewer1->Connect("Activated()", "SplitGLView", this, 
00772                       "OnViewerActivated()");
00773    fViewer1->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", 
00774                       "SplitGLView", this, 
00775                       "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
00776    fViewer1->Connect("Clicked(TObject*)", "SplitGLView", this, 
00777                       "OnClicked(TObject*)");
00778    fViewer[1] = new TEveViewer("SplitGLViewer[1]");
00779    fViewer[1]->SetGLViewer(fViewer1, fViewer1->GetFrame());
00780    fViewer[1]->IncDenyDestroy();
00781    if (fIsEmbedded && gEve) {
00782       fRhoZMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
00783       fRhoZMgr->ImportElements((TEveElement *)gEve->GetEventScene());
00784       fViewer[1]->AddScene(s);
00785       gEve->GetViewers()->AddElement(fViewer[1]);
00786       gRhoZMgr = fRhoZMgr;
00787 
00788       s = gEve->SpawnNewScene("R-Phi Projection");
00789       // projections
00790       fRPhiMgr = new TEveProjectionManager(TEveProjection::kPT_RPhi);
00791       s->AddElement(fRPhiMgr);
00792       gEve->AddToListTree(fRPhiMgr, kTRUE);
00793       TEveProjectionAxes* a = new TEveProjectionAxes(fRPhiMgr);
00794       s->AddElement(a);
00795    }
00796 
00797    // get bottom center split frame
00798    frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
00799    frm->SetName("Bottom_Center");
00800 
00801    // create (embed) a GL viewer inside
00802    fViewer2 = new TGLEmbeddedViewer(frm, fPad);
00803    but5 = new TGLOverlayButton(fViewer2, "Swap", 10.0, -10.0, 55.0, 16.0);
00804    but5->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "SwapToMainView(TGLViewerBase*)");
00805    but6 = new TGLOverlayButton(fViewer2, "Undock", 70.0, -10.0, 55.0, 16.0);
00806    but6->Connect("Clicked(TGLViewerBase*)", "SplitGLView", this, "UnDock(TGLViewerBase*)");
00807    frm->AddFrame(fViewer2->GetFrame(), new TGLayoutHints(kLHintsExpandX | 
00808                   kLHintsExpandY));
00809 
00810    // set the camera to orthographic (XOY) for this viewer
00811    fViewer2->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00812    // connect signal we are interested to
00813    fViewer2->Connect("MouseOver(TGLPhysicalShape*)", "SplitGLView", this, 
00814                       "OnMouseOver(TGLPhysicalShape*)");
00815    fViewer2->Connect("Activated()", "SplitGLView", this, 
00816                       "OnViewerActivated()");
00817    fViewer2->Connect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", 
00818                       "SplitGLView", this, 
00819                       "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
00820    fViewer2->Connect("Clicked(TObject*)", "SplitGLView", this, 
00821                       "OnClicked(TObject*)");
00822    fViewer[2] = new TEveViewer("SplitGLViewer[2]");
00823    fViewer[2]->SetGLViewer(fViewer2, fViewer2->GetFrame());
00824    fViewer[2]->IncDenyDestroy();
00825    if (fIsEmbedded && gEve) {
00826       fRPhiMgr->ImportElements((TEveElement *)gEve->GetGlobalScene());
00827       fRPhiMgr->ImportElements((TEveElement *)gEve->GetEventScene());
00828       fViewer[2]->AddScene(s);
00829       gEve->GetViewers()->AddElement(fViewer[2]);
00830       gRPhiMgr = fRPhiMgr;
00831    }
00832 
00833    // get bottom right split frame
00834    frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
00835    frm->SetName("Bottom_Right");
00836 
00837    dfrm = new TGDockableFrame(frm);
00838    dfrm->SetFixedSize(kFALSE);
00839    dfrm->EnableHide(kFALSE);
00840    hfrm = new TGHorizontalFrame(dfrm);
00841    button= new TGPictureButton(hfrm, gClient->GetPicture("swap.png"));
00842    button->SetToolTipText("Swap to big view");
00843    hfrm->AddFrame(button);
00844    button->Connect("Clicked()","SplitGLView",this,"SwapToMainView(TGLViewerBase*=0)");
00845    fgHtmlSummary = new HtmlSummary("Alice Event Display Summary Table");
00846    fgHtml = new TGHtml(hfrm, 100, 100, -1);
00847    hfrm->AddFrame(fgHtml, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00848    dfrm->AddFrame(hfrm, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00849    frm->AddFrame(dfrm, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00850 
00851    if (fIsEmbedded && gEve) {
00852       gEve->GetListTree()->Connect("Clicked(TGListTreeItem*, Int_t, Int_t, Int_t)",
00853          "SplitGLView", this, "ItemClicked(TGListTreeItem*, Int_t, Int_t, Int_t)");
00854    }
00855 
00856    fShapedToolTip = new TGShapedToolTip("Default.png", 120, 22, 160, 110, 
00857                                         23, 115, 12, "#ffff80");
00858    Resize(GetDefaultSize());
00859    MapSubwindows();
00860    MapWindow();
00861    LoadConfig(".everc");
00862 }
00863 
00864 //______________________________________________________________________________
00865 SplitGLView::~SplitGLView()
00866 {
00867    // Clean up main frame...
00868    //Cleanup();
00869    
00870    fMenuFile->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
00871    fMenuCamera->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
00872    fMenuScene->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
00873    fMenuHelp->Disconnect("Activated(Int_t)", this, "HandleMenu(Int_t)");
00874    fViewer0->Disconnect("MouseOver(TGLPhysicalShape*)", this, 
00875                          "OnMouseOver(TGLPhysicalShape*)");
00876    fViewer0->Disconnect("Activated()", this, "OnViewerActivated()");
00877    fViewer0->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", 
00878                          this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
00879    fViewer1->Disconnect("MouseOver(TGLPhysicalShape*)", this, 
00880                          "OnMouseOver(TGLPhysicalShape*)");
00881    fViewer1->Disconnect("Activated()", this, "OnViewerActivated()");
00882    fViewer1->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", 
00883                          this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
00884    fViewer2->Disconnect("MouseOver(TGLPhysicalShape*)", this, 
00885                          "OnMouseOver(TGLPhysicalShape*)");
00886    fViewer2->Disconnect("Activated()", this, "OnViewerActivated()");
00887    fViewer2->Disconnect("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", 
00888                          this, "OnMouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)");
00889    if (!fIsEmbedded) {
00890       delete fViewer[0];
00891       delete fViewer[1];
00892       delete fViewer[2];
00893    }
00894    delete fShapedToolTip;
00895    delete fMenuFile;
00896    delete fMenuScene;
00897    delete fMenuCamera;
00898    delete fMenuHelp;
00899    if (!fIsEmbedded)
00900       delete fMenuBar;
00901    delete fViewer0;
00902    delete fViewer1;
00903    delete fViewer2;
00904    delete fSplitFrame;
00905    delete fPad;
00906    if (!fIsEmbedded) {
00907       delete fStatusBar;
00908       gApplication->Terminate(0);
00909    }
00910 }
00911 
00912 //______________________________________________________________________________
00913 void SplitGLView::HandleMenu(Int_t id)
00914 {
00915    // Handle menu items.
00916 
00917    static TString rcdir(".");
00918    static TString rcfile(".everc");
00919 
00920    switch (id) {
00921 
00922       case kFileOpen:
00923          {
00924             static TString dir(".");
00925             TGFileInfo fi;
00926             fi.fFileTypes = filetypes;
00927             fi.fIniDir    = StrDup(dir);
00928             new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
00929             if (fi.fFilename)
00930                OpenFile(fi.fFilename);
00931             dir = fi.fIniDir;
00932          }
00933          break;
00934 
00935       case kFileLoadConfig:
00936          {
00937             TGFileInfo fi;
00938             fi.fFileTypes = rcfiletypes;
00939             fi.fIniDir    = StrDup(rcdir);
00940             fi.fFilename  = StrDup(rcfile);
00941             new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
00942             if (fi.fFilename) {
00943                rcfile = fi.fFilename;
00944                LoadConfig(fi.fFilename);
00945             }
00946             rcdir = fi.fIniDir;
00947          }
00948          break;
00949 
00950       case kFileSaveConfig:
00951          {
00952             TGFileInfo fi;
00953             fi.fFileTypes = rcfiletypes;
00954             fi.fIniDir    = StrDup(rcdir);
00955             fi.fFilename  = StrDup(rcfile);
00956             new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
00957             if (fi.fFilename) {
00958                rcfile = fi.fFilename;
00959                SaveConfig(fi.fFilename);
00960             }
00961             rcdir = fi.fIniDir;
00962          }
00963          break;
00964 
00965       case kFileExit:
00966          CloseWindow();
00967          break;
00968 
00969       case kGLPerspYOZ:
00970          if (fActViewer)
00971             fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspYOZ);
00972          break;
00973       case kGLPerspXOZ:
00974          if (fActViewer)
00975             fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOZ);
00976          break;
00977       case kGLPerspXOY:
00978          if (fActViewer)
00979             fActViewer->SetCurrentCamera(TGLViewer::kCameraPerspXOY);
00980          break;
00981       case kGLXOY:
00982          if (fActViewer)
00983             fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00984          break;
00985       case kGLXOZ:
00986          if (fActViewer)
00987             fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoXOZ);
00988          break;
00989       case kGLZOY:
00990          if (fActViewer)
00991             fActViewer->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
00992          break;
00993       case kGLOrthoRotate:
00994          ToggleOrthoRotate();
00995          break;
00996       case kGLOrthoDolly:
00997          ToggleOrthoDolly();
00998          break;
00999 
01000       case kSceneUpdate:
01001          if (fActViewer)
01002             fActViewer->UpdateScene();
01003          UpdateSummary();
01004          break;
01005 
01006       case kSceneUpdateAll:
01007          fViewer0->UpdateScene();
01008          fViewer1->UpdateScene();
01009          fViewer2->UpdateScene();
01010          UpdateSummary();
01011          break;
01012 
01013       case kSummaryUpdate:
01014          UpdateSummary();
01015          break;
01016 
01017       case kHelpAbout:
01018          {
01019 #ifdef R__UNIX
01020             TString rootx;
01021 # ifdef ROOTBINDIR
01022             rootx = ROOTBINDIR;
01023 # else
01024             rootx = gSystem->Getenv("ROOTSYS");
01025             if (!rootx.IsNull()) rootx += "/bin";
01026 # endif
01027             rootx += "/root -a &";
01028             gSystem->Exec(rootx);
01029 #else
01030 #ifdef WIN32
01031             new TWin32SplashThread(kTRUE);
01032 #else
01033             char str[32];
01034             sprintf(str, "About ROOT %s...", gROOT->GetVersion());
01035             hd = new TRootHelpDialog(this, str, 600, 400);
01036             hd->SetText(gHelpAbout);
01037             hd->Popup();
01038 #endif
01039 #endif
01040          }
01041          break;
01042 
01043       default:
01044          break;
01045    }
01046 }
01047 
01048 //______________________________________________________________________________
01049 void SplitGLView::OnClicked(TObject *obj)
01050 {
01051    // Handle click events in GL viewer
01052 
01053    if (obj)
01054       fStatusBar->SetText(Form("User clicked on: \"%s\"", obj->GetName()), 1);
01055    else
01056       fStatusBar->SetText("", 1);
01057 }
01058 
01059 //______________________________________________________________________________
01060 void SplitGLView::OnMouseIdle(TGLPhysicalShape *shape, UInt_t posx, UInt_t posy)
01061 {
01062    // Slot used to handle "OnMouseIdle" signal coming from any GL viewer.
01063    // We receive a pointer on the physical shape in which the mouse cursor is
01064    // and the actual cursor position (x,y)
01065 
01066    Window_t wtarget;
01067    Int_t    x = 0, y = 0;
01068 
01069    static TH1F *h1f = 0;
01070    TFormula *form1 = new TFormula("form1","abs(sin(x)/x)");
01071    form1->Update(); // silent warning about unused variable...
01072    TF1 *sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
01073    sqroot->SetParameters(10,4,1,20);
01074    if (h1f == 0)
01075       h1f = new TH1F("h1f","",50,0,10);
01076    h1f->Reset();
01077    h1f->SetFillColor(45);
01078    h1f->SetStats(0);
01079    h1f->FillRandom("sqroot",200);
01080 
01081    if (fShapedToolTip) {
01082       fShapedToolTip->UnmapWindow();
01083    }
01084    if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal()) {
01085       // get the actual viewer who actually emitted the signal
01086       TGLEmbeddedViewer *actViewer = dynamic_cast<TGLEmbeddedViewer*>((TQObject*)gTQSender);
01087       // then translate coordinates from the root (screen) coordinates 
01088       // to the actual frame (viewer) ones
01089       gVirtualX->TranslateCoordinates(actViewer->GetFrame()->GetId(),
01090                gClient->GetDefaultRoot()->GetId(), posx, posy, x, y,
01091                wtarget);
01092       // Then display our tooltip at this x,y location
01093       if (fShapedToolTip) {
01094          fShapedToolTip->Show(x+5, y+5, Form("%s\n     \n%s",
01095                               shape->GetLogical()->GetExternal()->IsA()->GetName(), 
01096                               shape->GetLogical()->GetExternal()->GetName()), h1f);
01097       }
01098    }
01099 }
01100 
01101 //______________________________________________________________________________
01102 void SplitGLView::OnMouseOver(TGLPhysicalShape *shape)
01103 {
01104    // Slot used to handle "OnMouseOver" signal coming from any GL viewer.
01105    // We receive a pointer on the physical shape in which the mouse cursor is.
01106 
01107    // display informations on the physical shape in the status bar
01108    if (shape && shape->GetLogical() && shape->GetLogical()->GetExternal())
01109       fStatusBar->SetText(Form("Mouse Over: \"%s\"", 
01110          shape->GetLogical()->GetExternal()->GetName()), 0);
01111    else
01112       fStatusBar->SetText("", 0);
01113 }
01114 
01115 //______________________________________________________________________________
01116 void SplitGLView::OnViewerActivated()
01117 {
01118    // Slot used to handle "Activated" signal coming from any GL viewer.
01119    // Used to know which GL viewer is active.
01120 
01121    static Pixel_t green = 0;
01122    // set the actual GL viewer frame to default color
01123    if (fActViewer && fActViewer->GetFrame())
01124       fActViewer->GetFrame()->ChangeBackground(GetDefaultFrameBackground());
01125 
01126    // change the actual GL viewer to the one who emitted the signal
01127    // fActViewer = (TGLEmbeddedViewer *)gTQSender;
01128    fActViewer = dynamic_cast<TGLEmbeddedViewer*>((TQObject*)gTQSender);
01129 
01130    if (fActViewer == 0) {
01131       printf ("dyncast failed ...\n");
01132       return;
01133    }
01134 
01135    // get the highlight color (only once)
01136    if (green == 0) {
01137       gClient->GetColorByName("green", green);
01138    }
01139    // set the new actual GL viewer frame to highlight color
01140    if (fActViewer->GetFrame())
01141       fActViewer->GetFrame()->ChangeBackground(green);
01142 
01143    // update menu entries to match actual viewer's options
01144    if (fActViewer->GetOrthoXOYCamera()->GetDollyToZoom() &&
01145        fActViewer->GetOrthoXOZCamera()->GetDollyToZoom() &&
01146        fActViewer->GetOrthoZOYCamera()->GetDollyToZoom())
01147       fMenuCamera->UnCheckEntry(kGLOrthoDolly);
01148    else
01149       fMenuCamera->CheckEntry(kGLOrthoDolly);
01150 
01151    if (fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
01152        fActViewer->GetOrthoXOYCamera()->GetEnableRotate() &&
01153        fActViewer->GetOrthoXOYCamera()->GetEnableRotate())
01154       fMenuCamera->CheckEntry(kGLOrthoRotate);
01155    else
01156       fMenuCamera->UnCheckEntry(kGLOrthoRotate);
01157 }
01158 
01159 //______________________________________________________________________________
01160 void SplitGLView::OpenFile(const char *fname)
01161 {
01162    // Open a Root file to display a geometry in the GL viewers.
01163 
01164    TString filename = fname;
01165    // check if the file type is correct
01166    if (!filename.EndsWith(".root")) {
01167       new TGMsgBox(gClient->GetRoot(), this, "OpenFile",
01168                    Form("The file \"%s\" is not a root file!", fname),
01169                    kMBIconExclamation, kMBOk);
01170       return;
01171    }
01172    // check if the root file contains a geometry
01173    if (TGeoManager::Import(fname) == 0) {
01174       new TGMsgBox(gClient->GetRoot(), this, "OpenFile",
01175                    Form("The file \"%s\" does't contain a geometry", fname),
01176                    kMBIconExclamation, kMBOk);
01177       return;
01178    }
01179    gGeoManager->DefaultColors();
01180    // delete previous primitives (if any)
01181    fPad->GetListOfPrimitives()->Delete();
01182    // and add the geometry to eve pad (container)
01183    fPad->GetListOfPrimitives()->Add(gGeoManager->GetTopVolume());
01184    // paint the geometry in each GL viewer
01185    fViewer0->PadPaint(fPad);
01186    fViewer1->PadPaint(fPad);
01187    fViewer2->PadPaint(fPad);
01188 }
01189 
01190 //______________________________________________________________________________
01191 void SplitGLView::ToggleOrthoRotate()
01192 {
01193    // Toggle state of the 'Ortho allow rotate' menu entry.
01194 
01195    if (fMenuCamera->IsEntryChecked(kGLOrthoRotate))
01196       fMenuCamera->UnCheckEntry(kGLOrthoRotate);
01197    else
01198       fMenuCamera->CheckEntry(kGLOrthoRotate);
01199    Bool_t state = fMenuCamera->IsEntryChecked(kGLOrthoRotate);
01200    if (fActViewer) {
01201       fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
01202       fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
01203       fActViewer->GetOrthoXOYCamera()->SetEnableRotate(state);
01204    }
01205 }
01206 
01207 //______________________________________________________________________________
01208 void SplitGLView::ToggleOrthoDolly()
01209 {
01210    // Toggle state of the 'Ortho allow dolly' menu entry.
01211 
01212    if (fMenuCamera->IsEntryChecked(kGLOrthoDolly))
01213       fMenuCamera->UnCheckEntry(kGLOrthoDolly);
01214    else
01215       fMenuCamera->CheckEntry(kGLOrthoDolly);
01216    Bool_t state = ! fMenuCamera->IsEntryChecked(kGLOrthoDolly);
01217    if (fActViewer) {
01218       fActViewer->GetOrthoXOYCamera()->SetDollyToZoom(state);
01219       fActViewer->GetOrthoXOZCamera()->SetDollyToZoom(state);
01220       fActViewer->GetOrthoZOYCamera()->SetDollyToZoom(state);
01221    }
01222 }
01223 
01224 //______________________________________________________________________________
01225 void SplitGLView::ItemClicked(TGListTreeItem *item, Int_t, Int_t, Int_t)
01226 {
01227    // Item has been clicked, based on mouse button do:
01228 
01229    static const TEveException eh("SplitGLView::ItemClicked ");
01230    TEveElement* re = (TEveElement*)item->GetUserData();
01231    if(re == 0) return;
01232    TObject* obj = re->GetObject(eh);
01233    if (obj->InheritsFrom("TEveViewer")) {
01234       TGLViewer *v = ((TEveViewer *)obj)->GetGLViewer();
01235       //v->Activated();
01236       if (v->InheritsFrom("TGLEmbeddedViewer")) {
01237          TGLEmbeddedViewer *ev = (TGLEmbeddedViewer *)v;
01238          gVirtualX->SetInputFocus(ev->GetGLWidget()->GetId());
01239       }
01240    }
01241 }
01242 
01243 //______________________________________________________________________________
01244 void SplitGLView::LoadConfig(const char *fname)
01245 {
01246 
01247    Int_t height, width;
01248    TEnv *env = new TEnv(fname);
01249 
01250    Int_t mainheight = env->GetValue("MainView.Height", 434);
01251    Int_t blwidth    = env->GetValue("Bottom.Left.Width", 266);
01252    Int_t bcwidth    = env->GetValue("Bottom.Center.Width", 266);
01253    Int_t brwidth    = env->GetValue("Bottom.Right.Width", 266);
01254    Int_t top_height = env->GetValue("Right.Tab.Height", 0);
01255    Int_t bottom_height = env->GetValue("Bottom.Tab.Height", 0);
01256 
01257    if (fIsEmbedded && gEve) {
01258       Int_t sel = env->GetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
01259       Int_t hi = env->GetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
01260       gEve->GetBrowser()->EveMenu(9+sel);
01261       gEve->GetBrowser()->EveMenu(13+hi);
01262 
01263       width  = env->GetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
01264       height = env->GetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
01265       gEve->GetBrowser()->Resize(width, height);
01266    }
01267 
01268    // top (main) split frame
01269    width = fSplitFrame->GetFirst()->GetWidth();
01270    fSplitFrame->GetFirst()->Resize(width, mainheight);
01271    // bottom left split frame
01272    height = fSplitFrame->GetSecond()->GetFirst()->GetHeight();
01273    fSplitFrame->GetSecond()->GetFirst()->Resize(blwidth, height);
01274    // bottom center split frame
01275    height = fSplitFrame->GetSecond()->GetSecond()->GetFirst()->GetHeight();
01276    fSplitFrame->GetSecond()->GetSecond()->GetFirst()->Resize(bcwidth, height);
01277    // bottom right split frame
01278    height = fSplitFrame->GetSecond()->GetSecond()->GetSecond()->GetHeight();
01279    fSplitFrame->GetSecond()->GetSecond()->GetSecond()->Resize(brwidth, height);
01280 
01281    fSplitFrame->Layout();
01282 
01283    if (fIsEmbedded && gEve) {
01284       width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetWidth();
01285       ((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->Resize(width, bottom_height);
01286       width = ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetWidth();
01287       ((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->Resize(width, top_height);
01288    }
01289 }
01290 
01291 //______________________________________________________________________________
01292 void SplitGLView::SaveConfig(const char *fname)
01293 {
01294 
01295    Int_t bottom_height = 0;
01296    Int_t top_height = 0;
01297    TGSplitFrame *frm;
01298    TEnv *env = new TEnv(fname);
01299 
01300    if (fIsEmbedded && gEve) {
01301       env->SetValue("Eve.Width", (Int_t)gEve->GetBrowser()->GetWidth());
01302       env->SetValue("Eve.Height", (Int_t)gEve->GetBrowser()->GetHeight());
01303    }
01304    // get top (main) split frame
01305    frm = fSplitFrame->GetFirst();
01306    env->SetValue("MainView.Height", (Int_t)frm->GetHeight());
01307    // get bottom left split frame
01308    frm = fSplitFrame->GetSecond()->GetFirst();
01309    env->SetValue("Bottom.Left.Width", (Int_t)frm->GetWidth());
01310    // get bottom center split frame
01311    frm = fSplitFrame->GetSecond()->GetSecond()->GetFirst();
01312    env->SetValue("Bottom.Center.Width", (Int_t)frm->GetWidth());
01313    // get bottom right split frame
01314    frm = fSplitFrame->GetSecond()->GetSecond()->GetSecond();
01315    env->SetValue("Bottom.Right.Width", (Int_t)frm->GetWidth());
01316    if (fIsEmbedded && gEve) {
01317       top_height = (Int_t)((TGCompositeFrame *)gEve->GetBrowser()->GetTabRight()->GetParent())->GetHeight();
01318       env->SetValue("Right.Tab.Height", top_height);
01319       bottom_height = (Int_t)((TGCompositeFrame *)gEve->GetBrowser()->GetTabBottom()->GetParent())->GetHeight();
01320       env->SetValue("Bottom.Tab.Height", bottom_height);
01321 
01322       env->SetValue("Eve.Selection", gEve->GetSelection()->GetPickToSelect());
01323       env->SetValue("Eve.Highlight", gEve->GetHighlight()->GetPickToSelect());
01324    }
01325 
01326    env->SaveLevel(kEnvLocal);
01327 #ifdef R__WIN32
01328    if (!gSystem->AccessPathName(Form("%s.new", fname))) {
01329       gSystem->Exec(Form("del %s", fname));
01330       gSystem->Rename(Form("%s.new", fname), fname);
01331    }
01332 #endif
01333 }
01334 
01335 //______________________________________________________________________________
01336 void SplitGLView::SwapToMainView(TGLViewerBase *viewer)
01337 {
01338    // Swap frame embedded in a splitframe to the main view (slot method).
01339 
01340    TGCompositeFrame *parent = 0;
01341    if (!fSplitFrame->GetFirst()->GetFrame())
01342       return;
01343    if (viewer == 0) {
01344       TGPictureButton *src = (TGPictureButton*)gTQSender;
01345       parent = (TGCompositeFrame *)src->GetParent();
01346       while (parent && !parent->InheritsFrom("TGSplitFrame")) {
01347          parent = (TGCompositeFrame *)parent->GetParent();
01348       }
01349    }
01350    else {
01351       TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
01352       if (!src) return;
01353       TGLOverlayButton *but = (TGLOverlayButton *)((TQObject *)gTQSender);
01354       but->ResetState();
01355       parent = (TGCompositeFrame *)src->GetParent();
01356    }
01357    if (parent && parent->InheritsFrom("TGSplitFrame"))
01358       ((TGSplitFrame *)parent)->SwitchToMain();
01359 }
01360 
01361 //______________________________________________________________________________
01362 void SplitGLView::UnDock(TGLViewerBase *viewer)
01363 {
01364    // Undock frame embedded in a splitframe (slot method).
01365 
01366    TGCompositeFrame *src = ((TGLEmbeddedViewer *)viewer)->GetFrame();
01367    if (!src) return;
01368    TGLOverlayButton *but = (TGLOverlayButton *)((TQObject *)gTQSender);
01369    but->ResetState();
01370    TGCompositeFrame *parent = (TGCompositeFrame *)src->GetParent();
01371    if (parent && parent->InheritsFrom("TGSplitFrame"))
01372       ((TGSplitFrame *)parent)->ExtractFrame();
01373 }
01374 
01375 //______________________________________________________________________________
01376 void SplitGLView::UpdateSummary()
01377 {
01378    // Update summary of current event.
01379 
01380    TEveElement::List_i i;
01381    TEveElement::List_i j;
01382    Int_t k;
01383    TEveElement *el;
01384    HtmlObjTable *table;
01385    TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
01386    if (mgr) {
01387       fgHtmlSummary->Clear("D");
01388       for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) {
01389          el = ((TEveElement*)(*i));
01390          if (el->IsA() == TEvePointSet::Class()) {
01391             TEvePointSet *ps = (TEvePointSet *)el;
01392             TString ename  = ps->GetElementName();
01393             TString etitle = ps->GetElementTitle();
01394             if (ename.First('\'') != kNPOS)
01395                ename.Remove(ename.First('\''));
01396             etitle.Remove(0, 2);
01397             Int_t nel = atoi(etitle.Data());
01398             table = fgHtmlSummary->AddTable(ename, 0, nel);
01399          }
01400          else if (el->IsA() == TEveTrackList::Class()) {
01401             TEveTrackList *tracks = (TEveTrackList *)el;
01402             TString ename  = tracks->GetElementName();
01403             if (ename.First('\'') != kNPOS)
01404                ename.Remove(ename.First('\''));
01405             table = fgHtmlSummary->AddTable(ename.Data(), 5, 
01406                      tracks->NumChildren(), kTRUE, "first");
01407             table->SetLabel(0, "Momentum");
01408             table->SetLabel(1, "P_t");
01409             table->SetLabel(2, "Phi");
01410             table->SetLabel(3, "Theta");
01411             table->SetLabel(4, "Eta");
01412             k=0;
01413             for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) {
01414                Float_t p     = ((TEveTrack*)(*j))->GetMomentum().Mag();
01415                table->SetValue(0, k, p);
01416                Float_t pt    = ((TEveTrack*)(*j))->GetMomentum().Perp();
01417                table->SetValue(1, k, pt);
01418                Float_t phi   = ((TEveTrack*)(*j))->GetMomentum().Phi();
01419                table->SetValue(2, k, phi);
01420                Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta();
01421                table->SetValue(3, k, theta);
01422                Float_t eta   = ((TEveTrack*)(*j))->GetMomentum().Eta();
01423                table->SetValue(4, k, eta);
01424                ++k;
01425             }
01426          }
01427       }
01428       fgHtmlSummary->Build();
01429       fgHtml->Clear();
01430       fgHtml->ParseText((char*)fgHtmlSummary->Html().Data());
01431       fgHtml->Layout();
01432    }
01433 }
01434 
01435 // Linkdef
01436 #ifdef __CINT__
01437 
01438 #pragma link C++ class SplitGLView;
01439 
01440 #endif
01441 
01442 #ifdef __CINT__
01443 void SplitGLView()
01444 {
01445    printf("This script is used via ACLiC by the macro \"alice_esd_split.C\"\n");
01446    printf("To see it in action, just run \".x alice_esd_split.C\"\n");
01447    return;
01448 }
01449 #endif
01450 
01451 

Generated on Tue Jul 5 15:44:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1