51 TMap TGeoTabManager::fgEditorToMgrMap;
53 ClassImp(TGeoTabManager);
58 TGeoTabManager::TGeoTabManager(TGedEditor *ged)
69 fgEditorToMgrMap.Add(ged,
this);
75 TGeoTabManager::~TGeoTabManager()
77 fgEditorToMgrMap.Remove(fGedEditor);
78 if (fShapePanel)
delete fShapePanel;
79 if (fMaterialPanel)
delete fMaterialPanel;
80 if (fMatrixPanel)
delete fMatrixPanel;
81 if (fMediumPanel)
delete fMediumPanel;
88 void TGeoTabManager::Cleanup(TGCompositeFrame *frame)
91 TList *list = frame->GetList();
92 Int_t nframes = list->GetSize();
94 for (Int_t i=0; i<nframes; i++) {
95 el = (TGFrameElement *)list->At(i);
96 cl = el->fFrame->IsA();
97 if (cl==TGCompositeFrame::Class() || cl==TGHorizontalFrame::Class() || cl==TGVerticalFrame::Class())
98 Cleanup((TGCompositeFrame*)el->fFrame);
106 void TGeoTabManager::GetShapeEditor(TGeoShape *shape)
109 if (!fShapePanel) fShapePanel =
new TGeoTransientPanel(fGedEditor,
"Shape", shape);
111 fShapePanel->SetModel(shape);
119 void TGeoTabManager::GetVolumeEditor(TGeoVolume *volume)
121 if (!volume || !fVolumeTab)
return;
122 GetEditors(TAttLine::Class());
123 GetEditors(TGeoVolume::Class());
124 fVolumeTab->MapSubwindows();
125 fVolumeTab->Layout();
132 void TGeoTabManager::GetMatrixEditor(TGeoMatrix *matrix)
135 if (!fMatrixPanel) fMatrixPanel =
new TGeoTransientPanel(fGedEditor,
"Matrix", matrix);
137 fMatrixPanel->SetModel(matrix);
138 fMatrixPanel->Show();
145 void TGeoTabManager::GetMediumEditor(TGeoMedium *medium)
148 if (!fMediumPanel) fMediumPanel =
new TGeoTransientPanel(fGedEditor,
"Medium", medium);
150 fMediumPanel->SetModel(medium);
151 fMediumPanel->Show();
152 fMediumPanel->RaiseWindow();
159 void TGeoTabManager::GetMaterialEditor(TGeoMaterial *material)
161 if (!material)
return;
162 TString name =
"Material";
163 if (material->IsMixture()) name =
"Mixture";
164 if (!fMaterialPanel) fMaterialPanel =
new TGeoTransientPanel(fGedEditor, name.Data(), material);
166 fMaterialPanel->SetModel(material);
167 fMaterialPanel->Show();
168 fMaterialPanel->RaiseWindow();
176 void TGeoTabManager::GetEditors(TClass *cl)
178 TClass *class2 = TClass::GetClass(TString::Format(
"%sEditor",cl->GetName()));
179 if (class2 && class2->InheritsFrom(TGedFrame::Class())) {
181 TIter next(fVolumeTab->GetList());
182 while ((fr = (TGFrameElement *) next()))
if (fr->fFrame->IsA() == class2)
return;
183 TGClient *client = fGedEditor->GetClient();
184 TGWindow *exroot = (TGWindow*) client->GetRoot();
185 client->SetRoot(fVolumeTab);
186 TGedEditor::SetFrameCreator(fGedEditor);
187 TGedFrame* gfr =
reinterpret_cast<TGedFrame*
>(class2->New());
188 gfr->SetModelClass(cl);
189 TGedEditor::SetFrameCreator(0);
190 client->SetRoot(exroot);
191 fVolumeTab->AddFrame(gfr,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
192 gfr->MapSubwindows();
200 TGeoTabManager *TGeoTabManager::GetMakeTabManager(TGedEditor *ged)
202 if (!ged)
return NULL;
203 TPair *pair = (TPair*) fgEditorToMgrMap.FindObject(ged);
205 return (TGeoTabManager*) pair->Value();
207 TGeoTabManager *tabmgr =
new TGeoTabManager(ged);
215 Int_t TGeoTabManager::GetTabIndex()
const
217 Int_t ntabs = fTab->GetNumberOfTabs();
218 TString tabname =
"Volume";
221 for (Int_t i=0; i<ntabs; i++) {
222 tel = fTab->GetTabTab(i);
223 if (tel && !strcmp(tel->GetString(),tabname.Data()))
return i;
231 void TGeoTabManager::MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
233 TList *list = p->GetList();
235 TGFrameElement *el = 0;
236 while ((el=(TGFrameElement*)next())) {
237 if (el->fFrame == fr)
break;
248 void TGeoTabManager::SetVolTabEnabled(Bool_t flag)
250 fTab->SetEnabled(GetTabIndex(), flag);
256 void TGeoTabManager::SetModel(TObject *model)
258 TGCompositeFrame *tab = fVolumeTab;
259 fVolume = (TGeoVolume*)model;
261 TIter next(tab->GetList());
262 while ((el = (TGFrameElement *) next())) {
263 if ((el->fFrame)->InheritsFrom(TGedFrame::Class())) {
264 ((TGedFrame *)(el->fFrame))->SetModel(model);
272 void TGeoTabManager::SetTab()
274 fTab->SetTab(GetTabIndex());
277 ClassImp(TGeoTreeDialog);
279 TObject *TGeoTreeDialog::fgSelectedObj = 0;
284 TObject *TGeoTreeDialog::GetSelected()
286 return fgSelectedObj;
292 TGeoTreeDialog::TGeoTreeDialog(TGFrame *caller,
const TGWindow *main, UInt_t w, UInt_t h)
293 :TGTransientFrame(main, main, w, h)
296 fCanvas =
new TGCanvas(
this, 100, 200, kSunkenFrame | kDoubleBorder);
297 fLT =
new TGListTree(fCanvas->GetViewPort(), 100, 200);
298 fLT->Associate(
this);
299 fCanvas->SetContainer(fLT);
300 AddFrame(fCanvas,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2,2,2,2));
301 f1 =
new TGCompositeFrame(
this, 100, 10, kHorizontalFrame | kLHintsExpandX);
302 fObjLabel =
new TGLabel(f1,
"Selected: -none-");
304 gClient->GetColorByName(
"#0000ff", color);
305 fObjLabel->SetTextColor(color);
306 fObjLabel->ChangeOptions(kSunkenFrame | kDoubleBorder);
307 f1->AddFrame(fObjLabel,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2,2,2,2));
308 fClose =
new TGTextButton(f1,
"&Close");
309 fClose->Associate(
this);
310 f1->AddFrame(fClose,
new TGLayoutHints(kLHintsRight, 2,2,2,2));
311 AddFrame(f1,
new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 2,2,2,2));
313 Int_t ww = caller->GetWidth();
316 gVirtualX->TranslateCoordinates(caller->GetId(), main->GetId(), 0,0,ax,ay,wdum);
318 SetWMPosition(ax, ay);
325 TGeoTreeDialog::~TGeoTreeDialog()
337 void TGeoTreeDialog::DoSelect(TGListTreeItem *item)
340 if (!item || !item->GetUserData()) {
342 name =
"Selected: -none-";
343 fObjLabel->SetText(name);
346 fgSelectedObj = (TObject *)item->GetUserData();
348 name = TString::Format(
"Selected %s", fgSelectedObj->GetName());
349 fObjLabel->SetText(name);
353 ClassImp(TGeoVolumeDialog);
358 TGeoVolumeDialog::TGeoVolumeDialog(TGFrame *caller,
const TGWindow *main, UInt_t w, UInt_t h)
359 :TGeoTreeDialog(caller, main, w, h)
362 ConnectSignalsToSlots();
365 SetWindowName(
"Volume dialog");
367 gClient->WaitForUnmap(
this);
373 void TGeoVolumeDialog::BuildListTree()
375 const TGPicture *pic_fld = gClient->GetPicture(
"folder_t.xpm");
376 const TGPicture *pic_fldo = gClient->GetPicture(
"ofolder_t.xpm");
377 const TGPicture *pic_file = gClient->GetPicture(
"mdi_default.xpm");
378 const TGPicture *pic_fileo = gClient->GetPicture(
"fileopen.xpm");
379 TGListTreeItem *parent_item=0;
380 TGeoVolume *parent_vol = gGeoManager->GetMasterVolume();
383 parent_item = fLT->AddItem(parent_item,
"Volume hierarchy", pic_fldo, pic_fld);
384 parent_item->SetTipText(
"Select a volume from the existing hierarchy");
385 fLT->OpenItem(parent_item);
387 if (!parent_vol->GetNdaughters()) {
388 parent_item = fLT->AddItem(parent_item, parent_vol->GetName(), parent_vol, pic_fileo, pic_file);
389 parent_item->SetTipText(
"Master volume");
390 fLT->SetSelected(parent_item);
392 parent_item = fLT->AddItem(parent_item, parent_vol->GetName(), parent_vol, pic_fldo, pic_fld);
393 parent_item->SetTipText(
"Master volume");
394 fLT->SetSelected(parent_item);
397 parent_item = fLT->AddItem(NULL,
"Other volumes", pic_fldo, pic_fld);
398 parent_item->SetTipText(
"Select a volume from the list of unconnected volumes");
399 TIter next1(gGeoManager->GetListOfVolumes());
400 Bool_t found = kFALSE;
401 while ((vol=(TGeoVolume*)next1())) {
402 if (vol->IsAdded())
continue;
403 fLT->AddItem(parent_item, vol->GetName(), vol, pic_fileo, pic_file);
408 if (!parent_vol) fLT->SetSelected(parent_item->GetFirstChild());
415 void TGeoVolumeDialog::DoClose()
424 void TGeoVolumeDialog::DoItemClick(TGListTreeItem *item, Int_t btn)
426 if (btn!=kButton1)
return;
428 if (!item || !item->GetUserData())
return;
429 const TGPicture *pic_fld = gClient->GetPicture(
"folder_t.xpm");
430 const TGPicture *pic_fldo = gClient->GetPicture(
"ofolder_t.xpm");
431 const TGPicture *pic_file = gClient->GetPicture(
"mdi_default.xpm");
432 const TGPicture *pic_fileo = gClient->GetPicture(
"fileopen.xpm");
433 TGeoVolume *parent_vol = (TGeoVolume*)item->GetUserData();
436 TGListTreeItem *daughter_item;
438 Int_t nd = parent_vol->GetNdaughters();
439 for (i=0; i<nd; i++) {
441 crtnode = parent_vol->GetNode(i);
442 vol = crtnode->GetVolume();
444 ind = parent_vol->GetIndex(crtnode);
445 for (j=0; j<ind; j++)
if (parent_vol->GetNode(j)->GetVolume() == vol)
break;
448 for (j=ind+1; j<nd; j++)
if (parent_vol->GetNode(j)->GetVolume() == vol) icopy++;
449 daughter_item = fLT->AddItem(item, ((icopy>1)?(TString::Format(
"%s (%i)",vol->GetName(),icopy)).Data():vol->GetName()),
450 vol,((vol->GetNdaughters())?pic_fldo:pic_fileo), ((vol->GetNdaughters())?pic_fld:pic_file));
451 if (strlen(vol->GetTitle())) daughter_item->SetTipText(vol->GetTitle());
453 if (nd) gClient->NeedRedraw(fLT);
459 void TGeoVolumeDialog::ConnectSignalsToSlots()
461 fClose->Connect(
"Clicked()",
"TGeoVolumeDialog",
this,
"DoClose()");
462 fLT->Connect(
"Clicked(TGListTreeItem *, Int_t)",
"TGeoVolumeDialog",
this,
463 "DoItemClick(TGListTreeItem *, Int_t)");
466 ClassImp(TGeoShapeDialog);
471 TGeoShapeDialog::TGeoShapeDialog(TGFrame *caller,
const TGWindow *main, UInt_t w, UInt_t h)
472 :TGeoTreeDialog(caller, main, w, h)
475 ConnectSignalsToSlots();
478 SetWindowName(
"Shape dialog");
480 gClient->WaitForUnmap(
this);
486 void TGeoShapeDialog::BuildListTree()
488 const TGPicture *pic_fld = gClient->GetPicture(
"folder_t.xpm");
489 const TGPicture *pic_fldo = gClient->GetPicture(
"ofolder_t.xpm");
490 const TGPicture *pic_shape;
491 TGListTreeItem *parent_item=0;
493 const char *shapename;
495 Int_t nshapes = gGeoManager->GetListOfShapes()->GetEntriesFast();
496 if (!nshapes)
return;
498 for (Int_t i=0; i<nshapes; i++) {
499 shape = (TGeoShape*)gGeoManager->GetListOfShapes()->At(i);
500 if (!shape)
continue;
501 shapename = shape->IsA()->GetName();
502 pic_shape = fClient->GetMimeTypeList()->GetIcon(shapename, kTRUE);
503 fld_name = shapename;
504 fld_name.Remove(0,4);
505 fld_name +=
" Shapes";
506 parent_item = fLT->FindChildByName(NULL, fld_name.Data());
508 parent_item = fLT->AddItem(NULL, fld_name.Data(), pic_fldo, pic_fld);
509 parent_item->SetTipText(TString::Format(
"List of %s shapes",fld_name.Data()));
511 fLT->AddItem(parent_item, shape->GetName(), shape, pic_shape, pic_shape);
518 void TGeoShapeDialog::DoClose()
527 void TGeoShapeDialog::DoItemClick(TGListTreeItem *item, Int_t btn)
529 if (btn!=kButton1)
return;
531 if (!item || !item->GetUserData())
return;
537 void TGeoShapeDialog::ConnectSignalsToSlots()
539 fClose->Connect(
"Clicked()",
"TGeoShapeDialog",
this,
"DoClose()");
540 fLT->Connect(
"Clicked(TGListTreeItem *, Int_t)",
"TGeoShapeDialog",
this,
541 "DoItemClick(TGListTreeItem *, Int_t)");
544 ClassImp(TGeoMediumDialog);
549 TGeoMediumDialog::TGeoMediumDialog(TGFrame *caller,
const TGWindow *main, UInt_t w, UInt_t h)
550 :TGeoTreeDialog(caller, main, w, h)
553 ConnectSignalsToSlots();
556 SetWindowName(
"Medium dialog");
558 gClient->WaitForUnmap(
this);
564 void TGeoMediumDialog::BuildListTree()
566 const TGPicture *pic_med = gClient->GetPicture(
"geomedium_t.xpm");;
568 Int_t nmed = gGeoManager->GetListOfMedia()->GetSize();
571 for (Int_t i=0; i<nmed; i++) {
572 med = (TGeoMedium*)gGeoManager->GetListOfMedia()->At(i);
573 fLT->AddItem(NULL, med->GetName(), med, pic_med, pic_med);
580 void TGeoMediumDialog::DoClose()
589 void TGeoMediumDialog::DoItemClick(TGListTreeItem *item, Int_t btn)
591 if (btn!=kButton1)
return;
593 if (!item || !item->GetUserData())
return;
600 void TGeoMediumDialog::ConnectSignalsToSlots()
602 fClose->Connect(
"Clicked()",
"TGeoMediumDialog",
this,
"DoClose()");
603 fLT->Connect(
"Clicked(TGListTreeItem *, Int_t)",
"TGeoMediumDialog",
this,
604 "DoItemClick(TGListTreeItem *, Int_t)");
607 ClassImp(TGeoMaterialDialog);
612 TGeoMaterialDialog::TGeoMaterialDialog(TGFrame *caller,
const TGWindow *main, UInt_t w, UInt_t h)
613 :TGeoTreeDialog(caller, main, w, h)
616 ConnectSignalsToSlots();
619 SetWindowName(
"Material dialog");
621 gClient->WaitForUnmap(
this);
627 void TGeoMaterialDialog::BuildListTree()
629 const TGPicture *pic_mat = gClient->GetPicture(
"geomaterial_t.xpm");;
631 Int_t nmat = gGeoManager->GetListOfMaterials()->GetSize();
634 for (Int_t i=0; i<nmat; i++) {
635 mat = (TGeoMaterial*)gGeoManager->GetListOfMaterials()->At(i);
636 fLT->AddItem(NULL, mat->GetName(), mat, pic_mat, pic_mat);
643 void TGeoMaterialDialog::DoClose()
652 void TGeoMaterialDialog::DoItemClick(TGListTreeItem *item, Int_t btn)
654 if (btn!=kButton1)
return;
656 if (!item || !item->GetUserData())
return;
663 void TGeoMaterialDialog::ConnectSignalsToSlots()
665 fClose->Connect(
"Clicked()",
"TGeoMaterialDialog",
this,
"DoClose()");
666 fLT->Connect(
"Clicked(TGListTreeItem *, Int_t)",
"TGeoMaterialDialog",
this,
667 "DoItemClick(TGListTreeItem *, Int_t)");
670 ClassImp(TGeoMatrixDialog);
675 TGeoMatrixDialog::TGeoMatrixDialog(TGFrame *caller,
const TGWindow *main, UInt_t w, UInt_t h)
676 :TGeoTreeDialog(caller, main, w, h)
679 ConnectSignalsToSlots();
682 SetWindowName(
"Matrix dialog");
684 gClient->WaitForUnmap(
this);
690 void TGeoMatrixDialog::BuildListTree()
692 const TGPicture *pic_tr = gClient->GetPicture(
"geotranslation_t.xpm");
693 const TGPicture *pic_rot = gClient->GetPicture(
"georotation_t.xpm");
694 const TGPicture *pic_combi = gClient->GetPicture(
"geocombi_t.xpm");
695 const TGPicture *pic;
696 TGListTreeItem *parent_item=0;
698 Int_t nmat = gGeoManager->GetListOfMatrices()->GetEntriesFast();
701 for (Int_t i=0; i<nmat; i++) {
702 matrix = (TGeoMatrix*)gGeoManager->GetListOfMatrices()->At(i);
703 if (matrix->IsIdentity())
continue;
704 if (!strcmp(matrix->IsA()->GetName(),
"TGeoTranslation")) {
706 parent_item = fLT->FindChildByName(NULL,
"Translations");
708 parent_item = fLT->AddItem(NULL,
"Translations", pic, pic);
709 parent_item->SetTipText(
"List of translations");
711 }
else if (!strcmp(matrix->IsA()->GetName(),
"TGeoRotation")) {
713 parent_item = fLT->FindChildByName(NULL,
"Rotations");
715 parent_item = fLT->AddItem(NULL,
"Rotations", pic, pic);
716 parent_item->SetTipText(
"List of rotations");
718 }
else if (!strcmp(matrix->IsA()->GetName(),
"TGeoCombiTrans") ||
719 !strcmp(matrix->IsA()->GetName(),
"TGeoHMatrix")) {
721 parent_item = fLT->FindChildByName(NULL,
"Combined");
723 parent_item = fLT->AddItem(NULL,
"Combined", pic, pic);
724 parent_item->SetTipText(
"List of combined transformations");
727 fLT->AddItem(parent_item, matrix->GetName(), matrix, pic, pic);
734 void TGeoMatrixDialog::DoClose()
743 void TGeoMatrixDialog::DoItemClick(TGListTreeItem *item, Int_t btn)
745 if (btn!=kButton1)
return;
747 if (!item || !item->GetUserData())
return;
754 void TGeoMatrixDialog::ConnectSignalsToSlots()
756 fClose->Connect(
"Clicked()",
"TGeoMatrixDialog",
this,
"DoClose()");
757 fLT->Connect(
"Clicked(TGListTreeItem *, Int_t)",
"TGeoMatrixDialog",
this,
758 "DoItemClick(TGListTreeItem *, Int_t)");
761 ClassImp(TGeoTransientPanel);
766 TGeoTransientPanel::TGeoTransientPanel(TGedEditor* ged,
const char *name, TObject *obj)
767 :TGMainFrame(gClient->GetRoot(),175,20)
771 fCan =
new TGCanvas(
this, 170, 100);
772 fTab =
new TGTab(fCan->GetViewPort(), 10, 10);
773 fCan->SetContainer(fTab);
774 AddFrame(fCan,
new TGLayoutHints(kLHintsExpandY | kLHintsExpandX));
775 fTab->Associate(fCan);
776 fTabContainer = fTab->AddTab(name);
777 fStyle =
new TGCompositeFrame(fTabContainer, 110, 30, kVerticalFrame);
778 fTabContainer->AddFrame(fStyle,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,\
780 TString wname = name;
782 SetWindowName(wname.Data());
784 fClose =
new TGTextButton(
this,
"Close");
785 AddFrame(fClose,
new TGLayoutHints(kLHintsBottom | kLHintsRight, 0,10,5,5));
788 Resize(fTabContainer->GetDefaultWidth()+30, fTabContainer->GetDefaultHeight()+65);
790 gROOT->GetListOfCleanups()->Add(
this);
791 fClose->Connect(
"Clicked()",
"TGeoTransientPanel",
this,
"Hide()");
797 TGeoTransientPanel::~TGeoTransientPanel()
802 gROOT->GetListOfCleanups()->Remove(
this);
809 void TGeoTransientPanel::CloseWindow()
812 gROOT->GetListOfCleanups()->Remove(
this);
819 void TGeoTransientPanel::GetEditors(TClass *cl)
821 TClass *class2 = TClass::GetClass(TString::Format(
"%sEditor",cl->GetName()));
822 if (class2 && class2->InheritsFrom(TGedFrame::Class())) {
824 TIter next(fStyle->GetList());
825 while ((fr = (TGFrameElement *) next()))
826 if (fr->fFrame->IsA() == class2)
return;
827 TGClient *client = fGedEditor->GetClient();
828 TGWindow *exroot = (TGWindow*) client->GetRoot();
829 client->SetRoot(fStyle);
830 TGedEditor::SetFrameCreator(fGedEditor);
831 TGedFrame* gfr =
reinterpret_cast<TGedFrame*
>(class2->New());
832 gfr->SetModelClass(cl);
833 TGedEditor::SetFrameCreator(0);
834 client->SetRoot(exroot);
835 fStyle->AddFrame(gfr,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
836 gfr->MapSubwindows();
843 void TGeoTransientPanel::SetModel(TObject *model)
847 GetEditors(model->IsA());
849 TIter next(fStyle->GetList());
850 while ((el = (TGFrameElement *) next())) {
851 if ((el->fFrame)->InheritsFrom(TGedFrame::Class())) {
852 ((TGedFrame *)(el->fFrame))->SetModel(model);
855 Resize(fTabContainer->GetDefaultWidth()+30, fTabContainer->GetDefaultHeight()+65);
861 void TGeoTransientPanel::Hide()
869 void TGeoTransientPanel::Show()
877 void TGeoTransientPanel::DeleteEditors()