Logo ROOT   6.16/01
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
15Editor 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");
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");
65 f1->AddFrame(fNodeNumber, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
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);
73 fLSelMother = new TGLabel(f1, "Select mother");
74 gClient->GetColorByName("#0000ff", color);
79 fBSelMother->SetToolTipText("Select one of the existing volumes");
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));
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);
91 fLSelVolume = new TGLabel(f1, "Select volume");
92 gClient->GetColorByName("#0000ff", color);
97 fBSelVolume->SetToolTipText("Select one of the existing volumes");
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);
113 f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
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())) {
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);
205 else fSelectedMother = vol;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Select the volume.
210
212{
214 new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300);
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);
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;
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
void Class()
Definition: Class.C:29
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:363
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
#define gClient
Definition: TGClient.h:166
@ kRaisedFrame
Definition: TGFrame.h:62
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
@ kDoubleBorder
Definition: TGFrame.h:63
@ kFixedWidth
Definition: TGFrame.h:65
@ kHorizontalFrame
Definition: TGFrame.h:60
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsExpandX
Definition: TGLayout.h:37
ETGeoNodeWid
@ kNODE_MATRIX
@ kNODE_ID
@ kNODE_MVOLSEL
@ kNODE_VOLSEL
@ kNODE_EDIT_VOL
@ kNODE_EDIT_MATRIX
@ kNODE_NAME
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
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:289
virtual TList * GetList() const
Definition: TGFrame.h:369
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:303
virtual void SetSize(const TGDimension &s)
Definition: TGFrame.h:299
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGDimension GetSize() const
Definition: TGFrame.h:277
virtual Bool_t IsComposite() const
Definition: TGFrame.h:259
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
virtual void SetNumber(Double_t val)
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
TGClient * fClient
Definition: TGObject.h:37
const char * GetText() const
Definition: TGTextEntry.h:134
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
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.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGeoTabManager * fTabMgr
Definition: TGeoGedFrame.h:17
Geometrical transformation package.
Definition: TGeoMatrix.h:41
Editor class for TGeoNode objects.
void DoNodeNumber()
Change node copy number.
TGeoNode * fNode
TGNumberEntry * fNodeNumber
virtual void SetModel(TObject *obj)
Connect to a editable object.
void DoSelectMatrix()
Select the matrix.
TGLabel * fLSelVolume
void DoEditMother()
Edit the mother volume.
TGTextButton * fEditMatrix
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.
void DoEditMatrix()
Edit selected material.
void DoSelectMother()
Select the mother volume.
TGTextButton * fEditVolume
void DoUndo()
Slot for undoing last operation.
TGTextButton * fApply
TGTextButton * fEditMother
TGLabel * fLSelMother
TGTextEntry * fNodeName
TGPictureButton * fBSelMatrix
virtual ~TGeoNodeEditor()
Destructor.
void DoEditVolume()
Edit selected volume.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGLabel * fLSelMatrix
TGeoVolume * fSelectedMother
void DoApply()
Slot for applying modifications.
TGeoVolume * fSelectedVolume
TGPictureButton * fBSelMother
void DoSelectVolume()
Select the volume.
TGPictureButton * fBSelVolume
TGTextButton * fUndo
TGeoMatrix * fSelectedMatrix
void DoNodeName()
Change node name.
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:41
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:94
virtual TGeoMatrix * GetMatrix() const =0
TGeoVolume * GetMotherVolume() const
Definition: TGeoNode.h:89
Int_t GetNumber() const
Definition: TGeoNode.h:92
void GetVolumeEditor(TGeoVolume *vol)
Get editor for a volume.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
void SetTab()
Set a given tab element as active one.
void SetVolTabEnabled(Bool_t flag=kTRUE)
Enable/disable tabs.
void GetMatrixEditor(TGeoMatrix *matrix)
Get editor for a matrix.
static TObject * GetSelected()
static; return selected object
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:53
virtual void Draw(Option_t *option="")
draw top volume according to option
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
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
TF1 * f1
Definition: legend1.C:11