Logo ROOT   6.08/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 //______________________________________________________________________________
13 //
14 // TGeoNodeEditor - Editor class for TGeoNode objects
15 //
16 //______________________________________________________________________________
17 
18 #include "TGeoNodeEditor.h"
19 #include "TGedEditor.h"
20 #include "TGeoManager.h"
21 #include "TGeoMatrix.h"
22 #include "TGeoNode.h"
23 #include "TPad.h"
24 #include "TGTab.h"
25 #include "TGComboBox.h"
26 #include "TGButton.h"
27 #include "TGTextEntry.h"
28 #include "TGNumberEntry.h"
29 #include "TGLabel.h"
30 #include "TGeoTabManager.h"
31 
33 
37 };
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Constructor for node editor
41 
43  Int_t height, UInt_t options, Pixel_t back)
44  : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
45 {
46  fNode = 0;
48  Pixel_t color;
49 
50  // TextEntry for medium name
51  TGTextEntry *nef;
52  MakeTitle("Name");
54  fNodeName = new TGTextEntry(f1, new TGTextBuffer(50), kNODE_NAME);
56  fNodeName->SetToolTipText("Enter the node name");
57  fNodeName->Associate(this);
58  f1->AddFrame(fNodeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
59  f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
60  fNodeNumber = new TGNumberEntry(f1, 0., 1, kNODE_ID);
62  nef->SetToolTipText("Enter the node copy number");
63  fNodeNumber->Associate(this);
65  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 5));
66 
67 
68 // Mother volume selection
69  MakeTitle("Mother volume");
70  f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
71  fSelectedMother = 0;
72  fLSelMother = new TGLabel(f1, "Select mother");
73  gClient->GetColorByName("#0000ff", color);
74  fLSelMother->SetTextColor(color);
77  fBSelMother = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MVOLSEL);
78  fBSelMother->SetToolTipText("Select one of the existing volumes");
79  fBSelMother->Associate(this);
80  f1->AddFrame(fBSelMother, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
81  fEditMother = new TGTextButton(f1, "Edit");
82  f1->AddFrame(fEditMother, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
83  fEditMother->Associate(this);
84  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
85 
86 // Volume selection
87  MakeTitle("Volume");
88  f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
89  fSelectedVolume = 0;
90  fLSelVolume = new TGLabel(f1, "Select volume");
91  gClient->GetColorByName("#0000ff", color);
92  fLSelVolume->SetTextColor(color);
95  fBSelVolume = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_VOLSEL);
96  fBSelVolume->SetToolTipText("Select one of the existing volumes");
97  fBSelVolume->Associate(this);
98  f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
99  fEditVolume = new TGTextButton(f1, "Edit");
100  f1->AddFrame(fEditVolume, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
101  fEditVolume->Associate(this);
102  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
103 
104 // Matrix selection
105  MakeTitle("Matrix");
106  f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
107  fSelectedMatrix = 0;
108  fLSelMatrix = new TGLabel(f1, "Select matrix");
109  gClient->GetColorByName("#0000ff", color);
110  fLSelMatrix->SetTextColor(color);
113  fBSelMatrix = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MATRIX);
114  fBSelMatrix->SetToolTipText("Select one of the existing matrices");
115  fBSelMatrix->Associate(this);
116  f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
117  fEditMatrix = new TGTextButton(f1, "Edit");
118  f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
119  fEditMatrix->Associate(this);
120  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
121 
122  // Buttons
123  f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
124  fApply = new TGTextButton(f1, "Apply");
125  f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
126  fApply->Associate(this);
127  fUndo = new TGTextButton(f1, "Undo");
128  f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
129  fUndo->Associate(this);
130  AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
132 }
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 /// Destructor
136 
138 {
139  TGFrameElement *el;
140  TIter next(GetList());
141  while ((el = (TGFrameElement *)next())) {
142  if (el->fFrame->IsComposite())
144  }
145  Cleanup();
146 }
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 /// Connect signals to slots.
150 
152 {
153  fBSelMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMother()");
154  fBSelVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectVolume()");
155  fBSelMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMatrix()");
156  fApply->Connect("Clicked()", "TGeoNodeEditor", this, "DoApply()");
157  fUndo->Connect("Clicked()", "TGeoNodeEditor", this, "DoUndo()");
158  fEditMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMother()");
159  fEditVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditVolume()");
160  fEditMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMatrix()");
161  fNodeName->Connect("TextChanged(const char *)", "TGeoNodeEditor", this, "DoNodeName()");
162  fInit = kFALSE;
163 }
164 
165 
166 ////////////////////////////////////////////////////////////////////////////////
167 /// Connect to a editable object.
168 
170 {
171  if (obj == 0 || !obj->InheritsFrom(TGeoNode::Class())) {
172  SetActive(kFALSE);
173  return;
174  }
175  fNode = (TGeoNode*)obj;
176  const char *sname = fNode->GetName();
177  fNodeName->SetText(sname);
178 
180 
187 
190 
192  SetActive();
193 }
194 
195 ////////////////////////////////////////////////////////////////////////////////
196 /// Select the mother volume.
197 
199 {
201  new TGeoVolumeDialog(fBSelMother, gClient->GetRoot(), 200,300);
203  if (fSelectedMother) fLSelMother->SetText(fSelectedMother->GetName());
204  else fSelectedMother = vol;
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// Select the volume.
209 
211 {
213  new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300);
215  if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName());
216  else fSelectedVolume = vol;
217 }
218 
219 ////////////////////////////////////////////////////////////////////////////////
220 /// Select the matrix.
221 
223 {
224  TGeoMatrix *matrix = fSelectedMatrix;
225  new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200,300);
227  if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName());
228  else fSelectedMatrix = matrix;
229 }
230 
231 ////////////////////////////////////////////////////////////////////////////////
232 /// Edit the mother volume.
233 
235 {
236  if (!fSelectedMother) {
238  return;
239  }
242  fTabMgr->SetTab();
244 }
245 
246 ////////////////////////////////////////////////////////////////////////////////
247 /// Edit selected volume.
248 
250 {
251  if (!fSelectedVolume) {
253  return;
254  }
257  fTabMgr->SetTab();
259 }
260 
261 ////////////////////////////////////////////////////////////////////////////////
262 /// Edit selected material.
263 
265 {
266  if (!fSelectedMatrix) return;
268 }
269 
270 ////////////////////////////////////////////////////////////////////////////////
271 /// Change node name.
272 
274 {
275  const char *name = fNodeName->GetText();
276  if (!name[0] || !strcmp(name, fNode->GetName())) return;
277  fNode->SetName(name);
278 }
279 
280 ////////////////////////////////////////////////////////////////////////////////
281 /// Change node copy number
282 
284 {
285 }
286 
287 ////////////////////////////////////////////////////////////////////////////////
288 /// Slot for applying modifications.
289 
291 {
292 }
293 
294 ////////////////////////////////////////////////////////////////////////////////
295 /// Slot for undoing last operation.
296 
298 {
299 }
300 
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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:131
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:61
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:174
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Bool_t IsComposite() const
Definition: TGFrame.h:275
const char * Class
Definition: TXMLSetup.cxx:64
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:101
TGeoNode * fNode
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hirarchically all daughters of a composite frame.
void DoSelectMother()
Select the mother volume.
ULong_t Pixel_t
Definition: GuiTypes.h:41
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:385
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:1137
Int_t GetNumber() const
Definition: TGeoNode.h:104
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:315
virtual ~TGeoNodeEditor()
Destructor.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:221
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:125
const std::string sname
Definition: testIO.cxx:45
static TObject * GetSelected()
static; return selected object
TGDimension GetSize() const
Definition: TGFrame.h:293
void DoUndo()
Slot for undoing last operation.
const char * GetText() const
Definition: TGTextEntry.h:140
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:254
TGLabel * fLSelMatrix
#define ClassImp(name)
Definition: Rtypes.h:279
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:51
Bool_t fInit
Definition: TGedFrame.h:55
TGNumberEntryField * GetNumberEntry() const
void DoEditVolume()
Edit selected volume.
TGClient * fClient
Definition: TGObject.h:41
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
const Bool_t kTRUE
Definition: Rtypes.h:91
TGNumberEntry * fNodeNumber
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:106
char name[80]
Definition: TGX11.cxx:109
void DoApply()
Slot for applying modifications.
TGTextEntry * fNodeName
TGeoTabManager * fTabMgr
Definition: TGeoGedFrame.h:27