Logo ROOT   6.12/07
Reference Guide
TGeoNodeEditor.cxx
Go to the documentation of this file.
1 // @(#):$Id: b94274447e46ae2cf700c562e57c3c38c6612b74 $
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 TGeoNodeEditor
13 \ingroup Geometry_builder
14 
15 Editor class for TGeoNode objects.
16 
17 */
18 
19 #include "TGeoNodeEditor.h"
20 #include "TGedEditor.h"
21 #include "TGeoManager.h"
22 #include "TGeoMatrix.h"
23 #include "TGeoNode.h"
24 #include "TPad.h"
25 #include "TGTab.h"
26 #include "TGComboBox.h"
27 #include "TGButton.h"
28 #include "TGTextEntry.h"
29 #include "TGNumberEntry.h"
30 #include "TGLabel.h"
31 #include "TGeoTabManager.h"
32 
34 
38 };
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Constructor for node editor
42 
44  Int_t height, UInt_t options, Pixel_t back)
45  : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
46 {
47  fNode = 0;
49  Pixel_t color;
50 
51  // TextEntry for medium name
52  TGTextEntry *nef;
53  MakeTitle("Name");
55  fNodeName = new TGTextEntry(f1, new TGTextBuffer(50), kNODE_NAME);
57  fNodeName->SetToolTipText("Enter the node name");
58  fNodeName->Associate(this);
59  f1->AddFrame(fNodeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
60  f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
61  fNodeNumber = new TGNumberEntry(f1, 0., 1, kNODE_ID);
63  nef->SetToolTipText("Enter the node copy number");
64  fNodeNumber->Associate(this);
66  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 5));
67 
68 
69 // Mother volume selection
70  MakeTitle("Mother volume");
71  f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
72  fSelectedMother = 0;
73  fLSelMother = new TGLabel(f1, "Select mother");
74  gClient->GetColorByName("#0000ff", color);
75  fLSelMother->SetTextColor(color);
78  fBSelMother = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MVOLSEL);
79  fBSelMother->SetToolTipText("Select one of the existing volumes");
80  fBSelMother->Associate(this);
81  f1->AddFrame(fBSelMother, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
82  fEditMother = new TGTextButton(f1, "Edit");
83  f1->AddFrame(fEditMother, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
84  fEditMother->Associate(this);
85  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
86 
87 // Volume selection
88  MakeTitle("Volume");
89  f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
90  fSelectedVolume = 0;
91  fLSelVolume = new TGLabel(f1, "Select volume");
92  gClient->GetColorByName("#0000ff", color);
93  fLSelVolume->SetTextColor(color);
96  fBSelVolume = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_VOLSEL);
97  fBSelVolume->SetToolTipText("Select one of the existing volumes");
98  fBSelVolume->Associate(this);
99  f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
100  fEditVolume = new TGTextButton(f1, "Edit");
101  f1->AddFrame(fEditVolume, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
102  fEditVolume->Associate(this);
103  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
104 
105 // Matrix selection
106  MakeTitle("Matrix");
107  f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
108  fSelectedMatrix = 0;
109  fLSelMatrix = new TGLabel(f1, "Select matrix");
110  gClient->GetColorByName("#0000ff", color);
111  fLSelMatrix->SetTextColor(color);
114  fBSelMatrix = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MATRIX);
115  fBSelMatrix->SetToolTipText("Select one of the existing matrices");
116  fBSelMatrix->Associate(this);
117  f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
118  fEditMatrix = new TGTextButton(f1, "Edit");
119  f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
120  fEditMatrix->Associate(this);
121  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
122 
123  // Buttons
124  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
125  fApply = new TGTextButton(f1, "Apply");
126  f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
127  fApply->Associate(this);
128  fUndo = new TGTextButton(f1, "Undo");
129  f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
130  fUndo->Associate(this);
131  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
133 }
134 
135 ////////////////////////////////////////////////////////////////////////////////
136 /// Destructor
137 
139 {
140  TGFrameElement *el;
141  TIter next(GetList());
142  while ((el = (TGFrameElement *)next())) {
143  if (el->fFrame->IsComposite())
145  }
146  Cleanup();
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 /// Connect signals to slots.
151 
153 {
154  fBSelMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMother()");
155  fBSelVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectVolume()");
156  fBSelMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMatrix()");
157  fApply->Connect("Clicked()", "TGeoNodeEditor", this, "DoApply()");
158  fUndo->Connect("Clicked()", "TGeoNodeEditor", this, "DoUndo()");
159  fEditMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMother()");
160  fEditVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditVolume()");
161  fEditMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMatrix()");
162  fNodeName->Connect("TextChanged(const char *)", "TGeoNodeEditor", this, "DoNodeName()");
163  fInit = kFALSE;
164 }
165 
166 
167 ////////////////////////////////////////////////////////////////////////////////
168 /// Connect to a editable object.
169 
171 {
172  if (obj == 0 || !obj->InheritsFrom(TGeoNode::Class())) {
173  SetActive(kFALSE);
174  return;
175  }
176  fNode = (TGeoNode*)obj;
177  const char *sname = fNode->GetName();
178  fNodeName->SetText(sname);
179 
181 
188 
191 
193  SetActive();
194 }
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 /// Select the mother volume.
198 
200 {
202  new TGeoVolumeDialog(fBSelMother, gClient->GetRoot(), 200,300);
204  if (fSelectedMother) fLSelMother->SetText(fSelectedMother->GetName());
205  else fSelectedMother = vol;
206 }
207 
208 ////////////////////////////////////////////////////////////////////////////////
209 /// Select the volume.
210 
212 {
214  new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300);
216  if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName());
217  else fSelectedVolume = vol;
218 }
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Select the matrix.
222 
224 {
225  TGeoMatrix *matrix = fSelectedMatrix;
226  new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200,300);
228  if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName());
229  else fSelectedMatrix = matrix;
230 }
231 
232 ////////////////////////////////////////////////////////////////////////////////
233 /// Edit the mother volume.
234 
236 {
237  if (!fSelectedMother) {
239  return;
240  }
243  fTabMgr->SetTab();
245 }
246 
247 ////////////////////////////////////////////////////////////////////////////////
248 /// Edit selected volume.
249 
251 {
252  if (!fSelectedVolume) {
254  return;
255  }
258  fTabMgr->SetTab();
260 }
261 
262 ////////////////////////////////////////////////////////////////////////////////
263 /// Edit selected material.
264 
266 {
267  if (!fSelectedMatrix) return;
269 }
270 
271 ////////////////////////////////////////////////////////////////////////////////
272 /// Change node name.
273 
275 {
276  const char *name = fNodeName->GetText();
277  if (!name[0] || !strcmp(name, fNode->GetName())) return;
278  fNode->SetName(name);
279 }
280 
281 ////////////////////////////////////////////////////////////////////////////////
282 /// Change node copy number
283 
285 {
286 }
287 
288 ////////////////////////////////////////////////////////////////////////////////
289 /// Slot for applying modifications.
290 
292 {
293 }
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 /// Slot for undoing last operation.
297 
299 {
300 }
301 
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGPictureButton * fBSelMatrix
TGeoVolume * fSelectedMother
TGTextButton * fEditVolume
void SetTab()
Set a given tab element as active one.
TGTextButton * fApply
TGPictureButton * fBSelMother
TGeoVolume * fSelectedVolume
Geometrical transformation package.
Definition: TGeoMatrix.h:40
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
TGeoMatrix * fSelectedMatrix
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
virtual void SetNumber(Double_t val)
virtual void Draw(Option_t *option="")
draw top volume according to option
void DoEditMother()
Edit the mother volume.
void DoNodeNumber()
Change node copy number.
#define gClient
Definition: TGClient.h:166
int Int_t
Definition: RtypesCore.h:41
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
TGTextButton * fEditMother
virtual void SetModel(TObject *obj)
Connect to a editable object.
void SetVolTabEnabled(Bool_t flag=kTRUE)
Enable/disable tabs.
TGeoVolume * GetMotherVolume() const
Definition: TGeoNode.h:89
TGeoNode * fNode
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
void DoSelectMother()
Select the mother volume.
ULong_t Pixel_t
Definition: GuiTypes.h:39
void Class()
Definition: Class.C:29
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
TGLabel * fLSelVolume
TGTextButton * fEditMatrix
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
void DoEditMatrix()
Edit selected material.
TGCompositeFrame(const TGCompositeFrame &)
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual TGeoMatrix * GetMatrix() const =0
void DoSelectMatrix()
Select the matrix.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGPictureButton * fBSelVolume
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:867
Int_t GetNumber() const
Definition: TGeoNode.h:92
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual ~TGeoNodeEditor()
Destructor.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
Editor class for TGeoNode objects.
TGTextButton * fUndo
unsigned int UInt_t
Definition: RtypesCore.h:42
ETGeoNodeWid
void GetVolumeEditor(TGeoVolume *vol)
Get editor for a volume.
TGFrame * fFrame
Definition: TGLayout.h:119
static TObject * GetSelected()
static; return selected object
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGDimension GetSize() const
Definition: TGFrame.h:277
void DoUndo()
Slot for undoing last operation.
const char * GetText() const
Definition: TGTextEntry.h:134
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGLabel * fLSelMatrix
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:409
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:287
void DoSelectVolume()
Select the volume.
TGeoNodeEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for node editor.
TGLabel * fLSelMother
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Mother of all ROOT objects.
Definition: TObject.h:37
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:39
Bool_t fInit
Definition: TGedFrame.h:53
TGNumberEntryField * GetNumberEntry() const
void DoEditVolume()
Edit selected volume.
TGClient * fClient
Definition: TGObject.h:37
TF1 * f1
Definition: legend1.C:11
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
void DoNodeName()
Change node name.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGNumberEntry * fNodeNumber
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
void GetMatrixEditor(TGeoMatrix *matrix)
Get editor for a matrix.
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:303
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:94
char name[80]
Definition: TGX11.cxx:109
void DoApply()
Slot for applying modifications.
TGTextEntry * fNodeName
TGeoTabManager * fTabMgr
Definition: TGeoGedFrame.h:17
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13