00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGLPlotPainter
00013 #define ROOT_TGLPlotPainter
00014
00015 #include <vector>
00016
00017 #ifndef ROOT_TVirtualGL
00018 #include "TVirtualGL.h"
00019 #endif
00020 #ifndef ROOT_TGLPlotBox
00021 #include "TGLPlotBox.h"
00022 #endif
00023 #ifndef ROOT_TPoint
00024 #include "TPoint.h"
00025 #endif
00026 #ifndef ROOT_TGLUtil
00027 #include "TGLUtil.h"
00028 #endif
00029 #ifndef ROOT_TNamed
00030 #include "TNamed.h"
00031 #endif
00032
00033 class TGLPlotCoordinates;
00034 class TGLPlotCamera;
00035 class TGL5DDataSet;
00036 class TString;
00037 class TColor;
00038 class TAxis;
00039 class TH1;
00040 class TH3;
00041 class TF3;
00042
00043
00044
00045
00046
00047
00048 class TGLBoxCut {
00049 private:
00050 Double_t fXLength;
00051 Double_t fYLength;
00052 Double_t fZLength;
00053 TGLVertex3 fCenter;
00054 Rgl::Range_t fXRange;
00055 Rgl::Range_t fYRange;
00056 Rgl::Range_t fZRange;
00057
00058 const TGLPlotBox * const fPlotBox;
00059 Bool_t fActive;
00060 Double_t fFactor;
00061
00062 TPoint fMousePos;
00063
00064 public:
00065 TGLBoxCut(const TGLPlotBox *plotBox);
00066 virtual ~TGLBoxCut();
00067
00068 void TurnOnOff();
00069 Bool_t IsActive()const{return fActive;}
00070 void SetActive(Bool_t a);
00071
00072 void ResetBoxGeometry();
00073
00074 void SetFactor(Double_t f){fFactor = f;}
00075
00076 void DrawBox(Bool_t selectionPass, Int_t selected)const;
00077
00078 void StartMovement(Int_t px, Int_t py);
00079 void MoveBox(Int_t px, Int_t py, Int_t axisID);
00080
00081 Bool_t IsInCut(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax,
00082 Double_t zMin, Double_t zMax)const;
00083
00084 template<class V>
00085 Bool_t IsInCut(const V * v) const
00086 {
00087
00088 if (v[0] >= fXRange.first && v[0] < fXRange.second &&
00089 v[1] >= fYRange.first && v[1] < fYRange.second &&
00090 v[2] >= fZRange.first && v[2] < fZRange.second)
00091 return kTRUE;
00092 return kFALSE;
00093 }
00094
00095 Rgl::Range_t GetXRange()const{return fXRange;}
00096 Rgl::Range_t GetYRange()const{return fYRange;}
00097 Rgl::Range_t GetZRange()const{return fZRange;}
00098
00099 private:
00100 void AdjustBox();
00101
00102 ClassDef(TGLBoxCut, 0)
00103 };
00104
00105
00106
00107
00108
00109 class TGLTH3Slice : public TNamed {
00110 public:
00111 enum ESliceAxis {kXOZ, kYOZ, kXOY};
00112
00113 private:
00114 ESliceAxis fAxisType;
00115 TAxis *fAxis;
00116 mutable TGLLevelPalette fPalette;
00117
00118 const TGLPlotCoordinates *fCoord;
00119 const TGLPlotBox *fBox;
00120 Int_t fSliceWidth;
00121
00122 const TH3 *fHist;
00123 const TF3 *fF3;
00124
00125 mutable TGL2DArray<Double_t> fTexCoords;
00126
00127 mutable Rgl::Range_t fMinMax;
00128
00129 public:
00130 TGLTH3Slice(const TString &sliceName,
00131 const TH3 *hist,
00132 const TGLPlotCoordinates *coord,
00133 const TGLPlotBox * box,
00134 ESliceAxis axis);
00135 TGLTH3Slice(const TString &sliceName,
00136 const TH3 *hist, const TF3 *fun,
00137 const TGLPlotCoordinates *coord,
00138 const TGLPlotBox * box,
00139 ESliceAxis axis);
00140
00141 void DrawSlice(Double_t pos)const;
00142
00143 void SetSliceWidth(Int_t width = 1);
00144
00145 void SetMinMax(const Rgl::Range_t &newRange)
00146 {
00147 fMinMax = newRange;
00148 }
00149
00150 const TGLLevelPalette & GetPalette()const
00151 {
00152 return fPalette;
00153 }
00154
00155 private:
00156 void PrepareTexCoords(Double_t pos, Int_t sliceBegin, Int_t sliceEnd)const;
00157 void FindMinMax(Int_t sliceBegin, Int_t sliceEnd)const;
00158 Bool_t PreparePalette()const;
00159 void DrawSliceTextured(Double_t pos)const;
00160 void DrawSliceFrame(Int_t low, Int_t up)const;
00161
00162 ClassDef(TGLTH3Slice, 0)
00163 };
00164
00165
00166
00167
00168
00169
00170 class TGLPlotPainter;
00171
00172
00173
00174
00175
00176
00177
00178 namespace Rgl {
00179
00180 class PlotTranslation {
00181 public:
00182 PlotTranslation(const TGLPlotPainter *painter);
00183 ~PlotTranslation();
00184
00185 private:
00186 const TGLPlotPainter *fPainter;
00187 };
00188
00189 }
00190
00191 class TGLPlotPainter : public TVirtualGLPainter {
00192 friend class Rgl::PlotTranslation;
00193 private:
00194 const TColor *fPadColor;
00195
00196 protected:
00197 Double_t fPadPhi;
00198 Double_t fPadTheta;
00199 TH1 *fHist;
00200 TAxis *fXAxis;
00201 TAxis *fYAxis;
00202 TAxis *fZAxis;
00203
00204 TGLPlotCoordinates *fCoord;
00205 TGLPlotCamera *fCamera;
00206 TGLSelectionBuffer fSelection;
00207
00208 Bool_t fUpdateSelection;
00209 Bool_t fSelectionPass;
00210 Int_t fSelectedPart;
00211 TPoint fMousePosition;
00212 mutable Double_t fXOZSectionPos;
00213 mutable Double_t fYOZSectionPos;
00214 mutable Double_t fXOYSectionPos;
00215 TGLPlotBox fBackBox;
00216 TGLBoxCut fBoxCut;
00217
00218 std::vector<Double_t> fZLevels;
00219 Bool_t fHighColor;
00220
00221 enum ESelectionBase{
00222 kHighColorSelectionBase = 7,
00223 kTrueColorSelectionBase = 10
00224 };
00225
00226 ESelectionBase fSelectionBase;
00227 mutable Bool_t fDrawPalette;
00228
00229 public:
00230
00231
00232
00233 TGLPlotPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord,
00234 Bool_t xoySelectable, Bool_t xozSelectable, Bool_t yozSelectable);
00235 TGLPlotPainter(TGL5DDataSet *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
00236 TGLPlotPainter(TGLPlotCamera *camera);
00237
00238 const TGLPlotBox& RefBackBox() const { return fBackBox; }
00239
00240 virtual void InitGL()const = 0;
00241 virtual void DeInitGL()const = 0;
00242 virtual void DrawPlot()const = 0;
00243 virtual void Paint();
00244
00245
00246 virtual Bool_t PlotSelected(Int_t px, Int_t py);
00247
00248 virtual Bool_t InitGeometry() = 0;
00249
00250 virtual void StartPan(Int_t px, Int_t py) = 0;
00251
00252
00253
00254 virtual void AddOption(const TString &stringOption) = 0;
00255
00256 virtual void ProcessEvent(Int_t event, Int_t px, Int_t py) = 0;
00257
00258 void SetPadColor(const TColor *color);
00259
00260 virtual void SetFrameColor(const TColor *frameColor);
00261
00262
00263 void InvalidateSelection();
00264
00265 enum ECutAxisID {
00266 kXAxis = 7,
00267 kYAxis = 8,
00268 kZAxis = 9
00269 };
00270
00271 Bool_t CutAxisSelected()const{return !fHighColor && fSelectedPart <= kZAxis && fSelectedPart >= kXAxis;}
00272
00273 protected:
00274 const TColor *GetPadColor()const;
00275
00276 void MoveSection(Int_t px, Int_t py);
00277 void DrawSections()const;
00278 virtual void DrawSectionXOZ()const = 0;
00279 virtual void DrawSectionYOZ()const = 0;
00280 virtual void DrawSectionXOY()const = 0;
00281
00282 virtual void DrawPaletteAxis()const;
00283
00284 virtual void ClearBuffers()const;
00285
00286 void PrintPlot()const;
00287
00288
00289
00290
00291
00292 void SaveModelviewMatrix()const;
00293 void SaveProjectionMatrix()const;
00294
00295 void RestoreModelviewMatrix()const;
00296 void RestoreProjectionMatrix()const;
00297
00298 ClassDef(TGLPlotPainter, 0)
00299 };
00300
00301
00302
00303
00304
00305
00306 class TH2Poly;
00307
00308 class TGLPlotCoordinates {
00309 private:
00310 EGLCoordType fCoordType;
00311
00312 Rgl::BinRange_t fXBins;
00313 Rgl::BinRange_t fYBins;
00314 Rgl::BinRange_t fZBins;
00315
00316 Double_t fXScale;
00317 Double_t fYScale;
00318 Double_t fZScale;
00319
00320 Rgl::Range_t fXRange;
00321 Rgl::Range_t fYRange;
00322 Rgl::Range_t fZRange;
00323
00324 Rgl::Range_t fXRangeScaled;
00325 Rgl::Range_t fYRangeScaled;
00326 Rgl::Range_t fZRangeScaled;
00327
00328 Bool_t fXLog;
00329 Bool_t fYLog;
00330 Bool_t fZLog;
00331
00332 Bool_t fModified;
00333 Double_t fFactor;
00334
00335 public:
00336 TGLPlotCoordinates();
00337 virtual ~TGLPlotCoordinates();
00338
00339 void SetCoordType(EGLCoordType type);
00340 EGLCoordType GetCoordType()const;
00341
00342 void SetXLog(Bool_t xLog);
00343 Bool_t GetXLog()const;
00344
00345 void SetYLog(Bool_t yLog);
00346 Bool_t GetYLog()const;
00347
00348 void SetZLog(Bool_t zLog);
00349 Bool_t GetZLog()const;
00350
00351 void ResetModified();
00352 Bool_t Modified()const;
00353
00354 Bool_t SetRanges(const TH1 *hist, Bool_t errors = kFALSE, Bool_t zBins = kFALSE);
00355
00356 Bool_t SetRanges(TH2Poly *hist);
00357
00358 Bool_t SetRanges(const TAxis *xAxis, const TAxis *yAxis, const TAxis *zAxis);
00359
00360 Int_t GetNXBins()const;
00361 Int_t GetNYBins()const;
00362 Int_t GetNZBins()const;
00363
00364 const Rgl::BinRange_t &GetXBins()const;
00365 const Rgl::BinRange_t &GetYBins()const;
00366 const Rgl::BinRange_t &GetZBins()const;
00367
00368 const Rgl::Range_t &GetXRange()const;
00369 Double_t GetXLength()const;
00370 const Rgl::Range_t &GetYRange()const;
00371 Double_t GetYLength()const;
00372 const Rgl::Range_t &GetZRange()const;
00373 Double_t GetZLength()const;
00374
00375 const Rgl::Range_t &GetXRangeScaled()const;
00376 const Rgl::Range_t &GetYRangeScaled()const;
00377 const Rgl::Range_t &GetZRangeScaled()const;
00378
00379 Double_t GetXScale()const{return fXScale;}
00380 Double_t GetYScale()const{return fYScale;}
00381 Double_t GetZScale()const{return fZScale;}
00382
00383 Int_t GetFirstXBin()const{return fXBins.first;}
00384 Int_t GetLastXBin()const{return fXBins.second;}
00385 Int_t GetFirstYBin()const{return fYBins.first;}
00386 Int_t GetLastYBin()const{return fYBins.second;}
00387 Int_t GetFirstZBin()const{return fZBins.first;}
00388 Int_t GetLastZBin()const{return fZBins.second;}
00389
00390 Double_t GetFactor()const;
00391
00392 private:
00393 Bool_t SetRangesPolar(const TH1 *hist);
00394 Bool_t SetRangesCylindrical(const TH1 *hist);
00395 Bool_t SetRangesSpherical(const TH1 *hist);
00396
00397 Bool_t SetRangesCartesian(const TH1 *hist, Bool_t errors = kFALSE, Bool_t zBins = kFALSE);
00398
00399 TGLPlotCoordinates(const TGLPlotCoordinates &);
00400 TGLPlotCoordinates &operator = (const TGLPlotCoordinates &);
00401
00402 ClassDef(TGLPlotCoordinates, 0)
00403 };
00404
00405 class TGLLevelPalette;
00406
00407 namespace Rgl {
00408
00409 void DrawPalette(const TGLPlotCamera * camera, const TGLLevelPalette & palette);
00410 void DrawPaletteAxis(const TGLPlotCamera * camera, const Range_t & minMax, Bool_t logZ);
00411
00412
00413 extern const Double_t gH2PolyScaleXY;
00414
00415 }
00416
00417 #endif