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.
The following types of plots are provided:
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).
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.
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
.TGLParametricPlot
)$ROOTSYS/tutorials/gl/glparametric.C
shows how to create parametric equations and visualize the surface.
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.
Different parts of the plot can be selected:
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.
The selected plot can be moved in a pad's area by pressing and holding the left mouse button and the shift key.
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.
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)
"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.
The contour plot is drawn on the slicing plane. For TF3
the color scheme can be changed by pressing ‘'s’or
'S'`.
The contour plot corresponding to slice plane position is drawn in real time.
Slicing is similar to "GLBOX"
option.
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.
Classes | |
struct | PlotOption_t |
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. | |
TList * | GetContourList (Double_t contour) const |
Get contour list. | |
char * | GetObjectInfo (Int_t px, Int_t py) const |
Overrides TObject::GetObjectInfo. | |
TGLPlotPainter * | GetRealPainter () |
TList * | GetStack () const |
Get stack. | |
virtual TClass * | IsA () const |
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. | |
virtual void | Streamer (TBuffer &) |
Stream an object of class TObject. | |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Public Member Functions inherited from TVirtualHistPainter | |
TVirtualHistPainter () | |
~TVirtualHistPainter () override | |
TClass * | IsA () const override |
void | Streamer (TBuffer &) override |
Stream an object of class TObject. | |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
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 TObject * | Clone (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 TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1) . | |
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=nullptr) |
Execute method on this object with the given parameter string, e.g. | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr) |
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 TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. | |
virtual Option_t * | GetDrawOption () 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_t * | GetOption () 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) |
Bool_t | IsDestructed () const |
IsDestructed. | |
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 []. | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (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. | |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
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=nullptr, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. | |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. | |
Static Public Member Functions | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
Static Public Member Functions inherited from TVirtualHistPainter | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static TVirtualHistPainter * | HistPainter (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 TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static Longptr_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. | |
Private Member Functions | |
TGLHistPainter (const TGLHistPainter &) | |
void | CreatePainter (const PlotOption_t &parsed, const TString &option) |
Create painter. | |
TGLHistPainter & | operator= (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< TVirtualHistPainter > | fDefaultPainter |
TGLParametricEquation * | fEq |
TF3 * | fF3 |
std::unique_ptr< TGLPlotPainter > | fGLPainter |
TH1 * | fHist |
EGLPlotType | fPlotType |
TList * | fStack |
Additional Inherited Members | |
Public Types inherited from TObject | |
enum | { kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 , kBitMask = 0x00ffffff } |
enum | { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) } |
enum | EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) } |
enum | EStatusBits { kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) , kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 )) } |
Protected Types inherited from TObject | |
enum | { kOnlyPrepStep = (1ULL << ( 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>
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::TGLHistPainter | ( | TGLParametricEquation * | equation | ) |
This ctor creates gl-parametric plot's painter.
Definition at line 214 of file TGLHistPainter.cxx.
TGLHistPainter::TGLHistPainter | ( | TGL5DDataSet * | data | ) |
This ctor creates plot painter for TGL5DDataSet.
Definition at line 227 of file TGLHistPainter.cxx.
TGLHistPainter::TGLHistPainter | ( | TGLTH3Composition * | comp | ) |
This ctor creates plot painter for TGL5DDataSet.
Definition at line 240 of file TGLHistPainter.cxx.
|
private |
|
static |
|
inlinestaticconstexpr |
Definition at line 94 of file TGLHistPainter.h.
|
private |
Create painter.
Definition at line 699 of file TGLHistPainter.cxx.
|
inlinestatic |
Definition at line 94 of file TGLHistPainter.h.
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.
|
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.
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:
Implements TVirtualHistPainter.
Definition at line 312 of file TGLHistPainter.cxx.
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.
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.
|
inline |
Definition at line 80 of file TGLHistPainter.h.
|
virtual |
|
inlinevirtual |
Reimplemented from TObject.
Definition at line 94 of file TGLHistPainter.h.
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.
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.
|
virtual |
|
private |
Definition at line 755 of file TGLHistPainter.cxx.
|
virtual |
Final-overrider for TObject::Paint.
Implements TVirtualHistPainter.
Definition at line 579 of file TGLHistPainter.cxx.
Paint statistics.
This does not work on windows.
Implements TVirtualHistPainter.
Definition at line 505 of file TGLHistPainter.cxx.
|
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.
|
virtual |
|
virtual |
Set highlight mode.
Implements TVirtualHistPainter.
Definition at line 526 of file TGLHistPainter.cxx.
|
virtual |
|
virtual |
Set show projection.
Implements TVirtualHistPainter.
Definition at line 748 of file TGLHistPainter.cxx.
|
virtual |
|
virtual |
|
inline |
Definition at line 94 of file TGLHistPainter.h.
|
private |
Definition at line 53 of file TGLHistPainter.h.
|
private |
Definition at line 54 of file TGLHistPainter.h.
|
private |
Definition at line 44 of file TGLHistPainter.h.
|
private |
Definition at line 48 of file TGLHistPainter.h.
|
private |
Definition at line 50 of file TGLHistPainter.h.
|
private |
Definition at line 46 of file TGLHistPainter.h.
|
private |
Definition at line 49 of file TGLHistPainter.h.
|
private |
Definition at line 52 of file TGLHistPainter.h.
|
private |
Definition at line 51 of file TGLHistPainter.h.