Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoTabManager.cxx
Go to the documentation of this file.
1// @(#):$Id$
2// Author: M.Gheata
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoTabManager
13\ingroup Geometry_builder
14
15Manager for all editor tabs.
16
17TGeoTreeDialog - Base class for dialog frames for selecting objects
18with a tree hierarchy. Specific implementations are:
19
20 - TGeoVolumeDialog - Special tree dialog class for selecting volumes.
21 - TGeoShapeDialog - Special tree dialog class for selecting shapes.
22 - TGeoMediumDialog - Special tree dialog class for selecting media.
23 - TGeoMaterialDialog - Special tree dialog class for selecting materials.
24 - TGeoMatrixDialog - Special tree dialog class for selecting matrices.
25 - TGeoTransientPanel - Special transient tab holding TGeo editors.
26*/
27
28#include "TROOT.h"
29#include "TClass.h"
30#include "TVirtualPad.h"
31#include "TGeoGedFrame.h"
32#include "TGTab.h"
33#include "TGLabel.h"
34#include "TGComboBox.h"
35#include "TGListTree.h"
36#include "TGTextEntry.h"
37#include "TGCanvas.h"
38#include "TGMimeTypes.h"
39
40#include "TGeoManager.h"
41#include "TGeoShape.h"
42#include "TGeoVolume.h"
43#include "TGeoMedium.h"
44#include "TGeoMaterial.h"
45#include "TGeoMatrix.h"
46
47#include "TGedEditor.h"
48#include "TGeoTabManager.h"
49#include "TVirtualX.h"
50
52
54
55////////////////////////////////////////////////////////////////////////////////
56/// Ctor.
57
59{
60 fGedEditor = ged;
61 fPad = ged->GetPad();
62 fTab = ged->GetTab();
63 fVolume = nullptr;
64 fShapePanel = nullptr;
65 fMediumPanel = nullptr;
66 fMaterialPanel = nullptr;
67 fMatrixPanel = nullptr;
68 fVolumeTab = nullptr;
69 fgEditorToMgrMap.Add(ged, this);
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Dtor.
74
76{
78 if (fShapePanel)
79 delete fShapePanel;
81 delete fMaterialPanel;
82 if (fMatrixPanel)
83 delete fMatrixPanel;
84 if (fMediumPanel)
85 delete fMediumPanel;
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Static method to cleanup hierarchically all daughters of a composite frame.
90/// Does not remove the frame itself.
91
93{
95 TList *list = frame->GetList();
96 Int_t nframes = list->GetSize();
97 TClass *cl;
98 for (Int_t i = 0; i < nframes; i++) {
99 el = (TGFrameElement *)list->At(i);
100 cl = el->fFrame->IsA();
103 }
104 frame->Cleanup();
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Get editor for a shape.
109
111{
112 if (!shape)
113 return;
114 if (!fShapePanel)
115 fShapePanel = new TGeoTransientPanel(fGedEditor, "Shape", shape);
116 else {
117 fShapePanel->SetModel(shape);
118 fShapePanel->Show();
119 }
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Get editor for a volume.
124
126{
127 if (!volume || !fVolumeTab)
128 return;
133 SetModel(volume);
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Get editor for a matrix.
138
140{
141 if (!matrix)
142 return;
143 if (!fMatrixPanel)
144 fMatrixPanel = new TGeoTransientPanel(fGedEditor, "Matrix", matrix);
145 else {
146 fMatrixPanel->SetModel(matrix);
148 }
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Get editor for a medium.
153
155{
156 if (!medium)
157 return;
158 if (!fMediumPanel)
159 fMediumPanel = new TGeoTransientPanel(fGedEditor, "Medium", medium);
160 else {
161 fMediumPanel->SetModel(medium);
164 }
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Get editor for a material.
169
171{
172 if (!material)
173 return;
174 TString name = "Material";
175 if (material->IsMixture())
176 name = "Mixture";
177 if (!fMaterialPanel)
178 fMaterialPanel = new TGeoTransientPanel(fGedEditor, name.Data(), material);
179 else {
180 fMaterialPanel->SetModel(material);
183 }
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Get editor for a class.
188/// Look in fVolumeTab for any object deriving from TGedFrame,
189
191{
192 TClass *class2 = TClass::GetClass(TString::Format("%sEditor", cl->GetName()));
193 if (class2 && class2->InheritsFrom(TGedFrame::Class())) {
194 TGFrameElement *fr;
195 TIter next(fVolumeTab->GetList());
196 while ((fr = (TGFrameElement *)next()))
197 if (fr->fFrame->IsA() == class2)
198 return;
199 TGClient *client = fGedEditor->GetClient();
200 TGWindow *exroot = (TGWindow *)client->GetRoot();
201 client->SetRoot(fVolumeTab);
203 TGedFrame *gfr = reinterpret_cast<TGedFrame *>(class2->New());
204 gfr->SetModelClass(cl);
206 client->SetRoot(exroot);
208 gfr->MapSubwindows();
209 }
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Static method to return the tab manager currently appended to the pad or create one
214/// if not existing.
215
217{
218 if (!ged)
219 return nullptr;
220 TPair *pair = (TPair *)fgEditorToMgrMap.FindObject(ged);
221 if (pair) {
222 return (TGeoTabManager *)pair->Value();
223 } else {
224 TGeoTabManager *tabmgr = new TGeoTabManager(ged); // added to fgEditorToMgrMap in ctor
225 return tabmgr;
226 }
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Get index for a given tab element.
231
233{
234 Int_t ntabs = fTab->GetNumberOfTabs();
235 TString tabname = "Volume";
236
237 TGTabElement *tel;
238 for (Int_t i = 0; i < ntabs; i++) {
239 tel = fTab->GetTabTab(i);
240 if (tel && !strcmp(tel->GetString(), tabname.Data()))
241 return i;
242 }
243 return 0;
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Move frame fr at the end of the list of parent p.
248
250{
251 TList *list = p->GetList();
252 TIter next(list);
253 TGFrameElement *el = nullptr;
254 while ((el = (TGFrameElement *)next())) {
255 if (el->fFrame == fr)
256 break;
257 }
258 if (el) {
259 list->Remove(el);
260 list->Add(el);
261 }
262}
263
264////////////////////////////////////////////////////////////////////////////////
265/// Enable/disable tabs
266
268{
269 fTab->SetEnabled(GetTabIndex(), flag);
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Send the SetModel signal to all editors in the tab TYPE.
274
276{
278 fVolume = (TGeoVolume *)model;
279 TGFrameElement *el;
280 TIter next(tab->GetList());
281 while ((el = (TGFrameElement *)next())) {
282 if ((el->fFrame)->InheritsFrom(TGedFrame::Class())) {
283 ((TGedFrame *)(el->fFrame))->SetModel(model);
284 }
285 }
286}
287
288////////////////////////////////////////////////////////////////////////////////
289/// Set a given tab element as active one.
290
292{
294}
295
297
299
300////////////////////////////////////////////////////////////////////////////////
301/// static; return selected object
302
304{
305 return fgSelectedObj;
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Constructor
310
313{
314 fgSelectedObj = nullptr;
315 fCanvas = new TGCanvas(this, 100, 200, kSunkenFrame | kDoubleBorder);
316 fLT = new TGListTree(fCanvas->GetViewPort(), 100, 200);
317 fLT->Associate(this);
320 f1 = new TGCompositeFrame(this, 100, 10, kHorizontalFrame | kFitWidth);
321 fObjLabel = new TGLabel(f1, "Selected: -none-");
322 Pixel_t color;
323 gClient->GetColorByName("#0000ff", color);
324 fObjLabel->SetTextColor(color);
327 fClose = new TGTextButton(f1, "&Close");
328 fClose->Associate(this);
329 f1->AddFrame(fClose, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
331
332 Int_t ww = caller->GetWidth();
333 Window_t wdum;
334 Int_t ax, ay;
335 gVirtualX->TranslateCoordinates(caller->GetId(), main->GetId(), 0, 0, ax, ay, wdum);
336 Move(ax + ww, ay);
337 SetWMPosition(ax, ay);
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Destructor
342
344{
345 delete fClose;
346 delete fObjLabel;
347 delete f1;
348 delete fLT;
349 delete fCanvas;
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Update dialog to reflect current clicked object.
354
356{
357 static TString name;
358 if (!item || !item->GetUserData()) {
359 fgSelectedObj = nullptr;
360 name = "Selected: -none-";
362 return;
363 }
364 fgSelectedObj = (TObject *)item->GetUserData();
365 if (fgSelectedObj) {
366 name = TString::Format("Selected %s", fgSelectedObj->GetName());
368 }
369}
370
372
373////////////////////////////////////////////////////////////////////////////////
374/// Ctor.
375
377 : TGeoTreeDialog(caller, main, w, h)
378{
382 Layout();
383 SetWindowName("Volume dialog");
384 MapWindow();
385 gClient->WaitForUnmap(this);
386}
387
388////////////////////////////////////////////////////////////////////////////////
389/// Build volume specific list tree.
390
392{
393 const TGPicture *pic_fld = gClient->GetPicture("folder_t.xpm");
394 const TGPicture *pic_fldo = gClient->GetPicture("ofolder_t.xpm");
395 const TGPicture *pic_file = gClient->GetPicture("mdi_default.xpm");
396 const TGPicture *pic_fileo = gClient->GetPicture("fileopen.xpm");
397 TGListTreeItem *parent_item = nullptr;
398 TGeoVolume *parent_vol = gGeoManager->GetMasterVolume();
399 TGeoVolume *vol;
400 // Existing volume hierarchy
401 parent_item = fLT->AddItem(parent_item, "Volume hierarchy", pic_fldo, pic_fld);
402 parent_item->SetTipText("Select a volume from the existing hierarchy");
403 fLT->OpenItem(parent_item);
404 if (parent_vol) {
405 if (!parent_vol->GetNdaughters()) {
406 parent_item = fLT->AddItem(parent_item, parent_vol->GetName(), parent_vol, pic_fileo, pic_file);
407 parent_item->SetTipText("Master volume");
408 fLT->SetSelected(parent_item);
409 } else {
410 parent_item = fLT->AddItem(parent_item, parent_vol->GetName(), parent_vol, pic_fldo, pic_fld);
411 parent_item->SetTipText("Master volume");
412 fLT->SetSelected(parent_item);
413 }
414 }
415 parent_item = fLT->AddItem(nullptr, "Other volumes", pic_fldo, pic_fld);
416 parent_item->SetTipText("Select a volume from the list of unconnected volumes");
418 Bool_t found = kFALSE;
419 while ((vol = (TGeoVolume *)next1())) {
420 if (vol->IsAdded())
421 continue;
422 fLT->AddItem(parent_item, vol->GetName(), vol, pic_fileo, pic_file);
423 found = kTRUE;
424 }
425 if (found) {
426 // fLT->OpenItem(parent_item);
427 if (!parent_vol)
428 fLT->SetSelected(parent_item->GetFirstChild());
429 }
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Handle close button.
434
436{
437 DeleteWindow();
438}
439
440////////////////////////////////////////////////////////////////////////////////
441/// Handle item click.
442/// Iterate daughters
443
445{
446 if (btn != kButton1)
447 return;
448 DoSelect(item);
449 if (!item || !item->GetUserData())
450 return;
451 const TGPicture *pic_fld = gClient->GetPicture("folder_t.xpm");
452 const TGPicture *pic_fldo = gClient->GetPicture("ofolder_t.xpm");
453 const TGPicture *pic_file = gClient->GetPicture("mdi_default.xpm");
454 const TGPicture *pic_fileo = gClient->GetPicture("fileopen.xpm");
455 TGeoVolume *parent_vol = (TGeoVolume *)item->GetUserData();
456 TGeoVolume *vol;
457 TGeoNode *crtnode;
458 TGListTreeItem *daughter_item;
459 Int_t i, j, ind, icopy;
460 Int_t nd = parent_vol->GetNdaughters();
461 for (i = 0; i < nd; i++) {
462 icopy = 0;
463 crtnode = parent_vol->GetNode(i);
464 vol = crtnode->GetVolume();
465 // check if the volume is replicated in the parent
466 ind = parent_vol->GetIndex(crtnode);
467 for (j = 0; j < ind; j++)
468 if (parent_vol->GetNode(j)->GetVolume() == vol)
469 break;
470 if (i < ind)
471 continue;
472 icopy++;
473 for (j = ind + 1; j < nd; j++)
474 if (parent_vol->GetNode(j)->GetVolume() == vol)
475 icopy++;
476 daughter_item = fLT->AddItem(
477 item, ((icopy > 1) ? (TString::Format("%s (%i)", vol->GetName(), icopy)).Data() : vol->GetName()), vol,
478 ((vol->GetNdaughters()) ? pic_fldo : pic_fileo), ((vol->GetNdaughters()) ? pic_fld : pic_file));
479 if (strlen(vol->GetTitle()))
480 daughter_item->SetTipText(vol->GetTitle());
481 }
482 if (nd)
483 gClient->NeedRedraw(fLT);
484}
485
486////////////////////////////////////////////////////////////////////////////////
487/// Connect signals to slots.
488
490{
491 fClose->Connect("Clicked()", "TGeoVolumeDialog", this, "DoClose()");
492 fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoVolumeDialog", this, "DoItemClick(TGListTreeItem *, Int_t)");
493}
494
496
497////////////////////////////////////////////////////////////////////////////////
498/// Ctor.
499
501 : TGeoTreeDialog(caller, main, w, h)
502{
506 Layout();
507 SetWindowName("Shape dialog");
508 MapWindow();
509 gClient->WaitForUnmap(this);
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Build shape specific list tree.
514
516{
517 const TGPicture *pic_fld = gClient->GetPicture("folder_t.xpm");
518 const TGPicture *pic_fldo = gClient->GetPicture("ofolder_t.xpm");
519 const TGPicture *pic_shape;
520 TGListTreeItem *parent_item = nullptr;
521 TGeoShape *shape;
522 const char *shapename;
523 TString fld_name;
525 if (!nshapes)
526 return;
527 // Existing shapes
528 for (Int_t i = 0; i < nshapes; i++) {
529 shape = (TGeoShape *)gGeoManager->GetListOfShapes()->At(i);
530 if (!shape)
531 continue;
532 shapename = shape->IsA()->GetName();
533 pic_shape = fClient->GetMimeTypeList()->GetIcon(shapename, kTRUE);
534 fld_name = shapename; // e.g. "TGeoBBox"
535 fld_name.Remove(0, 4); // remove "TGeo" part -> "BBox"
536 fld_name += " Shapes";
537 parent_item = fLT->FindChildByName(nullptr, fld_name.Data());
538 if (!parent_item) {
539 parent_item = fLT->AddItem(nullptr, fld_name.Data(), pic_fldo, pic_fld);
540 parent_item->SetTipText(TString::Format("List of %s shapes", fld_name.Data()));
541 }
542 fLT->AddItem(parent_item, shape->GetName(), shape, pic_shape, pic_shape);
543 }
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Handle close button.
548
550{
551 DeleteWindow();
552}
553
554////////////////////////////////////////////////////////////////////////////////
555/// Handle item click.
556/// Iterate daughters
557
559{
560 if (btn != kButton1)
561 return;
562 DoSelect(item);
563 if (!item || !item->GetUserData())
564 return;
565}
566
567////////////////////////////////////////////////////////////////////////////////
568/// Connect signals to slots.
569
571{
572 fClose->Connect("Clicked()", "TGeoShapeDialog", this, "DoClose()");
573 fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoShapeDialog", this, "DoItemClick(TGListTreeItem *, Int_t)");
574}
575
577
578////////////////////////////////////////////////////////////////////////////////
579/// Ctor.
580
582 : TGeoTreeDialog(caller, main, w, h)
583{
587 Layout();
588 SetWindowName("Medium dialog");
589 MapWindow();
590 gClient->WaitForUnmap(this);
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// Build volume specific list tree.
595
597{
598 const TGPicture *pic_med = gClient->GetPicture("geomedium_t.xpm");
599 ;
600 TGeoMedium *med;
602 if (!nmed)
603 return;
604 // Existing media
605 for (Int_t i = 0; i < nmed; i++) {
606 med = (TGeoMedium *)gGeoManager->GetListOfMedia()->At(i);
607 fLT->AddItem(nullptr, med->GetName(), med, pic_med, pic_med);
608 }
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Handle close button.
613
615{
616 DeleteWindow();
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Handle item click.
621/// Iterate daughters
622
624{
625 if (btn != kButton1)
626 return;
627 DoSelect(item);
628 if (!item || !item->GetUserData())
629 return;
630 // gClient->NeedRedraw(fLT);
631}
632
633////////////////////////////////////////////////////////////////////////////////
634/// Connect signals to slots.
635
637{
638 fClose->Connect("Clicked()", "TGeoMediumDialog", this, "DoClose()");
639 fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoMediumDialog", this, "DoItemClick(TGListTreeItem *, Int_t)");
640}
641
643
644////////////////////////////////////////////////////////////////////////////////
645/// Ctor.
646
648 : TGeoTreeDialog(caller, main, w, h)
649{
653 Layout();
654 SetWindowName("Material dialog");
655 MapWindow();
656 gClient->WaitForUnmap(this);
657}
658
659////////////////////////////////////////////////////////////////////////////////
660/// Build volume specific list tree.
661
663{
664 const TGPicture *pic_mat = gClient->GetPicture("geomaterial_t.xpm");
665 ;
666 TGeoMaterial *mat;
668 if (!nmat)
669 return;
670 // Existing materials
671 for (Int_t i = 0; i < nmat; i++) {
673 fLT->AddItem(nullptr, mat->GetName(), mat, pic_mat, pic_mat);
674 }
675}
676
677////////////////////////////////////////////////////////////////////////////////
678/// Handle close button.
679
681{
682 DeleteWindow();
683}
684
685////////////////////////////////////////////////////////////////////////////////
686/// Handle item click.
687/// Iterate daughters
688
690{
691 if (btn != kButton1)
692 return;
693 DoSelect(item);
694 if (!item || !item->GetUserData())
695 return;
696 // gClient->NeedRedraw(fLT);
697}
698
699////////////////////////////////////////////////////////////////////////////////
700/// Connect signals to slots.
701
703{
704 fClose->Connect("Clicked()", "TGeoMaterialDialog", this, "DoClose()");
705 fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoMaterialDialog", this, "DoItemClick(TGListTreeItem *, Int_t)");
706}
707
709
710////////////////////////////////////////////////////////////////////////////////
711/// Ctor.
712
714 : TGeoTreeDialog(caller, main, w, h)
715{
719 Layout();
720 SetWindowName("Matrix dialog");
721 MapWindow();
722 gClient->WaitForUnmap(this);
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Build matrix specific list tree.
727
729{
730 const TGPicture *pic_tr = gClient->GetPicture("geotranslation_t.xpm");
731 const TGPicture *pic_rot = gClient->GetPicture("georotation_t.xpm");
732 const TGPicture *pic_combi = gClient->GetPicture("geocombi_t.xpm");
733 const TGPicture *pic;
734 TGListTreeItem *parent_item = nullptr;
735 TGeoMatrix *matrix;
737 if (!nmat)
738 return;
739 // Existing matrices
740 for (Int_t i = 0; i < nmat; i++) {
741 matrix = (TGeoMatrix *)gGeoManager->GetListOfMatrices()->At(i);
742 if (matrix->IsIdentity())
743 continue;
744 if (!strcmp(matrix->IsA()->GetName(), "TGeoTranslation")) {
745 pic = pic_tr;
746 parent_item = fLT->FindChildByName(nullptr, "Translations");
747 if (!parent_item) {
748 parent_item = fLT->AddItem(nullptr, "Translations", pic, pic);
749 parent_item->SetTipText("List of translations");
750 }
751 } else if (!strcmp(matrix->IsA()->GetName(), "TGeoRotation")) {
752 pic = pic_rot;
753 parent_item = fLT->FindChildByName(nullptr, "Rotations");
754 if (!parent_item) {
755 parent_item = fLT->AddItem(nullptr, "Rotations", pic, pic);
756 parent_item->SetTipText("List of rotations");
757 }
758 } else if (!strcmp(matrix->IsA()->GetName(), "TGeoCombiTrans") ||
759 !strcmp(matrix->IsA()->GetName(), "TGeoHMatrix")) {
760 pic = pic_combi;
761 parent_item = fLT->FindChildByName(nullptr, "Combined");
762 if (!parent_item) {
763 parent_item = fLT->AddItem(nullptr, "Combined", pic, pic);
764 parent_item->SetTipText("List of combined transformations");
765 }
766 } else
767 continue;
768 fLT->AddItem(parent_item, matrix->GetName(), matrix, pic, pic);
769 }
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Handle close button.
774
776{
777 DeleteWindow();
778}
779
780////////////////////////////////////////////////////////////////////////////////
781/// Handle item click.
782/// Iterate daughters
783
785{
786 if (btn != kButton1)
787 return;
788 DoSelect(item);
789 if (!item || !item->GetUserData())
790 return;
791 // gClient->NeedRedraw(fLT);
792}
793
794////////////////////////////////////////////////////////////////////////////////
795/// Connect signals to slots.
796
798{
799 fClose->Connect("Clicked()", "TGeoMatrixDialog", this, "DoClose()");
800 fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoMatrixDialog", this, "DoItemClick(TGListTreeItem *, Int_t)");
801}
802
804
805////////////////////////////////////////////////////////////////////////////////
806/// Transient panel ctor.
807
809 : TGMainFrame(gClient->GetRoot(), 175, 20)
810{
811 fGedEditor = ged;
812 fModel = obj;
813 fCan = new TGCanvas(this, 170, 100);
814 fTab = new TGTab(fCan->GetViewPort(), 10, 10);
821 TString wname = name;
822 wname += " Editor";
823 SetWindowName(wname.Data());
825 fClose = new TGTextButton(this, "Close");
828 Layout();
830 MapWindow();
831 gROOT->GetListOfCleanups()->Add(this);
832 fClose->Connect("Clicked()", "TGeoTransientPanel", this, "Hide()");
833}
834
835////////////////////////////////////////////////////////////////////////////////
836/// Destructor.
837
839{
841 delete fTab;
842 delete fCan;
843 gROOT->GetListOfCleanups()->Remove(this);
844}
845
846////////////////////////////////////////////////////////////////////////////////
847/// When closed via WM close button, just unmap (i.e. hide) editor
848/// for later use.
849
851{
852 UnmapWindow();
853 gROOT->GetListOfCleanups()->Remove(this);
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// Get editor for a class.
858/// Look in fStyle for any object deriving from TGedFrame,
859
861{
862 TClass *class2 = TClass::GetClass(TString::Format("%sEditor", cl->GetName()));
863 if (class2 && class2->InheritsFrom(TGedFrame::Class())) {
864 TGFrameElement *fr;
865 TIter next(fStyle->GetList());
866 while ((fr = (TGFrameElement *)next()))
867 if (fr->fFrame->IsA() == class2)
868 return;
869 TGClient *client = fGedEditor->GetClient();
870 TGWindow *exroot = (TGWindow *)client->GetRoot();
871 client->SetRoot(fStyle);
873 TGedFrame *gfr = reinterpret_cast<TGedFrame *>(class2->New());
874 gfr->SetModelClass(cl);
876 client->SetRoot(exroot);
877 fStyle->AddFrame(gfr, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
878 gfr->MapSubwindows();
879 }
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// Update the editors in the main tab to reflect the selected object.
884
886{
887 if (!model)
888 return;
889 fModel = model;
890 GetEditors(model->IsA());
891 TGFrameElement *el;
892 TIter next(fStyle->GetList());
893 while ((el = (TGFrameElement *)next())) {
894 if ((el->fFrame)->InheritsFrom(TGedFrame::Class())) {
895 ((TGedFrame *)(el->fFrame))->SetModel(model);
896 }
897 }
899}
900
901////////////////////////////////////////////////////////////////////////////////
902/// Hide the transient frame
903
905{
906 UnmapWindow();
907}
908
909////////////////////////////////////////////////////////////////////////////////
910/// Hide the transient frame
911
913{
914 MapWindow();
915}
916
917////////////////////////////////////////////////////////////////////////////////
918/// Delete editors.
919
921{
922 fStyle->Cleanup();
923}
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton1
Definition GuiTypes.h:214
int main()
Definition Prototype.cxx:12
#define h(i)
Definition RSha256.hxx:106
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
#define gClient
Definition TGClient.h:156
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetWMPosition
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
#define gROOT
Definition TROOT.h:406
#define gVirtualX
Definition TVirtualX.h:337
static TClass * Class()
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:4978
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4874
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2968
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:222
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
Window client.
Definition TGClient.h:37
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
TGMimeTypes * GetMimeTypeList() const
Definition TGClient.h:146
void SetRoot(TGWindow *root=nullptr)
Sets the current root (i.e.
Definition TGClient.cxx:244
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:314
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
static TClass * Class()
virtual void Associate(const TGWindow *w)
Definition TGCanvas.h:89
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:321
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
void MapWindow() override
map window
Definition TGFrame.h:204
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:593
TClass * IsA() const override
Definition TGFrame.h:283
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
UInt_t GetWidth() const
Definition TGFrame.h:224
static TClass * Class()
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGLabel.cxx:362
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:180
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGListTreeItem * GetFirstChild() const
Definition TGListTree.h:59
virtual void SetTipText(const char *)
Definition TGListTree.h:77
virtual void * GetUserData() const =0
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:195
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
void SetSelected(TGListTreeItem *item)
Definition TGListTree.h:353
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
const TGPicture * GetIcon(const char *filename, Bool_t small_icon)
Return icon belonging to mime type of filename.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
TGClient * GetClient() const
Definition TGObject.h:42
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Pixmap_t GetPicture() const
Definition TGPicture.h:54
Service classes of the tab widget.
Definition TGTab.h:117
const char * GetString() const
Definition TGTab.h:146
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition TGTab.cxx:470
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:663
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition TGTab.cxx:709
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition TGTab.cxx:558
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:376
Yield an action as soon as it is clicked.
Definition TGButton.h:142
Defines transient windows that typically are used for dialogs windows.
Definition TGFrame.h:498
static TClass * Class()
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void RaiseWindow()
raise window
Definition TGWindow.cxx:208
TGTab * GetTab() const
Definition TGedEditor.h:73
virtual TVirtualPad * GetPad() const
Definition TGedEditor.h:78
static void SetFrameCreator(TGedEditor *e)
Set the TGedEditor that currently creates TGedFrames.
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
void SetModelClass(TClass *mcl)
Definition TGedFrame.h:78
TList * GetListOfMedia() const
TObjArray * GetListOfVolumes() const
TObjArray * GetListOfMatrices() const
TGeoVolume * GetMasterVolume() const
TList * GetListOfMaterials() const
TObjArray * GetListOfShapes() const
void ConnectSignalsToSlots() override
Connect signals to slots.
TGeoMaterialDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Ctor.
void DoItemClick(TGListTreeItem *item, Int_t btn) override
Handle item click.
void DoClose() override
Handle close button.
void BuildListTree() override
Build volume specific list tree.
Base class describing materials.
virtual Bool_t IsMixture() const
void DoItemClick(TGListTreeItem *item, Int_t btn) override
Handle item click.
void DoClose() override
Handle close button.
void ConnectSignalsToSlots() override
Connect signals to slots.
TGeoMatrixDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Ctor.
void BuildListTree() override
Build matrix specific list tree.
Geometrical transformation package.
Definition TGeoMatrix.h:38
TClass * IsA() const override
Definition TGeoMatrix.h:104
Bool_t IsIdentity() const
Definition TGeoMatrix.h:63
void ConnectSignalsToSlots() override
Connect signals to slots.
void DoClose() override
Handle close button.
void BuildListTree() override
Build volume specific list tree.
void DoItemClick(TGListTreeItem *item, Int_t btn) override
Handle item click.
TGeoMediumDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Ctor.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
void BuildListTree() override
Build shape specific list tree.
TGeoShapeDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Ctor.
void ConnectSignalsToSlots() override
Connect signals to slots.
void DoClose() override
Handle close button.
void DoItemClick(TGListTreeItem *item, Int_t btn) override
Handle item click.
Base abstract class for all shapes.
Definition TGeoShape.h:25
const char * GetName() const override
Get the shape name.
TClass * IsA() const override
Definition TGeoShape.h:171
Manager for all editor tabs.
TVirtualPad * fPad
void GetVolumeEditor(TGeoVolume *vol)
Get editor for a volume.
TGedEditor * fGedEditor
TGeoTransientPanel * fMaterialPanel
TGeoVolume * fVolume
TGCompositeFrame * fVolumeTab
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
static TMap fgEditorToMgrMap
void GetMaterialEditor(TGeoMaterial *material)
Get editor for a material.
void GetEditors(TClass *cl)
Get editor for a class.
static TGeoTabManager * GetMakeTabManager(TGedEditor *ged)
Static method to return the tab manager currently appended to the pad or create one if not existing.
void SetModel(TObject *model)
Send the SetModel signal to all editors in the tab TYPE.
Int_t GetTabIndex() const
Get index for a given tab element.
TGeoTransientPanel * fShapePanel
void GetMediumEditor(TGeoMedium *medium)
Get editor for a medium.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
void GetShapeEditor(TGeoShape *shape)
Get editor for a shape.
TGeoTransientPanel * fMediumPanel
TGeoTabManager(TGedEditor *ged)
Ctor.
void SetTab()
Set a given tab element as active one.
~TGeoTabManager() override
Dtor.
void SetVolTabEnabled(Bool_t flag=kTRUE)
Enable/disable tabs.
void GetMatrixEditor(TGeoMatrix *matrix)
Get editor for a matrix.
TGeoTransientPanel * fMatrixPanel
TGedEditor * fGedEditor
virtual void Hide()
Hide the transient frame.
TGTextButton * fClose
void CloseWindow() override
When closed via WM close button, just unmap (i.e.
TGeoTransientPanel(TGedEditor *ged, const char *name, TObject *obj)
Transient panel ctor.
void GetEditors(TClass *cl)
Get editor for a class.
virtual void Show()
Hide the transient frame.
virtual void DeleteEditors()
Delete editors.
TGCompositeFrame * fTabContainer
TGCompositeFrame * fStyle
void SetModel(TObject *model)
Update the editors in the main tab to reflect the selected object.
~TGeoTransientPanel() override
Destructor.
static TObject * fgSelectedObj
~TGeoTreeDialog() override
Destructor.
TGLabel * fObjLabel
static TObject * GetSelected()
static; return selected object
TGCompositeFrame * f1
TGTextButton * fClose
void DoSelect(TGListTreeItem *item)
Update dialog to reflect current clicked object.
TGListTree * fLT
TGeoTreeDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Constructor.
TGCanvas * fCanvas
void DoItemClick(TGListTreeItem *item, Int_t btn) override
Handle item click.
TGeoVolumeDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Ctor.
void DoClose() override
Handle close button.
void BuildListTree() override
Build volume specific list tree.
void ConnectSignalsToSlots() override
Connect signals to slots.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
Int_t GetNdaughters() const
Definition TGeoVolume.h:362
static TClass * Class()
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
Int_t GetIndex(const TGeoNode *node) const
get index number for a given daughter
Bool_t IsAdded() const
Definition TGeoVolume.h:147
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:83
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
void Add(TObject *obj) override
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
Definition TMap.cxx:54
TObject * FindObject(const char *keyname) const override
Check if a (key,value) pair exists with keyname as name of the key.
Definition TMap.cxx:215
TObject * Remove(TObject *key) override
Remove the (key,value) pair with key from the map.
Definition TMap.cxx:296
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Int_t GetEntriesFast() const
Definition TObjArray.h:58
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
static TClass * Class()
virtual TClass * IsA() const
Definition TObject.h:243
Class used by TMap to store (key,value) pairs.
Definition TMap.h:102
TObject * Value() const
Definition TMap.h:121
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
TString & Remove(Ssiz_t pos)
Definition TString.h:685
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378