33 ClassImp(TGeoNodeEditor);
36 kNODE_NAME, kNODE_ID, kNODE_VOLSEL, kNODE_MVOLSEL,
37 kNODE_MATRIX, kNODE_EDIT_VOL, kNODE_EDIT_MATRIX
43 TGeoNodeEditor::TGeoNodeEditor(
const TGWindow *p, Int_t width,
44 Int_t height, UInt_t options, Pixel_t back)
45 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
54 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 140, 30, kHorizontalFrame | kRaisedFrame);
55 fNodeName =
new TGTextEntry(f1,
new TGTextBuffer(50), kNODE_NAME);
56 fNodeName->Resize(100, fNodeName->GetDefaultHeight());
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);
62 nef = (TGTextEntry*)fNodeNumber->GetNumberEntry();
63 nef->SetToolTipText(
"Enter the node copy number");
64 fNodeNumber->Associate(
this);
65 f1->AddFrame(fNodeNumber,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
66 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 3, 3, 2, 5));
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);
75 fLSelMother->SetTextColor(color);
76 fLSelMother->ChangeOptions(kSunkenFrame | kDoubleBorder);
77 f1->AddFrame(fLSelMother,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
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));
89 f1 =
new TGCompositeFrame(
this, 155, 30, kHorizontalFrame | kFixedWidth);
91 fLSelVolume =
new TGLabel(f1,
"Select volume");
92 gClient->GetColorByName(
"#0000ff", color);
93 fLSelVolume->SetTextColor(color);
94 fLSelVolume->ChangeOptions(kSunkenFrame | kDoubleBorder);
95 f1->AddFrame(fLSelVolume,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
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));
107 f1 =
new TGCompositeFrame(
this, 155, 30, kHorizontalFrame | kFixedWidth);
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));
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());
138 TGeoNodeEditor::~TGeoNodeEditor()
141 TIter next(GetList());
142 while ((el = (TGFrameElement *)next())) {
143 if (el->fFrame->IsComposite())
144 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
152 void TGeoNodeEditor::ConnectSignals2Slots()
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()");
170 void TGeoNodeEditor::SetModel(TObject* obj)
172 if (obj == 0 || !obj->InheritsFrom(TGeoNode::Class())) {
176 fNode = (TGeoNode*)obj;
177 const char *sname = fNode->GetName();
178 fNodeName->SetText(sname);
180 fNodeNumber->SetNumber(fNode->GetNumber());
182 fSelectedMother = fNode->GetMotherVolume();
183 if (fSelectedMother) fLSelMother->SetText(fSelectedMother->GetName());
184 fSelectedVolume = fNode->GetVolume();
185 if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName());
186 fSelectedMatrix = fNode->GetMatrix();
187 if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName());
189 fApply->SetEnabled(kFALSE);
190 fUndo->SetEnabled(kFALSE);
192 if (fInit) ConnectSignals2Slots();
199 void TGeoNodeEditor::DoSelectMother()
201 TGeoVolume *vol = fSelectedMother;
202 new TGeoVolumeDialog(fBSelMother, gClient->GetRoot(), 200,300);
203 fSelectedMother = (TGeoVolume*)TGeoVolumeDialog::GetSelected();
204 if (fSelectedMother) fLSelMother->SetText(fSelectedMother->GetName());
205 else fSelectedMother = vol;
211 void TGeoNodeEditor::DoSelectVolume()
213 TGeoVolume *vol = fSelectedVolume;
214 new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300);
215 fSelectedVolume = (TGeoVolume*)TGeoVolumeDialog::GetSelected();
216 if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName());
217 else fSelectedVolume = vol;
223 void TGeoNodeEditor::DoSelectMatrix()
225 TGeoMatrix *matrix = fSelectedMatrix;
226 new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200,300);
227 fSelectedMatrix = (TGeoMatrix*)TGeoMatrixDialog::GetSelected();
228 if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName());
229 else fSelectedMatrix = matrix;
235 void TGeoNodeEditor::DoEditMother()
237 if (!fSelectedMother) {
238 fTabMgr->SetVolTabEnabled(kFALSE);
241 fTabMgr->SetVolTabEnabled();
242 fTabMgr->GetVolumeEditor(fSelectedMother);
244 fSelectedMother->Draw();
250 void TGeoNodeEditor::DoEditVolume()
252 if (!fSelectedVolume) {
253 fTabMgr->SetVolTabEnabled(kFALSE);
256 fTabMgr->SetVolTabEnabled();
257 fTabMgr->GetVolumeEditor(fSelectedVolume);
259 fSelectedVolume->Draw();
265 void TGeoNodeEditor::DoEditMatrix()
267 if (!fSelectedMatrix)
return;
268 fTabMgr->GetMatrixEditor(fSelectedMatrix);
274 void TGeoNodeEditor::DoNodeName()
276 const char *name = fNodeName->GetText();
277 if (!name[0] || !strcmp(name, fNode->GetName()))
return;
278 fNode->SetName(name);
284 void TGeoNodeEditor::DoNodeNumber()
291 void TGeoNodeEditor::DoApply()
298 void TGeoNodeEditor::DoUndo()