Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGLWidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/gl:$Id$
0002 // Author:  Timur Pocheptsov, Jun 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGLWidget
0013 #define ROOT_TGLWidget
0014 
0015 #include <utility>
0016 #include <memory>
0017 #include <set>
0018 
0019 #include "TGLContext.h"
0020 #include "TVirtualGL.h"
0021 #include "TGLFormat.h"
0022 #include "TGFrame.h"
0023 
0024 class TGLWidget;
0025 class TGEventHandler;
0026 
0027 class TGLWidget : public TGFrame, public TGLPaintDevice
0028 {
0029    friend class TGLContext;
0030 
0031 private:
0032    TGLContext                       *fGLContext;
0033    //fInnerData is for X11 - <dpy, visualInfo> pair.
0034    std::pair<void *, void *>         fInnerData;
0035    Int_t                             fWindowIndex;
0036 
0037    TGLFormat                         fGLFormat;
0038    //fFromCtor checks that SetFormat was called only from ctor.
0039    Bool_t                            fFromInit;
0040 
0041    std::set<TGLContext *>            fValidContexts;
0042 
0043    TGEventHandler                   *fEventHandler;
0044 
0045 public:
0046    static TGLWidget* CreateDummy();
0047 
0048    static TGLWidget* Create(const TGWindow* parent, Bool_t selectInput,
0049              Bool_t shareDefault, const TGLPaintDevice *shareDevice,
0050              UInt_t width, UInt_t height);
0051 
0052    static TGLWidget* Create(const TGLFormat &format,
0053              const TGWindow* parent, Bool_t selectInput,
0054              Bool_t shareDefault, const TGLPaintDevice *shareDevice,
0055              UInt_t width, UInt_t height);
0056 
0057    ~TGLWidget() override;
0058 
0059    virtual void      InitGL();
0060    virtual void      PaintGL();
0061 
0062    Bool_t            MakeCurrent() override;
0063    Bool_t            ClearCurrent();
0064    void              SwapBuffers() override;
0065    const TGLContext *GetContext()const override;
0066 
0067    const  TGLFormat *GetPixelFormat()const override;
0068 
0069    //This function is public _ONLY_ for calls
0070    //via gInterpreter. Do not call it directly.
0071    void              SetFormat();
0072    //To repaint gl-widget without GUI events.
0073    void              ExtractViewport(Int_t *vp)const override;
0074 
0075    TGEventHandler   *GetEventHandler() const { return fEventHandler; }
0076    void              SetEventHandler(TGEventHandler *eh);
0077 
0078    Bool_t HandleButton(Event_t *ev) override;
0079    Bool_t HandleDoubleClick(Event_t *ev) override;
0080    Bool_t HandleConfigureNotify(Event_t *ev) override;
0081    Bool_t HandleKey(Event_t *ev) override;
0082    Bool_t HandleMotion(Event_t *ev) override;
0083    Bool_t HandleFocusChange(Event_t *) override;
0084    Bool_t HandleCrossing(Event_t *) override;
0085 
0086    void   DoRedraw() override;
0087 
0088 private:
0089    TGLWidget(const TGLWidget &) = delete;
0090    TGLWidget &operator = (const TGLWidget &) = delete;
0091 
0092 protected:
0093    TGLWidget(Window_t glw, const TGWindow* parent, Bool_t selectInput);
0094 
0095    static Window_t CreateWindow(const TGWindow* parent, const TGLFormat &format,
0096                                 UInt_t width, UInt_t height,
0097                                 std::pair<void *, void *>& innerData);
0098 
0099    void AddContext(TGLContext *ctx) override;
0100    void RemoveContext(TGLContext *ctx) override;
0101 
0102    std::pair<void *, void *> GetInnerData()const;
0103 
0104    ClassDefOverride(TGLWidget, 0); //Window (widget) version of TGLPaintDevice
0105 };
0106 
0107 #endif