12 #ifndef ROOT_TGLPlotPainter
13 #define ROOT_TGLPlotPainter
23 class TGLPlotCoordinates;
48 const TGLPlotBox *
const fPlotBox;
55 TGLBoxCut(
const TGLPlotBox *plotBox);
59 Bool_t IsActive()
const{
return fActive;}
60 void SetActive(Bool_t a);
62 void ResetBoxGeometry();
64 void SetFactor(Double_t f){fFactor = f;}
66 void DrawBox(Bool_t selectionPass, Int_t selected)
const;
68 void StartMovement(Int_t px, Int_t py);
69 void MoveBox(Int_t px, Int_t py, Int_t axisID);
71 Bool_t IsInCut(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax,
72 Double_t zMin, Double_t zMax)
const;
75 Bool_t IsInCut(
const V * v)
const
78 if (v[0] >= fXRange.first && v[0] < fXRange.second &&
79 v[1] >= fYRange.first && v[1] < fYRange.second &&
80 v[2] >= fZRange.first && v[2] < fZRange.second)
85 Rgl::Range_t GetXRange()
const{
return fXRange;}
86 Rgl::Range_t GetYRange()
const{
return fYRange;}
87 Rgl::Range_t GetZRange()
const{
return fZRange;}
92 ClassDef(TGLBoxCut, 0)
99 class TGLTH3Slice :
public TNamed {
101 enum ESliceAxis {kXOZ, kYOZ, kXOY};
104 ESliceAxis fAxisType;
106 mutable TGLLevelPalette fPalette;
108 const TGLPlotCoordinates *fCoord;
109 const TGLPlotBox *fBox;
115 mutable TGL2DArray<Double_t> fTexCoords;
117 mutable Rgl::Range_t fMinMax;
120 TGLTH3Slice(
const TString &sliceName,
122 const TGLPlotCoordinates *coord,
123 const TGLPlotBox * box,
125 TGLTH3Slice(
const TString &sliceName,
126 const TH3 *hist,
const TF3 *fun,
127 const TGLPlotCoordinates *coord,
128 const TGLPlotBox * box,
131 void DrawSlice(Double_t pos)
const;
133 void SetSliceWidth(Int_t width = 1);
135 void SetMinMax(
const Rgl::Range_t &newRange)
140 const TGLLevelPalette & GetPalette()
const
146 void PrepareTexCoords(Double_t pos, Int_t sliceBegin, Int_t sliceEnd)
const;
147 void FindMinMax(Int_t sliceBegin, Int_t sliceEnd)
const;
148 Bool_t PreparePalette()
const;
149 void DrawSliceTextured(Double_t pos)
const;
150 void DrawSliceFrame(Int_t low, Int_t up)
const;
152 ClassDef(TGLTH3Slice, 0)
160 class TGLPlotPainter;
170 class PlotTranslation {
172 PlotTranslation(
const TGLPlotPainter *painter);
176 const TGLPlotPainter *fPainter;
181 class TGLPlotPainter :
public TVirtualGLPainter {
182 friend class Rgl::PlotTranslation;
184 const TColor *fPadColor;
187 const Float_t *fPhysicalShapeColor;
196 TGLPlotCoordinates *fCoord;
197 TGLPlotCamera *fCamera;
198 TGLSelectionBuffer fSelection;
200 Bool_t fUpdateSelection;
201 Bool_t fSelectionPass;
203 TPoint fMousePosition;
204 mutable Double_t fXOZSectionPos;
205 mutable Double_t fYOZSectionPos;
206 mutable Double_t fXOYSectionPos;
210 std::vector<Double_t> fZLevels;
214 kHighColorSelectionBase = 7,
215 kTrueColorSelectionBase = 10
218 Int_t fSelectionBase;
219 mutable Bool_t fDrawPalette;
226 TGLPlotPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord,
227 Bool_t xoySelectable, Bool_t xozSelectable, Bool_t yozSelectable);
228 TGLPlotPainter(TGL5DDataSet *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
229 TGLPlotPainter(TGLPlotCamera *camera);
231 const TGLPlotBox& RefBackBox()
const {
return fBackBox; }
232 void SetPhysicalShapeColor(
const Float_t *rgba)
234 fPhysicalShapeColor = rgba;
237 virtual void InitGL()
const = 0;
238 virtual void DeInitGL()
const = 0;
239 virtual void DrawPlot()
const = 0;
240 virtual void Paint();
243 virtual Bool_t PlotSelected(Int_t px, Int_t py);
245 virtual Bool_t InitGeometry() = 0;
247 virtual void StartPan(Int_t px, Int_t py) = 0;
251 virtual void AddOption(
const TString &stringOption) = 0;
253 virtual void ProcessEvent(Int_t event, Int_t px, Int_t py) = 0;
255 void SetPadColor(
const TColor *color);
257 virtual void SetFrameColor(
const TColor *frameColor);
260 void InvalidateSelection();
268 Bool_t CutAxisSelected()
const{
return !fHighColor && fSelectedPart <= kZAxis && fSelectedPart >= kXAxis;}
270 void SetDrawFrontBox(Bool_t b) {fBackBox.SetDrawFront(b);}
271 void SetDrawBackBox(Bool_t b) {fBackBox.SetDrawBack(b);}
272 void SetDrawAxes(Bool_t s) {fDrawAxes = s;}
273 Bool_t GetDrawAxes() {
return fDrawAxes;}
276 const TColor *GetPadColor()
const;
278 void MoveSection(Int_t px, Int_t py);
279 void DrawSections()
const;
280 virtual void DrawSectionXOZ()
const = 0;
281 virtual void DrawSectionYOZ()
const = 0;
282 virtual void DrawSectionXOY()
const = 0;
284 virtual void DrawPaletteAxis()
const;
286 virtual void ClearBuffers()
const;
288 void PrintPlot()
const;
294 void SaveModelviewMatrix()
const;
295 void SaveProjectionMatrix()
const;
297 void RestoreModelviewMatrix()
const;
298 void RestoreProjectionMatrix()
const;
300 ClassDef(TGLPlotPainter, 0)
310 class TGLPlotCoordinates {
312 EGLCoordType fCoordType;
314 Rgl::BinRange_t fXBins;
315 Rgl::BinRange_t fYBins;
316 Rgl::BinRange_t fZBins;
322 Rgl::Range_t fXRange;
323 Rgl::Range_t fYRange;
324 Rgl::Range_t fZRange;
326 Rgl::Range_t fXRangeScaled;
327 Rgl::Range_t fYRangeScaled;
328 Rgl::Range_t fZRangeScaled;
338 TGLPlotCoordinates();
339 virtual ~TGLPlotCoordinates();
341 void SetCoordType(EGLCoordType type);
342 EGLCoordType GetCoordType()
const;
344 void SetXLog(Bool_t xLog);
345 Bool_t GetXLog()
const;
347 void SetYLog(Bool_t yLog);
348 Bool_t GetYLog()
const;
350 void SetZLog(Bool_t zLog);
351 Bool_t GetZLog()
const;
353 void ResetModified();
354 Bool_t Modified()
const;
356 Bool_t SetRanges(
const TH1 *hist, Bool_t errors = kFALSE, Bool_t zBins = kFALSE);
358 Bool_t SetRanges(TH2Poly *hist);
360 Bool_t SetRanges(
const TAxis *xAxis,
const TAxis *yAxis,
const TAxis *zAxis);
362 Int_t GetNXBins()
const;
363 Int_t GetNYBins()
const;
364 Int_t GetNZBins()
const;
366 const Rgl::BinRange_t &GetXBins()
const;
367 const Rgl::BinRange_t &GetYBins()
const;
368 const Rgl::BinRange_t &GetZBins()
const;
370 const Rgl::Range_t &GetXRange()
const;
371 Double_t GetXLength()
const;
372 const Rgl::Range_t &GetYRange()
const;
373 Double_t GetYLength()
const;
374 const Rgl::Range_t &GetZRange()
const;
375 Double_t GetZLength()
const;
377 const Rgl::Range_t &GetXRangeScaled()
const;
378 const Rgl::Range_t &GetYRangeScaled()
const;
379 const Rgl::Range_t &GetZRangeScaled()
const;
381 Double_t GetXScale()
const{
return fXScale;}
382 Double_t GetYScale()
const{
return fYScale;}
383 Double_t GetZScale()
const{
return fZScale;}
385 Int_t GetFirstXBin()
const{
return fXBins.first;}
386 Int_t GetLastXBin()
const{
return fXBins.second;}
387 Int_t GetFirstYBin()
const{
return fYBins.first;}
388 Int_t GetLastYBin()
const{
return fYBins.second;}
389 Int_t GetFirstZBin()
const{
return fZBins.first;}
390 Int_t GetLastZBin()
const{
return fZBins.second;}
392 Double_t GetFactor()
const;
395 Bool_t SetRangesPolar(
const TH1 *hist);
396 Bool_t SetRangesCylindrical(
const TH1 *hist);
397 Bool_t SetRangesSpherical(
const TH1 *hist);
399 Bool_t SetRangesCartesian(
const TH1 *hist, Bool_t errors = kFALSE, Bool_t zBins = kFALSE);
401 TGLPlotCoordinates(
const TGLPlotCoordinates &);
402 TGLPlotCoordinates &operator = (
const TGLPlotCoordinates &);
404 ClassDef(TGLPlotCoordinates, 0)
407 class TGLLevelPalette;
411 void DrawPalette(
const TGLPlotCamera *camera,
const TGLLevelPalette &palette);
412 void DrawPalette(
const TGLPlotCamera *camera,
const TGLLevelPalette &palette,
413 const std::vector<Double_t> &levels);
414 void DrawPaletteAxis(
const TGLPlotCamera *camera,
const Range_t &minMax, Bool_t logZ);
417 extern const Double_t gH2PolyScaleXY;