]>
Commit | Line | Data |
---|---|---|
82b3616d | 1 | // $Header$ |
2 | ||
3 | #include "ITSModuleStepper.h" | |
4 | #include "ITSDigitsInfo.h" | |
d7e36bcf | 5 | #include "ITSScaledModule.h" |
82b3616d | 6 | |
7 | #include "Reve/RGTopFrame.h" | |
d7e36bcf | 8 | #include "Reve/RGEditor.h" |
82b3616d | 9 | #include "Reve/GridStepper.h" |
10 | ||
d7e36bcf | 11 | #include <TObject.h> |
12 | ||
82b3616d | 13 | using namespace Reve; |
14 | using namespace Alieve; | |
15 | ||
16 | //______________________________________________________________________ | |
17 | // ITSModuleStepper | |
18 | // | |
19 | ||
20 | ClassImp(ITSModuleStepper) | |
21 | ||
82b3616d | 22 | ITSModuleStepper::ITSModuleStepper(ITSDigitsInfo* di): |
23 | RenderElementList("ITS 2DStore", "ITSModuleStepper"), | |
24 | fDigitsInfo(di), | |
d7e36bcf | 25 | fStepper(0), |
26 | fExpand(0.85) | |
82b3616d | 27 | { |
28 | fStepper = new GridStepper(); | |
29 | } | |
30 | ||
31 | /**************************************************************************/ | |
32 | ITSModuleStepper::~ITSModuleStepper() | |
33 | { | |
34 | delete fStepper; | |
35 | } | |
36 | ||
37 | /**************************************************************************/ | |
d7e36bcf | 38 | |
82b3616d | 39 | void ITSModuleStepper::SetStepper(Int_t nx, Int_t ny, Float_t dx, Float_t dy) |
40 | { | |
41 | fStepper->SetNs(nx, ny, 1); | |
42 | RenderElement::DestroyElements(); | |
43 | ||
44 | Int_t nmod = nx*ny; | |
45 | for(Int_t m = 0; m<nmod; m++) | |
46 | { | |
d7e36bcf | 47 | AddElement( new ITSScaledModule(m, fDigitsInfo)); |
82b3616d | 48 | } |
49 | ||
50 | if(dx > 0 && dy > 0) | |
51 | fStepper->SetDs(dx, dy); | |
52 | } | |
53 | ||
54 | /**************************************************************************/ | |
d7e36bcf | 55 | |
82b3616d | 56 | void ITSModuleStepper::Start() |
57 | { | |
58 | fPosition = fIDs.begin(); | |
59 | fStepper->Reset(); | |
60 | Apply(); | |
61 | } | |
62 | ||
63 | void ITSModuleStepper::Next() | |
64 | { | |
65 | if(fPosition == fIDs.end()) | |
66 | return; | |
67 | fStepper->Reset(); | |
68 | Apply(); | |
69 | } | |
70 | ||
71 | /**************************************************************************/ | |
d7e36bcf | 72 | |
82b3616d | 73 | void ITSModuleStepper::Apply() |
74 | { | |
d7e36bcf | 75 | // check editor |
82b3616d | 76 | for(List_i childit=fChildren.begin(); childit!=fChildren.end(); ++childit) |
77 | { | |
78 | if(fPosition != fIDs.end()) | |
79 | { | |
d7e36bcf | 80 | ITSScaledModule* mod = dynamic_cast<ITSScaledModule*>(*childit); |
81 | mod->SetID(*fPosition, kFALSE); | |
82b3616d | 82 | ZTrans& mx = mod->RefHMTrans(); |
83 | ||
d7e36bcf | 84 | Float_t dx, dz; |
85 | Float_t* fp = mod->GetFrame()->GetFramePoints(); | |
86 | // switch x,z it will be rotated afterwards | |
87 | dz = -2*fp[0]; | |
88 | dx = -2*fp[2]; | |
89 | ||
82b3616d | 90 | Double_t sh = fStepper->Dy; |
91 | Double_t sw = (dx*fStepper->Dy)/dz; | |
92 | if(sw > fStepper->Dx) | |
93 | { | |
d7e36bcf | 94 | printf("fit width \n"); |
82b3616d | 95 | sw = fStepper->Dx; |
96 | sh = (dz*fStepper->Dx)/dx; | |
97 | } | |
98 | mx.UnitTrans(); | |
99 | mx.RotateLF(3,2,TMath::PiOver2()); | |
100 | mx.Scale(sw/dx, sh/dz,1); | |
82b3616d | 101 | fStepper->SetTransAdvance(&mx); |
d7e36bcf | 102 | mx.Scale(fExpand, fExpand,1); |
103 | mx.RotateLF(2,1,TMath::PiOver2()); | |
104 | mod->SetRnrSelf(kTRUE); | |
105 | ||
106 | if(mod->GetSubDetID() == 2) | |
107 | mod->SetName(Form("SSD %d", *fPosition)); | |
108 | else if(mod->GetSubDetID() == 1) | |
109 | mod->SetName(Form("SDD %d", *fPosition)); | |
110 | else | |
111 | mod->SetName(Form("SPD %d", *fPosition)); | |
112 | mod->UpdateItems(); | |
113 | ||
82b3616d | 114 | fPosition++; |
115 | } | |
116 | else { | |
117 | (*childit)->SetRnrSelf(kFALSE); | |
118 | } | |
119 | } | |
d7e36bcf | 120 | // update in case scaled module is a model in the editor |
121 | gReve->GetEditor()->DisplayObject(gReve->GetEditor()->GetModel()); | |
82b3616d | 122 | gReve->Redraw3D(); |
123 | } |