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
41};
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");
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);
65 nef->SetToolTipText("Enter the node copy number");
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);
80 fBSelMother->SetToolTipText("Select one of the existing volumes");
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));
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);
98 fBSelVolume->SetToolTipText("Select one of the existing volumes");
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);
114 f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
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));
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
181
183 if (fSelectedMother)
186 if (fSelectedVolume)
189 if (fSelectedMatrix)
191
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)
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)
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)
238 else
239 fSelectedMatrix = matrix;
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Edit the mother volume.
244
246{
247 if (!fSelectedMother) {
249 return;
250 }
253 fTabMgr->SetTab();
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Edit selected volume.
259
261{
262 if (!fSelectedVolume) {
264 return;
265 }
268 fTabMgr->SetTab();
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Edit selected material.
274
276{
277 if (!fSelectedMatrix)
278 return;
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;
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
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
winID h TVirtualViewer3D TVirtualGLPainter p
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 SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:459
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
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
TGFrame * fFrame
Definition TGLayout.h:112
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:321
virtual void SetSize(const TGDimension &s)
Definition TGFrame.h:252
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
TGDimension GetSize() const
Definition TGFrame.h:230
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGLabel.cxx:362
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:180
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.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
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
const char * GetText() const
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:72
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
Common base class for geombuilder editors.
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
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
virtual TGeoMatrix * GetMatrix() const =0
static TClass * Class()
TGeoVolume * GetMotherVolume() const
Definition TGeoNode.h:90
Int_t GetNumber() const
Definition TGeoNode.h:93
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:43
void Draw(Option_t *option="") override
draw top volume according to option
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
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
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:869
TF1 * f1
Definition legend1.C:11