CMS 3D CMS Logo

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

#include "FWTGLViewer.h"

Inheritance diagram for FWTGLViewer:

Public Member Functions

void DrawHiLod (Bool_t swap_buffers)
 
 FWTGLViewer (const TGWindow *parent)
 
 FWTGLViewer (const FWTGLViewer &)=delete
 
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)
 
const FWTGLVieweroperator= (const FWTGLViewer &)=delete
 
 ~FWTGLViewer () override
 

Private Attributes

TGLFBO * m_fbo
 
int m_fbo_h
 
int m_fbo_w
 

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 38 of file FWTGLViewer.cc.

39  : TGLEmbeddedViewer(parent, nullptr, nullptr, 0), m_fbo(nullptr), m_fbo_w(-1), m_fbo_h(-1) {}
TGLFBO * m_fbo
Definition: FWTGLViewer.h:60
FWTGLViewer::~FWTGLViewer ( )
override

Definition at line 46 of file FWTGLViewer.cc.

References m_fbo.

46 { delete m_fbo; }
TGLFBO * m_fbo
Definition: FWTGLViewer.h:60
FWTGLViewer::FWTGLViewer ( const FWTGLViewer )
delete

Member Function Documentation

void FWTGLViewer::DrawHiLod ( Bool_t  swap_buffers)

Definition at line 68 of file FWTGLViewer.cc.

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

Definition at line 140 of file FWTGLViewer.cc.

References h, m_fbo, m_fbo_h, m_fbo_w, and w.

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

140  {
141  // Generate FBO -- function that does the actual work.
142 
143  static const TString eh("FWTGLViewer::SavePictureUsingFBO");
144 
145  if (!GLEW_EXT_framebuffer_object) {
146  ::Warning(eh, "Missing FBO support.");
147  }
148 
149  if (!TakeLock(kDrawLock)) {
150  ::Error(eh, "viewer locked - try later.");
151  return nullptr;
152  }
153 
154  TUnlocker ulck(this);
155 
156  MakeCurrent();
157 
158  if (m_fbo == nullptr) {
159  m_fbo = new TGLFBO();
160  }
161  if (m_fbo_w != w || m_fbo_h != h) {
162  try {
163  m_fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
164  } catch (std::runtime_error& exc) {
165  m_fbo_w = m_fbo_h = -1;
166 
167  ::Error(eh, "%s", exc.what());
168  return nullptr;
169  }
170 
171  m_fbo_w = w;
172  m_fbo_h = h;
173  }
174 
175  TGLRect old_vp(fViewport);
176  SetViewport(0, 0, w, h);
177 
178  Float_t old_scale = 1;
179  if (pixel_object_scale != 0) {
180  old_scale = fRnrCtx->GetRenderScale();
181  fRnrCtx->SetRenderScale(old_scale * pixel_object_scale);
182  }
183 
184  m_fbo->Bind();
185 
186  fLOD = TGLRnrCtx::kLODHigh;
187  fRnrCtx->SetGrabImage(kTRUE);
188 
189  DoDraw(kFALSE);
190 
191  fRnrCtx->SetGrabImage(kFALSE);
192 
193  m_fbo->Unbind();
194 
195  if (pixel_object_scale != 0) {
196  fRnrCtx->SetRenderScale(old_scale);
197  }
198 
199  SetViewport(old_vp);
200 
201  return m_fbo;
202 }
edm::ErrorSummaryEntry Error
const double w
Definition: UKUtility.cc:23
TGLFBO * m_fbo
Definition: FWTGLViewer.h:60
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 90 of file FWTGLViewer.cc.

90 { fGLWidget->SwapBuffers(); }
TGLFBO * FWTGLViewer::MakeFbo ( )

Definition at line 97 of file FWTGLViewer.cc.

References GenerateFbo().

Referenced by FWTEveViewer::CaptureAndSaveImage().

97  {
98  // Generate FBO with same dimensions as the viewport.
99 
100  return GenerateFbo(fViewport.Width(), fViewport.Height(), kFALSE);
101 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:140
TGLFBO * FWTGLViewer::MakeFboHeight ( Int_t  height,
Bool_t  pixel_object_scale = kTRUE 
)

Definition at line 116 of file FWTGLViewer.cc.

References GenerateFbo(), and pileupReCalc_HLTpaths::scale.

Referenced by FWTEveViewer::CaptureAndSaveImage().

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

Definition at line 128 of file FWTGLViewer.cc.

References GenerateFbo(), h, and w.

128  {
129  // Generate FBO with given scale to current window size.
130  // If pixel_object_scale is true (default), the same scaling is
131  // used.
132 
133  Int_t w = TMath::Nint(scale * fViewport.Width());
134  Int_t h = TMath::Nint(scale * fViewport.Height());
135 
136  return GenerateFbo(w, h, pixel_object_scale ? scale : 0);
137 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:140
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 104 of file FWTGLViewer.cc.

References GenerateFbo(), and pileupReCalc_HLTpaths::scale.

104  {
105  // Generate FBO with given width (height scaled proportinally).
106  // If pixel_object_scale is true (default), the corresponding
107  // scaling gets calculated from the current window size.
108 
109  Float_t scale = Float_t(width) / fViewport.Width();
110  Int_t height = TMath::Nint(scale * fViewport.Height());
111 
112  return GenerateFbo(width, height, pixel_object_scale ? scale : 0);
113 }
TGLFBO * GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale)
Definition: FWTGLViewer.cc:140
const FWTGLViewer& FWTGLViewer::operator= ( const FWTGLViewer )
delete

Member Data Documentation

TGLFBO* FWTGLViewer::m_fbo
private

Definition at line 60 of file FWTGLViewer.h.

Referenced by GenerateFbo(), and ~FWTGLViewer().

int FWTGLViewer::m_fbo_h
private

Definition at line 61 of file FWTGLViewer.h.

Referenced by GenerateFbo().

int FWTGLViewer::m_fbo_w
private

Definition at line 61 of file FWTGLViewer.h.

Referenced by GenerateFbo().