00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "TGeoMatrixEditor.h"
00019 #include "TGeoTabManager.h"
00020 #include "TGeoMatrix.h"
00021 #include "TPad.h"
00022 #include "TGTab.h"
00023 #include "TGComboBox.h"
00024 #include "TGButton.h"
00025 #include "TGButtonGroup.h"
00026 #include "TGTextEntry.h"
00027 #include "TGNumberEntry.h"
00028 #include "TGLabel.h"
00029
00030 ClassImp(TGeoTranslationEditor)
00031
00032 enum ETGeoMatrixWid {
00033 kMATRIX_NAME, kMATRIX_DX, kMATRIX_DY, kMATRIX_DZ,
00034 kMATRIX_PHI, kMATRIX_THETA, kMATRIX_PSI,
00035 kMATRIX_APPLY, kMATRIX_CANCEL, kMATRIX_UNDO
00036 };
00037
00038
00039 TGeoTranslationEditor::TGeoTranslationEditor(const TGWindow *p, Int_t width,
00040 Int_t height, UInt_t options, Pixel_t back)
00041 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
00042 {
00043
00044 fTranslation = 0;
00045 fDxi = fDyi = fDzi = 0.0;
00046 fNamei = "";
00047 fIsModified = kFALSE;
00048 fIsEditable = kFALSE;
00049
00050
00051 MakeTitle("Name");
00052 fTransName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
00053 fTransName->Resize(135, fTransName->GetDefaultHeight());
00054 fTransName->SetToolTipText("Enter the translation name");
00055 fTransName->Associate(this);
00056 AddFrame(fTransName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00057
00058 TGTextEntry *nef;
00059 MakeTitle("Translations on axes");
00060 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
00061
00062 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00063 kLHintsExpandX | kFixedWidth | kOwnBackground);
00064 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00065 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
00066 nef = (TGTextEntry*)fTransDx->GetNumberEntry();
00067 nef->SetToolTipText("Enter the translation on X");
00068 fTransDx->Associate(this);
00069 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00070 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00071
00072
00073 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00074 kLHintsExpandX | kFixedWidth | kOwnBackground);
00075 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00076 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
00077 nef = (TGTextEntry*)fTransDy->GetNumberEntry();
00078 nef->SetToolTipText("Enter the translation on Y");
00079 fTransDy->Associate(this);
00080 f2->AddFrame(fTransDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00081 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00082
00083
00084 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00085 kLHintsExpandX | kFixedWidth | kOwnBackground);
00086 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00087 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
00088 nef = (TGTextEntry*)fTransDz->GetNumberEntry();
00089 nef->SetToolTipText("Enter the translation on Z");
00090 fTransDz->Associate(this);
00091 f3->AddFrame(fTransDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00092 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00093
00094 compxyz->Resize(150,30);
00095 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00096
00097
00098 TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder);
00099 fApply = new TGTextButton(f23, "&Apply");
00100 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00101 fApply->Associate(this);
00102 fCancel = new TGTextButton(f23, "&Cancel");
00103 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
00104 fCancel->Associate(this);
00105 fUndo = new TGTextButton(f23, " &Undo ");
00106 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
00107 fUndo->Associate(this);
00108 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00109 fUndo->SetSize(fCancel->GetSize());
00110 fApply->SetSize(fCancel->GetSize());
00111 }
00112
00113
00114 TGeoTranslationEditor::~TGeoTranslationEditor()
00115 {
00116
00117 TGFrameElement *el;
00118 TIter next(GetList());
00119 while ((el = (TGFrameElement *)next())) {
00120 if (el->fFrame->IsComposite())
00121 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
00122 }
00123 Cleanup();
00124 }
00125
00126
00127 void TGeoTranslationEditor::ConnectSignals2Slots()
00128 {
00129
00130 fApply->Connect("Clicked()", "TGeoTranslationEditor", this, "DoApply()");
00131 fCancel->Connect("Clicked()", "TGeoTranslationEditor", this, "DoCancel()");
00132 fUndo->Connect("Clicked()", "TGeoTranslationEditor", this, "DoUndo()");
00133 fTransName->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoModified()");
00134 fTransDx->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDx()");
00135 fTransDy->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDy()");
00136 fTransDz->Connect("ValueSet(Long_t)", "TGeoTranslationEditor", this, "DoDz()");
00137 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDx()");
00138 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDy()");
00139 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTranslationEditor", this, "DoDz()");
00140 fInit = kFALSE;
00141 }
00142
00143
00144
00145 void TGeoTranslationEditor::SetModel(TObject* obj)
00146 {
00147
00148 if (obj == 0 || (obj->IsA()!=TGeoTranslation::Class())) {
00149 SetActive(kFALSE);
00150 return;
00151 }
00152 fTranslation = (TGeoTranslation*)obj;
00153 fDxi = fTranslation->GetTranslation()[0];
00154 fDyi = fTranslation->GetTranslation()[1];
00155 fDzi = fTranslation->GetTranslation()[2];
00156 const char *sname = fTranslation->GetName();
00157 if (!strcmp(sname, fTranslation->ClassName())) fTransName->SetText("no_name");
00158 else {
00159 fTransName->SetText(sname);
00160 fNamei = sname;
00161 }
00162 fTransDx->SetNumber(fDxi);
00163 fTransDy->SetNumber(fDyi);
00164 fTransDz->SetNumber(fDzi);
00165 fApply->SetEnabled(kFALSE);
00166 fUndo->SetEnabled(kFALSE);
00167 fCancel->SetEnabled(kFALSE);
00168
00169 if (fInit) ConnectSignals2Slots();
00170 SetActive();
00171 }
00172
00173
00174 void TGeoTranslationEditor::DoName()
00175 {
00176
00177 const char *name = fTransName->GetText();
00178 if (!strcmp(name, "no_name") || !strcmp(name, fTranslation->GetName())) return;
00179 fTranslation->SetName(name);
00180 }
00181
00182
00183 Bool_t TGeoTranslationEditor::DoParameters()
00184 {
00185
00186 Double_t dx = fTransDx->GetNumber();
00187 Double_t dy = fTransDy->GetNumber();
00188 Double_t dz = fTransDz->GetNumber();
00189 Bool_t changed = kFALSE;
00190 if (dx != fTranslation->GetTranslation()[0] ||
00191 dy != fTranslation->GetTranslation()[1] ||
00192 dz != fTranslation->GetTranslation()[2]) changed = kTRUE;
00193 if (!changed) return kFALSE;
00194 fUndo->SetEnabled();
00195 fTranslation->SetTranslation(dx, dy, dz);
00196 if (fPad) {
00197 fPad->Modified();
00198 fPad->Update();
00199 }
00200 return kTRUE;
00201 }
00202
00203
00204 void TGeoTranslationEditor::DoApply()
00205 {
00206
00207 DoName();
00208 if (DoParameters()) {
00209 fUndo->SetEnabled();
00210 fCancel->SetEnabled(kFALSE);
00211 fApply->SetEnabled(kFALSE);
00212 }
00213 }
00214
00215
00216 void TGeoTranslationEditor::DoCancel()
00217 {
00218
00219 if (!fNamei.Length()) fTransName->SetText("no_name");
00220 else fTransName->SetText(fNamei.Data());
00221 fTransDx->SetNumber(fDxi);
00222 fTransDy->SetNumber(fDyi);
00223 fTransDz->SetNumber(fDzi);
00224 fApply->SetEnabled(kFALSE);
00225 fUndo->SetEnabled(kFALSE);
00226 fCancel->SetEnabled(kFALSE);
00227 }
00228
00229
00230 void TGeoTranslationEditor::DoModified()
00231 {
00232
00233 fApply->SetEnabled();
00234 if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled();
00235 }
00236
00237
00238 void TGeoTranslationEditor::DoUndo()
00239 {
00240
00241 DoCancel();
00242 DoParameters();
00243 fCancel->SetEnabled(kFALSE);
00244 fUndo->SetEnabled(kFALSE);
00245 fApply->SetEnabled(kFALSE);
00246 }
00247
00248
00249 void TGeoTranslationEditor::DoDx()
00250 {
00251
00252 DoModified();
00253 }
00254
00255
00256 void TGeoTranslationEditor::DoDy()
00257 {
00258
00259 DoModified();
00260 }
00261
00262
00263 void TGeoTranslationEditor::DoDz()
00264 {
00265
00266 DoModified();
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 ClassImp(TGeoRotationEditor)
00278
00279
00280 TGeoRotationEditor::TGeoRotationEditor(const TGWindow *p, Int_t width,
00281 Int_t height, UInt_t options, Pixel_t back)
00282 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
00283 {
00284
00285 fRotation = 0;
00286 fPhii = fThetai = fPsii = 0.0;
00287 fAngleX = fAngleY = fAngleZ = 0.0;
00288 fNamei = "";
00289 fIsModified = kFALSE;
00290 fIsEditable = kFALSE;
00291
00292
00293 MakeTitle("Name");
00294 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
00295 fRotName->Resize(135, fRotName->GetDefaultHeight());
00296 fRotName->SetToolTipText("Enter the rotation name");
00297 fRotName->Associate(this);
00298 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00299
00300 TGTextEntry *nef;
00301 MakeTitle("Euler angles");
00302 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
00303
00304 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00305 kLHintsExpandX | kFixedWidth | kOwnBackground);
00306 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00307 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
00308 nef = (TGTextEntry*)fRotPhi->GetNumberEntry();
00309 nef->SetToolTipText("Modify the first rotation angle about Z");
00310 fRotPhi->Associate(this);
00311 fRotPhi->Resize(90, fRotPhi->GetDefaultHeight());
00312 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00313 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00314
00315
00316 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00317 kLHintsExpandX | kFixedWidth | kOwnBackground);
00318 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00319 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
00320 nef = (TGTextEntry*)fRotTheta->GetNumberEntry();
00321 nef->SetToolTipText("Modify the second rotation angle about the new X");
00322 fRotTheta->Associate(this);
00323 fRotTheta->Resize(90, fRotTheta->GetDefaultHeight());
00324 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00325 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00326
00327
00328 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00329 kLHintsExpandX | kFixedWidth | kOwnBackground);
00330 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00331 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
00332 nef = (TGTextEntry*)fRotPsi->GetNumberEntry();
00333 nef->SetToolTipText("Modify the third rotation angle about Z");
00334 fRotPsi->Associate(this);
00335 fRotPsi->Resize(90, fRotPsi->GetDefaultHeight());
00336 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00337 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00338
00339 compxyz->Resize(150,compxyz->GetDefaultHeight());
00340 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00341
00342 MakeTitle("Rotate about axis");
00343 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
00344
00345 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00346 kLHintsExpandX | kFixedWidth | kOwnBackground);
00347 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00348 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
00349 nef = (TGTextEntry*)fRotAxis->GetNumberEntry();
00350 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
00351 fRotAxis->Associate(this);
00352 fRotAxis->Resize(90, fRotAxis->GetDefaultHeight());
00353 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00354 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00355
00356
00357 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
00358 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
00359 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
00360 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
00361 bg1->SetRadioButtonExclusive();
00362 bg1->Show();
00363 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00364
00365 compxyz->Resize(150,compxyz->GetDefaultHeight());
00366 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00367
00368
00369
00370 TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder);
00371 fApply = new TGTextButton(f23, "Apply");
00372 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00373 fApply->Associate(this);
00374 fCancel = new TGTextButton(f23, "Cancel");
00375 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
00376 fCancel->Associate(this);
00377 fUndo = new TGTextButton(f23, " Undo ");
00378 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
00379 fUndo->Associate(this);
00380 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00381 fUndo->SetSize(fCancel->GetSize());
00382 fApply->SetSize(fCancel->GetSize());
00383 }
00384
00385
00386 TGeoRotationEditor::~TGeoRotationEditor()
00387 {
00388
00389 TGFrameElement *el;
00390 TIter next(GetList());
00391 while ((el = (TGFrameElement *)next())) {
00392 if (el->fFrame->IsComposite())
00393 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
00394 }
00395 Cleanup();
00396 }
00397
00398
00399 void TGeoRotationEditor::ConnectSignals2Slots()
00400 {
00401
00402 fApply->Connect("Clicked()", "TGeoRotationEditor", this, "DoApply()");
00403 fCancel->Connect("Clicked()", "TGeoRotationEditor", this, "DoCancel()");
00404 fUndo->Connect("Clicked()", "TGeoRotationEditor", this, "DoUndo()");
00405 fRotName->Connect("TextChanged(const char *)", "TGeoRotationEditor", this, "DoModified()");
00406 fRotPhi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPhi()");
00407 fRotTheta->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotTheta()");
00408 fRotPsi->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotPsi()");
00409 fRotAxis->Connect("ValueSet(Long_t)", "TGeoRotationEditor", this, "DoRotAngle()");
00410 fInit = kFALSE;
00411 }
00412
00413
00414
00415 void TGeoRotationEditor::SetModel(TObject* obj)
00416 {
00417
00418 if (obj == 0 || (obj->IsA()!=TGeoRotation::Class())) {
00419 SetActive(kFALSE);
00420 return;
00421 }
00422 fRotation = (TGeoRotation*)obj;
00423 fRotation->GetAngles(fPhii, fThetai, fPsii);
00424 const char *sname = fRotation->GetName();
00425 if (!strcmp(sname, fRotation->ClassName())) fRotName->SetText("no_name");
00426 else {
00427 fRotName->SetText(sname);
00428 fNamei = sname;
00429 }
00430 fRotPhi->SetNumber(fPhii);
00431 fRotTheta->SetNumber(fThetai);
00432 fRotPsi->SetNumber(fPsii);
00433 fRotAxis->SetNumber(0.0);
00434
00435 fApply->SetEnabled(kFALSE);
00436 fUndo->SetEnabled(kFALSE);
00437 fCancel->SetEnabled(kFALSE);
00438
00439 if (fInit) ConnectSignals2Slots();
00440 SetActive();
00441 }
00442
00443
00444 void TGeoRotationEditor::DoName()
00445 {
00446
00447 const char *name = fRotName->GetText();
00448 if (!strcmp(name, "no_name") || !strcmp(name, fRotation->GetName())) return;
00449 fRotation->SetName(name);
00450 }
00451
00452
00453 void TGeoRotationEditor::DoRotPhi()
00454 {
00455
00456 if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
00457 if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
00458 DoModified();
00459 }
00460
00461
00462 void TGeoRotationEditor::DoRotTheta()
00463 {
00464
00465 if (fRotTheta->GetNumber() < 0.) fRotTheta->SetNumber(fRotTheta->GetNumber()+360.);
00466 if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
00467 DoModified();
00468 }
00469
00470
00471 void TGeoRotationEditor::DoRotPsi()
00472 {
00473
00474 if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
00475 if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
00476 DoModified();
00477 }
00478
00479
00480 void TGeoRotationEditor::DoRotAngle()
00481 {
00482
00483 if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
00484 if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
00485 DoModified();
00486 }
00487
00488
00489 Bool_t TGeoRotationEditor::DoParameters()
00490 {
00491
00492 Double_t phi = fRotPhi->GetNumber();
00493 Double_t theta = fRotTheta->GetNumber();
00494 Double_t psi = fRotPsi->GetNumber();
00495 Double_t angle = fRotAxis->GetNumber();
00496 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
00497 fRotation->GetAngles(phi0,theta0,psi0);
00498 Bool_t changed = kFALSE;
00499 if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
00500 if (changed) fRotation->SetAngles(phi, theta, psi);
00501
00502 if (angle != 0.0) {
00503 if (fRotX->IsOn()) {fRotation->RotateX(angle); changed = kTRUE;}
00504 if (fRotY->IsOn()) {fRotation->RotateY(angle); changed = kTRUE;}
00505 if (fRotZ->IsOn()) {fRotation->RotateZ(angle); changed = kTRUE;}
00506 }
00507 if (!changed) return kFALSE;
00508 fRotAxis->SetNumber(0.0);
00509 fUndo->SetEnabled();
00510 if (fPad) {
00511 fPad->Modified();
00512 fPad->Update();
00513 }
00514 return kTRUE;
00515 }
00516
00517
00518 void TGeoRotationEditor::DoApply()
00519 {
00520
00521 DoName();
00522 if (DoParameters()) {
00523 fUndo->SetEnabled();
00524 fCancel->SetEnabled(kFALSE);
00525 fApply->SetEnabled(kFALSE);
00526 }
00527 }
00528
00529
00530 void TGeoRotationEditor::DoCancel()
00531 {
00532
00533 if (!fNamei.Length()) fRotName->SetText("no_name");
00534 else fRotName->SetText(fNamei.Data());
00535 fRotPhi->SetNumber(fPhii);
00536 fRotTheta->SetNumber(fThetai);
00537 fRotPsi->SetNumber(fPsii);
00538 fRotAxis->SetNumber(0.0);
00539 fApply->SetEnabled(kFALSE);
00540 fUndo->SetEnabled(kFALSE);
00541 fCancel->SetEnabled(kFALSE);
00542 }
00543
00544
00545 void TGeoRotationEditor::DoModified()
00546 {
00547
00548 fApply->SetEnabled();
00549 if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled();
00550 }
00551
00552
00553 void TGeoRotationEditor::DoUndo()
00554 {
00555
00556 DoCancel();
00557 DoParameters();
00558 fCancel->SetEnabled(kFALSE);
00559 fUndo->SetEnabled(kFALSE);
00560 fApply->SetEnabled(kFALSE);
00561 }
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 ClassImp(TGeoCombiTransEditor)
00573
00574
00575 TGeoCombiTransEditor::TGeoCombiTransEditor(const TGWindow *p, Int_t width,
00576 Int_t height, UInt_t options, Pixel_t back)
00577 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
00578 {
00579
00580 fCombi = 0;
00581 fPhii = fThetai = fPsii = 0.0;
00582 fDxi = fDyi = fDzi = 0.0;
00583 fAngleX = fAngleY = fAngleZ = 0.0;
00584 fNamei = "";
00585 fIsModified = kFALSE;
00586 fIsEditable = kFALSE;
00587
00588
00589 MakeTitle("Name");
00590 fRotName = new TGTextEntry(this, new TGTextBuffer(50), kMATRIX_NAME);
00591 fRotName->Resize(135, fRotName->GetDefaultHeight());
00592 fRotName->SetToolTipText("Enter the rotation name");
00593 fRotName->Associate(this);
00594 AddFrame(fRotName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00595
00596 TGTextEntry *nef;
00597 MakeTitle("Translations on axes");
00598 TGCompositeFrame *compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
00599
00600 TGCompositeFrame *f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00601 kLHintsExpandX | kFixedWidth | kOwnBackground);
00602 f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00603 fTransDx = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
00604 nef = (TGTextEntry*)fTransDx->GetNumberEntry();
00605 nef->SetToolTipText("Enter the translation on X");
00606 fTransDx->Associate(this);
00607 f1->AddFrame(fTransDx, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00608 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00609
00610
00611 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00612 kLHintsExpandX | kFixedWidth | kOwnBackground);
00613 f2->AddFrame(new TGLabel(f2, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00614 fTransDy = new TGNumberEntry(f2, 0., 5, kMATRIX_DY);
00615 nef = (TGTextEntry*)fTransDy->GetNumberEntry();
00616 nef->SetToolTipText("Enter the translation on Y");
00617 fTransDy->Associate(this);
00618 f2->AddFrame(fTransDy, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00619 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00620
00621
00622 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00623 kLHintsExpandX | kFixedWidth | kOwnBackground);
00624 f3->AddFrame(new TGLabel(f3, "DZ"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00625 fTransDz = new TGNumberEntry(f3, 0., 5, kMATRIX_DZ);
00626 nef = (TGTextEntry*)fTransDz->GetNumberEntry();
00627 nef->SetToolTipText("Enter the translation on Z");
00628 fTransDz->Associate(this);
00629 f3->AddFrame(fTransDz, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00630 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00631
00632 compxyz->Resize(150,30);
00633 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00634
00635
00636 MakeTitle("Euler angles");
00637 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
00638
00639 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00640 kLHintsExpandX | kFixedWidth | kOwnBackground);
00641 f1->AddFrame(new TGLabel(f1, " PHI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00642 fRotPhi = new TGNumberEntry(f1, 0., 5, kMATRIX_PHI);
00643 nef = (TGTextEntry*)fRotPhi->GetNumberEntry();
00644 nef->SetToolTipText("Modify the first rotation angle about Z");
00645 fRotPhi->Associate(this);
00646 fRotPhi->Resize(90, fRotPhi->GetDefaultHeight());
00647 f1->AddFrame(fRotPhi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00648 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00649
00650
00651 f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00652 kLHintsExpandX | kFixedWidth | kOwnBackground);
00653 f2->AddFrame(new TGLabel(f2, "THETA"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00654 fRotTheta = new TGNumberEntry(f2, 0., 5, kMATRIX_THETA);
00655 nef = (TGTextEntry*)fRotTheta->GetNumberEntry();
00656 nef->SetToolTipText("Modify the second rotation angle about the new X");
00657 fRotTheta->Associate(this);
00658 fRotTheta->Resize(90, fRotTheta->GetDefaultHeight());
00659 f2->AddFrame(fRotTheta, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00660 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00661
00662
00663 f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00664 kLHintsExpandX | kFixedWidth | kOwnBackground);
00665 f3->AddFrame(new TGLabel(f3, " PSI "), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00666 fRotPsi = new TGNumberEntry(f3, 0., 5, kMATRIX_PSI);
00667 nef = (TGTextEntry*)fRotPsi->GetNumberEntry();
00668 nef->SetToolTipText("Modify the third rotation angle about Z");
00669 fRotPsi->Associate(this);
00670 fRotPsi->Resize(90, fRotPsi->GetDefaultHeight());
00671 f3->AddFrame(fRotPsi, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00672 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00673
00674 compxyz->Resize(150,compxyz->GetDefaultHeight());
00675 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00676
00677 MakeTitle("Rotate about axis");
00678 compxyz = new TGCompositeFrame(this, 140, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
00679
00680 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
00681 kLHintsExpandX | kFixedWidth | kOwnBackground);
00682 f1->AddFrame(new TGLabel(f1, "ANGLE"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00683 fRotAxis = new TGNumberEntry(f1, 0., 5, kMATRIX_DX);
00684 nef = (TGTextEntry*)fRotAxis->GetNumberEntry();
00685 nef->SetToolTipText("Enter the new rotation angle about the selected axis");
00686 fRotAxis->Associate(this);
00687 fRotAxis->Resize(90, fRotAxis->GetDefaultHeight());
00688 f1->AddFrame(fRotAxis, new TGLayoutHints(kLHintsRight , 2, 2, 2, 2));
00689 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00690
00691
00692 TGHButtonGroup *bg1 = new TGHButtonGroup(compxyz, " Axis ");
00693 fRotX = new TGRadioButton(bg1, " &X ", kMATRIX_DX);
00694 fRotY = new TGRadioButton(bg1, " &Y ", kMATRIX_DY);
00695 fRotZ = new TGRadioButton(bg1, " &Z ", kMATRIX_DZ);
00696 bg1->SetRadioButtonExclusive();
00697 bg1->Show();
00698 compxyz->AddFrame(bg1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 2, 2));
00699
00700 compxyz->Resize(150,compxyz->GetDefaultHeight());
00701 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00702
00703
00704
00705 TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder);
00706 fApply = new TGTextButton(f23, "&Apply");
00707 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00708 fApply->Associate(this);
00709 fCancel = new TGTextButton(f23, "&Cancel");
00710 f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4));
00711 fCancel->Associate(this);
00712 fUndo = new TGTextButton(f23, " &Undo ");
00713 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
00714 fUndo->Associate(this);
00715 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 2, 2));
00716 fUndo->SetSize(fCancel->GetSize());
00717 fApply->SetSize(fCancel->GetSize());
00718 }
00719
00720
00721 TGeoCombiTransEditor::~TGeoCombiTransEditor()
00722 {
00723
00724 TGFrameElement *el;
00725 TIter next(GetList());
00726 while ((el = (TGFrameElement *)next())) {
00727 if (el->fFrame->IsComposite())
00728 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
00729 }
00730 Cleanup();
00731 }
00732
00733
00734 void TGeoCombiTransEditor::ConnectSignals2Slots()
00735 {
00736
00737 fApply->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoApply()");
00738 fCancel->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoCancel()");
00739 fUndo->Connect("Clicked()", "TGeoCombiTransEditor", this, "DoUndo()");
00740 fRotName->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoModified()");
00741 fRotPhi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPhi()");
00742 fRotTheta->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotTheta()");
00743 fRotPsi->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotPsi()");
00744 fRotAxis->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoRotAngle()");
00745 fTransDx->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDx()");
00746 fTransDy->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDy()");
00747 fTransDz->Connect("ValueSet(Long_t)", "TGeoCombiTransEditor", this, "DoDz()");
00748 fTransDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDx()");
00749 fTransDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDy()");
00750 fTransDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoCombiTransEditor", this, "DoDz()");
00751 fInit = kFALSE;
00752 }
00753
00754
00755
00756 void TGeoCombiTransEditor::SetModel(TObject* obj)
00757 {
00758
00759 if (obj == 0 || (obj->IsA()!=TGeoCombiTrans::Class())) {
00760 SetActive(kFALSE);
00761 return;
00762 }
00763 fCombi = (TGeoCombiTrans*)obj;
00764 TGeoRotation *rot = fCombi->GetRotation();
00765 if (rot) rot->GetAngles(fPhii, fThetai, fPsii);
00766 const char *sname = fCombi->GetName();
00767 if (!strcmp(sname, fCombi->ClassName())) fRotName->SetText("no_name");
00768 else {
00769 fRotName->SetText(sname);
00770 fNamei = sname;
00771 }
00772
00773 fDxi = fCombi->GetTranslation()[0];
00774 fDyi = fCombi->GetTranslation()[1];
00775 fDzi = fCombi->GetTranslation()[2];
00776 fTransDx->SetNumber(fDxi);
00777 fTransDy->SetNumber(fDyi);
00778 fTransDz->SetNumber(fDzi);
00779
00780 fRotPhi->SetNumber(fPhii);
00781 fRotTheta->SetNumber(fThetai);
00782 fRotPsi->SetNumber(fPsii);
00783 fRotAxis->SetNumber(0.0);
00784
00785 fApply->SetEnabled(kFALSE);
00786 fUndo->SetEnabled(kFALSE);
00787 fCancel->SetEnabled(kFALSE);
00788
00789 if (fInit) ConnectSignals2Slots();
00790 SetActive();
00791 }
00792
00793
00794 void TGeoCombiTransEditor::DoName()
00795 {
00796
00797 const char *name = fRotName->GetText();
00798 if (!strcmp(name, "no_name") || !strcmp(name, fCombi->GetName())) return;
00799 fCombi->SetName(name);
00800 }
00801
00802
00803 void TGeoCombiTransEditor::DoRotPhi()
00804 {
00805
00806 if (fRotPhi->GetNumber() < 0.) fRotPhi->SetNumber(fRotPhi->GetNumber()+360.);
00807 if (fRotPhi->GetNumber() >= 360.) fRotPhi->SetNumber(fRotPhi->GetNumber()-360.);
00808 DoModified();
00809 }
00810
00811
00812 void TGeoCombiTransEditor::DoRotTheta()
00813 {
00814
00815 if (fRotTheta->GetNumber() < 0.) fRotTheta->SetNumber(fRotTheta->GetNumber()+360.);
00816 if (fRotTheta->GetNumber() >= 360.) fRotTheta->SetNumber(fRotTheta->GetNumber()-360.);
00817 DoModified();
00818 }
00819
00820
00821 void TGeoCombiTransEditor::DoRotPsi()
00822 {
00823
00824 if (fRotPsi->GetNumber() < 0.) fRotPsi->SetNumber(fRotPsi->GetNumber()+360.);
00825 if (fRotPsi->GetNumber() >= 360.) fRotPsi->SetNumber(fRotPsi->GetNumber()-360.);
00826 DoModified();
00827 }
00828
00829
00830 void TGeoCombiTransEditor::DoRotAngle()
00831 {
00832
00833 if (fRotAxis->GetNumber() < 0.) fRotAxis->SetNumber(fRotAxis->GetNumber()+360.);
00834 if (fRotAxis->GetNumber() >= 360.) fRotAxis->SetNumber(fRotAxis->GetNumber()-360.);
00835 DoModified();
00836 }
00837
00838
00839 Bool_t TGeoCombiTransEditor::DoParameters()
00840 {
00841
00842 Double_t dx = fTransDx->GetNumber();
00843 Double_t dy = fTransDy->GetNumber();
00844 Double_t dz = fTransDz->GetNumber();
00845 Bool_t changedtr = kFALSE;
00846 if (dx != fCombi->GetTranslation()[0] ||
00847 dy != fCombi->GetTranslation()[1] ||
00848 dz != fCombi->GetTranslation()[2]) changedtr = kTRUE;
00849 if (changedtr) fCombi->SetTranslation(dx, dy, dz);
00850 Double_t phi = fRotPhi->GetNumber();
00851 Double_t theta = fRotTheta->GetNumber();
00852 Double_t psi = fRotPsi->GetNumber();
00853 Double_t angle = fRotAxis->GetNumber();
00854 Double_t phi0 = 0., theta0 = 0., psi0 = 0.;
00855 TGeoRotation *rot = fCombi->GetRotation();
00856 if (rot) rot->GetAngles(phi0,theta0,psi0);
00857 else {
00858 if (phi!=fPhii || theta!=fThetai || psi!=fPsii) {
00859 TGeoRotation r("rot",10.,0.,0.);
00860 fCombi->SetRotation(r);
00861 rot = fCombi->GetRotation();
00862 rot->SetAngles(0.,0.,0.);
00863 }
00864 }
00865 Bool_t changed = kFALSE;
00866 if (phi != psi0 || theta != theta0 || psi != psi0) changed = kTRUE;
00867 if (changed && rot) rot->SetAngles(phi, theta, psi);
00868
00869 if (angle != 0.0) {
00870 if (fRotX->IsOn()) {fCombi->RotateX(angle); changed = kTRUE;}
00871 if (fRotY->IsOn()) {fCombi->RotateY(angle); changed = kTRUE;}
00872 if (fRotZ->IsOn()) {fCombi->RotateZ(angle); changed = kTRUE;}
00873 }
00874 if (changedtr) changed = kTRUE;
00875 if (!changed) return kFALSE;
00876 fRotAxis->SetNumber(0.0);
00877 fUndo->SetEnabled();
00878 if (fPad) {
00879 fPad->Modified();
00880 fPad->Update();
00881 }
00882 return kTRUE;
00883 }
00884
00885
00886 void TGeoCombiTransEditor::DoApply()
00887 {
00888
00889 DoName();
00890 if (DoParameters()) {
00891 fUndo->SetEnabled();
00892 fCancel->SetEnabled(kFALSE);
00893 fApply->SetEnabled(kFALSE);
00894 }
00895 }
00896
00897
00898 void TGeoCombiTransEditor::DoCancel()
00899 {
00900
00901 if (!fNamei.Length()) fRotName->SetText("no_name");
00902 else fRotName->SetText(fNamei.Data());
00903 fTransDx->SetNumber(fDxi);
00904 fTransDy->SetNumber(fDyi);
00905 fTransDz->SetNumber(fDzi);
00906 fRotPhi->SetNumber(fPhii);
00907 fRotTheta->SetNumber(fThetai);
00908 fRotPsi->SetNumber(fPsii);
00909 fRotAxis->SetNumber(0.0);
00910 fApply->SetEnabled(kFALSE);
00911 fUndo->SetEnabled(kFALSE);
00912 fCancel->SetEnabled(kFALSE);
00913 }
00914
00915
00916 void TGeoCombiTransEditor::DoModified()
00917 {
00918
00919 fApply->SetEnabled();
00920 if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled();
00921 }
00922
00923
00924 void TGeoCombiTransEditor::DoUndo()
00925 {
00926
00927 DoCancel();
00928 DoParameters();
00929 fCancel->SetEnabled(kFALSE);
00930 fUndo->SetEnabled(kFALSE);
00931 fApply->SetEnabled(kFALSE);
00932 }
00933
00934
00935 void TGeoCombiTransEditor::DoDx()
00936 {
00937
00938 DoModified();
00939 }
00940
00941
00942 void TGeoCombiTransEditor::DoDy()
00943 {
00944
00945 DoModified();
00946 }
00947
00948
00949 void TGeoCombiTransEditor::DoDz()
00950 {
00951
00952 DoModified();
00953 }
00954