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 "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(0),
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(0),
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 = 0;
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{
87
88 // Direct events from the TGWindow directly to the base viewer
89 fEventHandler = new TGLEventHandler(0, 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
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 == 0) {
124 Error("DestroyGLWidget", "Widget does not exist.");
125 return;
126 }
127
130
133 fGLWidget = 0;
134}
int Int_t
Definition: RtypesCore.h:45
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:364
@ 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
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1117
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1257
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:316
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1164
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1149
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:276
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:605
virtual void MapWindow()
map window
Definition: TGFrame.h:204
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:206
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: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.
Definition: TGLWidget.cxx:558
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:893
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51