Changeset 7001 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 05/09/05 10:15:41 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 4 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r6926 r7001 107 107 TVirtualPad *save = gPad; 108 108 gPad = 0; 109 /* 109 110 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06) 110 111 SetPalette(1, 0); 111 #else 112 #endif 113 */ 114 /* 115 #if ROOT_VERSION_CODE < ROOT_VERSION(4,04,00) 112 116 SetPrettyPalette(); 117 #elese 113 118 // WORAROUND - FIXME: Calling it many times becomes slower and slower 114 //SetInvDeepBlueSeaPalette();119 SetInvDeepBlueSeaPalette(); 115 120 #endif 121 */ 116 122 gPad = save; 117 123 } … … 121 127 // Default Constructor. To be used by the root system ONLY. 122 128 // 123 MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), f Colors(kItemsLegend), fAbberation(0)129 MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fAbberation(0) 124 130 { 125 131 Init(); … … 133 139 // 134 140 MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title) 135 : fGeomCam(NULL), f Colors(kItemsLegend), fAbberation(0)141 : fGeomCam(NULL), fAbberation(0) 136 142 { 137 143 //fGeomCam = (MGeomCam*)geom.Clone(); … … 463 469 // GeMinimum() ((val-min)/(max-min)) 464 470 // 'proj' Display the y-projection of the histogram 471 // 'pal0' Use Pretty palette 472 // 'pal1' Use Deep Blue Sea palette 473 // 'pal2' Use Inverse Depp Blue Sea palette 465 474 // 'same' Draw trandparent pixels on top of an existing pad. This 466 475 // makes it possible to draw the camera image on top of an … … 970 979 { 971 980 opt.ReplaceAll("hist", ""); 981 opt.ReplaceAll("box", ""); 982 opt.ReplaceAll("pixelindex", ""); 983 opt.ReplaceAll("sectorindex", ""); 984 opt.ReplaceAll("content", ""); 985 opt.ReplaceAll("proj", ""); 986 opt.ReplaceAll("pal0", ""); 987 opt.ReplaceAll("pal1", ""); 988 opt.ReplaceAll("pal2", ""); 972 989 TH1D::Paint(opt); 973 990 return; … … 1007 1024 } 1008 1025 1026 const Bool_t pal1 = opt.Contains("pal1"); 1027 const Bool_t pal2 = opt.Contains("pal2"); 1028 1029 if (!pal1 && !pal2) 1030 SetPrettyPalette(); 1031 1032 if (pal1) 1033 SetDeepBlueSeaPalette(); 1034 1035 if (pal2) 1036 SetInvDeepBlueSeaPalette(); 1037 1009 1038 // Update Contents of the pixels and paint legend 1010 1039 Update(gPad->GetLogy(), hasbox, hascol, hassame); … … 1021 1050 } 1022 1051 1052 void MHCamera::SetDrawOption(Option_t *option) 1053 { 1054 // This is a workaround. For some reason MHCamera is 1055 // stored in a TObjLink instead of a TObjOptLink 1056 if (!option || !gPad) 1057 return; 1058 1059 TListIter next(gPad->GetListOfPrimitives()); 1060 delete gPad->FindObject("Tframe"); 1061 TObject *obj; 1062 while ((obj = next())) 1063 if (obj == this && (TString)next.GetOption()!=(TString)option) 1064 { 1065 gPad->GetListOfPrimitives()->Remove(this); 1066 gPad->GetListOfPrimitives()->AddFirst(this, option); 1067 return; 1068 } 1069 } 1070 1023 1071 // ------------------------------------------------------------------------ 1024 1072 // … … 1053 1101 else 1054 1102 gStyle->SetPalette(ncolors, colors); 1055 1056 fColors.Set(kItemsLegend);1057 for (int i=0; i<kItemsLegend; i++)1058 fColors[i] = gStyle->GetColorPalette(i);1059 1103 } 1060 1104 … … 1068 1112 void MHCamera::SetPrettyPalette() 1069 1113 { 1070 if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase)) 1114 TString opt(GetDrawOption()); 1115 1116 if (!opt.Contains("hist", TString::kIgnoreCase)) 1071 1117 SetPalette(1, 0); 1118 1119 opt.ReplaceAll("pal1", ""); 1120 opt.ReplaceAll("pal2", ""); 1121 1122 SetDrawOption(opt); 1072 1123 } 1073 1124 … … 1080 1131 void MHCamera::SetDeepBlueSeaPalette() 1081 1132 { 1082 if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase)) 1133 TString opt(GetDrawOption()); 1134 1135 if (!opt.Contains("hist", TString::kIgnoreCase)) 1083 1136 SetPalette(51, 0); 1137 1138 opt.ReplaceAll("pal1", ""); 1139 opt.ReplaceAll("pal2", ""); 1140 opt += "pal1"; 1141 1142 SetDrawOption(opt); 1084 1143 } 1085 1144 … … 1092 1151 void MHCamera::SetInvDeepBlueSeaPalette() 1093 1152 { 1094 if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase)) 1153 TString opt(GetDrawOption()); 1154 1155 if (!opt.Contains("hist", TString::kIgnoreCase)) 1095 1156 SetPalette(52, 0); 1157 1158 opt.ReplaceAll("pal1", ""); 1159 opt.ReplaceAll("pal2", ""); 1160 opt += "pal2"; 1161 1162 SetDrawOption(opt); 1096 1163 } 1097 1164 … … 1515 1582 1516 1583 if (val >= max) 1517 return fColors[maxcolidx];1584 return gStyle->GetColorPalette(maxcolidx); 1518 1585 1519 1586 if (val <= min) 1520 return fColors[0];1587 return gStyle->GetColorPalette(0); 1521 1588 1522 1589 // … … 1530 1597 1531 1598 const Int_t colidx = (Int_t)(ratio*maxcolidx + .5); 1532 return fColors[colidx];1599 return gStyle->GetColorPalette(colidx); 1533 1600 } 1534 1601 … … 1612 1679 for (Int_t i=0; i<kItemsLegend; i++) 1613 1680 { 1614 newbox.SetFillColor( fColors[i]);1681 newbox.SetFillColor(gStyle->GetColorPalette(i)); 1615 1682 newbox.PaintBox(range, H*(i*h-1)-offset, range+w, H*((i+1)*h-1)-offset); 1616 1683 } -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r6855 r7001 48 48 TArrayI fBinEntries; // number of entries per bin 49 49 50 TArrayI fColors; //! Color conversion table51 50 TList *fNotify; //! 52 51 … … 214 213 char *GetObjectInfo(Int_t px, Int_t py) const; 215 214 void ExecuteEvent(Int_t event, Int_t px, Int_t py); 215 void SetDrawOption(Option_t *option); //*MENU* 216 216 217 217 void SetPalette(Int_t ncolors, Int_t *colors); … … 222 222 223 223 void SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU* 224 void DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU*225 void DisplayAsCamera() { SetDrawOption(""); } // *MENU*226 224 227 225 void SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE* *GETTER=IsFreezed
Note:
See TracChangeset
for help on using the changeset viewer.