Changeset 979 for trunk/MagicSoft/Mars/mgui
- Timestamp:
- 10/24/01 11:51:15 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
r976 r979 15 15 #include "MCerPhotEvt.h" 16 16 17 #define kItemsLegend 25 17 #define kItemsLegend 25 // see SetPalette(1,0) 18 18 19 19 ClassImp(MCamDisplay); … … 23 23 // default constructor 24 24 // 25 MCamDisplay::MCamDisplay(MGeomCam *geom) : fAutoScale(kTRUE) 26 { 27 // 28 // set the color palette 29 // 30 gStyle->SetPalette(1, 0); 31 25 MCamDisplay::MCamDisplay(MGeomCam *geom) 26 : fAutoScale(kTRUE), fW(0), fH(0), fMinPhe(-2), fMaxPhe(50), fDrawingPad(NULL) 27 { 32 28 // 33 29 // create the hexagons of the display 34 30 // 35 31 fNumPixels = geom->GetNumPixels(); 36 fRange = (Int_t)geom->GetMaxRadius(); 37 38 fPixels = new TClonesArray("MHexagon", fNumPixels); 32 fRange = geom->GetMaxRadius(); 39 33 40 34 // 41 35 // Construct all hexagons. Use new-operator with placement 42 36 // 37 fPixels = new TClonesArray("MHexagon", fNumPixels); 43 38 for (UInt_t i=0; i<fNumPixels; i++) 44 39 new ((*fPixels)[i]) MHexagon((*geom)[i]); 45 40 46 41 // 47 // set the range to default 48 // 49 fMinPhe = -2.; 50 fMaxPhe = 50.; 42 // set the color palette for the TBox elements 43 // 44 gStyle->SetPalette(1, 0); 51 45 52 46 // … … 58 52 for (Int_t i = 0; i<kItemsLegend; i++) 59 53 { 60 //const Int_t y = il*40;61 62 //63 // Construct gui elements of legend. Use new-operator with placement64 //65 //TBox *newbox = new ((*fLegend)[il]) TBox (650, y-500, 700, y-460);66 //TText *newtxt = new ((*fLegText)[il]) TText(720, y-480, text);67 68 54 TBox *newbox = new ((*fLegend)[i]) TBox; 69 55 TText *newtxt = new ((*fLegText)[i]) TText; … … 80 66 // ------------------------------------------------------------------------ 81 67 // 68 // Destructor. Deletes TClonesArrays for hexagons and legend elements. 82 69 // 83 70 MCamDisplay::~MCamDisplay() … … 95 82 // ------------------------------------------------------------------------ 96 83 // 84 // This is called at any time the canvas should get repainted. 85 // Here we maintain an aspect ratio of 5/4=1.15. This makes sure, 86 // that the camera image doesn't get distorted by resizing the canvas. 87 // 88 void MCamDisplay::Paint(Option_t *opt) 89 { 90 const UInt_t w = gPad->GetWw(); 91 const UInt_t h = gPad->GetWh(); 92 93 // 94 // Check for a change in width or height, and make sure, that the 95 // first call also sets the range 96 // 97 if (w*fH == h*fW && fW && fH) 98 return; 99 100 // 101 // Calculate aspect ratio (5/4=1.25 recommended) 102 // 103 const Double_t ratio = (Double_t)w/h; 104 105 Float_t x; 106 Float_t y; 107 108 if (ratio>1.25) 109 { 110 x = (ratio*2-1)*fRange; 111 y = fRange; 112 } 113 else 114 { 115 x = fRange*1.5; 116 y = fRange*1.25/ratio; 117 } 118 119 fH = h; 120 fW = w; 121 122 // 123 // Set new range 124 // 125 gPad->Range(-fRange, -y, x, y); 126 } 127 128 // ------------------------------------------------------------------------ 129 // 130 // Call this function to draw the camera layout into your canvas. 131 // Setup a drawing canvas. Add this object and all child objects 132 // (hexagons, etc) to the current pad. If no pad exists a new one is 133 // created. 97 134 // 98 135 void MCamDisplay::Draw(Option_t *option) … … 110 147 111 148 // 112 // FIXME: This class should be a TPad, so that it is informed if the 113 // ratio between height and size changes! 114 // 115 const Float_t ratio = (Float_t)gPad->GetWw()/gPad->GetWh(); 116 117 // 118 // The recommended size ratio is 5:4 119 // 120 Int_t x, y; 121 122 if (ratio > 5./4.) 123 { 124 x = (UInt_t)((ratio-1)*3*fRange); 125 y = fRange; 126 } 127 else 128 { 129 x = 3*fRange/2; 130 y = (UInt_t)(fRange/ratio); 131 } 149 // Append this object, so that the aspect ratio is maintained 150 // (Paint-function is called) 151 // 152 AppendPad(option); 132 153 133 154 // … … 136 157 gStyle->SetPalette(1, 0); 137 158 138 gPad->Range(-fRange, -y, x, y);139 159 gPad->SetFillColor(22); 140 160 … … 172 192 // ------------------------------------------------------------------------ 173 193 // 194 // Call this function to draw the number of photo electron into the 195 // camera. 174 196 // 175 197 void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event) 176 198 { 199 if (!fDrawingPad) 200 Draw(); 201 177 202 fDrawingPad->cd(); 178 203 179 204 // 180 // loop over all pixels in the MCerPhotEvt and 181 // determine the Pixel Id and the content 205 // Reset pixel colors to default value 182 206 // 183 207 Reset(); … … 219 243 gPad->Update(); 220 244 } 221 222 // ------------------------------------------------------------------------223 //224 //225 void MCamDisplay::DrawPhotErr(const MCerPhotEvt *event)226 {227 fDrawingPad->cd();228 229 //230 // reset the all pixel colors to a default value231 //232 Reset();233 234 //235 // loop over all pixels in the MCerPhotEvt and236 // determine the Pixel Id and the content237 //238 const Int_t entries = event->GetNumPixels();239 240 for (Int_t i=0 ; i<entries; i++)241 {242 const MCerPhotPix &pix = (*event)[i];243 244 SetPixColor(pix);245 }246 247 //248 // Update display physically249 //250 gPad->Modified();251 gPad->Update();252 }253 254 245 255 246 // ------------------------------------------------------------------------ … … 305 296 char text[10]; 306 297 307 for (Int_t i l=0; il < kItemsLegend; il++)308 { 309 const Float_t val = fMinPhe + (Float_t)i l/kItemsLegend * (fMaxPhe-fMinPhe) ;298 for (Int_t i=0; i<kItemsLegend; i++) 299 { 300 const Float_t val = fMinPhe + (Float_t)i/kItemsLegend * (fMaxPhe-fMinPhe) ; 310 301 311 302 sprintf(text, "%5.1f", val); 312 303 313 TText &txt = *GetText(i l);304 TText &txt = *GetText(i); 314 305 315 306 txt.SetText(txt.GetX(), txt.GetY(), text);
Note:
See TracChangeset
for help on using the changeset viewer.