ROOT  6.06/09
Reference Guide
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 //______________________________________________________________________________
13 // TGeoTabManager - manager for all editor tabs. //
14 //
15 // TGeoTreeDialog - Base class for dialog frames for selecting objects
16 // with a tree hierarchy. Specific implementations are:
17 // TGeoVolumeDialog - Special tree dialog class for selecting volumes.
18 // TGeoShapeDialog - Special tree dialog class for selecting shapes.
19 // TGeoMediumDialog - Special tree dialog class for selecting media.
20 // TGeoMaterialDialog - Special tree dialog class for selecting materials.
21 // TGeoMatrixDialog - Special tree dialog class for selecting matrices.
22 // TGeoTransientPanel - Special transient tab holding TGeo editors.
23 //______________________________________________________________________________
24 
25 #include "TROOT.h"
26 #include "TClass.h"
27 #include "TVirtualPad.h"
28 #include "TGeoGedFrame.h"
29 #include "TGTab.h"
30 #include "TGLabel.h"
31 #include "TGComboBox.h"
32 #include "TGListBox.h"
33 #include "TGListTree.h"
34 #include "TGTextEntry.h"
35 #include "TGCanvas.h"
36 #include "TGMimeTypes.h"
37 
38 #include "TGeoManager.h"
39 #include "TGeoShape.h"
40 #include "TGeoVolume.h"
41 #include "TGeoMedium.h"
42 #include "TGeoMaterial.h"
43 #include "TGeoMatrix.h"
44 
45 #include "TGedEditor.h"
46 #include "TGeoTabManager.h"
47 
49 
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 /// Ctor.
54 
56 {
57  fGedEditor = ged;
58  fPad = ged->GetPad();
59  fTab = ged->GetTab();
60  fVolume = 0;
61  fShapePanel = 0;
62  fMediumPanel = 0;
63  fMaterialPanel = 0;
64  fMatrixPanel = 0;
65  fVolumeTab = 0;
66  fgEditorToMgrMap.Add(ged, this);
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Dtor.
71 
73 {
75  if (fShapePanel) delete fShapePanel;
76  if (fMaterialPanel) delete fMaterialPanel;
77  if (fMatrixPanel) delete fMatrixPanel;
78  if (fMediumPanel) delete fMediumPanel;
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Static method to cleanup hirarchically all daughters of a composite frame.
83 /// Does not remove the frame itself.
84 
86 {
87  TGFrameElement *el;
88  TList *list = frame->GetList();
89  Int_t nframes = list->GetSize();
90  TClass *cl;
91  for (Int_t i=0; i<nframes; i++) {
92  el = (TGFrameElement *)list->At(i);
93  cl = el->fFrame->IsA();
96  }
97  frame->Cleanup();
98 }
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Get editor for a shape.
102 
104 {
105  if (!shape) return;
106  if (!fShapePanel) fShapePanel = new TGeoTransientPanel(fGedEditor, "Shape", shape);
107  else {
108  fShapePanel->SetModel(shape);
109  fShapePanel->Show();
110  }
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Get editor for a volume.
115 
117 {
118  if (!volume || !fVolumeTab) return;
122  fVolumeTab->Layout();
123  SetModel(volume);
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Get editor for a matrix.
128 
130 {
131  if (!matrix) return;
132  if (!fMatrixPanel) fMatrixPanel = new TGeoTransientPanel(fGedEditor, "Matrix", matrix);
133  else {
134  fMatrixPanel->SetModel(matrix);
135  fMatrixPanel->Show();
136  }
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 /// Get editor for a medium.
141 
143 {
144  if (!medium) return;
145  if (!fMediumPanel) fMediumPanel = new TGeoTransientPanel(fGedEditor, "Medium", medium);
146  else {
147  fMediumPanel->SetModel(medium);
148  fMediumPanel->Show();
150  }
151 }
152 
153 ////////////////////////////////////////////////////////////////////////////////
154 /// Get editor for a material.
155 
157 {
158  if (!material) return;
159  TString name = "Material";
160  if (material->IsMixture()) name = "Mixture";
161  if (!fMaterialPanel) fMaterialPanel = new TGeoTransientPanel(fGedEditor, name.Data(), material);
162  else {
163  fMaterialPanel->SetModel(material);
164  fMaterialPanel->Show();
166  }
167 }
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 /// Get editor for a class.
171 /// Look in fVolumeTab for any object deriving from TGedFrame,
172 
174 {
175  TClass *class2 = TClass::GetClass(TString::Format("%sEditor",cl->GetName()));
176  if (class2 && class2->InheritsFrom(TGedFrame::Class())) {
177  TGFrameElement *fr;
179  while ((fr = (TGFrameElement *) next())) if (fr->fFrame->IsA() == class2) return;
180  TGClient *client = fGedEditor->GetClient();
181  TGWindow *exroot = (TGWindow*) client->GetRoot();
182  client->SetRoot(fVolumeTab);
184  TGedFrame* gfr = reinterpret_cast<TGedFrame*>(class2->New());
185  gfr->SetModelClass(cl);
187  client->SetRoot(exroot);
188  fVolumeTab->AddFrame(gfr, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
189  gfr->MapSubwindows();
190  }
191 }
192 
193 ////////////////////////////////////////////////////////////////////////////////
194 /// Static method to return the tab manager currently appended to the pad or create one
195 /// if not existing.
196 
198 {
199  if (!ged) return NULL;
200  TPair *pair = (TPair*) fgEditorToMgrMap.FindObject(ged);
201  if (pair) {
202  return (TGeoTabManager*) pair->Value();
203  } else {
204  TGeoTabManager *tabmgr = new TGeoTabManager(ged); // added to fgEditorToMgrMap in ctor
205  return tabmgr;
206  }
207 }
208 
209 ////////////////////////////////////////////////////////////////////////////////
210 /// Get index for a given tab element.
211 
213 {
214  Int_t ntabs = fTab->GetNumberOfTabs();
215  TString tabname = "Volume";
216 
217  TGTabElement *tel;
218  for (Int_t i=0; i<ntabs; i++) {
219  tel = fTab->GetTabTab(i);
220  if (tel && !strcmp(tel->GetString(),tabname.Data())) return i;
221  }
222  return 0;
223 }
224 
225 ////////////////////////////////////////////////////////////////////////////////
226 /// Move frame fr at the end of the list of parent p.
227 
229 {
230  TList *list = p->GetList();
231  TIter next(list);
232  TGFrameElement *el = 0;
233  while ((el=(TGFrameElement*)next())) {
234  if (el->fFrame == fr) break;
235  }
236  if (el) {
237  list->Remove(el);
238  list->Add(el);
239  }
240 }
241 
242 ////////////////////////////////////////////////////////////////////////////////
243 /// Enable/disable tabs
244 
246 {
247  fTab->SetEnabled(GetTabIndex(), flag);
248 }
249 
250 ////////////////////////////////////////////////////////////////////////////////
251 /// Send the SetModel signal to all editors in the tab TYPE.
252 
254 {
256  fVolume = (TGeoVolume*)model;
257  TGFrameElement *el;
258  TIter next(tab->GetList());
259  while ((el = (TGFrameElement *) next())) {
260  if ((el->fFrame)->InheritsFrom(TGedFrame::Class())) {
261  ((TGedFrame *)(el->fFrame))->SetModel(model);
262  }
263  }
264 }
265 
266 ////////////////////////////////////////////////////////////////////////////////
267 /// Set a given tab element as active one.
268 
270 {
271  fTab->SetTab(GetTabIndex());
272 }
273 
275 
276 TObject *TGeoTreeDialog::fgSelectedObj = 0;
277 
278 ////////////////////////////////////////////////////////////////////////////////
279 ///static; return selected object
280 
281 TObject *TGeoTreeDialog::GetSelected()
282 {
283  return fgSelectedObj;
284 }
285 
286 ////////////////////////////////////////////////////////////////////////////////
287 /// Constructor
288 
290  :TGTransientFrame(main, main, w, h)
291 {
292  fgSelectedObj = 0;
293  fCanvas = new TGCanvas(this, 100, 200, kSunkenFrame | kDoubleBorder);
294  fLT = new TGListTree(fCanvas->GetViewPort(), 100, 200);
295  fLT->Associate(this);
298  f1 = new TGCompositeFrame(this, 100, 10, kHorizontalFrame | kLHintsExpandX);
299  fObjLabel = new TGLabel(f1, "Selected: -none-");
300  Pixel_t color;
301  gClient->GetColorByName("#0000ff", color);
302  fObjLabel->SetTextColor(color);
305  fClose = new TGTextButton(f1, "&Close");
306  fClose->Associate(this);
307  f1->AddFrame(fClose, new TGLayoutHints(kLHintsRight, 2,2,2,2));
309 
310  Int_t ww = caller->GetWidth();
311  Window_t wdum;
312  Int_t ax, ay;
313  gVirtualX->TranslateCoordinates(caller->GetId(), main->GetId(), 0,0,ax,ay,wdum);
314  Move(ax + ww, ay);
315  SetWMPosition(ax, ay);
316 
317 }
318 
319 ////////////////////////////////////////////////////////////////////////////////
320 /// Destructor
321 
323 {
324  delete fClose;
325  delete fObjLabel;
326  delete f1;
327  delete fLT;
328  delete fCanvas;
329 }
330 
331 ////////////////////////////////////////////////////////////////////////////////
332 /// Update dialog to reflect current clicked object.
333 
335 {
336  static TString name;
337  if (!item || !item->GetUserData()) {
338  fgSelectedObj = 0;
339  name = "Selected: -none-";
340  fObjLabel->SetText(name);
341  return;
342  }
343  fgSelectedObj = (TObject *)item->GetUserData();
344  if (fgSelectedObj) {
345  name = TString::Format("Selected %s", fgSelectedObj->GetName());
346  fObjLabel->SetText(name);
347  }
348 }
349 
351 
352 ////////////////////////////////////////////////////////////////////////////////
353 /// Ctor.
354 
356  :TGeoTreeDialog(caller, main, w, h)
357 {
358  BuildListTree();
359  ConnectSignalsToSlots();
360  MapSubwindows();
361  Layout();
362  SetWindowName("Volume dialog");
363  MapWindow();
364  gClient->WaitForUnmap(this);
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Build volume specific list tree.
369 
371 {
372  const TGPicture *pic_fld = gClient->GetPicture("folder_t.xpm");
373  const TGPicture *pic_fldo = gClient->GetPicture("ofolder_t.xpm");
374  const TGPicture *pic_file = gClient->GetPicture("mdi_default.xpm");
375  const TGPicture *pic_fileo = gClient->GetPicture("fileopen.xpm");
376  TGListTreeItem *parent_item=0;
377  TGeoVolume *parent_vol = gGeoManager->GetMasterVolume();
378  TGeoVolume *vol;
379  // Existing volume hierarchy
380  parent_item = fLT->AddItem(parent_item, "Volume hierarchy", pic_fldo, pic_fld);
381  parent_item->SetTipText("Select a volume from the existing hierarchy");
382  fLT->OpenItem(parent_item);
383  if (parent_vol) {
384  if (!parent_vol->GetNdaughters()) {
385  parent_item = fLT->AddItem(parent_item, parent_vol->GetName(), parent_vol, pic_fileo, pic_file);
386  parent_item->SetTipText("Master volume");
387  fLT->SetSelected(parent_item);
388  } else {
389  parent_item = fLT->AddItem(parent_item, parent_vol->GetName(), parent_vol, pic_fldo, pic_fld);
390  parent_item->SetTipText("Master volume");
391  fLT->SetSelected(parent_item);
392  }
393  }
394  parent_item = fLT->AddItem(NULL, "Other volumes", pic_fldo, pic_fld);
395  parent_item->SetTipText("Select a volume from the list of unconnected volumes");
397  Bool_t found = kFALSE;
398  while ((vol=(TGeoVolume*)next1())) {
399  if (vol->IsAdded()) continue;
400  fLT->AddItem(parent_item, vol->GetName(), vol, pic_fileo, pic_file);
401  found = kTRUE;
402  }
403  if (found) {
404 // fLT->OpenItem(parent_item);
405  if (!parent_vol) fLT->SetSelected(parent_item->GetFirstChild());
406  }
407 }
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 /// Handle close button.
411 
413 {
414  DeleteWindow();
415 }
416 
417 ////////////////////////////////////////////////////////////////////////////////
418 /// Handle item click.
419 /// Iterate daughters
420 
422 {
423  if (btn!=kButton1) return;
424  DoSelect(item);
425  if (!item || !item->GetUserData()) return;
426  const TGPicture *pic_fld = gClient->GetPicture("folder_t.xpm");
427  const TGPicture *pic_fldo = gClient->GetPicture("ofolder_t.xpm");
428  const TGPicture *pic_file = gClient->GetPicture("mdi_default.xpm");
429  const TGPicture *pic_fileo = gClient->GetPicture("fileopen.xpm");
430  TGeoVolume *parent_vol = (TGeoVolume*)item->GetUserData();
431  TGeoVolume *vol;
432  TGeoNode *crtnode;
433  TGListTreeItem *daughter_item;
434  Int_t i,j,ind,icopy;
435  Int_t nd = parent_vol->GetNdaughters();
436  for (i=0; i<nd; i++) {
437  icopy = 0;
438  crtnode = parent_vol->GetNode(i);
439  vol = crtnode->GetVolume();
440  // check if the volume is replicated in the parent
441  ind = parent_vol->GetIndex(crtnode);
442  for (j=0; j<ind; j++) if (parent_vol->GetNode(j)->GetVolume() == vol) break;
443  if (i<ind) continue;
444  icopy++;
445  for (j=ind+1; j<nd; j++) if (parent_vol->GetNode(j)->GetVolume() == vol) icopy++;
446  daughter_item = fLT->AddItem(item, ((icopy>1)?(TString::Format("%s (%i)",vol->GetName(),icopy)).Data():vol->GetName()),
447  vol,((vol->GetNdaughters())?pic_fldo:pic_fileo), ((vol->GetNdaughters())?pic_fld:pic_file));
448  if (strlen(vol->GetTitle())) daughter_item->SetTipText(vol->GetTitle());
449  }
450  if (nd) gClient->NeedRedraw(fLT);
451 }
452 
453 ////////////////////////////////////////////////////////////////////////////////
454 /// Connect signals to slots.
455 
457 {
458  fClose->Connect("Clicked()", "TGeoVolumeDialog", this, "DoClose()");
459  fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoVolumeDialog", this,
460  "DoItemClick(TGListTreeItem *, Int_t)");
461 }
462 
464 
465 ////////////////////////////////////////////////////////////////////////////////
466 /// Ctor.
467 
469  :TGeoTreeDialog(caller, main, w, h)
470 {
471  BuildListTree();
472  ConnectSignalsToSlots();
473  MapSubwindows();
474  Layout();
475  SetWindowName("Shape dialog");
476  MapWindow();
477  gClient->WaitForUnmap(this);
478 }
479 
480 ////////////////////////////////////////////////////////////////////////////////
481 /// Build shape specific list tree.
482 
484 {
485  const TGPicture *pic_fld = gClient->GetPicture("folder_t.xpm");
486  const TGPicture *pic_fldo = gClient->GetPicture("ofolder_t.xpm");
487  const TGPicture *pic_shape;
488  TGListTreeItem *parent_item=0;
489  TGeoShape *shape;
490  const char *shapename;
491  TString fld_name;
493  if (!nshapes) return;
494  // Existing shapes
495  for (Int_t i=0; i<nshapes; i++) {
496  shape = (TGeoShape*)gGeoManager->GetListOfShapes()->At(i);
497  if (!shape) continue;
498  shapename = shape->IsA()->GetName();
499  pic_shape = fClient->GetMimeTypeList()->GetIcon(shapename, kTRUE);
500  fld_name = shapename; // e.g. "TGeoBBox"
501  fld_name.Remove(0,4); // remove "TGeo" part -> "BBox"
502  fld_name += " Shapes";
503  parent_item = fLT->FindChildByName(NULL, fld_name.Data());
504  if (!parent_item) {
505  parent_item = fLT->AddItem(NULL, fld_name.Data(), pic_fldo, pic_fld);
506  parent_item->SetTipText(TString::Format("List of %s shapes",fld_name.Data()));
507  }
508  fLT->AddItem(parent_item, shape->GetName(), shape, pic_shape, pic_shape);
509  }
510 }
511 
512 ////////////////////////////////////////////////////////////////////////////////
513 /// Handle close button.
514 
516 {
517  DeleteWindow();
518 }
519 
520 ////////////////////////////////////////////////////////////////////////////////
521 /// Handle item click.
522 /// Iterate daughters
523 
525 {
526  if (btn!=kButton1) return;
527  DoSelect(item);
528  if (!item || !item->GetUserData()) return;
529 }
530 
531 ////////////////////////////////////////////////////////////////////////////////
532 /// Connect signals to slots.
533 
535 {
536  fClose->Connect("Clicked()", "TGeoShapeDialog", this, "DoClose()");
537  fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoShapeDialog", this,
538  "DoItemClick(TGListTreeItem *, Int_t)");
539 }
540 
542 
543 ////////////////////////////////////////////////////////////////////////////////
544 /// Ctor.
545 
547  :TGeoTreeDialog(caller, main, w, h)
548 {
549  BuildListTree();
550  ConnectSignalsToSlots();
551  MapSubwindows();
552  Layout();
553  SetWindowName("Medium dialog");
554  MapWindow();
555  gClient->WaitForUnmap(this);
556 }
557 
558 ////////////////////////////////////////////////////////////////////////////////
559 /// Build volume specific list tree.
560 
562 {
563  const TGPicture *pic_med = gClient->GetPicture("geomedium_t.xpm");;
564  TGeoMedium *med;
566  if (!nmed) return;
567  // Existing media
568  for (Int_t i=0; i<nmed; i++) {
569  med = (TGeoMedium*)gGeoManager->GetListOfMedia()->At(i);
570  fLT->AddItem(NULL, med->GetName(), med, pic_med, pic_med);
571  }
572 }
573 
574 ////////////////////////////////////////////////////////////////////////////////
575 /// Handle close button.
576 
578 {
579  DeleteWindow();
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// Handle item click.
584 /// Iterate daughters
585 
587 {
588  if (btn!=kButton1) return;
589  DoSelect(item);
590  if (!item || !item->GetUserData()) return;
591  //gClient->NeedRedraw(fLT);
592 }
593 
594 ////////////////////////////////////////////////////////////////////////////////
595 /// Connect signals to slots.
596 
598 {
599  fClose->Connect("Clicked()", "TGeoMediumDialog", this, "DoClose()");
600  fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoMediumDialog", this,
601  "DoItemClick(TGListTreeItem *, Int_t)");
602 }
603 
605 
606 ////////////////////////////////////////////////////////////////////////////////
607 /// Ctor.
608 
610  :TGeoTreeDialog(caller, main, w, h)
611 {
612  BuildListTree();
613  ConnectSignalsToSlots();
614  MapSubwindows();
615  Layout();
616  SetWindowName("Material dialog");
617  MapWindow();
618  gClient->WaitForUnmap(this);
619 }
620 
621 ////////////////////////////////////////////////////////////////////////////////
622 /// Build volume specific list tree.
623 
625 {
626  const TGPicture *pic_mat = gClient->GetPicture("geomaterial_t.xpm");;
627  TGeoMaterial *mat;
629  if (!nmat) return;
630  // Existing materials
631  for (Int_t i=0; i<nmat; i++) {
633  fLT->AddItem(NULL, mat->GetName(), mat, pic_mat, pic_mat);
634  }
635 }
636 
637 ////////////////////////////////////////////////////////////////////////////////
638 /// Handle close button.
639 
641 {
642  DeleteWindow();
643 }
644 
645 ////////////////////////////////////////////////////////////////////////////////
646 /// Handle item click.
647 /// Iterate daughters
648 
650 {
651  if (btn!=kButton1) return;
652  DoSelect(item);
653  if (!item || !item->GetUserData()) return;
654  //gClient->NeedRedraw(fLT);
655 }
656 
657 ////////////////////////////////////////////////////////////////////////////////
658 /// Connect signals to slots.
659 
661 {
662  fClose->Connect("Clicked()", "TGeoMaterialDialog", this, "DoClose()");
663  fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoMaterialDialog", this,
664  "DoItemClick(TGListTreeItem *, Int_t)");
665 }
666 
668 
669 ////////////////////////////////////////////////////////////////////////////////
670 /// Ctor.
671 
673  :TGeoTreeDialog(caller, main, w, h)
674 {
675  BuildListTree();
676  ConnectSignalsToSlots();
677  MapSubwindows();
678  Layout();
679  SetWindowName("Matrix dialog");
680  MapWindow();
681  gClient->WaitForUnmap(this);
682 }
683 
684 ////////////////////////////////////////////////////////////////////////////////
685 /// Build matrix specific list tree.
686 
688 {
689  const TGPicture *pic_tr = gClient->GetPicture("geotranslation_t.xpm");
690  const TGPicture *pic_rot = gClient->GetPicture("georotation_t.xpm");
691  const TGPicture *pic_combi = gClient->GetPicture("geocombi_t.xpm");
692  const TGPicture *pic;
693  TGListTreeItem *parent_item=0;
694  TGeoMatrix *matrix;
696  if (!nmat) return;
697  // Existing matrices
698  for (Int_t i=0; i<nmat; i++) {
699  matrix = (TGeoMatrix*)gGeoManager->GetListOfMatrices()->At(i);
700  if (matrix->IsIdentity()) continue;
701  if (!strcmp(matrix->IsA()->GetName(),"TGeoTranslation")) {
702  pic = pic_tr;
703  parent_item = fLT->FindChildByName(NULL, "Translations");
704  if (!parent_item) {
705  parent_item = fLT->AddItem(NULL, "Translations", pic, pic);
706  parent_item->SetTipText("List of translations");
707  }
708  } else if (!strcmp(matrix->IsA()->GetName(),"TGeoRotation")) {
709  pic = pic_rot;
710  parent_item = fLT->FindChildByName(NULL, "Rotations");
711  if (!parent_item) {
712  parent_item = fLT->AddItem(NULL, "Rotations", pic, pic);
713  parent_item->SetTipText("List of rotations");
714  }
715  } else if (!strcmp(matrix->IsA()->GetName(),"TGeoCombiTrans") ||
716  !strcmp(matrix->IsA()->GetName(),"TGeoHMatrix")) {
717  pic = pic_combi;
718  parent_item = fLT->FindChildByName(NULL, "Combined");
719  if (!parent_item) {
720  parent_item = fLT->AddItem(NULL, "Combined", pic, pic);
721  parent_item->SetTipText("List of combined transformations");
722  }
723  } else continue;
724  fLT->AddItem(parent_item, matrix->GetName(), matrix, pic, pic);
725  }
726 }
727 
728 ////////////////////////////////////////////////////////////////////////////////
729 /// Handle close button.
730 
732 {
733  DeleteWindow();
734 }
735 
736 ////////////////////////////////////////////////////////////////////////////////
737 /// Handle item click.
738 /// Iterate daughters
739 
741 {
742  if (btn!=kButton1) return;
743  DoSelect(item);
744  if (!item || !item->GetUserData()) return;
745  //gClient->NeedRedraw(fLT);
746 }
747 
748 ////////////////////////////////////////////////////////////////////////////////
749 /// Connect signals to slots.
750 
752 {
753  fClose->Connect("Clicked()", "TGeoMatrixDialog", this, "DoClose()");
754  fLT->Connect("Clicked(TGListTreeItem *, Int_t)", "TGeoMatrixDialog", this,
755  "DoItemClick(TGListTreeItem *, Int_t)");
756 }
757 
759 
760 ////////////////////////////////////////////////////////////////////////////////
761 /// Transient panel ctor.
762 
764  :TGMainFrame(gClient->GetRoot(),175,20)
765 {
766  fGedEditor = ged;
767  fModel = obj;
768  fCan = new TGCanvas(this, 170, 100);
769  fTab = new TGTab(fCan->GetViewPort(), 10, 10);
770  fCan->SetContainer(fTab);
771  AddFrame(fCan, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX));
772  fTab->Associate(fCan);
773  fTabContainer = fTab->AddTab(name);
774  fStyle = new TGCompositeFrame(fTabContainer, 110, 30, kVerticalFrame);
775  fTabContainer->AddFrame(fStyle, new TGLayoutHints(kLHintsTop | kLHintsExpandX,\
776  5, 0, 2, 2));
777  TString wname = name;
778  wname += " Editor";
779  SetWindowName(wname.Data());
780  SetModel(fModel);
781  fClose = new TGTextButton(this, "Close");
782  AddFrame(fClose, new TGLayoutHints(kLHintsBottom | kLHintsRight, 0,10,5,5));
783  MapSubwindows();
784  Layout();
785  Resize(fTabContainer->GetDefaultWidth()+30, fTabContainer->GetDefaultHeight()+65);
786  MapWindow();
787  gROOT->GetListOfCleanups()->Add(this);
788  fClose->Connect("Clicked()", "TGeoTransientPanel", this, "Hide()");
789 }
790 
791 ////////////////////////////////////////////////////////////////////////////////
792 /// Destructor.
793 
795 {
796  DeleteEditors();
797  delete fTab;
798  delete fCan;
799  gROOT->GetListOfCleanups()->Remove(this);
800 }
801 
802 ////////////////////////////////////////////////////////////////////////////////
803 /// When closed via WM close button, just unmap (i.e. hide) editor
804 /// for later use.
805 
807 {
808  UnmapWindow();
809  gROOT->GetListOfCleanups()->Remove(this);
810 }
811 
812 ////////////////////////////////////////////////////////////////////////////////
813 /// Get editor for a class.
814 /// Look in fStyle for any object deriving from TGedFrame,
815 
817 {
818  TClass *class2 = TClass::GetClass(TString::Format("%sEditor",cl->GetName()));
819  if (class2 && class2->InheritsFrom(TGedFrame::Class())) {
820  TGFrameElement *fr;
821  TIter next(fStyle->GetList());
822  while ((fr = (TGFrameElement *) next()))
823  if (fr->fFrame->IsA() == class2) return;
824  TGClient *client = fGedEditor->GetClient();
825  TGWindow *exroot = (TGWindow*) client->GetRoot();
826  client->SetRoot(fStyle);
828  TGedFrame* gfr = reinterpret_cast<TGedFrame*>(class2->New());
829  gfr->SetModelClass(cl);
831  client->SetRoot(exroot);
832  fStyle->AddFrame(gfr, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
833  gfr->MapSubwindows();
834  }
835 }
836 
837 ////////////////////////////////////////////////////////////////////////////////
838 /// Update the editors in the main tab to reflect the selected object.
839 
841 {
842  if (!model) return;
843  fModel = model;
844  GetEditors(model->IsA());
845  TGFrameElement *el;
846  TIter next(fStyle->GetList());
847  while ((el = (TGFrameElement *) next())) {
848  if ((el->fFrame)->InheritsFrom(TGedFrame::Class())) {
849  ((TGedFrame *)(el->fFrame))->SetModel(model);
850  }
851  }
853 }
854 
855 ////////////////////////////////////////////////////////////////////////////////
856 /// Hide the transient frame
857 
859 {
860  UnmapWindow();
861 }
862 
863 ////////////////////////////////////////////////////////////////////////////////
864 /// Hide the transient frame
865 
867 {
868  MapWindow();
869 }
870 
871 ////////////////////////////////////////////////////////////////////////////////
872 /// Delete editors.
873 
875 {
876  fStyle->Cleanup();
877 }
878 
879 
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGCanvas * fCanvas
virtual void DoClose()
Handle close button.
virtual ~TGeoTreeDialog()
Destructor.
virtual void ConnectSignalsToSlots()
Connect signals to slots.
virtual void ConnectSignalsToSlots()
Connect signals to slots.
virtual void DoClose()
Handle close button.
void SetTab()
Set a given tab element as active one.
TList * GetListOfMaterials() const
Definition: TGeoManager.h:463
virtual void * GetUserData() const =0
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:242
void GetEditors(TClass *cl)
Get editor for a class.
TGeoVolume * GetMasterVolume() const
Definition: TGeoManager.h:498
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:106
virtual void BuildListTree()
Build shape specific list tree.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Definition: TGTab.h:66
static TObject * fgSelectedObj
const TGPicture * GetIcon(const char *filename, Bool_t small_icon)
Return icon belonging to mime type of filename.
virtual void DoItemClick(TGListTreeItem *item, Int_t btn)
Handle item click.
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
virtual void DeleteEditors()
Delete editors.
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
TGeoTabManager(TGedEditor *ged)
TH1 * h
Definition: legend2.C:5
UInt_t GetWidth() const
Definition: TGFrame.h:287
virtual void ConnectSignalsToSlots()
Connect signals to slots.
TGCompositeFrame * fVolumeTab
virtual void SetContainer(TGFrame *f)
Definition: TGCanvas.h:234
#define gROOT
Definition: TROOT.h:340
virtual void Associate(const TGWindow *w)
Definition: TGCanvas.h:101
Basic string class.
Definition: TString.h:137
virtual TList * GetList() const
Definition: TGFrame.h:385
#define gClient
Definition: TGClient.h:174
TObjArray * GetListOfShapes() const
Definition: TGeoManager.h:467
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void GetMaterialEditor(TGeoMaterial *material)
Get editor for a material.
const Bool_t kFALSE
Definition: Rtypes.h:92
TGListTree * fLT
virtual void BuildListTree()
Build volume specific list tree.
Int_t GetTabIndex() const
Get index for a given tab element.
Int_t GetEntriesFast() const
Definition: TObjArray.h:66
static void SetFrameCreator(TGedEditor *e)
Set the TGedEditor that currently creates TGedFrames.
Definition: TGedEditor.cxx:93
void SetVolTabEnabled(Bool_t flag=kTRUE)
Enable/disable tabs.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:310
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
Int_t GetNdaughters() const
Definition: TGeoVolume.h:362
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition: TGTab.cxx:658
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hirarchically all daughters of a composite frame.
const char * Data() const
Definition: TString.h:349
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
TGCompositeFrame * f1
virtual ~TGeoTransientPanel()
Destructor.
void DoSelect(TGListTreeItem *item)
Update dialog to reflect current clicked object.
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:2334
ULong_t Pixel_t
Definition: GuiTypes.h:41
void Class()
Definition: Class.C:29
virtual void BuildListTree()
Build matrix specific list tree.
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
virtual void BuildListTree()
Build volume specific list tree.
void GetMediumEditor(TGeoMedium *medium)
Get editor for a medium.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4683
TList * GetListOfMedia() const
Definition: TGeoManager.h:464
virtual Bool_t IsMixture() const
Definition: TGeoMaterial.h:127
TGCompositeFrame(const TGCompositeFrame &)
Bool_t IsIdentity() const
Definition: TGeoMatrix.h:77
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
Definition: TMap.cxx:213
A doubly linked list.
Definition: TList.h:47
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
TGeoTransientPanel * fMatrixPanel
TObjArray * GetListOfVolumes() const
Definition: TGeoManager.h:465
virtual void SetTipText(const char *)
Definition: TGListTree.h:98
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:1135
virtual void DoClose()
Handle close button.
Bool_t IsAdded() const
Definition: TGeoVolume.h:161
virtual void ConnectSignalsToSlots()
Connect signals to slots.
TGLabel * fObjLabel
Int_t GetIndex(const TGeoNode *node) const
get index number for a given daughter
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:612
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:80
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:387
void SetModel(TObject *model)
Update the editors in the main tab to reflect the selected object.
virtual ~TGeoTabManager()
Dtor.
TObject * Remove(TObject *key)
Remove the (key,value) pair with key from the map.
Definition: TMap.cxx:294
virtual void DoItemClick(TGListTreeItem *item, Int_t btn)
Handle item click.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:389
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
static TGeoTabManager * GetMakeTabManager(TGedEditor *ged)
Static method to return the tab manager currently appended to the pad or create one if not existing...
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:507
TObject * Value() const
Definition: TMap.h:125
unsigned int UInt_t
Definition: RtypesCore.h:42
const char * GetString() const
Definition: TGTab.h:163
TGCompositeFrame * fStyle
void GetVolumeEditor(TGeoVolume *vol)
Get editor for a volume.
TGFrame * fFrame
Definition: TGLayout.h:125
TGeoTransientPanel * fShapePanel
void GetEditors(TClass *cl)
Get editor for a class.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TGCompositeFrame * fTabContainer
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
TGedEditor * fGedEditor
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
TObjArray * GetListOfMatrices() const
Definition: TGeoManager.h:462
virtual const char * GetName() const
Get the shape name.
Definition: TGeoShape.cxx:247
#define gVirtualX
Definition: TVirtualX.h:362
TGMimeTypes * GetMimeTypeList() const
Definition: TGClient.h:163
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:575
void SetModel(TObject *model)
Send the SetModel signal to all editors in the tab TYPE.
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
int main(int argc, char *argv[])
Definition: python64.c:14
Class used by TMap to store (key,value) pairs.
Definition: TMap.h:106
TGeoTreeDialog(TGFrame *caller, const TGWindow *main, UInt_t w=1, UInt_t h=1)
Constructor.
virtual Int_t GetSize() const
Definition: TCollection.h:95
virtual void ConnectSignalsToSlots()
Connect signals to slots.
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:556
TGedEditor * fGedEditor
TGeoTransientPanel * fMediumPanel
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
TGeoTransientPanel * fMaterialPanel
virtual void DoClose()
Handle close button.
TGClient * GetClient() const
Definition: TGObject.h:53
virtual void RaiseWindow()
Definition: TGWindow.h:96
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
static TMap fgEditorToMgrMap
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
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:2881
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
Handle_t Window_t
Definition: GuiTypes.h:30
virtual void UnmapWindow()
Definition: TGFrame.h:269
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition: TGFrame.cxx:1837
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
virtual void DoItemClick(TGListTreeItem *item, Int_t btn)
Handle item click.
virtual void Add(TObject *obj)
Definition: TList.h:81
virtual void BuildListTree()
Build volume specific list tree.
virtual void MapWindow()
Definition: TGFrame.h:267
TGClient * fClient
Definition: TGObject.h:41
ClassImp(TGeoTabManager) TGeoTabManager
Ctor.
#define NULL
Definition: Rtypes.h:82
TVirtualPad * GetPad() const
virtual void Show()
Hide the transient frame.
virtual void DoClose()
Handle close button.
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4579
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
virtual void Hide()
Hide the transient frame.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
virtual void DoItemClick(TGListTreeItem *item, Int_t btn)
Handle item click.
Handle_t GetId() const
Definition: TGObject.h:52
TGTextButton * fClose
virtual void CloseWindow()
When closed via WM close button, just unmap (i.e.
void GetMatrixEditor(TGeoMatrix *matrix)
Get editor for a matrix.
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:303
TGeoVolume * fVolume
void SetModelClass(TClass *mcl)
Definition: TGedFrame.h:86
void SetSelected(TGListTreeItem *item)
Definition: TGListTree.h:374
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:229
void GetShapeEditor(TGeoShape *shape)
Get editor for a shape.
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition: TGTab.cxx:435
virtual void DoItemClick(TGListTreeItem *item, Int_t btn)
Handle item click.