ROOT  6.06/09
Reference Guide
TGLViewer.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Richard Maunder 25/05/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 "TGLViewer.h"
13 #include "TGLIncludes.h"
14 #include "TGLStopwatch.h"
15 #include "TGLRnrCtx.h"
16 #include "TGLSelectBuffer.h"
17 #include "TGLLightSet.h"
18 #include "TGLManipSet.h"
19 #include "TGLCameraOverlay.h"
20 #include "TGLAutoRotator.h"
21 
22 #include "TGLScenePad.h"
23 #include "TGLLogicalShape.h"
24 #include "TGLPhysicalShape.h"
25 #include "TGLObject.h"
26 #include "TGLStopwatch.h"
27 #include "TBuffer3D.h"
28 #include "TBuffer3DTypes.h"
29 
30 #include "TGLOutput.h"
31 
32 #include "TROOT.h"
33 #include "TVirtualMutex.h"
34 
35 #include "TVirtualPad.h" // Remove when pad removed - use signal
36 #include "TVirtualX.h"
37 
38 #include "TMath.h"
39 #include "TColor.h"
40 #include "TError.h"
41 #include "TClass.h"
42 #include "TROOT.h"
43 #include "TEnv.h"
44 
45 // For event type translation ExecuteEvent
46 #include "Buttons.h"
47 #include "GuiTypes.h"
48 
49 #include "TVirtualGL.h"
50 
51 #include "TGLWidget.h"
52 #include "TGLFBO.h"
53 #include "TGLViewerEditor.h"
54 #include "TGedEditor.h"
55 #include "TGLPShapeObj.h"
56 
57 #include "KeySymbols.h"
58 #include "TContextMenu.h"
59 #include "TImage.h"
60 
61 #include <stdexcept>
62 
63 #ifndef GL_BGRA
64 #define GL_BGRA GL_BGRA_EXT
65 #endif
66 
67 /** \class TGLViewer
68 \ingroup opengl
69 Base GL viewer object - used by both standalone and embedded (in pad)
70 GL. Contains core viewer objects :
71 
72 GL scene - collection of main drawn objects - see TGLStdScene
73 Cameras (fXyzzCamera) - ortho and perspective cameras - see TGLCamera
74 Clipping (fClipXyzz) - collection of clip objects - see TGLClip
75 Manipulators (fXyzzManip) - collection of manipulators - see TGLManip
76 
77 It maintains the current active draw styles, clipping object,
78 manipulator, camera etc.
79 
80 TGLViewer is 'GUI free' in that it does not derive from any ROOT GUI
81 TGFrame etc - see TGLSAViewer for this. However it contains GUI
82 GUI style methods HandleButton() etc to which GUI events can be
83 directed from standalone frame or embedding pad to perform
84 interaction.
85 
86 Also, the TGLWidget needs to be created externally. It is not owned
87 by the viewer.
88 
89 For embedded (pad) GL this viewer is created directly by plugin
90 manager. For standalone the derived TGLSAViewer is.
91 */
92 
94 
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 
101  Int_t width, Int_t height) :
102  fPad(pad),
103  fContextMenu(0),
104  fPerspectiveCameraXOZ(TGLVector3(-1.0, 0.0, 0.0), TGLVector3(0.0, 1.0, 0.0)), // XOZ floor
105  fPerspectiveCameraYOZ(TGLVector3( 0.0,-1.0, 0.0), TGLVector3(1.0, 0.0, 0.0)), // YOZ floor
106  fPerspectiveCameraXOY(TGLVector3(-1.0, 0.0, 0.0), TGLVector3(0.0, 0.0, 1.0)), // XOY floor
107  fOrthoXOYCamera (TGLOrthoCamera::kXOY, TGLVector3( 0.0, 0.0, 1.0), TGLVector3(0.0, 1.0, 0.0)), // Looking down Z axis, X horz, Y vert
108  fOrthoXOZCamera (TGLOrthoCamera::kXOZ, TGLVector3( 0.0,-1.0, 0.0), TGLVector3(0.0, 0.0, 1.0)), // Looking along Y axis, X horz, Z vert
109  fOrthoZOYCamera (TGLOrthoCamera::kZOY, TGLVector3(-1.0, 0.0, 0.0), TGLVector3(0.0, 1.0, 0.0)), // Looking along X axis, Z horz, Y vert
110  fOrthoXnOYCamera(TGLOrthoCamera::kXnOY, TGLVector3( 0.0, 0.0,-1.0), TGLVector3(0.0, 1.0, 0.0)), // Looking along Z axis, -X horz, Y vert
111  fOrthoXnOZCamera(TGLOrthoCamera::kXnOZ, TGLVector3( 0.0, 1.0, 0.0), TGLVector3(0.0, 0.0, 1.0)), // Looking down Y axis, -X horz, Z vert
112  fOrthoZnOYCamera(TGLOrthoCamera::kZnOY, TGLVector3( 1.0, 0.0, 0.0), TGLVector3(0.0, 1.0, 0.0)), // Looking down X axis, -Z horz, Y vert
113  fCurrentCamera(&fPerspectiveCameraXOZ),
114  fAutoRotator(0),
115 
116  fStereo (kFALSE),
117  fStereoQuadBuf (kFALSE),
118  fStereoZeroParallax (0.03f),
119  fStereoEyeOffsetFac (1.0f),
120  fStereoFrustumAsymFac (1.0f),
121 
122  fLightSet (0),
123  fClipSet (0),
124  fSelectedPShapeRef (0),
125  fCurrentOvlElm (0),
126 
127  fEventHandler(0),
128  fGedEditor(0),
129  fPShapeWrap(0),
130  fPushAction(kPushStd), fDragAction(kDragNone),
131  fRedrawTimer(0),
132  fMaxSceneDrawTimeHQ(5000),
133  fMaxSceneDrawTimeLQ(100),
134  fPointScale (1), fLineScale(1), fSmoothPoints(kFALSE), fSmoothLines(kFALSE),
135  fAxesType(TGLUtil::kAxesNone),
136  fAxesDepthTest(kTRUE),
137  fReferenceOn(kFALSE),
138  fReferencePos(0.0, 0.0, 0.0),
139  fDrawCameraCenter(kFALSE),
140  fCameraOverlay(0),
141  fSmartRefresh(kFALSE),
142  fDebugMode(kFALSE),
143  fIsPrinting(kFALSE),
144  fPictureFileName("viewer.jpg"),
145  fFader(0),
146  fGLWidget(0),
147  fGLDevice(-1),
148  fGLCtxId(0),
149  fIgnoreSizesOnUpdate(kFALSE),
150  fResetCamerasOnUpdate(kTRUE),
151  fResetCamerasOnNextUpdate(kFALSE)
152 {
153  // Construct the viewer object, with following arguments:
154  // 'pad' - external pad viewer is bound to
155  // 'x', 'y' - initial top left position
156  // 'width', 'height' - initial width/height
157 
159 
160  SetViewport(x, y, width, height);
161 }
162 
163 ////////////////////////////////////////////////////////////////////////////////
164 
166  fPad(pad),
167  fContextMenu(0),
168  fPerspectiveCameraXOZ(TGLVector3(-1.0, 0.0, 0.0), TGLVector3(0.0, 1.0, 0.0)), // XOZ floor
169  fPerspectiveCameraYOZ(TGLVector3( 0.0,-1.0, 0.0), TGLVector3(1.0, 0.0, 0.0)), // YOZ floor
170  fPerspectiveCameraXOY(TGLVector3(-1.0, 0.0, 0.0), TGLVector3(0.0, 0.0, 1.0)), // XOY floor
171  fOrthoXOYCamera (TGLOrthoCamera::kXOY, TGLVector3( 0.0, 0.0, 1.0), TGLVector3(0.0, 1.0, 0.0)), // Looking down Z axis, X horz, Y vert
172  fOrthoXOZCamera (TGLOrthoCamera::kXOZ, TGLVector3( 0.0,-1.0, 0.0), TGLVector3(0.0, 0.0, 1.0)), // Looking along Y axis, X horz, Z vert
173  fOrthoZOYCamera (TGLOrthoCamera::kZOY, TGLVector3(-1.0, 0.0, 0.0), TGLVector3(0.0, 1.0, 0.0)), // Looking along X axis, Z horz, Y vert
174  fOrthoXnOYCamera(TGLOrthoCamera::kXnOY, TGLVector3( 0.0, 0.0,-1.0), TGLVector3(0.0, 1.0, 0.0)), // Looking along Z axis, -X horz, Y vert
175  fOrthoXnOZCamera(TGLOrthoCamera::kXnOZ, TGLVector3( 0.0, 1.0, 0.0), TGLVector3(0.0, 0.0, 1.0)), // Looking down Y axis, -X horz, Z vert
176  fOrthoZnOYCamera(TGLOrthoCamera::kZnOY, TGLVector3( 1.0, 0.0, 0.0), TGLVector3(0.0, 1.0, 0.0)), // Looking down X axis, -Z horz, Y vert
177  fCurrentCamera(&fPerspectiveCameraXOZ),
178  fAutoRotator(0),
179 
180  fStereo (kFALSE),
181  fStereoQuadBuf (kFALSE),
182  fStereoZeroParallax (0.03f),
183  fStereoEyeOffsetFac (1.0f),
184  fStereoFrustumAsymFac (1.0f),
185 
186  fLightSet (0),
187  fClipSet (0),
188  fSelectedPShapeRef (0),
189  fCurrentOvlElm (0),
190 
191  fEventHandler(0),
192  fGedEditor(0),
193  fPShapeWrap(0),
194  fPushAction(kPushStd), fDragAction(kDragNone),
195  fRedrawTimer(0),
196  fMaxSceneDrawTimeHQ(5000),
197  fMaxSceneDrawTimeLQ(100),
198  fPointScale (1), fLineScale(1), fSmoothPoints(kFALSE), fSmoothLines(kFALSE),
199  fAxesType(TGLUtil::kAxesNone),
200  fAxesDepthTest(kTRUE),
201  fReferenceOn(kFALSE),
202  fReferencePos(0.0, 0.0, 0.0),
203  fDrawCameraCenter(kFALSE),
204  fCameraOverlay(0),
205  fSmartRefresh(kFALSE),
206  fDebugMode(kFALSE),
207  fIsPrinting(kFALSE),
208  fPictureFileName("viewer.jpg"),
209  fFader(0),
210  fGLWidget(0),
211  fGLDevice(fPad->GetGLDevice()),
212  fGLCtxId(0),
213  fIgnoreSizesOnUpdate(kFALSE),
214  fResetCamerasOnUpdate(kTRUE),
215  fResetCamerasOnNextUpdate(kFALSE)
216 {
217  //gl-embedded viewer's ctor
218  // Construct the viewer object, with following arguments:
219  // 'pad' - external pad viewer is bound to
220  // 'x', 'y' - initial top left position
221  // 'width', 'height' - initial width/height
222 
224 
225  if (fGLDevice != -1) {
226  // For the moment instantiate a fake context identity.
228  fGLCtxId->AddRef(0);
229  Int_t viewport[4] = {0};
230  gGLManager->ExtractViewport(fGLDevice, viewport);
231  SetViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
232  }
233 }
234 
235 ////////////////////////////////////////////////////////////////////////////////
236 /// Common initialization.
237 
239 {
240  fLightSet = new TGLLightSet;
241  fClipSet = new TGLClipSet;
243 
247 
248  fPShapeWrap = new TGLPShapeObj(0, this);
249 
253  } else {
254  if (fPad) {
258  } else {
260  }
261  }
262 
265 
266  fRedrawTimer = new TGLRedrawTimer(*this);
267 }
268 
269 ////////////////////////////////////////////////////////////////////////////////
270 /// Destroy viewer object.
271 
273 {
274  delete fAutoRotator;
275 
276  delete fLightSet;
277  // fClipSet, fSelectedPShapeRef and fCameraOverlay deleted via overlay.
278 
279  delete fContextMenu;
280  delete fRedrawTimer;
281 
282  if (fEventHandler) {
283  if (fGLWidget)
285  delete fEventHandler;
286  }
287 
288  if (fPad)
290  if (fGLDevice != -1)
291  fGLCtxId->Release(0);
292 }
293 
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 /// Entry point for updating viewer contents via VirtualViewer3D
297 /// interface.
298 /// We search and forward the request to appropriate TGLScenePad.
299 /// If it is not found we create a new TGLScenePad so this can
300 /// potentially also be used for registration of new pads.
301 
303 {
304  TGLScenePad* scenepad = 0;
305  for (SceneInfoList_i si = fScenes.begin(); si != fScenes.end(); ++si)
306  {
307  scenepad = dynamic_cast<TGLScenePad*>((*si)->GetScene());
308  if (scenepad && scenepad->GetPad() == pad)
309  break;
310  scenepad = 0;
311  }
312  if (scenepad == 0)
313  {
314  scenepad = new TGLScenePad(pad);
315  AddScene(scenepad);
316  }
317 
318  scenepad->PadPaintFromViewer(this);
319 
322 
323  RequestDraw();
324 }
325 
326 
327 /**************************************************************************/
328 /**************************************************************************/
329 
330 ////////////////////////////////////////////////////////////////////////////////
331 /// Force update of pad-scenes. Eventually this could be generalized
332 /// to all scene-types via a virtual function in TGLSceneBase.
333 
335 {
336  // Cancel any pending redraw timer.
337  fRedrawTimer->Stop();
338 
339  for (SceneInfoList_i si = fScenes.begin(); si != fScenes.end(); ++si)
340  {
341  TGLScenePad* scenepad = dynamic_cast<TGLScenePad*>((*si)->GetScene());
342  if (scenepad)
343  scenepad->PadPaintFromViewer(this);
344  }
345 
348 
349  if (redraw)
350  RequestDraw();
351 }
352 
353 ////////////////////////////////////////////////////////////////////////////////
354 /// Resets position/rotation of current camera to default values.
355 
357 {
360 }
361 
362 ////////////////////////////////////////////////////////////////////////////////
363 /// Setup cameras for current bounding box.
364 
366 {
367  if (IsLocked()) {
368  Error("TGLViewer::SetupCameras", "expected kUnlocked, found %s", LockName(CurrentLock()));
369  return;
370  }
371 
372  // Setup cameras if scene box is not empty
374  if (!box.IsEmpty()) {
375  fPerspectiveCameraYOZ.Setup(box, reset);
376  fPerspectiveCameraXOZ.Setup(box, reset);
377  fPerspectiveCameraXOY.Setup(box, reset);
378  fOrthoXOYCamera.Setup(box, reset);
379  fOrthoXOZCamera.Setup(box, reset);
380  fOrthoZOYCamera.Setup(box, reset);
381  fOrthoXnOYCamera.Setup(box, reset);
382  fOrthoXnOZCamera.Setup(box, reset);
383  fOrthoZnOYCamera.Setup(box, reset);
384  }
385 }
386 
387 ////////////////////////////////////////////////////////////////////////////////
388 /// Perform post scene-build setup.
389 
391 {
393  SetupCameras(resetCameras);
394 
395  // Set default reference to center
397  RefreshPadEditor(this);
398 }
399 
400 
401 /**************************************************************************/
402 /**************************************************************************/
403 
404 ////////////////////////////////////////////////////////////////////////////////
405 /// Initialise GL state.
406 
408 {
409  glEnable(GL_LIGHTING);
410  glEnable(GL_DEPTH_TEST);
411  glEnable(GL_CULL_FACE);
412  glCullFace(GL_BACK);
413  glClearColor(0.f, 0.f, 0.f, 0.f);
414  glClearDepth(1.0);
415  glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
416  glEnable(GL_COLOR_MATERIAL);
417  glMaterialf(GL_BACK, GL_SHININESS, 0.0);
418  glPolygonMode(GL_FRONT, GL_FILL);
419  glDisable(GL_BLEND);
420 
421  glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
422  Float_t lmodelAmb[] = {0.5f, 0.5f, 1.f, 1.f};
423  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodelAmb);
424  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
425 
426  glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
427  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
428 
429  TGLUtil::CheckError("TGLViewer::InitGL");
430 }
431 
432 ////////////////////////////////////////////////////////////////////////////////
433 /// Post request for redraw of viewer at level of detail 'LOD'
434 /// Request is directed via cross thread gVirtualGL object.
435 
437 {
438  fRedrawTimer->Stop();
439  // Ignore request if GL window or context not yet available or shown.
440  if ((!fGLWidget && fGLDevice == -1) || (fGLWidget && !fGLWidget->IsMapped()))
441  {
442  return;
443  }
444 
445  // Take scene draw lock - to be revisited
446  if ( ! TakeLock(kDrawLock)) {
447  // If taking drawlock fails the previous draw is still in progress
448  // set timer to do this one later
449  if (gDebug>3) {
450  Info("TGLViewer::RequestDraw", "viewer locked - requesting another draw.");
451  }
452  fRedrawTimer->RequestDraw(100, LODInput);
453  return;
454  }
455  fLOD = LODInput;
456 
457  if (!gVirtualX->IsCmdThread())
458  gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoDraw()", (ULong_t)this));
459  else
460  DoDraw();
461 }
462 
463 ////////////////////////////////////////////////////////////////////////////////
464 /// Setup clip-object. Protected virtual method.
465 
467 {
468  if (GetClipAutoUpdate())
469  {
471  }
472  else
473  {
475  }
476 }
477 ////////////////////////////////////////////////////////////////////////////////
478 /// Initialize objects that influence rendering.
479 /// Called before every render.
480 
482 {
485  if (fGLDevice != -1)
486  {
489  }
490 
493 
494  if (fSmoothPoints) glEnable(GL_POINT_SMOOTH); else glDisable(GL_POINT_SMOOTH);
495  if (fSmoothLines) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
497  {
498  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
499  glEnable(GL_BLEND);
500  }
501  else
502  {
503  glDisable(GL_BLEND);
504  }
505 
507 
508  // Setup lighting
510 }
511 
512 ////////////////////////////////////////////////////////////////////////////////
513 /// Normal rendering, used by mono and stereo rendering.
514 
516 {
518 
519  DrawGuides();
521 
522  if ( ! fRnrCtx->Selection())
523  {
525  }
526 
527  glClear(GL_DEPTH_BUFFER_BIT);
528  DrawDebugInfo();
529 }
530 
531 ////////////////////////////////////////////////////////////////////////////////
532 /// Restore state set in PreRender().
533 /// Called after every render.
534 
536 {
538 
541 }
542 
543 ////////////////////////////////////////////////////////////////////////////////
544 /// Draw out the viewer.
545 
546 void TGLViewer::DoDraw(Bool_t swap_buffers)
547 {
548  // Locking mainly for Win32 multi thread safety - but no harm in all using it
549  // During normal draws a draw lock is taken in other thread (Win32) in RequestDraw()
550  // to ensure thread safety. For PrintObjects repeated Draw() calls are made.
551  // If no draw lock taken get one now.
552 
554 
555  fRedrawTimer->Stop();
556 
557  if (CurrentLock() != kDrawLock) {
558  if ( ! TakeLock(kDrawLock)) {
559  Error("TGLViewer::DoDraw", "viewer is %s", LockName(CurrentLock()));
560  return;
561  }
562  }
563 
564  TUnlocker ulck(this);
565 
566  if (fGLDevice == -1 && (fViewport.Width() <= 1 || fViewport.Height() <= 1)) {
567  if (gDebug > 2) {
568  Info("TGLViewer::DoDraw()", "zero surface area, draw skipped.");
569  }
570  return;
571  }
572 
573  if (fGLDevice != -1) {
574  Int_t viewport[4] = {};
575  gGLManager->ExtractViewport(fGLDevice, viewport);
576  SetViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
577  }
578 
580  if (gDebug>2) {
581  timer.Start();
582  }
583 
584  // Setup scene draw time
588 
590  !fIsPrinting)
591  {
592  DoDrawStereo(swap_buffers);
593  }
594  else
595  {
596  DoDrawMono(swap_buffers);
597  }
598 
600 
601  if (gDebug>2) {
602  Info("TGLViewer::DoDraw()", "Took %f msec", timer.End());
603  }
604 
605  // Check if further redraws are needed and schedule them.
606 
608  // Reset major view-dependant cache.
609  ResetSceneInfos();
611  }
612 
613  if (fLOD != TGLRnrCtx::kLODHigh &&
614  (fDragAction < kDragCameraRotate || fDragAction > kDragCameraDolly))
615  {
616  // Request final draw pass.
618  }
619 }
620 
621 ////////////////////////////////////////////////////////////////////////////////
622 /// Draw out in monoscopic mode.
623 
624 void TGLViewer::DoDrawMono(Bool_t swap_buffers)
625 {
626  MakeCurrent();
627 
628  if (!fIsPrinting) PreDraw();
629  PreRender();
630 
632  if (fFader < 1)
633  {
634  Render();
635  }
637 
638  PostRender();
639 
640  if (fFader > 0)
641  {
642  FadeView(fFader);
643  }
644 
645  PostDraw();
646 
647  if (swap_buffers)
648  {
649  SwapBuffers();
650  }
651 }
652 
653 ////////////////////////////////////////////////////////////////////////////////
654 /// Draw out in stereoscopic mode.
655 
656 void TGLViewer::DoDrawStereo(Bool_t swap_buffers)
657 {
659 
660  Float_t gl_near, gl_far, zero_p_dist;
661  Float_t h_half, w_half;
662  Float_t x_len_at_zero_parallax;
663  Float_t stereo_offset;
664  Float_t frustum_asym;
665 
666  MakeCurrent();
667 
668  // Draw left
669  if (fStereoQuadBuf)
670  {
671  glDrawBuffer(GL_BACK_LEFT);
672  }
673  else
674  {
675  glScissor(0, 0, fViewport.Width(), fViewport.Height());
676  glEnable(GL_SCISSOR_TEST);
677  }
678  PreDraw();
679  PreRender();
680 
681  gl_near = c.GetNearClip();
682  gl_far = c.GetFarClip();
683  zero_p_dist = gl_near + fStereoZeroParallax*(gl_far-gl_near);
684 
685  h_half = TMath::Tan(0.5*TMath::DegToRad()*c.GetFOV()) * gl_near;
686  w_half = h_half * fViewport.Aspect();
687 
688  x_len_at_zero_parallax = 2.0f * w_half * zero_p_dist / gl_near;
689  stereo_offset = 0.035f * x_len_at_zero_parallax * fStereoEyeOffsetFac;
690 
691  frustum_asym = stereo_offset * gl_near / zero_p_dist * fStereoFrustumAsymFac;
692 
693  TGLMatrix abs_trans(c.RefCamBase());
694  abs_trans *= c.RefCamTrans();
695  TGLVector3 left_vec = abs_trans.GetBaseVec(2);
696 
697  glTranslatef(stereo_offset*left_vec[0], stereo_offset*left_vec[1], stereo_offset*left_vec[2]);
698 
699  glMatrixMode(GL_PROJECTION);
700  glLoadIdentity();
701  glFrustum(-w_half + frustum_asym, w_half + frustum_asym,
702  -h_half, h_half, gl_near, gl_far);
703  glMatrixMode(GL_MODELVIEW);
704 
706  if (fFader < 1)
707  {
708  Render();
709  }
711 
712  PostRender();
713 
714  if (fFader > 0)
715  {
716  FadeView(fFader);
717  }
718  PostDraw();
719 
720  // Draw right
721  if (fStereoQuadBuf)
722  {
723  glDrawBuffer(GL_BACK_RIGHT);
724  }
725  else
726  {
727  glScissor(fViewport.Width(), 0, fViewport.Width(), fViewport.Height());
728  }
729  PreDraw();
730  PreRender();
731  if ( ! fStereoQuadBuf)
732  {
733  glViewport(fViewport.Width(), 0, fViewport.Width(), fViewport.Height());
734  }
735 
736  glTranslatef(-stereo_offset*left_vec[0], -stereo_offset*left_vec[1], -stereo_offset*left_vec[2]);
737 
738  glMatrixMode(GL_PROJECTION);
739  glLoadIdentity();
740  glFrustum(-w_half - frustum_asym, w_half - frustum_asym,
741  -h_half, h_half, gl_near, gl_far);
742  glMatrixMode(GL_MODELVIEW);
743 
745  if (fFader < 1)
746  {
747  Render();
748  }
750 
751  PostRender();
752 
753  if (fFader > 0)
754  {
755  FadeView(fFader);
756  }
757  PostDraw();
758 
759  // End
760  if (swap_buffers)
761  {
762  SwapBuffers();
763  }
764 
765  if (fStereoQuadBuf)
766  {
767  glDrawBuffer(GL_BACK);
768  }
769  else
770  {
771  glDisable(GL_SCISSOR_TEST);
772  glViewport(0, 0, fViewport.Width(), fViewport.Height());
773  }
774 }
775 
776 ////////////////////////////////////////////////////////////////////////////////
777 /// Save current image using the default file name which can be set
778 /// via SetPictureFileName() and defaults to "viewer.jpg".
779 /// Really useful for the files ending with 'gif+'.
780 
782 {
784 }
785 
786 ////////////////////////////////////////////////////////////////////////////////
787 /// Save current image in various formats (gif, gif+, jpg, png, eps, pdf).
788 /// 'gif+' will append image to an existing file (animated gif).
789 /// 'eps' and 'pdf' do not fully support transparency and texturing.
790 /// The viewer window most be fully contained within the desktop but
791 /// can be covered by other windows.
792 /// Returns false if something obvious goes wrong, true otherwise.
793 ///
794 /// The mage is saved using a frame-buffer object if the GL implementation
795 /// claims to support it -- this claim is not always true, especially when
796 /// running over ssh with drastically different GL implementations on the
797 /// client and server sides. Set this in .rootrc to enforce creation of
798 /// pictures using the back-buffer:
799 /// OpenGL.SavePicturesViaFBO: off
800 
802 {
803  if (fileName.EndsWith(".eps"))
804  {
805  return TGLOutput::Capture(*this, TGLOutput::kEPS_BSP, fileName.Data());
806  }
807  else if (fileName.EndsWith(".pdf"))
808  {
809  return TGLOutput::Capture(*this, TGLOutput::kPDF_BSP, fileName.Data());
810  }
811  else
812  {
813  if (GLEW_EXT_framebuffer_object && gEnv->GetValue("OpenGL.SavePicturesViaFBO", 1))
814  {
815  return SavePictureUsingFBO(fileName, fViewport.Width(), fViewport.Height(), kFALSE);
816  }
817  else
818  {
819  return SavePictureUsingBB(fileName);
820  }
821  }
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Save current image in various formats (gif, gif+, jpg, png).
826 /// 'gif+' will append image to an existing file (animated gif).
827 /// Back-Buffer is used for capturing of the image.
828 /// The viewer window most be fully contained within the desktop but
829 /// can be covered by other windows.
830 /// Returns false if something obvious goes wrong, true otherwise.
831 
833 {
834  static const TString eh("TGLViewer::SavePictureUsingBB");
835 
836  if (! fileName.EndsWith(".gif") && ! fileName.Contains(".gif+") &&
837  ! fileName.EndsWith(".jpg") && ! fileName.EndsWith(".png"))
838  {
839  Warning(eh, "file %s cannot be saved with this extension.", fileName.Data());
840  return kFALSE;
841  }
842 
843  if ( ! TakeLock(kDrawLock)) {
844  Error(eh, "viewer locked - try later.");
845  return kFALSE;
846  }
847 
848  TUnlocker ulck(this);
849 
852 
853  if (!gVirtualX->IsCmdThread())
854  gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoDraw(kFALSE)", (ULong_t)this));
855  else
856  DoDraw(kFALSE);
857 
859 
860  glReadBuffer(GL_BACK);
861 
862  UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
863  glPixelStorei(GL_PACK_ALIGNMENT, 1);
864  glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
865  GL_BGRA, GL_UNSIGNED_BYTE, xx);
866 
867  std::auto_ptr<TImage> image(TImage::Create());
868  image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
869  image->WriteImage(fileName);
870 
871  delete [] xx;
872 
873  return kTRUE;
874 }
875 
876 ////////////////////////////////////////////////////////////////////////////////
877 /// Save current image in various formats (gif, gif+, jpg, png).
878 /// 'gif+' will append image to an existing file (animated gif).
879 /// Frame-Buffer-Object is used for capturing of the image - OpenGL
880 /// 1.5 is required.
881 /// The viewer window does not have to be visible at all.
882 /// Returns false if something obvious goes wrong, true otherwise.
883 ///
884 /// pixel_object_scale is used to scale (as much as possible) the
885 /// objects whose representation size is pixel based (point-sizes,
886 /// line-widths, bitmap/pixmap font-sizes).
887 /// If set to 0 (default) no scaling is applied.
888 
890  Float_t pixel_object_scale)
891 {
892  static const TString eh("TGLViewer::SavePictureUsingFBO");
893 
894  if (! fileName.EndsWith(".gif") && ! fileName.Contains(".gif+") &&
895  ! fileName.EndsWith(".jpg") && ! fileName.EndsWith(".png"))
896  {
897  Warning(eh, "file %s cannot be saved with this extension.", fileName.Data());
898  return kFALSE;
899  }
900 
901  if ( ! TakeLock(kDrawLock)) {
902  Error(eh, "viewer locked - try later.");
903  return kFALSE;
904  }
905 
906  TUnlocker ulck(this);
907 
908  MakeCurrent();
909 
910  TGLFBO *fbo = new TGLFBO();
911  try
912  {
913  fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
914  }
915  catch (std::runtime_error& exc)
916  {
917  Error(eh, "%s",exc.what());
918  if (gEnv->GetValue("OpenGL.SavePictureFallbackToBB", 1)) {
919  Info(eh, "Falling back to saving image via back-buffer. Window must be fully visible.");
920  if (w != fViewport.Width() || h != fViewport.Height())
921  Warning(eh, "Back-buffer does not support image scaling, window size will be used.");
922  return SavePictureUsingBB(fileName);
923  } else {
924  return kFALSE;
925  }
926  }
927 
928  TGLRect old_vp(fViewport);
929  SetViewport(0, 0, w, h);
930 
931  Float_t old_scale = 1;
932  if (pixel_object_scale != 0)
933  {
934  old_scale = fRnrCtx->GetRenderScale();
935  fRnrCtx->SetRenderScale(old_scale * pixel_object_scale);
936  }
937 
938  fbo->Bind();
939 
942 
943  if (!gVirtualX->IsCmdThread())
944  gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoDraw(kFALSE)", (ULong_t)this));
945  else
946  DoDraw(kFALSE);
947 
949 
950  fbo->Unbind();
951 
952  fbo->SetAsReadBuffer();
953 
954  UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
955  glPixelStorei(GL_PACK_ALIGNMENT, 1);
956  glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
957  GL_BGRA, GL_UNSIGNED_BYTE, xx);
958 
959  std::auto_ptr<TImage> image(TImage::Create());
960  image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
961  image->WriteImage(fileName);
962 
963  delete [] xx;
964 
965  delete fbo;
966 
967  if (pixel_object_scale != 0)
968  {
969  fRnrCtx->SetRenderScale(old_scale);
970  }
971 
972  SetViewport(old_vp);
973 
974  return kTRUE;
975 }
976 
977 ////////////////////////////////////////////////////////////////////////////////
978 /// Returns current image.
979 /// Back-Buffer is used for capturing of the image.
980 /// The viewer window most be fully contained within the desktop but
981 /// can be covered by other windows.
982 
984 {
985  static const TString eh("TGLViewer::GetPictureUsingBB");
986 
987  if ( ! TakeLock(kDrawLock)) {
988  Error(eh, "viewer locked - try later.");
989  return NULL;
990  }
991 
992  TUnlocker ulck(this);
993 
996 
997  if (!gVirtualX->IsCmdThread())
998  gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoDraw(kFALSE)", (ULong_t)this));
999  else
1000  DoDraw(kFALSE);
1001 
1003 
1004  glReadBuffer(GL_BACK);
1005 
1006  UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
1007  glPixelStorei(GL_PACK_ALIGNMENT, 1);
1008  glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
1009  GL_BGRA, GL_UNSIGNED_BYTE, xx);
1010 
1012  image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
1013 
1014  delete [] xx;
1015 
1016  return image;
1017 }
1018 
1019 ////////////////////////////////////////////////////////////////////////////////
1020 /// Returns current image.
1021 /// Frame-Buffer-Object is used for capturing of the image - OpenGL
1022 /// 1.5 is required.
1023 /// The viewer window does not have to be visible at all.
1024 ///
1025 /// pixel_object_scale is used to scale (as much as possible) the
1026 /// objects whose representation size is pixel based (point-sizes,
1027 /// line-widths, bitmap/pixmap font-sizes).
1028 /// If set to 0 (default) no scaling is applied.
1029 
1031 {
1032  static const TString eh("TGLViewer::GetPictureUsingFBO");
1033 
1034  if ( ! TakeLock(kDrawLock)) {
1035  Error(eh, "viewer locked - try later.");
1036  return NULL;
1037  }
1038 
1039  TUnlocker ulck(this);
1040 
1041  MakeCurrent();
1042 
1043  TGLFBO *fbo = new TGLFBO();
1044  try
1045  {
1046  fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
1047  }
1048  catch (std::runtime_error& exc)
1049  {
1050  Error(eh, "%s",exc.what());
1051  if (gEnv->GetValue("OpenGL.GetPictureFallbackToBB", 1)) {
1052  Info(eh, "Falling back to saving image via back-buffer. Window must be fully visible.");
1053  if (w != fViewport.Width() || h != fViewport.Height())
1054  Warning(eh, "Back-buffer does not support image scaling, window size will be used.");
1055  return GetPictureUsingBB();
1056  } else {
1057  return NULL;
1058  }
1059  }
1060 
1061  TGLRect old_vp(fViewport);
1062  SetViewport(0, 0, w, h);
1063 
1064  Float_t old_scale = 1;
1065  if (pixel_object_scale != 0)
1066  {
1067  old_scale = fRnrCtx->GetRenderScale();
1068  fRnrCtx->SetRenderScale(old_scale * pixel_object_scale);
1069  }
1070 
1071  fbo->Bind();
1072 
1075 
1076  if (!gVirtualX->IsCmdThread())
1077  gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoDraw(kFALSE)", (ULong_t)this));
1078  else
1079  DoDraw(kFALSE);
1080 
1082 
1083  fbo->Unbind();
1084 
1085  fbo->SetAsReadBuffer();
1086 
1087  UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
1088  glPixelStorei(GL_PACK_ALIGNMENT, 1);
1089  glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
1090  GL_BGRA, GL_UNSIGNED_BYTE, xx);
1091 
1093  image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
1094 
1095  delete [] xx;
1096  delete fbo;
1097 
1098  return image;
1099 }
1100 
1101 
1102 ////////////////////////////////////////////////////////////////////////////////
1103 /// Save picture with given width (height scaled proportionally).
1104 /// If pixel_object_scale is true (default), the corresponding
1105 /// scaling gets calculated from the current window size.
1106 
1108  Bool_t pixel_object_scale)
1109 {
1110  Float_t scale = Float_t(width) / fViewport.Width();
1111  Int_t height = TMath::Nint(scale*fViewport.Height());
1112 
1113  return SavePictureUsingFBO(fileName, width, height, pixel_object_scale ? scale : 0);
1114 }
1115 
1116 ////////////////////////////////////////////////////////////////////////////////
1117 /// Save picture with given height (width scaled proportionally).
1118 /// If pixel_object_scale is true (default), the corresponding
1119 /// scaling gets calculated from the current window size.
1120 
1122  Bool_t pixel_object_scale)
1123 {
1124  Float_t scale = Float_t(height) / fViewport.Height();
1125  Int_t width = TMath::Nint(scale*fViewport.Width());
1126 
1127  return SavePictureUsingFBO(fileName, width, height, pixel_object_scale ? scale : 0);
1128 }
1129 
1130 ////////////////////////////////////////////////////////////////////////////////
1131 /// Save picture with given scale to current window size.
1132 /// If pixel_object_scale is true (default), the same scaling is
1133 /// used.
1134 
1136  Bool_t pixel_object_scale)
1137 {
1138  Int_t w = TMath::Nint(scale*fViewport.Width());
1139  Int_t h = TMath::Nint(scale*fViewport.Height());
1140 
1141  return SavePictureUsingFBO(fileName, w, h, pixel_object_scale ? scale : 0);
1142 }
1143 
1144 ////////////////////////////////////////////////////////////////////////////////
1145 /// Draw reference marker and coordinate axes.
1146 
1148 {
1149  Bool_t disabled = kFALSE;
1150  if (fReferenceOn)
1151  {
1152  glDisable(GL_DEPTH_TEST);
1154  disabled = kTRUE;
1155  }
1156  if (fDrawCameraCenter)
1157  {
1158  glDisable(GL_DEPTH_TEST);
1160  const UChar_t rgba[4] = { 0, 255, 255, 255 };
1161  TGLUtil::DrawSphere(fCamera->GetCenterVec(), radius, rgba);
1162  disabled = kTRUE;
1163  }
1164  if (fAxesDepthTest && disabled)
1165  {
1166  glEnable(GL_DEPTH_TEST);
1167  disabled = kFALSE;
1168  }
1169  else if (fAxesDepthTest == kFALSE && disabled == kFALSE)
1170  {
1171  glDisable(GL_DEPTH_TEST);
1172  disabled = kTRUE;
1173  }
1175  if (disabled)
1176  glEnable(GL_DEPTH_TEST);
1177 }
1178 
1179 ////////////////////////////////////////////////////////////////////////////////
1180 /// If in debug mode draw camera aids and overall bounding box.
1181 
1183 {
1184  if (fDebugMode)
1185  {
1186  glDisable(GL_LIGHTING);
1188 
1189  // Green scene bounding box
1190  glColor3d(0.0, 1.0, 0.0);
1192 
1193  // Scene bounding box center sphere (green) and
1194  glDisable(GL_DEPTH_TEST);
1195  Double_t size = fOverallBoundingBox.Extents().Mag() / 200.0;
1196  TGLUtil::DrawSphere(TGLVertex3(0.0, 0.0, 0.0), size, TGLUtil::fgWhite);
1197  const TGLVertex3 & center = fOverallBoundingBox.Center();
1198  TGLUtil::DrawSphere(center, size, TGLUtil::fgGreen);
1199  glEnable(GL_DEPTH_TEST);
1200 
1201  glEnable(GL_LIGHTING);
1202  }
1203 }
1204 
1205 ////////////////////////////////////////////////////////////////////////////////
1206 /// Perform GL work which must be done before each draw.
1207 
1209 {
1210  InitGL();
1211 
1212  // For embedded gl clear color must be pad's background color.
1213  {
1214  Color_t ci = (fGLDevice != -1) ? gPad->GetFillColor() : fRnrCtx->ColorSet().Background().GetColorIndex();
1215  TColor *color = gROOT->GetColor(ci);
1216  Float_t rgb[3];
1217  if (color)
1218  color->GetRGB(rgb[0], rgb[1], rgb[2]);
1219  else
1220  rgb[0] = rgb[1] = rgb[2] = 0.0f;
1221 
1222  glClearColor(rgb[0], rgb[1], rgb[2], 0.0f);
1223  }
1224 
1225  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1226 
1227  TGLUtil::CheckError("TGLViewer::PreDraw");
1228 }
1229 
1230 ////////////////////////////////////////////////////////////////////////////////
1231 /// Perform GL work which must be done after each draw.
1232 
1234 {
1235  glFlush();
1236  TGLUtil::CheckError("TGLViewer::PostDraw");
1237 }
1238 
1239 ////////////////////////////////////////////////////////////////////////////////
1240 /// Draw a rectangle (background color and given alpha) across the
1241 /// whole viewport.
1242 
1244 {
1245  static const Float_t z = -1.0f;
1246 
1247  glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
1248  glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
1249 
1250  {
1251  TGLCapabilitySwitch blend(GL_BLEND, kTRUE);
1252  TGLCapabilitySwitch light(GL_LIGHTING, kFALSE);
1253  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1255  glBegin(GL_QUADS);
1256  glVertex3f(-1, -1, z); glVertex3f( 1, -1, z);
1257  glVertex3f( 1, 1, z); glVertex3f(-1, 1, z);
1258  glEnd();
1259  }
1260 
1261  glMatrixMode(GL_PROJECTION); glPopMatrix();
1262  glMatrixMode(GL_MODELVIEW); glPopMatrix();
1263 }
1264 
1265 ////////////////////////////////////////////////////////////////////////////////
1266 /// Make GL context current
1267 
1269 {
1270  if (fGLDevice == -1)
1272  else
1273  gGLManager->MakeCurrent(fGLDevice);
1274 }
1275 
1276 ////////////////////////////////////////////////////////////////////////////////
1277 /// Swap GL buffers
1278 
1280 {
1281  if ( ! IsDrawOrSelectLock()) {
1282  Error("TGLViewer::SwapBuffers", "viewer is %s", LockName(CurrentLock()));
1283  }
1284  if (fGLDevice == -1)
1286  else {
1287  gGLManager->ReadGLBuffer(fGLDevice);
1288  gGLManager->Flush(fGLDevice);
1289  gGLManager->MarkForDirectCopy(fGLDevice, kFALSE);
1290  }
1291 }
1292 
1293 ////////////////////////////////////////////////////////////////////////////////
1294 /// Post request for selection render pass viewer, picking objects
1295 /// around the window point (x,y).
1296 
1298 {
1299  // Take select lock on scene immediately we enter here - it is released
1300  // in the other (drawing) thread - see TGLViewer::DoSelect()
1301 
1302  if ( ! TakeLock(kSelectLock)) {
1303  return kFALSE;
1304  }
1305 
1306  if (!gVirtualX->IsCmdThread())
1307  return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoSelect(%d, %d)", (ULong_t)this, x, y)));
1308  else
1309  return DoSelect(x, y);
1310 }
1311 
1312 ////////////////////////////////////////////////////////////////////////////////
1313 /// Perform GL selection, picking objects overlapping WINDOW
1314 /// area described by 'rect'. Return kTRUE if selection should be
1315 /// changed, kFALSE otherwise.
1316 /// Select lock should already been taken in other thread in
1317 /// TGLViewer::ReqSelect().
1318 
1320 {
1322 
1323  if (CurrentLock() != kSelectLock) {
1324  Error("TGLViewer::DoSelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1325  return kFALSE;
1326  }
1327 
1329 
1330  TUnlocker ulck(this);
1331 
1332  MakeCurrent();
1333 
1335  glRenderMode(GL_SELECT);
1336 
1337  PreRender();
1339  PostRender();
1340 
1341  Int_t nHits = glRenderMode(GL_RENDER);
1342  fRnrCtx->EndSelection(nHits);
1343 
1344  // Process selection.
1345  if (gDebug > 0) Info("TGLViewer::DoSelect", "Primary select nHits=%d.", nHits);
1346 
1347  if (nHits > 0)
1348  {
1349  Int_t idx = 0;
1350  if (FindClosestRecord(fSelRec, idx))
1351  {
1353  {
1354  TGLSelectRecord opaque;
1355  if (FindClosestOpaqueRecord(opaque, ++idx))
1356  fSelRec = opaque;
1358  fSelRec.Reset();
1359  }
1360  if (gDebug > 1) fSelRec.Print();
1361  }
1362  } else {
1363  fSelRec.Reset();
1364  }
1365 
1368 }
1369 
1370 ////////////////////////////////////////////////////////////////////////////////
1371 /// Request secondary select.
1372 
1374 {
1375  if ( ! TakeLock(kSelectLock)) {
1376  return kFALSE;
1377  }
1378 
1379  if (!gVirtualX->IsCmdThread())
1380  return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoSecondarySelect(%d, %d)", (ULong_t)this, x, y)));
1381  else
1382  return DoSecondarySelect(x, y);
1383 }
1384 
1385 ////////////////////////////////////////////////////////////////////////////////
1386 /// Secondary selection.
1387 
1389 {
1391 
1392  if (CurrentLock() != kSelectLock) {
1393  Error("TGLViewer::DoSecondarySelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1394  return kFALSE;
1395  }
1396 
1398 
1399  TUnlocker ulck(this);
1400 
1401  if (! fSelRec.GetSceneInfo() || ! fSelRec.GetPhysShape() ||
1403  {
1404  if (gDebug > 0)
1405  Info("TGLViewer::SecondarySelect", "Skipping secondary selection "
1406  "(sinfo=0x%lx, pshape=0x%lx).\n",
1408  fSecSelRec.Reset();
1409  return kFALSE;
1410  }
1411 
1412  MakeCurrent();
1413 
1414  TGLSceneInfo* sinfo = fSelRec.GetSceneInfo();
1415  TGLSceneBase* scene = sinfo->GetScene();
1417 
1418  SceneInfoList_t foo;
1419  foo.push_back(sinfo);
1420  fScenes.swap(foo);
1423  glRenderMode(GL_SELECT);
1424 
1425  PreRender();
1426  fRnrCtx->SetSceneInfo(sinfo);
1427  scene->PreRender(*fRnrCtx);
1430  glPushName(pshp->ID());
1431  // !!! Hack: does not use clipping and proper draw-pass settings.
1432  pshp->Draw(*fRnrCtx);
1433  glPopName();
1434  scene->PostRender(*fRnrCtx);
1435  fRnrCtx->SetSceneInfo(0);
1436  PostRender();
1437 
1438  Int_t nSecHits = glRenderMode(GL_RENDER);
1439  fRnrCtx->EndSelection(nSecHits);
1440  fScenes.swap(foo);
1441 
1442  if (gDebug > 0) Info("TGLViewer::DoSelect", "Secondary select nSecHits=%d.", nSecHits);
1443 
1445 
1446  if (nSecHits > 0)
1447  {
1448  fSecSelRec = fSelRec;
1450  if (gDebug > 1) fSecSelRec.Print();
1451  return kTRUE;
1452  } else {
1453  fSecSelRec.Reset();
1454  return kFALSE;
1455  }
1456 }
1457 
1458 ////////////////////////////////////////////////////////////////////////////////
1459 /// Process result from last selection (in fSelRec) and
1460 /// extract a new current selection from it.
1461 /// Here we only use physical shape.
1462 
1464 {
1466 
1467  TGLPhysicalShape *selPhys = fSelRec.GetPhysShape();
1468  fSelectedPShapeRef->SetPShape(selPhys);
1469 
1470  // Inform external client selection has been modified.
1471  SelectionChanged();
1472 
1474 }
1475 
1476 ////////////////////////////////////////////////////////////////////////////////
1477 /// Post request for secondary selection rendering of selected object
1478 /// around the window point (x,y).
1479 
1481 {
1482  // Take select lock on viewer immediately - it is released
1483  // in the other (drawing) thread - see TGLViewer::DoSecondarySelect().
1484 
1485  if ( ! TakeLock(kSelectLock)) {
1486  return kFALSE;
1487  }
1488 
1489  if (!gVirtualX->IsCmdThread())
1490  return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoOverlaySelect(%d, %d)", (ULong_t)this, x, y)));
1491  else
1492  return DoOverlaySelect(x, y);
1493 }
1494 
1495 ////////////////////////////////////////////////////////////////////////////////
1496 /// Perform GL selection, picking overlay objects only.
1497 /// Return TRUE if the selected overlay-element has changed.
1498 
1500 {
1502 
1503  if (CurrentLock() != kSelectLock) {
1504  Error("TGLViewer::DoOverlaySelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1505  return kFALSE;
1506  }
1507 
1509 
1510  TUnlocker ulck(this);
1511 
1512  MakeCurrent();
1513 
1515  glRenderMode(GL_SELECT);
1516 
1520 
1521  Int_t nHits = glRenderMode(GL_RENDER);
1522  fRnrCtx->EndSelection(nHits);
1523 
1524  // Process overlay selection.
1525  TGLOverlayElement * selElm = 0;
1526  if (nHits > 0)
1527  {
1528  Int_t idx = 0;
1529  while (idx < nHits && FindClosestOverlayRecord(fOvlSelRec, idx))
1530  {
1532  if (el == fCurrentOvlElm)
1533  {
1534  if (el->MouseStillInside(fOvlSelRec))
1535  {
1536  selElm = el;
1537  break;
1538  }
1539  }
1540  else if (el->MouseEnter(fOvlSelRec))
1541  {
1542  selElm = el;
1543  break;
1544  }
1545  ++idx;
1546  }
1547  }
1548  else
1549  {
1550  fOvlSelRec.Reset();
1551  }
1552 
1554 
1555  if (fCurrentOvlElm != selElm)
1556  {
1558  fCurrentOvlElm = selElm;
1559  return kTRUE;
1560  }
1561  else
1562  {
1563  return kFALSE;
1564  }
1565 }
1566 
1567 ////////////////////////////////////////////////////////////////////////////////
1568 /// Make one fading step and request redraw.
1569 
1571 {
1572  Float_t fade = fViewer->GetFader();
1573 
1574  if (fade == fFadeTarget) {
1575  delete this; return;
1576  }
1577  if (TMath::Abs(fFadeTarget - fade) < 1e-3) {
1580  delete this;
1581  return;
1582  }
1583 
1584  Float_t dt = fTime/fNSteps;
1585  Float_t df = (fFadeTarget - fade)/fNSteps;
1586  fViewer->SetFader(fade + df);
1588  fTime -= dt; --fNSteps;
1590  "TGLFaderHelper", this, "MakeFadeStep()");
1591 }
1592 
1593 ////////////////////////////////////////////////////////////////////////////////
1594 /// Animate fading from current value to fade over given time (sec)
1595 /// and number of steps.
1596 
1597 void TGLViewer::AutoFade(Float_t fade, Float_t time, Int_t steps)
1598 {
1599  TGLFaderHelper* fh = new TGLFaderHelper(this, fade, time, steps);
1600  fh->MakeFadeStep();
1601 }
1602 
1603 ////////////////////////////////////////////////////////////////////////////////
1604 /// Use the dark color-set.
1605 
1607 {
1609  RefreshPadEditor(this);
1610 }
1611 
1612 ////////////////////////////////////////////////////////////////////////////////
1613 /// Use the light color-set.
1614 
1616 {
1618  RefreshPadEditor(this);
1619 }
1620 
1621 ////////////////////////////////////////////////////////////////////////////////
1622 /// Switch between dark and light colorsets.
1623 
1625 {
1626  if (IsUsingDefaultColorSet())
1627  {
1628  Info("SwitchColorSet()", "Global color-set is in use, switch not supported.");
1629  return;
1630  }
1631 
1633  UseDarkColorSet();
1634  else
1635  UseLightColorSet();
1636 }
1637 
1638 ////////////////////////////////////////////////////////////////////////////////
1639 /// Set usage of the default color set.
1640 
1642 {
1643  if (x)
1645  else
1647  RefreshPadEditor(this);
1648 }
1649 
1650 ////////////////////////////////////////////////////////////////////////////////
1651 /// Check if the viewer is using the default color set.
1652 /// If yes, some operations might be disabled.
1653 
1655 {
1657 }
1658 
1659 ////////////////////////////////////////////////////////////////////////////////
1660 /// Set background method.
1661 /// Deprecated method - set background color in the color-set.
1662 
1664 {
1666 }
1667 
1668 ////////////////////////////////////////////////////////////////////////////////
1669 /// Returns reference to the default color-set.
1670 /// Static function.
1671 
1673 {
1674  return fgDefaultColorSet;
1675 }
1676 
1677 ////////////////////////////////////////////////////////////////////////////////
1678 /// Sets static flag that determines if new viewers should use the
1679 /// default color-set.
1680 /// This is false at startup.
1681 
1683 {
1685 }
1686 
1687 ////////////////////////////////////////////////////////////////////////////////
1688 /// Returns the value of the static flag that determines if new
1689 /// viewers should use the default color-set.
1690 /// This is false at startup.
1691 
1693 {
1695 }
1696 
1697 ////////////////////////////////////////////////////////////////////////////////
1698 /// Returns true if current color set is dark.
1699 
1701 {
1702  return fRnrCtx->GetBaseColorSet() == &fDarkColorSet;
1703 }
1704 
1705 /**************************************************************************/
1706 // Viewport
1707 /**************************************************************************/
1708 
1709 ////////////////////////////////////////////////////////////////////////////////
1710 /// Set viewer viewport (window area) with bottom/left at (x,y), with
1711 /// dimensions 'width'/'height'
1712 
1714 {
1715  if (fStereo && ! fStereoQuadBuf) width /= 2;
1716 
1717  // Only process if changed
1718  if (fViewport.X() == x && fViewport.Y() == y &&
1719  fViewport.Width() == width && fViewport.Height() == height) {
1720  return;
1721  }
1722 
1723  fViewport.Set(x, y, width, height);
1725 
1726  if (gDebug > 2) {
1727  Info("TGLViewer::SetViewport", "updated - corner %d,%d dimensions %d,%d", x, y, width, height);
1728  }
1729 }
1730 
1732 {
1733  // Set viewer viewport from TGLRect.
1734 
1735  SetViewport(vp.X(), vp.Y(), vp.Width(), vp.Height());
1736 }
1737 
1738 /**************************************************************************/
1739 // Camera methods
1740 /**************************************************************************/
1741 
1742 ////////////////////////////////////////////////////////////////////////////////
1743 /// Return camera reference by type.
1744 
1746 {
1747  // TODO: Move these into a vector!
1748  switch(cameraType) {
1749  case kCameraPerspXOZ:
1750  return fPerspectiveCameraXOZ;
1751  case kCameraPerspYOZ:
1752  return fPerspectiveCameraYOZ;
1753  case kCameraPerspXOY:
1754  return fPerspectiveCameraXOY;
1755  case kCameraOrthoXOY:
1756  return fOrthoXOYCamera;
1757  case kCameraOrthoXOZ:
1758  return fOrthoXOZCamera;
1759  case kCameraOrthoZOY:
1760  return fOrthoZOYCamera;
1761  case kCameraOrthoXnOY:
1762  return fOrthoXnOYCamera;
1763  case kCameraOrthoXnOZ:
1764  return fOrthoXnOZCamera;
1765  case kCameraOrthoZnOY:
1766  return fOrthoZnOYCamera;
1767  default:
1768  Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1769  return *fCurrentCamera;
1770  }
1771 }
1772 
1773 ////////////////////////////////////////////////////////////////////////////////
1774 /// Set current active camera - 'cameraType' one of:
1775 /// kCameraPerspX, kCameraPerspY, kCameraPerspZ,
1776 /// kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY,
1777 /// kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY
1778 
1780 {
1781  if (IsLocked()) {
1782  Error("TGLViewer::SetCurrentCamera", "expected kUnlocked, found %s", LockName(CurrentLock()));
1783  return;
1784  }
1785 
1786  // TODO: Move these into a vector!
1787  TGLCamera *prev = fCurrentCamera;
1788  switch (cameraType)
1789  {
1790  case kCameraPerspXOZ: {
1792  break;
1793  }
1794  case kCameraPerspYOZ: {
1796  break;
1797  }
1798  case kCameraPerspXOY: {
1800  break;
1801  }
1802  case kCameraOrthoXOY: {
1804  break;
1805  }
1806  case kCameraOrthoXOZ: {
1808  break;
1809  }
1810  case kCameraOrthoZOY: {
1812  break;
1813  }
1814  case kCameraOrthoXnOY: {
1816  break;
1817  }
1818  case kCameraOrthoXnOZ: {
1820  break;
1821  }
1822  case kCameraOrthoZnOY: {
1824  break;
1825  }
1826  default: {
1827  Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1828  break;
1829  }
1830  }
1831 
1832  if (fCurrentCamera != prev)
1833  {
1834  // Ensure any viewport has been propagated to the current camera
1836  RefreshPadEditor(this);
1837 
1838  if (fAutoRotator)
1839  {
1840  if (fAutoRotator->IsRunning())
1841  {
1842  fAutoRotator->Stop();
1843  }
1844  else
1845  {
1847  {
1848  fAutoRotator->Start();
1849  }
1850  }
1851  }
1852 
1854  }
1855 }
1856 
1857 ////////////////////////////////////////////////////////////////////////////////
1858 /// Set an orthographic camera to supplied configuration - note this
1859 /// does not need to be the current camera - though you will not see
1860 /// the effect if it is not.
1861 ///
1862 /// 'camera' defines the ortho camera - one of kCameraOrthoXOY / XOZ / ZOY
1863 /// 'left' / 'right' / 'top' / 'bottom' define the WORLD coordinates which
1864 /// correspond with the left/right/top/bottom positions on the GL viewer viewport
1865 /// E.g. for kCameraOrthoXOY camera left/right are X world coords,
1866 /// top/bottom are Y world coords
1867 /// As this is an orthographic camera the other axis (in eye direction) is
1868 /// no relevant. The near/far clip planes are set automatically based in scene
1869 /// contents
1870 
1872  Double_t zoom, Double_t dolly,
1873  Double_t center[3],
1874  Double_t hRotate, Double_t vRotate)
1875 {
1876  // TODO: Move these into a vector!
1877  switch(camera) {
1878  case kCameraOrthoXOY: {
1879  fOrthoXOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1880  if (fCurrentCamera == &fOrthoXOYCamera) {
1882  }
1883  break;
1884  }
1885  case kCameraOrthoXOZ: {
1886  fOrthoXOZCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1887  if (fCurrentCamera == &fOrthoXOZCamera) {
1889  }
1890  break;
1891  }
1892  case kCameraOrthoZOY: {
1893  fOrthoZOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1894  if (fCurrentCamera == &fOrthoZOYCamera) {
1896  }
1897  break;
1898  }
1899  default: {
1900  Error("TGLViewer::SetOrthoCamera", "invalid camera type");
1901  break;
1902  }
1903  }
1904 }
1905 
1906 ////////////////////////////////////////////////////////////////////////////////
1907 /// Set a perspective camera to supplied configuration - note this
1908 /// does not need to be the current camera - though you will not see
1909 /// the effect if it is not.
1910 ///
1911 /// - 'camera' defines the persp camera - one of kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY
1912 /// - 'fov' - field of view (lens angle) in degrees (clamped to 0.1 - 170.0)
1913 /// - 'dolly' - distance from 'center'
1914 /// - 'center' - world position from which dolly/hRotate/vRotate are measured
1915 /// camera rotates round this, always facing in (in center of viewport)
1916 /// - 'hRotate' - horizontal rotation from initial configuration in degrees
1917 /// - 'hRotate' - vertical rotation from initial configuration in degrees
1918 
1920  Double_t fov, Double_t dolly,
1921  Double_t center[3],
1922  Double_t hRotate, Double_t vRotate)
1923 {
1924  // TODO: Move these into a vector!
1925  switch(camera) {
1926  case kCameraPerspXOZ: {
1927  fPerspectiveCameraXOZ.Configure(fov, dolly, center, hRotate, vRotate);
1930  }
1931  break;
1932  }
1933  case kCameraPerspYOZ: {
1934  fPerspectiveCameraYOZ.Configure(fov, dolly, center, hRotate, vRotate);
1937  }
1938  break;
1939  }
1940  case kCameraPerspXOY: {
1941  fPerspectiveCameraXOY.Configure(fov, dolly, center, hRotate, vRotate);
1944  }
1945  break;
1946  }
1947  default: {
1948  Error("TGLViewer::SetPerspectiveCamera", "invalid camera type");
1949  break;
1950  }
1951  }
1952 }
1953 
1954 ////////////////////////////////////////////////////////////////////////////////
1955 /// Change base-vectors defining the camera-base transformation of current
1956 /// camera. hAxis and vAxis are the default directions for forward
1957 /// (inverted) and upwards.
1958 
1959 void TGLViewer::ReinitializeCurrentCamera(const TGLVector3& hAxis, const TGLVector3& vAxis, Bool_t redraw)
1960 {
1962  cb.Set(cb.GetTranslation(), vAxis, hAxis);
1964  if (redraw)
1965  RequestDraw();
1966 }
1967 
1968 ////////////////////////////////////////////////////////////////////////////////
1969 /// Get the auto-rotator for this viewer.
1970 
1972 {
1973  if (fAutoRotator == 0)
1974  fAutoRotator = new TGLAutoRotator(this);
1975  return fAutoRotator;
1976 }
1977 
1978 ////////////////////////////////////////////////////////////////////////////////
1979 /// Set the auto-rotator for this viewer. The old rotator is deleted.
1980 
1982 {
1983  delete fAutoRotator;
1984  fAutoRotator = ar;
1985 }
1986 
1987 ////////////////////////////////////////////////////////////////////////////////
1988 /// Enable stereo rendering.
1989 /// If quad_buf is true rendering is done into separate left and right GL
1990 /// buffers. This requires hardware support. Otherwise left and right images
1991 /// get rendered into left and right half of the window.
1992 /// Note that mouse highlighting and selection will not work exactly right
1993 /// as image for each eye gets slightly shifted and there are two different
1994 /// directions through the mouse pointer, one for each eye.
1995 
1996 void TGLViewer::SetStereo(Bool_t stereo, Bool_t quad_buf)
1997 {
1998  if (stereo != fStereo)
1999  {
2000  fStereo = stereo;
2001  fStereoQuadBuf = quad_buf;
2002  if (fStereo)
2004  else
2006  }
2008 }
2009 
2010 /**************************************************************************/
2011 // Guide methods
2012 /**************************************************************************/
2013 
2014 ////////////////////////////////////////////////////////////////////////////////
2015 /// Fetch the state of guides (axes & reference markers) into arguments
2016 
2017 void TGLViewer::GetGuideState(Int_t & axesType, Bool_t & axesDepthTest, Bool_t & referenceOn, Double_t referencePos[3]) const
2018 {
2019  axesType = fAxesType;
2020  axesDepthTest = fAxesDepthTest;
2021 
2022  referenceOn = fReferenceOn;
2023  referencePos[0] = fReferencePos.X();
2024  referencePos[1] = fReferencePos.Y();
2025  referencePos[2] = fReferencePos.Z();
2026 }
2027 
2028 ////////////////////////////////////////////////////////////////////////////////
2029 /// Set the state of guides (axes & reference markers) from arguments.
2030 
2031 void TGLViewer::SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t referencePos[3])
2032 {
2033  fAxesType = axesType;
2034  fAxesDepthTest = axesDepthTest;
2035  fReferenceOn = referenceOn;
2036  if (referencePos)
2037  fReferencePos.Set(referencePos[0], referencePos[1], referencePos[2]);
2038  if (fGLDevice != -1)
2039  gGLManager->MarkForDirectCopy(fGLDevice, kTRUE);
2040  RequestDraw();
2041 }
2042 
2043 ////////////////////////////////////////////////////////////////////////////////
2044 /// Draw camera look at and rotation point.
2045 
2047 {
2048  fDrawCameraCenter = x;
2049  RequestDraw();
2050 }
2051 
2052 // Selected physical
2053 ////////////////////////////////////////////////////////////////////////////////
2054 /// Return selected physical shape.
2055 
2057 {
2058  return fSelectedPShapeRef->GetPShape();
2059 }
2060 
2061 /**************************************************************************/
2062 /**************************************************************************/
2063 
2064 ////////////////////////////////////////////////////////////////////////////////
2065 /// Emit MouseOver signal.
2066 
2068 {
2069  Emit("MouseOver(TGLPhysicalShape*)", (Long_t)shape);
2070 }
2071 
2072 ////////////////////////////////////////////////////////////////////////////////
2073 /// Emit MouseOver signal.
2074 
2076 {
2077  Long_t args[2];
2078  args[0] = (Long_t)shape;
2079  args[1] = state;
2080  Emit("MouseOver(TGLPhysicalShape*,UInt_t)", args);
2081 }
2082 
2083 ////////////////////////////////////////////////////////////////////////////////
2084 /// Emit MouseOver signal.
2085 
2087 {
2088  Long_t args[2];
2089  args[0] = (Long_t)obj;
2090  args[1] = state;
2091  Emit("MouseOver(TObject*,UInt_t)", args);
2092 }
2093 
2094 ////////////////////////////////////////////////////////////////////////////////
2095 /// Emit MouseOver signal.
2096 
2098 {
2099  Long_t args[2];
2100  args[0] = (Long_t)obj;
2101  args[1] = state;
2102  Emit("ReMouseOver(TObject*,UInt_t)", args);
2103 }
2104 
2105 
2106 ////////////////////////////////////////////////////////////////////////////////
2107 /// Emit UnMouseOver signal.
2108 
2110 {
2111  Long_t args[2];
2112  args[0] = (Long_t)obj;
2113  args[1] = state;
2114  Emit("UnMouseOver(TObject*,UInt_t)", args);
2115 }
2116 
2117 ////////////////////////////////////////////////////////////////////////////////
2118 /// Emit Clicked signal.
2119 
2121 {
2122  Emit("Clicked(TObject*)", (Long_t)obj);
2123 }
2124 
2125 ////////////////////////////////////////////////////////////////////////////////
2126 /// Emit Clicked signal with button id and modifier state.
2127 
2129 {
2130  Long_t args[3];
2131  args[0] = (Long_t)obj;
2132  args[1] = button;
2133  args[2] = state;
2134  Emit("Clicked(TObject*,UInt_t,UInt_t)", args);
2135 }
2136 
2137 
2138 ////////////////////////////////////////////////////////////////////////////////
2139 /// Emit ReClicked signal with button id and modifier state.
2140 
2142 {
2143  Long_t args[3];
2144  args[0] = (Long_t)obj;
2145  args[1] = button;
2146  args[2] = state;
2147  Emit("ReClicked(TObject*,UInt_t,UInt_t)", args);
2148 }
2149 
2150 ////////////////////////////////////////////////////////////////////////////////
2151 /// Emit UnClicked signal with button id and modifier state.
2152 
2154 {
2155  Long_t args[3];
2156  args[0] = (Long_t)obj;
2157  args[1] = button;
2158  args[2] = state;
2159  Emit("UnClicked(TObject*,UInt_t,UInt_t)", args);
2160 }
2161 
2162 ////////////////////////////////////////////////////////////////////////////////
2163 /// Emit MouseIdle signal.
2164 
2166 {
2167  Long_t args[3];
2168  static UInt_t oldx = 0, oldy = 0;
2169 
2170  if (oldx != posx || oldy != posy) {
2171  args[0] = (Long_t)shape;
2172  args[1] = posx;
2173  args[2] = posy;
2174  Emit("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", args);
2175  oldx = posx;
2176  oldy = posy;
2177  }
2178 }
2179 
2180 /**************************************************************************/
2181 /**************************************************************************/
2182 ////////////////////////////////////////////////////////////////////////////////
2183 /// Calculate and return pixel distance to nearest viewer object from
2184 /// window location px, py
2185 /// This is provided for use when embedding GL viewer into pad
2186 
2188 {
2189  // Can't track the indvidual objects in rollover. Just set the viewer as the
2190  // selected object, and return 0 (object identified) so we receive ExecuteEvent calls
2191  gPad->SetSelected(this);
2192  return 0;
2193 }
2194 
2195 ////////////////////////////////////////////////////////////////////////////////
2196 /// Process event of type 'event' - one of EEventType types,
2197 /// occurring at window location px, py
2198 /// This is provided for use when embedding GL viewer into pad
2199 
2201 {
2202  if (fEventHandler)
2203  return fEventHandler->ExecuteEvent(event, px, py);
2204 }
2205 
2206 ////////////////////////////////////////////////////////////////////////////////
2207 /// Pass viewer for print capture by TGLOutput.
2208 
2210 {
2211  TGLOutput::Capture(*this);
2212 }
2213 
2214 ////////////////////////////////////////////////////////////////////////////////
2215 /// Update GUI components for embedded viewer selection change.
2216 
2218 {
2219  if (!fGedEditor)
2220  return;
2221 
2222  TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
2223 
2224  if (selected) {
2225  fPShapeWrap->fPShape = selected;
2227  } else {
2228  fPShapeWrap->fPShape = 0;
2230  }
2231 }
2232 
2233 ////////////////////////////////////////////////////////////////////////////////
2234 /// An overlay operation can result in change to an object.
2235 /// Refresh geditor.
2236 
2238 {
2239  if (fGedEditor)
2240  {
2242  }
2243 }
2244 
2245 ////////////////////////////////////////////////////////////////////////////////
2246 /// Update GED editor if it is set.
2247 
2249 {
2250  if (fGedEditor && (obj == 0 || fGedEditor->GetModel() == obj))
2251  {
2253  }
2254 }
2255 
2256 ////////////////////////////////////////////////////////////////////////////////
2257 /// Set the event-handler. The event-handler is owned by the viewer.
2258 /// If GLWidget is set, the handler is propagated to it.
2259 ///
2260 /// If called with handler=0, the current handler will be deleted
2261 /// (also from TGLWidget).
2262 
2264 {
2265  if (fEventHandler)
2266  delete fEventHandler;
2267 
2268  fEventHandler = handler;
2269  if (fGLWidget)
2271 }
2272 
2273 ////////////////////////////////////////////////////////////////////////////////
2274 /// Remove overlay element.
2275 
2277 {
2278  if (el == fCurrentOvlElm)
2279  {
2280  fCurrentOvlElm = 0;
2281  }
2283 }
2284 
2285 ////////////////////////////////////////////////////////////////////////////////
2286 /// Reset current overlay-element to zero, eventually notifying the
2287 /// old one that the mouse has left.
2288 /// Usually called when mouse leaves the window.
2289 
2291 {
2292  if (fCurrentOvlElm)
2293  {
2295  fCurrentOvlElm = 0;
2296  RequestDraw();
2297  }
2298 }
TGEventHandler * fEventHandler
select record from last overlay select
Definition: TGLViewer.h:119
Bool_t IsLocked() const
Definition: TGLLockable.h:60
void FadeView(Float_t alpha)
Draw a rectangle (background color and given alpha) across the whole viewport.
Definition: TGLViewer.cxx:1243
Int_t fAxesType
smooth line edge rendering
Definition: TGLViewer.h:146
TGLCamera * fCurrentCamera
Definition: TGLViewer.h:96
virtual Bool_t SupportsSecondarySelect() const
Float_t fTime
Definition: TGLViewer.h:439
A GL overlay element which displays camera furstum.
TGLVertex3 fReferencePos
reference marker on?
Definition: TGLViewer.h:149
virtual void Stop()
Definition: TGLViewer.h:417
void SetSecSelection(Bool_t secSel)
Definition: TGLRnrCtx.h:225
TVirtualPad * GetPad() const
Definition: TGLScenePad.h:67
virtual void ReMouseOver(TObject *obj, UInt_t state)
Emit MouseOver signal.
Definition: TGLViewer.cxx:2097
Class encapsulating a set of colors used throughout standard rendering.
Definition: TGLUtil.h:838
void DrawDebugAids() const
Draw out some debugging aids for the camera:
Definition: TGLCamera.cxx:793
TGLSelectRecord fSelRec
select record in use as selected
Definition: TGLViewer.h:112
Bool_t GetGrabImage() const
Definition: TGLRnrCtx.h:267
TString fPictureFileName
Definition: TGLViewer.h:158
Bool_t fStereoQuadBuf
use stereo rendering
Definition: TGLViewer.h:101
TGLColorSet fLightColorSet
color-set with dark background
Definition: TGLViewer.h:141
virtual void PadPaint(TVirtualPad *pad)
Entry point for updating viewer contents via VirtualViewer3D interface.
Definition: TGLViewer.cxx:302
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
TGLPerspectiveCamera fPerspectiveCameraXOZ
Definition: TGLViewer.h:87
Int_t Width() const
Definition: TGLUtil.h:455
virtual void PreRender()
Initialize objects that influence rendering.
Definition: TGLViewer.cxx:481
void Start()
Start timing.
Wrapper class for various misc static functions - error checking, draw helpers etc.
Definition: TGLUtil.h:880
void ReinitializeCurrentCamera(const TGLVector3 &hAxis, const TGLVector3 &vAxis, Bool_t redraw=kTRUE)
Change base-vectors defining the camera-base transformation of current camera.
Definition: TGLViewer.cxx:1959
void StdLightBackground()
Set defaults for light (white) background.
Definition: TGLUtil.cxx:1406
Float_t fLineScale
size scale for points
Definition: TGLViewer.h:143
Wrap TGLPysicalShape into TObject so that it can be edited using GED.
Definition: TGLPShapeObj.h:20
float Float_t
Definition: RtypesCore.h:53
void Unbind()
Unbind the frame-buffer object.
Definition: TGLFBO.cxx:215
virtual void MouseOver(TGLPhysicalShape *)
Emit MouseOver signal.
Definition: TGLViewer.cxx:2067
void SwitchColorSet()
Switch between dark and light colorsets.
Definition: TGLViewer.cxx:1624
TGLAutoRotator * fAutoRotator
Definition: TGLViewer.h:97
Float_t fFadeTarget
Definition: TGLViewer.h:438
static void DrawReferenceMarker(const TGLCamera &camera, const TGLVertex3 &pos, Float_t radius=3, const UChar_t *rgba=0)
Draw a sphere- marker on world-coordinate 'pos' with pixel radius 'radius'.
Definition: TGLUtil.cxx:2440
TGLVector3 GetTranslation() const
Return the translation component of matrix.
Definition: TGLUtil.cxx:822
std::list< TGLSceneInfo * > SceneInfoList_t
Definition: TGLViewerBase.h:43
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:600
ELock CurrentLock() const
Definition: TGLLockable.h:61
virtual void Render()
Render all scenes.
Double_t DegToRad()
Definition: TMath.h:50
TH1 * h
Definition: legend2.C:5
TGLOrthoCamera fOrthoXnOZCamera
Definition: TGLViewer.h:94
Identifier of a shared GL-context.
Definition: TGLContext.h:83
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
static void DrawSimpleAxes(const TGLCamera &camera, const TGLBoundingBox &bbox, Int_t axesType)
Draw simple xyz-axes for given bounding-box.
Definition: TGLUtil.cxx:2455
void Bind()
Bind the frame-buffer object.
Definition: TGLFBO.cxx:198
void ResetCurrentCamera()
Resets position/rotation of current camera to default values.
Definition: TGLViewer.cxx:356
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
void SetupCameras(Bool_t reset)
Setup cameras for current bounding box.
Definition: TGLViewer.cxx:365
TGLOrthoCamera fOrthoXOZCamera
Definition: TGLViewer.h:91
static TGLColorSet & GetDefaultColorSet()
Returns reference to the default color-set.
Definition: TGLViewer.cxx:1672
TGLOrthoCamera fOrthoXOYCamera
Definition: TGLViewer.h:90
TGLCamera & RefCamera(ECameraType camera)
Return camera reference by type.
Definition: TGLViewer.cxx:1745
Bool_t RequestOverlaySelect(Int_t x, Int_t y)
Post request for secondary selection rendering of selected object around the window point (x...
Definition: TGLViewer.cxx:1480
virtual void SetEventHandler(TGEventHandler *handler)
Set the event-handler.
Definition: TGLViewer.cxx:2263
Stopwatch object for timing GL work.
Definition: TGLStopwatch.h:34
virtual void SetPShape(TGLPhysicalShape *shape)
Set phys-shape, override of virtual from TGLPShapeRef.
Definition: TGLManipSet.cxx:64
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes: ...
Definition: TGLSceneBase.h:32
Float_t fStereoEyeOffsetFac
position of zero-parallax plane: 0 - near clipping plane, 1 - far clipping plane
Definition: TGLViewer.h:103
TGLViewer * fViewer
Definition: TGLViewer.h:437
virtual void PreRender(TGLRnrCtx &rnrCtx)
Perform pre-render initialization - fill rnrCtx with values stored during PreDraw().
virtual void Reset()
Reinitialise all data to null values.
Bool_t FindClosestRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved, starting from position 'recIdx'.
TGLVector3 ViewportDeltaToWorld(const TGLVertex3 &worldRef, Double_t viewportXDelta, Double_t viewportYDelta, TGLMatrix *modviewMat=0) const
Apply a 2D viewport delta (shift) to the projection of worldRef onto viewport, returning the resultan...
Definition: TGLCamera.cxx:546
Short_t SelectTransparents() const
Definition: TGLRnrCtx.h:227
#define gROOT
Definition: TROOT.h:340
void SetGrabImage(Bool_t gi)
Definition: TGLRnrCtx.h:266
void MakeFadeStep()
Make one fading step and request redraw.
Definition: TGLViewer.cxx:1570
Double_t Mag() const
Definition: TGLUtil.h:303
void DoDraw(Bool_t swap_buffers=kTRUE)
Draw out the viewer.
Definition: TGLViewer.cxx:546
TGLVertex3 Center() const
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
Basic string class.
Definition: TString.h:137
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition: TTimer.cxx:254
Bool_t SavePictureScale(const TString &fileName, Float_t scale, Bool_t pixel_object_scale=kTRUE)
Save picture with given scale to current window size.
Definition: TGLViewer.cxx:1135
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:63
const Bool_t kFALSE
Definition: Rtypes.h:92
static void PointToViewport(Int_t &x, Int_t &y)
Convert from point/screen coordinates to GL viewport coordinates.
Definition: TGLUtil.cxx:1784
void SetRawOnly(UInt_t *data)
Setup the record from raw buffer.
void SetDrawCameraCenter(Bool_t x)
Draw camera look at and rotation point.
Definition: TGLViewer.cxx:2046
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event)
Activate object editors according to the selected object.
Definition: TGedEditor.cxx:349
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
An abstract interface to image processing library.
Definition: TImage.h:45
Bool_t SavePictureHeight(const TString &fileName, Int_t height, Bool_t pixel_object_scale=kTRUE)
Save picture with given height (width scaled proportionally).
Definition: TGLViewer.cxx:1121
Bool_t IsUsingDefaultColorSet() const
Check if the viewer is using the default color set.
Definition: TGLViewer.cxx:1654
Bool_t RequestSecondarySelect(Int_t x, Int_t y)
Request secondary select.
Definition: TGLViewer.cxx:1373
virtual void UnMouseOver(TObject *obj, UInt_t state)
Emit UnMouseOver signal.
Definition: TGLViewer.cxx:2109
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
UInt_t * RawRecord(Int_t i)
virtual TObject * GetModel() const
Definition: TGedEditor.h:98
Perspective projection camera - with characteristic foreshortening.
Double_t GetFarClip() const
Definition: TGLCamera.h:164
virtual void PostRender()
Restore state set in PreRender().
Definition: TGLViewer.cxx:535
void Set(Double_t x, Double_t y, Double_t z)
Definition: TGLUtil.h:213
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Process event of type 'event' - one of EEventType types, occurring at window location px...
Definition: TGLViewer.cxx:2200
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
Encapsulates a set of lights for OpenGL.
Definition: TGLLightSet.h:21
void StartStopwatch()
Start the stopwatch.
Definition: TGLRnrCtx.cxx:166
void UseLightColorSet()
Use the light color-set.
Definition: TGLViewer.cxx:1615
Combine all available manipulators in a collection.
Definition: TGLManipSet.h:21
An overlay element.
Definition: TGLOverlay.h:22
void SetShapeLOD(Short_t LOD)
Definition: TGLRnrCtx.h:178
static void UseDefaultColorSetForNewViewers(Bool_t x)
Sets static flag that determines if new viewers should use the default color-set. ...
Definition: TGLViewer.cxx:1682
void SetOrthoCamera(ECameraType camera, Double_t zoom, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Set an orthographic camera to supplied configuration - note this does not need to be the current came...
Definition: TGLViewer.cxx:1871
void SetClearColor(Color_t col)
Set background method.
Definition: TGLViewer.cxx:1663
Concrete physical shape - a GL drawable.
virtual void Render()
Normal rendering, used by mono and stereo rendering.
Definition: TGLViewer.cxx:515
void SetAsReadBuffer()
Definition: TGLFBO.cxx:262
const char * Data() const
Definition: TString.h:349
TGLOverlayElement * GetOvlElement() const
void AutoFade(Float_t fade, Float_t time=1, Int_t steps=10)
Animate fading from current value to fade over given time (sec) and number of steps.
Definition: TGLViewer.cxx:1597
static TGLColorSet fgDefaultColorSet
fade the view (0 - no fade/default, 1 - full fade/no rendering done)
Definition: TGLViewer.h:161
void Release(TGLContext *ctx)
Remove context ctx from the list of references.
Definition: TGLContext.cxx:504
Bool_t FindClosestOpaqueRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved and whose result is not transparent, starting from posit...
TGLSelectRecord fCurrentSelRec
Definition: TGLViewer.h:111
TStopwatch timer
Definition: pirndm.C:37
Double_t x[n]
Definition: legend1.C:17
virtual void PostRenderOverlaySelection()
Perform cleanup after overlay selection.
virtual void OverlayDragFinished()
An overlay operation can result in change to an object.
Definition: TGLViewer.cxx:2237
Bool_t fDebugMode
cache logicals during scene rebuilds
Definition: TGLViewer.h:156
TGLRedrawTimer * fRedrawTimer
Definition: TGLViewer.h:135
Double_t GetNearClip() const
Definition: TGLCamera.h:163
ClassImp(TGLViewer)
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
TGLRnrCtx * fRnrCtx
Definition: TGLViewerBase.h:62
void Set(const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis=0)
Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'...
Definition: TGLUtil.cxx:764
virtual void ReleaseViewer3D(Option_t *type="")=0
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:86
void SetFader(Float_t x)
Definition: TGLViewer.h:349
TGLContextIdentity * fGLCtxId
for embedded gl viewer
Definition: TGLViewer.h:187
static void DrawSphere(const TGLVertex3 &position, Double_t radius, const UChar_t rgba[4])
Draw sphere, centered on vertex 'position', with radius 'radius', color 'rgba'.
Definition: TGLUtil.cxx:2318
virtual void PostSceneBuildSetup(Bool_t resetCameras)
Perform post scene-build setup.
Definition: TGLViewer.cxx:390
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)=0
Float_t GetRenderScale() const
Definition: TGLRnrCtx.h:244
void StopStopwatch()
Stop the stopwatch.
Definition: TGLRnrCtx.cxx:179
virtual void ResetSceneInfos()
Force rebuild of view-dependent scene-info structures.
void PostDraw()
Perform GL work which must be done after each draw.
Definition: TGLViewer.cxx:1233
Bool_t GetTransparent() const
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
Definition: TGLWidget.cxx:558
void SetupCurrentClip(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition: TGLClip.cxx:435
void SetSceneInfo(TGLSceneInfo *si)
Definition: TGLRnrCtx.h:168
virtual void RenderSelectedForHighlight()
Render selected objects from all scenes for highlight.
Bool_t IsColorSetDark() const
Returns true if current color set is dark.
Definition: TGLViewer.cxx:1700
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:426
Bool_t fResetCamerasOnUpdate
Definition: TGLViewer.h:191
Bool_t DoSecondarySelect(Int_t x, Int_t y)
Secondary selection.
Definition: TGLViewer.cxx:1388
virtual Bool_t MouseStillInside(TGLOvlSelectRecord &selRec)
Definition: TGLOverlay.cxx:30
3 component (x/y/z) vector class.
Definition: TGLUtil.h:250
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
Definition: TGLViewer.cxx:2276
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
TVirtualPad * fPad
Definition: TGLViewer.h:80
void DrawGuides()
Draw reference marker and coordinate axes.
Definition: TGLViewer.cxx:1147
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
void ApplySelection()
Process result from last selection (in fSelRec) and extract a new current selection from it...
Definition: TGLViewer.cxx:1463
virtual void Reset()
Reinitialise all data to null values.
Bool_t fAxesDepthTest
axes type
Definition: TGLViewer.h:147
short Color_t
Definition: RtypesCore.h:79
TGLWidget * fGLWidget
Definition: TGLViewer.h:185
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
Bool_t IsRunning() const
virtual void PadPaintFromViewer(TGLViewer *viewer)
Entry point for requesting update of scene's contents from gl-viewer.
TGLSelectBuffer * GetSelectBuffer() const
Definition: TGLRnrCtx.h:231
void SwapBuffers()
Swap buffers.
Definition: TGLWidget.cxx:217
TGLManipSet * fSelectedPShapeRef
select record from last secondary select (should go to context)
Definition: TGLViewer.h:114
Float_t fMaxSceneDrawTimeLQ
max time for scene rendering at high LOD (in ms)
Definition: TGLViewer.h:137
TGLVector3 Extents() const
void UpdateScene(Bool_t redraw=kTRUE)
Force update of pad-scenes.
Definition: TGLViewer.cxx:334
void InitGL()
Initialise GL state.
Definition: TGLViewer.cxx:407
static void SetPointSizeScale(Float_t scale)
Set global point-size scale.
Definition: TGLUtil.cxx:1852
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by 'box' and call Reset() to initialise...
Double_t * GetCenterVec()
Definition: TGLCamera.h:157
void SetPerspectiveCamera(ECameraType camera, Double_t fov, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Set a perspective camera to supplied configuration - note this does not need to be the current camera...
Definition: TGLViewer.cxx:1919
virtual void MouseLeave()
Mouse has left the element.
Definition: TGLOverlay.cxx:56
Float_t fFader
default file-name for SavePicture()
Definition: TGLViewer.h:159
TGLMatrix & RefCamTrans()
Definition: TGLCamera.h:170
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by 'box' and call Reset() to initialise...
TGLPhysicalShape * fPShape
Definition: TGLPShapeObj.h:23
Automatically rotates GL camera.
TGLAutoRotator * GetAutoRotator()
Get the auto-rotator for this viewer.
Definition: TGLViewer.cxx:1971
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail 'LOD' Request is directed via cross thread gVirt...
Definition: TGLViewer.cxx:436
virtual void PrintObjects()
Pass viewer for print capture by TGLOutput.
Definition: TGLViewer.cxx:2209
Bool_t RequestSelect(Int_t x, Int_t y)
Post request for selection render pass viewer, picking objects around the window point (x...
Definition: TGLViewer.cxx:1297
static void SetLineWidthScale(Float_t scale)
Set global line-width scale.
Definition: TGLUtil.cxx:1868
TGLBoundingBox fOverallBoundingBox
Definition: TGLViewerBase.h:77
static Bool_t IsUsingDefaultColorSetForNewViewers()
Returns the value of the static flag that determines if new viewers should use the default color-set...
Definition: TGLViewer.cxx:1692
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2220
TGLCamera * fCamera
Definition: TGLViewerBase.h:64
virtual void PreRender()
Initialize render-context, setup camera, GL, render-area.
void RequestDraw(Int_t milliSec, Short_t redrawLOD)
Definition: TGLViewer.h:410
Bool_t fIsPrinting
debug mode (forced rebuild + draw scene/frustum/interest boxes)
Definition: TGLViewer.h:157
TGLCamera * GetCamera() const
static const UChar_t fgWhite[4]
Definition: TGLUtil.h:1055
TGLSceneInfo * GetSceneInfo() const
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
Standard selection record including information about containing scene and details ob out selected ob...
TGLMatrix & RefCamBase()
Definition: TGLCamera.h:169
virtual Color_t GetFillColor() const
Definition: TAttFill.h:43
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition: TColor.h:54
Bool_t SavePictureUsingFBO(const TString &fileName, Int_t w, Int_t h, Float_t pixel_object_scale=0)
Save current image in various formats (gif, gif+, jpg, png).
Definition: TGLViewer.cxx:889
void Init(int w, int h, int ms_samples=0)
Acquire GL resources for given width, height and number of multi-sampling samples.
Definition: TGLFBO.cxx:74
Int_t fGLDevice
Definition: TGLViewer.h:186
Double_t Aspect() const
Definition: TGLUtil.h:505
TGLCamera & CurrentCamera() const
Definition: TGLViewer.h:267
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Clicked(TObject *obj)
Emit Clicked signal.
Definition: TGLViewer.cxx:2120
void SwapBuffers() const
Swap GL buffers.
Definition: TGLViewer.cxx:1279
TGLRect fViewport
max time for scene rendering at high LOD (in ms)
Definition: TGLViewer.h:139
char * Form(const char *fmt,...)
Bool_t fStereo
Definition: TGLViewer.h:100
Bool_t DoOverlaySelect(Int_t x, Int_t y)
Perform GL selection, picking overlay objects only.
Definition: TGLViewer.cxx:1499
Implements VirtualViewer3D interface and fills the base-class visualization structures from pad conte...
Definition: TGLScenePad.h:31
void DoDrawStereo(Bool_t swap_buffers)
Draw out in stereoscopic mode.
Definition: TGLViewer.cxx:656
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:139
Double_t GetFOV() const
void DeleteGLResources()
Delete GL resources registered for destruction.
Definition: TGLContext.cxx:530
short Short_t
Definition: RtypesCore.h:35
TGLOvlSelectRecord fOvlSelRec
current overlay element
Definition: TGLViewer.h:117
void UseDarkColorSet()
Use the dark color-set.
Definition: TGLViewer.cxx:1606
virtual void PostRender()
Function called after rendering is finished.
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the 'lock' argument.
Definition: TGLLockable.cxx:51
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
void GetGuideState(Int_t &axesType, Bool_t &axesDepthTest, Bool_t &referenceOn, Double_t *referencePos) const
Fetch the state of guides (axes & reference markers) into arguments.
Definition: TGLViewer.cxx:2017
Bool_t fSmoothPoints
width scale for lines
Definition: TGLViewer.h:144
TGLPhysicalShape * GetPShape() const
Definition: TGLPShapeRef.h:36
virtual Color_t GetLineColor() const
Definition: TAttLine.h:47
Int_t X() const
Definition: TGLUtil.h:451
void SetStereo(Bool_t stereo, Bool_t quad_buf=kTRUE)
Enable stereo rendering.
Definition: TGLViewer.cxx:1996
#define gVirtualX
Definition: TVirtualX.h:362
static TImage * Create()
void SetDrawBBox(Bool_t bb)
Definition: TGLManipSet.h:55
Bool_t DoSelect(Int_t x, Int_t y)
Perform GL selection, picking objects overlapping WINDOW area described by 'rect'.
Definition: TGLViewer.cxx:1319
TGLColorSet * ChangeBaseColorSet(TGLColorSet *set)
Change the default/bottom color-set.
Definition: TGLRnrCtx.cxx:304
friend class TGLAutoRotator
Definition: TGLViewer.h:60
static const UChar_t fgGreen[4]
Definition: TGLUtil.h:1052
#define blend
virtual Bool_t IsPerspective() const
Definition: TGLCamera.h:119
void Print()
Print contents of the select record to stdout.
virtual void PreRenderOverlaySelection()
Perform minimal initialization for overlay selection.
Bool_t MakeCurrent()
Make the gl-context current.
Definition: TGLWidget.cxx:201
virtual void RenderOverlay(Int_t state, Bool_t selection)
Render overlay objects.
long Long_t
Definition: RtypesCore.h:50
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
TImage * GetPictureUsingBB()
Returns current image.
Definition: TGLViewer.cxx:983
Float_t GetFader() const
Definition: TGLViewer.h:348
void Stop()
Stop the auto-rotator.
virtual void Configure(Double_t fov, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Configure the camera state.
Bool_t fSmoothLines
smooth point edge rendering
Definition: TGLViewer.h:145
static const char * LockName(ELock lock)
Return name-string for given lock-type.
Definition: TGLLockable.cxx:69
void EndSelection(Int_t glResult)
End selection.
Definition: TGLRnrCtx.cxx:219
double f(double x)
TGLClip * fClip
Definition: TGLViewerBase.h:65
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TObject.cxx:369
Bool_t SavePictureWidth(const TString &fileName, Int_t width, Bool_t pixel_object_scale=kTRUE)
Save picture with given width (height scaled proportionally).
Definition: TGLViewer.cxx:1107
void MakeCurrent() const
Make GL context current.
Definition: TGLViewer.cxx:1268
double Double_t
Definition: RtypesCore.h:55
TGLSceneBase * GetScene() const
Definition: TGLSceneInfo.h:83
void SetViewport(Int_t x, Int_t y, Int_t width, Int_t height)
Set viewer viewport (window area) with bottom/left at (x,y), with dimensions 'width'/'height'.
Definition: TGLViewer.cxx:1713
TGLSceneInfo * AddScene(TGLSceneBase *scene)
Add new scene, appropriate scene-info is created.
TGLOrthoCamera fOrthoXnOYCamera
Definition: TGLViewer.h:93
void BeginSelection(Int_t x, Int_t y, Int_t r=3)
Setup context for running selection.
Definition: TGLRnrCtx.cxx:205
Bool_t GetClipAutoUpdate() const
Definition: TGLViewer.h:263
TGLOrthoCamera fOrthoZOYCamera
Definition: TGLViewer.h:92
static Bool_t fgUseDefaultColorSetForNewViewers
a shared, default color-set
Definition: TGLViewer.h:162
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
Float_t fMaxSceneDrawTimeHQ
timer for triggering redraws
Definition: TGLViewer.h:136
unsigned long ULong_t
Definition: RtypesCore.h:51
TGLOrthoCamera fOrthoZnOYCamera
Definition: TGLViewer.h:95
Float_t fStereoZeroParallax
draw quad buffer or left/right stereo in left/right half of window
Definition: TGLViewer.h:102
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:180
virtual void SelectionChanged()
Update GUI components for embedded viewer selection change.
Definition: TGLViewer.cxx:2217
virtual void ReClicked(TObject *obj, UInt_t button, UInt_t state)
Emit ReClicked signal with button id and modifier state.
Definition: TGLViewer.cxx:2141
Bool_t fReferenceOn
remove guides hidden-lines
Definition: TGLViewer.h:148
#define gGLManager
Definition: TVirtualGL.h:168
Int_t GetSamples() const
Get the number of samples for multi-sampling.
Definition: TGLFormat.cxx:211
Bool_t UpdateInterest(Bool_t force)
Update the internal interest box (fInterestBox) of the camera.
Definition: TGLCamera.cxx:643
The color creation and management class.
Definition: TColor.h:23
Bool_t IsDrawOrSelectLock() const
Definition: TGLLockable.h:63
Bool_t FindClosestOverlayRecord(TGLOvlSelectRecord &rec, Int_t &recIdx)
Find next overlay-select record that can be resolved, starting from position 'recIdx'.
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1779
TGLCameraOverlay * fCameraOverlay
reference marker on?
Definition: TGLViewer.h:151
virtual void MergeSceneBBoxes(TGLBoundingBox &bbox)
Merge bounding-boxes of all active registered scenes.
Bool_t TakeLock(ELock lock) const
Lock the object in mode 'lock'.
Definition: TGLLockable.cxx:32
void AddRef(TGLContext *ctx)
Add context ctx to the list of references.
Definition: TGLContext.cxx:495
TContextMenu * fContextMenu
external pad - remove replace with signal
Definition: TGLViewer.h:83
TImage * GetPictureUsingFBO(Int_t w, Int_t h, Float_t pixel_object_scale=0)
Returns current image.
Definition: TGLViewer.cxx:1030
static Bool_t Capture(TGLViewer &viewer, EFormat format, const char *filePath=0)
Double_t X() const
Definition: TGLUtil.h:122
TGLColor & Background()
Definition: TGLUtil.h:853
virtual void Configure(Double_t zoom, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Configure the camera state.
void SetDrawPass(Short_t dpass)
Definition: TGLRnrCtx.h:205
TGLOverlayElement * fCurrentOvlElm
Definition: TGLViewer.h:116
void DoDrawMono(Bool_t swap_buffers)
Draw out in monoscopic mode.
Definition: TGLViewer.cxx:624
Orthographic projection camera.
Mother of all ROOT objects.
Definition: TObject.h:58
static Int_t CheckError(const char *loc)
Check current GL error state, outputting details via ROOT Error method if one.
Definition: TGLUtil.cxx:1607
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
void SetupCurrentClipIfInvalid(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition: TGLClip.cxx:445
TGLViewer(const TGLViewer &)
Float_t fStereoFrustumAsymFac
Definition: TGLViewer.h:104
Double_t Y() const
Definition: TGLUtil.h:124
virtual void RefreshPadEditor(TObject *obj=0)
Update GED editor if it is set.
Definition: TGLViewer.cxx:2248
void ClearCurrentOvlElm()
Reset current overlay-element to zero, eventually notifying the old one that the mouse has left...
Definition: TGLViewer.cxx:2290
Bool_t SavePictureUsingBB(const TString &fileName)
Save current image in various formats (gif, gif+, jpg, png).
Definition: TGLViewer.cxx:832
Color_t GetColorIndex() const
Returns color-index representing the color.
Definition: TGLUtil.cxx:1240
void SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t *referencePos)
Set the state of guides (axes & reference markers) from arguments.
Definition: TGLViewer.cxx:2031
void InitSecondaryObjects()
Common initialization.
Definition: TGLViewer.cxx:238
SceneInfoList_t fScenes
Definition: TGLViewerBase.h:74
virtual void MouseIdle(TGLPhysicalShape *, UInt_t, UInt_t)
Emit MouseIdle signal.
Definition: TGLViewer.cxx:2165
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
virtual ~TGLViewer()
Destroy viewer object.
Definition: TGLViewer.cxx:272
virtual void SetupClipObject()
name says it all
Definition: TGLViewer.cxx:466
TGLPerspectiveCamera fPerspectiveCameraXOY
Definition: TGLViewer.h:89
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Calculate and return pixel distance to nearest viewer object from window location px...
Definition: TGLViewer.cxx:2187
Int_t Height() const
Definition: TGLUtil.h:457
#define NULL
Definition: Rtypes.h:82
Base class for extended scene context.
Definition: TGLSceneInfo.h:26
TGLColorSet * GetBaseColorSet()
Returns the current base color-set.
Definition: TGLRnrCtx.cxx:314
#define gPad
Definition: TVirtualPad.h:288
static Int_t GetPickingRadius()
Returns picking radius.
Definition: TGLUtil.cxx:1832
ClassImp(TSlaveInfo) Int_t TSlaveInfo const TSlaveInfo * si
Used to sort slaveinfos by ordinal.
Definition: TProof.cxx:167
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
void SetRenderTimeOut(Double_t tout)
Definition: TGLRnrCtx.h:211
static Bool_t AreSameSelectionWise(const TGLSelectRecord &r1, const TGLSelectRecord &r2)
Check if the records imply the same selection result, that is, their secondary members are all equal...
TGLPhysicalShape * GetPhysShape() const
#define GL_BGRA
Definition: TGLViewer.cxx:64
unsigned char UChar_t
Definition: RtypesCore.h:34
Double_t Z() const
Definition: TGLUtil.h:126
SceneInfoList_t::iterator SceneInfoList_i
Definition: TGLViewerBase.h:44
virtual void UnClicked(TObject *obj, UInt_t button, UInt_t state)
Emit UnClicked signal with button id and modifier state.
Definition: TGLViewer.cxx:2153
Bool_t IsEmpty() const
TGLLightSet * fLightSet
Definition: TGLViewer.h:107
void PreDraw()
Perform GL work which must be done before each draw.
Definition: TGLViewer.cxx:1208
void Start()
Start the auto-rotator.
void UseDefaultColorSet(Bool_t x)
Set usage of the default color set.
Definition: TGLViewer.cxx:1641
void SetAutoRotator(TGLAutoRotator *ar)
Set the auto-rotator for this viewer. The old rotator is deleted.
Definition: TGLViewer.cxx:1981
TGLColorSet fDarkColorSet
viewport - drawn area
Definition: TGLViewer.h:140
TGLLogicalShape * GetLogShape() const
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
Frame-buffer object.
Definition: TGLFBO.h:17
void SetViewport(const TGLRect &viewport)
Set viewport extents from passed 'viewport' rect.
Definition: TGLCamera.cxx:99
void SetColor(Int_t r, Int_t g, Int_t b, Int_t a=255)
Set color with Int_t values.
Definition: TGLUtil.cxx:1258
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
TGedEditor * fGedEditor
event handler
Definition: TGLViewer.h:120
static void ColorAlpha(const TGLColor &color, UChar_t alpha)
Set color from TGLColor and alpha value.
Definition: TGLUtil.cxx:1666
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered this element.
Definition: TGLOverlay.cxx:25
Int_t Nint(T x)
Definition: TMath.h:480
TGLColor & Foreground()
Definition: TGLUtil.h:854
TGLClipSet * fClipSet
Definition: TGLViewer.h:109
Float_t fPointScale
color-set with light background
Definition: TGLViewer.h:142
Int_t Y() const
Definition: TGLUtil.h:453
virtual void PostRender(TGLRnrCtx &rnrCtx)
Perform post-render clean-up.
Int_t CeilNint(Double_t x)
Definition: TMath.h:470
Double_t Tan(Double_t)
Definition: TMath.h:427
UInt_t ID() const
TGLPerspectiveCamera fPerspectiveCameraYOZ
Definition: TGLViewer.h:88
Bool_t fDrawCameraCenter
reference position
Definition: TGLViewer.h:150
void StdSetupLights(const TGLBoundingBox &bbox, const TGLCamera &camera, Bool_t debug=kFALSE)
Setup lights for current given bounding box and camera.
Definition: TGLLightSet.cxx:76
Double_t End()
End timing, return total time since Start(), in milliseconds.
Bool_t SavePicture()
Save current image using the default file name which can be set via SetPictureFileName() and defaults...
Definition: TGLViewer.cxx:781
void Set(Int_t x, Int_t y, Int_t width, Int_t height)
Definition: TGLUtil.h:476
const TGLPhysicalShape * GetSelected() const
Return selected physical shape.
Definition: TGLViewer.cxx:2056
TGLPShapeObj * fPShapeWrap
GED editor.
Definition: TGLViewer.h:121
const char Int_t const char * image
Definition: TXSlave.cxx:46
TGLSelectRecord fSecSelRec
select record from last select (should go to context)
Definition: TGLViewer.h:113
void DrawDebugInfo()
If in debug mode draw camera aids and overall bounding box.
Definition: TGLViewer.cxx:1182
const TGLFormat * GetPixelFormat() const
Pixel format.
Definition: TGLWidget.cxx:233
Bool_t fResetCamerasOnNextUpdate
Definition: TGLViewer.h:192
void SetGLCtxIdentity(TGLContextIdentity *cid)
Definition: TGLRnrCtx.h:255
void SetRenderScale(Float_t s)
Definition: TGLRnrCtx.h:245
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904