38 ClassImp(TGeoHypeEditor);
41 kHYPE_NAME, kHYPE_RIN, kHYPE_ROUT, kHYPE_DZ, kHYPE_STIN,
42 kHYPE_STOUT, kHYPE_APPLY, kHYPE_UNDO
48 TGeoHypeEditor::TGeoHypeEditor(
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 fRini = fRouti = fStIni = fStOuti = 0.0;
56 fIsShapeEditable = kTRUE;
60 fShapeName =
new TGTextEntry(
this,
new TGTextBuffer(50), kHYPE_NAME);
61 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
62 fShapeName->SetToolTipText(
"Enter the hyperboloid name");
63 fShapeName->Associate(
this);
64 AddFrame(fShapeName,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
67 MakeTitle(
"Dimensions");
69 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
70 f1->AddFrame(
new TGLabel(f1,
"Rin"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
71 fERin =
new TGNumberEntry(f1, 0., 5, kHYPE_RIN);
72 fERin->SetNumAttr(TGNumberFormat::kNEAPositive);
73 fERin->Resize(100, fERin->GetDefaultHeight());
74 nef = (TGTextEntry*)fERin->GetNumberEntry();
75 nef->SetToolTipText(
"Enter the inner radius ");
76 fERin->Associate(
this);
77 f1->AddFrame(fERin,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
78 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
81 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
82 f1->AddFrame(
new TGLabel(f1,
"Rout"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
83 fERout =
new TGNumberEntry(f1, 0., 5, kHYPE_ROUT);
84 fERout->SetNumAttr(TGNumberFormat::kNEAPositive);
85 fERout->Resize(100, fERout->GetDefaultHeight());
86 nef = (TGTextEntry*)fERout->GetNumberEntry();
87 nef->SetToolTipText(
"Enter the outer radius");
88 fERout->Associate(
this);
89 f1->AddFrame(fERout,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
90 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
93 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
94 f1->AddFrame(
new TGLabel(f1,
"Dz"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
95 fEDz =
new TGNumberEntry(f1, 0., 5, kHYPE_DZ);
96 fEDz->SetNumAttr(TGNumberFormat::kNEAPositive);
97 fEDz->Resize(100, fEDz->GetDefaultHeight());
98 nef = (TGTextEntry*)fEDz->GetNumberEntry();
99 nef->SetToolTipText(
"Enter the half-length in Dz");
100 fEDz->Associate(
this);
101 f1->AddFrame(fEDz,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
102 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
105 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
106 f1->AddFrame(
new TGLabel(f1,
"StIn"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
107 fEStIn =
new TGNumberEntry(f1, 0., 5, kHYPE_STIN);
108 fEStIn->Resize(100, fEStIn->GetDefaultHeight());
109 nef = (TGTextEntry*)fEStIn->GetNumberEntry();
110 nef->SetToolTipText(
"Enter the stereo angle for inner surface");
111 fEStIn->Associate(
this);
112 f1->AddFrame(fEStIn,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
113 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
116 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
117 f1->AddFrame(
new TGLabel(f1,
"StOut"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
118 fEStOut =
new TGNumberEntry(f1, 0., 5, kHYPE_STOUT);
119 fEStOut->SetNumAttr(TGNumberFormat::kNEAPositive);
120 fEStOut->Resize(100, fEStOut->GetDefaultHeight());
121 nef = (TGTextEntry*)fEStOut->GetNumberEntry();
122 nef->SetToolTipText(
"Enter the stereo angle for outer surface");
123 fEStOut->Associate(
this);
124 f1->AddFrame(fEStOut,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
125 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
128 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
129 fDelayed =
new TGCheckButton(f1,
"Delayed draw");
130 f1->AddFrame(fDelayed,
new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
131 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
134 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
135 fApply =
new TGTextButton(f1,
"Apply");
136 f1->AddFrame(fApply,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
137 fApply->Associate(
this);
138 fUndo =
new TGTextButton(f1,
"Undo");
139 f1->AddFrame(fUndo,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
140 fUndo->Associate(
this);
141 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
142 fUndo->SetSize(fApply->GetSize());
148 TGeoHypeEditor::~TGeoHypeEditor()
151 TIter next(GetList());
152 while ((el = (TGFrameElement *)next())) {
153 if (el->fFrame->IsComposite())
154 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
162 void TGeoHypeEditor::ConnectSignals2Slots()
164 fApply->Connect(
"Clicked()",
"TGeoHypeEditor",
this,
"DoApply()");
165 fUndo->Connect(
"Clicked()",
"TGeoHypeEditor",
this,
"DoUndo()");
166 fShapeName->Connect(
"TextChanged(const char *)",
"TGeoHypeEditor",
this,
"DoModified()");
167 fERin->Connect(
"ValueSet(Long_t)",
"TGeoHypeEditor",
this,
"DoRin()");
168 fERout->Connect(
"ValueSet(Long_t)",
"TGeoHypeEditor",
this,
"DoRout()");
169 fEDz->Connect(
"ValueSet(Long_t)",
"TGeoHypeEditor",
this,
"DoDz()");
170 fEStIn->Connect(
"ValueSet(Long_t)",
"TGeoHypeEditor",
this,
"DoStIn()");
171 fEStOut->Connect(
"ValueSet(Long_t)",
"TGeoHypeEditor",
this,
"DoStOut()");
172 fERin->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoHypeEditor",
this,
"DoModified()");
173 fERout->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoHypeEditor",
this,
"DoModified()");
174 fEDz->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoHypeEditor",
this,
"DoModified()");
175 fEStIn->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoHypeEditor",
this,
"DoModified()");
176 fEStOut->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoHypeEditor",
this,
"DoModified()");
184 void TGeoHypeEditor::SetModel(TObject* obj)
186 if (obj == 0 || (obj->IsA()!=TGeoHype::Class())) {
190 fShape = (TGeoHype*)obj;
191 fRini = fShape->GetRmin();
192 fRouti = fShape->GetRmax();
193 fDzi = fShape->GetDz();
194 fStIni = fShape->GetStIn();
195 fStOuti = fShape->GetStOut();
196 const char *sname = fShape->GetName();
197 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText(
"-no_name");
199 fShapeName->SetText(sname);
202 fERin->SetNumber(fRini);
203 fERout->SetNumber(fRouti);
204 fEDz->SetNumber(fDzi);
205 fEStIn->SetNumber(fStIni);
206 fEStOut->SetNumber(fStOuti);
207 fApply->SetEnabled(kFALSE);
208 fUndo->SetEnabled(kFALSE);
210 if (fInit) ConnectSignals2Slots();
217 Bool_t TGeoHypeEditor::IsDelayed()
const
219 return (fDelayed->GetState() == kButtonDown);
225 void TGeoHypeEditor::DoName()
233 void TGeoHypeEditor::DoApply()
235 const char *name = fShapeName->GetText();
236 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
237 Double_t rin = fERin->GetNumber();
238 Double_t rout = fERout->GetNumber();
239 Double_t dz = fEDz->GetNumber();
240 Double_t stin = fEStIn->GetNumber();
241 Double_t stout = fEStOut->GetNumber();
242 Double_t tin = TMath::Tan(stin*TMath::DegToRad());
243 Double_t tout = TMath::Tan(stout*TMath::DegToRad());
244 if ((dz<=0) || (rin<0) || (rin>rout) ||
245 (rin*rin+tin*tin*dz*dz > rout*rout+tout*tout*dz*dz)) {
247 fApply->SetEnabled(kFALSE);
256 fShape->SetDimensions(param);
257 fShape->ComputeBBox();
259 fApply->SetEnabled(kFALSE);
261 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
262 TView *view = fPad->GetView();
265 fPad->GetView()->ShowAxis();
267 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
268 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
278 void TGeoHypeEditor::DoModified()
280 fApply->SetEnabled();
286 void TGeoHypeEditor::DoUndo()
288 fERin->SetNumber(fRini);
289 fERout->SetNumber(fRouti);
290 fEDz->SetNumber(fDzi);
291 fEStIn->SetNumber(fStIni);
292 fEStOut->SetNumber(fStOuti);
294 fUndo->SetEnabled(kFALSE);
295 fApply->SetEnabled(kFALSE);
301 void TGeoHypeEditor::DoRin()
303 Double_t rin = fERin->GetNumber();
304 Double_t rout = fERout->GetNumber();
305 Double_t dz = fEDz->GetNumber();
306 Double_t stin = fEStIn->GetNumber();
307 Double_t stout = fEStOut->GetNumber();
308 Double_t tin = TMath::Tan(stin*TMath::DegToRad());
309 Double_t tout = TMath::Tan(stout*TMath::DegToRad());
312 fERin->SetNumber(rin);
314 Double_t rinmax = TMath::Sqrt((rout*rout+tout*tout*dz*dz)/(tin*tin*dz*dz));
315 rinmax = TMath::Min(rinmax, rout);
318 fERin->SetNumber(rin);
321 if (!IsDelayed()) DoApply();
327 void TGeoHypeEditor::DoRout()
329 Double_t rin = fERin->GetNumber();
330 Double_t rout = fERout->GetNumber();
331 Double_t dz = fEDz->GetNumber();
332 Double_t stin = fEStIn->GetNumber();
333 Double_t stout = fEStOut->GetNumber();
334 Double_t tin = TMath::Tan(stin*TMath::DegToRad());
335 Double_t tout = TMath::Tan(stout*TMath::DegToRad());
336 Double_t routmin = TMath::Sqrt((rin*rin+tin*tin*dz*dz)/(tout*tout*dz*dz));
337 routmin = TMath::Max(routmin,rin);
338 if (rout < routmin) {
339 rout = routmin+1.e-6;
340 fERout->SetNumber(rout);
343 if (!IsDelayed()) DoApply();
349 void TGeoHypeEditor::DoDz()
351 Double_t rin = fERin->GetNumber();
352 Double_t rout = fERout->GetNumber();
353 Double_t dz = fEDz->GetNumber();
354 Double_t stin = fEStIn->GetNumber();
355 Double_t stout = fEStOut->GetNumber();
356 if (TMath::Abs(stin-stout)<1.e-6) {
358 fEStIn->SetNumber(stin);
360 Double_t tin = TMath::Tan(stin*TMath::DegToRad());
361 Double_t tout = TMath::Tan(stout*TMath::DegToRad());
366 Double_t dzmax = TMath::Sqrt((rout*rout-rin*rin)/(tin*tin-tout*tout));
372 if (!IsDelayed()) DoApply();
378 void TGeoHypeEditor::DoStIn()
380 Double_t rin = fERin->GetNumber();
381 Double_t rout = fERout->GetNumber();
382 Double_t dz = fEDz->GetNumber();
383 Double_t stin = fEStIn->GetNumber();
384 Double_t stout = fEStOut->GetNumber();
387 fEStIn->SetNumber(stin);
389 Double_t tin = TMath::Tan(stin*TMath::DegToRad());
390 Double_t tout = TMath::Tan(stout*TMath::DegToRad());
391 Double_t tinmax = TMath::Sqrt(tout*tout+(rout*rout-rin*rin)/(dz*dz));
394 stin = TMath::RadToDeg()*TMath::ATan(tin);
395 fEStIn->SetNumber(stin);
398 if (!IsDelayed()) DoApply();
404 void TGeoHypeEditor::DoStOut()
406 Double_t rin = fERin->GetNumber();
407 Double_t rout = fERout->GetNumber();
408 Double_t dz = fEDz->GetNumber();
409 Double_t stin = fEStIn->GetNumber();
410 Double_t stout = fEStOut->GetNumber();
413 fEStOut->SetNumber(stout);
415 Double_t tin = TMath::Tan(stin*TMath::DegToRad());
416 Double_t tout = TMath::Tan(stout*TMath::DegToRad());
417 Double_t tinmin = TMath::Sqrt((rout*rout-rin*rin)/(dz*dz));
420 stin = TMath::RadToDeg()*TMath::ATan(tin);
421 fEStIn->SetNumber(stin);
423 Double_t toutmin = TMath::Sqrt(tin*tin -tinmin*tinmin);
424 if (tout < toutmin) {
425 tout = toutmin+1.e-6;
426 stout = TMath::RadToDeg()*TMath::ATan(tout);
427 fEStOut->SetNumber(stout);
430 if (!IsDelayed()) DoApply();