Logo ROOT   6.08/07
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
178  fAutoRotator(0),
179 
180  fStereo (kFALSE),
182  fStereoZeroParallax (0.03f),
183  fStereoEyeOffsetFac (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),
195  fRedrawTimer(0),
196  fMaxSceneDrawTimeHQ(5000),
197  fMaxSceneDrawTimeLQ(100),
199  fAxesType(TGLUtil::kAxesNone),
202  fReferencePos(0.0, 0.0, 0.0),
204  fCameraOverlay(0),
208  fPictureFileName("viewer.jpg"),
209  fFader(0),
210  fGLWidget(0),
211  fGLDevice(fPad->GetGLDevice()),
212  fGLCtxId(0),
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::unique_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::unique_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 
1011  TImage *image(TImage::Create());
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 
1092  TImage *image(TImage::Create());
1093  image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
1094 
1095  delete [] xx;
1096  delete fbo;
1097 
1098  if (pixel_object_scale != 0)
1099  {
1100  fRnrCtx->SetRenderScale(old_scale);
1101  }
1102 
1103  SetViewport(old_vp);
1104 
1105  return image;
1106 }
1107 
1108 
1109 ////////////////////////////////////////////////////////////////////////////////
1110 /// Save picture with given width (height scaled proportionally).
1111 /// If pixel_object_scale is true (default), the corresponding
1112 /// scaling gets calculated from the current window size.
1113 
1115  Bool_t pixel_object_scale)
1116 {
1117  Float_t scale = Float_t(width) / fViewport.Width();
1118  Int_t height = TMath::Nint(scale*fViewport.Height());
1119 
1120  return SavePictureUsingFBO(fileName, width, height, pixel_object_scale ? scale : 0);
1121 }
1122 
1123 ////////////////////////////////////////////////////////////////////////////////
1124 /// Save picture with given height (width scaled proportionally).
1125 /// If pixel_object_scale is true (default), the corresponding
1126 /// scaling gets calculated from the current window size.
1127 
1129  Bool_t pixel_object_scale)
1130 {
1131  Float_t scale = Float_t(height) / fViewport.Height();
1132  Int_t width = TMath::Nint(scale*fViewport.Width());
1133 
1134  return SavePictureUsingFBO(fileName, width, height, pixel_object_scale ? scale : 0);
1135 }
1136 
1137 ////////////////////////////////////////////////////////////////////////////////
1138 /// Save picture with given scale to current window size.
1139 /// If pixel_object_scale is true (default), the same scaling is
1140 /// used.
1141 
1143  Bool_t pixel_object_scale)
1144 {
1145  Int_t w = TMath::Nint(scale*fViewport.Width());
1146  Int_t h = TMath::Nint(scale*fViewport.Height());
1147 
1148  return SavePictureUsingFBO(fileName, w, h, pixel_object_scale ? scale : 0);
1149 }
1150 
1151 ////////////////////////////////////////////////////////////////////////////////
1152 /// Draw reference marker and coordinate axes.
1153 
1155 {
1156  Bool_t disabled = kFALSE;
1157  if (fReferenceOn)
1158  {
1159  glDisable(GL_DEPTH_TEST);
1161  disabled = kTRUE;
1162  }
1163  if (fDrawCameraCenter)
1164  {
1165  glDisable(GL_DEPTH_TEST);
1167  const UChar_t rgba[4] = { 0, 255, 255, 255 };
1168  TGLUtil::DrawSphere(fCamera->GetCenterVec(), radius, rgba);
1169  disabled = kTRUE;
1170  }
1171  if (fAxesDepthTest && disabled)
1172  {
1173  glEnable(GL_DEPTH_TEST);
1174  disabled = kFALSE;
1175  }
1176  else if (fAxesDepthTest == kFALSE && disabled == kFALSE)
1177  {
1178  glDisable(GL_DEPTH_TEST);
1179  disabled = kTRUE;
1180  }
1182  if (disabled)
1183  glEnable(GL_DEPTH_TEST);
1184 }
1185 
1186 ////////////////////////////////////////////////////////////////////////////////
1187 /// If in debug mode draw camera aids and overall bounding box.
1188 
1190 {
1191  if (fDebugMode)
1192  {
1193  glDisable(GL_LIGHTING);
1195 
1196  // Green scene bounding box
1197  glColor3d(0.0, 1.0, 0.0);
1199 
1200  // Scene bounding box center sphere (green) and
1201  glDisable(GL_DEPTH_TEST);
1202  Double_t size = fOverallBoundingBox.Extents().Mag() / 200.0;
1203  TGLUtil::DrawSphere(TGLVertex3(0.0, 0.0, 0.0), size, TGLUtil::fgWhite);
1204  const TGLVertex3 & center = fOverallBoundingBox.Center();
1205  TGLUtil::DrawSphere(center, size, TGLUtil::fgGreen);
1206  glEnable(GL_DEPTH_TEST);
1207 
1208  glEnable(GL_LIGHTING);
1209  }
1210 }
1211 
1212 ////////////////////////////////////////////////////////////////////////////////
1213 /// Perform GL work which must be done before each draw.
1214 
1216 {
1217  InitGL();
1218 
1219  // For embedded gl clear color must be pad's background color.
1220  {
1221  Color_t ci = (fGLDevice != -1) ? gPad->GetFillColor() : fRnrCtx->ColorSet().Background().GetColorIndex();
1222  TColor *color = gROOT->GetColor(ci);
1223  Float_t rgb[3];
1224  if (color)
1225  color->GetRGB(rgb[0], rgb[1], rgb[2]);
1226  else
1227  rgb[0] = rgb[1] = rgb[2] = 0.0f;
1228 
1229  glClearColor(rgb[0], rgb[1], rgb[2], 0.0f);
1230  }
1231 
1232  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1233 
1234  TGLUtil::CheckError("TGLViewer::PreDraw");
1235 }
1236 
1237 ////////////////////////////////////////////////////////////////////////////////
1238 /// Perform GL work which must be done after each draw.
1239 
1241 {
1242  glFlush();
1243  TGLUtil::CheckError("TGLViewer::PostDraw");
1244 }
1245 
1246 ////////////////////////////////////////////////////////////////////////////////
1247 /// Draw a rectangle (background color and given alpha) across the
1248 /// whole viewport.
1249 
1251 {
1252  static const Float_t z = -1.0f;
1253 
1254  glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
1255  glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
1256 
1257  {
1258  TGLCapabilitySwitch blend(GL_BLEND, kTRUE);
1259  TGLCapabilitySwitch light(GL_LIGHTING, kFALSE);
1260  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1262  glBegin(GL_QUADS);
1263  glVertex3f(-1, -1, z); glVertex3f( 1, -1, z);
1264  glVertex3f( 1, 1, z); glVertex3f(-1, 1, z);
1265  glEnd();
1266  }
1267 
1268  glMatrixMode(GL_PROJECTION); glPopMatrix();
1269  glMatrixMode(GL_MODELVIEW); glPopMatrix();
1270 }
1271 
1272 ////////////////////////////////////////////////////////////////////////////////
1273 /// Make GL context current
1274 
1276 {
1277  if (fGLDevice == -1)
1279  else
1280  gGLManager->MakeCurrent(fGLDevice);
1281 }
1282 
1283 ////////////////////////////////////////////////////////////////////////////////
1284 /// Swap GL buffers
1285 
1287 {
1288  if ( ! IsDrawOrSelectLock()) {
1289  Error("TGLViewer::SwapBuffers", "viewer is %s", LockName(CurrentLock()));
1290  }
1291  if (fGLDevice == -1)
1293  else {
1294  gGLManager->ReadGLBuffer(fGLDevice);
1295  gGLManager->Flush(fGLDevice);
1296  gGLManager->MarkForDirectCopy(fGLDevice, kFALSE);
1297  }
1298 }
1299 
1300 ////////////////////////////////////////////////////////////////////////////////
1301 /// Post request for selection render pass viewer, picking objects
1302 /// around the window point (x,y).
1303 
1305 {
1306  // Take select lock on scene immediately we enter here - it is released
1307  // in the other (drawing) thread - see TGLViewer::DoSelect()
1308 
1309  if ( ! TakeLock(kSelectLock)) {
1310  return kFALSE;
1311  }
1312 
1313  if (!gVirtualX->IsCmdThread())
1314  return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoSelect(%d, %d)", (ULong_t)this, x, y)));
1315  else
1316  return DoSelect(x, y);
1317 }
1318 
1319 ////////////////////////////////////////////////////////////////////////////////
1320 /// Perform GL selection, picking objects overlapping WINDOW
1321 /// area described by 'rect'. Return kTRUE if selection should be
1322 /// changed, kFALSE otherwise.
1323 /// Select lock should already been taken in other thread in
1324 /// TGLViewer::ReqSelect().
1325 
1327 {
1329 
1330  if (CurrentLock() != kSelectLock) {
1331  Error("TGLViewer::DoSelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1332  return kFALSE;
1333  }
1334 
1336 
1337  TUnlocker ulck(this);
1338 
1339  MakeCurrent();
1340 
1342  glRenderMode(GL_SELECT);
1343 
1344  PreRender();
1346  PostRender();
1347 
1348  Int_t nHits = glRenderMode(GL_RENDER);
1349  fRnrCtx->EndSelection(nHits);
1350 
1351  // Process selection.
1352  if (gDebug > 0) Info("TGLViewer::DoSelect", "Primary select nHits=%d.", nHits);
1353 
1354  if (nHits > 0)
1355  {
1356  Int_t idx = 0;
1357  if (FindClosestRecord(fSelRec, idx))
1358  {
1360  {
1361  TGLSelectRecord opaque;
1362  if (FindClosestOpaqueRecord(opaque, ++idx))
1363  fSelRec = opaque;
1365  fSelRec.Reset();
1366  }
1367  if (gDebug > 1) fSelRec.Print();
1368  }
1369  } else {
1370  fSelRec.Reset();
1371  }
1372 
1375 }
1376 
1377 ////////////////////////////////////////////////////////////////////////////////
1378 /// Request secondary select.
1379 
1381 {
1382  if ( ! TakeLock(kSelectLock)) {
1383  return kFALSE;
1384  }
1385 
1386  if (!gVirtualX->IsCmdThread())
1387  return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoSecondarySelect(%d, %d)", (ULong_t)this, x, y)));
1388  else
1389  return DoSecondarySelect(x, y);
1390 }
1391 
1392 ////////////////////////////////////////////////////////////////////////////////
1393 /// Secondary selection.
1394 
1396 {
1398 
1399  if (CurrentLock() != kSelectLock) {
1400  Error("TGLViewer::DoSecondarySelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1401  return kFALSE;
1402  }
1403 
1405 
1406  TUnlocker ulck(this);
1407 
1408  if (! fSelRec.GetSceneInfo() || ! fSelRec.GetPhysShape() ||
1410  {
1411  if (gDebug > 0)
1412  Info("TGLViewer::SecondarySelect", "Skipping secondary selection "
1413  "(sinfo=0x%lx, pshape=0x%lx).\n",
1415  fSecSelRec.Reset();
1416  return kFALSE;
1417  }
1418 
1419  MakeCurrent();
1420 
1421  TGLSceneInfo* sinfo = fSelRec.GetSceneInfo();
1422  TGLSceneBase* scene = sinfo->GetScene();
1424 
1425  SceneInfoList_t foo;
1426  foo.push_back(sinfo);
1427  fScenes.swap(foo);
1430  glRenderMode(GL_SELECT);
1431 
1432  PreRender();
1433  fRnrCtx->SetSceneInfo(sinfo);
1434  scene->PreRender(*fRnrCtx);
1437  glPushName(pshp->ID());
1438  // !!! Hack: does not use clipping and proper draw-pass settings.
1439  pshp->Draw(*fRnrCtx);
1440  glPopName();
1441  scene->PostRender(*fRnrCtx);
1442  fRnrCtx->SetSceneInfo(0);
1443  PostRender();
1444 
1445  Int_t nSecHits = glRenderMode(GL_RENDER);
1446  fRnrCtx->EndSelection(nSecHits);
1447  fScenes.swap(foo);
1448 
1449  if (gDebug > 0) Info("TGLViewer::DoSelect", "Secondary select nSecHits=%d.", nSecHits);
1450 
1452 
1453  if (nSecHits > 0)
1454  {
1455  fSecSelRec = fSelRec;
1457  if (gDebug > 1) fSecSelRec.Print();
1458  return kTRUE;
1459  } else {
1460  fSecSelRec.Reset();
1461  return kFALSE;
1462  }
1463 }
1464 
1465 ////////////////////////////////////////////////////////////////////////////////
1466 /// Process result from last selection (in fSelRec) and
1467 /// extract a new current selection from it.
1468 /// Here we only use physical shape.
1469 
1471 {
1473 
1474  TGLPhysicalShape *selPhys = fSelRec.GetPhysShape();
1475  fSelectedPShapeRef->SetPShape(selPhys);
1476 
1477  // Inform external client selection has been modified.
1478  SelectionChanged();
1479 
1481 }
1482 
1483 ////////////////////////////////////////////////////////////////////////////////
1484 /// Post request for secondary selection rendering of selected object
1485 /// around the window point (x,y).
1486 
1488 {
1489  // Take select lock on viewer immediately - it is released
1490  // in the other (drawing) thread - see TGLViewer::DoSecondarySelect().
1491 
1492  if ( ! TakeLock(kSelectLock)) {
1493  return kFALSE;
1494  }
1495 
1496  if (!gVirtualX->IsCmdThread())
1497  return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%lx)->DoOverlaySelect(%d, %d)", (ULong_t)this, x, y)));
1498  else
1499  return DoOverlaySelect(x, y);
1500 }
1501 
1502 ////////////////////////////////////////////////////////////////////////////////
1503 /// Perform GL selection, picking overlay objects only.
1504 /// Return TRUE if the selected overlay-element has changed.
1505 
1507 {
1509 
1510  if (CurrentLock() != kSelectLock) {
1511  Error("TGLViewer::DoOverlaySelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1512  return kFALSE;
1513  }
1514 
1516 
1517  TUnlocker ulck(this);
1518 
1519  MakeCurrent();
1520 
1522  glRenderMode(GL_SELECT);
1523 
1527 
1528  Int_t nHits = glRenderMode(GL_RENDER);
1529  fRnrCtx->EndSelection(nHits);
1530 
1531  // Process overlay selection.
1532  TGLOverlayElement * selElm = 0;
1533  if (nHits > 0)
1534  {
1535  Int_t idx = 0;
1536  while (idx < nHits && FindClosestOverlayRecord(fOvlSelRec, idx))
1537  {
1539  if (el == fCurrentOvlElm)
1540  {
1541  if (el->MouseStillInside(fOvlSelRec))
1542  {
1543  selElm = el;
1544  break;
1545  }
1546  }
1547  else if (el->MouseEnter(fOvlSelRec))
1548  {
1549  selElm = el;
1550  break;
1551  }
1552  ++idx;
1553  }
1554  }
1555  else
1556  {
1557  fOvlSelRec.Reset();
1558  }
1559 
1561 
1562  if (fCurrentOvlElm != selElm)
1563  {
1565  fCurrentOvlElm = selElm;
1566  return kTRUE;
1567  }
1568  else
1569  {
1570  return kFALSE;
1571  }
1572 }
1573 
1574 ////////////////////////////////////////////////////////////////////////////////
1575 /// Make one fading step and request redraw.
1576 
1578 {
1579  Float_t fade = fViewer->GetFader();
1580 
1581  if (fade == fFadeTarget) {
1582  delete this; return;
1583  }
1584  if (TMath::Abs(fFadeTarget - fade) < 1e-3) {
1585  fViewer->SetFader(fFadeTarget);
1586  fViewer->RequestDraw(TGLRnrCtx::kLODHigh);
1587  delete this;
1588  return;
1589  }
1590 
1591  Float_t dt = fTime/fNSteps;
1592  Float_t df = (fFadeTarget - fade)/fNSteps;
1593  fViewer->SetFader(fade + df);
1594  fViewer->RequestDraw(TGLRnrCtx::kLODHigh);
1595  fTime -= dt; --fNSteps;
1597  "TGLFaderHelper", this, "MakeFadeStep()");
1598 }
1599 
1600 ////////////////////////////////////////////////////////////////////////////////
1601 /// Animate fading from current value to fade over given time (sec)
1602 /// and number of steps.
1603 
1604 void TGLViewer::AutoFade(Float_t fade, Float_t time, Int_t steps)
1605 {
1606  TGLFaderHelper* fh = new TGLFaderHelper(this, fade, time, steps);
1607  fh->MakeFadeStep();
1608 }
1609 
1610 ////////////////////////////////////////////////////////////////////////////////
1611 /// Use the dark color-set.
1612 
1614 {
1616  RefreshPadEditor(this);
1617 }
1618 
1619 ////////////////////////////////////////////////////////////////////////////////
1620 /// Use the light color-set.
1621 
1623 {
1625  RefreshPadEditor(this);
1626 }
1627 
1628 ////////////////////////////////////////////////////////////////////////////////
1629 /// Switch between dark and light colorsets.
1630 
1632 {
1633  if (IsUsingDefaultColorSet())
1634  {
1635  Info("SwitchColorSet()", "Global color-set is in use, switch not supported.");
1636  return;
1637  }
1638 
1640  UseDarkColorSet();
1641  else
1642  UseLightColorSet();
1643 }
1644 
1645 ////////////////////////////////////////////////////////////////////////////////
1646 /// Set usage of the default color set.
1647 
1649 {
1650  if (x)
1652  else
1654  RefreshPadEditor(this);
1655 }
1656 
1657 ////////////////////////////////////////////////////////////////////////////////
1658 /// Check if the viewer is using the default color set.
1659 /// If yes, some operations might be disabled.
1660 
1662 {
1664 }
1665 
1666 ////////////////////////////////////////////////////////////////////////////////
1667 /// Set background method.
1668 /// Deprecated method - set background color in the color-set.
1669 
1671 {
1673 }
1674 
1675 ////////////////////////////////////////////////////////////////////////////////
1676 /// Returns reference to the default color-set.
1677 /// Static function.
1678 
1680 {
1681  return fgDefaultColorSet;
1682 }
1683 
1684 ////////////////////////////////////////////////////////////////////////////////
1685 /// Sets static flag that determines if new viewers should use the
1686 /// default color-set.
1687 /// This is false at startup.
1688 
1690 {
1692 }
1693 
1694 ////////////////////////////////////////////////////////////////////////////////
1695 /// Returns the value of the static flag that determines if new
1696 /// viewers should use the default color-set.
1697 /// This is false at startup.
1698 
1700 {
1702 }
1703 
1704 ////////////////////////////////////////////////////////////////////////////////
1705 /// Returns true if current color set is dark.
1706 
1708 {
1709  return fRnrCtx->GetBaseColorSet() == &fDarkColorSet;
1710 }
1711 
1712 /**************************************************************************/
1713 // Viewport
1714 /**************************************************************************/
1715 
1716 ////////////////////////////////////////////////////////////////////////////////
1717 /// Set viewer viewport (window area) with bottom/left at (x,y), with
1718 /// dimensions 'width'/'height'
1719 
1721 {
1722  if (fStereo && ! fStereoQuadBuf) width /= 2;
1723 
1724  // Only process if changed
1725  if (fViewport.X() == x && fViewport.Y() == y &&
1726  fViewport.Width() == width && fViewport.Height() == height) {
1727  return;
1728  }
1729 
1730  fViewport.Set(x, y, width, height);
1732 
1733  if (gDebug > 2) {
1734  Info("TGLViewer::SetViewport", "updated - corner %d,%d dimensions %d,%d", x, y, width, height);
1735  }
1736 }
1737 
1739 {
1740  // Set viewer viewport from TGLRect.
1741 
1742  SetViewport(vp.X(), vp.Y(), vp.Width(), vp.Height());
1743 }
1744 
1745 /**************************************************************************/
1746 // Camera methods
1747 /**************************************************************************/
1748 
1749 ////////////////////////////////////////////////////////////////////////////////
1750 /// Return camera reference by type.
1751 
1753 {
1754  // TODO: Move these into a vector!
1755  switch(cameraType) {
1756  case kCameraPerspXOZ:
1757  return fPerspectiveCameraXOZ;
1758  case kCameraPerspYOZ:
1759  return fPerspectiveCameraYOZ;
1760  case kCameraPerspXOY:
1761  return fPerspectiveCameraXOY;
1762  case kCameraOrthoXOY:
1763  return fOrthoXOYCamera;
1764  case kCameraOrthoXOZ:
1765  return fOrthoXOZCamera;
1766  case kCameraOrthoZOY:
1767  return fOrthoZOYCamera;
1768  case kCameraOrthoXnOY:
1769  return fOrthoXnOYCamera;
1770  case kCameraOrthoXnOZ:
1771  return fOrthoXnOZCamera;
1772  case kCameraOrthoZnOY:
1773  return fOrthoZnOYCamera;
1774  default:
1775  Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1776  return *fCurrentCamera;
1777  }
1778 }
1779 
1780 ////////////////////////////////////////////////////////////////////////////////
1781 /// Set current active camera - 'cameraType' one of:
1782 /// kCameraPerspX, kCameraPerspY, kCameraPerspZ,
1783 /// kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY,
1784 /// kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY
1785 
1787 {
1788  if (IsLocked()) {
1789  Error("TGLViewer::SetCurrentCamera", "expected kUnlocked, found %s", LockName(CurrentLock()));
1790  return;
1791  }
1792 
1793  // TODO: Move these into a vector!
1794  TGLCamera *prev = fCurrentCamera;
1795  switch (cameraType)
1796  {
1797  case kCameraPerspXOZ: {
1799  break;
1800  }
1801  case kCameraPerspYOZ: {
1803  break;
1804  }
1805  case kCameraPerspXOY: {
1807  break;
1808  }
1809  case kCameraOrthoXOY: {
1811  break;
1812  }
1813  case kCameraOrthoXOZ: {
1815  break;
1816  }
1817  case kCameraOrthoZOY: {
1819  break;
1820  }
1821  case kCameraOrthoXnOY: {
1823  break;
1824  }
1825  case kCameraOrthoXnOZ: {
1827  break;
1828  }
1829  case kCameraOrthoZnOY: {
1831  break;
1832  }
1833  default: {
1834  Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1835  break;
1836  }
1837  }
1838 
1839  if (fCurrentCamera != prev)
1840  {
1841  // Ensure any viewport has been propagated to the current camera
1843  RefreshPadEditor(this);
1844 
1845  if (fAutoRotator)
1846  {
1847  if (fAutoRotator->IsRunning())
1848  {
1849  fAutoRotator->Stop();
1850  }
1851  else
1852  {
1854  {
1855  fAutoRotator->Start();
1856  }
1857  }
1858  }
1859 
1861  }
1862 }
1863 
1864 ////////////////////////////////////////////////////////////////////////////////
1865 /// Set an orthographic camera to supplied configuration - note this
1866 /// does not need to be the current camera - though you will not see
1867 /// the effect if it is not.
1868 ///
1869 /// 'camera' defines the ortho camera - one of kCameraOrthoXOY / XOZ / ZOY
1870 /// 'left' / 'right' / 'top' / 'bottom' define the WORLD coordinates which
1871 /// correspond with the left/right/top/bottom positions on the GL viewer viewport
1872 /// E.g. for kCameraOrthoXOY camera left/right are X world coords,
1873 /// top/bottom are Y world coords
1874 /// As this is an orthographic camera the other axis (in eye direction) is
1875 /// no relevant. The near/far clip planes are set automatically based in scene
1876 /// contents
1877 
1879  Double_t zoom, Double_t dolly,
1880  Double_t center[3],
1881  Double_t hRotate, Double_t vRotate)
1882 {
1883  // TODO: Move these into a vector!
1884  switch(camera) {
1885  case kCameraOrthoXOY: {
1886  fOrthoXOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1887  if (fCurrentCamera == &fOrthoXOYCamera) {
1889  }
1890  break;
1891  }
1892  case kCameraOrthoXOZ: {
1893  fOrthoXOZCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1894  if (fCurrentCamera == &fOrthoXOZCamera) {
1896  }
1897  break;
1898  }
1899  case kCameraOrthoZOY: {
1900  fOrthoZOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1901  if (fCurrentCamera == &fOrthoZOYCamera) {
1903  }
1904  break;
1905  }
1906  default: {
1907  Error("TGLViewer::SetOrthoCamera", "invalid camera type");
1908  break;
1909  }
1910  }
1911 }
1912 
1913 ////////////////////////////////////////////////////////////////////////////////
1914 /// Set a perspective camera to supplied configuration - note this
1915 /// does not need to be the current camera - though you will not see
1916 /// the effect if it is not.
1917 ///
1918 /// - 'camera' defines the persp camera - one of kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY
1919 /// - 'fov' - field of view (lens angle) in degrees (clamped to 0.1 - 170.0)
1920 /// - 'dolly' - distance from 'center'
1921 /// - 'center' - world position from which dolly/hRotate/vRotate are measured
1922 /// camera rotates round this, always facing in (in center of viewport)
1923 /// - 'hRotate' - horizontal rotation from initial configuration in degrees
1924 /// - 'hRotate' - vertical rotation from initial configuration in degrees
1925 
1927  Double_t fov, Double_t dolly,
1928  Double_t center[3],
1929  Double_t hRotate, Double_t vRotate)
1930 {
1931  // TODO: Move these into a vector!
1932  switch(camera) {
1933  case kCameraPerspXOZ: {
1934  fPerspectiveCameraXOZ.Configure(fov, dolly, center, hRotate, vRotate);
1937  }
1938  break;
1939  }
1940  case kCameraPerspYOZ: {
1941  fPerspectiveCameraYOZ.Configure(fov, dolly, center, hRotate, vRotate);
1944  }
1945  break;
1946  }
1947  case kCameraPerspXOY: {
1948  fPerspectiveCameraXOY.Configure(fov, dolly, center, hRotate, vRotate);
1951  }
1952  break;
1953  }
1954  default: {
1955  Error("TGLViewer::SetPerspectiveCamera", "invalid camera type");
1956  break;
1957  }
1958  }
1959 }
1960 
1961 ////////////////////////////////////////////////////////////////////////////////
1962 /// Change base-vectors defining the camera-base transformation of current
1963 /// camera. hAxis and vAxis are the default directions for forward
1964 /// (inverted) and upwards.
1965 
1966 void TGLViewer::ReinitializeCurrentCamera(const TGLVector3& hAxis, const TGLVector3& vAxis, Bool_t redraw)
1967 {
1969  cb.Set(cb.GetTranslation(), vAxis, hAxis);
1971  if (redraw)
1972  RequestDraw();
1973 }
1974 
1975 ////////////////////////////////////////////////////////////////////////////////
1976 /// Get the auto-rotator for this viewer.
1977 
1979 {
1980  if (fAutoRotator == 0)
1981  fAutoRotator = new TGLAutoRotator(this);
1982  return fAutoRotator;
1983 }
1984 
1985 ////////////////////////////////////////////////////////////////////////////////
1986 /// Set the auto-rotator for this viewer. The old rotator is deleted.
1987 
1989 {
1990  delete fAutoRotator;
1991  fAutoRotator = ar;
1992 }
1993 
1994 ////////////////////////////////////////////////////////////////////////////////
1995 /// Enable stereo rendering.
1996 /// If quad_buf is true rendering is done into separate left and right GL
1997 /// buffers. This requires hardware support. Otherwise left and right images
1998 /// get rendered into left and right half of the window.
1999 /// Note that mouse highlighting and selection will not work exactly right
2000 /// as image for each eye gets slightly shifted and there are two different
2001 /// directions through the mouse pointer, one for each eye.
2002 
2003 void TGLViewer::SetStereo(Bool_t stereo, Bool_t quad_buf)
2004 {
2005  if (stereo != fStereo)
2006  {
2007  fStereo = stereo;
2008  fStereoQuadBuf = quad_buf;
2009  if (fStereo)
2011  else
2013  }
2015 }
2016 
2017 /**************************************************************************/
2018 // Guide methods
2019 /**************************************************************************/
2020 
2021 ////////////////////////////////////////////////////////////////////////////////
2022 /// Fetch the state of guides (axes & reference markers) into arguments
2023 
2024 void TGLViewer::GetGuideState(Int_t & axesType, Bool_t & axesDepthTest, Bool_t & referenceOn, Double_t referencePos[3]) const
2025 {
2026  axesType = fAxesType;
2027  axesDepthTest = fAxesDepthTest;
2028 
2029  referenceOn = fReferenceOn;
2030  referencePos[0] = fReferencePos.X();
2031  referencePos[1] = fReferencePos.Y();
2032  referencePos[2] = fReferencePos.Z();
2033 }
2034 
2035 ////////////////////////////////////////////////////////////////////////////////
2036 /// Set the state of guides (axes & reference markers) from arguments.
2037 
2038 void TGLViewer::SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t referencePos[3])
2039 {
2040  fAxesType = axesType;
2041  fAxesDepthTest = axesDepthTest;
2042  fReferenceOn = referenceOn;
2043  if (referencePos)
2044  fReferencePos.Set(referencePos[0], referencePos[1], referencePos[2]);
2045  if (fGLDevice != -1)
2046  gGLManager->MarkForDirectCopy(fGLDevice, kTRUE);
2047  RequestDraw();
2048 }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// Draw camera look at and rotation point.
2052 
2054 {
2055  fDrawCameraCenter = x;
2056  RequestDraw();
2057 }
2058 
2059 // Selected physical
2060 ////////////////////////////////////////////////////////////////////////////////
2061 /// Return selected physical shape.
2062 
2064 {
2065  return fSelectedPShapeRef->GetPShape();
2066 }
2067 
2068 /**************************************************************************/
2069 /**************************************************************************/
2070 
2071 ////////////////////////////////////////////////////////////////////////////////
2072 /// Emit MouseOver signal.
2073 
2075 {
2076  Emit("MouseOver(TGLPhysicalShape*)", (Long_t)shape);
2077 }
2078 
2079 ////////////////////////////////////////////////////////////////////////////////
2080 /// Emit MouseOver signal.
2081 
2083 {
2084  Long_t args[2];
2085  args[0] = (Long_t)shape;
2086  args[1] = state;
2087  Emit("MouseOver(TGLPhysicalShape*,UInt_t)", args);
2088 }
2089 
2090 ////////////////////////////////////////////////////////////////////////////////
2091 /// Emit MouseOver signal.
2092 
2094 {
2095  Long_t args[2];
2096  args[0] = (Long_t)obj;
2097  args[1] = state;
2098  Emit("MouseOver(TObject*,UInt_t)", args);
2099 }
2100 
2101 ////////////////////////////////////////////////////////////////////////////////
2102 /// Emit MouseOver signal.
2103 
2105 {
2106  Long_t args[2];
2107  args[0] = (Long_t)obj;
2108  args[1] = state;
2109  Emit("ReMouseOver(TObject*,UInt_t)", args);
2110 }
2111 
2112 
2113 ////////////////////////////////////////////////////////////////////////////////
2114 /// Emit UnMouseOver signal.
2115 
2117 {
2118  Long_t args[2];
2119  args[0] = (Long_t)obj;
2120  args[1] = state;
2121  Emit("UnMouseOver(TObject*,UInt_t)", args);
2122 }
2123 
2124 ////////////////////////////////////////////////////////////////////////////////
2125 /// Emit Clicked signal.
2126 
2128 {
2129  Emit("Clicked(TObject*)", (Long_t)obj);
2130 }
2131 
2132 ////////////////////////////////////////////////////////////////////////////////
2133 /// Emit Clicked signal with button id and modifier state.
2134 
2135 void TGLViewer::Clicked(TObject *obj, UInt_t button, UInt_t state)
2136 {
2137  Long_t args[3];
2138  args[0] = (Long_t)obj;
2139  args[1] = button;
2140  args[2] = state;
2141  Emit("Clicked(TObject*,UInt_t,UInt_t)", args);
2142 }
2143 
2144 
2145 ////////////////////////////////////////////////////////////////////////////////
2146 /// Emit ReClicked signal with button id and modifier state.
2147 
2148 void TGLViewer::ReClicked(TObject *obj, UInt_t button, UInt_t state)
2149 {
2150  Long_t args[3];
2151  args[0] = (Long_t)obj;
2152  args[1] = button;
2153  args[2] = state;
2154  Emit("ReClicked(TObject*,UInt_t,UInt_t)", args);
2155 }
2156 
2157 ////////////////////////////////////////////////////////////////////////////////
2158 /// Emit UnClicked signal with button id and modifier state.
2159 
2160 void TGLViewer::UnClicked(TObject *obj, UInt_t button, UInt_t state)
2161 {
2162  Long_t args[3];
2163  args[0] = (Long_t)obj;
2164  args[1] = button;
2165  args[2] = state;
2166  Emit("UnClicked(TObject*,UInt_t,UInt_t)", args);
2167 }
2168 
2169 ////////////////////////////////////////////////////////////////////////////////
2170 /// Emit MouseIdle signal.
2171 
2173 {
2174  Long_t args[3];
2175  static UInt_t oldx = 0, oldy = 0;
2176 
2177  if (oldx != posx || oldy != posy) {
2178  args[0] = (Long_t)shape;
2179  args[1] = posx;
2180  args[2] = posy;
2181  Emit("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", args);
2182  oldx = posx;
2183  oldy = posy;
2184  }
2185 }
2186 
2187 /**************************************************************************/
2188 /**************************************************************************/
2189 ////////////////////////////////////////////////////////////////////////////////
2190 /// Calculate and return pixel distance to nearest viewer object from
2191 /// window location px, py
2192 /// This is provided for use when embedding GL viewer into pad
2193 
2195 {
2196  // Can't track the indvidual objects in rollover. Just set the viewer as the
2197  // selected object, and return 0 (object identified) so we receive ExecuteEvent calls
2198  gPad->SetSelected(this);
2199  return 0;
2200 }
2201 
2202 ////////////////////////////////////////////////////////////////////////////////
2203 /// Process event of type 'event' - one of EEventType types,
2204 /// occurring at window location px, py
2205 /// This is provided for use when embedding GL viewer into pad
2206 
2208 {
2209  if (fEventHandler)
2210  return fEventHandler->ExecuteEvent(event, px, py);
2211 }
2212 
2213 ////////////////////////////////////////////////////////////////////////////////
2214 /// Pass viewer for print capture by TGLOutput.
2215 
2217 {
2218  TGLOutput::Capture(*this);
2219 }
2220 
2221 ////////////////////////////////////////////////////////////////////////////////
2222 /// Update GUI components for embedded viewer selection change.
2223 
2225 {
2226  if (!fGedEditor)
2227  return;
2228 
2229  TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
2230 
2231  if (selected) {
2232  fPShapeWrap->fPShape = selected;
2234  } else {
2235  fPShapeWrap->fPShape = 0;
2237  }
2238 }
2239 
2240 ////////////////////////////////////////////////////////////////////////////////
2241 /// An overlay operation can result in change to an object.
2242 /// Refresh geditor.
2243 
2245 {
2246  if (fGedEditor)
2247  {
2249  }
2250 }
2251 
2252 ////////////////////////////////////////////////////////////////////////////////
2253 /// Update GED editor if it is set.
2254 
2256 {
2257  if (fGedEditor && (obj == 0 || fGedEditor->GetModel() == obj))
2258  {
2260  }
2261 }
2262 
2263 ////////////////////////////////////////////////////////////////////////////////
2264 /// Set the event-handler. The event-handler is owned by the viewer.
2265 /// If GLWidget is set, the handler is propagated to it.
2266 ///
2267 /// If called with handler=0, the current handler will be deleted
2268 /// (also from TGLWidget).
2269 
2271 {
2272  if (fEventHandler)
2273  delete fEventHandler;
2274 
2275  fEventHandler = handler;
2276  if (fGLWidget)
2278 }
2279 
2280 ////////////////////////////////////////////////////////////////////////////////
2281 /// Remove overlay element.
2282 
2284 {
2285  if (el == fCurrentOvlElm)
2286  {
2287  fCurrentOvlElm = 0;
2288  }
2290 }
2291 
2292 ////////////////////////////////////////////////////////////////////////////////
2293 /// Reset current overlay-element to zero, eventually notifying the
2294 /// old one that the mouse has left.
2295 /// Usually called when mouse leaves the window.
2296 
2298 {
2299  if (fCurrentOvlElm)
2300  {
2302  fCurrentOvlElm = 0;
2303  RequestDraw();
2304  }
2305 }
TGEventHandler * fEventHandler
select record from last overlay select
Definition: TGLViewer.h:119
void FadeView(Float_t alpha)
Draw a rectangle (background color and given alpha) across the whole viewport.
Definition: TGLViewer.cxx:1250
Int_t fAxesType
smooth line edge rendering
Definition: TGLViewer.h:146
TGLCamera * fCurrentCamera
Definition: TGLViewer.h:96
A GL overlay element which displays camera furstum.
virtual void Stop()
Definition: TGLViewer.h:417
TGLVertex3 fReferencePos
reference marker on?
Definition: TGLViewer.h:149
void SetSecSelection(Bool_t secSel)
Definition: TGLRnrCtx.h:225
virtual void ReMouseOver(TObject *obj, UInt_t state)
Emit MouseOver signal.
Definition: TGLViewer.cxx:2104
Class encapsulating a set of colors used throughout standard rendering.
Definition: TGLUtil.h:838
TGLVertex3 Center() const
TGLSelectRecord fSelRec
select record in use as selected
Definition: TGLViewer.h:112
TString fPictureFileName
Definition: TGLViewer.h:158
Bool_t fStereoQuadBuf
use stereo rendering
Definition: TGLViewer.h:101
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:899
TGLColorSet fLightColorSet
color-set with dark background
Definition: TGLViewer.h:141
void MakeCurrent() const
Make GL context current.
Definition: TGLViewer.cxx:1275
virtual void PadPaint(TVirtualPad *pad)
Entry point for updating viewer contents via VirtualViewer3D interface.
Definition: TGLViewer.cxx:302
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
TGLPerspectiveCamera fPerspectiveCameraXOZ
Definition: TGLViewer.h:87
TGLVector3 Extents() const
virtual void PreRender()
Initialize objects that influence rendering.
Definition: TGLViewer.cxx:481
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the &#39;lock&#39; argument.
Definition: TGLLockable.cxx:51
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:1966
Int_t X() const
Definition: TGLUtil.h:451
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:214
virtual void MouseOver(TGLPhysicalShape *)
Emit MouseOver signal.
Definition: TGLViewer.cxx:2074
void SwitchColorSet()
Switch between dark and light colorsets.
Definition: TGLViewer.cxx:1631
TGLAutoRotator * fAutoRotator
Definition: TGLViewer.h:97
return c
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 &#39;pos&#39; with pixel radius &#39;radius&#39;.
Definition: TGLUtil.cxx:2440
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
const TGLFormat * GetPixelFormat() const
Pixel format.
Definition: TGLWidget.cxx:233
std::list< TGLSceneInfo * > SceneInfoList_t
Definition: TGLViewerBase.h:43
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:600
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:85
TGLLogicalShape * GetLogShape() const
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:197
void ResetCurrentCamera()
Resets position/rotation of current camera to default values.
Definition: TGLViewer.cxx:356
Double_t GetFarClip() const
Definition: TGLCamera.h:164
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:1679
TGLOrthoCamera fOrthoXOYCamera
Definition: TGLViewer.h:90
TGLCamera & RefCamera(ECameraType camera)
Return camera reference by type.
Definition: TGLViewer.cxx:1752
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:1487
virtual void SetEventHandler(TGEventHandler *handler)
Set the event-handler.
Definition: TGLViewer.cxx:2270
Int_t GetSamples() const
Get the number of samples for multi-sampling.
Definition: TGLFormat.cxx:211
Stopwatch object for timing GL work.
Definition: TGLStopwatch.h:34
Bool_t IsRunning() const
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
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 &#39;recIdx&#39;.
#define gROOT
Definition: TROOT.h:364
void SetGrabImage(Bool_t gi)
Definition: TGLRnrCtx.h:266
void MakeFadeStep()
Make one fading step and request redraw.
Definition: TGLViewer.cxx:1577
void DoDraw(Bool_t swap_buffers=kTRUE)
Draw out the viewer.
Definition: TGLViewer.cxx:546
Bool_t IsColorSetDark() const
Returns true if current color set is dark.
Definition: TGLViewer.cxx:1707
TGLSceneBase * GetScene() const
Definition: TGLSceneInfo.h:83
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:256
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:1142
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const TGLPhysicalShape * GetSelected() const
Return selected physical shape.
Definition: TGLViewer.cxx:2063
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
Int_t Y() const
Definition: TGLUtil.h:453
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:2053
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event)
Activate object editors according to the selected object.
Definition: TGedEditor.cxx:349
An abstract interface to image processing library.
Definition: TImage.h:37
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:1128
Bool_t RequestSecondarySelect(Int_t x, Int_t y)
Request secondary select.
Definition: TGLViewer.cxx:1380
virtual void UnMouseOver(TObject *obj, UInt_t state)
Emit UnMouseOver signal.
Definition: TGLViewer.cxx:2116
Float_t GetRenderScale() const
Definition: TGLRnrCtx.h:244
TGLPhysicalShape * GetPShape() const
Definition: TGLPShapeRef.h:36
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)
Perspective projection camera - with characteristic foreshortening.
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 GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition: TColor.h:54
Double_t Aspect() const
Definition: TGLUtil.h:505
virtual Bool_t SupportsSecondarySelect() const
TGLCamera * GetCamera() const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Process event of type &#39;event&#39; - one of EEventType types, occurring at window location px...
Definition: TGLViewer.cxx:2207
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:1622
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:1689
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:1878
void SetClearColor(Color_t col)
Set background method.
Definition: TGLViewer.cxx:1670
Concrete physical shape - a GL drawable.
Bool_t IsEmpty() const
TGLCamera & CurrentCamera() const
Definition: TGLViewer.h:267
virtual void Render()
Normal rendering, used by mono and stereo rendering.
Definition: TGLViewer.cxx:515
void SetAsReadBuffer()
Definition: TGLFBO.cxx:261
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:1604
virtual Bool_t IsPerspective() const
Definition: TGLCamera.h:119
static TGLColorSet fgDefaultColorSet
fade the view (0 - no fade/default, 1 - full fade/no rendering done)
Definition: TGLViewer.h:161
TGLPhysicalShape * GetPhysShape() const
void Release(TGLContext *ctx)
Remove context ctx from the list of references.
Definition: TGLContext.cxx:496
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 TObject * GetModel() const
Definition: TGedEditor.h:98
virtual void PostRenderOverlaySelection()
Perform cleanup after overlay selection.
virtual void OverlayDragFinished()
An overlay operation can result in change to an object.
Definition: TGLViewer.cxx:2244
Bool_t fDebugMode
cache logicals during scene rebuilds
Definition: TGLViewer.h:156
TGLRedrawTimer * fRedrawTimer
Definition: TGLViewer.h:135
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 &#39;origin&#39; and the local Z axis in direction &#39;z&#39;...
Definition: TGLUtil.cxx:764
virtual void ReleaseViewer3D(Option_t *type="")=0
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:86
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 &#39;position&#39;, with radius &#39;radius&#39;, color &#39;rgba&#39;.
Definition: TGLUtil.cxx:2318
virtual void PostSceneBuildSetup(Bool_t resetCameras)
Perform post scene-build setup.
Definition: TGLViewer.cxx:390
Bool_t GetGrabImage() const
Definition: TGLRnrCtx.h:267
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)=0
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:1240
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
Definition: TGLWidget.cxx:558
Short_t SelectTransparents() const
Definition: TGLRnrCtx.h:227
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
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2221
virtual void RenderSelectedForHighlight()
Render selected objects from all scenes for highlight.
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:426
Bool_t fResetCamerasOnUpdate
Definition: TGLViewer.h:191
void SwapBuffers() const
Swap GL buffers.
Definition: TGLViewer.cxx:1286
Bool_t DoSecondarySelect(Int_t x, Int_t y)
Secondary selection.
Definition: TGLViewer.cxx:1395
virtual Bool_t MouseStillInside(TGLOvlSelectRecord &selRec)
Definition: TGLOverlay.cxx:30
3 component (x/y/z) vector class.
Definition: TGLUtil.h:250
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
Definition: TGLViewer.cxx:2283
TVirtualPad * fPad
Definition: TGLViewer.h:80
void DrawGuides()
Draw reference marker and coordinate axes.
Definition: TGLViewer.cxx:1154
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:1470
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:561
virtual void PadPaintFromViewer(TGLViewer *viewer)
Entry point for requesting update of scene&#39;s contents from gl-viewer.
void SwapBuffers()
Swap buffers.
Definition: TGLWidget.cxx:217
TGLManipSet * fSelectedPShapeRef
select record from last secondary select (should go to context)
Definition: TGLViewer.h:114
Bool_t GetClipAutoUpdate() const
Definition: TGLViewer.h:263
Float_t fMaxSceneDrawTimeLQ
max time for scene rendering at high LOD (in ms)
Definition: TGLViewer.h:137
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
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 &#39;box&#39; 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:1926
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
TGLVector3 GetTranslation() const
Return the translation component of matrix.
Definition: TGLUtil.cxx:822
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by &#39;box&#39; and call Reset() to initialise...
TGLPhysicalShape * fPShape
Definition: TGLPShapeObj.h:23
Bool_t IsUsingDefaultColorSet() const
Check if the viewer is using the default color set.
Definition: TGLViewer.cxx:1661
Automatically rotates GL camera.
TGLAutoRotator * GetAutoRotator()
Get the auto-rotator for this viewer.
Definition: TGLViewer.cxx:1978
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail &#39;LOD&#39; Request is directed via cross thread gVirt...
Definition: TGLViewer.cxx:436
Double_t Mag() const
Definition: TGLUtil.h:303
virtual void PrintObjects()
Pass viewer for print capture by TGLOutput.
Definition: TGLViewer.cxx:2216
TVirtualPad * GetPad() const
Definition: TGLScenePad.h:67
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:1304
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:1699
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
static const UChar_t fgWhite[4]
Definition: TGLUtil.h:1055
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:496
Standard selection record including information about containing scene and details ob out selected ob...
TGLMatrix & RefCamBase()
Definition: TGLCamera.h:169
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:73
Int_t fGLDevice
Definition: TGLViewer.h:186
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:2024
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Clicked(TObject *obj)
Emit Clicked signal.
Definition: TGLViewer.cxx:2127
TGLRect fViewport
max time for scene rendering at high LOD (in ms)
Definition: TGLViewer.h:139
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
Bool_t IsDrawOrSelectLock() const
Definition: TGLLockable.h:63
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:1506
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
EDragAction fDragAction
Definition: TGLViewer.h:132
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:139
ELock CurrentLock() const
Definition: TGLLockable.h:61
void DeleteGLResources()
Delete GL resources registered for destruction.
Definition: TGLContext.cxx:522
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:1613
virtual void PostRender()
Function called after rendering is finished.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
Bool_t fSmoothPoints
width scale for lines
Definition: TGLViewer.h:144
void SetStereo(Bool_t stereo, Bool_t quad_buf=kTRUE)
Enable stereo rendering.
Definition: TGLViewer.cxx:2003
#define gVirtualX
Definition: TVirtualX.h:362
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 &#39;rect&#39;.
Definition: TGLViewer.cxx:1326
TGLColorSet * ChangeBaseColorSet(TGLColorSet *set)
Change the default/bottom color-set.
Definition: TGLRnrCtx.cxx:304
Int_t Width() const
Definition: TGLUtil.h:455
friend class TGLAutoRotator
Definition: TGLViewer.h:60
static const UChar_t fgGreen[4]
Definition: TGLUtil.h:1052
#define R__LOCKGUARD2(mutex)
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:39
void Print()
Print contents of the select record to stdout.
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
virtual void PreRenderOverlaySelection()
Perform minimal initialization for overlay selection.
Bool_t MakeCurrent()
Make the gl-context current.
Definition: TGLWidget.cxx:201
static Bool_t Capture(TGLViewer &viewer, EFormat format, const char *filePath=0)
Capture viewer to file.
Definition: TGLOutput.cxx:46
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.
Double_t Z() const
Definition: TGLUtil.h:126
TImage * GetPictureUsingBB()
Returns current image.
Definition: TGLViewer.cxx:983
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
UInt_t ID() const
static const char * LockName(ELock lock)
Return name-string for given lock-type.
Definition: TGLLockable.cxx:69
#define ClassImp(name)
Definition: Rtypes.h:279
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:370
TGLSceneInfo * GetSceneInfo() const
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:1114
double Double_t
Definition: RtypesCore.h:55
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 &#39;width&#39;/&#39;height&#39;.
Definition: TGLViewer.cxx:1720
TGLSceneInfo * AddScene(TGLSceneBase *scene)
Add new scene, appropriate scene-info is created.
TGLOrthoCamera fOrthoXnOYCamera
Definition: TGLViewer.h:93
EPushAction fPushAction
Definition: TGLViewer.h:131
void BeginSelection(Int_t x, Int_t y, Int_t r=3)
Setup context for running selection.
Definition: TGLRnrCtx.cxx:205
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
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:2224
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:35
virtual void ReClicked(TObject *obj, UInt_t button, UInt_t state)
Emit ReClicked signal with button id and modifier state.
Definition: TGLViewer.cxx:2148
Color_t GetColorIndex() const
Returns color-index representing the color.
Definition: TGLUtil.cxx:1240
Bool_t fReferenceOn
remove guides hidden-lines
Definition: TGLViewer.h:148
#define gGLManager
Definition: TVirtualGL.h:168
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
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 FindClosestOverlayRecord(TGLOvlSelectRecord &rec, Int_t &recIdx)
Find next overlay-select record that can be resolved, starting from position &#39;recIdx&#39;.
void SetCurrentCamera(ECameraType camera)
Set current active camera - &#39;cameraType&#39; one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1786
TGLCameraOverlay * fCameraOverlay
reference marker on?
Definition: TGLViewer.h:151
virtual void MergeSceneBBoxes(TGLBoundingBox &bbox)
Merge bounding-boxes of all active registered scenes.
Bool_t fIgnoreSizesOnUpdate
for embedded gl viewer
Definition: TGLViewer.h:190
void AddRef(TGLContext *ctx)
Add context ctx to the list of references.
Definition: TGLContext.cxx:487
TContextMenu * fContextMenu
external pad - remove replace with signal
Definition: TGLViewer.h:83
Bool_t IsLocked() const
Definition: TGLLockable.h:60
TImage * GetPictureUsingFBO(Int_t w, Int_t h, Float_t pixel_object_scale=0)
Returns current image.
Definition: TGLViewer.cxx:1030
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.
Double_t GetNearClip() const
Definition: TGLCamera.h:163
Mother of all ROOT objects.
Definition: TObject.h:37
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
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
TGLViewer(const TGLViewer &)
Float_t fStereoFrustumAsymFac
Definition: TGLViewer.h:104
virtual void RefreshPadEditor(TObject *obj=0)
Update GED editor if it is set.
Definition: TGLViewer.cxx:2255
Bool_t GetTransparent() const
void ClearCurrentOvlElm()
Reset current overlay-element to zero, eventually notifying the old one that the mouse has left...
Definition: TGLViewer.cxx:2297
Bool_t SavePictureUsingBB(const TString &fileName)
Save current image in various formats (gif, gif+, jpg, png).
Definition: TGLViewer.cxx:832
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:2038
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:2172
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:2194
#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:289
static Int_t GetPickingRadius()
Returns picking radius.
Definition: TGLUtil.cxx:1832
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...
Bool_t TakeLock(ELock lock) const
Lock the object in mode &#39;lock&#39;.
Definition: TGLLockable.cxx:32
#define GL_BGRA
Definition: TGLViewer.cxx:64
unsigned char UChar_t
Definition: RtypesCore.h:34
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:2160
TGLLightSet * fLightSet
Definition: TGLViewer.h:107
void PreDraw()
Perform GL work which must be done before each draw.
Definition: TGLViewer.cxx:1215
void Start()
Start the auto-rotator.
Int_t Height() const
Definition: TGLUtil.h:457
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
void UseDefaultColorSet(Bool_t x)
Set usage of the default color set.
Definition: TGLViewer.cxx:1648
void SetAutoRotator(TGLAutoRotator *ar)
Set the auto-rotator for this viewer. The old rotator is deleted.
Definition: TGLViewer.cxx:1988
TGLColorSet fDarkColorSet
viewport - drawn area
Definition: TGLViewer.h:140
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
Frame-buffer object.
Definition: TGLFBO.h:17
TGLSelectBuffer * GetSelectBuffer() const
Definition: TGLRnrCtx.h:231
void SetViewport(const TGLRect &viewport)
Set viewport extents from passed &#39;viewport&#39; 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
TGedEditor * fGedEditor
event handler
Definition: TGLViewer.h:120
Double_t Y() const
Definition: TGLUtil.h:124
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
Bool_t fSmartRefresh
markup size of viewport in scene units
Definition: TGLViewer.h:153
TGLColor & Foreground()
Definition: TGLUtil.h:854
TGLClipSet * fClipSet
Definition: TGLViewer.h:109
Float_t fPointScale
color-set with light background
Definition: TGLViewer.h:142
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
TGLPerspectiveCamera fPerspectiveCameraYOZ
Definition: TGLViewer.h:88
Bool_t fDrawCameraCenter
reference position
Definition: TGLViewer.h:150
TGLOverlayElement * GetOvlElement() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:911
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
TGLPShapeObj * fPShapeWrap
GED editor.
Definition: TGLViewer.h:121
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:1189
const char * Data() const
Definition: TString.h:349
Bool_t fResetCamerasOnNextUpdate
Definition: TGLViewer.h:192
void DrawDebugAids() const
Draw out some debugging aids for the camera:
Definition: TGLCamera.cxx:793
void SetGLCtxIdentity(TGLContextIdentity *cid)
Definition: TGLRnrCtx.h:255
void SetRenderScale(Float_t s)
Definition: TGLRnrCtx.h:245
Double_t X() const
Definition: TGLUtil.h:122