TEveBrowser.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveBrowser.cxx 36955 2010-11-25 21:23:09Z matevz $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveBrowser.h"
00013 
00014 #include "TEveUtil.h"
00015 #include "TEveElement.h"
00016 #include "TEveManager.h"
00017 #include "TEveSelection.h"
00018 #include "TEveGedEditor.h"
00019 #include "TEveWindow.h"
00020 #include "TEveWindowManager.h"
00021 
00022 #include "TGFileBrowser.h"
00023 #include "TBrowser.h"
00024 
00025 #include <Riostream.h>
00026 
00027 #include "TClass.h"
00028 #include "TROOT.h"
00029 #include "TStyle.h"
00030 #include "TSystem.h"
00031 #include "TRint.h"
00032 #include "TVirtualX.h"
00033 #include "TEnv.h"
00034 
00035 #include "TApplication.h"
00036 #include "TFile.h"
00037 #include "TClassMenuItem.h"
00038 
00039 #include "TColor.h"
00040 
00041 #include "TGCanvas.h"
00042 #include "TGSplitter.h"
00043 #include "TGStatusBar.h"
00044 #include "TGMenu.h"
00045 #include "TGPicture.h"
00046 #include "TGToolBar.h"
00047 #include "TGLabel.h"
00048 #include "TGXYLayout.h"
00049 #include "TGNumberEntry.h"
00050 #include <KeySymbols.h>
00051 
00052 #include "TGLSAViewer.h"
00053 #include "TGLSAFrame.h"
00054 #include "TGTab.h"
00055 
00056 #include "TGeoVolume.h"
00057 #include "TGeoNode.h"
00058 
00059 
00060 //==============================================================================
00061 //==============================================================================
00062 // TEveListTreeItem
00063 //==============================================================================
00064 
00065 //______________________________________________________________________________
00066 //
00067 // Special list-tree-item for Eve.
00068 //
00069 // Most state is picked directly from TEveElement, no need to store it
00070 // locally nor to manage its consistency.
00071 //
00072 // Handles also selected/highlighted colors and, in the future,
00073 // drag-n-drop.
00074 
00075 ClassImp(TEveListTreeItem);
00076 
00077 //______________________________________________________________________________
00078 void TEveListTreeItem::NotSupported(const char* func) const
00079 {
00080    // Warn about access to function members that should never be called.
00081    // TGListTree calls them in cases that are not used by Eve.
00082 
00083    Warning(Form("TEveListTreeItem::%s()", func), "not supported.");
00084 }
00085 
00086 //______________________________________________________________________________
00087 Pixel_t TEveListTreeItem::GetActiveColor() const
00088 {
00089    // Return highlight color corresponding to current state of TEveElement.
00090 
00091    switch (fElement->GetSelectedLevel())
00092    {
00093       case 1: return TColor::Number2Pixel(kBlue - 2);
00094       case 2: return TColor::Number2Pixel(kBlue - 6);
00095       case 3: return TColor::Number2Pixel(kCyan - 2);
00096       case 4: return TColor::Number2Pixel(kCyan - 6);
00097    }
00098    return TGFrame::GetDefaultSelectedBackground();
00099 }
00100 
00101 //______________________________________________________________________________
00102 void TEveListTreeItem::Toggle()
00103 {
00104    // Item's check-box state has been toggled ... forward to element's
00105    // render-state.
00106 
00107    fElement->SetRnrState(!IsChecked());
00108    fElement->ElementChanged(kTRUE, kTRUE);
00109 }
00110 
00111 
00112 //==============================================================================
00113 //==============================================================================
00114 // TEveGListTreeEditorFrame
00115 //==============================================================================
00116 
00117 //______________________________________________________________________________
00118 //
00119 // Composite GUI frame for parallel display of a TGListTree and TEveGedEditor.
00120 //
00121 
00122 ClassImp(TEveGListTreeEditorFrame);
00123 
00124 TString TEveGListTreeEditorFrame::fgEditorClass("TEveGedEditor");
00125 
00126 //______________________________________________________________________________
00127 TEveGListTreeEditorFrame::TEveGListTreeEditorFrame(const TGWindow* p, Int_t width, Int_t height) :
00128    TGMainFrame (p ? p : gClient->GetRoot(), width, height),
00129    fFrame      (0),
00130    fLTFrame    (0),
00131    fListTree   (0),
00132    fSplitter   (0),
00133    fEditor     (0),
00134    fCtxMenu    (0),
00135    fSignalsConnected (kFALSE)
00136 {
00137    // Constructor.
00138 
00139    SetCleanup(kNoCleanup);
00140 
00141    fFrame = new TGCompositeFrame(this, width, height, kVerticalFrame);
00142 
00143    // List-tree
00144    fLTFrame  = new TGCompositeFrame(fFrame, width, 3*height/7, kVerticalFrame);
00145    fLTCanvas = new TGCanvas(fLTFrame, 10, 10, kSunkenFrame | kDoubleBorder);
00146    fListTree = new TGListTree(fLTCanvas->GetViewPort(), 10, 10, kHorizontalFrame);
00147    fListTree->SetCanvas(fLTCanvas);
00148    fListTree->Associate(fFrame);
00149    fListTree->SetColorMode(TGListTree::EColorMarkupMode(TGListTree::kColorUnderline | TGListTree::kColorBox));
00150    fListTree->SetAutoCheckBoxPic(kFALSE);
00151    fListTree->SetUserControl(kTRUE);
00152    fLTCanvas->SetContainer(fListTree);
00153    fLTFrame->AddFrame(fLTCanvas, new TGLayoutHints
00154                       (kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
00155    fFrame  ->AddFrame(fLTFrame, new TGLayoutHints
00156                       (kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
00157 
00158    // Splitter
00159    fSplitter = new TGHSplitter(fFrame);
00160    fFrame->AddFrame(fSplitter, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1,1,2,2));
00161 
00162    // Editor
00163    fFrame->SetEditDisabled(kEditEnable);
00164    fFrame->SetEditable();
00165    fEditor = (TEveGedEditor*) gROOT->GetClass(fgEditorClass)->New();
00166    fEditor->SetGlobal(kFALSE);
00167    fEditor->ChangeOptions(fEditor->GetOptions() | kFixedHeight);
00168    fFrame->SetEditable(kEditDisable);
00169    fFrame->SetEditable(kFALSE);
00170    {
00171       TGFrameElement *el = 0;
00172       TIter next(fFrame->GetList());
00173       while ((el = (TGFrameElement *) next())) {
00174          if (el->fFrame == fEditor)
00175             if (el->fLayout) {
00176                el->fLayout->SetLayoutHints(kLHintsTop | kLHintsExpandX);
00177                el->fLayout->SetPadLeft(0); el->fLayout->SetPadRight(1);
00178                el->fLayout->SetPadTop(2);  el->fLayout->SetPadBottom(1);
00179                break;
00180             }
00181       }
00182    }
00183    fSplitter->SetFrame(fEditor, kFALSE);
00184 
00185    AddFrame(fFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
00186 
00187    fCtxMenu = new TContextMenu("", "");
00188 
00189    Layout();
00190    MapSubwindows();
00191    MapWindow();
00192 }
00193 
00194 //______________________________________________________________________________
00195 TEveGListTreeEditorFrame::~TEveGListTreeEditorFrame()
00196 {
00197    // Destructor.
00198 
00199    DisconnectSignals();
00200 
00201    delete fCtxMenu;
00202 
00203    // Should un-register editor, all items and list-tree from gEve ... eventually.
00204 
00205    delete fEditor;
00206    delete fSplitter;
00207    delete fListTree;
00208    delete fLTCanvas;
00209    delete fLTFrame;
00210    delete fFrame;
00211 }
00212 
00213 //______________________________________________________________________________
00214 void TEveGListTreeEditorFrame::SetEditorClass(const char* edclass)
00215 {
00216    // Set GED editor class.
00217 
00218    fgEditorClass = edclass;
00219 }
00220 
00221 //______________________________________________________________________________
00222 void TEveGListTreeEditorFrame::ConnectSignals()
00223 {
00224    // Connect list-tree signals.
00225 
00226    fListTree->Connect("MouseOver(TGListTreeItem*, UInt_t)", "TEveGListTreeEditorFrame",
00227                       this, "ItemBelowMouse(TGListTreeItem*, UInt_t)");
00228    fListTree->Connect("Clicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)", "TEveGListTreeEditorFrame",
00229                       this, "ItemClicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)");
00230    fListTree->Connect("DoubleClicked(TGListTreeItem*, Int_t)", "TEveGListTreeEditorFrame",
00231                       this, "ItemDblClicked(TGListTreeItem*, Int_t)");
00232    fListTree->Connect("KeyPressed(TGListTreeItem*, ULong_t, ULong_t)", "TEveGListTreeEditorFrame",
00233                       this, "ItemKeyPress(TGListTreeItem*, UInt_t, UInt_t)");
00234 
00235    fSignalsConnected = kTRUE;
00236 }
00237 
00238 //______________________________________________________________________________
00239 void TEveGListTreeEditorFrame::DisconnectSignals()
00240 {
00241    // Disconnect list-tree signals.
00242 
00243    if (!fSignalsConnected) return;
00244 
00245    fListTree->Disconnect("MouseOver(TGListTreeItem*, UInt_t)",
00246                       this, "ItemBelowMouse(TGListTreeItem*, UInt_t)");
00247    fListTree->Disconnect("Clicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)",
00248                       this, "ItemClicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)");
00249    fListTree->Disconnect("DoubleClicked(TGListTreeItem*, Int_t)",
00250                       this, "ItemDblClicked(TGListTreeItem*, Int_t)");
00251    fListTree->Disconnect("KeyPressed(TGListTreeItem*, ULong_t, ULong_t)",
00252                       this, "ItemKeyPress(TGListTreeItem*, UInt_t, UInt_t)");
00253 
00254    fSignalsConnected = kFALSE;
00255 }
00256 
00257 /******************************************************************************/
00258 
00259 //______________________________________________________________________________
00260 void TEveGListTreeEditorFrame::ReconfToHorizontal()
00261 {
00262    // Reconfigure to horizontal layout, list-tree and editor side by side.
00263 
00264    UnmapWindow();
00265 
00266    fFrame->ChangeOptions(kHorizontalFrame);
00267    fLTFrame->ChangeOptions(kHorizontalFrame);
00268    fListTree->ChangeOptions(kVerticalFrame);
00269 
00270    TGFrameElement *el = 0;
00271    TIter next(fFrame->GetList());
00272    while ((el = (TGFrameElement *) next()))
00273    {
00274       if (el->fFrame == fSplitter)
00275       {
00276          // This is needed so that splitter window gets destroyed on server.
00277          fSplitter->ReparentWindow(fClient->GetDefaultRoot());
00278          delete fSplitter;
00279          el->fFrame = fSplitter = new TGVSplitter(fFrame);
00280          el->fLayout->SetLayoutHints(kLHintsLeft | kLHintsExpandY);
00281          el->fLayout->SetPadLeft(2); el->fLayout->SetPadRight (2);
00282          el->fLayout->SetPadTop (1); el->fLayout->SetPadBottom(1);
00283       }
00284       else if (el->fFrame == fEditor)
00285       {
00286          fEditor->ChangeOptions(fEditor->GetOptions() & (~kFixedHeight));
00287          fEditor->ChangeOptions(fEditor->GetOptions() |   kFixedWidth);
00288          el->fLayout->SetLayoutHints(kLHintsLeft | kLHintsExpandY);
00289       }
00290    }
00291 
00292    fEditor->Resize(fEditor->GetWidth() / 2 - 1, fEditor->GetHeight());
00293    fSplitter->SetFrame(fEditor, kFALSE);
00294 
00295    Layout();
00296    MapSubwindows();
00297    MapWindow();
00298 }
00299 
00300 //______________________________________________________________________________
00301 void TEveGListTreeEditorFrame::ReconfToVertical()
00302 {
00303    // Reconfigure to vertical layout, list-tree above the editor.
00304 
00305    UnmapWindow();
00306 
00307    fFrame->ChangeOptions(kVerticalFrame);
00308    fLTFrame->ChangeOptions(kVerticalFrame);
00309    fListTree->ChangeOptions(kHorizontalFrame);
00310 
00311    TGFrameElement *el = 0;
00312    TIter next(fFrame->GetList());
00313    while ((el = (TGFrameElement *) next()))
00314    {
00315       if (el->fFrame == fSplitter)
00316       {
00317          // This is needed so that splitter window gets destroyed on server.
00318          fSplitter->ReparentWindow(fClient->GetDefaultRoot());
00319          delete fSplitter;
00320          el->fFrame = fSplitter = new TGHSplitter(fFrame);
00321          el->fLayout->SetLayoutHints(kLHintsTop | kLHintsExpandX);
00322          el->fLayout->SetPadLeft(2); el->fLayout->SetPadRight (2);
00323          el->fLayout->SetPadTop (1); el->fLayout->SetPadBottom(1);
00324       }
00325       else if (el->fFrame == fEditor)
00326       {
00327          fEditor->ChangeOptions(fEditor->GetOptions() & (~kFixedWidth));
00328          fEditor->ChangeOptions(fEditor->GetOptions() |   kFixedHeight);
00329          el->fLayout->SetLayoutHints(kLHintsTop | kLHintsExpandX);
00330       }
00331    }
00332 
00333    fEditor->Resize(fEditor->GetWidth(), fEditor->GetHeight() / 2 - 1);
00334    fSplitter->SetFrame(fEditor, kFALSE);
00335 
00336    Layout();
00337    MapSubwindows();
00338    MapWindow();
00339 }
00340 
00341 //==============================================================================
00342 
00343 //______________________________________________________________________________
00344 void TEveGListTreeEditorFrame::ItemBelowMouse(TGListTreeItem *entry, UInt_t /*mask*/)
00345 {
00346    // Different item is below mouse.
00347 
00348    TEveElement* el = entry ? (TEveElement*) entry->GetUserData() : 0;
00349    gEve->GetHighlight()->UserPickedElement(el, kFALSE);
00350 }
00351 
00352 //______________________________________________________________________________
00353 void TEveGListTreeEditorFrame::ItemClicked(TGListTreeItem *item, Int_t btn, UInt_t mask, Int_t x, Int_t y)
00354 {
00355    // Item has been clicked, based on mouse button do:
00356    // M1 - select, show in editor;
00357    // M2 - paste (call gEve->ElementPaste();
00358    // M3 - popup context menu.
00359 
00360    //printf("ItemClicked item %s List %d btn=%d, x=%d, y=%d\n",
00361    //  item->GetText(),fDisplayFrame->GetList()->GetEntries(), btn, x, y);
00362 
00363    static const TEveException eh("TEveGListTreeEditorFrame::ItemClicked ");
00364 
00365    TEveElement* el = (TEveElement*) item->GetUserData();
00366    if (el == 0) return;
00367    TObject* obj = el->GetObject(eh);
00368 
00369    switch (btn)
00370    {
00371       case 1:
00372          gEve->GetSelection()->UserPickedElement(el, mask & kKeyControlMask);
00373          break;
00374 
00375       case 2:
00376          if (gEve->ElementPaste(el))
00377             gEve->Redraw3D();
00378          break;
00379 
00380       case 3:
00381          // If control pressed, show menu for render-element itself.
00382          // event->fState & kKeyControlMask
00383          // ??? how do i get current event?
00384          // !!!!! Have this now ... fix.
00385          if (obj) fCtxMenu->Popup(x, y, obj);
00386          break;
00387 
00388       default:
00389          break;
00390    }
00391 }
00392 
00393 //______________________________________________________________________________
00394 void TEveGListTreeEditorFrame::ItemDblClicked(TGListTreeItem* item, Int_t btn)
00395 {
00396    // Item has been double-clicked, potentially expand the children.
00397 
00398    static const TEveException eh("TEveGListTreeEditorFrame::ItemDblClicked ");
00399 
00400    if (btn != 1) return;
00401 
00402    TEveElement* el = (TEveElement*) item->GetUserData();
00403    if (el == 0) return;
00404 
00405    el->ExpandIntoListTree(fListTree, item);
00406 
00407    TObject* obj = el->GetObject(eh);
00408    if (obj)
00409    {
00410       // Browse geonodes.
00411       if (obj->IsA()->InheritsFrom(TGeoNode::Class()))
00412       {
00413          TGeoNode* n = dynamic_cast<TGeoNode*>(obj);
00414          if (item->GetFirstChild() == 0 && n->GetNdaughters())
00415          {
00416             fListTree->DeleteChildren(item);
00417             for (Int_t i=0; i< n->GetNdaughters(); i++)
00418             {
00419                TString title;
00420                title.Form("%d : %s[%d]", i,
00421                           n->GetDaughter(i)->GetVolume()->GetName(),
00422                           n->GetDaughter(i)->GetNdaughters());
00423 
00424                TGListTreeItem* child = fListTree->AddItem(item, title.Data());
00425                child->SetUserData(n->GetDaughter(i));
00426             }
00427          }
00428       }
00429    }
00430 }
00431 
00432 //______________________________________________________________________________
00433 void TEveGListTreeEditorFrame::ItemKeyPress(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)
00434 {
00435    // A key has been pressed for an item.
00436    //
00437    // Only <Delete>, <Enter> and <Return> keys are handled here,
00438    // otherwise the control is passed back to TGListTree.
00439 
00440    static const TEveException eh("TEveGListTreeEditorFrame::ItemKeyPress ");
00441 
00442    entry = fListTree->GetCurrent();
00443    if (entry == 0) return;
00444 
00445    TEveElement* el = (TEveElement*) entry->GetUserData();
00446 
00447    fListTree->SetEventHandled(); // Reset back to false in default case.
00448 
00449    switch (keysym)
00450    {
00451       case kKey_Delete:
00452       {
00453          if (entry->GetParent())
00454          {
00455             if (el->GetDenyDestroy() > 0 && el->GetNItems() == 1)
00456                throw(eh + "DestroyDenied set for this item.");
00457 
00458             TEveElement* parent = (TEveElement*) entry->GetParent()->GetUserData();
00459 
00460             if (parent)
00461             {
00462                gEve->RemoveElement(el, parent);
00463                gEve->Redraw3D();
00464             }
00465          }
00466          else
00467          {
00468             if (el->GetDenyDestroy() > 0)
00469                throw(eh + "DestroyDenied set for this top-level item.");
00470             gEve->RemoveFromListTree(el, fListTree, entry);
00471             gEve->Redraw3D();
00472          }
00473          break;
00474       }
00475 
00476       case kKey_Enter:
00477       case kKey_Return:
00478       {
00479          gEve->GetSelection()->UserPickedElement(el, mask & kKeyControlMask);
00480          break;
00481       }
00482 
00483       default:
00484       {
00485          fListTree->SetEventHandled(kFALSE);
00486          break;
00487       }
00488    }
00489 }
00490 
00491 
00492 //==============================================================================
00493 //==============================================================================
00494 // TEveBrowser
00495 //==============================================================================
00496 
00497 //______________________________________________________________________________
00498 //
00499 // Specialization of TRootBrowser for Eve.
00500 
00501 ClassImp(TEveBrowser);
00502 
00503 //______________________________________________________________________________
00504 void TEveBrowser::SetupCintExport(TClass* cl)
00505 {
00506    // Add "Export to CINT" into context-menu for class cl.
00507 
00508    TList* l = cl->GetMenuList();
00509    TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction, cl,
00510                                           "Export to CINT", "ExportToCINT", this, "const char*,TObject*", 1);
00511 
00512    l->AddFirst(n);
00513 }
00514 
00515 //______________________________________________________________________________
00516 void TEveBrowser::CalculateReparentXY(TGObject* parent, Int_t& x, Int_t& y)
00517 {
00518    // Calculate position of a widget for reparenting into parent.
00519 
00520    UInt_t   w, h;
00521    Window_t childdum;
00522    gVirtualX->GetWindowSize(parent->GetId(), x, y, w, h);
00523    gVirtualX->TranslateCoordinates(parent->GetId(),
00524                                    gClient->GetDefaultRoot()->GetId(),
00525                                    0, 0, x, y, childdum);
00526 }
00527 
00528 /******************************************************************************/
00529 
00530 namespace
00531 {
00532 enum EEveMenu_e {
00533    kNewMainFrameSlot, kNewTabSlot,
00534    kNewViewer,  kNewScene,  kNewProjector,
00535    kNewBrowser, kNewCanvas, kNewCanvasExt, kNewTextEditor, kNewHtmlBrowser,
00536    kSel_PS_Ignore, kSel_PS_Element, kSel_PS_Projectable, kSel_PS_Compound,
00537    kSel_PS_PableCompound, kSel_PS_Master, kSel_PS_END,
00538    kHil_PS_Ignore, kHil_PS_Element, kHil_PS_Projectable, kHil_PS_Compound,
00539    kHil_PS_PableCompound, kHil_PS_Master, kHil_PS_END,
00540    kVerticalBrowser,
00541    kWinDecorNormal, kWinDecorHide, kWinDecorTitleBar, kWinDecorMiniBar
00542 };
00543 
00544 }
00545 
00546 //______________________________________________________________________________
00547 TEveBrowser::TEveBrowser(UInt_t w, UInt_t h) :
00548    TRootBrowser(0, "Eve Main Window", w, h, "", kFALSE),
00549    fFileBrowser(0),
00550    fEvePopup   (0),
00551    fSelPopup   (0),
00552    fHilPopup   (0)
00553 {
00554    // Constructor.
00555 
00556    // Construct Eve menu.
00557 
00558    fEvePopup = new TGPopupMenu(gClient->GetRoot());
00559    fEvePopup->AddEntry("New &MainFrame Slot", kNewMainFrameSlot);
00560    fEvePopup->AddEntry("New &Tab Slot",       kNewTabSlot);
00561    fEvePopup->AddSeparator();
00562    fEvePopup->AddEntry("New &Viewer",         kNewViewer);
00563    fEvePopup->AddEntry("New &Scene",          kNewScene);
00564    fEvePopup->AddEntry("New &Projector",      kNewProjector);
00565    fEvePopup->AddSeparator();
00566    fEvePopup->AddEntry("New &Browser",        kNewBrowser);
00567    fEvePopup->AddEntry("New &Canvas",         kNewCanvas);
00568    fEvePopup->AddEntry("New Canvas Ext",      kNewCanvasExt);
00569    fEvePopup->AddEntry("New Text &Editor",    kNewTextEditor);
00570    // fEvePopup->AddEntry("New HTML Browser", kNewHtmlBrowser);
00571    fEvePopup->AddSeparator();
00572 
00573    {
00574       fSelPopup = new TGPopupMenu(gClient->GetRoot());
00575       fSelPopup->AddEntry("Ignore",      kSel_PS_Ignore);
00576       fSelPopup->AddEntry("Element",     kSel_PS_Element);
00577       fSelPopup->AddEntry("Projectable", kSel_PS_Projectable);
00578       fSelPopup->AddEntry("Compound",    kSel_PS_Compound);
00579       fSelPopup->AddEntry("Projectable and Compound",
00580                           kSel_PS_PableCompound);
00581       fSelPopup->AddEntry("Master",      kSel_PS_Master);
00582       fSelPopup->RCheckEntry(kSel_PS_Ignore + gEve->GetSelection()->GetPickToSelect(),
00583                              kSel_PS_Ignore, kSel_PS_END - 1);
00584       fEvePopup->AddPopup("Selection", fSelPopup);
00585    }
00586    {
00587       fHilPopup = new TGPopupMenu(gClient->GetRoot());
00588       fHilPopup->AddEntry("Ignore",      kHil_PS_Ignore);
00589       fHilPopup->AddEntry("Element",     kHil_PS_Element);
00590       fHilPopup->AddEntry("Projectable", kHil_PS_Projectable);
00591       fHilPopup->AddEntry("Compound",    kHil_PS_Compound);
00592       fHilPopup->AddEntry("Projectable and Compound",
00593                           kHil_PS_PableCompound);
00594       fHilPopup->AddEntry("Master",      kHil_PS_Master);
00595       fHilPopup->RCheckEntry(kHil_PS_Ignore + gEve->GetHighlight()->GetPickToSelect(),
00596                              kHil_PS_Ignore, kHil_PS_END - 1);
00597       fEvePopup->AddPopup("Highlight", fHilPopup);
00598    }
00599 
00600    fEvePopup->AddSeparator();
00601    fEvePopup->AddEntry("Vertical browser", kVerticalBrowser);
00602    fEvePopup->CheckEntry(kVerticalBrowser);
00603    {
00604       TGPopupMenu *wd = new TGPopupMenu(gClient->GetRoot());
00605       wd->AddEntry("Normal",     kWinDecorNormal);
00606       wd->AddEntry("Hide",       kWinDecorHide);
00607       wd->AddEntry("Title bars", kWinDecorTitleBar);
00608       wd->AddEntry("Mini bars",  kWinDecorMiniBar);
00609       fEvePopup->AddPopup("Window decorations", wd);
00610    }
00611 
00612    fEvePopup->Connect("Activated(Int_t)", "TEveBrowser",
00613                        this, "EveMenu(Int_t)");
00614 
00615    fMenuBar->AddPopup("&Eve", fEvePopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
00616 
00617    fPreMenuFrame->ChangeOptions(fPreMenuFrame->GetOptions() | kRaisedFrame);
00618    fTopMenuFrame->Layout();
00619    fTopMenuFrame->MapSubwindows();
00620 }
00621 
00622 /******************************************************************************/
00623 
00624 //______________________________________________________________________________
00625 void TEveBrowser::EveMenu(Int_t id)
00626 {
00627    // Handle events from Eve menu.
00628 
00629    switch (id)
00630    {
00631       case kNewMainFrameSlot: {
00632          TEveWindowSlot* ew_slot = TEveWindow::CreateWindowMainFrame(0);
00633          gEve->GetWindowManager()->SelectWindow(ew_slot);
00634          break;
00635       }
00636       case kNewTabSlot: {
00637          TEveWindowSlot* ew_slot = TEveWindow::CreateWindowInTab(GetTabRight(), 0);
00638          gEve->GetWindowManager()->SelectWindow(ew_slot);
00639          break;
00640       }
00641       case kNewViewer: {
00642          gEve->SpawnNewViewer("Viewer Pepe");
00643          break;
00644       }
00645       case kNewScene: {
00646          gEve->SpawnNewScene("Scena Mica");
00647          break;
00648       }
00649       case kNewProjector: {
00650          TEveElement* pr = (TEveElement*) (gROOT->GetClass("TEveProjectionManager")->New());
00651          pr->SetElementNameTitle("Projector", "User-created projector.");
00652          gEve->AddToListTree(pr, kTRUE);
00653          break;
00654       }
00655       case kNewBrowser: {
00656          gROOT->ProcessLineFast("new TBrowser");
00657          break;
00658       }
00659       case kNewCanvas: {
00660          StartEmbedding(1);
00661          gROOT->ProcessLineFast("new TCanvas");
00662          StopEmbedding();
00663          SetTabTitle("Canvas", 1);
00664          break;
00665       }
00666       case kNewCanvasExt: {
00667          gROOT->ProcessLineFast("new TCanvas");
00668          break;
00669       }
00670       case kNewTextEditor: {
00671          StartEmbedding(1);
00672          gROOT->ProcessLineFast(Form("new TGTextEditor((const char *)0, (const TGWindow *)0x%lx)", (ULong_t)gClient->GetRoot()));
00673          StopEmbedding();
00674          SetTabTitle("Editor", 1);
00675          break;
00676       }
00677       case kNewHtmlBrowser: {
00678          gSystem->Load("libGuiHtml");
00679          if (gSystem->Load("libRHtml") >= 0)
00680          {
00681             StartEmbedding(1);
00682             gROOT->ProcessLine(Form("new TGHtmlBrowser(\"http://root.cern.ch/root/html/ClassIndex.html\", \
00683                               (const TGWindow *)0x%lx)", (ULong_t)gClient->GetRoot()));
00684             StopEmbedding();
00685             SetTabTitle("HTML", 1);
00686          }
00687          break;
00688       }
00689       case kSel_PS_Ignore:
00690       case kSel_PS_Element:
00691       case kSel_PS_Projectable:
00692       case kSel_PS_Compound:
00693       case kSel_PS_PableCompound:
00694       case kSel_PS_Master: {
00695          gEve->GetSelection()->SetPickToSelect(id - kSel_PS_Ignore);
00696          fSelPopup->RCheckEntry(kSel_PS_Ignore + gEve->GetSelection()->GetPickToSelect(),
00697                                 kSel_PS_Ignore, kSel_PS_END - 1);
00698          break;
00699       }
00700       case kHil_PS_Ignore:
00701       case kHil_PS_Element:
00702       case kHil_PS_Projectable:
00703       case kHil_PS_Compound:
00704       case kHil_PS_PableCompound:
00705       case kHil_PS_Master: {
00706          gEve->GetHighlight()->SetPickToSelect(id - kHil_PS_Ignore);
00707          fHilPopup->RCheckEntry(kHil_PS_Ignore + gEve->GetHighlight()->GetPickToSelect(),
00708                                 kHil_PS_Ignore, kHil_PS_END - 1);
00709          break;
00710       }
00711       case kVerticalBrowser: {
00712          if (fEvePopup->IsEntryChecked(kVerticalBrowser)) {
00713             gEve->GetLTEFrame()->ReconfToHorizontal();
00714             fEvePopup->UnCheckEntry(kVerticalBrowser);
00715          } else {
00716             gEve->GetLTEFrame()->ReconfToVertical();
00717             fEvePopup->CheckEntry(kVerticalBrowser);
00718          }
00719          break;
00720       }
00721       case kWinDecorNormal: {
00722          gEve->GetWindowManager()->ShowNormalEveDecorations();
00723          break;
00724       }
00725       case kWinDecorHide: {
00726          gEve->GetWindowManager()->HideAllEveDecorations();
00727          break;
00728       }
00729       case kWinDecorTitleBar: {
00730          gEve->GetWindowManager()->SetShowTitleBars(kTRUE);
00731          break;
00732       }
00733       case kWinDecorMiniBar: {
00734          gEve->GetWindowManager()->SetShowTitleBars(kFALSE);
00735          break;
00736       }
00737 
00738       default: {
00739          break;
00740       }
00741    }
00742 }
00743 
00744 /******************************************************************************/
00745 
00746 //______________________________________________________________________________
00747 void TEveBrowser::InitPlugins(Option_t *opt)
00748 {
00749    // Initialize standard plugins.
00750 
00751    TString o(opt);
00752 
00753    // File Browser plugin ... we have to process it here.
00754    if (o.Contains('F'))
00755    {
00756       StartEmbedding(0);
00757       TGFileBrowser *fb = MakeFileBrowser();
00758       fb->BrowseObj(gROOT);
00759       fb->Show();
00760       fFileBrowser = fb;
00761       StopEmbedding("Files");
00762       o.ReplaceAll("F", ".");
00763    }
00764 
00765    TRootBrowser::InitPlugins(o);
00766 }
00767 
00768 //______________________________________________________________________________
00769 TGFileBrowser* TEveBrowser::MakeFileBrowser()
00770 {
00771    // Create a file-browser. Caller should provide
00772    // Start/StopEmbedding() calls and populate the new browser.
00773 
00774    TBrowserImp    imp;
00775    TBrowser      *tb = new TBrowser("Pipi", "Strel", &imp);
00776    TGFileBrowser *fb = new TGFileBrowser(gClient->GetRoot(), tb, 200, 500);
00777    tb->SetBrowserImp((TBrowserImp *)this);
00778    fb->SetBrowser(tb);
00779    fb->SetNewBrowser(this);
00780    gROOT->GetListOfBrowsers()->Remove(tb);
00781    return fb;
00782 }
00783 
00784 //______________________________________________________________________________
00785 void TEveBrowser::ReallyDelete()
00786 {
00787    // Really delete the browser and the this GUI.
00788 
00789    delete this;    // will in turn delete this object
00790 }
00791 
00792 void TEveBrowser::HideBottomTab()
00793 {
00794    fV2->HideFrame(fHSplitter);
00795    fV2->HideFrame(fH2);
00796 }

Generated on Tue Jul 5 14:16:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1