Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGeoManagerEditor.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 TGeoManagerEditor
13 \ingroup Geometry_builder
14 
15 Editor for TGeoManager class. Provides also builder functionality for the
16 main TGeo objects: TGeoVolume, TGeoShape - derived classes, TGeoMaterial,
17 TGeoMatrix - derived transformations and TGeoMedium.
18 The GUI represents the main entry point for editing geometry classes. It
19 can be started either by:
20 
21  1. TGeoManager::Edit(). The method must be used when starting from a new
22  geometry.
23  2. Left-click on the 40x40 pixels top-right corner of a pad containing a
24  drawn volume. The region is always accesible when drawing geometry elements
25  and allows also restoring the manager editor in the "Style" tab of the GED
26  editor anytime.
27 
28 The TGeoManager editor is vertically split by a TGShutter widget into the
29 following categories:
30 
31  - General. This allows changing the name/title of the geometry, setting the
32  top volume, closing the geometry and saving the geometry in a file. The name
33  of the geometry file is formed by geometry_name.C/.root depending if the geometry
34  need to be saved as a C macro or a .root file.
35  - Shapes. The category provide buttons for creation of all supported shapes. The
36  new shape name is chosen by the interface, but can be changed from the shape
37  editor GUI. Existing shapes can be browsed and edited from the same category.
38  - Volumes. The category allows the creation of a new volume having a given name,
39  shape and medium. For creating a volume assembly only the name is relevant.
40  Existing volumes can be browsed or edited from this category.
41  - Materials. Allows creation of new materials/mixtures or editing existing ones.
42  - Media. The same for creation/editing of tracking media (materials having a set
43  of properties related to tracking)
44  - Matrices. Allows creation of translations, rotations or combined transformations.
45  Existing matrices can also be browser/edited.
46 */
47 
48 #include "TVirtualPad.h"
49 #include "TCanvas.h"
50 #include "TGTab.h"
51 #include "TG3DLine.h"
52 #include "TGComboBox.h"
53 #include "TGButton.h"
54 #include "TGButtonGroup.h"
55 #include "TGTextEntry.h"
56 #include "TGNumberEntry.h"
57 #include "TGLabel.h"
58 #include "TGShutter.h"
59 
60 #include "TGeoVolumeEditor.h"
61 #include "TGeoNodeEditor.h"
62 #include "TGeoTabManager.h"
63 #include "TGeoVolume.h"
64 #include "TGeoManager.h"
65 #include "TGeoMatrix.h"
66 #include "TGeoBBox.h"
67 #include "TGeoPara.h"
68 #include "TGeoArb8.h"
69 #include "TGeoTube.h"
70 #include "TGeoEltu.h"
71 #include "TGeoHype.h"
72 #include "TGeoTorus.h"
73 #include "TGeoTrd1.h"
74 #include "TGeoTrd2.h"
75 #include "TGeoCone.h"
76 #include "TGeoSphere.h"
77 #include "TGeoPcon.h"
78 #include "TGeoPgon.h"
79 #include "TGeoElement.h"
80 #include "TGeoMaterial.h"
81 #include "TView.h"
82 
83 #include "TGeoManagerEditor.h"
84 #include "TGedEditor.h"
85 
86 ClassImp(TGeoManagerEditor);
87 
88 enum ETGeoVolumeWid {
89  kMANAGER_NAME, kMANAGER_TITLE,
90  kMANAGER_SHAPE_SELECT, kMANAGER_MEDIA_SELECT,kMANAGER_MATERIAL_SELECT, kMANAGER_ELEMENT_SELECT,
91  kMANAGER_SHAPE_SELECT2, kMANAGER_MEDIUM_SELECT2, kMANAGER_VOLUME_SELECT,
92  kMANAGER_EDIT_SHAPE, kMANAGER_EDIT_MEDIUM, kMANAGER_DENSITY_SELECT, kMANAGER_NELEM_SELECT,
93  kMANAGER_MATERIAL_SELECT2, kMANAGER_MEDIUM_SELECT, kMANAGER_MATRIX_SELECT, kMANAGER_TOP_SELECT,
94  kEXPORT_ROOT, kEXPORT_C, kEXPORT_GEOMETRY,
95  kCAT_GENERAL, kCAT_SHAPES, kCAT_VOLUMES, kCAT_MEDIA, kCAT_MATERIALS, kCAT_MATRICES,
96  kCREATE_BOX, kCREATE_PARA, kCREATE_TRD1, kCREATE_TRD2,
97  kCREATE_TRAP, kCREATE_GTRA, kCREATE_XTRU, kCREATE_ARB8,
98  kCREATE_TUBE, kCREATE_TUBS, kCREATE_CONE, kCREATE_CONS,
99  kCREATE_SPHE, kCREATE_CTUB, kCREATE_ELTU, kCREATE_TORUS,
100  kCREATE_PCON, kCREATE_PGON, kCREATE_HYPE, kCREATE_PARAB, kCREATE_COMP,
101  kCREATE_MATERIAL, kCREATE_MIXTURE, kCREATE_MEDIUM, kCREATE_VOLUME, kCREATE_ASSEMBLY,
102  kCREATE_TRANSLATION, kCREATE_ROTATION, kCREATE_COMBI,
103  kMEDIUM_NAME, kMEDIUM_ID, kMATRIX_NAME, kMATERIAL_NAME, kVOLUME_NAME,
104  kMANAGER_APPLY, kMANAGER_CANCEL, kMANAGER_UNDO
105 };
106 
107 ////////////////////////////////////////////////////////////////////////////////
108 /// Constructor for manager editor.
109 
110 TGeoManagerEditor::TGeoManagerEditor(const TGWindow *p, Int_t width,
111  Int_t height, UInt_t options, Pixel_t back)
112  : TGedFrame(p, width, height, options | kVerticalFrame, back)
113 {
114  fGeometry = gGeoManager;
115  fTabMgr = 0;
116  fTab = 0;
117  fConnectedCanvas = 0;
118 
119  fIsModified = kFALSE;
120  TGCompositeFrame *f1;
121  TGLabel *label;
122 
123  // TGShutter for categories
124  fCategories = new TGShutter(this, kSunkenFrame | kFixedHeight);
125 
126  TGCompositeFrame *container;
127  Pixel_t color;
128  // General settings
129  TGShutterItem *si = new TGShutterItem(fCategories, new TGHotString("General"),kCAT_GENERAL);
130  container = (TGCompositeFrame*)si->GetContainer();
131  container->SetBackgroundColor(GetDefaultFrameBackground());
132  fCategories->AddItem(si);
133  // TextEntry for manager name
134  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
135  f1->AddFrame(label = new TGLabel(f1, "Name/Title"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
136  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
137  gClient->GetColorByName("#ff0000", color);
138  label->SetTextColor(color);
139  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
140  fManagerName = new TGTextEntry(container, new TGTextBuffer(50), kMANAGER_NAME);
141  fManagerName->Resize(135, fManagerName->GetDefaultHeight());
142  fManagerName->SetToolTipText("Enter the geometry name");
143  container->AddFrame(fManagerName, new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
144  fManagerTitle = new TGTextEntry(container, new TGTextBuffer(50), kMANAGER_TITLE);
145  fManagerTitle->Resize(135, fManagerTitle->GetDefaultHeight());
146  fManagerTitle->SetToolTipText("Enter the geometry name");
147  container->AddFrame(fManagerTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 0, 0));
148  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
149  f1->AddFrame(label = new TGLabel(f1, "Export geometry"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
150  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
151  gClient->GetColorByName("#ff0000", color);
152  label->SetTextColor(color);
153  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 6, 0));
154  TString stitle = "Options";
155  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
156  TGButtonGroup *bg = new TGVButtonGroup(f1, stitle);
157  fExportOption[0] = new TGRadioButton(bg, ".root", kEXPORT_ROOT);
158  fExportOption[1] = new TGRadioButton(bg, ".C", kEXPORT_C);
159  fExportButton = new TGTextButton(f1, "Export", kEXPORT_GEOMETRY);
160  bg->SetRadioButtonExclusive();
161  bg->SetButton(kEXPORT_ROOT);
162  bg->Show();
163  f1->AddFrame(bg, new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
164  f1->AddFrame(fExportButton, new TGLayoutHints(kLHintsLeft, 20, 2, 22, 0));
165  container->AddFrame(f1, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2));
166  // Close geometry
167  f7 = new TGCompositeFrame(container, 155, 10, kVerticalFrame | kFixedWidth);
168  f1 = new TGCompositeFrame(f7, 155, 10, kHorizontalFrame | kFixedWidth);
169  f1->AddFrame(label = new TGLabel(f1, "Close geometry"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
170  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
171  gClient->GetColorByName("#ff0000", color);
172  label->SetTextColor(color);
173  f7->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
174  f1 = new TGCompositeFrame(f7, 155, 30, kHorizontalFrame | kFixedWidth);
175  fLSelTop = new TGLabel(f1, "Select top");
176  gClient->GetColorByName("#0000ff", color);
177  fLSelTop->SetTextColor(color);
178  fLSelTop->ChangeOptions(kSunkenFrame | kDoubleBorder);
179  f1->AddFrame(fLSelTop, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
180  fBSelTop = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_TOP_SELECT);
181  fBSelTop->SetToolTipText("Select the top volume");
182  fBSelTop->Associate(this);
183  f1->AddFrame(fBSelTop, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
184  fCloseGeometry = new TGTextButton(f1, "Close");
185  f1->AddFrame(fCloseGeometry, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
186  fCloseGeometry->SetToolTipText("Close geometry to make it ready for tracking");
187  fCloseGeometry->Associate(this);
188  f7->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
189  container->AddFrame(f7, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
190 
191 
192  si = new TGShutterItem(fCategories, new TGHotString("Shapes"),kCAT_SHAPES);
193  container = (TGCompositeFrame*)si->GetContainer();
194  container->SetBackgroundColor(GetDefaultFrameBackground());
195  fCategories->AddItem(si);
196 
197  // Shape creators
198  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
199  f1->AddFrame(label = new TGLabel(f1, "Create new shape"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
200  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
201  gClient->GetColorByName("#ff0000", color);
202  label->SetTextColor(color);
203  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
204  TGLayoutHints *lhb = new TGLayoutHints(kLHintsLeft, 0, 4, 0, 0);
205  TGLayoutHints *lhf1 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
206  Int_t ipict;
207  f1 = new TGCompositeFrame(container, 118, 30, kHorizontalFrame);
208  fShapeButton[0] = new TGPictureButton(f1, fClient->GetPicture("geobbox_t.xpm"), kCREATE_BOX);
209  fShapeButton[0]->SetToolTipText("Create a box");
210  fShapeButton[1] = new TGPictureButton(f1, fClient->GetPicture("geopara_t.xpm"), kCREATE_PARA);
211  fShapeButton[1]->SetToolTipText("Create a parallelipiped");
212  fShapeButton[2] = new TGPictureButton(f1, fClient->GetPicture("geotrd1_t.xpm"), kCREATE_TRD1);
213  fShapeButton[2]->SetToolTipText("Create a TRD1 trapezoid");
214  fShapeButton[3] = new TGPictureButton(f1, fClient->GetPicture("geotrd2_t.xpm"), kCREATE_TRD2);
215  fShapeButton[3]->SetToolTipText("Create a TRD2 trapezoid");
216  fShapeButton[4] = new TGPictureButton(f1, fClient->GetPicture("geotrap_t.xpm"), kCREATE_TRAP);
217  fShapeButton[4]->SetToolTipText("Create a general trapezoid");
218  fShapeButton[5] = new TGPictureButton(f1, fClient->GetPicture("geogtra_t.xpm"), kCREATE_GTRA);
219  fShapeButton[5]->SetToolTipText("Create a general twisted trapezoid");
220  for (ipict=0; ipict<6; ipict++) f1->AddFrame(fShapeButton[ipict],lhb);
221  container->AddFrame(f1, lhf1);
222  f1 = new TGCompositeFrame(container, 118, 30, kHorizontalFrame);
223  fShapeButton[6] = new TGPictureButton(f1, fClient->GetPicture("geoxtru_t.xpm"), kCREATE_XTRU);
224  fShapeButton[6]->SetToolTipText("Create a extruded polygone");
225  fShapeButton[7] = new TGPictureButton(f1, fClient->GetPicture("geoarb8_t.xpm"), kCREATE_ARB8);
226  fShapeButton[7]->SetToolTipText("Create an arbitrary trapezoid with 8 vertices");
227  fShapeButton[8] = new TGPictureButton(f1, fClient->GetPicture("geotube_t.xpm"), kCREATE_TUBE);
228  fShapeButton[8]->SetToolTipText("Create a cylindrical pipe");
229  fShapeButton[9] = new TGPictureButton(f1, fClient->GetPicture("geotubeseg_t.xpm"), kCREATE_TUBS);
230  fShapeButton[9]->SetToolTipText("Create a cylindrical pipe within a phi range");
231  fShapeButton[10] = new TGPictureButton(f1, fClient->GetPicture("geocone_t.xpm"), kCREATE_CONE);
232  fShapeButton[10]->SetToolTipText("Create a conical pipe");
233  fShapeButton[11] = new TGPictureButton(f1, fClient->GetPicture("geoconeseg_t.xpm"), kCREATE_CONS);
234  fShapeButton[11]->SetToolTipText("Create a conical pipe within a phi range");
235  for (ipict=0; ipict<6; ipict++) f1->AddFrame(fShapeButton[ipict+6],lhb);
236  container->AddFrame(f1, lhf1);
237  f1 = new TGCompositeFrame(container, 118, 30, kHorizontalFrame);
238  fShapeButton[12] = new TGPictureButton(f1, fClient->GetPicture("geosphere_t.xpm"), kCREATE_SPHE);
239  fShapeButton[12]->SetToolTipText("Create a spherical sector");
240  fShapeButton[13] = new TGPictureButton(f1, fClient->GetPicture("geoctub_t.xpm"), kCREATE_CTUB);
241  fShapeButton[13]->SetToolTipText("Create a cut tube");
242  fShapeButton[14] = new TGPictureButton(f1, fClient->GetPicture("geoeltu_t.xpm"), kCREATE_ELTU);
243  fShapeButton[14]->SetToolTipText("Create an elliptical tube");
244  fShapeButton[15] = new TGPictureButton(f1, fClient->GetPicture("geotorus_t.xpm"), kCREATE_TORUS);
245  fShapeButton[15]->SetToolTipText("Create a toroidal tube with a phi range");
246  fShapeButton[16] = new TGPictureButton(f1, fClient->GetPicture("geopcon_t.xpm"), kCREATE_PCON);
247  fShapeButton[16]->SetToolTipText("Create a polycone shape");
248  fShapeButton[17] = new TGPictureButton(f1, fClient->GetPicture("geopgon_t.xpm"), kCREATE_PGON);
249  fShapeButton[17]->SetToolTipText("Create a polygon shape");
250  for (ipict=0; ipict<6; ipict++) f1->AddFrame(fShapeButton[ipict+12],lhb);
251  container->AddFrame(f1, lhf1);
252  f1 = new TGCompositeFrame(container, 118, 30, kHorizontalFrame);
253  fShapeButton[18] = new TGPictureButton(f1, fClient->GetPicture("geohype_t.xpm"), kCREATE_HYPE);
254  fShapeButton[18]->SetToolTipText("Create a hyperboloid");
255  fShapeButton[19] = new TGPictureButton(f1, fClient->GetPicture("geoparab_t.xpm"), kCREATE_PARAB);
256  fShapeButton[19]->SetToolTipText("Create a paraboloid");
257  fShapeButton[20] = new TGPictureButton(f1, fClient->GetPicture("geocomposite_t.xpm"), kCREATE_COMP);
258  fShapeButton[20]->SetToolTipText("Create a composite shape");
259  for (ipict=0; ipict<3; ipict++) f1->AddFrame(fShapeButton[ipict+18],lhb);
260  container->AddFrame(f1, lhf1);
261 
262  // List of shapes
263  f2 = new TGCompositeFrame(container, 155, 10, kVerticalFrame | kFixedWidth);
264  f1 = new TGCompositeFrame(f2, 155, 10, kHorizontalFrame | kFixedWidth);
265  f1->AddFrame(label = new TGLabel(f1, "Existing shapes"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
266  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
267  gClient->GetColorByName("#ff0000", color);
268  label->SetTextColor(color);
269  f2->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
270  f1 = new TGCompositeFrame(f2, 155, 30, kHorizontalFrame | kFixedWidth);
271  fSelectedShape = 0;
272  fLSelShape = new TGLabel(f1, "Select shape");
273  gClient->GetColorByName("#0000ff", color);
274  fLSelShape->SetTextColor(color);
275  fLSelShape->ChangeOptions(kSunkenFrame | kDoubleBorder);
276  f1->AddFrame(fLSelShape, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
277  fBSelShape = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_SHAPE_SELECT);
278  fBSelShape->SetToolTipText("Select one of the existing shapes");
279  fBSelShape->Associate(this);
280  f1->AddFrame(fBSelShape, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
281  fEditShape = new TGTextButton(f1, "Edit");
282  f1->AddFrame(fEditShape, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
283  fEditShape->SetToolTipText("Edit selected shape");
284  fEditShape->Associate(this);
285  f2->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
286  container->AddFrame(f2, new TGLayoutHints(kLHintsLeft, 0, 0, 6, 0));
287 
288  // Volumes category
289  si = new TGShutterItem(fCategories, new TGHotString("Volumes"),kCAT_VOLUMES);
290  container = (TGCompositeFrame*)si->GetContainer();
291  container->SetBackgroundColor(GetDefaultFrameBackground());
292  fCategories->AddItem(si);
293 
294  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
295  f1->AddFrame(label = new TGLabel(f1, "Create new volume"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
296  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
297  gClient->GetColorByName("#ff0000", color);
298  label->SetTextColor(color);
299  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
300 
301  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
302  f1->AddFrame(new TGLabel(f1, "Name"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
303  fVolumeName = new TGTextEntry(f1, new TGTextBuffer(50), kVOLUME_NAME);
304  fVolumeName->Resize(100, fVolumeName->GetDefaultHeight());
305  fVolumeName->SetToolTipText("Enter the name for the new volume");
306  f1->AddFrame(fVolumeName, new TGLayoutHints(kLHintsRight, 3, 1, 2, 5));
307  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
308 
309  // ComboBox for shape component
310  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
311  fSelectedShape2 = 0;
312  fLSelShape2 = new TGLabel(f1, "Select shape");
313  gClient->GetColorByName("#0000ff", color);
314  fLSelShape2->SetTextColor(color);
315  fLSelShape2->ChangeOptions(kSunkenFrame | kDoubleBorder);
316  f1->AddFrame(fLSelShape2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
317  fBSelShape2 = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_SHAPE_SELECT2);
318  fBSelShape2->SetToolTipText("Select one of the existing shapes");
319  fBSelShape2->Associate(this);
320  f1->AddFrame(fBSelShape2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
321  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
322 
323  // ComboBox for medium component
324  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
325  fSelectedMedium2 = 0;
326  fLSelMedium2 = new TGLabel(f1, "Select medium");
327  gClient->GetColorByName("#0000ff", color);
328  fLSelMedium2->SetTextColor(color);
329  fLSelMedium2->ChangeOptions(kSunkenFrame | kDoubleBorder);
330  f1->AddFrame(fLSelMedium2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
331  fBSelMedium2 = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_MEDIUM_SELECT2);
332  fBSelMedium2->SetToolTipText("Select one of the existing media");
333  fBSelMedium2->Associate(this);
334  f1->AddFrame(fBSelMedium2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
335  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
336  // Picture buttons for different volumes
337  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
338  f1->AddFrame(new TGLabel(f1, "Create..."), new TGLayoutHints(kLHintsLeft, 1, 5, 6, 0));
339  fVolumeButton[0] = new TGPictureButton(f1, fClient->GetPicture("geovolume_t.xpm"), kCREATE_VOLUME);
340  fVolumeButton[0]->SetToolTipText("Create a new volume from shape and medium");
341  fVolumeButton[1] = new TGPictureButton(f1, fClient->GetPicture("geoassembly_t.xpm"), kCREATE_ASSEMBLY);
342  fVolumeButton[1]->SetToolTipText("Create a new volume assembly having the selected name");
343  for (ipict=0; ipict<2; ipict++) f1->AddFrame(fVolumeButton[ipict],lhb);
344  container->AddFrame(f1, lhf1);
345  // List of volumes
346  f3 = new TGCompositeFrame(container, 155, 10, kVerticalFrame | kFixedWidth);
347  f1 = new TGCompositeFrame(f3, 155, 10, kHorizontalFrame | kFixedWidth);
348  f1->AddFrame(label = new TGLabel(f1, "Existing volumes"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
349  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
350  gClient->GetColorByName("#ff0000", color);
351  label->SetTextColor(color);
352  f3->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
353  f1 = new TGCompositeFrame(f3, 155, 30, kHorizontalFrame | kFixedWidth);
354  fSelectedVolume = 0;
355  fLSelVolume = new TGLabel(f1, "Select volume");
356  gClient->GetColorByName("#0000ff", color);
357  fLSelVolume->SetTextColor(color);
358  fLSelVolume->ChangeOptions(kSunkenFrame | kDoubleBorder);
359  f1->AddFrame(fLSelVolume, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
360  fBSelVolume = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_VOLUME_SELECT);
361  fBSelVolume->SetToolTipText("Select one of the existing volumes");
362  fBSelVolume->Associate(this);
363  f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
364  f3->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
365  f1 = new TGCompositeFrame(f3, 155, 30, kHorizontalFrame | kFixedWidth);
366  fEditVolume = new TGTextButton(f1, " Edit ");
367  f1->AddFrame(fEditVolume, new TGLayoutHints(kLHintsLeft, 20, 1, 2, 2));
368  fEditVolume->SetToolTipText("Edit selected volume");
369  fEditVolume->Associate(this);
370  fSetTopVolume = new TGTextButton(f1, "Set top");
371  f1->AddFrame(fSetTopVolume, new TGLayoutHints(kLHintsRight, 1, 20, 2, 2));
372  fSetTopVolume->SetToolTipText("Set top volume for geometry");
373  fSetTopVolume->Associate(this);
374  f3->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
375  container->AddFrame(f3, new TGLayoutHints(kLHintsLeft, 0, 0, 6, 0));
376 
377  // Materials category
378  si = new TGShutterItem(fCategories, new TGHotString("Materials"),kCAT_MATERIALS);
379  container = (TGCompositeFrame*)si->GetContainer();
380  container->SetBackgroundColor(GetDefaultFrameBackground());
381  fCategories->AddItem(si);
382 
383  // Material creators
384  gGeoManager->BuildDefaultMaterials();
385  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
386  f1->AddFrame(label = new TGLabel(f1, "Create material/mixt."), new TGLayoutHints(kLHintsLeft, 2, 1, 0, 0));
387  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
388  gClient->GetColorByName("#ff0000", color);
389  label->SetTextColor(color);
390  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
391  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
392  f1->AddFrame(new TGLabel(f1, "Name"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
393  fMaterialName = new TGTextEntry(f1, new TGTextBuffer(50), kMATERIAL_NAME);
394  fMaterialName->Resize(100, fMaterialName->GetDefaultHeight());
395  fMaterialName->SetToolTipText("Enter the new material name");
396  f1->AddFrame(fMaterialName, new TGLayoutHints(kLHintsRight, 3, 1, 2, 5));
397  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
398 
399  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
400  f1->AddFrame(new TGLabel(f1, "Element"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
401  fElementList = new TGComboBox(f1, kMANAGER_ELEMENT_SELECT);
402  fElementList->Resize(100, fManagerName->GetDefaultHeight());
403  TGeoElementTable *table = gGeoManager->GetElementTable();
404  if (table) {
405  TGeoElement *element;
406  for (Int_t i=0; i<table->GetNelements(); i++) {
407  element = table->GetElement(i);
408  fElementList->AddEntry(element->GetTitle(),i);
409  }
410  }
411  fElementList->Select(0);
412  f1->AddFrame(fElementList, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
413  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
414  // Number entry for density
415  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
416  f1->AddFrame(new TGLabel(f1, "Density"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
417  fEntryDensity = new TGNumberEntry(f1, 0., 5, kMANAGER_DENSITY_SELECT);
418  fEntryDensity->SetNumStyle(TGNumberFormat::kNESRealThree);
419  fEntryDensity->SetNumAttr(TGNumberFormat::kNEANonNegative);
420  fEntryDensity->Resize(100,fEntryDensity->GetDefaultHeight());
421  TGTextEntry *nef = (TGTextEntry*)fEntryDensity->GetNumberEntry();
422  nef->SetToolTipText("Enter material/mixture density");
423  fEntryDensity->SetNumber(0);
424  fEntryDensity->Associate(this);
425  f1->AddFrame(fEntryDensity, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
426  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
427  // Buttons for creating materials/mixtures
428  // Picture buttons for different volumes
429  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
430  f1->AddFrame(new TGLabel(f1, "Create..."), new TGLayoutHints(kLHintsLeft, 1, 5, 6, 0));
431  fMaterialButton[0] = new TGPictureButton(f1, fClient->GetPicture("geomaterial_t.xpm"), kCREATE_MATERIAL);
432  fMaterialButton[0]->SetToolTipText("Create a new material from element and density");
433  fMaterialButton[1] = new TGPictureButton(f1, fClient->GetPicture("geomixture_t.xpm"), kCREATE_MIXTURE);
434  fMaterialButton[1]->SetToolTipText("Create a new mixture with selected density");
435  for (ipict=0; ipict<2; ipict++) f1->AddFrame(fMaterialButton[ipict],lhb);
436  container->AddFrame(f1, lhf1);
437 
438  // List of materials
439  f4 = new TGCompositeFrame(container, 155, 10, kVerticalFrame | kFixedWidth);
440  f1 = new TGCompositeFrame(f4, 155, 10, kHorizontalFrame | kFixedWidth);
441  f1->AddFrame(label = new TGLabel(f1, "Existing materials"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
442  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
443  gClient->GetColorByName("#ff0000", color);
444  label->SetTextColor(color);
445  f4->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
446  f1 = new TGCompositeFrame(f4, 155, 30, kHorizontalFrame | kFixedWidth);
447  fSelectedMaterial = 0;
448  fLSelMaterial = new TGLabel(f1, "Select material");
449  gClient->GetColorByName("#0000ff", color);
450  fLSelMaterial->SetTextColor(color);
451  fLSelMaterial->ChangeOptions(kSunkenFrame | kDoubleBorder);
452  f1->AddFrame(fLSelMaterial, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
453  fBSelMaterial = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_MATERIAL_SELECT);
454  fBSelMaterial->SetToolTipText("Select one of the existing materials");
455  fBSelMaterial->Associate(this);
456  f1->AddFrame(fBSelMaterial, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
457  fEditMaterial = new TGTextButton(f1, "Edit");
458  f1->AddFrame(fEditMaterial, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
459  fEditMaterial->SetToolTipText("Edit selected material");
460  fEditMaterial->Associate(this);
461  f4->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
462  container->AddFrame(f4, new TGLayoutHints(kLHintsLeft, 0, 0, 6, 0));
463 
464  si = new TGShutterItem(fCategories, new TGHotString("Media"),kCAT_MEDIA);
465  container = (TGCompositeFrame*)si->GetContainer();
466  container->SetBackgroundColor(GetDefaultFrameBackground());
467  fCategories->AddItem(si);
468 
469  // Media category
470  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
471  f1->AddFrame(label = new TGLabel(f1, "Create new medium"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
472  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
473  gClient->GetColorByName("#ff0000", color);
474  label->SetTextColor(color);
475  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
476 
477  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
478  f1->AddFrame(new TGLabel(f1, "Name"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
479  fMediumName = new TGTextEntry(f1, new TGTextBuffer(50), kMEDIUM_NAME);
480  fMediumName->Resize(60, fMediumName->GetDefaultHeight());
481  fMediumName->SetToolTipText("Enter the new medium name");
482  f1->AddFrame(fMediumName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
483 
484  fMediumId = new TGNumberEntry(f1, 0., 5, kMEDIUM_ID);
485  fMediumId->SetNumStyle(TGNumberFormat::kNESInteger);
486  fMediumId->SetNumAttr(TGNumberFormat::kNEAPositive);
487  fMediumId->Resize(35,fMediumId->GetDefaultHeight());
488  nef = (TGTextEntry*)fMediumId->GetNumberEntry();
489  nef->SetToolTipText("Enter medium ID");
490  fMediumId->SetNumber(fGeometry->GetListOfMedia()->GetSize());
491  fMediumId->Associate(this);
492  f1->AddFrame(fMediumId, new TGLayoutHints(kLHintsRight, 2, 2, 2 ,2));
493  f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsRight, 1, 1, 6, 0));
494  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
495  // ComboBox for materials
496  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
497  fSelectedMaterial2 = 0;
498  fLSelMaterial2 = new TGLabel(f1, "Select material");
499  gClient->GetColorByName("#0000ff", color);
500  fLSelMaterial2->SetTextColor(color);
501  fLSelMaterial2->ChangeOptions(kSunkenFrame | kDoubleBorder);
502  f1->AddFrame(fLSelMaterial2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
503  fBSelMaterial2 = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_MATERIAL_SELECT2);
504  fBSelMaterial2->SetToolTipText("Select one of the existing materials");
505  fBSelMaterial2->Associate(this);
506  f1->AddFrame(fBSelMaterial2, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
507  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
508  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
509  f1->AddFrame(new TGLabel(f1, "Create..."), new TGLayoutHints(kLHintsLeft, 1, 5, 6, 0));
510  fMediumButton = new TGPictureButton(f1, fClient->GetPicture("geomedium_t.xpm"), kCREATE_MEDIUM);
511  fMediumButton->SetToolTipText("Create a new medium from selected material");
512  fMediumButton->Associate(this);
513  f1->AddFrame(fMediumButton, new TGLayoutHints(kLHintsLeft, 5, 2, 2, 2));
514  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
515 
516  // List of media
517  f5 = new TGCompositeFrame(container, 155, 10, kVerticalFrame | kFixedWidth);
518  f1 = new TGCompositeFrame(f5, 145, 10, kHorizontalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
519  f1->AddFrame(label = new TGLabel(f1, "Existing media"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
520  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
521  gClient->GetColorByName("#ff0000", color);
522  label->SetTextColor(color);
523  f5->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
524  f1 = new TGCompositeFrame(f5, 155, 30, kHorizontalFrame | kFixedWidth);
525  fSelectedMedium = 0;
526  fLSelMedium = new TGLabel(f1, "Select medium");
527  gClient->GetColorByName("#0000ff", color);
528  fLSelMedium->SetTextColor(color);
529  fLSelMedium->ChangeOptions(kSunkenFrame | kDoubleBorder);
530  f1->AddFrame(fLSelMedium, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
531  fBSelMedium = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_MEDIA_SELECT);
532  fBSelMedium->SetToolTipText("Select one of the existing media");
533  fBSelMedium->Associate(this);
534  f1->AddFrame(fBSelMedium, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
535  fEditMedium = new TGTextButton(f1, "Edit");
536  f1->AddFrame(fEditMedium, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
537  fEditMedium->SetToolTipText("Edit selected medium");
538  fEditMedium->Associate(this);
539  f5->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
540  container->AddFrame(f5, new TGLayoutHints(kLHintsLeft, 0, 0, 6, 0));
541 
542  // Matrix category
543  si = new TGShutterItem(fCategories, new TGHotString("Matrices"),kCAT_MATRICES);
544  container = (TGCompositeFrame*)si->GetContainer();
545  container->SetBackgroundColor(GetDefaultFrameBackground());
546  fCategories->AddItem(si);
547  // Name entry
548  f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
549  f1->AddFrame(label = new TGLabel(f1, "Create new matrix"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
550  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
551  gClient->GetColorByName("#ff0000", color);
552  label->SetTextColor(color);
553  container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
554 
555  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
556  f1->AddFrame(new TGLabel(f1, "Name"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
557  fMatrixName = new TGTextEntry(f1, new TGTextBuffer(50), kMATRIX_NAME);
558  fMatrixName->Resize(100, fMatrixName->GetDefaultHeight());
559  fMatrixName->SetToolTipText("Enter the new matrix name");
560  f1->AddFrame(fMatrixName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
561  container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
562  // Picture buttons for different matrices
563  f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
564  f1->AddFrame(new TGLabel(f1, "Create..."), new TGLayoutHints(kLHintsLeft, 1, 5, 6, 0));
565  fMatrixButton[0] = new TGPictureButton(f1, fClient->GetPicture("geotranslation_t.xpm"), kCREATE_TRANSLATION);
566  fMatrixButton[0]->SetToolTipText("Create a translation");
567  fMatrixButton[1] = new TGPictureButton(f1, fClient->GetPicture("georotation_t.xpm"), kCREATE_ROTATION);
568  fMatrixButton[1]->SetToolTipText("Create a rotation");
569  fMatrixButton[2] = new TGPictureButton(f1, fClient->GetPicture("geocombi_t.xpm"), kCREATE_COMBI);
570  fMatrixButton[2]->SetToolTipText("Create a rotation + translation");
571  for (ipict=0; ipict<3; ipict++) f1->AddFrame(fMatrixButton[ipict],lhb);
572  container->AddFrame(f1, lhf1);
573  // List of matrices
574  f6 = new TGCompositeFrame(container, 155, 10, kVerticalFrame | kFixedWidth);
575  f1 = new TGCompositeFrame(f6, 155, 10, kHorizontalFrame | kFixedWidth);
576  f1->AddFrame(label = new TGLabel(f1, "Existing matrices"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
577  f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
578  gClient->GetColorByName("#ff0000", color);
579  label->SetTextColor(color);
580  f6->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
581  f1 = new TGCompositeFrame(f6, 155, 30, kHorizontalFrame | kFixedWidth);
582  fSelectedMatrix = 0;
583  fLSelMatrix = new TGLabel(f1, "Select matrix");
584  gClient->GetColorByName("#0000ff", color);
585  fLSelMatrix->SetTextColor(color);
586  fLSelMatrix->ChangeOptions(kSunkenFrame | kDoubleBorder);
587  f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
588  fBSelMatrix = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMANAGER_MATRIX_SELECT);
589  fBSelMatrix->SetToolTipText("Select one of the existing matrices");
590  fBSelMatrix->Associate(this);
591  f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
592  fEditMatrix = new TGTextButton(f1, "Edit");
593  f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
594  fEditMatrix->SetToolTipText("Edit selected matrix");
595  fEditMatrix->Associate(this);
596  f6->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
597  container->AddFrame(f6, new TGLayoutHints(kLHintsLeft, 0, 0, 6, 0));
598 
599  fCategories->Resize(163,370);
600  AddFrame(fCategories, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 4));
601 
602  fVolumeTab = CreateEditorTabSubFrame("Volume");
603 
604  // Set the fTab and disconnect editor from the canvas.
605  fTab = fGedEditor->GetTab();
606  TCanvas* edCanvas = fGedEditor->GetCanvas();
607  fGedEditor->DisconnectFromCanvas();
608  if (edCanvas != fConnectedCanvas) {
609  DisconnectSelected();
610  if (edCanvas)
611  ConnectSelected(edCanvas);
612  fConnectedCanvas = edCanvas;
613  }
614 }
615 
616 ////////////////////////////////////////////////////////////////////////////////
617 /// Destructor.
618 
619 TGeoManagerEditor::~TGeoManagerEditor()
620 {
621  TGCompositeFrame *cont;
622  cont = (TGCompositeFrame*)fCategories->GetItem("General")->GetContainer();
623  TGeoTabManager::Cleanup(cont);
624  fCategories->GetItem("General")->SetCleanup(0);
625  cont = (TGCompositeFrame*)fCategories->GetItem("Shapes")->GetContainer();
626  TGeoTabManager::Cleanup(cont);
627  fCategories->GetItem("Shapes")->SetCleanup(0);
628  cont = (TGCompositeFrame*)fCategories->GetItem("Volumes")->GetContainer();
629  TGeoTabManager::Cleanup(cont);
630  fCategories->GetItem("Volumes")->SetCleanup(0);
631  cont = (TGCompositeFrame*)fCategories->GetItem("Materials")->GetContainer();
632  TGeoTabManager::Cleanup(cont);
633  fCategories->GetItem("Materials")->SetCleanup(0);
634  cont = (TGCompositeFrame*)fCategories->GetItem("Media")->GetContainer();
635  TGeoTabManager::Cleanup(cont);
636  fCategories->GetItem("Media")->SetCleanup(0);
637  cont = (TGCompositeFrame*)fCategories->GetItem("Matrices")->GetContainer();
638  TGeoTabManager::Cleanup(cont);
639  fCategories->GetItem("Matrices")->SetCleanup(0);
640 
641  delete fExportOption[0]; delete fExportOption[1];
642 
643  Cleanup();
644 
645  if (fTabMgr) {
646  fTabMgr->GetVolumeTab()->Cleanup();
647  delete fTabMgr;
648  }
649 }
650 
651 ////////////////////////////////////////////////////////////////////////////////
652 /// Connected to TCanvas::Selected. TGeoManagerEditor takes this
653 /// function from TGedEditor and only uses it if obj is a TGeoVolume.
654 
655 void TGeoManagerEditor::SelectedSlot(TVirtualPad* /*pad*/, TObject* obj, Int_t event)
656 {
657  if (event == kButton1 && obj->InheritsFrom(TGeoVolume::Class())) {
658  TGeoVolume* v = (TGeoVolume*) obj;
659  fTabMgr->SetVolTabEnabled();
660  fTabMgr->SetTab();
661  fTabMgr->GetVolumeEditor(v);
662  v->Draw();
663  }
664 }
665 
666 void TGeoManagerEditor::ConnectSelected(TCanvas *c)
667 {
668  // Connect to TCanvas::Selected.
669 
670  c->Connect("Selected(TVirtualPad*,TObject*,Int_t)", "TGeoManagerEditor",
671  this, "SelectedSlot(TVirtualPad*,TObject*,Int_t)");
672 }
673 
674 void TGeoManagerEditor::DisconnectSelected()
675 {
676  // Disconnect from TCanvas::Selected.
677 
678  if (fConnectedCanvas)
679  Disconnect(fConnectedCanvas, "Selected(TVirtualPad*,TObject*,Int_t)",
680  this, "SelectedSlot(TVirtualPad*,TObject*,Int_t)");
681 
682 }
683 
684 ////////////////////////////////////////////////////////////////////////////////
685 /// Connect signals to slots.
686 
687 void TGeoManagerEditor::ConnectSignals2Slots()
688 {
689  fManagerName->Connect("TextChanged(const char *)", "TGeoManagerEditor", this, "DoName()");
690  fManagerTitle->Connect("TextChanged(const char *)", "TGeoManagerEditor", this, "DoName()");
691  fExportButton->Connect("Clicked()", "TGeoManagerEditor", this, "DoExportGeometry()");
692  fCloseGeometry->Connect("Clicked()", "TGeoManagerEditor", this, "DoCloseGeometry()");
693  fShapeButton[0]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateBox()");
694  fShapeButton[1]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreatePara()");
695  fShapeButton[2]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTrd1()");
696  fShapeButton[3]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTrd2()");
697  fShapeButton[4]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTrap()");
698  fShapeButton[5]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateGtra()");
699  fShapeButton[6]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateXtru()");
700  fShapeButton[7]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateArb8()");
701  fShapeButton[8]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTube()");
702  fShapeButton[9]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTubs()");
703  fShapeButton[10]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateCone()");
704  fShapeButton[11]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateCons()");
705  fShapeButton[12]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateSphe()");
706  fShapeButton[13]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateCtub()");
707  fShapeButton[14]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateEltu()");
708  fShapeButton[15]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTorus()");
709  fShapeButton[16]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreatePcon()");
710  fShapeButton[17]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreatePgon()");
711  fShapeButton[18]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateHype()");
712  fShapeButton[19]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateParab()");
713  fShapeButton[20]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateComposite()");
714  fMatrixButton[0]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateTranslation()");
715  fMatrixButton[1]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateRotation()");
716  fMatrixButton[2]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateCombi()");
717  fVolumeButton[0]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateVolume()");
718  fVolumeButton[1]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateAssembly()");
719  fBSelTop->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectTopVolume()");
720  fBSelVolume->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectVolume()");
721  fBSelShape->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectShape()");
722  fBSelShape2->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectShape2()");
723  fBSelMatrix->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectMatrix()");
724  fBSelMaterial->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectMaterial()");
725  fBSelMaterial2->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectMaterial2()");
726  fBSelMedium->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectMedium()");
727  fBSelMedium2->Connect("Clicked()", "TGeoManagerEditor", this, "DoSelectMedium2()");
728  fSetTopVolume->Connect("Clicked()", "TGeoManagerEditor", this, "DoSetTopVolume()");
729  fEditShape->Connect("Clicked()", "TGeoManagerEditor", this, "DoEditShape()");
730  fEditMedium->Connect("Clicked()", "TGeoManagerEditor", this, "DoEditMedium()");
731  fEditMaterial->Connect("Clicked()", "TGeoManagerEditor", this, "DoEditMaterial()");
732  fEditMatrix->Connect("Clicked()", "TGeoManagerEditor", this, "DoEditMatrix()");
733  fEditVolume->Connect("Clicked()", "TGeoManagerEditor", this, "DoEditVolume()");
734 
735  fMaterialButton[0]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateMaterial()");
736  fMaterialButton[1]->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateMixture()");
737  fMediumButton->Connect("Clicked()", "TGeoManagerEditor", this, "DoCreateMedium()");
738 }
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 /// Refresh editor according the selected obj.
742 
743 void TGeoManagerEditor::SetModel(TObject* obj)
744 {
745  fGeometry = (TGeoManager*)obj;
746  fManagerName->SetText(fGeometry->GetName());
747  fManagerTitle->SetText(fGeometry->GetTitle());
748  fMatrixName->SetText(TString::Format("matrix%i", fGeometry->GetListOfMatrices()->GetEntries()));
749  fMaterialName->SetText(TString::Format("material%i", fGeometry->GetListOfMaterials()->GetSize()));
750  fMediumName->SetText(TString::Format("medium%i", fGeometry->GetListOfMedia()->GetSize()));
751  fVolumeName->SetText(TString::Format("volume%i", fGeometry->GetListOfVolumes()->GetEntries()));
752  // Check if master volume can be set
753  if (fGeometry->GetMasterVolume()) fSetTopVolume->SetEnabled(kFALSE);
754  else fSetTopVolume->SetEnabled(kTRUE);
755  // Check if geometry is already closed
756  if (!fGeometry->IsClosed()) fCloseGeometry->SetEnabled(kTRUE);
757  else {
758  fCloseGeometry->SetEnabled(kFALSE);
759  fBSelTop->SetEnabled(kFALSE);
760  }
761  // Check if volumes category can be activated
762  if (!fGeometry->GetListOfShapes()->GetEntries() || !fGeometry->GetListOfMedia()->GetSize())
763  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kFALSE);
764  else
765  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
766  if (!fGeometry->GetListOfShapes()->GetEntries()) ShowSelectShape(kFALSE);
767  else ShowSelectShape();
768  if (!fGeometry->GetListOfVolumes()->GetEntries()) ShowSelectVolume(kFALSE);
769  else ShowSelectVolume();
770  if (!fGeometry->GetListOfMedia()->GetSize()) ShowSelectMedium(kFALSE);
771  else ShowSelectMedium();
772  if (!fGeometry->GetListOfMatrices()->GetEntries()) ShowSelectMatrix(kFALSE);
773  else ShowSelectMatrix();
774 
775  // Check if media category can be activated
776  if (!fGeometry->GetListOfMaterials()->GetSize()) {
777  fCategories->GetItem("Media")->GetButton()->SetEnabled(kFALSE);
778  ShowSelectMaterial(kFALSE);
779  } else {
780  fCategories->GetItem("Media")->GetButton()->SetEnabled(kTRUE);
781  ShowSelectMaterial();
782  }
783 
784  fTab->SetTab(0);
785  fCategories->Layout();
786  if (fTabMgr == 0) {
787  fTabMgr = TGeoTabManager::GetMakeTabManager(fGedEditor);
788  fTabMgr->fVolumeTab = fVolumeTab;
789  }
790  if (fInit) ConnectSignals2Slots();
791  // SetActive();
792 }
793 
794 ////////////////////////////////////////////////////////////////////////////////
795 /// Change name/title of the geometry
796 
797 void TGeoManagerEditor::DoName()
798 {
799  fGeometry->SetName(fManagerName->GetText());
800  fGeometry->SetTitle(fManagerTitle->GetText());
801 }
802 
803 ////////////////////////////////////////////////////////////////////////////////
804 /// Export geometry as .root or .C file
805 
806 void TGeoManagerEditor::DoExportGeometry()
807 {
808  Bool_t asroot = fExportOption[0]->IsDown();
809  TString s = fGeometry->GetName();
810  s = s.Strip();
811  s.Remove(20);
812  const char *name;
813  if (asroot) name = TString::Format("%s.root", s.Data());
814  else name = TString::Format("%s.C", s.Data());
815  fGeometry->Export(name);
816 }
817 
818 ////////////////////////////////////////////////////////////////////////////////
819 /// Create a box.
820 
821 void TGeoManagerEditor::DoCreateBox()
822 {
823  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
824  fSelectedShape = new TGeoBBox(TString::Format("box_%i",id), 1., 1., 1.);
825  ShowSelectShape();
826  // Check if volumes category can be activated
827  if (fGeometry->GetListOfMedia()->GetSize())
828  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
829  DoEditShape();
830 }
831 
832 ////////////////////////////////////////////////////////////////////////////////
833 /// Create a parallelipiped.
834 
835 void TGeoManagerEditor::DoCreatePara()
836 {
837  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
838  fSelectedShape = new TGeoPara(TString::Format("para_%i",id), 1., 1., 1., 30., 20., 45.);
839  ShowSelectShape();
840  if (fGeometry->GetListOfMedia()->GetSize())
841  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
842  DoEditShape();
843 }
844 
845 ////////////////////////////////////////////////////////////////////////////////
846 /// Create a Trd1.
847 
848 void TGeoManagerEditor::DoCreateTrd1()
849 {
850  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
851  fSelectedShape = new TGeoTrd1(TString::Format("trd1_%i",id), 0.5, 1., 1., 1.);
852  ShowSelectShape();
853  if (fGeometry->GetListOfMedia()->GetSize())
854  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
855  DoEditShape();
856 }
857 
858 ////////////////////////////////////////////////////////////////////////////////
859 /// Create a Trd2.
860 
861 void TGeoManagerEditor::DoCreateTrd2()
862 {
863  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
864  fSelectedShape = new TGeoTrd2(TString::Format("trd2_%i",id), 0.5, 1., 0.5, 1., 1.);
865  ShowSelectShape();
866  if (fGeometry->GetListOfMedia()->GetSize())
867  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
868  DoEditShape();
869 }
870 
871 ////////////////////////////////////////////////////////////////////////////////
872 /// Create a general trapezoid.
873 
874 void TGeoManagerEditor::DoCreateTrap()
875 {
876  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
877  fSelectedShape = new TGeoTrap(TString::Format("trap_%i",id), 1., 15., 45., 0.5, 0.3, 0.5, 30., 0.5, 0.3, 0.5, 30.);
878  ShowSelectShape();
879  if (fGeometry->GetListOfMedia()->GetSize())
880  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
881  DoEditShape();
882 }
883 
884 ////////////////////////////////////////////////////////////////////////////////
885 /// Create a twisted trapezoid.
886 
887 void TGeoManagerEditor::DoCreateGtra()
888 {
889  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
890  fSelectedShape = new TGeoGtra(TString::Format("gtra_%i",id), 1., 15., 45., 45.,0.5, 0.3, 0.5, 30., 0.5, 0.3, 0.5, 30.);
891  ShowSelectShape();
892  if (fGeometry->GetListOfMedia()->GetSize())
893  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
894  DoEditShape();
895 }
896 
897 ////////////////////////////////////////////////////////////////////////////////
898 /// Create an extruded polygone.
899 
900 void TGeoManagerEditor::DoCreateXtru()
901 {
902 }
903 
904 ////////////////////////////////////////////////////////////////////////////////
905 /// Create an arbitrary polygone with maximum 8 vertices sitting on 2 parallel
906 /// planes
907 
908 void TGeoManagerEditor::DoCreateArb8()
909 {
910 }
911 
912 ////////////////////////////////////////////////////////////////////////////////
913 /// Create a tube.
914 
915 void TGeoManagerEditor::DoCreateTube()
916 {
917  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
918  fSelectedShape = new TGeoTube(TString::Format("tube_%i",id), 0.5, 1., 1.);
919  ShowSelectShape();
920  if (fGeometry->GetListOfMedia()->GetSize())
921  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
922  DoEditShape();
923 }
924 
925 ////////////////////////////////////////////////////////////////////////////////
926 /// Create a tube segment.
927 
928 void TGeoManagerEditor::DoCreateTubs()
929 {
930  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
931  fSelectedShape = new TGeoTubeSeg(TString::Format("tubs_%i",id), 0.5, 1., 1.,0.,45.);
932  ShowSelectShape();
933  if (fGeometry->GetListOfMedia()->GetSize())
934  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
935  DoEditShape();
936 }
937 
938 ////////////////////////////////////////////////////////////////////////////////
939 /// Create a cone.
940 
941 void TGeoManagerEditor::DoCreateCone()
942 {
943  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
944  fSelectedShape = new TGeoCone(TString::Format("cone_%i",id), 0.5, 0.5, 1., 1.5, 2.);
945  ShowSelectShape();
946  if (fGeometry->GetListOfMedia()->GetSize())
947  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
948  DoEditShape();
949 }
950 
951 ////////////////////////////////////////////////////////////////////////////////
952 /// Create a cone segment.
953 
954 void TGeoManagerEditor::DoCreateCons()
955 {
956  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
957  fSelectedShape = new TGeoConeSeg(TString::Format("cons_%i",id), 0.5, 0.5, 1., 1.5, 2.,0.,45.);
958  ShowSelectShape();
959  if (fGeometry->GetListOfMedia()->GetSize())
960  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
961  DoEditShape();
962 }
963 
964 ////////////////////////////////////////////////////////////////////////////////
965 /// Create a sphere.
966 
967 void TGeoManagerEditor::DoCreateSphe()
968 {
969  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
970  fSelectedShape = new TGeoSphere(TString::Format("sphere_%i",id), 0.5, 1., 0., 180., 0.,360.);
971  ShowSelectShape();
972  if (fGeometry->GetListOfMedia()->GetSize())
973  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
974  DoEditShape();
975 }
976 
977 ////////////////////////////////////////////////////////////////////////////////
978 /// Create a cut tube.
979 
980 void TGeoManagerEditor::DoCreateCtub()
981 {
982  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
983  fSelectedShape = new TGeoCtub(TString::Format("ctub_%i",id), 0.5, 1., 1.,0.,45.,0.,0.,-1,0.,0.,1);
984  ShowSelectShape();
985  if (fGeometry->GetListOfMedia()->GetSize())
986  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
987  DoEditShape();
988 }
989 
990 ////////////////////////////////////////////////////////////////////////////////
991 /// Create an elliptical tube.
992 
993 void TGeoManagerEditor::DoCreateEltu()
994 {
995  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
996  fSelectedShape = new TGeoEltu(TString::Format("para_%i",id), 1., 2., 1.5 );
997  ShowSelectShape();
998  if (fGeometry->GetListOfMedia()->GetSize())
999  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
1000  DoEditShape();
1001 }
1002 
1003 ////////////////////////////////////////////////////////////////////////////////
1004 /// Create a torus shape.
1005 
1006 void TGeoManagerEditor::DoCreateTorus()
1007 {
1008  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
1009  fSelectedShape = new TGeoTorus(TString::Format("torus_%i",id), 10., 1., 1.5, 0, 360.);
1010  ShowSelectShape();
1011  if (fGeometry->GetListOfMedia()->GetSize())
1012  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
1013  DoEditShape();
1014 
1015 }
1016 
1017 ////////////////////////////////////////////////////////////////////////////////
1018 /// Create a polycone shape.
1019 
1020 void TGeoManagerEditor::DoCreatePcon()
1021 {
1022  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
1023  fSelectedShape = new TGeoPcon(TString::Format("pcon_%i",id), 0., 360., 2);
1024  ((TGeoPcon*)fSelectedShape)->DefineSection(0, -1, 0.5, 1.);
1025  ((TGeoPcon*)fSelectedShape)->DefineSection(1, 1, 0.2, 0.5);
1026  ShowSelectShape();
1027  if (fGeometry->GetListOfMedia()->GetSize())
1028  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
1029  DoEditShape();
1030 }
1031 
1032 ////////////////////////////////////////////////////////////////////////////////
1033 /// Create a polygone shape.
1034 
1035 void TGeoManagerEditor::DoCreatePgon()
1036 {
1037  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
1038  fSelectedShape = new TGeoPgon(TString::Format("pgon_%i",id), 0., 360.,6,2);
1039  ((TGeoPcon*)fSelectedShape)->DefineSection(0, -1, 0.5, 1.);
1040  ((TGeoPcon*)fSelectedShape)->DefineSection(1, 1, 0.2, 0.5);
1041  ShowSelectShape();
1042  if (fGeometry->GetListOfMedia()->GetSize())
1043  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
1044  DoEditShape();
1045 }
1046 
1047 ////////////////////////////////////////////////////////////////////////////////
1048 /// Create a hyperboloid.
1049 
1050 void TGeoManagerEditor::DoCreateHype()
1051 {
1052  Int_t id = gGeoManager->GetListOfShapes()->GetEntries();
1053  fSelectedShape = new TGeoHype(TString::Format("hype_%i",id), 1., 15., 2., 30., 5.);
1054  ShowSelectShape();
1055  if (fGeometry->GetListOfMedia()->GetSize())
1056  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
1057  DoEditShape();
1058 }
1059 
1060 ////////////////////////////////////////////////////////////////////////////////
1061 /// Create a paraboloid.
1062 
1063 void TGeoManagerEditor::DoCreateParab()
1064 {
1065 }
1066 
1067 ////////////////////////////////////////////////////////////////////////////////
1068 /// Create a composite shape.
1069 
1070 void TGeoManagerEditor::DoCreateComposite()
1071 {
1072 }
1073 
1074 ////////////////////////////////////////////////////////////////////////////////
1075 /// Create a new material.
1076 
1077 void TGeoManagerEditor::DoCreateMaterial()
1078 {
1079  TGeoElement *el = fGeometry->GetElementTable()->GetElement(fElementList->GetSelected());
1080  if (!el) {
1081  Error("DoCreateMaterial", "Cannot find selected element in list");
1082  return;
1083  }
1084  Double_t density = fEntryDensity->GetNumber();
1085  const char *name = fMaterialName->GetText();
1086  fSelectedMaterial = new TGeoMaterial(name, el, density);
1087  ShowSelectMaterial();
1088  fCategories->GetItem("Media")->GetButton()->SetEnabled(kTRUE);
1089  DoEditMaterial();
1090  fMaterialName->SetText(TString::Format("material%i", fGeometry->GetListOfMaterials()->GetSize()));
1091 }
1092 
1093 ////////////////////////////////////////////////////////////////////////////////
1094 /// Create a new mixture.
1095 
1096 void TGeoManagerEditor::DoCreateMixture()
1097 {
1098  Double_t density = fEntryDensity->GetNumber();
1099  const char *name = fMaterialName->GetText();
1100  fSelectedMaterial = new TGeoMixture(name, 1, density);
1101  ShowSelectMaterial();
1102  fCategories->GetItem("Media")->GetButton()->SetEnabled(kTRUE);
1103  DoEditMaterial();
1104  fMaterialName->SetText(TString::Format("material%i", fGeometry->GetListOfMaterials()->GetSize()));
1105 }
1106 
1107 ////////////////////////////////////////////////////////////////////////////////
1108 /// Create a new medium.
1109 
1110 void TGeoManagerEditor::DoCreateMedium()
1111 {
1112  Int_t id = fMediumId->GetIntNumber();
1113  if (!fSelectedMaterial2) return;
1114  const char *name = fMediumName->GetText();
1115  fSelectedMedium = new TGeoMedium(name, id, fSelectedMaterial2);
1116  ShowSelectMedium();
1117  if (fGeometry->GetListOfShapes()->GetEntries())
1118  fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE);
1119  DoEditMedium();
1120  fMediumName->SetText(TString::Format("medium%i", fGeometry->GetListOfMedia()->GetSize()));
1121 }
1122 
1123 ////////////////////////////////////////////////////////////////////////////////
1124 /// Create a new translation.
1125 
1126 void TGeoManagerEditor::DoCreateTranslation()
1127 {
1128  const char *name = fMatrixName->GetText();
1129  fSelectedMatrix = new TGeoTranslation(name, 0., 0., 0.);
1130  fSelectedMatrix->SetBit(TGeoMatrix::kGeoTranslation);
1131  fSelectedMatrix->RegisterYourself();
1132  ShowSelectMatrix();
1133  DoEditMatrix();
1134  fMatrixName->SetText(TString::Format("matrix%i", fGeometry->GetListOfMatrices()->GetEntries()));
1135 }
1136 
1137 ////////////////////////////////////////////////////////////////////////////////
1138 /// Create a new rotation.
1139 
1140 void TGeoManagerEditor::DoCreateRotation()
1141 {
1142  const char *name = fMatrixName->GetText();
1143  fSelectedMatrix = new TGeoRotation(name);
1144  fSelectedMatrix->SetBit(TGeoMatrix::kGeoRotation);
1145  fSelectedMatrix->RegisterYourself();
1146  ShowSelectMatrix();
1147  DoEditMatrix();
1148  fMatrixName->SetText(TString::Format("matrix%i", fGeometry->GetListOfMatrices()->GetEntries()));
1149 }
1150 
1151 ////////////////////////////////////////////////////////////////////////////////
1152 /// Create a new volume.
1153 
1154 void TGeoManagerEditor::DoCreateVolume()
1155 {
1156  const char *name = fVolumeName->GetText();
1157  if (!fSelectedShape2 || !fSelectedMedium2) return;
1158  fSelectedVolume = new TGeoVolume(name, fSelectedShape2, fSelectedMedium2);
1159  fLSelVolume->SetText(name);
1160  ShowSelectVolume();
1161  DoEditVolume();
1162  fVolumeName->SetText(TString::Format("volume%i", fGeometry->GetListOfVolumes()->GetEntries()));
1163 }
1164 
1165 ////////////////////////////////////////////////////////////////////////////////
1166 /// Create a new volume assembly.
1167 
1168 void TGeoManagerEditor::DoCreateAssembly()
1169 {
1170  const char *name = fVolumeName->GetText();
1171  fSelectedVolume = new TGeoVolumeAssembly(name);
1172  fLSelVolume->SetText(name);
1173  ShowSelectVolume();
1174  DoEditVolume();
1175  fVolumeName->SetText(TString::Format("volume%i", fGeometry->GetListOfVolumes()->GetEntries()));
1176 }
1177 
1178 ////////////////////////////////////////////////////////////////////////////////
1179 /// Create a new translation + rotation.
1180 
1181 void TGeoManagerEditor::DoCreateCombi()
1182 {
1183  const char *name = fMatrixName->GetText();
1184  fSelectedMatrix = new TGeoCombiTrans(name, 0., 0., 0., new TGeoRotation());
1185  fSelectedMatrix->RegisterYourself();
1186  fSelectedMatrix->SetBit(TGeoMatrix::kGeoTranslation);
1187  fSelectedMatrix->SetBit(TGeoMatrix::kGeoRotation);
1188  ShowSelectMatrix();
1189  DoEditMatrix();
1190  fMatrixName->SetText(TString::Format("matrix%i", fGeometry->GetListOfMatrices()->GetEntries()));
1191 }
1192 
1193 ////////////////////////////////////////////////////////////////////////////////
1194 /// Set top volume for the geometry.
1195 
1196 void TGeoManagerEditor::DoSetTopVolume()
1197 {
1198  if (!fSelectedVolume) return;
1199  fGeometry->SetTopVolume(fSelectedVolume);
1200  fSetTopVolume->SetEnabled(kFALSE);
1201 }
1202 
1203 ////////////////////////////////////////////////////////////////////////////////
1204 /// Slot for editing selected shape.
1205 
1206 void TGeoManagerEditor::DoEditShape()
1207 {
1208  if (!fSelectedShape) return;
1209  fTabMgr->GetShapeEditor(fSelectedShape);
1210  fSelectedShape->Draw();
1211  fTabMgr->GetPad()->GetView()->ShowAxis();
1212 }
1213 
1214 ////////////////////////////////////////////////////////////////////////////////
1215 /// Slot for editing selected volume.
1216 
1217 void TGeoManagerEditor::DoEditVolume()
1218 {
1219  if (!fSelectedVolume) {
1220  fTabMgr->SetVolTabEnabled(kFALSE);
1221  return;
1222  }
1223  fTabMgr->SetVolTabEnabled();
1224  fTabMgr->SetTab();
1225  fTabMgr->GetVolumeEditor(fSelectedVolume);
1226  fSelectedVolume->Draw();
1227 }
1228 
1229 ////////////////////////////////////////////////////////////////////////////////
1230 /// Slot for editing selected medium.
1231 
1232 void TGeoManagerEditor::DoEditMedium()
1233 {
1234  if (!fSelectedMedium) return;
1235  fTabMgr->GetMediumEditor(fSelectedMedium);
1236 }
1237 
1238 ////////////////////////////////////////////////////////////////////////////////
1239 /// Slot for editing selected material.
1240 
1241 void TGeoManagerEditor::DoEditMaterial()
1242 {
1243  if (!fSelectedMaterial) return;
1244  fTabMgr->GetMaterialEditor(fSelectedMaterial);
1245 }
1246 
1247 ////////////////////////////////////////////////////////////////////////////////
1248 /// Slot for editing selected matrix.
1249 
1250 void TGeoManagerEditor::DoEditMatrix()
1251 {
1252  if (!fSelectedMatrix) return;
1253  fTabMgr->GetMatrixEditor(fSelectedMatrix);
1254 }
1255 
1256 ////////////////////////////////////////////////////////////////////////////////
1257 /// Slot for selecting an existing matrix.
1258 
1259 void TGeoManagerEditor::DoSelectMatrix()
1260 {
1261  TGeoMatrix *matrix = fSelectedMatrix;
1262  new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200,300);
1263  fSelectedMatrix = (TGeoMatrix*)TGeoMatrixDialog::GetSelected();
1264  if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName());
1265  else fSelectedMatrix = matrix;
1266 }
1267 
1268 ////////////////////////////////////////////////////////////////////////////////
1269 /// Slot for selecting an existing shape.
1270 
1271 void TGeoManagerEditor::DoSelectShape()
1272 {
1273  TGeoShape *shape = fSelectedShape;
1274  new TGeoShapeDialog(fBSelShape, gClient->GetRoot(), 200,300);
1275  fSelectedShape = (TGeoShape*)TGeoShapeDialog::GetSelected();
1276  if (fSelectedShape) fLSelShape->SetText(fSelectedShape->GetName());
1277  else fSelectedShape = shape;
1278 }
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Slot for selecting a shape for making a volume.
1282 
1283 void TGeoManagerEditor::DoSelectShape2()
1284 {
1285  TGeoShape *shape = fSelectedShape2;
1286  new TGeoShapeDialog(fBSelShape2, gClient->GetRoot(), 200,300);
1287  fSelectedShape2 = (TGeoShape*)TGeoShapeDialog::GetSelected();
1288  if (fSelectedShape2) fLSelShape2->SetText(fSelectedShape2->GetName());
1289  else fSelectedShape2 = shape;
1290 }
1291 
1292 ////////////////////////////////////////////////////////////////////////////////
1293 /// Slot for selecting an existing material.
1294 
1295 void TGeoManagerEditor::DoSelectMaterial()
1296 {
1297  TGeoMaterial *mat = fSelectedMaterial;
1298  new TGeoMaterialDialog(fBSelMaterial, gClient->GetRoot(), 200,300);
1299  fSelectedMaterial = (TGeoMaterial*)TGeoMaterialDialog::GetSelected();
1300  if (fSelectedMaterial) fLSelMaterial->SetText(fSelectedMaterial->GetName());
1301  else fSelectedMaterial = mat;
1302 }
1303 
1304 ////////////////////////////////////////////////////////////////////////////////
1305 /// Slot for selecting an existing material and making a medium.
1306 
1307 void TGeoManagerEditor::DoSelectMaterial2()
1308 {
1309  TGeoMaterial *mat = fSelectedMaterial2;
1310  new TGeoMaterialDialog(fBSelMaterial2, gClient->GetRoot(), 200,300);
1311  fSelectedMaterial2 = (TGeoMaterial*)TGeoMaterialDialog::GetSelected();
1312  if (fSelectedMaterial2) fLSelMaterial2->SetText(fSelectedMaterial2->GetName());
1313  else fSelectedMaterial2 = mat;
1314 }
1315 
1316 ////////////////////////////////////////////////////////////////////////////////
1317 /// Slot for selecting an existing medium.
1318 
1319 void TGeoManagerEditor::DoSelectMedium()
1320 {
1321  TGeoMedium *med = fSelectedMedium;
1322  new TGeoMediumDialog(fBSelMedium, gClient->GetRoot(), 200,300);
1323  fSelectedMedium = (TGeoMedium*)TGeoMediumDialog::GetSelected();
1324  if (fSelectedMedium) fLSelMedium->SetText(fSelectedMedium->GetName());
1325  else fSelectedMedium = med;
1326 }
1327 
1328 ////////////////////////////////////////////////////////////////////////////////
1329 /// Slot for selecting an existing medium for making a volume.
1330 
1331 void TGeoManagerEditor::DoSelectMedium2()
1332 {
1333  TGeoMedium *med = fSelectedMedium2;
1334  new TGeoMediumDialog(fBSelMedium2, gClient->GetRoot(), 200,300);
1335  fSelectedMedium2 = (TGeoMedium*)TGeoMediumDialog::GetSelected();
1336  if (fSelectedMedium2) fLSelMedium2->SetText(fSelectedMedium2->GetName());
1337  else fSelectedMedium2 = med;
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Slot for selecting an existing volume.
1342 
1343 void TGeoManagerEditor::DoSelectVolume()
1344 {
1345  TGeoVolume *vol = fSelectedVolume;
1346  new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300);
1347  fSelectedVolume = (TGeoVolume*)TGeoVolumeDialog::GetSelected();
1348  if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName());
1349  else fSelectedVolume = vol;
1350 }
1351 
1352 ////////////////////////////////////////////////////////////////////////////////
1353 /// Slot for setting top geometry volume.
1354 
1355 void TGeoManagerEditor::DoSelectTopVolume()
1356 {
1357  TGeoVolume *vol = fGeometry->GetTopVolume();
1358  new TGeoVolumeDialog(fBSelTop, gClient->GetRoot(), 200,300);
1359  fSelectedVolume = (TGeoVolume*)TGeoVolumeDialog::GetSelected();
1360  if (fSelectedVolume) fLSelTop->SetText(fSelectedVolume->GetName());
1361  else fSelectedVolume = vol;
1362  if (fSelectedVolume && (fSelectedVolume != vol)) fGeometry->SetTopVolume(fSelectedVolume);
1363 }
1364 
1365 ////////////////////////////////////////////////////////////////////////////////
1366 /// Slot for closing the geometry.
1367 
1368 void TGeoManagerEditor::DoCloseGeometry()
1369 {
1370  if (!fGeometry->IsClosed()) fGeometry->CloseGeometry();
1371  fCloseGeometry->SetEnabled(kFALSE);
1372 }
1373 
1374 ////////////////////////////////////////////////////////////////////////////////
1375 /// Show/hide interface for shape selection.
1376 
1377 void TGeoManagerEditor::ShowSelectShape(Bool_t show)
1378 {
1379  TGCompositeFrame *cont = (TGCompositeFrame*)fCategories->GetItem("Shapes")->GetContainer();
1380  if (show) cont->ShowFrame(f2);
1381  else cont->HideFrame(f2);
1382 }
1383 
1384 ////////////////////////////////////////////////////////////////////////////////
1385 /// Show/hide interface for volume selection.
1386 
1387 void TGeoManagerEditor::ShowSelectVolume(Bool_t show)
1388 {
1389  TGCompositeFrame *cont = (TGCompositeFrame*)fCategories->GetItem("General")->GetContainer();
1390  if (show) cont->ShowFrame(f7);
1391  else cont->HideFrame(f7);
1392  cont = (TGCompositeFrame*)fCategories->GetItem("Volumes")->GetContainer();
1393  if (show) cont->ShowFrame(f3);
1394  else cont->HideFrame(f3);
1395 }
1396 
1397 ////////////////////////////////////////////////////////////////////////////////
1398 /// Show/hide interface for material selection.
1399 
1400 void TGeoManagerEditor::ShowSelectMaterial(Bool_t show)
1401 {
1402  TGCompositeFrame *cont = (TGCompositeFrame*)fCategories->GetItem("Materials")->GetContainer();
1403  if (show) cont->ShowFrame(f4);
1404  else cont->HideFrame(f4);
1405 }
1406 
1407 ////////////////////////////////////////////////////////////////////////////////
1408 /// Show/hide interface for medium selection.
1409 
1410 void TGeoManagerEditor::ShowSelectMedium(Bool_t show)
1411 {
1412  TGCompositeFrame *cont = (TGCompositeFrame*)fCategories->GetItem("Media")->GetContainer();
1413  if (show) cont->ShowFrame(f5);
1414  else cont->HideFrame(f5);
1415 }
1416 
1417 ////////////////////////////////////////////////////////////////////////////////
1418 /// Show/hide interface for matrix selection.
1419 
1420 void TGeoManagerEditor::ShowSelectMatrix(Bool_t show)
1421 {
1422  TGCompositeFrame *cont = (TGCompositeFrame*)fCategories->GetItem("Matrices")->GetContainer();
1423  if (show) cont->ShowFrame(f6);
1424  else cont->HideFrame(f6);
1425 }