Logo ROOT  
Reference Guide
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 "TGFrame.h"
13#include "TGLayout.h"
14#include "TGLWidget.h"
15#include "TGLSAFrame.h"
16#include "TString.h"
17#include "TGLPShapeObj.h"
18#include "TGLPhysicalShape.h"
19#include "TGLLogicalShape.h"
20#include "TGLEmbeddedViewer.h"
21#include "TGLEventHandler.h"
22
23/** \class TGLEmbeddedViewer
24\ingroup opengl
25Minimal GL-viewer that can be embedded in a standard ROOT frames.
26*/
27
29
30////////////////////////////////////////////////////////////////////////////////
31/// Constructor.
32/// Argument 'border' specifies how many pixels to pad on each side of the
33/// viewer. This area can be used for highlightning of the active viewer.
34
36 Int_t border) :
37 TGLViewer(pad, 0, 0, 400, 300),
38 fFrame(0),
39 fBorder(border)
40{
41 Init(parent);
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Constructor allowing to also specify an GED editor to use.
46/// Argument 'border' specifies how many pixels to pad on each side of the
47/// viewer. This area can be used for highlightning of the active viewer.
48
50 TGedEditor *ged, Int_t border) :
51 TGLViewer(pad, 0, 0, 400, 300),
52 fFrame(0),
53 fBorder(border)
54{
55 fGedEditor = ged;
56 Init(parent);
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Destroy standalone viewer object.
61
63{
64 delete fFrame;
65 fGLWidget = 0;
66}
67
68////////////////////////////////////////////////////////////////////////////////
69/// Common initialization from all constructors.
70
72{
73 fFrame = new TGCompositeFrame(parent);
74
76
79 fFrame->Resize(400, 300);
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Internal frames creation.
84
86{
88
89 // Direct events from the TGWindow directly to the base viewer
90 fEventHandler = new TGLEventHandler(0, this);
92
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Create a GLwidget, it is an error if it is already created.
99/// This is needed for frame-swapping on mac.
100
102{
103 if (fGLWidget) {
104 Error("CreateGLWidget", "Widget already exists.");
105 return;
106 }
107
110
113 fFrame->Layout();
114
116}
117
118////////////////////////////////////////////////////////////////////////////////
119/// Destroy the GLwidget, it is an error if it does not exist.
120/// This is needed for frame-swapping on mac.
121
123{
124 if (fGLWidget == 0) {
125 Error("DestroyGLWidget", "Widget does not exist.");
126 return;
127 }
128
131
134 fGLWidget = 0;
135}
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsExpandX
Definition: TGLayout.h:37
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1241
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:353
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1148
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1133
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:260
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
virtual void MapWindow()
map window
Definition: TGFrame.h:229
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:231
Minimal GL-viewer that can be embedded in a standard ROOT frames.
void CreateFrames()
Internal frames creation.
~TGLEmbeddedViewer()
Destroy standalone viewer object.
virtual void DestroyGLWidget()
Destroy the GLwidget, it is an error if it does not exist.
TGLEmbeddedViewer(const TGLEmbeddedViewer &)
void Init(const TGWindow *parent)
Common initialization from all constructors.
TGCompositeFrame * fFrame
virtual void CreateGLWidget()
Create a GLwidget, it is an error if it is already created.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:57
TGEventHandler * fEventHandler
select record from last overlay select
Definition: TGLViewer.h:121
TGLWidget * fGLWidget
Definition: TGLViewer.h:187
TGedEditor * fGedEditor
event handler
Definition: TGLViewer.h:122
friend class TGLEventHandler
Definition: TGLViewer.h:59
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.
Definition: TGLWidget.cxx:558
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51