CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions
FWTGLViewer Class Reference

#include "FWTGLViewer.h"

Inheritance diagram for FWTGLViewer:

Public Member Functions

void DrawHiLod (Bool_t swap_buffers)
 
 FWTGLViewer (const TGWindow *parent)
 
TGLFBO * GenerateFbo (Int_t w, Int_t h, Float_t pixel_object_scale)
 
void JustSwap ()
 
TGLFBO * MakeFbo ()
 
TGLFBO * MakeFboHeight (Int_t height, Bool_t pixel_object_scale=kTRUE)
 
TGLFBO * MakeFboScale (Float_t scale, Bool_t pixel_object_scale=kTRUE)
 
TGLFBO * MakeFboWidth (Int_t width, Bool_t pixel_object_scale=kTRUE)
 
virtual ~FWTGLViewer ()
 

Private Member Functions

 FWTGLViewer (const FWTGLViewer &)
 
const FWTGLVieweroperator= (const FWTGLViewer &)
 

Detailed Description

Description: [one line class summary]

Usage: <usage>

Definition at line 32 of file FWTGLViewer.h.

Constructor & Destructor Documentation

FWTGLViewer::FWTGLViewer ( const TGWindow *  parent)

Definition at line 39 of file FWTGLViewer.cc.

39  :
40  TGLEmbeddedViewer(parent, 0, 0, 0)
41 {
42 }
list parent
Definition: dbtoconf.py:74
FWTGLViewer::~FWTGLViewer ( )
virtual

Definition at line 49 of file FWTGLViewer.cc.

50 {
51 }
FWTGLViewer::FWTGLViewer ( const FWTGLViewer )
private

Member Function Documentation

void FWTGLViewer::DrawHiLod ( Bool_t  swap_buffers)

Definition at line 73 of file FWTGLViewer.cc.

74 {
75  fRedrawTimer->Stop();
76 
77  // Ignore request if GL window or context not yet availible or shown.
78  if ((!fGLWidget && fGLDevice == -1) || (fGLWidget && !fGLWidget->IsMapped()))
79  {
80  return;
81  }
82 
83  // Take scene draw lock - to be revisited
84  if ( ! TakeLock(kDrawLock))
85  {
86  // If taking drawlock fails the previous draw is still in progress
87  // set timer to do this one later
88  Error("FWTGLViewer::DrawHiLodNoSwap", "viewer locked - skipping this draw.");
89  fRedrawTimer->RequestDraw(100, TGLRnrCtx::kLODHigh);
90  return;
91  }
92 
93  fLOD = TGLRnrCtx::kLODHigh;
94 
95  DoDraw(swap_buffers);
96 }
TGLFBO * FWTGLViewer::GenerateFbo ( Int_t  w,
Int_t  h,
Float_t  pixel_object_scale 
)

Definition at line 155 of file FWTGLViewer.cc.

Referenced by MakeFbo(), MakeFboHeight(), MakeFboScale(), and MakeFboWidth().

156 {
157  // Generate FBO -- function that does the actual work.
158 
159  static const TString eh("FWTGLViewer::SavePictureUsingFBO");
160 
161  if ( ! GLEW_EXT_framebuffer_object)
162  {
163  ::Warning(eh, "Missing FBO support.");
164  }
165 
166  if ( ! TakeLock(kDrawLock)) {
167  ::Error(eh, "viewer locked - try later.");
168  return 0;
169  }
170 
171  TUnlocker ulck(this);
172 
173  MakeCurrent();
174 
175  TGLFBO *fbo = new TGLFBO();
176  try
177  {
178  fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
179  }
180  catch (std::runtime_error& exc)
181  {
182  ::Error(eh, "%s",exc.what());
183  return 0;
184  }
185 
186  TGLRect old_vp(fViewport);
187  SetViewport(0, 0, w, h);
188 
189  Float_t old_scale = 1;
190  if (pixel_object_scale != 0)
191  {
192  old_scale = fRnrCtx->GetRenderScale();
193  fRnrCtx->SetRenderScale(old_scale * pixel_object_scale);
194  }
195 
196  fbo->Bind();
197 
198  fLOD = TGLRnrCtx::kLODHigh;
199  fRnrCtx->SetGrabImage(kTRUE);
200 
201  DoDraw(kFALSE);
202 
203  fRnrCtx->SetGrabImage(kFALSE);
204 
205  fbo->Unbind();
206 
207  if (pixel_object_scale != 0)
208  {
209  fRnrCtx->SetRenderScale(old_scale);
210  }
211 
212  SetViewport(old_vp);
213 
214  return fbo;
215 }
const double w
Definition: UKUtility.cc:23
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void FWTGLViewer::JustSwap ( )

Definition at line 98 of file FWTGLViewer.cc.

99 {
100  fGLWidget->SwapBuffers();
101 }
TGLFBO * FWTGLViewer::MakeFbo ( )

Definition at line 108 of file FWTGLViewer.cc.

References GenerateFbo().

Referenced by FWTEveViewer::CaptureAndSaveImage().

109 {
110  // Generate FBO with same dimensions as the viewport.
111 
112  return GenerateFbo(fViewport.Width(), fViewport.Height(), kFALSE);
113 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:155
TGLFBO * FWTGLViewer::MakeFboHeight ( Int_t  height,
Bool_t  pixel_object_scale = kTRUE 
)

Definition at line 129 of file FWTGLViewer.cc.

References GenerateFbo(), pileupReCalc_HLTpaths::scale, and create_public_lumi_plots::width.

Referenced by FWTEveViewer::CaptureAndSaveImage().

130 {
131  // Generate FBO with given height (width scaled proportinally).
132  // If pixel_object_scale is true (default), the corresponding
133  // scaling gets calculated from the current window size.
134 
135  Float_t scale = Float_t(height) / fViewport.Height();
136  Int_t width = TMath::Nint(scale*fViewport.Width());
137 
138  return GenerateFbo(width, height, pixel_object_scale ? scale : 0);
139 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:155
TGLFBO * FWTGLViewer::MakeFboScale ( Float_t  scale,
Bool_t  pixel_object_scale = kTRUE 
)

Definition at line 142 of file FWTGLViewer.cc.

References GenerateFbo(), h, and w.

143 {
144  // Generate FBO with given scale to current window size.
145  // If pixel_object_scale is true (default), the same scaling is
146  // used.
147 
148  Int_t w = TMath::Nint(scale*fViewport.Width());
149  Int_t h = TMath::Nint(scale*fViewport.Height());
150 
151  return GenerateFbo(w, h, pixel_object_scale ? scale : 0);
152 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:155
const double w
Definition: UKUtility.cc:23
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
TGLFBO * FWTGLViewer::MakeFboWidth ( Int_t  width,
Bool_t  pixel_object_scale = kTRUE 
)

Definition at line 116 of file FWTGLViewer.cc.

References GenerateFbo(), and pileupReCalc_HLTpaths::scale.

117 {
118  // Generate FBO with given width (height scaled proportinally).
119  // If pixel_object_scale is true (default), the corresponding
120  // scaling gets calculated from the current window size.
121 
122  Float_t scale = Float_t(width) / fViewport.Width();
123  Int_t height = TMath::Nint(scale*fViewport.Height());
124 
125  return GenerateFbo(width, height, pixel_object_scale ? scale : 0);
126 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:155
const FWTGLViewer& FWTGLViewer::operator= ( const FWTGLViewer )
private