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
32
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor for node editor
45
47 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fNode = nullptr;
51 Pixel_t color;
52
53 // TextEntry for medium name
54 TGTextEntry *nef;
55 MakeTitle("Name");
58 fNodeName->Resize(100, fNodeName->GetDefaultHeight());
59 fNodeName->SetToolTipText("Enter the node name");
60 fNodeName->Associate(this);
61 f1->AddFrame(fNodeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
62 f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
63 fNodeNumber = new TGNumberEntry(f1, 0., 1, kNODE_ID);
64 nef = (TGTextEntry *)fNodeNumber->GetNumberEntry();
65 nef->SetToolTipText("Enter the node copy number");
66 fNodeNumber->Associate(this);
67 f1->AddFrame(fNodeNumber, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
68 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 5));
69
70 // Mother volume selection
71 MakeTitle("Mother volume");
72 f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
73 fSelectedMother = nullptr;
74 fLSelMother = new TGLabel(f1, "Select mother");
75 gClient->GetColorByName("#0000ff", color);
76 fLSelMother->SetTextColor(color);
77 fLSelMother->ChangeOptions(kSunkenFrame | kDoubleBorder);
79 fBSelMother = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MVOLSEL);
80 fBSelMother->SetToolTipText("Select one of the existing volumes");
81 fBSelMother->Associate(this);
82 f1->AddFrame(fBSelMother, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
83 fEditMother = new TGTextButton(f1, "Edit");
84 f1->AddFrame(fEditMother, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
85 fEditMother->Associate(this);
86 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
87
88 // Volume selection
89 MakeTitle("Volume");
90 f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
91 fSelectedVolume = nullptr;
92 fLSelVolume = new TGLabel(f1, "Select volume");
93 gClient->GetColorByName("#0000ff", color);
94 fLSelVolume->SetTextColor(color);
95 fLSelVolume->ChangeOptions(kSunkenFrame | kDoubleBorder);
97 fBSelVolume = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_VOLSEL);
98 fBSelVolume->SetToolTipText("Select one of the existing volumes");
99 fBSelVolume->Associate(this);
100 f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
101 fEditVolume = new TGTextButton(f1, "Edit");
102 f1->AddFrame(fEditVolume, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
103 fEditVolume->Associate(this);
104 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
105
106 // Matrix selection
107 MakeTitle("Matrix");
108 f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth);
109 fSelectedMatrix = nullptr;
110 fLSelMatrix = new TGLabel(f1, "Select matrix");
111 gClient->GetColorByName("#0000ff", color);
112 fLSelMatrix->SetTextColor(color);
113 fLSelMatrix->ChangeOptions(kSunkenFrame | kDoubleBorder);
114 f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
115 fBSelMatrix = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MATRIX);
116 fBSelMatrix->SetToolTipText("Select one of the existing matrices");
117 fBSelMatrix->Associate(this);
118 f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
119 fEditMatrix = new TGTextButton(f1, "Edit");
120 f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1));
121 fEditMatrix->Associate(this);
122 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
123
124 // Buttons
125 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
126 fApply = new TGTextButton(f1, "Apply");
127 f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128 fApply->Associate(this);
129 fUndo = new TGTextButton(f1, "Undo");
130 f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
131 fUndo->Associate(this);
132 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
133 fUndo->SetSize(fApply->GetSize());
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Destructor
138
140{
141 TGFrameElement *el;
142 TIter next(GetList());
143 while ((el = (TGFrameElement *)next())) {
144 if (el->fFrame->IsComposite())
146 }
147 Cleanup();
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Connect signals to slots.
152
154{
155 fBSelMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMother()");
156 fBSelVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectVolume()");
157 fBSelMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMatrix()");
158 fApply->Connect("Clicked()", "TGeoNodeEditor", this, "DoApply()");
159 fUndo->Connect("Clicked()", "TGeoNodeEditor", this, "DoUndo()");
160 fEditMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMother()");
161 fEditVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditVolume()");
162 fEditMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMatrix()");
163 fNodeName->Connect("TextChanged(const char *)", "TGeoNodeEditor", this, "DoNodeName()");
164 fInit = kFALSE;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Connect to a editable object.
169
171{
172 if (obj == nullptr || !obj->InheritsFrom(TGeoNode::Class())) {
174 return;
175 }
176 fNode = (TGeoNode *)obj;
177 const char *sname = fNode->GetName();
178 fNodeName->SetText(sname);
179
180 fNodeNumber->SetNumber(fNode->GetNumber());
181
182 fSelectedMother = fNode->GetMotherVolume();
183 if (fSelectedMother)
184 fLSelMother->SetText(fSelectedMother->GetName());
185 fSelectedVolume = fNode->GetVolume();
186 if (fSelectedVolume)
187 fLSelVolume->SetText(fSelectedVolume->GetName());
188 fSelectedMatrix = fNode->GetMatrix();
189 if (fSelectedMatrix)
190 fLSelMatrix->SetText(fSelectedMatrix->GetName());
191
192 fApply->SetEnabled(kFALSE);
193 fUndo->SetEnabled(kFALSE);
194
195 if (fInit)
197 SetActive();
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Select the mother volume.
202
204{
206 new TGeoVolumeDialog(fBSelMother, gClient->GetRoot(), 200, 300);
208 if (fSelectedMother)
209 fLSelMother->SetText(fSelectedMother->GetName());
210 else
211 fSelectedMother = vol;
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Select the volume.
216
218{
220 new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200, 300);
222 if (fSelectedVolume)
223 fLSelVolume->SetText(fSelectedVolume->GetName());
224 else
225 fSelectedVolume = vol;
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Select the matrix.
230
232{
233 TGeoMatrix *matrix = fSelectedMatrix;
234 new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200, 300);
236 if (fSelectedMatrix)
237 fLSelMatrix->SetText(fSelectedMatrix->GetName());
238 else
239 fSelectedMatrix = matrix;
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Edit the mother volume.
244
246{
247 if (!fSelectedMother) {
248 fTabMgr->SetVolTabEnabled(kFALSE);
249 return;
250 }
251 fTabMgr->SetVolTabEnabled();
252 fTabMgr->GetVolumeEditor(fSelectedMother);
253 fTabMgr->SetTab();
254 fSelectedMother->Draw();
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Edit selected volume.
259
261{
262 if (!fSelectedVolume) {
263 fTabMgr->SetVolTabEnabled(kFALSE);
264 return;
265 }
266 fTabMgr->SetVolTabEnabled();
267 fTabMgr->GetVolumeEditor(fSelectedVolume);
268 fTabMgr->SetTab();
269 fSelectedVolume->Draw();
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Edit selected material.
274
276{
277 if (!fSelectedMatrix)
278 return;
279 fTabMgr->GetMatrixEditor(fSelectedMatrix);
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Change node name.
284
286{
287 const char *name = fNodeName->GetText();
288 if (!name[0] || !strcmp(name, fNode->GetName()))
289 return;
290 fNode->SetName(name);
291}
292
293////////////////////////////////////////////////////////////////////////////////
294/// Change node copy number
295
297
298////////////////////////////////////////////////////////////////////////////////
299/// Slot for applying modifications.
300
302
303////////////////////////////////////////////////////////////////////////////////
304/// Slot for undoing last operation.
305
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
#define gClient
Definition TGClient.h:156
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
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:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
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:95
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:38
Editor class for TGeoNode objects.
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:41
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
TF1 * f1
Definition legend1.C:11