Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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 "TGTab.h"
25#include "TGButton.h"
26#include "TGTextEntry.h"
27#include "TGNumberEntry.h"
28#include "TGLabel.h"
29#include "TGeoTabManager.h"
30
31
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor for node editor
44
45TGeoNodeEditor::TGeoNodeEditor(const TGWindow *p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
46 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
47{
48 fNode = nullptr;
50 Pixel_t color;
51
52 // TextEntry for medium name
53 TGTextEntry *nef;
54 MakeTitle("Name");
57 fNodeName->Resize(100, fNodeName->GetDefaultHeight());
58 fNodeName->SetToolTipText("Enter the node name");
59 fNodeName->Associate(this);
60 f1->AddFrame(fNodeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
61 f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
62 fNodeNumber = new TGNumberEntry(f1, 0., 1, kNODE_ID);
63 nef = (TGTextEntry *)fNodeNumber->GetNumberEntry();
64 nef->SetToolTipText("Enter the node copy number");
65 fNodeNumber->Associate(this);
66 f1->AddFrame(fNodeNumber, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
67 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 5));
68
69 // Mother volume selection
70 MakeTitle("Mother volume");
71 f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
72 fSelectedMother = nullptr;
73 fLSelMother = new TGLabel(f1, "Select mother");
74 gClient->GetColorByName("#0000ff", color);
75 fLSelMother->SetTextColor(color);
76 fLSelMother->ChangeOptions(kSunkenFrame | kDoubleBorder);
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 = nullptr;
91 fLSelVolume = new TGLabel(f1, "Select volume");
92 gClient->GetColorByName("#0000ff", color);
93 fLSelVolume->SetTextColor(color);
94 fLSelVolume->ChangeOptions(kSunkenFrame | kDoubleBorder);
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 = nullptr;
109 fLSelMatrix = new TGLabel(f1, "Select matrix");
110 gClient->GetColorByName("#0000ff", color);
111 fLSelMatrix->SetTextColor(color);
112 fLSelMatrix->ChangeOptions(kSunkenFrame | kDoubleBorder);
113 f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
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));
132 fUndo->SetSize(fApply->GetSize());
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/// Connect to a editable object.
168
170{
171 if (obj == nullptr || !obj->InheritsFrom(TGeoNode::Class())) {
173 return;
174 }
175 fNode = (TGeoNode *)obj;
176 const char *sname = fNode->GetName();
177 fNodeName->SetText(sname);
178
179 fNodeNumber->SetNumber(fNode->GetNumber());
180
181 fSelectedMother = fNode->GetMotherVolume();
182 if (fSelectedMother)
183 fLSelMother->SetText(fSelectedMother->GetName());
184 fSelectedVolume = fNode->GetVolume();
185 if (fSelectedVolume)
186 fLSelVolume->SetText(fSelectedVolume->GetName());
187 fSelectedMatrix = fNode->GetMatrix();
188 if (fSelectedMatrix)
189 fLSelMatrix->SetText(fSelectedMatrix->GetName());
190
191 fApply->SetEnabled(kFALSE);
192 fUndo->SetEnabled(kFALSE);
193
194 if (fInit)
196 SetActive();
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Select the mother volume.
201
203{
205 new TGeoVolumeDialog(fBSelMother, gClient->GetRoot(), 200, 300);
207 if (fSelectedMother)
208 fLSelMother->SetText(fSelectedMother->GetName());
209 else
210 fSelectedMother = vol;
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Select the volume.
215
217{
219 new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200, 300);
221 if (fSelectedVolume)
222 fLSelVolume->SetText(fSelectedVolume->GetName());
223 else
224 fSelectedVolume = vol;
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Select the matrix.
229
231{
232 TGeoMatrix *matrix = fSelectedMatrix;
233 new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200, 300);
235 if (fSelectedMatrix)
236 fLSelMatrix->SetText(fSelectedMatrix->GetName());
237 else
238 fSelectedMatrix = matrix;
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Edit the mother volume.
243
245{
246 if (!fSelectedMother) {
247 fTabMgr->SetVolTabEnabled(kFALSE);
248 return;
249 }
250 fTabMgr->SetVolTabEnabled();
251 fTabMgr->GetVolumeEditor(fSelectedMother);
252 fTabMgr->SetTab();
253 fSelectedMother->Draw();
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Edit selected volume.
258
260{
261 if (!fSelectedVolume) {
262 fTabMgr->SetVolTabEnabled(kFALSE);
263 return;
264 }
265 fTabMgr->SetVolTabEnabled();
266 fTabMgr->GetVolumeEditor(fSelectedVolume);
267 fTabMgr->SetTab();
268 fSelectedVolume->Draw();
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Edit selected material.
273
275{
276 if (!fSelectedMatrix)
277 return;
278 fTabMgr->GetMatrixEditor(fSelectedMatrix);
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Change node name.
283
285{
286 const char *name = fNodeName->GetText();
287 if (!name[0] || !strcmp(name, fNode->GetName()))
288 return;
289 fNode->SetName(name);
290}
291
292////////////////////////////////////////////////////////////////////////////////
293/// Change node copy number
294
296
297////////////////////////////////////////////////////////////////////////////////
298/// Slot for applying modifications.
299
301
302////////////////////////////////////////////////////////////////////////////////
303/// Slot for undoing last operation.
304
@ kRaisedFrame
Definition GuiTypes.h:385
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define gClient
Definition TGClient.h:157
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
char name[80]
Definition TGX11.cxx:148
ETGeoNodeWid
@ kNODE_MATRIX
@ kNODE_ID
@ kNODE_MVOLSEL
@ kNODE_VOLSEL
@ kNODE_EDIT_VOL
@ kNODE_EDIT_MATRIX
@ kNODE_NAME
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
virtual Bool_t IsComposite() const
Definition TGFrame.h:214
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Yield an action as soon as it is clicked.
Definition TGButton.h:228
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
ROOT GUI Window base class.
Definition TGWindow.h:23
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
TGeoGedFrame(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGeoTabManager * fTabMgr
Geometrical transformation package.
Definition TGeoMatrix.h:39
void DoNodeNumber()
Change node copy number.
TGeoNode * fNode
TGNumberEntry * fNodeNumber
void DoSelectMatrix()
Select the matrix.
TGLabel * fLSelVolume
void DoEditMother()
Edit the mother volume.
TGTextButton * fEditMatrix
~TGeoNodeEditor() override
Destructor.
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
void DoEditVolume()
Edit selected volume.
TGeoNodeEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for node editor.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGLabel * fLSelMatrix
TGeoVolume * fSelectedMother
void DoApply()
Slot for applying modifications.
TGeoVolume * fSelectedVolume
void SetModel(TObject *obj) override
Connect to a editable object.
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:39
static TClass * Class()
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
static TObject * GetSelected()
static; return selected object
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
Mother of all ROOT objects.
Definition TObject.h:42
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:549
TF1 * f1
Definition legend1.C:11