69 ClassImp(TEveListTreeItem);
75 void TEveListTreeItem::NotSupported(
const char* func)
const
77 Warning(Form(
"TEveListTreeItem::%s()", func),
"not supported.");
83 Pixel_t TEveListTreeItem::GetActiveColor()
const
85 switch (fElement->GetSelectedLevel())
87 case 1:
return TColor::Number2Pixel(kBlue - 2);
88 case 2:
return TColor::Number2Pixel(kBlue - 6);
89 case 3:
return TColor::Number2Pixel(kCyan - 2);
90 case 4:
return TColor::Number2Pixel(kCyan - 6);
92 return TGFrame::GetDefaultSelectedBackground();
99 void TEveListTreeItem::Toggle()
101 fElement->SetRnrState(!IsChecked());
102 fElement->ElementChanged(kTRUE, kTRUE);
110 ClassImp(TEveGListTreeEditorFrame);
112 TString TEveGListTreeEditorFrame::fgEditorClass(
"TEveGedEditor");
117 TEveGListTreeEditorFrame::TEveGListTreeEditorFrame(
const TGWindow* p, Int_t width, Int_t height) :
118 TGMainFrame (p ? p : gClient->GetRoot(), width, height),
125 fSignalsConnected (kFALSE)
127 SetCleanup(kNoCleanup);
129 fFrame =
new TGCompositeFrame(
this, width, height, kVerticalFrame);
132 fLTFrame =
new TGCompositeFrame(fFrame, width, 3*height/7, kVerticalFrame);
133 fLTCanvas =
new TGCanvas(fLTFrame, 10, 10, kSunkenFrame | kDoubleBorder);
134 fListTree =
new TGListTree(fLTCanvas->GetViewPort(), 10, 10, kHorizontalFrame);
135 fListTree->SetCanvas(fLTCanvas);
136 fListTree->Associate(fFrame);
137 fListTree->SetColorMode(TGListTree::EColorMarkupMode(TGListTree::kColorUnderline | TGListTree::kColorBox));
138 fListTree->SetAutoCheckBoxPic(kFALSE);
139 fListTree->SetUserControl(kTRUE);
140 fLTCanvas->SetContainer(fListTree);
141 fLTFrame->AddFrame(fLTCanvas,
new TGLayoutHints
142 (kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));
143 fFrame ->AddFrame(fLTFrame,
new TGLayoutHints
144 (kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
147 fSplitter =
new TGHSplitter(fFrame);
148 fFrame->AddFrame(fSplitter,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1,1,2,2));
151 fFrame->SetEditDisabled(kEditEnable);
152 fFrame->SetEditable();
153 fEditor = (TEveGedEditor*) gROOT->GetClass(fgEditorClass)->New();
154 fEditor->SetGlobal(kFALSE);
155 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedHeight);
156 fFrame->SetEditable(kEditDisable);
157 fFrame->SetEditable(kFALSE);
159 TGFrameElement *el = 0;
160 TIter next(fFrame->GetList());
161 while ((el = (TGFrameElement *) next())) {
162 if (el->fFrame == fEditor)
164 el->fLayout->SetLayoutHints(kLHintsTop | kLHintsExpandX);
165 el->fLayout->SetPadLeft(0); el->fLayout->SetPadRight(1);
166 el->fLayout->SetPadTop(2); el->fLayout->SetPadBottom(1);
171 fSplitter->SetFrame(fEditor, kFALSE);
173 AddFrame(fFrame,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
175 fCtxMenu =
new TContextMenu(
"",
"");
185 TEveGListTreeEditorFrame::~TEveGListTreeEditorFrame()
204 void TEveGListTreeEditorFrame::SetEditorClass(
const char* edclass)
206 fgEditorClass = edclass;
212 void TEveGListTreeEditorFrame::ConnectSignals()
214 fListTree->Connect(
"MouseOver(TGListTreeItem*, UInt_t)",
"TEveGListTreeEditorFrame",
215 this,
"ItemBelowMouse(TGListTreeItem*, UInt_t)");
216 fListTree->Connect(
"Clicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)",
"TEveGListTreeEditorFrame",
217 this,
"ItemClicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)");
218 fListTree->Connect(
"DoubleClicked(TGListTreeItem*, Int_t)",
"TEveGListTreeEditorFrame",
219 this,
"ItemDblClicked(TGListTreeItem*, Int_t)");
220 fListTree->Connect(
"KeyPressed(TGListTreeItem*, ULong_t, ULong_t)",
"TEveGListTreeEditorFrame",
221 this,
"ItemKeyPress(TGListTreeItem*, UInt_t, UInt_t)");
223 fSignalsConnected = kTRUE;
229 void TEveGListTreeEditorFrame::DisconnectSignals()
231 if (!fSignalsConnected)
return;
233 fListTree->Disconnect(
"MouseOver(TGListTreeItem*, UInt_t)",
234 this,
"ItemBelowMouse(TGListTreeItem*, UInt_t)");
235 fListTree->Disconnect(
"Clicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)",
236 this,
"ItemClicked(TGListTreeItem*, Int_t, UInt_t, Int_t, Int_t)");
237 fListTree->Disconnect(
"DoubleClicked(TGListTreeItem*, Int_t)",
238 this,
"ItemDblClicked(TGListTreeItem*, Int_t)");
239 fListTree->Disconnect(
"KeyPressed(TGListTreeItem*, ULong_t, ULong_t)",
240 this,
"ItemKeyPress(TGListTreeItem*, UInt_t, UInt_t)");
242 fSignalsConnected = kFALSE;
248 void TEveGListTreeEditorFrame::ReconfToHorizontal()
252 fFrame->ChangeOptions(kHorizontalFrame);
253 fLTFrame->ChangeOptions(kHorizontalFrame);
254 fListTree->ChangeOptions(kVerticalFrame);
256 TGFrameElement *el = 0;
257 TIter next(fFrame->GetList());
258 while ((el = (TGFrameElement *) next()))
260 if (el->fFrame == fSplitter)
263 fSplitter->ReparentWindow(fClient->GetDefaultRoot());
265 el->fFrame = fSplitter =
new TGVSplitter(fFrame);
266 el->fLayout->SetLayoutHints(kLHintsLeft | kLHintsExpandY);
267 el->fLayout->SetPadLeft(2); el->fLayout->SetPadRight (2);
268 el->fLayout->SetPadTop (1); el->fLayout->SetPadBottom(1);
270 else if (el->fFrame == fEditor)
272 fEditor->ChangeOptions(fEditor->GetOptions() & (~kFixedHeight));
273 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedWidth);
274 el->fLayout->SetLayoutHints(kLHintsLeft | kLHintsExpandY);
278 fEditor->Resize(fEditor->GetWidth() / 2 - 1, fEditor->GetHeight());
279 fSplitter->SetFrame(fEditor, kFALSE);
289 void TEveGListTreeEditorFrame::ReconfToVertical()
293 fFrame->ChangeOptions(kVerticalFrame);
294 fLTFrame->ChangeOptions(kVerticalFrame);
295 fListTree->ChangeOptions(kHorizontalFrame);
297 TGFrameElement *el = 0;
298 TIter next(fFrame->GetList());
299 while ((el = (TGFrameElement *) next()))
301 if (el->fFrame == fSplitter)
304 fSplitter->ReparentWindow(fClient->GetDefaultRoot());
306 el->fFrame = fSplitter =
new TGHSplitter(fFrame);
307 el->fLayout->SetLayoutHints(kLHintsTop | kLHintsExpandX);
308 el->fLayout->SetPadLeft(2); el->fLayout->SetPadRight (2);
309 el->fLayout->SetPadTop (1); el->fLayout->SetPadBottom(1);
311 else if (el->fFrame == fEditor)
313 fEditor->ChangeOptions(fEditor->GetOptions() & (~kFixedWidth));
314 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedHeight);
315 el->fLayout->SetLayoutHints(kLHintsTop | kLHintsExpandX);
319 fEditor->Resize(fEditor->GetWidth(), fEditor->GetHeight() / 2 - 1);
320 fSplitter->SetFrame(fEditor, kFALSE);
330 void TEveGListTreeEditorFrame::ItemBelowMouse(TGListTreeItem *entry, UInt_t )
332 TEveElement* el = entry ? (TEveElement*) entry->GetUserData() : 0;
333 gEve->GetHighlight()->UserPickedElement(el, kFALSE);
342 void TEveGListTreeEditorFrame::ItemClicked(TGListTreeItem *item, Int_t btn, UInt_t mask, Int_t x, Int_t y)
347 static const TEveException eh(
"TEveGListTreeEditorFrame::ItemClicked ");
349 TEveElement* el = (TEveElement*) item->GetUserData();
351 TObject* obj = el->GetObject(eh);
356 gEve->GetSelection()->UserPickedElement(el, mask & kKeyControlMask);
360 if (gEve->ElementPaste(el))
369 if (obj) fCtxMenu->Popup(x, y, obj);
380 void TEveGListTreeEditorFrame::ItemDblClicked(TGListTreeItem* item, Int_t btn)
382 static const TEveException eh(
"TEveGListTreeEditorFrame::ItemDblClicked ");
384 if (btn != 1)
return;
386 TEveElement* el = (TEveElement*) item->GetUserData();
389 el->ExpandIntoListTree(fListTree, item);
391 TObject* obj = el->GetObject(eh);
395 if (obj->IsA()->InheritsFrom(TGeoNode::Class()))
397 TGeoNode* n =
dynamic_cast<TGeoNode*
>(obj);
398 if (item->GetFirstChild() == 0 && n->GetNdaughters())
400 fListTree->DeleteChildren(item);
401 for (Int_t i=0; i< n->GetNdaughters(); i++)
404 title.Form(
"%d : %s[%d]", i,
405 n->GetDaughter(i)->GetVolume()->GetName(),
406 n->GetDaughter(i)->GetNdaughters());
408 TGListTreeItem* child = fListTree->AddItem(item, title.Data());
409 child->SetUserData(n->GetDaughter(i));
422 void TEveGListTreeEditorFrame::ItemKeyPress(TGListTreeItem *entry, UInt_t keysym, UInt_t mask)
424 static const TEveException eh(
"TEveGListTreeEditorFrame::ItemKeyPress ");
426 entry = fListTree->GetCurrent();
427 if (entry == 0)
return;
429 TEveElement* el = (TEveElement*) entry->GetUserData();
431 fListTree->SetEventHandled();
437 if (entry->GetParent())
439 if (el->GetDenyDestroy() > 0 && el->GetNItems() == 1)
440 throw(eh +
"DestroyDenied set for this item.");
442 TEveElement* parent = (TEveElement*) entry->GetParent()->GetUserData();
446 gEve->RemoveElement(el, parent);
452 if (el->GetDenyDestroy() > 0)
453 throw(eh +
"DestroyDenied set for this top-level item.");
454 gEve->RemoveFromListTree(el, fListTree, entry);
463 gEve->GetSelection()->UserPickedElement(el, mask & kKeyControlMask);
469 fListTree->SetEventHandled(kFALSE);
481 ClassImp(TEveBrowser);
486 void TEveBrowser::SetupCintExport(TClass* cl)
488 TList* l = cl->GetMenuList();
489 TClassMenuItem* n =
new TClassMenuItem(TClassMenuItem::kPopupUserFunction, cl,
490 "Export to CINT",
"ExportToCINT",
this,
"const char*,TObject*", 1);
498 void TEveBrowser::CalculateReparentXY(TGObject* parent, Int_t& x, Int_t& y)
502 gVirtualX->GetWindowSize(parent->GetId(), x, y, w, h);
503 gVirtualX->TranslateCoordinates(parent->GetId(),
504 gClient->GetDefaultRoot()->GetId(),
505 0, 0, x, y, childdum);
511 kNewMainFrameSlot, kNewTabSlot,
512 kNewViewer, kNewScene,
513 kNewBrowser, kNewCanvas, kNewCanvasExt, kNewTextEditor, kNewHtmlBrowser,
514 kSel_PS_Ignore, kSel_PS_Element, kSel_PS_Projectable, kSel_PS_Compound,
515 kSel_PS_PableCompound, kSel_PS_Master, kSel_PS_END,
516 kHil_PS_Ignore, kHil_PS_Element, kHil_PS_Projectable, kHil_PS_Compound,
517 kHil_PS_PableCompound, kHil_PS_Master, kHil_PS_END,
519 kWinDecorNormal, kWinDecorHide, kWinDecorTitleBar, kWinDecorMiniBar
527 TEveBrowser::TEveBrowser(UInt_t w, UInt_t h) :
528 TRootBrowser(0,
"Eve Main Window", w, h,
"", kFALSE),
536 fEvePopup =
new TGPopupMenu(gClient->GetRoot());
537 fEvePopup->AddEntry(
"New &MainFrame Slot", kNewMainFrameSlot);
538 fEvePopup->AddEntry(
"New &Tab Slot", kNewTabSlot);
539 fEvePopup->AddSeparator();
540 fEvePopup->AddEntry(
"New &Viewer", kNewViewer);
541 fEvePopup->AddEntry(
"New &Scene", kNewScene);
542 fEvePopup->AddSeparator();
543 fEvePopup->AddEntry(
"New &Browser", kNewBrowser);
544 fEvePopup->AddEntry(
"New &Canvas", kNewCanvas);
545 fEvePopup->AddEntry(
"New Canvas Ext", kNewCanvasExt);
546 fEvePopup->AddEntry(
"New Text &Editor", kNewTextEditor);
548 fEvePopup->AddSeparator();
551 fSelPopup =
new TGPopupMenu(gClient->GetRoot());
552 fSelPopup->AddEntry(
"Ignore", kSel_PS_Ignore);
553 fSelPopup->AddEntry(
"Element", kSel_PS_Element);
554 fSelPopup->AddEntry(
"Projectable", kSel_PS_Projectable);
555 fSelPopup->AddEntry(
"Compound", kSel_PS_Compound);
556 fSelPopup->AddEntry(
"Projectable and Compound",
557 kSel_PS_PableCompound);
558 fSelPopup->AddEntry(
"Master", kSel_PS_Master);
559 fSelPopup->RCheckEntry(kSel_PS_Ignore + gEve->GetSelection()->GetPickToSelect(),
560 kSel_PS_Ignore, kSel_PS_END - 1);
561 fEvePopup->AddPopup(
"Selection", fSelPopup);
564 fHilPopup =
new TGPopupMenu(gClient->GetRoot());
565 fHilPopup->AddEntry(
"Ignore", kHil_PS_Ignore);
566 fHilPopup->AddEntry(
"Element", kHil_PS_Element);
567 fHilPopup->AddEntry(
"Projectable", kHil_PS_Projectable);
568 fHilPopup->AddEntry(
"Compound", kHil_PS_Compound);
569 fHilPopup->AddEntry(
"Projectable and Compound",
570 kHil_PS_PableCompound);
571 fHilPopup->AddEntry(
"Master", kHil_PS_Master);
572 fHilPopup->RCheckEntry(kHil_PS_Ignore + gEve->GetHighlight()->GetPickToSelect(),
573 kHil_PS_Ignore, kHil_PS_END - 1);
574 fEvePopup->AddPopup(
"Highlight", fHilPopup);
577 fEvePopup->AddSeparator();
578 fEvePopup->AddEntry(
"Vertical browser", kVerticalBrowser);
579 fEvePopup->CheckEntry(kVerticalBrowser);
581 TGPopupMenu *wd =
new TGPopupMenu(gClient->GetRoot());
582 wd->AddEntry(
"Normal", kWinDecorNormal);
583 wd->AddEntry(
"Hide", kWinDecorHide);
584 wd->AddEntry(
"Title bars", kWinDecorTitleBar);
585 wd->AddEntry(
"Mini bars", kWinDecorMiniBar);
586 fEvePopup->AddPopup(
"Window decorations", wd);
589 fEvePopup->Connect(
"Activated(Int_t)",
"TEveBrowser",
590 this,
"EveMenu(Int_t)");
592 fMenuBar->AddPopup(
"&Eve", fEvePopup,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
594 fPreMenuFrame->ChangeOptions(fPreMenuFrame->GetOptions() | kRaisedFrame);
595 fTopMenuFrame->Layout();
596 fTopMenuFrame->MapSubwindows();
599 fMenuFile->GetEntry(kCloseWindow)->GetLabel()->SetString(
"Close Eve");
605 void TEveBrowser::EveMenu(Int_t
id)
609 case kNewMainFrameSlot: {
610 TEveWindowSlot* ew_slot = TEveWindow::CreateWindowMainFrame(0);
611 gEve->GetWindowManager()->SelectWindow(ew_slot);
615 TEveWindowSlot* ew_slot = TEveWindow::CreateWindowInTab(GetTabRight(), 0);
616 gEve->GetWindowManager()->SelectWindow(ew_slot);
620 gEve->SpawnNewViewer(
"Viewer Pepe");
624 gEve->SpawnNewScene(
"Scena Mica");
628 gROOT->ProcessLineFast(
"new TBrowser");
633 gROOT->ProcessLineFast(
"new TCanvas");
635 SetTabTitle(
"Canvas", 1);
638 case kNewCanvasExt: {
639 gROOT->ProcessLineFast(
"new TCanvas");
642 case kNewTextEditor: {
644 gROOT->ProcessLineFast(Form(
"new TGTextEditor((const char *)0, (const TGWindow *)0x%lx)", (ULong_t)gClient->GetRoot()));
646 SetTabTitle(
"Editor", 1);
649 case kNewHtmlBrowser: {
650 gSystem->Load(
"libGuiHtml");
651 if (gSystem->Load(
"libRHtml") >= 0)
654 gROOT->ProcessLine(Form(
"new TGHtmlBrowser(\"http://root.cern.ch/root/html/ClassIndex.html\", \
655 (const TGWindow *)0x%lx)", (ULong_t)gClient->GetRoot()));
657 SetTabTitle(
"HTML", 1);
662 case kSel_PS_Element:
663 case kSel_PS_Projectable:
664 case kSel_PS_Compound:
665 case kSel_PS_PableCompound:
666 case kSel_PS_Master: {
667 gEve->GetSelection()->SetPickToSelect(
id - kSel_PS_Ignore);
668 fSelPopup->RCheckEntry(kSel_PS_Ignore + gEve->GetSelection()->GetPickToSelect(),
669 kSel_PS_Ignore, kSel_PS_END - 1);
673 case kHil_PS_Element:
674 case kHil_PS_Projectable:
675 case kHil_PS_Compound:
676 case kHil_PS_PableCompound:
677 case kHil_PS_Master: {
678 gEve->GetHighlight()->SetPickToSelect(
id - kHil_PS_Ignore);
679 fHilPopup->RCheckEntry(kHil_PS_Ignore + gEve->GetHighlight()->GetPickToSelect(),
680 kHil_PS_Ignore, kHil_PS_END - 1);
683 case kVerticalBrowser: {
684 if (fEvePopup->IsEntryChecked(kVerticalBrowser)) {
685 gEve->GetLTEFrame()->ReconfToHorizontal();
686 fEvePopup->UnCheckEntry(kVerticalBrowser);
688 gEve->GetLTEFrame()->ReconfToVertical();
689 fEvePopup->CheckEntry(kVerticalBrowser);
693 case kWinDecorNormal: {
694 gEve->GetWindowManager()->ShowNormalEveDecorations();
697 case kWinDecorHide: {
698 gEve->GetWindowManager()->HideAllEveDecorations();
701 case kWinDecorTitleBar: {
702 gEve->GetWindowManager()->SetShowTitleBars(kTRUE);
705 case kWinDecorMiniBar: {
706 gEve->GetWindowManager()->SetShowTitleBars(kFALSE);
719 void TEveBrowser::InitPlugins(Option_t *opt)
727 TGFileBrowser *fb = MakeFileBrowser();
728 fb->BrowseObj(gROOT);
731 StopEmbedding(
"Files");
732 o.ReplaceAll(
"F",
".");
735 TRootBrowser::InitPlugins(o);
745 TGFileBrowser* TEveBrowser::MakeFileBrowser(Bool_t make_default)
748 TBrowser *tb =
new TBrowser(
"Pipi",
"Strel", &imp);
749 TGFileBrowser *fb =
new TGFileBrowser(gClient->GetRoot(), tb, 200, 500);
750 tb->SetBrowserImp((TBrowserImp *)
this);
752 fb->SetNewBrowser(
this);
753 gROOT->GetListOfBrowsers()->Remove(tb);
756 delete tb->GetContextMenu();
767 TGFileBrowser* TEveBrowser::GetFileBrowser()
const
775 void TEveBrowser::SetFileBrowser(TGFileBrowser* b)
784 void TEveBrowser::ReallyDelete()
792 void TEveBrowser::CloseTab(Int_t
id)
795 TGCompositeFrame *pcf = fTabRight->GetTabContainer(
id);
798 TGFrameElement *fe = (TGFrameElement *) pcf->GetList()->First();
801 TEveCompositeFrame *ecf =
dynamic_cast<TEveCompositeFrame*
>(fe->fFrame);
804 ecf->GetEveWindow()->DestroyWindowAndSlot();
811 TRootBrowser::CloseTab(
id);
817 void TEveBrowser::CloseWindow()
819 TEveManager::Terminate();
825 void TEveBrowser::HideBottomTab()
827 fV2->HideFrame(fHSplitter);
836 void TEveBrowser::SanitizeTabCounts()
838 fNbTab[TRootBrowser::kRight] = fTabRight->GetNumberOfTabs();
839 fCrTab[TRootBrowser::kRight] = fTabRight->GetNumberOfTabs() - 1;