Changeset 1390 for trunk/MagicSoft
- Timestamp:
- 07/08/02 17:31:20 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1388 r1390 28 28 * mgui/MCamDisplay.[h,cc]: 29 29 - added DrawPixelNumbers 30 - added buttons to change the palette online 30 31 31 32 * mgui/MHexagon.h: -
trunk/MagicSoft/Mars/NEWS
r1385 r1390 27 27 28 28 - Added Monte Carlo Informations to event display gui 29 30 - Changed the camera display to display the pixel numbering 31 32 - Added three buttons to the camera display to change the palette 29 33 30 34 -
trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
r1384 r1390 35 35 #include <math.h> 36 36 #include <fstream.h> 37 #include <iostream.h> 37 38 38 39 #include <TClonesArray.h> … … 41 42 #include <TBox.h> 42 43 #include <TText.h> 44 #include <TButton.h> 43 45 44 46 #include "MHexagon.h" … … 50 52 #include "MCerPhotEvt.h" 51 53 52 #define kItemsLegend 25// see SetPalette(1,0)54 #define kItemsLegend 50 // see SetPalette(1,0) 53 55 54 56 ClassImp(MCamDisplay); … … 86 88 // 87 89 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06) 88 gStyle->SetPalette(1, 0);90 SetPalette(1, 0); 89 91 #else 90 gStyle->SetPalette(51, 0);92 SetPalette(51, 0); 91 93 #endif 92 94 … … 102 104 TText *newtxt = new ((*fLegText)[i]) TText; 103 105 104 const Float_t lvl = 50. / kItemsLegend * i; 105 106 newbox->SetFillColor(GetColor(lvl)); 106 newbox->SetFillColor(fColors[i]); 107 107 108 108 newtxt->SetTextSize(0.025); … … 186 186 // 187 187 gPad->Range(-fRange, -y, x, y); 188 } 189 190 // ------------------------------------------------------------------------ 191 // 192 // With this function you can change the color palette. For more 193 // information see TStyle::SetPalette. Only palettes with 50 colors 194 // are allowed. 195 // In addition you can use SetPalette(52, 0) to create an inverse 196 // deep blue sea palette 197 // 198 void MCamDisplay::SetPalette(Int_t ncolors, Int_t *colors) 199 { 200 // 201 // If not enough colors are specified skip this. 202 // 203 if (ncolors>1 && ncolors<50) 204 { 205 cout << "MCamDisplay::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl; 206 return; 207 } 208 209 // 210 // If ncolors==52 create a reversed deep blue sea palette 211 // 212 if (ncolors==52) 213 { 214 gStyle->SetPalette(51, NULL); 215 Int_t c[50]; 216 for (int i=0; i<50; i++) 217 c[49-i] = gStyle->GetColorPalette(i); 218 gStyle->SetPalette(50, c); 219 } 220 else 221 gStyle->SetPalette(ncolors, colors); 222 223 if (fDrawingPad) 224 { 225 // 226 // Set the colors of the legend 227 // 228 for (int i=0; i<kItemsLegend; i++) 229 { 230 Int_t col = GetBox(i)->GetFillColor(); 231 232 // 233 // Make sure, that the legend is already colored 234 // 235 if (col==10 || col==22) 236 continue; 237 GetBox(i)->SetFillColor(gStyle->GetColorPalette(i)); 238 } 239 240 // 241 // Change the colors of the pixels 242 // 243 for (unsigned int i=0; i<fNumPixels; i++) 244 { 245 // 246 // Get the old color index and check whether it is 247 // background or transparent 248 // 249 Int_t col = (*this)[i].GetFillColor(); 250 if (col==10 || col==22) 251 continue; 252 253 // 254 // Search for the color index (level) in the color table 255 // 256 int idx; 257 for (idx=0; idx<kItemsLegend; idx++) 258 if (col==fColors[idx]) 259 break; 260 // 261 // Should not happen 262 // 263 if (idx==kItemsLegend) 264 { 265 cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl; 266 continue; 267 } 268 269 // 270 // Convert the old color index (level) into the new one 271 // 272 (*this)[i].SetFillColor(gStyle->GetColorPalette(idx)); 273 } 274 275 // 276 // Update the pad on the screen 277 // 278 fDrawingPad->Modified(); 279 fDrawingPad->Update(); 280 } 281 282 // 283 // Store the color palette used for a leter reverse lookup 284 // 285 for (int i=0; i<kItemsLegend; i++) 286 fColors[i] = gStyle->GetColorPalette(i); 188 287 } 189 288 … … 226 325 227 326 // 327 // Create and draw the buttons which allows changing the 328 // color palette of the display 329 // 330 TButton *but; 331 char txt[100]; 332 sprintf(txt, "((MCamDisplay*)%p)->SetPalette(1,0);", this); 333 but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99); 334 but->Draw(); 335 sprintf(txt, "((MCamDisplay*)%p)->SetPalette(51,0);", this); 336 but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99); 337 but->Draw(); 338 sprintf(txt, "((MCamDisplay*)%p)->SetPalette(52,0);", this); 339 but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99); 340 but->Draw(); 341 342 // 228 343 // Setup the correct environment 229 344 // 230 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)231 gStyle->SetPalette(1, 0);232 #else233 gStyle->SetPalette(51, 0);234 #endif235 236 345 gPad->SetFillColor(22); 237 346 … … 241 350 // 242 351 for (UInt_t i=0; i<fNumPixels; i++) 352 { 353 (*this)[i].SetFillColor(22); 243 354 (*this)[i].Draw(); 244 245 // 246 // draw legend 355 } 356 357 // 358 // initialize and draw legend 247 359 // 248 360 const Float_t H = 0.9*fRange; … … 258 370 box->SetY1(H*( i *h - 1.)); 259 371 box->SetY2(H*((i+1)*h - 1.)); 372 box->SetFillColor(22); 260 373 box->Draw(); 261 374 … … 305 418 306 419 fDrawingPad->cd(); 420 421 for (int i=0; i<kItemsLegend; i++) 422 GetBox(i)->SetFillColor(fColors[i]); 307 423 308 424 // … … 374 490 // first treat the over- and under-flows 375 491 // 376 const Int_t maxcolidx = 49;492 const Int_t maxcolidx = kItemsLegend-1; 377 493 378 494 if (val >= fMaxPhe) 379 return gStyle->GetColorPalette(maxcolidx);495 return fColors[maxcolidx]; 380 496 381 497 if (val <= fMinPhe) 382 return gStyle->GetColorPalette(0);498 return fColors[0]; 383 499 384 500 // … … 388 504 const Int_t colidx = (Int_t)(ratio*maxcolidx + .5); 389 505 390 return gStyle->GetColorPalette(colidx);506 return fColors[colidx]; 391 507 } 392 508 … … 400 516 char text[10]; 401 517 402 for (Int_t i=0; i<kItemsLegend; i+ +)518 for (Int_t i=0; i<kItemsLegend; i+=3) 403 519 { 404 520 const Float_t val = fMinPhe + (Float_t)i/kItemsLegend * (fMaxPhe-fMinPhe) ; -
trunk/MagicSoft/Mars/mgui/MCamDisplay.h
r1384 r1390 30 30 Float_t fMinPhe; // The minimal number of Phe 31 31 Float_t fMaxPhe; // The maximum number of Phe 32 33 Int_t fColors[50]; 32 34 33 35 TClonesArray *fPixels; // array of all hexagons … … 64 66 void SavePrimitive(ofstream &out, Option_t *); 65 67 68 void SetPalette(Int_t ncolors, Int_t *colors); 69 66 70 ClassDef(MCamDisplay, 0) // Displays the magic camera 67 71 };
Note:
See TracChangeset
for help on using the changeset viewer.