Newer
Older
Olivier Couet
committed
// Author: Timur Pocheptsov 14/06/2006
Olivier Couet
committed
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TVirtualGL
#include "TVirtualGL.h"
#endif
#endif
#ifndef ROOT_TPoint
#include "TPoint.h"
#endif
class TString;
class TColor;
class TAxis;
class TH1;
Box cut. When attached to a plot, cuts away a part of it.
Can be moved in a plot's own area in X/Y/Z directions.
class TGLBoxCut {
private:
Double_t fXLength;
Double_t fYLength;
Double_t fZLength;
TGLVertex3 fCenter;
Rgl::Range_t fXRange;
Rgl::Range_t fYRange;
Rgl::Range_t fZRange;
const TGLPlotBox * const fPlotBox;
Bool_t fActive;
Double_t fFactor;
TPoint fMousePos;
public:
TGLBoxCut(const TGLPlotBox *plotBox);
virtual ~TGLBoxCut();
void TurnOnOff();
Bool_t IsActive()const{return fActive;}
void SetFactor(Double_t f){fFactor = f;}
void DrawBox(Bool_t selectionPass, Int_t selected)const;
Bool_t IsInCut(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax,
Double_t zMin, Double_t zMax)const;
private:
void AdjustBox();
/*
2D contour for TH3 slicing.
*/
class TGLTH3Slice : public TNamed {
public:
enum ESliceAxis {kXOZ, kYOZ, kXOY};
private:
ESliceAxis fAxisType;
TAxis *fAxis;
mutable TGLLevelPalette fPalette;
const TGLPlotCoordinates *fCoord;
const TGLPlotBox *fBox;
Int_t fSliceWidth;
const TH3 *fHist;
TGLTH3Slice(const TString &sliceName,
const TH3 *hist,
const TGLPlotCoordinates *coord,
void SetMinMax(const Rgl::Range_t &newRange)
{
fMinMax = newRange;
}
void PrepareTexCoords(Double_t pos, Int_t sliceBegin, Int_t sliceEnd)const;
void FindMinMax(Int_t sliceBegin, Int_t sliceEnd)const;
Bool_t PreparePalette()const;
void DrawSliceTextured(Double_t pos)const;
void DrawSliceFrame(Int_t low, Int_t up)const;
ClassDef(TGLTH3Slice, 0) // TH3 slice
};
/*
TGLPlotPainter class defines interface to different plot painters.
*/
class TGLPlotPainter : public TVirtualGLPainter {
private:
protected:
TH1 *fHist;
TAxis *fXAxis;
TAxis *fYAxis;
TAxis *fZAxis;
TGLPlotCoordinates *fCoord;
TGLOrthoCamera *fCamera;
TGLSelectionBuffer fSelection;
Bool_t fUpdateSelection;
Bool_t fSelectionPass;
Int_t fSelectedPart;
TPoint fMousePosition;
mutable Double_t fXOZSectionPos;
mutable Double_t fYOZSectionPos;
mutable Double_t fXOYSectionPos;
TGLPlotBox fBackBox;
/* TGLPlotPainter(TH1 *hist, TGLOrthoCamera *camera, TGLPlotCoordinates *coord, Int_t context,
Bool_t xoySelectable, Bool_t xozSelectable, Bool_t yozSelectable);
TGLPlotPainter(TGLOrthoCamera *camera, Int_t context);*/
TGLPlotPainter(TH1 *hist, TGLOrthoCamera *camera, TGLPlotCoordinates *coord, TGLPaintDevice *dev,
Bool_t xoySelectable, Bool_t xozSelectable, Bool_t yozSelectable);
TGLPlotPainter(TGLOrthoCamera *camera, TGLPaintDevice *dev);
const TGLPlotBox& RefBackBox() const { return fBackBox; }
virtual void InitGL()const = 0;
virtual void DrawPlot()const = 0;
//Checks, if mouse cursor is above plot.
virtual Bool_t PlotSelected(Int_t px, Int_t py);
//Init geometry does plot's specific initialization.
virtual Bool_t InitGeometry() = 0;
//Pan function is already declared in TVirtualGLPainter.
//Add string option, it can be a digit in "lego" or "surf".
//Function to process additional events (key presses, mouse clicks.)
virtual void ProcessEvent(Int_t event, Int_t px, Int_t py) = 0;
// void SetGLContext(Int_t context);
void SetGLDevice(TGLPaintDevice *dev){fGLDevice = dev;}
void SetPadColor(const TColor *color);
virtual void SetFrameColor(const TColor *frameColor);
//Camera is external to painter, if zoom was changed, or camera
//was rotated, selection must be invalidated.
void InvalidateSelection();
enum ECutAxisID {
kXAxis = 7,
kYAxis = 8,
kZAxis = 9
};
Bool_t CutAxisSelected()const{return !fHighColor && fSelectedPart <= kZAxis && fSelectedPart >= kXAxis;}
const TColor *GetPadColor()const;
Bool_t MakeGLContextCurrent()const;
//
void MoveSection(Int_t px, Int_t py);
void DrawSections()const;
virtual void DrawSectionXOZ()const = 0;
virtual void DrawSectionYOZ()const = 0;
virtual void DrawSectionXOY()const = 0;
ClassDef(TGLPlotPainter, 0) //Base for gl plots
};
/*
Auxiliary class, which holds different
information about plot's current coordinate system
*/
class TGLPlotCoordinates {
private:
EGLCoordType fCoordType;
Rgl::BinRange_t fXBins;
Rgl::BinRange_t fYBins;
Rgl::BinRange_t fZBins;
Double_t fXScale;
Double_t fYScale;
Double_t fZScale;
Rgl::Range_t fXRange;
Rgl::Range_t fYRange;
Rgl::Range_t fZRange;
Rgl::Range_t fXRangeScaled;
Rgl::Range_t fYRangeScaled;
Rgl::Range_t fZRangeScaled;
virtual ~TGLPlotCoordinates();
void SetCoordType(EGLCoordType type);
EGLCoordType GetCoordType()const;
Bool_t SetRanges(const TH1 *hist, Bool_t errors = kFALSE, Bool_t zBins = kFALSE);
Int_t GetNXBins()const;
Int_t GetNYBins()const;
Int_t GetNZBins()const;
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
const Rgl::BinRange_t &GetXBins()const;
const Rgl::BinRange_t &GetYBins()const;
const Rgl::BinRange_t &GetZBins()const;
const Rgl::Range_t &GetXRange()const;
Double_t GetXLength()const;
const Rgl::Range_t &GetYRange()const;
Double_t GetYLength()const;
const Rgl::Range_t &GetZRange()const;
Double_t GetZLength()const;
const Rgl::Range_t &GetXRangeScaled()const;
const Rgl::Range_t &GetYRangeScaled()const;
const Rgl::Range_t &GetZRangeScaled()const;
Double_t GetXScale()const{return fXScale;}
Double_t GetYScale()const{return fYScale;}
Double_t GetZScale()const{return fZScale;}
Int_t GetFirstXBin()const{return fXBins.first;}
Int_t GetLastXBin()const{return fXBins.second;}
Int_t GetFirstYBin()const{return fYBins.first;}
Int_t GetLastYBin()const{return fYBins.second;}
Int_t GetFirstZBin()const{return fZBins.first;}
Int_t GetLastZBin()const{return fZBins.second;}
Double_t GetFactor()const;
private:
Bool_t SetRangesCartesian(const TH1 *hist, Bool_t errors, Bool_t zBins);
Bool_t SetRangesPolar(const TH1 *hist);
Bool_t SetRangesCylindrical(const TH1 *hist);
Bool_t SetRangesSpherical(const TH1 *hist);
TGLPlotCoordinates(const TGLPlotCoordinates &);
TGLPlotCoordinates &operator = (const TGLPlotCoordinates &);
ClassDef(TGLPlotCoordinates, 0)//Auxilary class, holds plot dimensions.
};