37 ClassImp(TGeoBBoxEditor);
40 kBOX_NAME, kBOX_X, kBOX_Y, kBOX_Z,
41 kBOX_OX, kBOX_OY, kBOX_OZ,
42 kBOX_APPLY, kBOX_CANCEL, kBOX_UNDO
48 TGeoBBoxEditor::TGeoBBoxEditor(
const TGWindow *p, Int_t width,
49 Int_t height, UInt_t options, Pixel_t back)
50 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
53 fDxi = fDyi = fDzi = 0.0;
54 memset(fOrigi, 0, 3*
sizeof(Double_t));
57 fIsShapeEditable = kFALSE;
61 fShapeName =
new TGTextEntry(
this,
new TGTextBuffer(50), kBOX_NAME);
62 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
63 fShapeName->SetToolTipText(
"Enter the box name");
64 fShapeName->Associate(
this);
65 AddFrame(fShapeName,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
68 MakeTitle(
"Box half-lengths");
69 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
71 TGCompositeFrame *f1 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
72 kLHintsExpandX | kFixedWidth | kOwnBackground);
73 f1->AddFrame(
new TGLabel(f1,
"DX"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
74 fBoxDx =
new TGNumberEntry(f1, 0., 5, kBOX_X);
75 fBoxDx->SetNumAttr(TGNumberFormat::kNEAPositive);
76 nef = (TGTextEntry*)fBoxDx->GetNumberEntry();
77 nef->SetToolTipText(
"Enter the box half-length in X");
78 fBoxDx->Associate(
this);
79 f1->AddFrame(fBoxDx,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
80 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
83 TGCompositeFrame *f2 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
84 kLHintsExpandX | kFixedWidth | kOwnBackground);
85 f2->AddFrame(
new TGLabel(f2,
"DY"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
86 fBoxDy =
new TGNumberEntry(f2, 0., 5, kBOX_Y);
87 fBoxDy->SetNumAttr(TGNumberFormat::kNEAPositive);
88 nef = (TGTextEntry*)fBoxDy->GetNumberEntry();
89 nef->SetToolTipText(
"Enter the box half-length in Y");
90 fBoxDy->Associate(
this);
91 f2->AddFrame(fBoxDy,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
92 compxyz->AddFrame(f2,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
95 TGCompositeFrame *f3 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
96 kLHintsExpandX | kFixedWidth | kOwnBackground);
97 f3->AddFrame(
new TGLabel(f3,
"DZ"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
98 fBoxDz =
new TGNumberEntry(f3, 0., 5, kBOX_Z);
99 fBoxDz->SetNumAttr(TGNumberFormat::kNEAPositive);
100 nef = (TGTextEntry*)fBoxDz->GetNumberEntry();
101 nef->SetToolTipText(
"Enter the box half-length in Z");
102 fBoxDz->Associate(
this);
103 f3->AddFrame(fBoxDz,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
104 compxyz->AddFrame(f3,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
106 compxyz->Resize(150,30);
107 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
109 MakeTitle(
"Box origin");
110 compxyz =
new TGCompositeFrame(
this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
112 f1 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
113 kLHintsExpandX | kFixedWidth | kOwnBackground);
114 f1->AddFrame(
new TGLabel(f1,
"OX"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
115 fBoxOx =
new TGNumberEntry(f1, 0., 5, kBOX_OX);
116 nef = (TGTextEntry*)fBoxOx->GetNumberEntry();
117 nef->SetToolTipText(
"Enter the box origin X coordinate");
118 fBoxOx->Associate(
this);
119 f1->AddFrame(fBoxOx,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
120 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
123 f2 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
124 kLHintsExpandX | kFixedWidth | kOwnBackground);
125 f2->AddFrame(
new TGLabel(f2,
"OY"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
126 fBoxOy =
new TGNumberEntry(f2, 0., 5, kBOX_OY);
127 nef = (TGTextEntry*)fBoxOy->GetNumberEntry();
128 nef->SetToolTipText(
"Enter the box origin Y coordinate");
129 fBoxOy->Associate(
this);
130 f2->AddFrame(fBoxOy,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
131 compxyz->AddFrame(f2,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
134 f3 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
135 kLHintsExpandX | kFixedWidth | kOwnBackground);
136 f3->AddFrame(
new TGLabel(f3,
"OZ"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
137 fBoxOz =
new TGNumberEntry(f3, 0., 5, kBOX_OZ);
138 nef = (TGTextEntry*)fBoxOz->GetNumberEntry();
139 nef->SetToolTipText(
"Enter the box origin Z coordinate");
140 fBoxOz->Associate(
this);
141 f3->AddFrame(fBoxOz,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
142 compxyz->AddFrame(f3,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 4, 4));
144 compxyz->Resize(150,30);
145 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
148 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
149 fDelayed =
new TGCheckButton(f1,
"Delayed draw");
150 f1->AddFrame(fDelayed,
new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
151 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
154 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
155 fApply =
new TGTextButton(f1,
"Apply");
156 f1->AddFrame(fApply,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
157 fApply->Associate(
this);
158 fUndo =
new TGTextButton(f1,
"Undo");
159 f1->AddFrame(fUndo,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
160 fUndo->Associate(
this);
161 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
162 fUndo->SetSize(fApply->GetSize());
168 TGeoBBoxEditor::~TGeoBBoxEditor()
171 TIter next(GetList());
172 while ((el = (TGFrameElement *)next())) {
173 if (el->fFrame->IsComposite())
174 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
182 void TGeoBBoxEditor::ConnectSignals2Slots()
184 fApply->Connect(
"Clicked()",
"TGeoBBoxEditor",
this,
"DoApply()");
185 fUndo->Connect(
"Clicked()",
"TGeoBBoxEditor",
this,
"DoUndo()");
186 fShapeName->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
187 fBoxDx->Connect(
"ValueSet(Long_t)",
"TGeoBBoxEditor",
this,
"DoDx()");
188 fBoxDy->Connect(
"ValueSet(Long_t)",
"TGeoBBoxEditor",
this,
"DoDy()");
189 fBoxDz->Connect(
"ValueSet(Long_t)",
"TGeoBBoxEditor",
this,
"DoDz()");
190 fBoxDx->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
191 fBoxDy->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
192 fBoxDz->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
193 fBoxOx->Connect(
"ValueSet(Long_t)",
"TGeoBBoxEditor",
this,
"DoOx()");
194 fBoxOy->Connect(
"ValueSet(Long_t)",
"TGeoBBoxEditor",
this,
"DoOy()");
195 fBoxOz->Connect(
"ValueSet(Long_t)",
"TGeoBBoxEditor",
this,
"DoOz()");
196 fBoxOx->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
197 fBoxOy->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
198 fBoxOz->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoBBoxEditor",
this,
"DoModified()");
206 void TGeoBBoxEditor::SetModel(TObject* obj)
208 if (obj == 0 || (obj->IsA()!=TGeoBBox::Class())) {
212 fShape = (TGeoBBox*)obj;
213 fDxi = fShape->GetDX();
214 fDyi = fShape->GetDY();
215 fDzi = fShape->GetDZ();
216 memcpy(fOrigi, fShape->GetOrigin(), 3*
sizeof(Double_t));
217 const char *sname = fShape->GetName();
218 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText(
"-no_name");
220 fShapeName->SetText(sname);
223 fBoxDx->SetNumber(fDxi);
224 fBoxDy->SetNumber(fDyi);
225 fBoxDz->SetNumber(fDzi);
226 fBoxOx->SetNumber(fOrigi[0]);
227 fBoxOy->SetNumber(fOrigi[1]);
228 fBoxOz->SetNumber(fOrigi[2]);
229 fApply->SetEnabled(kFALSE);
230 fUndo->SetEnabled(kFALSE);
232 if (fInit) ConnectSignals2Slots();
239 Bool_t TGeoBBoxEditor::IsDelayed()
const
241 return (fDelayed->GetState() == kButtonDown);
247 void TGeoBBoxEditor::DoName()
255 void TGeoBBoxEditor::DoApply()
257 const char *name = fShapeName->GetText();
258 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
259 Double_t dx = fBoxDx->GetNumber();
260 Double_t dy = fBoxDy->GetNumber();
261 Double_t dz = fBoxDz->GetNumber();
263 orig[0] = fBoxOx->GetNumber();
264 orig[1] = fBoxOy->GetNumber();
265 orig[2] = fBoxOz->GetNumber();
266 fShape->SetBoxDimensions(dx, dy, dz, orig);
268 fApply->SetEnabled(kFALSE);
270 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
271 TView *view = fPad->GetView();
274 fPad->GetView()->ShowAxis();
276 const Double_t *origin = fShape->GetOrigin();
277 view->SetRange(origin[0]-fShape->GetDX(), origin[1]-fShape->GetDY(), origin[2]-fShape->GetDZ(),
278 origin[0]+fShape->GetDX(), origin[1]+fShape->GetDY(), origin[2]+fShape->GetDZ());
288 void TGeoBBoxEditor::DoModified()
290 fApply->SetEnabled();
296 void TGeoBBoxEditor::DoUndo()
298 fBoxDx->SetNumber(fDxi);
299 fBoxDy->SetNumber(fDyi);
300 fBoxDz->SetNumber(fDzi);
301 fBoxOx->SetNumber(fOrigi[0]);
302 fBoxOy->SetNumber(fOrigi[1]);
303 fBoxOz->SetNumber(fOrigi[2]);
305 fUndo->SetEnabled(kFALSE);
306 fApply->SetEnabled(kFALSE);
312 void TGeoBBoxEditor::DoDx()
314 Double_t dx = fBoxDx->GetNumber();
317 fBoxDx->SetNumber(dx);
320 if (!IsDelayed()) DoApply();
326 void TGeoBBoxEditor::DoDy()
328 Double_t dy = fBoxDy->GetNumber();
331 fBoxDy->SetNumber(dy);
334 if (!IsDelayed()) DoApply();
340 void TGeoBBoxEditor::DoDz()
342 Double_t dz = fBoxDz->GetNumber();
345 fBoxDz->SetNumber(dz);
348 if (!IsDelayed()) DoApply();
354 void TGeoBBoxEditor::DoOx()
357 if (!IsDelayed()) DoApply();
363 void TGeoBBoxEditor::DoOy()
366 if (!IsDelayed()) DoApply();
372 void TGeoBBoxEditor::DoOz()
375 if (!IsDelayed()) DoApply();