Logo ROOT   6.08/07
Reference Guide
TGLWidget.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLWidget
13 #define ROOT_TGLWidget
14 
15 #include <utility>
16 #include <memory>
17 #include <set>
18 
19 #ifndef ROOT_TGLContext
20 #include "TGLContext.h"
21 #endif
22 #ifndef ROOT_TVirtualGL
23 #include "TVirtualGL.h"
24 #endif
25 #ifndef ROOT_TGLFormat
26 #include "TGLFormat.h"
27 #endif
28 #ifndef ROOT_TGFrame
29 #include "TGFrame.h"
30 #endif
31 
32 class TGLWidget;
33 class TGEventHandler;
34 
35 class TGLWidget : public TGFrame, public TGLPaintDevice
36 {
37  friend class TGLContext;
38 
39 private:
41  //fInnerData is for X11 - <dpy, visualInfo> pair.
42  std::pair<void *, void *> fInnerData;
44 
46  //fFromCtor checks that SetFormat was called only from ctor.
48 
49  std::set<TGLContext *> fValidContexts;
50 
52 
53 public:
54  static TGLWidget* CreateDummy();
55 
56  static TGLWidget* Create(const TGWindow* parent, Bool_t selectInput,
57  Bool_t shareDefault, const TGLPaintDevice *shareDevice,
58  UInt_t width, UInt_t height);
59 
60  static TGLWidget* Create(const TGLFormat &format,
61  const TGWindow* parent, Bool_t selectInput,
62  Bool_t shareDefault, const TGLPaintDevice *shareDevice,
63  UInt_t width, UInt_t height);
64 
65  ~TGLWidget();
66 
67  virtual void InitGL();
68  virtual void PaintGL();
69 
72  void SwapBuffers();
73  const TGLContext *GetContext()const;
74 
75  const TGLFormat *GetPixelFormat()const;
76 
77  //This function is public _ONLY_ for calls
78  //via gInterpreter. Do not call it directly.
79  void SetFormat();
80  //To repaint gl-widget without GUI events.
81  void ExtractViewport(Int_t *vp)const;
82 
85 
93 
94  void DoRedraw();
95 
96 private:
97  TGLWidget(const TGLWidget &); // Not implemented.
98  TGLWidget &operator = (const TGLWidget &); // Not implemented.
99 
100 protected:
101  TGLWidget(Window_t glw, const TGWindow* parent, Bool_t selectInput);
102 
103  static Window_t CreateWindow(const TGWindow* parent, const TGLFormat &format,
104  UInt_t width, UInt_t height,
105  std::pair<void *, void *>& innerData);
106 
107  void AddContext(TGLContext *ctx);
108  void RemoveContext(TGLContext *ctx);
109 
110  std::pair<void *, void *> GetInnerData()const;
111 
112  ClassDef(TGLWidget, 0); //Window (widget) version of TGLPaintDevice
113 };
114 
115 #endif
Bool_t HandleConfigureNotify(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:619
Bool_t HandleKey(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:654
void SetFormat()
Set pixel format.
Definition: TGLWidget.cxx:542
TGLWidget(const TGLWidget &)
void AddContext(TGLContext *ctx)
Register gl-context created for this window.
Definition: TGLWidget.cxx:249
Bool_t HandleFocusChange(Event_t *)
Delegate call to the owner.
Definition: TGLWidget.cxx:638
const TGLFormat * GetPixelFormat() const
Pixel format.
Definition: TGLWidget.cxx:233
Bool_t HandleMotion(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:670
void ExtractViewport(Int_t *vp) const
For camera.
Definition: TGLWidget.cxx:267
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGLContext * fGLContext
Definition: TGLWidget.h:40
static std::string format(double x, double y, int digits, int width)
Bool_t HandleCrossing(Event_t *)
Handle mouse crossing event.
Definition: TGLWidget.cxx:566
void DoRedraw()
Delegate call to the owner.
Definition: TGLWidget.cxx:686
static TGLWidget * Create(const TGWindow *parent, Bool_t selectInput, Bool_t shareDefault, const TGLPaintDevice *shareDevice, UInt_t width, UInt_t height)
Static constructor for creating widget with default pixel format.
Definition: TGLWidget.cxx:83
void RemoveContext(TGLContext *ctx)
Remove context (no real deletion, done by TGLContex dtor).
Definition: TGLWidget.cxx:257
static TGLWidget * CreateDummy()
Static constructor for creating widget with default pixel format.
Definition: TGLWidget.cxx:73
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void InitGL()
Call glEnable(... in overrider of InitGL.
Definition: TGLWidget.cxx:187
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
Definition: TGLWidget.cxx:558
std::pair< void *, void * > fInnerData
Definition: TGLWidget.h:42
TGEventHandler * GetEventHandler() const
Definition: TGLWidget.h:83
Bool_t HandleButton(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:587
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:35
void SwapBuffers()
Swap buffers.
Definition: TGLWidget.cxx:217
Bool_t HandleDoubleClick(Event_t *ev)
Delegate call to the owner.
Definition: TGLWidget.cxx:603
const TGLContext * GetContext() const
Get gl context.
Definition: TGLWidget.cxx:225
TGLFormat fGLFormat
Definition: TGLWidget.h:45
unsigned int UInt_t
Definition: RtypesCore.h:42
GL window with context.
Definition: TGLWidget.h:35
~TGLWidget()
Destructor. Deletes window ???? and XVisualInfo.
Definition: TGLWidget.cxx:162
Bool_t MakeCurrent()
Make the gl-context current.
Definition: TGLWidget.cxx:201
This class encapsulates window-system specific information about a GL-context and alows their proper ...
Definition: TGLContext.h:35
Bool_t ClearCurrent()
Clear the current gl-context.
Definition: TGLWidget.cxx:209
TGEventHandler * fEventHandler
Definition: TGLWidget.h:51
Bool_t fFromInit
Definition: TGLWidget.h:47
static Window_t CreateWindow(const TGWindow *parent, const TGLFormat &format, UInt_t width, UInt_t height, std::pair< void *, void *> &innerData)
CreateWidget - X11 version.
Definition: TGLWidget.cxx:499
Handle_t Window_t
Definition: GuiTypes.h:30
Int_t fWindowIndex
Definition: TGLWidget.h:43
TGLWidget & operator=(const TGLWidget &)
virtual void PaintGL()
Do actual drawing in overrider of PaintGL.
Definition: TGLWidget.cxx:194
std::pair< void *, void * > GetInnerData() const
Dpy*, XVisualInfo *.
Definition: TGLWidget.cxx:241
std::set< TGLContext * > fValidContexts
Definition: TGLWidget.h:49