00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "TGeoTrapEditor.h"
00029 #include "TGeoTabManager.h"
00030 #include "TGeoArb8.h"
00031 #include "TGeoManager.h"
00032 #include "TVirtualGeoPainter.h"
00033 #include "TPad.h"
00034 #include "TView.h"
00035 #include "TGTab.h"
00036 #include "TGComboBox.h"
00037 #include "TGButton.h"
00038 #include "TGTextEntry.h"
00039 #include "TGNumberEntry.h"
00040 #include "TGLabel.h"
00041
00042 ClassImp(TGeoTrapEditor)
00043
00044 enum ETGeoTrapWid {
00045 kTRAP_NAME, kTRAP_H1, kTRAP_BL1, kTRAP_TL1, kTRAP_DZ, kTRAP_ALPHA1,
00046 kTRAP_SC1, kTRAP_SC2, kTRAP_THETA, kTRAP_PHI, kTRAP_APPLY, kTRAP_UNDO
00047 };
00048
00049
00050 TGeoTrapEditor::TGeoTrapEditor(const TGWindow *p, Int_t width,
00051 Int_t height, UInt_t options, Pixel_t back)
00052 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
00053 {
00054
00055 fShape = 0;
00056 fH1i = fBl1i = fTl1i = fDzi = fAlpha1i = fThetai = fPhii = fSci = 0.0;
00057 fNamei = "";
00058 fIsModified = kFALSE;
00059 fIsShapeEditable = kTRUE;
00060
00061
00062 MakeTitle("Name");
00063 fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTRAP_NAME);
00064 fShapeName->Resize(135, fShapeName->GetDefaultHeight());
00065 fShapeName->SetToolTipText("Enter the parallelipiped name");
00066 fShapeName->Associate(this);
00067 AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00068
00069 TGTextEntry *nef;
00070 MakeTitle("Dimensions");
00071
00072 TGCompositeFrame *f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00073 f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00074 fEH1 = new TGNumberEntry(f1, 0., 5, kTRAP_H1);
00075 fEH1->SetNumAttr(TGNumberFormat::kNEAPositive);
00076 fEH1->Resize(100, fEH1->GetDefaultHeight());
00077 nef = (TGTextEntry*)fEH1->GetNumberEntry();
00078 nef->SetToolTipText("Enter the half length in y at low z");
00079 fEH1->Associate(this);
00080 f1->AddFrame(fEH1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00081 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00082
00083
00084 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00085 f1->AddFrame(new TGLabel(f1, "DX1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00086 fEBl1 = new TGNumberEntry(f1, 0., 5, kTRAP_BL1);
00087 fEBl1->SetNumAttr(TGNumberFormat::kNEAPositive);
00088 fEBl1->Resize(100, fEBl1->GetDefaultHeight());
00089 nef = (TGTextEntry*)fEBl1->GetNumberEntry();
00090 nef->SetToolTipText("Enter the half length in x at low z and y low edge");
00091 fEBl1->Associate(this);
00092 f1->AddFrame(fEBl1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00093 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00094
00095
00096 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00097 f1->AddFrame(new TGLabel(f1, "DX2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00098 fETl1 = new TGNumberEntry(f1, 0., 5, kTRAP_TL1);
00099 fETl1->SetNumAttr(TGNumberFormat::kNEAPositive);
00100 fETl1->Resize(100, fETl1->GetDefaultHeight());
00101 nef = (TGTextEntry*)fETl1->GetNumberEntry();
00102 nef->SetToolTipText("Enter the half length in x at low z and y high edge");
00103 fETl1->Associate(this);
00104 f1->AddFrame(fETl1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00105 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00106
00107
00108 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00109 f1->AddFrame(new TGLabel(f1, "SC1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00110 fESc1 = new TGNumberEntry(f1, 0., 5, kTRAP_SC1);
00111 fESc1->SetNumAttr(TGNumberFormat::kNEAPositive);
00112 fESc1->Resize(100, fESc1->GetDefaultHeight());
00113 nef = (TGTextEntry*)fESc1->GetNumberEntry();
00114 nef->SetToolTipText("Enter the scale factor for lower Z face");
00115 fESc1->Associate(this);
00116 f1->AddFrame(fESc1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00117 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00118
00119
00120 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00121 f1->AddFrame(new TGLabel(f1, "SC2"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00122 fESc2 = new TGNumberEntry(f1, 0., 5, kTRAP_SC2);
00123 fESc2->SetNumAttr(TGNumberFormat::kNEAPositive);
00124 fESc2->Resize(100, fESc2->GetDefaultHeight());
00125 nef = (TGTextEntry*)fESc2->GetNumberEntry();
00126 nef->SetToolTipText("Enter the scale factor for upper Z face");
00127 fESc2->Associate(this);
00128 f1->AddFrame(fESc2, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00129 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00130
00131
00132 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00133 f1->AddFrame(new TGLabel(f1, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00134 fEDz = new TGNumberEntry(f1, 0., 5, kTRAP_DZ);
00135 fEDz->SetNumAttr(TGNumberFormat::kNEAPositive);
00136 fEDz->Resize(100, fEDz->GetDefaultHeight());
00137 nef = (TGTextEntry*)fEDz->GetNumberEntry();
00138 nef->SetToolTipText("Enter the half-lenth in Z");
00139 fEDz->Associate(this);
00140 f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00141 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00142
00143
00144 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00145 f1->AddFrame(new TGLabel(f1, "ALPHA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00146 fEAlpha1 = new TGNumberEntry(f1, 0., 5, kTRAP_ALPHA1);
00147 fEAlpha1->Resize(100, fEAlpha1->GetDefaultHeight());
00148 nef = (TGTextEntry*)fEAlpha1->GetNumberEntry();
00149 nef->SetToolTipText("Enter angle between centers of x edges an y axis at low z");
00150 fEAlpha1->Associate(this);
00151 f1->AddFrame(fEAlpha1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00152 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00153
00154
00155 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00156 f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00157 fETheta = new TGNumberEntry(f1, 0., 5, kTRAP_THETA);
00158 fETheta->SetNumAttr(TGNumberFormat::kNEAPositive);
00159 fETheta->Resize(100, fETheta->GetDefaultHeight());
00160 nef = (TGTextEntry*)fETheta->GetNumberEntry();
00161 nef->SetToolTipText("Enter initial theta");
00162 fETheta->Associate(this);
00163 f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00164 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00165
00166
00167 f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00168 f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00169 fEPhi = new TGNumberEntry(f1, 0., 5, kTRAP_PHI);
00170 fEPhi->SetNumAttr(TGNumberFormat::kNEAPositive);
00171 fEPhi->Resize(100, fEPhi->GetDefaultHeight());
00172 nef = (TGTextEntry*)fEPhi->GetNumberEntry();
00173 nef->SetToolTipText("Enter initial phi");
00174 fEPhi->Associate(this);
00175 f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00176 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00177
00178
00179 fDFrame = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame);
00180 fDelayed = new TGCheckButton(fDFrame, "Delayed draw");
00181 fDFrame->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4));
00182 AddFrame(fDFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
00183
00184
00185 fBFrame = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00186 fApply = new TGTextButton(fBFrame, "Apply");
00187 fBFrame->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00188 fApply->Associate(this);
00189 fUndo = new TGTextButton(fBFrame, "Undo");
00190 fBFrame->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
00191 fUndo->Associate(this);
00192 AddFrame(fBFrame, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4));
00193 fUndo->SetSize(fApply->GetSize());
00194 }
00195
00196
00197 TGeoTrapEditor::~TGeoTrapEditor()
00198 {
00199
00200 TGFrameElement *el;
00201 TIter next(GetList());
00202 while ((el = (TGFrameElement *)next())) {
00203 if (el->fFrame->IsComposite())
00204 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
00205 }
00206 Cleanup();
00207 }
00208
00209
00210 void TGeoTrapEditor::ConnectSignals2Slots()
00211 {
00212
00213 fApply->Connect("Clicked()", "TGeoTrapEditor", this, "DoApply()");
00214 fUndo->Connect("Clicked()", "TGeoTrapEditor", this, "DoUndo()");
00215 fShapeName->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00216 fEH1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoH1()");
00217 fEBl1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoBl1()");
00218 fETl1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoTl1()");
00219 fEDz->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoDz()");
00220 fESc1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoSc1()");
00221 fESc2->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoSc2()");
00222 fEAlpha1->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoAlpha1()");
00223 fETheta->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoTheta()");
00224 fEPhi->Connect("ValueSet(Long_t)", "TGeoTrapEditor", this, "DoPhi()");
00225 fEH1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00226 fEBl1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00227 fETl1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00228 fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00229 fESc1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00230 fESc2->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00231 fEAlpha1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00232 fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00233 fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTrapEditor", this, "DoModified()");
00234 fInit = kFALSE;
00235 }
00236
00237
00238 void TGeoTrapEditor::SetModel(TObject* obj)
00239 {
00240
00241 if (obj == 0 || (obj->IsA()!=TGeoTrap::Class())) {
00242 SetActive(kFALSE);
00243 return;
00244 }
00245 fShape = (TGeoTrap*)obj;
00246 fH1i = fShape->GetH1();
00247 fBl1i = fShape->GetBl1();
00248 fTl1i = fShape->GetTl1();
00249 fDzi = fShape->GetDz();
00250 Double_t h2i = fShape->GetH2();
00251
00252
00253 fSci = h2i/fH1i;
00254 fAlpha1i = fShape->GetAlpha1();
00255 fThetai = fShape->GetTheta();
00256 fPhii = fShape->GetPhi();
00257 const char *sname = fShape->GetName();
00258 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
00259 else {
00260 fShapeName->SetText(sname);
00261 fNamei = sname;
00262 }
00263 fEH1->SetNumber(fH1i);
00264 fEBl1->SetNumber(fBl1i);
00265 fETl1->SetNumber(fTl1i);
00266 fEDz->SetNumber(fDzi);
00267 fESc1->SetNumber(1.);
00268 fESc2->SetNumber(fSci);
00269 fEAlpha1->SetNumber(fAlpha1i);
00270 fETheta->SetNumber(fThetai);
00271 fEPhi->SetNumber(fPhii);
00272 fApply->SetEnabled(kFALSE);
00273 fUndo->SetEnabled(kFALSE);
00274
00275 if (fInit) ConnectSignals2Slots();
00276 SetActive();
00277 }
00278
00279
00280 Bool_t TGeoTrapEditor::IsDelayed() const
00281 {
00282
00283 return (fDelayed->GetState() == kButtonDown);
00284 }
00285
00286
00287 void TGeoTrapEditor::DoName()
00288 {
00289
00290 DoModified();
00291 }
00292
00293
00294 void TGeoTrapEditor::DoApply()
00295 {
00296
00297 const char *name = fShapeName->GetText();
00298 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
00299 Double_t sc1 = fESc1->GetNumber();
00300 Double_t sc2 = fESc2->GetNumber();
00301 Double_t h1 = sc1*fEH1->GetNumber();
00302 Double_t bl1 = sc1*fEBl1->GetNumber();
00303 Double_t tl1 = sc1*fETl1->GetNumber();
00304 Double_t h2 = sc2*fEH1->GetNumber();
00305 Double_t bl2 = sc2*fEBl1->GetNumber();
00306 Double_t tl2 = sc2*fETl1->GetNumber();
00307 Double_t dz = fEDz->GetNumber();
00308 Double_t alpha1 = fEAlpha1->GetNumber();
00309 Double_t theta = fETheta->GetNumber();
00310 Double_t phi = fEPhi->GetNumber();
00311 Double_t param[11];
00312 param[0] = dz;
00313 param[1] = theta;
00314 param[2] = phi;
00315 param[3] = h1;
00316 param[7] = h2;
00317 param[4] = bl1;
00318 param[8] = bl2;
00319 param[5] = tl1;
00320 param[9] = tl2;
00321 param[6] = alpha1;
00322 param[10] = alpha1;
00323 fShape->SetDimensions(param);
00324 fShape->ComputeBBox();
00325 fUndo->SetEnabled();
00326 fApply->SetEnabled(kFALSE);
00327 if (fPad) {
00328 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
00329 TView *view = fPad->GetView();
00330 if (!view) {
00331 fShape->Draw();
00332 fPad->GetView()->ShowAxis();
00333 } else {
00334 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
00335 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
00336 Update();
00337 }
00338 } else Update();
00339 }
00340 }
00341
00342
00343 void TGeoTrapEditor::DoModified()
00344 {
00345
00346 fApply->SetEnabled();
00347 }
00348
00349
00350 void TGeoTrapEditor::DoUndo()
00351 {
00352
00353 fEH1->SetNumber(fH1i);
00354 fEBl1->SetNumber(fBl1i);
00355 fETl1->SetNumber(fTl1i);
00356 fESc1->SetNumber(1.);
00357 fESc2->SetNumber(fSci);
00358 fEDz->SetNumber(fDzi);
00359 fEAlpha1->SetNumber(fAlpha1i);
00360 fETheta->SetNumber(fThetai);
00361 fEPhi->SetNumber(fPhii);
00362 DoApply();
00363 fUndo->SetEnabled(kFALSE);
00364 fApply->SetEnabled(kFALSE);
00365 }
00366
00367
00368 void TGeoTrapEditor::DoH1()
00369 {
00370
00371 Double_t h1 = fEH1->GetNumber();
00372 if (h1<=0) {
00373 h1 = 0.1;
00374 fEH1->SetNumber(h1);
00375 }
00376 DoModified();
00377 if (!IsDelayed()) DoApply();
00378 }
00379
00380
00381 void TGeoTrapEditor::DoBl1()
00382 {
00383
00384 Double_t bl1 = fEBl1->GetNumber();
00385 if (bl1<=0) {
00386 bl1 = 0.1;
00387 fEBl1->SetNumber(bl1);
00388 }
00389 DoModified();
00390 if (!IsDelayed()) DoApply();
00391 }
00392
00393
00394 void TGeoTrapEditor::DoTl1()
00395 {
00396
00397 Double_t tl1 = fETl1->GetNumber();
00398 if (tl1<=0) {
00399 tl1 = 0.1;
00400 fETl1->SetNumber(tl1);
00401 }
00402 DoModified();
00403 if (!IsDelayed()) DoApply();
00404 }
00405
00406
00407 void TGeoTrapEditor::DoDz()
00408 {
00409
00410 Double_t dz = fEDz->GetNumber();
00411 if (dz<=0) {
00412 dz = 0.1;
00413 fEDz->SetNumber(dz);
00414 }
00415 DoModified();
00416 if (!IsDelayed()) DoApply();
00417 }
00418
00419
00420 void TGeoTrapEditor::DoSc1()
00421 {
00422
00423 Double_t sc1 = fESc1->GetNumber();
00424 if (sc1<=0) {
00425 sc1 = 0.1;
00426 fESc1->SetNumber(sc1);
00427 }
00428 DoModified();
00429 if (!IsDelayed()) DoApply();
00430 }
00431
00432
00433 void TGeoTrapEditor::DoSc2()
00434 {
00435
00436 Double_t sc2 = fESc2->GetNumber();
00437 if (sc2<=0) {
00438 sc2 = 0.1;
00439 fESc2->SetNumber(sc2);
00440 }
00441 DoModified();
00442 if (!IsDelayed()) DoApply();
00443 }
00444
00445
00446 void TGeoTrapEditor::DoAlpha1()
00447 {
00448
00449 Double_t alpha1 = fEAlpha1->GetNumber();
00450 if (TMath::Abs(alpha1)>=90) {
00451 alpha1 = 89.9*TMath::Sign(1.,alpha1);
00452 fEAlpha1->SetNumber(alpha1);
00453 }
00454 DoModified();
00455 if (!IsDelayed()) DoApply();
00456 }
00457
00458
00459 void TGeoTrapEditor::DoTheta()
00460 {
00461
00462 Double_t theta = fETheta->GetNumber();
00463 if (theta<0) {
00464 theta = 0;
00465 fETheta->SetNumber(theta);
00466 }
00467 if (theta>180) {
00468 theta = 180;
00469 fETheta->SetNumber(theta);
00470 }
00471 DoModified();
00472 if (!IsDelayed()) DoApply();
00473 }
00474
00475
00476 void TGeoTrapEditor::DoPhi()
00477 {
00478
00479 Double_t phi = fEPhi->GetNumber();
00480 if (phi<0 || phi>360) {
00481 phi = 0;
00482 fEPhi->SetNumber(phi);
00483 }
00484 DoModified();
00485 if (!IsDelayed()) DoApply();
00486 }
00487
00488 ClassImp(TGeoGtraEditor)
00489
00490 enum ETGeoGtraWid {
00491 kGTRA_TWIST
00492 };
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 TGeoGtraEditor::TGeoGtraEditor(const TGWindow *p, Int_t width,
00512 Int_t height, UInt_t options, Pixel_t back)
00513 : TGeoTrapEditor(p, width, height, options, back)
00514 {
00515
00516 fTwisti = 0;
00517 TGTextEntry *nef;
00518
00519 TGCompositeFrame *f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth);
00520 f1->AddFrame(new TGLabel(f1, "TWIST"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00521 fETwist = new TGNumberEntry(f1, 0., 5, kGTRA_TWIST);
00522 fETwist->Resize(100, fETwist->GetDefaultHeight());
00523 nef = (TGTextEntry*)fETwist->GetNumberEntry();
00524 nef->SetToolTipText("Enter twist angle");
00525 fETwist->Associate(this);
00526 f1->AddFrame(fETwist, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
00527 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00528 TGeoTabManager::MoveFrame(fDFrame, this);
00529 TGeoTabManager::MoveFrame(fBFrame, this);
00530 fETwist->Connect("ValueSet(Long_t)", "TGeoGtraEditor", this, "DoTwist()");
00531 nef->Connect("TextChanged(const char *)", "TGeoGtraEditor", this, "DoModified()");
00532 }
00533
00534 TGeoGtraEditor::~TGeoGtraEditor()
00535 {
00536
00537 TGFrameElement *el;
00538 TIter next(GetList());
00539 while ((el = (TGFrameElement *)next())) {
00540 if (el->fFrame->IsComposite())
00541 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
00542 }
00543 Cleanup();
00544 }
00545
00546
00547 void TGeoGtraEditor::SetModel(TObject* obj)
00548 {
00549
00550 if (obj == 0 || (obj->IsA()!=TGeoGtra::Class())) {
00551 SetActive(kFALSE);
00552 return;
00553 }
00554 fShape = (TGeoTrap*)obj;
00555 fH1i = fShape->GetH1();
00556 fBl1i = fShape->GetBl1();
00557 fTl1i = fShape->GetTl1();
00558 fDzi = fShape->GetDz();
00559 Double_t h2i = fShape->GetH2();
00560
00561
00562 fSci = h2i/fH1i;
00563 fAlpha1i = fShape->GetAlpha1();
00564 fThetai = fShape->GetTheta();
00565 fPhii = fShape->GetPhi();
00566 fTwisti = ((TGeoGtra*)fShape)->GetTwistAngle();
00567 const char *sname = fShape->GetName();
00568 if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name");
00569 else {
00570 fShapeName->SetText(sname);
00571 fNamei = sname;
00572 }
00573 fEH1->SetNumber(fH1i);
00574 fEBl1->SetNumber(fBl1i);
00575 fETl1->SetNumber(fTl1i);
00576 fEDz->SetNumber(fDzi);
00577 fESc1->SetNumber(1.);
00578 fESc2->SetNumber(fSci);
00579 fEAlpha1->SetNumber(fAlpha1i);
00580 fETheta->SetNumber(fThetai);
00581 fEPhi->SetNumber(fPhii);
00582 fETwist->SetNumber(fTwisti);
00583 fApply->SetEnabled(kFALSE);
00584 fUndo->SetEnabled(kFALSE);
00585
00586 if (fInit) ConnectSignals2Slots();
00587 SetActive();
00588 }
00589
00590
00591 void TGeoGtraEditor::DoApply()
00592 {
00593
00594 const char *name = fShapeName->GetText();
00595 if (strcmp(name,fShape->GetName())) fShape->SetName(name);
00596 Double_t sc1 = fESc1->GetNumber();
00597 Double_t sc2 = fESc2->GetNumber();
00598 Double_t h1 = sc1*fEH1->GetNumber();
00599 Double_t bl1 = sc1*fEBl1->GetNumber();
00600 Double_t tl1 = sc1*fETl1->GetNumber();
00601 Double_t h2 = sc2*fEH1->GetNumber();
00602 Double_t bl2 = sc2*fEBl1->GetNumber();
00603 Double_t tl2 = sc2*fETl1->GetNumber();
00604 Double_t dz = fEDz->GetNumber();
00605 Double_t alpha1 = fEAlpha1->GetNumber();
00606 Double_t theta = fETheta->GetNumber();
00607 Double_t phi = fEPhi->GetNumber();
00608 Double_t twist = fETwist->GetNumber();
00609 Double_t param[12];
00610 param[0] = dz;
00611 param[1] = theta;
00612 param[2] = phi;
00613 param[3] = h1;
00614 param[7] = h2;
00615 param[4] = bl1;
00616 param[8] = bl2;
00617 param[5] = tl1;
00618 param[9] = tl2;
00619 param[6] = alpha1;
00620 param[10] = alpha1;
00621 param[11] = twist;
00622 TGeoGtra *shape = (TGeoGtra*)fShape;
00623 shape->SetDimensions(param);
00624 shape->ComputeBBox();
00625 fUndo->SetEnabled();
00626 fApply->SetEnabled(kFALSE);
00627 if (fPad) {
00628 if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) {
00629 TView *view = fPad->GetView();
00630 if (!view) {
00631 fShape->Draw();
00632 fPad->GetView()->ShowAxis();
00633 } else {
00634 view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(),
00635 fShape->GetDX(), fShape->GetDY(), fShape->GetDZ());
00636 Update();
00637 }
00638 } else Update();
00639 }
00640 }
00641
00642
00643 void TGeoGtraEditor::DoUndo()
00644 {
00645
00646 fEH1->SetNumber(fH1i);
00647 fEBl1->SetNumber(fBl1i);
00648 fETl1->SetNumber(fTl1i);
00649 fESc1->SetNumber(1.);
00650 fESc2->SetNumber(fSci);
00651 fEDz->SetNumber(fDzi);
00652 fEAlpha1->SetNumber(fAlpha1i);
00653 fETheta->SetNumber(fThetai);
00654 fEPhi->SetNumber(fPhii);
00655 fETwist->SetNumber(fTwisti);
00656 DoApply();
00657 fUndo->SetEnabled(kFALSE);
00658 fApply->SetEnabled(kFALSE);
00659 }
00660
00661
00662 void TGeoGtraEditor::DoTwist()
00663 {
00664
00665 Double_t twist = fETwist->GetNumber();
00666 if (twist<=-180 || twist>=180) {
00667 twist = 0.;
00668 fETwist->SetNumber(twist);
00669 }
00670 DoModified();
00671 if (!IsDelayed()) DoApply();
00672 }