Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLHistPainter Class Reference

The histogram painter class using OpenGL.

Histograms are, by default, drawn via the THistPainter class. TGLHistPainter allows to paint them using the OpenGL 3D graphics library. The plotting options provided by TGLHistPainter start with GL keyword.

General information: plot types and supported options

The following types of plots are provided:

Lego - (TGLLegoPainter)

The supported options are:

  • "GLLEGO" : Draw a lego plot.
  • "GLLEGO2" : Bins with color levels.
  • "GLLEGO3" : Cylindrical bars.

Lego painter in cartesian supports logarithmic scales for X, Y, Z. In polar only Z axis can be logarithmic, in cylindrical only Y (if you see what it means).

Surfaces (TF2 and TH2 with "GLSURF" options) - (TGLSurfacePainter)

The supported options are:

  • "GLSURF" : Draw a surface.
  • "GLSURF1" : Surface with color levels
  • "GLSURF2" : The same as "GLSURF1" but without polygon outlines.
  • "GLSURF3" : Color level projection on top of plot (works only in cartesian coordinate system).
  • "GLSURF4" : Same as "GLSURF" but without polygon outlines.

The surface painting in cartesian coordinates supports logarithmic scales along X, Y, Z axis. In polar coordinates only the Z axis can be logarithmic, in cylindrical coordinates only the Y axis.

Additional options to SURF and LEGO - Coordinate systems:

The supported options are:

  • " " : Default, cartesian coordinates system.
  • "POL" : Polar coordinates system.
  • "CYL" : Cylindrical coordinates system.
  • "SPH" : Spherical coordinates system.

TH3 as boxes (spheres) - (TGLBoxPainter)

The supported options are:

  • "GLBOX" : TH3 as a set of boxes, size of box is proportional to bin content.
  • "GLBOX1": the same as "glbox", but spheres are drawn instead of boxes.

TH3 as iso-surface(s) - (TGLIsoPainter)

The supported option is:

  • "GLISO" : TH3 is drawn using iso-surfaces.

TH3 as color boxes - (TGLVoxelPainter)

The supported option is:

  • "GLCOL" : TH3 is drawn using semi-transparent colored boxes. See $ROOTSYS/tutorials/gl/glvox1.C.

TF3 (implicit function) - (TGLTF3Painter)

The supported option is:

  • "GLTF3" : Draw a TF3.

Parametric surfaces - (TGLParametricPlot)

$ROOTSYS/tutorials/gl/glparametric.C shows how to create parametric equations and visualize the surface.

Interaction with the plots

General information.

All the interactions are implemented via standard methods DistancetoPrimitive and ExecuteEvent. That's why all the interactions with the OpenGL plots are possible i only when the mouse cursor is in the plot's area (the plot's area is the part of a the pad occupied by gl-produced picture). If the mouse cursor is not above gl-picture, the standard pad interaction is performed.

Selectable parts.

Different parts of the plot can be selected:

  • xoz, yoz, xoy back planes: When such a plane selected, it's highlighted in green if the dynamic slicing by this plane is supported, and it's highlighted in red, if the dynamic slicing is not supported. -*The plot itself*: On surfaces, the selected surface is outlined in red. (TF3 and ISO are not outlined). On lego plots, the selected bin is highlihted. The bin number and content are displayed in pad's status bar. In box plots, the box or sphere is highlighted and the bin info is displayed in pad's status bar.

Rotation and zooming.

  • Rotation:

When the plot is selected, it can be rotated by pressing and holding the left mouse button and move the cursor.

  • Zoom/Unzoom:

Mouse wheel or ‘'j’,'J','k','K'` keys.

Panning.

The selected plot can be moved in a pad's area by pressing and holding the left mouse button and the shift key.

Box cut

Surface, iso, box, TF3 and parametric painters support box cut by pressing the ‘'c’or 'C'` key when the mouse cursor is in a plot's area. That will display a transparent box, cutting away part of the surface (or boxes) in order to show internal part of plot. This box can be moved inside the plot's area (the full size of the box is equal to the plot's surrounding box) by selecting one of the box cut axes and pressing the left mouse button to move it.

Plot specific interactions (dynamic slicing etc.)

Currently, all gl-plots support some form of slicing. When back plane is selected (and if it's highlighted in green) you can press and hold left mouse button and shift key and move this back plane inside plot's area, creating the slice. During this "slicing" plot becomes semi-transparent. To remove all slices (and projected curves for surfaces)

  • double click with left mouse button in a plot's area.

Surface with option "GLSURF"

The surface profile is displayed on the slicing plane. The profile projection is drawn on the back plane by pressing ‘'p’or'P'` key.

TF3

The contour plot is drawn on the slicing plane. For TF3 the color scheme can be changed by pressing ‘'s’or'S'`.

Box

The contour plot corresponding to slice plane position is drawn in real time.

Iso

Slicing is similar to "GLBOX" option.

Parametric plot

No slicing. Additional keys: ‘'s’or'S'to change color scheme - about 20 color schemes supported ('s'for "scheme");'l'or'L'to increase number of polygons ('l'for "level" of details), 'w'or'W'to show outlines ('w'` for "wireframe").

Definition at line 40 of file TGLHistPainter.h.

Public Member Functions

 TGLHistPainter (TGL5DDataSet *data)
 This ctor creates plot painter for TGL5DDataSet.
 
 TGLHistPainter (TGLParametricEquation *equation)
 This ctor creates gl-parametric plot's painter.
 
 TGLHistPainter (TGLTH3Composition *comp)
 This ctor creates plot painter for TGL5DDataSet.
 
 TGLHistPainter (TH1 *hist)
 ROOT does not use exceptions, so, if default painter's creation failed, fDefaultPainter is 0.
 
Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Selects plot or axis.
 
void DrawPanel ()
 Default implementation is OK This function is called from a context menu after right click on a plot's area.
 
void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute event.
 
TListGetContourList (Double_t contour) const
 Get contour list.
 
char * GetObjectInfo (Int_t px, Int_t py) const
 Overrides TObject::GetObjectInfo.
 
TGLPlotPainterGetRealPainter ()
 
TListGetStack () const
 Get stack.
 
Bool_t IsInside (Double_t x, Double_t y)
 Returns kTRUE if the cell x, y is inside one of the graphical cuts.
 
Bool_t IsInside (Int_t x, Int_t y)
 Returns kTRUE if the cell ix, iy is inside one of the graphical cuts.
 
Int_t MakeCuts (char *cutsOpt)
 Make cuts.
 
void Paint (Option_t *option)
 Final-overrider for TObject::Paint.
 
void PaintStat (Int_t dostat, TF1 *fit)
 Paint statistics.
 
void ProcessMessage (const char *message, const TObject *obj)
 Process message.
 
void SetHighlight ()
 Set highlight mode.
 
void SetHistogram (TH1 *hist)
 Set histogram.
 
void SetShowProjection (const char *option, Int_t nbins)
 Set show projection.
 
void SetStack (TList *stack)
 Set stack.
 
- Public Member Functions inherited from TVirtualHistPainter
 TVirtualHistPainter ()
 
virtual ~TVirtualHistPainter ()
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 Make a clone of an object using the Streamer facility.
 
virtual Int_t Compare (const TObject *obj) const
 Compare abstract method.
 
virtual void Copy (TObject &object) const
 Copy this to obj.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual const char * GetName () const
 Returns name of object.
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 Returns title of object.
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
virtual ULong_t Hash () const
 Return hash value for this object.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 The ls function lists the contents of a class on stdout.
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification.
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual void Print (Option_t *option="") const
 This method must be overridden when a class wants to print itself.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out".
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Private Member Functions

 TGLHistPainter (const TGLHistPainter &)
 
void CreatePainter (const PlotOption_t &parsed, const TString &option)
 Create painter.
 
TGLHistPainteroperator= (const TGLHistPainter &)
 
void PadToViewport (Bool_t selectionPass=kFALSE)
 
PlotOption_t ParsePaintOption (const TString &option) const
 In principle, we can have several conflicting options: "lego surf pol sph", surfbb: surf, fb, bb.
 

Private Attributes

TGLPlotCamera fCamera
 
TGLPlotCoordinates fCoord
 
std::unique_ptr< TVirtualHistPainterfDefaultPainter
 
TGLParametricEquationfEq
 
TF3fF3
 
std::unique_ptr< TGLPlotPainterfGLPainter
 
TH1fHist
 
EGLPlotType fPlotType
 
TListfStack
 

Additional Inherited Members

- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = BIT(0) , kOverwrite = BIT(1) , kWriteDelete = BIT(2) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = BIT(3) }
 
enum  EStatusBits {
  kCanDelete = BIT(0) , kMustCleanup = BIT(3) , kIsReferenced = BIT(4) , kHasUUID = BIT(5) ,
  kCannotPick = BIT(6) , kNoContextMenu = BIT(8) , kInvalidObject = BIT(13)
}
 
- Static Public Member Functions inherited from TVirtualHistPainter
static TVirtualHistPainterHistPainter (TH1 *obj)
 Static function returning a pointer to the current histogram painter.
 
static void SetPainter (const char *painter)
 Static function to set an alternative histogram painter.
 
- Static Public Member Functions inherited from TObject
static Long_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = BIT(3) }
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

#include <TGLHistPainter.h>

Inheritance diagram for TGLHistPainter:
[legend]

Constructor & Destructor Documentation

◆ TGLHistPainter() [1/5]

TGLHistPainter::TGLHistPainter ( TH1 hist)

ROOT does not use exceptions, so, if default painter's creation failed, fDefaultPainter is 0.

In each function, which use it, I have to check the pointer first.

Definition at line 201 of file TGLHistPainter.cxx.

◆ TGLHistPainter() [2/5]

TGLHistPainter::TGLHistPainter ( TGLParametricEquation equation)

This ctor creates gl-parametric plot's painter.

Definition at line 214 of file TGLHistPainter.cxx.

◆ TGLHistPainter() [3/5]

TGLHistPainter::TGLHistPainter ( TGL5DDataSet data)

This ctor creates plot painter for TGL5DDataSet.

Definition at line 227 of file TGLHistPainter.cxx.

◆ TGLHistPainter() [4/5]

TGLHistPainter::TGLHistPainter ( TGLTH3Composition comp)

This ctor creates plot painter for TGL5DDataSet.

Definition at line 240 of file TGLHistPainter.cxx.

◆ TGLHistPainter() [5/5]

TGLHistPainter::TGLHistPainter ( const TGLHistPainter )
private

Member Function Documentation

◆ CreatePainter()

void TGLHistPainter::CreatePainter ( const PlotOption_t &  parsed,
const TString option 
)
private

Create painter.

Definition at line 699 of file TGLHistPainter.cxx.

◆ DistancetoPrimitive()

Int_t TGLHistPainter::DistancetoPrimitive ( Int_t  px,
Int_t  py 
)
virtual

Selects plot or axis.

9999 is the magic number, ROOT's classes use in DistancetoPrimitive.

Implements TVirtualHistPainter.

Definition at line 254 of file TGLHistPainter.cxx.

◆ DrawPanel()

void TGLHistPainter::DrawPanel ( )
virtual

Default implementation is OK This function is called from a context menu after right click on a plot's area.

Opens window ("panel") with several controls.

Implements TVirtualHistPainter.

Definition at line 295 of file TGLHistPainter.cxx.

◆ ExecuteEvent()

void TGLHistPainter::ExecuteEvent ( Int_t  event,
Int_t  px,
Int_t  py 
)
virtual

Execute event.

Events are: mouse events in a plot's area, key presses (while mouse cursor is in plot's area). "Event execution" means one of the following actions:

  1. Rotation.
  2. Panning.
  3. Zoom changing.
  4. Moving dynamic profile.
  5. Plot specific events - for example, 's' or 'S' key press for TF3.

Implements TVirtualHistPainter.

Definition at line 312 of file TGLHistPainter.cxx.

◆ GetContourList()

TList * TGLHistPainter::GetContourList ( Double_t  contour) const
virtual

Get contour list.

I do not use this function. Contours are implemented in a completely different way by gl-painters.

Implements TVirtualHistPainter.

Definition at line 438 of file TGLHistPainter.cxx.

◆ GetObjectInfo()

char * TGLHistPainter::GetObjectInfo ( Int_t  px,
Int_t  py 
) const
virtual

Overrides TObject::GetObjectInfo.

For lego info is: bin numbers (i, j), bin content. For TF2 info is: x,y,z 3d surface-point for 2d screen-point under cursor (this can work incorrectly now, because of wrong code in TF2). For TF3 no info now. For box info is: bin numbers (i, j, k), bin content.

Implements TVirtualHistPainter.

Definition at line 451 of file TGLHistPainter.cxx.

◆ GetRealPainter()

TGLPlotPainter * TGLHistPainter::GetRealPainter ( )
inline

Definition at line 80 of file TGLHistPainter.h.

◆ GetStack()

TList * TGLHistPainter::GetStack ( ) const
virtual

Get stack.

Implements TVirtualHistPainter.

Definition at line 472 of file TGLHistPainter.cxx.

◆ IsInside() [1/2]

Bool_t TGLHistPainter::IsInside ( Double_t  x,
Double_t  y 
)
virtual

Returns kTRUE if the cell x, y is inside one of the graphical cuts.

I do not use this function anywhere, this is a "default implementation".

Implements TVirtualHistPainter.

Definition at line 493 of file TGLHistPainter.cxx.

◆ IsInside() [2/2]

Bool_t TGLHistPainter::IsInside ( Int_t  x,
Int_t  y 
)
virtual

Returns kTRUE if the cell ix, iy is inside one of the graphical cuts.

I do not use this function anywhere, this is a "default implementation".

Implements TVirtualHistPainter.

Definition at line 481 of file TGLHistPainter.cxx.

◆ MakeCuts()

Int_t TGLHistPainter::MakeCuts ( char *  cutsOpt)
virtual

Make cuts.

Implements TVirtualHistPainter.

Definition at line 557 of file TGLHistPainter.cxx.

◆ operator=()

TGLHistPainter & TGLHistPainter::operator= ( const TGLHistPainter )
private

◆ PadToViewport()

void TGLHistPainter::PadToViewport ( Bool_t  selectionPass = kFALSE)
private

Definition at line 755 of file TGLHistPainter.cxx.

◆ Paint()

void TGLHistPainter::Paint ( Option_t option)
virtual

Final-overrider for TObject::Paint.

Implements TVirtualHistPainter.

Definition at line 579 of file TGLHistPainter.cxx.

◆ PaintStat()

void TGLHistPainter::PaintStat ( Int_t  dostat,
TF1 fit 
)
virtual

Paint statistics.

This does not work on windows.

Implements TVirtualHistPainter.

Definition at line 505 of file TGLHistPainter.cxx.

◆ ParsePaintOption()

TGLHistPainter::PlotOption_t TGLHistPainter::ParsePaintOption ( const TString o) const
private

In principle, we can have several conflicting options: "lego surf pol sph", surfbb: surf, fb, bb.

but only one will be selected, which one - depends on parsing order in this function.

Definition at line 652 of file TGLHistPainter.cxx.

◆ ProcessMessage()

void TGLHistPainter::ProcessMessage ( const char *  message,
const TObject obj 
)
virtual

Process message.

Implements TVirtualHistPainter.

Definition at line 514 of file TGLHistPainter.cxx.

◆ SetHighlight()

void TGLHistPainter::SetHighlight ( )
virtual

Set highlight mode.

Implements TVirtualHistPainter.

Definition at line 526 of file TGLHistPainter.cxx.

◆ SetHistogram()

void TGLHistPainter::SetHistogram ( TH1 hist)
virtual

Set histogram.

Implements TVirtualHistPainter.

Definition at line 535 of file TGLHistPainter.cxx.

◆ SetShowProjection()

void TGLHistPainter::SetShowProjection ( const char *  option,
Int_t  nbins 
)
virtual

Set show projection.

Implements TVirtualHistPainter.

Definition at line 748 of file TGLHistPainter.cxx.

◆ SetStack()

void TGLHistPainter::SetStack ( TList stack)
virtual

Set stack.

Implements TVirtualHistPainter.

Definition at line 546 of file TGLHistPainter.cxx.

Member Data Documentation

◆ fCamera

TGLPlotCamera TGLHistPainter::fCamera
private

Definition at line 53 of file TGLHistPainter.h.

◆ fCoord

TGLPlotCoordinates TGLHistPainter::fCoord
private

Definition at line 54 of file TGLHistPainter.h.

◆ fDefaultPainter

std::unique_ptr<TVirtualHistPainter> TGLHistPainter::fDefaultPainter
private

Definition at line 44 of file TGLHistPainter.h.

◆ fEq

TGLParametricEquation* TGLHistPainter::fEq
private

Definition at line 48 of file TGLHistPainter.h.

◆ fF3

TF3* TGLHistPainter::fF3
private

Definition at line 50 of file TGLHistPainter.h.

◆ fGLPainter

std::unique_ptr<TGLPlotPainter> TGLHistPainter::fGLPainter
private

Definition at line 46 of file TGLHistPainter.h.

◆ fHist

TH1* TGLHistPainter::fHist
private

Definition at line 49 of file TGLHistPainter.h.

◆ fPlotType

EGLPlotType TGLHistPainter::fPlotType
private

Definition at line 52 of file TGLHistPainter.h.

◆ fStack

TList* TGLHistPainter::fStack
private

Definition at line 51 of file TGLHistPainter.h.

Libraries for TGLHistPainter:

The documentation for this class was generated from the following files: