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
98 Int_t width, Int_t height) :
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
113 fAutoRotator(nullptr),
114
115 fStereo (kFALSE),
117 fStereoZeroParallax (0.03f),
118 fStereoEyeOffsetFac (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),
130 fRedrawTimer(nullptr),
134 fAxesType(TGLUtil::kAxesNone),
137 fReferencePos(0.0, 0.0, 0.0),
139 fCameraOverlay(nullptr),
143 fPictureFileName("viewer.jpg"),
144 fFader(0),
145 fGLWidget(nullptr),
146 fGLDevice(-1),
147 fGLCtxId(nullptr),
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
159 SetViewport(x, y, width, height);
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
179 fAutoRotator(nullptr),
180
181 fStereo (kFALSE),
183 fStereoZeroParallax (0.03f),
184 fStereoEyeOffsetFac (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),
196 fRedrawTimer(nullptr),
200 fAxesType(TGLUtil::kAxesNone),
203 fReferencePos(0.0, 0.0, 0.0),
205 fCameraOverlay(nullptr),
209 fPictureFileName("viewer.jpg"),
210 fFader(0),
211 fGLWidget(nullptr),
212 fGLDevice(fPad->GetGLDevice()),
213 fGLCtxId(nullptr),
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
240{
242 fClipSet = new TGLClipSet;
244
246 fSelectedPShapeRef->SetDrawBBox(kTRUE);
248
249 fPShapeWrap = new TGLPShapeObj(nullptr, this);
250
251 fLightColorSet.StdLightBackground();
253 fRnrCtx->ChangeBaseColorSet(&fgDefaultColorSet);
254 } else {
255 if (fPad) {
256 fRnrCtx->ChangeBaseColorSet(&fLightColorSet);
257 fLightColorSet.Background().SetColor(fPad->GetFillColor());
258 fLightColorSet.Foreground().SetColor(fPad->GetLineColor());
259 } else {
260 fRnrCtx->ChangeBaseColorSet(&fDarkColorSet);
261 }
262 }
263
266
267 fRedrawTimer = new TGLRedrawTimer(*this);
268}
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)
290 fPad->ReleaseViewer3D();
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.
338 fRedrawTimer->Stop();
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()) {
376 fPerspectiveCameraYOZ.Setup(box, reset);
377 fPerspectiveCameraXOZ.Setup(box, reset);
378 fPerspectiveCameraXOY.Setup(box, reset);
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{
439 fRedrawTimer->Stop();
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
468{
469 if (GetClipAutoUpdate())
470 {
471 fClipSet->SetupCurrentClip(fOverallBoundingBox);
472 }
473 else
474 {
475 fClipSet->SetupCurrentClipIfInvalid(fOverallBoundingBox);
476 }
477}
478////////////////////////////////////////////////////////////////////////////////
479/// Initialize objects that influence rendering.
480/// Called before every render.
481
483{
485 fClip = fClipSet->GetCurrentClip();
486 if (fGLDevice != -1)
487 {
488 fRnrCtx->SetGLCtxIdentity(fGLCtxId);
489 fGLCtxId->DeleteGLResources();
490 }
491
493 TGLUtil::SetLineWidthScale(fLineScale * fRnrCtx->GetRenderScale());
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
556 fRedrawTimer->Stop();
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
586 fRnrCtx->SetRenderTimeOut(fLOD == TGLRnrCtx::kLODHigh ?
589
590 if (fStereo && fCurrentCamera->IsPerspective() && !fRnrCtx->GetGrabImage() &&
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.
611 fRedrawTimer->RequestDraw(0, fLOD);
612 }
613
614 if (fLOD != TGLRnrCtx::kLODHigh &&
616 {
617 // Request final draw pass.
618 fRedrawTimer->RequestDraw(100, TGLRnrCtx::kLODHigh);
619 }
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// Draw out in monoscopic mode.
624
626{
627 MakeCurrent();
628
629 if (!fIsPrinting) PreDraw();
630 PreRender();
631
632 fRnrCtx->StartStopwatch();
633 if (fFader < 1)
634 {
635 Render();
636 }
637 fRnrCtx->StopStopwatch();
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
706 fRnrCtx->StartStopwatch();
707 if (fFader < 1)
708 {
709 Render();
710 }
711 fRnrCtx->StopStopwatch();
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
745 fRnrCtx->StartStopwatch();
746 if (fFader < 1)
747 {
748 Render();
749 }
750 fRnrCtx->StopStopwatch();
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 {
816 return SavePictureUsingFBO(fileName, fViewport.Width(), fViewport.Height(), kFALSE);
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
852 fRnrCtx->SetGrabImage(kTRUE);
853
854 if (!gVirtualX->IsCmdThread())
855 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
856 else
857 DoDraw(kFALSE);
858
859 fRnrCtx->SetGrabImage(kFALSE);
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
868 std::unique_ptr<TImage> image(TImage::Create());
869 image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
870 image->WriteImage(fileName);
871
872 delete [] xx;
873
874 return kTRUE;
875}
876
877////////////////////////////////////////////////////////////////////////////////
878/// Save current image in various formats (gif, gif+, jpg, png).
879/// 'gif+' will append image to an existing file (animated gif).
880/// Frame-Buffer-Object is used for capturing of the image - OpenGL
881/// 1.5 is required.
882/// The viewer window does not have to be visible at all.
883/// Returns false if something obvious goes wrong, true otherwise.
884///
885/// pixel_object_scale is used to scale (as much as possible) the
886/// objects whose representation size is pixel based (point-sizes,
887/// line-widths, bitmap/pixmap font-sizes).
888/// If set to 0 (default) no scaling is applied.
889
891 Float_t pixel_object_scale)
892{
893 static const TString eh("TGLViewer::SavePictureUsingFBO");
894
895 if (! fileName.EndsWith(".gif") && ! fileName.Contains(".gif+") &&
896 ! fileName.EndsWith(".jpg") && ! fileName.EndsWith(".png"))
897 {
898 Warning(eh, "file %s cannot be saved with this extension.", fileName.Data());
899 return kFALSE;
900 }
901
902 if ( ! TakeLock(kDrawLock)) {
903 Error(eh, "viewer locked - try later.");
904 return kFALSE;
905 }
906
907 TUnlocker ulck(this);
908
909 MakeCurrent();
910
911 TGLFBO *fbo = new TGLFBO();
912 try
913 {
914 fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
915 }
916 catch (std::runtime_error& exc)
917 {
918 Error(eh, "%s",exc.what());
919 if (gEnv->GetValue("OpenGL.SavePictureFallbackToBB", 1)) {
920 Info(eh, "Falling back to saving image via back-buffer. Window must be fully visible.");
921 if (w != fViewport.Width() || h != fViewport.Height())
922 Warning(eh, "Back-buffer does not support image scaling, window size will be used.");
923 return SavePictureUsingBB(fileName);
924 } else {
925 return kFALSE;
926 }
927 }
928
929 TGLRect old_vp(fViewport);
930 SetViewport(0, 0, w, h);
931
932 Float_t old_scale = 1;
933 if (pixel_object_scale != 0)
934 {
935 old_scale = fRnrCtx->GetRenderScale();
936 fRnrCtx->SetRenderScale(old_scale * pixel_object_scale);
937 }
938
939 fbo->Bind();
940
942 fRnrCtx->SetGrabImage(kTRUE);
943
944 if (!gVirtualX->IsCmdThread())
945 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
946 else
947 DoDraw(kFALSE);
948
949 fRnrCtx->SetGrabImage(kFALSE);
950
951 fbo->Unbind();
952
953 fbo->SetAsReadBuffer();
954
955 UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
956 glPixelStorei(GL_PACK_ALIGNMENT, 1);
957 glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
958 GL_BGRA, GL_UNSIGNED_BYTE, xx);
959
960 std::unique_ptr<TImage> image(TImage::Create());
961 image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
962 image->WriteImage(fileName);
963
964 delete [] xx;
965
966 delete fbo;
967
968 if (pixel_object_scale != 0)
969 {
970 fRnrCtx->SetRenderScale(old_scale);
971 }
972
973 SetViewport(old_vp);
974
975 return kTRUE;
976}
977
978////////////////////////////////////////////////////////////////////////////////
979/// Returns current image.
980/// Back-Buffer is used for capturing of the image.
981/// The viewer window most be fully contained within the desktop but
982/// can be covered by other windows.
983
985{
986 static const TString eh("TGLViewer::GetPictureUsingBB");
987
988 if ( ! TakeLock(kDrawLock)) {
989 Error(eh, "viewer locked - try later.");
990 return nullptr;
991 }
992
993 TUnlocker ulck(this);
994
996 fRnrCtx->SetGrabImage(kTRUE);
997
998 if (!gVirtualX->IsCmdThread())
999 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
1000 else
1001 DoDraw(kFALSE);
1002
1003 fRnrCtx->SetGrabImage(kFALSE);
1004
1005 glReadBuffer(GL_BACK);
1006
1007 UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
1008 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1009 glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
1010 GL_BGRA, GL_UNSIGNED_BYTE, xx);
1011
1012 TImage *image(TImage::Create());
1013 image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
1014
1015 delete [] xx;
1016
1017 return image;
1018}
1019
1020////////////////////////////////////////////////////////////////////////////////
1021/// Returns current image.
1022/// Frame-Buffer-Object is used for capturing of the image - OpenGL
1023/// 1.5 is required.
1024/// The viewer window does not have to be visible at all.
1025///
1026/// pixel_object_scale is used to scale (as much as possible) the
1027/// objects whose representation size is pixel based (point-sizes,
1028/// line-widths, bitmap/pixmap font-sizes).
1029/// If set to 0 (default) no scaling is applied.
1030
1032{
1033 static const TString eh("TGLViewer::GetPictureUsingFBO");
1034
1035 if ( ! TakeLock(kDrawLock)) {
1036 Error(eh, "viewer locked - try later.");
1037 return nullptr;
1038 }
1039
1040 TUnlocker ulck(this);
1041
1042 MakeCurrent();
1043
1044 TGLFBO *fbo = new TGLFBO();
1045 try
1046 {
1047 fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
1048 }
1049 catch (std::runtime_error& exc)
1050 {
1051 Error(eh, "%s",exc.what());
1052 if (gEnv->GetValue("OpenGL.GetPictureFallbackToBB", 1)) {
1053 Info(eh, "Falling back to saving image via back-buffer. Window must be fully visible.");
1054 if (w != fViewport.Width() || h != fViewport.Height())
1055 Warning(eh, "Back-buffer does not support image scaling, window size will be used.");
1056 return GetPictureUsingBB();
1057 } else {
1058 return nullptr;
1059 }
1060 }
1061
1062 TGLRect old_vp(fViewport);
1063 SetViewport(0, 0, w, h);
1064
1065 Float_t old_scale = 1;
1066 if (pixel_object_scale != 0)
1067 {
1068 old_scale = fRnrCtx->GetRenderScale();
1069 fRnrCtx->SetRenderScale(old_scale * pixel_object_scale);
1070 }
1071
1072 fbo->Bind();
1073
1075 fRnrCtx->SetGrabImage(kTRUE);
1076
1077 if (!gVirtualX->IsCmdThread())
1078 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
1079 else
1080 DoDraw(kFALSE);
1081
1082 fRnrCtx->SetGrabImage(kFALSE);
1083
1084 fbo->Unbind();
1085
1086 fbo->SetAsReadBuffer();
1087
1088 UChar_t* xx = new UChar_t[4 * fViewport.Width() * fViewport.Height()];
1089 glPixelStorei(GL_PACK_ALIGNMENT, 1);
1090 glReadPixels(0, 0, fViewport.Width(), fViewport.Height(),
1091 GL_BGRA, GL_UNSIGNED_BYTE, xx);
1092
1093 TImage *image(TImage::Create());
1094 image->FromGLBuffer(xx, fViewport.Width(), fViewport.Height());
1095
1096 delete [] xx;
1097 delete fbo;
1098
1099 if (pixel_object_scale != 0)
1100 {
1101 fRnrCtx->SetRenderScale(old_scale);
1102 }
1103
1104 SetViewport(old_vp);
1105
1106 return image;
1107}
1108
1109
1110////////////////////////////////////////////////////////////////////////////////
1111/// Save picture with given width (height scaled proportionally).
1112/// If pixel_object_scale is true (default), the corresponding
1113/// scaling gets calculated from the current window size.
1114
1116 Bool_t pixel_object_scale)
1117{
1118 Float_t scale = Float_t(width) / fViewport.Width();
1119 Int_t height = TMath::Nint(scale*fViewport.Height());
1120
1121 return SavePictureUsingFBO(fileName, width, height, pixel_object_scale ? scale : 0);
1122}
1123
1124////////////////////////////////////////////////////////////////////////////////
1125/// Save picture with given height (width 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(height) / fViewport.Height();
1133 Int_t width = TMath::Nint(scale*fViewport.Width());
1134
1135 return SavePictureUsingFBO(fileName, width, height, pixel_object_scale ? scale : 0);
1136}
1137
1138////////////////////////////////////////////////////////////////////////////////
1139/// Save picture with given scale to current window size.
1140/// If pixel_object_scale is true (default), the same scaling is
1141/// used.
1142
1144 Bool_t pixel_object_scale)
1145{
1146 Int_t w = TMath::Nint(scale*fViewport.Width());
1147 Int_t h = TMath::Nint(scale*fViewport.Height());
1148
1149 return SavePictureUsingFBO(fileName, w, h, pixel_object_scale ? scale : 0);
1150}
1151
1152////////////////////////////////////////////////////////////////////////////////
1153/// Draw reference marker and coordinate axes.
1154
1156{
1157 Bool_t disabled = kFALSE;
1158 if (fReferenceOn)
1159 {
1160 glDisable(GL_DEPTH_TEST);
1162 disabled = kTRUE;
1163 }
1165 {
1166 glDisable(GL_DEPTH_TEST);
1167 Float_t radius = fCamera->ViewportDeltaToWorld(TGLVertex3(fCamera->GetCenterVec()), 3, 3).Mag();
1168 const UChar_t rgba[4] = { 0, 255, 255, 255 };
1169 TGLUtil::DrawSphere(fCamera->GetCenterVec(), radius, rgba);
1170 disabled = kTRUE;
1171 }
1172 if (fAxesDepthTest && disabled)
1173 {
1174 glEnable(GL_DEPTH_TEST);
1175 disabled = kFALSE;
1176 }
1177 else if (fAxesDepthTest == kFALSE && disabled == kFALSE)
1178 {
1179 glDisable(GL_DEPTH_TEST);
1180 disabled = kTRUE;
1181 }
1183 if (disabled)
1184 glEnable(GL_DEPTH_TEST);
1185}
1186
1187////////////////////////////////////////////////////////////////////////////////
1188/// If in debug mode draw camera aids and overall bounding box.
1189
1191{
1192 if (fDebugMode)
1193 {
1194 glDisable(GL_LIGHTING);
1196
1197 // Green scene bounding box
1198 glColor3d(0.0, 1.0, 0.0);
1199 fOverallBoundingBox.Draw();
1200
1201 // Scene bounding box center sphere (green) and
1202 glDisable(GL_DEPTH_TEST);
1203 Double_t size = fOverallBoundingBox.Extents().Mag() / 200.0;
1205 const TGLVertex3 & center = fOverallBoundingBox.Center();
1207 glEnable(GL_DEPTH_TEST);
1208
1209 glEnable(GL_LIGHTING);
1210 }
1211}
1212
1213////////////////////////////////////////////////////////////////////////////////
1214/// Perform GL work which must be done before each draw.
1215
1217{
1218 InitGL();
1219
1220 // For embedded gl clear color must be pad's background color.
1221 {
1222 Color_t ci = (fGLDevice != -1) ? gPad->GetFillColor() : fRnrCtx->ColorSet().Background().GetColorIndex();
1223 TColor *color = gROOT->GetColor(ci);
1224 Float_t rgb[3];
1225 if (color)
1226 color->GetRGB(rgb[0], rgb[1], rgb[2]);
1227 else
1228 rgb[0] = rgb[1] = rgb[2] = 0.0f;
1229
1230 glClearColor(rgb[0], rgb[1], rgb[2], 0.0f);
1231 }
1232
1233 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1234
1235 TGLUtil::CheckError("TGLViewer::PreDraw");
1236}
1237
1238////////////////////////////////////////////////////////////////////////////////
1239/// Perform GL work which must be done after each draw.
1240
1242{
1243 glFlush();
1244 TGLUtil::CheckError("TGLViewer::PostDraw");
1245}
1246
1247////////////////////////////////////////////////////////////////////////////////
1248/// Draw a rectangle (background color and given alpha) across the
1249/// whole viewport.
1250
1252{
1253 static const Float_t z = -1.0f;
1254
1255 glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
1256 glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
1257
1258 {
1259 TGLCapabilitySwitch blend(GL_BLEND, kTRUE);
1260 TGLCapabilitySwitch light(GL_LIGHTING, kFALSE);
1261 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1262 TGLUtil::ColorAlpha(fRnrCtx->ColorSet().Background(), alpha);
1263 glBegin(GL_QUADS);
1264 glVertex3f(-1, -1, z); glVertex3f( 1, -1, z);
1265 glVertex3f( 1, 1, z); glVertex3f(-1, 1, z);
1266 glEnd();
1267 }
1268
1269 glMatrixMode(GL_PROJECTION); glPopMatrix();
1270 glMatrixMode(GL_MODELVIEW); glPopMatrix();
1271}
1272
1273////////////////////////////////////////////////////////////////////////////////
1274/// Make GL context current
1275
1277{
1278 if (fGLDevice == -1)
1279 fGLWidget->MakeCurrent();
1280 else
1281 gGLManager->MakeCurrent(fGLDevice);
1282}
1283
1284////////////////////////////////////////////////////////////////////////////////
1285/// Swap GL buffers
1286
1288{
1289 if ( ! IsDrawOrSelectLock()) {
1290 Error("TGLViewer::SwapBuffers", "viewer is %s", LockName(CurrentLock()));
1291 }
1292 if (fGLDevice == -1)
1293 fGLWidget->SwapBuffers();
1294 else {
1295 gGLManager->ReadGLBuffer(fGLDevice);
1296 gGLManager->Flush(fGLDevice);
1297 gGLManager->MarkForDirectCopy(fGLDevice, kFALSE);
1298 }
1299}
1300
1301////////////////////////////////////////////////////////////////////////////////
1302/// Post request for selection render pass viewer, picking objects
1303/// around the window point (x,y).
1304
1306{
1307 // Take select lock on scene immediately we enter here - it is released
1308 // in the other (drawing) thread - see TGLViewer::DoSelect()
1309
1310 if ( ! TakeLock(kSelectLock)) {
1311 return kFALSE;
1312 }
1313
1314 if (!gVirtualX->IsCmdThread())
1315 return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoSelect(%d, %d)", (size_t)this, x, y)));
1316 else
1317 return DoSelect(x, y);
1318}
1319
1320////////////////////////////////////////////////////////////////////////////////
1321/// Perform GL selection, picking objects overlapping WINDOW
1322/// area described by 'rect'. Return kTRUE if selection should be
1323/// changed, kFALSE otherwise.
1324/// Select lock should already been taken in other thread in
1325/// TGLViewer::ReqSelect().
1326
1328{
1330
1331 if (CurrentLock() != kSelectLock) {
1332 Error("TGLViewer::DoSelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1333 return kFALSE;
1334 }
1335
1337
1338 TUnlocker ulck(this);
1339
1340 MakeCurrent();
1341
1342 fRnrCtx->BeginSelection(x, y, TGLUtil::GetPickingRadius());
1343 glRenderMode(GL_SELECT);
1344
1345 PreRender();
1347 PostRender();
1348
1349 Int_t nHits = glRenderMode(GL_RENDER);
1350 fRnrCtx->EndSelection(nHits);
1351
1352 // Process selection.
1353 if (gDebug > 0) Info("TGLViewer::DoSelect", "Primary select nHits=%d.", nHits);
1354
1355 if (nHits > 0)
1356 {
1357 Int_t idx = 0;
1358 if (FindClosestRecord(fSelRec, idx))
1359 {
1360 if (fSelRec.GetTransparent() && fRnrCtx->SelectTransparents() != TGLRnrCtx::kIfClosest)
1361 {
1362 TGLSelectRecord opaque;
1363 if (FindClosestOpaqueRecord(opaque, ++idx))
1364 fSelRec = opaque;
1365 else if (fRnrCtx->SelectTransparents() == TGLRnrCtx::kNever)
1366 fSelRec.Reset();
1367 }
1368 if (gDebug > 1) fSelRec.Print();
1369 }
1370 } else {
1371 fSelRec.Reset();
1372 }
1373
1376}
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Request secondary select.
1380
1382{
1383 if ( ! TakeLock(kSelectLock)) {
1384 return kFALSE;
1385 }
1386
1387 if (!gVirtualX->IsCmdThread())
1388 return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoSecondarySelect(%d, %d)", (size_t)this, x, y)));
1389 else
1390 return DoSecondarySelect(x, y);
1391}
1392
1393////////////////////////////////////////////////////////////////////////////////
1394/// Secondary selection.
1395
1397{
1399
1400 if (CurrentLock() != kSelectLock) {
1401 Error("TGLViewer::DoSecondarySelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1402 return kFALSE;
1403 }
1404
1406
1407 TUnlocker ulck(this);
1408
1409 if (! fSelRec.GetSceneInfo() || ! fSelRec.GetPhysShape() ||
1410 ! fSelRec.GetLogShape()->SupportsSecondarySelect())
1411 {
1412 if (gDebug > 0)
1413 Info("TGLViewer::SecondarySelect", "Skipping secondary selection "
1414 "(sinfo=0x%zx, pshape=0x%zx).\n",
1415 (size_t)fSelRec.GetSceneInfo(), (size_t)fSelRec.GetPhysShape());
1416 fSecSelRec.Reset();
1417 return kFALSE;
1418 }
1419
1420 MakeCurrent();
1421
1422 TGLSceneInfo* sinfo = fSelRec.GetSceneInfo();
1423 TGLSceneBase* scene = sinfo->GetScene();
1424 TGLPhysicalShape* pshp = fSelRec.GetPhysShape();
1425
1426 SceneInfoList_t foo;
1427 foo.push_back(sinfo);
1428 fScenes.swap(foo);
1429 fRnrCtx->BeginSelection(x, y, TGLUtil::GetPickingRadius());
1430 fRnrCtx->SetSecSelection(kTRUE);
1431 glRenderMode(GL_SELECT);
1432
1433 PreRender();
1434 fRnrCtx->SetSceneInfo(sinfo);
1435 scene->PreRender(*fRnrCtx);
1436 fRnrCtx->SetDrawPass(TGLRnrCtx::kPassFill);
1437 fRnrCtx->SetShapeLOD(TGLRnrCtx::kLODHigh);
1438 glPushName(pshp->ID());
1439 // !!! Hack: does not use clipping and proper draw-pass settings.
1440 pshp->Draw(*fRnrCtx);
1441 glPopName();
1442 scene->PostRender(*fRnrCtx);
1443 fRnrCtx->SetSceneInfo(nullptr);
1444 PostRender();
1445
1446 Int_t nSecHits = glRenderMode(GL_RENDER);
1447 fRnrCtx->EndSelection(nSecHits);
1448 fScenes.swap(foo);
1449
1450 if (gDebug > 0) Info("TGLViewer::DoSelect", "Secondary select nSecHits=%d.", nSecHits);
1451
1453
1454 if (nSecHits > 0)
1455 {
1457 fSecSelRec.SetRawOnly(fRnrCtx->GetSelectBuffer()->RawRecord(0));
1458 if (gDebug > 1) fSecSelRec.Print();
1459 return kTRUE;
1460 } else {
1461 fSecSelRec.Reset();
1462 return kFALSE;
1463 }
1464}
1465
1466////////////////////////////////////////////////////////////////////////////////
1467/// Process result from last selection (in fSelRec) and
1468/// extract a new current selection from it.
1469/// Here we only use physical shape.
1470
1472{
1474
1475 TGLPhysicalShape *selPhys = fSelRec.GetPhysShape();
1476 fSelectedPShapeRef->SetPShape(selPhys);
1477
1478 // Inform external client selection has been modified.
1480
1482}
1483
1484////////////////////////////////////////////////////////////////////////////////
1485/// Post request for secondary selection rendering of selected object
1486/// around the window point (x,y).
1487
1489{
1490 // Take select lock on viewer immediately - it is released
1491 // in the other (drawing) thread - see TGLViewer::DoSecondarySelect().
1492
1493 if ( ! TakeLock(kSelectLock)) {
1494 return kFALSE;
1495 }
1496
1497 if (!gVirtualX->IsCmdThread())
1498 return Bool_t(gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoOverlaySelect(%d, %d)", (size_t)this, x, y)));
1499 else
1500 return DoOverlaySelect(x, y);
1501}
1502
1503////////////////////////////////////////////////////////////////////////////////
1504/// Perform GL selection, picking overlay objects only.
1505/// Return TRUE if the selected overlay-element has changed.
1506
1508{
1510
1511 if (CurrentLock() != kSelectLock) {
1512 Error("TGLViewer::DoOverlaySelect", "expected kSelectLock, found %s", LockName(CurrentLock()));
1513 return kFALSE;
1514 }
1515
1517
1518 TUnlocker ulck(this);
1519
1520 MakeCurrent();
1521
1522 fRnrCtx->BeginSelection(x, y, TGLUtil::GetPickingRadius());
1523 glRenderMode(GL_SELECT);
1524
1528
1529 Int_t nHits = glRenderMode(GL_RENDER);
1530 fRnrCtx->EndSelection(nHits);
1531
1532 // Process overlay selection.
1533 TGLOverlayElement * selElm = nullptr;
1534 if (nHits > 0)
1535 {
1536 Int_t idx = 0;
1537 while (idx < nHits && FindClosestOverlayRecord(fOvlSelRec, idx))
1538 {
1539 TGLOverlayElement* el = fOvlSelRec.GetOvlElement();
1540 if (el == fCurrentOvlElm)
1541 {
1543 {
1544 selElm = el;
1545 break;
1546 }
1547 }
1548 else if (el->MouseEnter(fOvlSelRec))
1549 {
1550 selElm = el;
1551 break;
1552 }
1553 ++idx;
1554 }
1555 }
1556 else
1557 {
1558 fOvlSelRec.Reset();
1559 }
1560
1562
1563 if (fCurrentOvlElm != selElm)
1564 {
1565 if (fCurrentOvlElm) fCurrentOvlElm->MouseLeave();
1566 fCurrentOvlElm = selElm;
1567 return kTRUE;
1568 }
1569 else
1570 {
1571 return kFALSE;
1572 }
1573}
1574
1575////////////////////////////////////////////////////////////////////////////////
1576/// Make one fading step and request redraw.
1577
1579{
1580 Float_t fade = fViewer->GetFader();
1581
1582 if (fade == fFadeTarget) {
1583 delete this; return;
1584 }
1585 if (TMath::Abs(fFadeTarget - fade) < 1e-3) {
1586 fViewer->SetFader(fFadeTarget);
1587 fViewer->RequestDraw(TGLRnrCtx::kLODHigh);
1588 delete this;
1589 return;
1590 }
1591
1592 Float_t dt = fTime/fNSteps;
1593 Float_t df = (fFadeTarget - fade)/fNSteps;
1594 fViewer->SetFader(fade + df);
1595 fViewer->RequestDraw(TGLRnrCtx::kLODHigh);
1596 fTime -= dt; --fNSteps;
1598 "TGLFaderHelper", this, "MakeFadeStep()");
1599}
1600
1601////////////////////////////////////////////////////////////////////////////////
1602/// Animate fading from current value to fade over given time (sec)
1603/// and number of steps.
1604
1606{
1607 TGLFaderHelper* fh = new TGLFaderHelper(this, fade, time, steps);
1608 fh->MakeFadeStep();
1609}
1610
1611////////////////////////////////////////////////////////////////////////////////
1612/// Use the dark color-set.
1613
1615{
1616 fRnrCtx->ChangeBaseColorSet(&fDarkColorSet);
1617 RefreshPadEditor(this);
1618}
1619
1620////////////////////////////////////////////////////////////////////////////////
1621/// Use the light color-set.
1622
1624{
1625 fRnrCtx->ChangeBaseColorSet(&fLightColorSet);
1626 RefreshPadEditor(this);
1627}
1628
1629////////////////////////////////////////////////////////////////////////////////
1630/// Switch between dark and light colorsets.
1631
1633{
1635 {
1636 Info("SwitchColorSet()", "Global color-set is in use, switch not supported.");
1637 return;
1638 }
1639
1640 if (fRnrCtx->GetBaseColorSet() == &fLightColorSet)
1642 else
1644}
1645
1646////////////////////////////////////////////////////////////////////////////////
1647/// Set usage of the default color set.
1648
1650{
1651 if (x)
1652 fRnrCtx->ChangeBaseColorSet(&fgDefaultColorSet);
1653 else
1654 fRnrCtx->ChangeBaseColorSet(&fDarkColorSet);
1655 RefreshPadEditor(this);
1656}
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Check if the viewer is using the default color set.
1660/// If yes, some operations might be disabled.
1661
1663{
1664 return fRnrCtx->GetBaseColorSet() == &fgDefaultColorSet;
1665}
1666
1667////////////////////////////////////////////////////////////////////////////////
1668/// Set background method.
1669/// Deprecated method - set background color in the color-set.
1670
1672{
1673 fRnrCtx->GetBaseColorSet()->Background().SetColor(col);
1674}
1675
1676////////////////////////////////////////////////////////////////////////////////
1677/// Returns reference to the default color-set.
1678/// Static function.
1679
1684
1685////////////////////////////////////////////////////////////////////////////////
1686/// Sets static flag that determines if new viewers should use the
1687/// default color-set.
1688/// This is false at startup.
1689
1694
1695////////////////////////////////////////////////////////////////////////////////
1696/// Returns the value of the static flag that determines if new
1697/// viewers should use the default color-set.
1698/// This is false at startup.
1699
1704
1705 ////////////////////////////////////////////////////////////////////////////////
1706/// Sets static scaling facor that allows simple guide axies to have label values
1707/// scaled relative to actual scene dimensions.
1708/// This is set to 1 in static initialization.
1709
1714
1715////////////////////////////////////////////////////////////////////////////////
1716/// Returns true if current color set is dark.
1717
1719{
1720 return fRnrCtx->GetBaseColorSet() == &fDarkColorSet;
1721}
1722
1723/**************************************************************************/
1724// Viewport
1725/**************************************************************************/
1726
1727////////////////////////////////////////////////////////////////////////////////
1728/// Set viewer viewport (window area) with bottom/left at (x,y), with
1729/// dimensions 'width'/'height'
1730
1732{
1733 if (fStereo && ! fStereoQuadBuf) width /= 2;
1734
1735 // Only process if changed
1736 if (fViewport.X() == x && fViewport.Y() == y &&
1737 fViewport.Width() == width && fViewport.Height() == height) {
1738 return;
1739 }
1740
1741 fViewport.Set(x, y, width, height);
1742 fCurrentCamera->SetViewport(fViewport);
1743
1744 if (gDebug > 2) {
1745 Info("TGLViewer::SetViewport", "updated - corner %d,%d dimensions %d,%d", x, y, width, height);
1746 }
1747}
1748
1750{
1751 // Set viewer viewport from TGLRect.
1752
1753 SetViewport(vp.X(), vp.Y(), vp.Width(), vp.Height());
1754}
1755
1756/**************************************************************************/
1757// Camera methods
1758/**************************************************************************/
1759
1760////////////////////////////////////////////////////////////////////////////////
1761/// Return camera reference by type.
1762
1764{
1765 // TODO: Move these into a vector!
1766 switch(cameraType) {
1767 case kCameraPerspXOZ:
1768 return fPerspectiveCameraXOZ;
1769 case kCameraPerspYOZ:
1770 return fPerspectiveCameraYOZ;
1771 case kCameraPerspXOY:
1772 return fPerspectiveCameraXOY;
1773 case kCameraOrthoXOY:
1774 return fOrthoXOYCamera;
1775 case kCameraOrthoXOZ:
1776 return fOrthoXOZCamera;
1777 case kCameraOrthoZOY:
1778 return fOrthoZOXCamera;
1779 case kCameraOrthoZOX:
1780 return fOrthoZOYCamera;
1781 case kCameraOrthoXnOY:
1782 return fOrthoXnOYCamera;
1783 case kCameraOrthoXnOZ:
1784 return fOrthoXnOZCamera;
1785 case kCameraOrthoZnOY:
1786 return fOrthoZnOYCamera;
1787 case kCameraOrthoZnOX:
1788 return fOrthoZnOXCamera;
1789 default:
1790 Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1791 return *fCurrentCamera;
1792 }
1793}
1794
1795////////////////////////////////////////////////////////////////////////////////
1796/// Set current active camera - 'cameraType' one of:
1797/// kCameraPerspX, kCameraPerspY, kCameraPerspZ,
1798/// kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY,
1799/// kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY
1800
1802{
1803 if (IsLocked()) {
1804 Error("TGLViewer::SetCurrentCamera", "expected kUnlocked, found %s", LockName(CurrentLock()));
1805 return;
1806 }
1807
1808 // TODO: Move these into a vector!
1809 TGLCamera *prev = fCurrentCamera;
1810 switch (cameraType)
1811 {
1812 case kCameraPerspXOZ: {
1814 break;
1815 }
1816 case kCameraPerspYOZ: {
1818 break;
1819 }
1820 case kCameraPerspXOY: {
1822 break;
1823 }
1824 case kCameraOrthoXOY: {
1826 break;
1827 }
1828 case kCameraOrthoXOZ: {
1830 break;
1831 }
1832 case kCameraOrthoZOY: {
1834 break;
1835 }
1836 case kCameraOrthoZOX: {
1838 break;
1839 }
1840 case kCameraOrthoXnOY: {
1842 break;
1843 }
1844 case kCameraOrthoXnOZ: {
1846 break;
1847 }
1848 case kCameraOrthoZnOY: {
1850 break;
1851 }
1852 case kCameraOrthoZnOX: {
1854 break;
1855 }
1856 default: {
1857 Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1858 break;
1859 }
1860 }
1861
1862 if (fCurrentCamera != prev)
1863 {
1864 // Ensure any viewport has been propagated to the current camera
1865 fCurrentCamera->SetViewport(fViewport);
1866 RefreshPadEditor(this);
1867
1868 if (fAutoRotator)
1869 {
1870 if (fAutoRotator->IsRunning())
1871 {
1872 fAutoRotator->Stop();
1873 }
1874 else
1875 {
1876 if (fAutoRotator->GetCamera() == fCurrentCamera)
1877 {
1878 fAutoRotator->Start();
1879 }
1880 }
1881 }
1882
1884 }
1885}
1886
1887////////////////////////////////////////////////////////////////////////////////
1888/// Set an orthographic camera to supplied configuration - note this
1889/// does not need to be the current camera - though you will not see
1890/// the effect if it is not.
1891///
1892/// 'camera' defines the ortho camera - one of kCameraOrthoXOY / XOZ / ZOY
1893/// 'left' / 'right' / 'top' / 'bottom' define the WORLD coordinates which
1894/// correspond with the left/right/top/bottom positions on the GL viewer viewport
1895/// E.g. for kCameraOrthoXOY camera left/right are X world coords,
1896/// top/bottom are Y world coords
1897/// As this is an orthographic camera the other axis (in eye direction) is
1898/// no relevant. The near/far clip planes are set automatically based in scene
1899/// contents
1900
1902 Double_t zoom, Double_t dolly,
1903 Double_t center[3],
1904 Double_t hRotate, Double_t vRotate)
1905{
1906 // TODO: Move these into a vector!
1907 switch(camera) {
1908 case kCameraOrthoXOY: {
1909 fOrthoXOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1912 }
1913 break;
1914 }
1915 case kCameraOrthoXOZ: {
1916 fOrthoXOZCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1919 }
1920 break;
1921 }
1922 case kCameraOrthoZOY: {
1923 fOrthoZOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1926 }
1927 break;
1928 }
1929 case kCameraOrthoZOX: {
1930 fOrthoZOXCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1933 }
1934 break;
1935 }
1936 default: {
1937 Error("TGLViewer::SetOrthoCamera", "invalid camera type");
1938 break;
1939 }
1940 }
1941}
1942
1943////////////////////////////////////////////////////////////////////////////////
1944/// Set a perspective camera to supplied configuration - note this
1945/// does not need to be the current camera - though you will not see
1946/// the effect if it is not.
1947///
1948/// - 'camera' defines the persp camera - one of kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY
1949/// - 'fov' - field of view (lens angle) in degrees (clamped to 0.1 - 170.0)
1950/// - 'dolly' - distance from 'center'
1951/// - 'center' - world position from which dolly/hRotate/vRotate are measured
1952/// camera rotates round this, always facing in (in center of viewport)
1953/// - 'hRotate' - horizontal rotation from initial configuration in radians
1954/// - 'vRotate' - vertical rotation from initial configuration in radians
1955
1957 Double_t fov, Double_t dolly,
1958 Double_t center[3],
1959 Double_t hRotate, Double_t vRotate)
1960{
1961 // TODO: Move these into a vector!
1962 switch(camera) {
1963 case kCameraPerspXOZ: {
1964 fPerspectiveCameraXOZ.Configure(fov, dolly, center, hRotate, vRotate);
1967 }
1968 break;
1969 }
1970 case kCameraPerspYOZ: {
1971 fPerspectiveCameraYOZ.Configure(fov, dolly, center, hRotate, vRotate);
1974 }
1975 break;
1976 }
1977 case kCameraPerspXOY: {
1978 fPerspectiveCameraXOY.Configure(fov, dolly, center, hRotate, vRotate);
1981 }
1982 break;
1983 }
1984 default: {
1985 Error("TGLViewer::SetPerspectiveCamera", "invalid camera type");
1986 break;
1987 }
1988 }
1989}
1990
1991////////////////////////////////////////////////////////////////////////////////
1992/// Change base-vectors defining the camera-base transformation of current
1993/// camera. hAxis and vAxis are the default directions for forward
1994/// (inverted) and upwards.
1995
1997{
1998 TGLMatrix& cb = fCurrentCamera->RefCamBase();
1999 cb.Set(cb.GetTranslation(), vAxis, hAxis);
2001 if (redraw)
2002 RequestDraw();
2003}
2004
2005////////////////////////////////////////////////////////////////////////////////
2006/// Get the auto-rotator for this viewer.
2007
2009{
2010 if (fAutoRotator == nullptr)
2011 fAutoRotator = new TGLAutoRotator(this);
2012 return fAutoRotator;
2013}
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Set the auto-rotator for this viewer. The old rotator is deleted.
2017
2019{
2020 delete fAutoRotator;
2021 fAutoRotator = ar;
2022}
2023
2024////////////////////////////////////////////////////////////////////////////////
2025/// Enable stereo rendering.
2026/// If quad_buf is true rendering is done into separate left and right GL
2027/// buffers. This requires hardware support. Otherwise left and right images
2028/// get rendered into left and right half of the window.
2029/// Note that mouse highlighting and selection will not work exactly right
2030/// as image for each eye gets slightly shifted and there are two different
2031/// directions through the mouse pointer, one for each eye.
2032
2033void TGLViewer::SetStereo(Bool_t stereo, Bool_t quad_buf)
2034{
2035 if (stereo != fStereo)
2036 {
2037 fStereo = stereo;
2038 fStereoQuadBuf = quad_buf;
2039 if (fStereo)
2040 SetViewport(fViewport.X(), fViewport.Y(), fViewport.Width(), fViewport.Height());
2041 else
2042 SetViewport(fViewport.X(), fViewport.Y(), 2*fViewport.Width(), fViewport.Height());
2043 }
2045}
2046
2047/**************************************************************************/
2048// Guide methods
2049/**************************************************************************/
2050
2051////////////////////////////////////////////////////////////////////////////////
2052/// Fetch the state of guides (axes & reference markers) into arguments
2053
2054void TGLViewer::GetGuideState(Int_t & axesType, Bool_t & axesDepthTest, Bool_t & referenceOn, Double_t referencePos[3]) const
2055{
2056 axesType = fAxesType;
2057 axesDepthTest = fAxesDepthTest;
2058
2059 referenceOn = fReferenceOn;
2060 referencePos[0] = fReferencePos.X();
2061 referencePos[1] = fReferencePos.Y();
2062 referencePos[2] = fReferencePos.Z();
2063}
2064
2065////////////////////////////////////////////////////////////////////////////////
2066/// Set the state of guides (axes & reference markers) from arguments.
2067
2068void TGLViewer::SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t referencePos[3])
2069{
2070 fAxesType = axesType;
2071 fAxesDepthTest = axesDepthTest;
2072 fReferenceOn = referenceOn;
2073 if (referencePos)
2074 fReferencePos.Set(referencePos[0], referencePos[1], referencePos[2]);
2075 if (fGLDevice != -1)
2076 gGLManager->MarkForDirectCopy(fGLDevice, kTRUE);
2077 RequestDraw();
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Draw camera look at and rotation point.
2082
2088
2089// Selected physical
2090////////////////////////////////////////////////////////////////////////////////
2091/// Return selected physical shape.
2092
2094{
2095 return fSelectedPShapeRef->GetPShape();
2096}
2097
2098/**************************************************************************/
2099/**************************************************************************/
2100
2101////////////////////////////////////////////////////////////////////////////////
2102/// Emit MouseOver signal.
2103
2105{
2106 Emit("MouseOver(TGLPhysicalShape*)", (Longptr_t)shape);
2107}
2108
2109////////////////////////////////////////////////////////////////////////////////
2110/// Emit MouseOver signal.
2111
2113{
2114 Longptr_t args[2];
2115 args[0] = (Longptr_t)shape;
2116 args[1] = state;
2117 Emit("MouseOver(TGLPhysicalShape*,UInt_t)", args);
2118}
2119
2120////////////////////////////////////////////////////////////////////////////////
2121/// Emit MouseOver signal.
2122
2124{
2125 Longptr_t args[2];
2126 args[0] = (Longptr_t)obj;
2127 args[1] = state;
2128 Emit("MouseOver(TObject*,UInt_t)", args);
2129}
2130
2131////////////////////////////////////////////////////////////////////////////////
2132/// Emit MouseOver signal.
2133
2135{
2136 Longptr_t args[2];
2137 args[0] = (Longptr_t)obj;
2138 args[1] = state;
2139 Emit("ReMouseOver(TObject*,UInt_t)", args);
2140}
2141
2142
2143////////////////////////////////////////////////////////////////////////////////
2144/// Emit UnMouseOver signal.
2145
2147{
2148 Longptr_t args[2];
2149 args[0] = (Longptr_t)obj;
2150 args[1] = state;
2151 Emit("UnMouseOver(TObject*,UInt_t)", args);
2152}
2153
2154////////////////////////////////////////////////////////////////////////////////
2155/// Emit Clicked signal.
2156
2158{
2159 Emit("Clicked(TObject*)", (Longptr_t)obj);
2160}
2161
2162////////////////////////////////////////////////////////////////////////////////
2163/// Emit Clicked signal with button id and modifier state.
2164
2165void TGLViewer::Clicked(TObject *obj, UInt_t button, UInt_t state)
2166{
2167 Longptr_t args[3];
2168 args[0] = (Longptr_t)obj;
2169 args[1] = button;
2170 args[2] = state;
2171 Emit("Clicked(TObject*,UInt_t,UInt_t)", args);
2172}
2173
2174
2175////////////////////////////////////////////////////////////////////////////////
2176/// Emit ReClicked signal with button id and modifier state.
2177
2179{
2180 Longptr_t args[3];
2181 args[0] = (Longptr_t)obj;
2182 args[1] = button;
2183 args[2] = state;
2184 Emit("ReClicked(TObject*,UInt_t,UInt_t)", args);
2185}
2186
2187////////////////////////////////////////////////////////////////////////////////
2188/// Emit UnClicked signal with button id and modifier state.
2189
2191{
2192 Longptr_t args[3];
2193 args[0] = (Longptr_t)obj;
2194 args[1] = button;
2195 args[2] = state;
2196 Emit("UnClicked(TObject*,UInt_t,UInt_t)", args);
2197}
2198
2199////////////////////////////////////////////////////////////////////////////////
2200/// Emit MouseIdle signal.
2201
2203{
2204 Longptr_t args[3];
2205 static UInt_t oldx = 0, oldy = 0;
2206
2207 if (oldx != posx || oldy != posy) {
2208 args[0] = (Longptr_t)shape;
2209 args[1] = posx;
2210 args[2] = posy;
2211 Emit("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", args);
2212 oldx = posx;
2213 oldy = posy;
2214 }
2215}
2216
2217/**************************************************************************/
2218/**************************************************************************/
2219////////////////////////////////////////////////////////////////////////////////
2220/// Calculate and return pixel distance to nearest viewer object from
2221/// window location px, py
2222/// This is provided for use when embedding GL viewer into pad
2223
2225{
2226 // Can't track the indvidual objects in rollover. Just set the viewer as the
2227 // selected object, and return 0 (object identified) so we receive ExecuteEvent calls
2228 gPad->SetSelected(this);
2229 return 0;
2230}
2231
2232////////////////////////////////////////////////////////////////////////////////
2233/// Process event of type 'event' - one of EEventType types,
2234/// occurring at window location px, py
2235/// This is provided for use when embedding GL viewer into pad
2236
2238{
2239 if (fEventHandler)
2240 return fEventHandler->ExecuteEvent(event, px, py);
2241}
2242
2243////////////////////////////////////////////////////////////////////////////////
2244/// Pass viewer for print capture by TGLOutput.
2245
2247{
2248 TGLOutput::Capture(*this);
2249}
2250
2251////////////////////////////////////////////////////////////////////////////////
2252/// Update GUI components for embedded viewer selection change.
2253
2255{
2256 if (!fGedEditor)
2257 return;
2258
2259 TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
2260
2261 if (selected) {
2262 fPShapeWrap->fPShape = selected;
2264 } else {
2265 fPShapeWrap->fPShape = nullptr;
2266 fGedEditor->SetModel(fPad, this, kButton1Down);
2267 }
2268}
2269
2270////////////////////////////////////////////////////////////////////////////////
2271/// An overlay operation can result in change to an object.
2272/// Refresh geditor.
2273
2275{
2276 if (fGedEditor)
2277 {
2278 fGedEditor->SetModel(fPad, fGedEditor->GetModel(), kButton1Down);
2279 }
2280}
2281
2282////////////////////////////////////////////////////////////////////////////////
2283/// Update GED editor if it is set.
2284
2286{
2287 if (fGedEditor && (obj == nullptr || fGedEditor->GetModel() == obj))
2288 {
2289 fGedEditor->SetModel(fPad, fGedEditor->GetModel(), kButton1Down);
2290 }
2291}
2292
2293////////////////////////////////////////////////////////////////////////////////
2294/// Set the event-handler. The event-handler is owned by the viewer.
2295/// If GLWidget is set, the handler is propagated to it.
2296///
2297/// If called with handler=0, the current handler will be deleted
2298/// (also from TGLWidget).
2299
2301{
2302 if (fEventHandler)
2303 delete fEventHandler;
2304
2305 fEventHandler = handler;
2306 if (fGLWidget)
2307 fGLWidget->SetEventHandler(fEventHandler);
2308}
2309
2310////////////////////////////////////////////////////////////////////////////////
2311/// Remove overlay element.
2312
2314{
2315 if (el == fCurrentOvlElm)
2316 {
2317 fCurrentOvlElm = nullptr;
2318 }
2320}
2321
2322////////////////////////////////////////////////////////////////////////////////
2323/// Reset current overlay-element to zero, eventually notifying the
2324/// old one that the mouse has left.
2325/// Usually called when mouse leaves the window.
2326
2328{
2329 if (fCurrentOvlElm)
2330 {
2331 fCurrentOvlElm->MouseLeave();
2332 fCurrentOvlElm = nullptr;
2333 RequestDraw();
2334 }
2335}
@ 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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
Definition RtypesCore.h:89
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
Definition RtypesCore.h:52
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
short Short_t
Signed Short integer 2 bytes (short).
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
short Color_t
Color number (short).
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
externTEnv * gEnv
Definition TEnv.h:170
#define GL_BGRA
Definition TGLViewer.cxx:61
Int_t gDebug
Definition TROOT.cxx:777
#define gROOT
Definition TROOT.h:417
externTVirtualMutex * gROOTMutex
Definition TROOT.h:63
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
#define gGLManager
Definition TVirtualGL.h:159
#define R__LOCKGUARD(mutex)
#define gPad
#define gVirtualX
Definition TVirtualX.h:375
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
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
void DrawDebugAids() const
Draw out some debugging aids for the camera:
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)=0
A collection of concrete TGLClip objects to be selected from.
Definition TGLClip.h:140
Class encapsulating a set of colors used throughout standard rendering.
Definition TGLUtil.h:836
Identifier of a shared GL-context.
Definition TGLContext.h:81
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
Encapsulates a set of lights for OpenGL.
Definition TGLLightSet.h:22
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
Combine all available manipulators in a collection.
Definition TGLManipSet.h:22
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.
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)
Wrap TGLPysicalShape into TObject so that it can be edited using GED.
Perspective projection camera - with characteristic foreshortening.
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
Int_t X() const
Definition TGLUtil.h:446
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:26
virtual void PadPaintFromViewer(TGLViewer *viewer)
Entry point for requesting update of scene's contents from gl-viewer.
TVirtualPad * GetPad() const
Definition TGLScenePad.h:62
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.
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 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
3 component (x/y/z) vertex class.
Definition TGLUtil.h:84
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
EPushAction fPushAction
Definition TGLViewer.h:131
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
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.
EDragAction fDragAction
Definition TGLViewer.h:132
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.
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.
Bool_t fIgnoreSizesOnUpdate
Definition TGLViewer.h:190
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.
Bool_t fSmartRefresh
! cache logicals during scene rebuilds
Definition TGLViewer.h:153
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.
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Create()
Create an image.
Definition TImage.cxx:34
virtual void FromGLBuffer(UChar_t *, UInt_t, UInt_t)
Definition TImage.h:246
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1084
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1098
TObject()
TObject constructor.
Definition TObject.h:259
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1072
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:138
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2250
const char * Data() const
Definition TString.h:384
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
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:51
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:704
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:685
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Definition TMath.h:611
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122