37 ClassImp(TGeoTorusEditor);
40 kTORUS_NAME, kTORUS_R, kTORUS_RMIN, kTORUS_RMAX, kTORUS_PHI1,
41 kTORUS_DPHI, kTORUS_APPLY, kTORUS_UNDO
47 TGeoTorusEditor::TGeoTorusEditor(
const TGWindow *p, Int_t width,
48 Int_t height, UInt_t options, Pixel_t back)
49 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
52 fRi = fRmini = fRmaxi = fPhi1i = fDphii = 0.0;
55 fIsShapeEditable = kTRUE;
59 fShapeName =
new TGTextEntry(
this,
new TGTextBuffer(50), kTORUS_NAME);
60 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
61 fShapeName->SetToolTipText(
"Enter the torus name");
62 fShapeName->Associate(
this);
63 AddFrame(fShapeName,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
66 MakeTitle(
"Dimensions");
68 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
69 f1->AddFrame(
new TGLabel(f1,
"R"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
70 fER =
new TGNumberEntry(f1, 0., 5, kTORUS_R);
71 fER->SetNumAttr(TGNumberFormat::kNEAPositive);
72 fER->Resize(100, fER->GetDefaultHeight());
73 nef = (TGTextEntry*)fER->GetNumberEntry();
74 nef->SetToolTipText(
"Enter the axial radius R");
76 f1->AddFrame(fER,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
77 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
80 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
81 f1->AddFrame(
new TGLabel(f1,
"Rmin"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
82 fERmin =
new TGNumberEntry(f1, 0., 5, kTORUS_RMIN);
83 fERmin->SetNumAttr(TGNumberFormat::kNEAPositive);
84 fERmin->Resize(100, fERmin->GetDefaultHeight());
85 nef = (TGTextEntry*)fERmin->GetNumberEntry();
86 nef->SetToolTipText(
"Enter the inner radius Rmin");
87 fERmin->Associate(
this);
88 f1->AddFrame(fERmin,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
89 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
92 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
93 f1->AddFrame(
new TGLabel(f1,
"Rmax"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
94 fERmax =
new TGNumberEntry(f1, 0., 5, kTORUS_RMAX);
95 fERmax->SetNumAttr(TGNumberFormat::kNEAPositive);
96 fERmax->Resize(100, fERmax->GetDefaultHeight());
97 nef = (TGTextEntry*)fERmax->GetNumberEntry();
98 nef->SetToolTipText(
"Enter the outer radius Rmax");
99 fERmax->Associate(
this);
100 f1->AddFrame(fERmax,
new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
101 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
104 f1 =
new TGCompositeFrame(
this, 155, 10, kHorizontalFrame | kFixedWidth);
105 f1->AddFrame(
new TGLabel(f1,
"Phi1"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
106 fEPhi1 =
new TGNumberEntry(f1, 0., 5, kTORUS_PHI1);
107 fEPhi1->SetNumAttr(TGNumberFormat::kNEANonNegative);
108 fEPhi1->Resize(100, fEPhi1->GetDefaultHeight());
109 nef = (TGTextEntry*)fEPhi1->GetNumberEntry();
110 nef->SetToolTipText(
"Enter the starting phi angle[deg]");
111 fEPhi1->Associate(
this);
112 f1->AddFrame(fEPhi1,
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,
"Dphi"),
new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
118 fEDphi =
new TGNumberEntry(f1, 0., 5, kTORUS_DPHI);
119 fEDphi->SetNumAttr(TGNumberFormat::kNEAPositive);
120 fEDphi->Resize(100, fEDphi->GetDefaultHeight());
121 nef = (TGTextEntry*)fEDphi->GetNumberEntry();
122 nef->SetToolTipText(
"Enter the extent phi Dphi [deg]");
123 fEDphi->Associate(
this);
124 f1->AddFrame(fEDphi,
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 TGeoTorusEditor::~TGeoTorusEditor()
151 TIter next(GetList());
152 while ((el = (TGFrameElement *)next())) {
153 if (el->fFrame->IsComposite())
154 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
162 void TGeoTorusEditor::ConnectSignals2Slots()
164 fApply->Connect(
"Clicked()",
"TGeoTorusEditor",
this,
"DoApply()");
165 fUndo->Connect(
"Clicked()",
"TGeoTorusEditor",
this,
"DoUndo()");
166 fShapeName->Connect(
"TextChanged(const char *)",
"TGeoTorusEditor",
this,
"DoModified()");
167 fER->Connect(
"ValueSet(Long_t)",
"TGeoTorusEditor",
this,
"DoR()");
168 fERmin->Connect(
"ValueSet(Long_t)",
"TGeoTorusEditor",
this,
"DoRmin()");
169 fERmax->Connect(
"ValueSet(Long_t)",
"TGeoTorusEditor",
this,
"DoRmax()");
170 fEPhi1->Connect(
"ValueSet(Long_t)",
"TGeoTorusEditor",
this,
"DoPhi1()");
171 fEDphi->Connect(
"ValueSet(Long_t)",
"TGeoTorusEditor",
this,
"DoDphi()");
172 fER->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTorusEditor",
this,
"DoModified()");
173 fERmin->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTorusEditor",
this,
"DoModified()");
174 fERmax->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTorusEditor",
this,
"DoModified()");
175 fEPhi1->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTorusEditor",
this,
"DoModified()");
176 fEDphi->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoTorusEditor",
this,
"DoModified()");
184 void TGeoTorusEditor::SetModel(TObject* obj)
186 if (obj == 0 || (obj->IsA()!=TGeoTorus::Class())) {
190 fShape = (TGeoTorus*)obj;
191 fRi = fShape->GetR();
192 fRmini = fShape->GetRmin();
193 fRmaxi = fShape->GetRmax();
194 fPhi1i = fShape->GetPhi1();
195 fDphii = fShape->GetDphi();
196 const char *sname = fShape->GetName();
197 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText(
"-no_name");
199 fShapeName->SetText(sname);
203 fERmin->SetNumber(fRmini);
204 fERmax->SetNumber(fRmaxi);
205 fEPhi1->SetNumber(fPhi1i);
206 fEDphi->SetNumber(fDphii);
207 fApply->SetEnabled(kFALSE);
208 fUndo->SetEnabled(kFALSE);
210 if (fInit) ConnectSignals2Slots();
217 Bool_t TGeoTorusEditor::IsDelayed()
const
219 return (fDelayed->GetState() == kButtonDown);
225 void TGeoTorusEditor::DoName()
233 void TGeoTorusEditor::DoApply()
235 const char *name = fShapeName->GetText();
236 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
237 Double_t r = fER->GetNumber();
238 Double_t rmax = fERmax->GetNumber();
239 Double_t rmin = fERmin->GetNumber();
240 Double_t phi = fEPhi1->GetNumber();
241 Double_t dphi = fEDphi->GetNumber();
248 fShape->SetDimensions(param);
249 fShape->ComputeBBox();
251 fApply->SetEnabled(kFALSE);
253 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
254 TView *view = fPad->GetView();
257 fPad->GetView()->ShowAxis();
259 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
260 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
270 void TGeoTorusEditor::DoModified()
272 fApply->SetEnabled();
278 void TGeoTorusEditor::DoUndo()
281 fERmin->SetNumber(fRmini);
282 fERmax->SetNumber(fRmaxi);
283 fEPhi1->SetNumber(fPhi1i);
284 fEDphi->SetNumber(fDphii);
286 fUndo->SetEnabled(kFALSE);
287 fApply->SetEnabled(kFALSE);
293 void TGeoTorusEditor::DoR()
295 Double_t r = fER->GetNumber();
296 Double_t rmax = fERmax->GetNumber();
302 if (!IsDelayed()) DoApply();
308 void TGeoTorusEditor::DoRmin()
310 Double_t rmin = fERmin->GetNumber();
311 Double_t rmax = fERmax->GetNumber();
314 fERmin->SetNumber(rmin);
317 if (!IsDelayed()) DoApply();
323 void TGeoTorusEditor::DoRmax()
325 Double_t r = fER->GetNumber();
326 Double_t rmin = fERmin->GetNumber();
327 Double_t rmax = fERmax->GetNumber();
330 fERmax->SetNumber(rmax);
334 fERmax->SetNumber(rmax);
337 if (!IsDelayed()) DoApply();
343 void TGeoTorusEditor::DoPhi1()
345 Double_t phi = fEPhi1->GetNumber();
346 if (phi<0 || phi>360) {
348 fEPhi1->SetNumber(phi);
351 if (!IsDelayed()) DoApply();
357 void TGeoTorusEditor::DoDphi()
359 Double_t dphi = fEDphi->GetNumber();
360 if (dphi<=0 || dphi>360) {
362 fEDphi->SetNumber(dphi);
365 if (!IsDelayed()) DoApply();