Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLEmbeddedViewer.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Bertrand Bellenot 23/01/2008
3
4/*************************************************************************
5 * Copyright (C) 1995-2008, 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#include "TGLayout.h"
13#include "TGLWidget.h"
14#include "TGLSAFrame.h"
15#include "TString.h"
16#include "TGLPShapeObj.h"
17#include "TGLPhysicalShape.h"
18#include "TGLLogicalShape.h"
19#include "TGLEmbeddedViewer.h"
20#include "TGLEventHandler.h"
21
22/** \class TGLEmbeddedViewer
23\ingroup opengl
24Minimal GL-viewer that can be embedded in a standard ROOT frames.
25*/
26
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31/// Argument 'border' specifies how many pixels to pad on each side of the
32/// viewer. This area can be used for highlightning of the active viewer.
33
35 Int_t border) :
36 TGLViewer(pad, 0, 0, 400, 300),
37 fFrame(nullptr),
38 fBorder(border)
39{
40 Init(parent);
41}
42
43////////////////////////////////////////////////////////////////////////////////
44/// Constructor allowing to also specify an GED editor to use.
45/// Argument 'border' specifies how many pixels to pad on each side of the
46/// viewer. This area can be used for highlightning of the active viewer.
47
49 TGedEditor *ged, Int_t border) :
50 TGLViewer(pad, 0, 0, 400, 300),
51 fFrame(nullptr),
52 fBorder(border)
53{
54 fGedEditor = ged;
55 Init(parent);
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Destroy standalone viewer object.
60
62{
63 delete fFrame;
64 fGLWidget = nullptr;
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// Common initialization from all constructors.
69
71{
72 fFrame = new TGCompositeFrame(parent);
73
75
78 fFrame->Resize(400, 300);
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Internal frames creation.
83
85{
86 fGLWidget = TGLWidget::Create(fFrame, kTRUE, kTRUE, nullptr, 10, 10);
87
88 // Direct events from the TGWindow directly to the base viewer
89 fEventHandler = new TGLEventHandler(nullptr, this);
91
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Create a GLwidget, it is an error if it is already created.
98/// This is needed for frame-swapping on mac.
99
101{
102 if (fGLWidget) {
103 Error("CreateGLWidget", "Widget already exists.");
104 return;
105 }
106
107 fGLWidget = TGLWidget::Create(fFrame, kTRUE, kTRUE, nullptr, 10, 10);
109
112 fFrame->Layout();
113
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Destroy the GLwidget, it is an error if it does not exist.
119/// This is needed for frame-swapping on mac.
120
122{
123 if (fGLWidget == nullptr) {
124 Error("DestroyGLWidget", "Widget does not exist.");
125 return;
126 }
127
129 fGLWidget->SetEventHandler(nullptr);
130
133 fGLWidget = nullptr;
134}
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsExpandX
Definition TGLayout.h:30
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:316
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
void MapWindow() override
map window
Definition TGFrame.h:204
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
Minimal GL-viewer that can be embedded in a standard ROOT frames.
void DestroyGLWidget() override
Destroy the GLwidget, it is an error if it does not exist.
void CreateGLWidget() override
Create a GLwidget, it is an error if it is already created.
void CreateFrames()
Internal frames creation.
~TGLEmbeddedViewer() override
Destroy standalone viewer object.
TGLEmbeddedViewer(const TGLEmbeddedViewer &)=delete
void Init(const TGWindow *parent)
Common initialization from all constructors.
TGCompositeFrame * fFrame
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition TGLViewer.h:55
TGEventHandler * fEventHandler
select record from last overlay select
Definition TGLViewer.h:119
TGLWidget * fGLWidget
Definition TGLViewer.h:185
TGedEditor * fGedEditor
event handler
Definition TGLViewer.h:120
friend class TGLEventHandler
Definition TGLViewer.h:57
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 SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51