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
27
28////////////////////////////////////////////////////////////////////////////////
29/// Constructor.
30/// Argument 'border' specifies how many pixels to pad on each side of the
31/// viewer. This area can be used for highlightning of the active viewer.
32
34 Int_t border) :
35 TGLViewer(pad, 0, 0, 400, 300),
36 fFrame(nullptr),
37 fBorder(border)
38{
39 Init(parent);
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor allowing to also specify an GED editor to use.
44/// Argument 'border' specifies how many pixels to pad on each side of the
45/// viewer. This area can be used for highlightning of the active viewer.
46
48 TGedEditor *ged, Int_t border) :
49 TGLViewer(pad, 0, 0, 400, 300),
50 fFrame(nullptr),
51 fBorder(border)
52{
53 fGedEditor = ged;
54 Init(parent);
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Destroy standalone viewer object.
59
61{
62 delete fFrame;
63 fGLWidget = nullptr;
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Common initialization from all constructors.
68
70{
71 fFrame = new TGCompositeFrame(parent);
72
74
77 fFrame->Resize(400, 300);
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Internal frames creation.
82
84{
85 fGLWidget = TGLWidget::Create(fFrame, kTRUE, kTRUE, nullptr, 10, 10);
86
87 // Direct events from the TGWindow directly to the base viewer
88 fEventHandler = new TGLEventHandler(nullptr, this);
90
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Create a GLwidget, it is an error if it is already created.
97/// This is needed for frame-swapping on mac.
98
100{
101 if (fGLWidget) {
102 Error("CreateGLWidget", "Widget already exists.");
103 return;
104 }
105
106 fGLWidget = TGLWidget::Create(fFrame, kTRUE, kTRUE, nullptr, 10, 10);
108
111 fFrame->Layout();
112
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Destroy the GLwidget, it is an error if it does not exist.
118/// This is needed for frame-swapping on mac.
119
121{
122 if (fGLWidget == nullptr) {
123 Error("DestroyGLWidget", "Widget does not exist.");
124 return;
125 }
126
128 fGLWidget->SetEventHandler(nullptr);
129
132 fGLWidget = nullptr;
133}
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsExpandX
Definition TGLayout.h:30
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1141
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
void MapWindow() override
map window
Definition TGFrame.h:206
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:268
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
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:82
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:1071
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51