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