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
76 fFrame->MapSubwindows();
77 fFrame->Resize(fFrame->GetDefaultSize());
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);
90 fGLWidget->SetEventHandler(fEventHandler);
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);
108 fGLWidget->SetEventHandler(fEventHandler);
109
112 fFrame->Layout();
113
114 fGLWidget->MapWindow();
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
128 fGLWidget->UnmapWindow();
129 fGLWidget->SetEventHandler(nullptr);
130
131 fFrame->RemoveFrame(fGLWidget);
132 fGLWidget->DeleteWindow();
133 fGLWidget = nullptr;
134}
int Int_t
Definition RtypesCore.h:45
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
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
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
TGLViewer(const TGLViewer &)=delete
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
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