Changeset 974
- Timestamp:
- 10/23/01 15:43:22 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mgui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
r973 r974 14 14 #include "MCerPhotEvt.h" 15 15 16 #define kI TEMS_LEGEND2516 #define kItemsLegend 25 17 17 18 18 ClassImp(MCamDisplay); … … 33 33 // 34 34 fNumPixels = geom->GetNumPixels(); 35 fRange = (Int_t)geom->GetMaxRadius(); 36 35 37 fPixels = new TClonesArray("MHexagon", fNumPixels); 36 38 39 // 40 // Construct all hexagons. Use new-operator with placement 41 // 37 42 for (UInt_t i=0; i<fNumPixels; i++) 38 43 new ((*fPixels)[i]) MHexagon((*geom)[i]); … … 47 52 // set up the Legend 48 53 // 49 fLegend = new TClonesArray("TBox", kITEMS_LEGEND); 50 fLegText = new TClonesArray("TText", kITEMS_LEGEND); 51 52 char text[10]; 53 for (Int_t il = 0; il<kITEMS_LEGEND; il++) 54 { 55 const Int_t y = il*40; 56 57 TBox *newbox = new ((*fLegend)[il]) TBox (650, y-500, 700, y-460); 58 TText *newtxt = new ((*fLegText)[il]) TText(720, y-480, text); 59 60 const Float_t lvl = 50. / kITEMS_LEGEND * il; 54 fLegend = new TClonesArray("TBox", kItemsLegend); 55 fLegText = new TClonesArray("TText", kItemsLegend); 56 57 for (Int_t i = 0; i<kItemsLegend; i++) 58 { 59 //const Int_t y = il*40; 60 61 // 62 // Construct gui elements of legend. Use new-operator with placement 63 // 64 //TBox *newbox = new ((*fLegend)[il]) TBox (650, y-500, 700, y-460); 65 //TText *newtxt = new ((*fLegText)[il]) TText(720, y-480, text); 66 67 TBox *newbox = new ((*fLegend)[i]) TBox; 68 TText *newtxt = new ((*fLegText)[i]) TText; 69 70 const Float_t lvl = 50. / kItemsLegend * i; 61 71 62 72 newbox->SetFillColor(GetColor(lvl)); 63 64 sprintf(text, "%5.1f", lvl);65 73 66 74 newtxt->SetTextSize(0.025); … … 75 83 { 76 84 delete fPixels; 85 delete fLegend; 86 delete fLegText; 77 87 } 78 88 … … 86 96 // 87 97 if (!gPad) 88 fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 650, 500);98 fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 750, 600); 89 99 else 90 100 { … … 94 104 95 105 // 106 // FIXME: This class should be a TPad, so that it is informed if the 107 // ratio between height and size changes! 108 // 109 const Float_t ratio = (Float_t)gPad->GetWw()/gPad->GetWh(); 110 111 // 112 // The recommended size ratio is 5:4 113 // 114 Int_t x, y; 115 116 if (ratio > 5./4.) 117 { 118 x = (UInt_t)((ratio-1)*3*fRange); 119 y = fRange; 120 } 121 else 122 { 123 x = 3*fRange/2; 124 y = (UInt_t)(fRange/ratio); 125 } 126 127 // 96 128 // Setup the correct environment 97 129 // 98 130 gStyle->SetPalette(1, 0); 99 131 100 gPad->Range(- 600, -600, 900, 600);132 gPad->Range(-fRange, -y, x, y); 101 133 gPad->SetFillColor(22); 102 134 … … 111 143 // draw legend 112 144 // 113 for (Int_t i=0; i<kITEMS_LEGEND; i++) 114 { 115 GetBox(i)->Draw(); 116 GetText(i)->Draw(); 145 const Float_t H = 0.9*fRange; 146 const Float_t h = 2./kItemsLegend; 147 148 const Float_t w = fRange/sqrt(fNumPixels); 149 150 for (Int_t i=0; i<kItemsLegend; i++) 151 { 152 TBox *box = GetBox(i); 153 box->SetX1(fRange); 154 box->SetX2(fRange+w); 155 box->SetY1(H*( i *h - 1.)); 156 box->SetY2(H*((i+1)*h - 1.)); 157 box->Draw(); 158 159 TText *txt = GetText(i); 160 txt->SetX(fRange+1.5*w); 161 txt->SetY(H*((i+0.5)*h - 1.)); 162 txt->Draw(); 117 163 } 118 164 } … … 153 199 for (Int_t i=0; i<entries; i++) 154 200 { 155 MCerPhotPix &pix = (*event)[i];201 const MCerPhotPix &pix = (*event)[i]; 156 202 157 203 if (!pix.IsPixelUsed()) … … 188 234 for (Int_t i=0 ; i<entries; i++) 189 235 { 190 MCerPhotPix &pix = (*event)[i];236 const MCerPhotPix &pix = (*event)[i]; 191 237 192 238 SetPixColor(pix); … … 253 299 char text[10]; 254 300 255 for (Int_t il=0; il < kI TEMS_LEGEND; il++)256 { 257 const Float_t val = fMinPhe + (Float_t)il/kI TEMS_LEGEND* (fMaxPhe-fMinPhe) ;301 for (Int_t il=0; il < kItemsLegend; il++) 302 { 303 const Float_t val = fMinPhe + (Float_t)il/kItemsLegend * (fMaxPhe-fMinPhe) ; 258 304 259 305 sprintf(text, "%5.1f", val); -
trunk/MagicSoft/Mars/mgui/MCamDisplay.h
r963 r974 32 32 33 33 UInt_t fNumPixels; 34 Int_t fRange; 35 34 36 TClonesArray *fPixels; 35 37 … … 45 47 TText *GetText(Int_t i) { return (TText*)fLegText->At(i); } 46 48 47 void SetPixColor( MCerPhotPix &pix)49 void SetPixColor(const MCerPhotPix &pix) 48 50 { 49 51 (*this)[pix.GetPixId()].SetFillColor( GetColor(pix.GetNumPhotons())); -
trunk/MagicSoft/Mars/mgui/MGeomCam.cc
r963 r974 47 47 // 48 48 MGeomCam::MGeomCam(UInt_t npix, const char *name, const char *title) 49 : fNumPixels(npix) 49 50 { 50 51 *fName = name ? name : "MGeomCam"; 51 52 *fTitle = title ? title : "Storage container for a camera geometry"; 52 53 53 fNumPixels = npix; 54 fPixels = new TObjArray(npix); 54 fPixels = new TObjArray(npix); 55 55 56 56 // … … 61 61 for (UInt_t i=0; i<npix; i++) 62 62 (*fPixels)[i] = new MGeomPix; 63 } 64 65 void MGeomCam::CalcMaxRadius() 66 { 67 fMaxRadius = 0; 68 69 for (UInt_t i=0; i<fNumPixels; i++) 70 { 71 const MGeomPix &pix = (*this)[i]; 72 73 const Float_t x = pix.GetX(); 74 const Float_t y = pix.GetY(); 75 const Float_t r = pix.GetR(); 76 77 const Float_t maxr = sqrt(x*x+y*y) + r; 78 79 if (maxr>fMaxRadius) 80 fMaxRadius = maxr; 81 } 63 82 } 64 83 -
trunk/MagicSoft/Mars/mgui/MGeomCam.h
r963 r974 18 18 { 19 19 private: 20 UInt_t fNumPixels; // Number of pixels in this camera 21 TObjArray *fPixels; // Array of singel pixels storing the geometry 20 UInt_t fNumPixels; // Number of pixels in this camera 21 Float_t fMaxRadius; // maximum radius of the camera 22 23 TObjArray *fPixels; // Array of singel pixels storing the geometry 24 25 protected: 26 void CalcMaxRadius(); 22 27 23 28 public: … … 27 32 virtual ~MGeomCam() { delete fPixels; } 28 33 29 UInt_t GetNumPixels() const { return fNumPixels; } 34 UInt_t GetNumPixels() const { return fNumPixels; } 35 Float_t GetMaxRadius() const { return fMaxRadius; } 30 36 31 37 MGeomPix &operator[](Int_t i) { return *(MGeomPix*)fPixels->At(i); }
Note:
See TracChangeset
for help on using the changeset viewer.