ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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:

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:

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:

TH3 as boxes (spheres) - (TGLBoxPainter)

The supported options are:

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

The supported option is:

TH3 as color boxes - (TGLVoxelPainter)

The supported option is:

TF3 (implicit function) - (TGLTF3Painter)

The supported option is:

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:

Rotation and zooming.

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

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)

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 46 of file TGLHistPainter.h.

Public Member Functions

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

Private Member Functions

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

Private Attributes

std::auto_ptr
< TVirtualHistPainter
fDefaultPainter
 
std::auto_ptr< TGLPlotPainterfGLPainter
 
TGLParametricEquationfEq
 
TH1fHist
 
TF3fF3
 
TListfStack
 
EGLPlotType fPlotType
 
TGLPlotCamera fCamera
 
TGLPlotCoordinates fCoord
 

Additional Inherited Members

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

#include <TGLHistPainter.h>

Inheritance diagram for TGLHistPainter:
[legend]

Constructor & Destructor Documentation

TGLHistPainter::TGLHistPainter ( TH1 hist)
TGLHistPainter::TGLHistPainter ( TGLParametricEquation equation)

This ctor creates gl-parametric plot's painter.

Definition at line 216 of file TGLHistPainter.cxx.

TGLHistPainter::TGLHistPainter ( TGL5DDataSet data)

This ctor creates plot painter for TGL5DDataSet.

Definition at line 229 of file TGLHistPainter.cxx.

TGLHistPainter::TGLHistPainter ( TGLTH3Composition comp)

This ctor creates plot painter for TGL5DDataSet.

Definition at line 242 of file TGLHistPainter.cxx.

TGLHistPainter::TGLHistPainter ( const TGLHistPainter )
private

Member Function Documentation

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

Create painter.

Definition at line 692 of file TGLHistPainter.cxx.

Referenced by Paint().

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 256 of file TGLHistPainter.cxx.

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 297 of file TGLHistPainter.cxx.

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 314 of file TGLHistPainter.cxx.

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 440 of file TGLHistPainter.cxx.

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 453 of file TGLHistPainter.cxx.

TGLPlotPainter* TGLHistPainter::GetRealPainter ( )
inline

Definition at line 85 of file TGLHistPainter.h.

TList * TGLHistPainter::GetStack ( ) const
virtual

Get stack.

Implements TVirtualHistPainter.

Definition at line 474 of file TGLHistPainter.cxx.

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 483 of file TGLHistPainter.cxx.

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 495 of file TGLHistPainter.cxx.

Int_t TGLHistPainter::MakeCuts ( char *  cutsOpt)
virtual

Make cuts.

Implements TVirtualHistPainter.

Definition at line 550 of file TGLHistPainter.cxx.

TGLHistPainter& TGLHistPainter::operator= ( const TGLHistPainter )
private
void TGLHistPainter::PadToViewport ( Bool_t  selectionPass = kFALSE)
private

Definition at line 748 of file TGLHistPainter.cxx.

Referenced by DistancetoPrimitive(), ExecuteEvent(), and Paint().

void TGLHistPainter::Paint ( Option_t option)
virtual

Final-overrider for TObject::Paint.

Implements TVirtualHistPainter.

Definition at line 572 of file TGLHistPainter.cxx.

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

Paint statistics.

This does not work on windows.

Implements TVirtualHistPainter.

Definition at line 507 of file TGLHistPainter.cxx.

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 645 of file TGLHistPainter.cxx.

Referenced by Paint().

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

Process message.

Implements TVirtualHistPainter.

Definition at line 516 of file TGLHistPainter.cxx.

void TGLHistPainter::SetHistogram ( TH1 hist)
virtual

Set histogram.

Implements TVirtualHistPainter.

Definition at line 528 of file TGLHistPainter.cxx.

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

Set show projection.

Implements TVirtualHistPainter.

Definition at line 741 of file TGLHistPainter.cxx.

void TGLHistPainter::SetStack ( TList stack)
virtual

Set stack.

Implements TVirtualHistPainter.

Definition at line 539 of file TGLHistPainter.cxx.

Member Data Documentation

TGLPlotCamera TGLHistPainter::fCamera
private

Definition at line 59 of file TGLHistPainter.h.

Referenced by CreatePainter(), ExecuteEvent(), PadToViewport(), and TGLHistPainter().

TGLPlotCoordinates TGLHistPainter::fCoord
private

Definition at line 60 of file TGLHistPainter.h.

Referenced by CreatePainter(), and TGLHistPainter().

std::auto_ptr<TVirtualHistPainter> TGLHistPainter::fDefaultPainter
private
TGLParametricEquation* TGLHistPainter::fEq
private

Definition at line 54 of file TGLHistPainter.h.

TF3* TGLHistPainter::fF3
private

Definition at line 56 of file TGLHistPainter.h.

Referenced by CreatePainter(), and ProcessMessage().

std::auto_ptr<TGLPlotPainter> TGLHistPainter::fGLPainter
private
TH1* TGLHistPainter::fHist
private

Definition at line 55 of file TGLHistPainter.h.

Referenced by CreatePainter(), and SetHistogram().

EGLPlotType TGLHistPainter::fPlotType
private
TList* TGLHistPainter::fStack
private

Definition at line 57 of file TGLHistPainter.h.

Referenced by GetStack(), ParsePaintOption(), and SetStack().

Collaboration diagram for TGLHistPainter:
[legend]

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