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