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
91
94
95////////////////////////////////////////////////////////////////////////////////
96
98 Int_t width, Int_t height) :
99 fPad(pad),
100 fContextMenu(0),
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(0),
114
115 fStereo (kFALSE),
116 fStereoQuadBuf (kFALSE),
117 fStereoZeroParallax (0.03f),
118 fStereoEyeOffsetFac (1.0f),
119 fStereoFrustumAsymFac (1.0f),
120
121 fLightSet (0),
122 fClipSet (0),
123 fSelectedPShapeRef (0),
124 fCurrentOvlElm (0),
125
126 fEventHandler(0),
127 fGedEditor(0),
128 fPShapeWrap(0),
129 fPushAction(kPushStd), fDragAction(kDragNone),
130 fRedrawTimer(0),
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(0),
140 fSmartRefresh(kFALSE),
141 fDebugMode(kFALSE),
142 fIsPrinting(kFALSE),
143 fPictureFileName("viewer.jpg"),
144 fFader(0),
145 fGLWidget(0),
146 fGLDevice(-1),
147 fGLCtxId(0),
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
159 SetViewport(x, y, width, height);
160}
161
162////////////////////////////////////////////////////////////////////////////////
163
165 fPad(pad),
166 fContextMenu(0),
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(0),
180
181 fStereo (kFALSE),
182 fStereoQuadBuf (kFALSE),
183 fStereoZeroParallax (0.03f),
184 fStereoEyeOffsetFac (1.0f),
185 fStereoFrustumAsymFac (1.0f),
186
187 fLightSet (0),
188 fClipSet (0),
189 fSelectedPShapeRef (0),
190 fCurrentOvlElm (0),
191
192 fEventHandler(0),
193 fGedEditor(0),
194 fPShapeWrap(0),
195 fPushAction(kPushStd), fDragAction(kDragNone),
196 fRedrawTimer(0),
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(0),
206 fSmartRefresh(kFALSE),
207 fDebugMode(kFALSE),
208 fIsPrinting(kFALSE),
209 fPictureFileName("viewer.jpg"),
210 fFader(0),
211 fGLWidget(0),
212 fGLDevice(fPad->GetGLDevice()),
213 fGLCtxId(0),
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(0);
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
248
249 fPShapeWrap = new TGLPShapeObj(0, this);
250
254 } else {
255 if (fPad) {
259 } else {
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)
286 delete fEventHandler;
287 }
288
289 if (fPad)
291 if (fGLDevice != -1)
292 fGLCtxId->Release(0);
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 = 0;
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 = 0;
312 }
313 if (scenepad == 0)
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
358{
361}
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
468{
469 if (GetClipAutoUpdate())
470 {
472 }
473 else
474 {
476 }
477}
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
537{
539
542}
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
783{
785}
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 (GLEW_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
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
943
944 if (!gVirtualX->IsCmdThread())
945 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
946 else
947 DoDraw(kFALSE);
948
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 NULL;
991 }
992
993 TUnlocker ulck(this);
994
997
998 if (!gVirtualX->IsCmdThread())
999 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
1000 else
1001 DoDraw(kFALSE);
1002
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 NULL;
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 NULL;
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
1076
1077 if (!gVirtualX->IsCmdThread())
1078 gROOT->ProcessLineFast(Form("((TGLViewer *)0x%zx)->DoDraw(kFALSE)", (size_t)this));
1079 else
1080 DoDraw(kFALSE);
1081
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();
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);
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);
1200
1201 // Scene bounding box center sphere (green) and
1202 glDisable(GL_DEPTH_TEST);
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);
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)
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)
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
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 {
1361 {
1362 TGLSelectRecord opaque;
1363 if (FindClosestOpaqueRecord(opaque, ++idx))
1364 fSelRec = opaque;
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() ||
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
1423 TGLSceneBase* scene = sinfo->GetScene();
1425
1426 SceneInfoList_t foo;
1427 foo.push_back(sinfo);
1428 fScenes.swap(foo);
1431 glRenderMode(GL_SELECT);
1432
1433 PreRender();
1434 fRnrCtx->SetSceneInfo(sinfo);
1435 scene->PreRender(*fRnrCtx);
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);
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 {
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
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
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 = 0;
1534 if (nHits > 0)
1535 {
1536 Int_t idx = 0;
1537 while (idx < nHits && FindClosestOverlayRecord(fOvlSelRec, idx))
1538 {
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 {
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) {
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);
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{
1617 RefreshPadEditor(this);
1618}
1619
1620////////////////////////////////////////////////////////////////////////////////
1621/// Use the light color-set.
1622
1624{
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
1642 else
1644}
1645
1646////////////////////////////////////////////////////////////////////////////////
1647/// Set usage of the default color set.
1648
1650{
1651 if (x)
1653 else
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{
1665}
1666
1667////////////////////////////////////////////////////////////////////////////////
1668/// Set background method.
1669/// Deprecated method - set background color in the color-set.
1670
1672{
1674}
1675
1676////////////////////////////////////////////////////////////////////////////////
1677/// Returns reference to the default color-set.
1678/// Static function.
1679
1681{
1682 return fgDefaultColorSet;
1683}
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
1691{
1693}
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
1701{
1703}
1704
1705////////////////////////////////////////////////////////////////////////////////
1706/// Returns true if current color set is dark.
1707
1709{
1711}
1712
1713/**************************************************************************/
1714// Viewport
1715/**************************************************************************/
1716
1717////////////////////////////////////////////////////////////////////////////////
1718/// Set viewer viewport (window area) with bottom/left at (x,y), with
1719/// dimensions 'width'/'height'
1720
1722{
1723 if (fStereo && ! fStereoQuadBuf) width /= 2;
1724
1725 // Only process if changed
1726 if (fViewport.X() == x && fViewport.Y() == y &&
1727 fViewport.Width() == width && fViewport.Height() == height) {
1728 return;
1729 }
1730
1731 fViewport.Set(x, y, width, height);
1733
1734 if (gDebug > 2) {
1735 Info("TGLViewer::SetViewport", "updated - corner %d,%d dimensions %d,%d", x, y, width, height);
1736 }
1737}
1738
1740{
1741 // Set viewer viewport from TGLRect.
1742
1743 SetViewport(vp.X(), vp.Y(), vp.Width(), vp.Height());
1744}
1745
1746/**************************************************************************/
1747// Camera methods
1748/**************************************************************************/
1749
1750////////////////////////////////////////////////////////////////////////////////
1751/// Return camera reference by type.
1752
1754{
1755 // TODO: Move these into a vector!
1756 switch(cameraType) {
1757 case kCameraPerspXOZ:
1758 return fPerspectiveCameraXOZ;
1759 case kCameraPerspYOZ:
1760 return fPerspectiveCameraYOZ;
1761 case kCameraPerspXOY:
1762 return fPerspectiveCameraXOY;
1763 case kCameraOrthoXOY:
1764 return fOrthoXOYCamera;
1765 case kCameraOrthoXOZ:
1766 return fOrthoXOZCamera;
1767 case kCameraOrthoZOY:
1768 return fOrthoZOXCamera;
1769 case kCameraOrthoZOX:
1770 return fOrthoZOYCamera;
1771 case kCameraOrthoXnOY:
1772 return fOrthoXnOYCamera;
1773 case kCameraOrthoXnOZ:
1774 return fOrthoXnOZCamera;
1775 case kCameraOrthoZnOY:
1776 return fOrthoZnOYCamera;
1777 case kCameraOrthoZnOX:
1778 return fOrthoZnOXCamera;
1779 default:
1780 Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1781 return *fCurrentCamera;
1782 }
1783}
1784
1785////////////////////////////////////////////////////////////////////////////////
1786/// Set current active camera - 'cameraType' one of:
1787/// kCameraPerspX, kCameraPerspY, kCameraPerspZ,
1788/// kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY,
1789/// kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY
1790
1792{
1793 if (IsLocked()) {
1794 Error("TGLViewer::SetCurrentCamera", "expected kUnlocked, found %s", LockName(CurrentLock()));
1795 return;
1796 }
1797
1798 // TODO: Move these into a vector!
1799 TGLCamera *prev = fCurrentCamera;
1800 switch (cameraType)
1801 {
1802 case kCameraPerspXOZ: {
1804 break;
1805 }
1806 case kCameraPerspYOZ: {
1808 break;
1809 }
1810 case kCameraPerspXOY: {
1812 break;
1813 }
1814 case kCameraOrthoXOY: {
1816 break;
1817 }
1818 case kCameraOrthoXOZ: {
1820 break;
1821 }
1822 case kCameraOrthoZOY: {
1824 break;
1825 }
1826 case kCameraOrthoZOX: {
1828 break;
1829 }
1830 case kCameraOrthoXnOY: {
1832 break;
1833 }
1834 case kCameraOrthoXnOZ: {
1836 break;
1837 }
1838 case kCameraOrthoZnOY: {
1840 break;
1841 }
1842 case kCameraOrthoZnOX: {
1844 break;
1845 }
1846 default: {
1847 Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1848 break;
1849 }
1850 }
1851
1852 if (fCurrentCamera != prev)
1853 {
1854 // Ensure any viewport has been propagated to the current camera
1856 RefreshPadEditor(this);
1857
1858 if (fAutoRotator)
1859 {
1860 if (fAutoRotator->IsRunning())
1861 {
1862 fAutoRotator->Stop();
1863 }
1864 else
1865 {
1867 {
1869 }
1870 }
1871 }
1872
1874 }
1875}
1876
1877////////////////////////////////////////////////////////////////////////////////
1878/// Set an orthographic camera to supplied configuration - note this
1879/// does not need to be the current camera - though you will not see
1880/// the effect if it is not.
1881///
1882/// 'camera' defines the ortho camera - one of kCameraOrthoXOY / XOZ / ZOY
1883/// 'left' / 'right' / 'top' / 'bottom' define the WORLD coordinates which
1884/// correspond with the left/right/top/bottom positions on the GL viewer viewport
1885/// E.g. for kCameraOrthoXOY camera left/right are X world coords,
1886/// top/bottom are Y world coords
1887/// As this is an orthographic camera the other axis (in eye direction) is
1888/// no relevant. The near/far clip planes are set automatically based in scene
1889/// contents
1890
1892 Double_t zoom, Double_t dolly,
1893 Double_t center[3],
1894 Double_t hRotate, Double_t vRotate)
1895{
1896 // TODO: Move these into a vector!
1897 switch(camera) {
1898 case kCameraOrthoXOY: {
1899 fOrthoXOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1902 }
1903 break;
1904 }
1905 case kCameraOrthoXOZ: {
1906 fOrthoXOZCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1909 }
1910 break;
1911 }
1912 case kCameraOrthoZOY: {
1913 fOrthoZOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1916 }
1917 break;
1918 }
1919 case kCameraOrthoZOX: {
1920 fOrthoZOXCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1923 }
1924 break;
1925 }
1926 default: {
1927 Error("TGLViewer::SetOrthoCamera", "invalid camera type");
1928 break;
1929 }
1930 }
1931}
1932
1933////////////////////////////////////////////////////////////////////////////////
1934/// Set a perspective camera to supplied configuration - note this
1935/// does not need to be the current camera - though you will not see
1936/// the effect if it is not.
1937///
1938/// - 'camera' defines the persp camera - one of kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY
1939/// - 'fov' - field of view (lens angle) in degrees (clamped to 0.1 - 170.0)
1940/// - 'dolly' - distance from 'center'
1941/// - 'center' - world position from which dolly/hRotate/vRotate are measured
1942/// camera rotates round this, always facing in (in center of viewport)
1943/// - 'hRotate' - horizontal rotation from initial configuration in degrees
1944/// - 'hRotate' - vertical rotation from initial configuration in degrees
1945
1947 Double_t fov, Double_t dolly,
1948 Double_t center[3],
1949 Double_t hRotate, Double_t vRotate)
1950{
1951 // TODO: Move these into a vector!
1952 switch(camera) {
1953 case kCameraPerspXOZ: {
1954 fPerspectiveCameraXOZ.Configure(fov, dolly, center, hRotate, vRotate);
1957 }
1958 break;
1959 }
1960 case kCameraPerspYOZ: {
1961 fPerspectiveCameraYOZ.Configure(fov, dolly, center, hRotate, vRotate);
1964 }
1965 break;
1966 }
1967 case kCameraPerspXOY: {
1968 fPerspectiveCameraXOY.Configure(fov, dolly, center, hRotate, vRotate);
1971 }
1972 break;
1973 }
1974 default: {
1975 Error("TGLViewer::SetPerspectiveCamera", "invalid camera type");
1976 break;
1977 }
1978 }
1979}
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Change base-vectors defining the camera-base transformation of current
1983/// camera. hAxis and vAxis are the default directions for forward
1984/// (inverted) and upwards.
1985
1987{
1989 cb.Set(cb.GetTranslation(), vAxis, hAxis);
1991 if (redraw)
1992 RequestDraw();
1993}
1994
1995////////////////////////////////////////////////////////////////////////////////
1996/// Get the auto-rotator for this viewer.
1997
1999{
2000 if (fAutoRotator == 0)
2001 fAutoRotator = new TGLAutoRotator(this);
2002 return fAutoRotator;
2003}
2004
2005////////////////////////////////////////////////////////////////////////////////
2006/// Set the auto-rotator for this viewer. The old rotator is deleted.
2007
2009{
2010 delete fAutoRotator;
2011 fAutoRotator = ar;
2012}
2013
2014////////////////////////////////////////////////////////////////////////////////
2015/// Enable stereo rendering.
2016/// If quad_buf is true rendering is done into separate left and right GL
2017/// buffers. This requires hardware support. Otherwise left and right images
2018/// get rendered into left and right half of the window.
2019/// Note that mouse highlighting and selection will not work exactly right
2020/// as image for each eye gets slightly shifted and there are two different
2021/// directions through the mouse pointer, one for each eye.
2022
2023void TGLViewer::SetStereo(Bool_t stereo, Bool_t quad_buf)
2024{
2025 if (stereo != fStereo)
2026 {
2027 fStereo = stereo;
2028 fStereoQuadBuf = quad_buf;
2029 if (fStereo)
2031 else
2033 }
2035}
2036
2037/**************************************************************************/
2038// Guide methods
2039/**************************************************************************/
2040
2041////////////////////////////////////////////////////////////////////////////////
2042/// Fetch the state of guides (axes & reference markers) into arguments
2043
2044void TGLViewer::GetGuideState(Int_t & axesType, Bool_t & axesDepthTest, Bool_t & referenceOn, Double_t referencePos[3]) const
2045{
2046 axesType = fAxesType;
2047 axesDepthTest = fAxesDepthTest;
2048
2049 referenceOn = fReferenceOn;
2050 referencePos[0] = fReferencePos.X();
2051 referencePos[1] = fReferencePos.Y();
2052 referencePos[2] = fReferencePos.Z();
2053}
2054
2055////////////////////////////////////////////////////////////////////////////////
2056/// Set the state of guides (axes & reference markers) from arguments.
2057
2058void TGLViewer::SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t referencePos[3])
2059{
2060 fAxesType = axesType;
2061 fAxesDepthTest = axesDepthTest;
2062 fReferenceOn = referenceOn;
2063 if (referencePos)
2064 fReferencePos.Set(referencePos[0], referencePos[1], referencePos[2]);
2065 if (fGLDevice != -1)
2066 gGLManager->MarkForDirectCopy(fGLDevice, kTRUE);
2067 RequestDraw();
2068}
2069
2070////////////////////////////////////////////////////////////////////////////////
2071/// Draw camera look at and rotation point.
2072
2074{
2076 RequestDraw();
2077}
2078
2079// Selected physical
2080////////////////////////////////////////////////////////////////////////////////
2081/// Return selected physical shape.
2082
2084{
2085 return fSelectedPShapeRef->GetPShape();
2086}
2087
2088/**************************************************************************/
2089/**************************************************************************/
2090
2091////////////////////////////////////////////////////////////////////////////////
2092/// Emit MouseOver signal.
2093
2095{
2096 Emit("MouseOver(TGLPhysicalShape*)", (Longptr_t)shape);
2097}
2098
2099////////////////////////////////////////////////////////////////////////////////
2100/// Emit MouseOver signal.
2101
2103{
2104 Longptr_t args[2];
2105 args[0] = (Longptr_t)shape;
2106 args[1] = state;
2107 Emit("MouseOver(TGLPhysicalShape*,UInt_t)", args);
2108}
2109
2110////////////////////////////////////////////////////////////////////////////////
2111/// Emit MouseOver signal.
2112
2114{
2115 Longptr_t args[2];
2116 args[0] = (Longptr_t)obj;
2117 args[1] = state;
2118 Emit("MouseOver(TObject*,UInt_t)", args);
2119}
2120
2121////////////////////////////////////////////////////////////////////////////////
2122/// Emit MouseOver signal.
2123
2125{
2126 Longptr_t args[2];
2127 args[0] = (Longptr_t)obj;
2128 args[1] = state;
2129 Emit("ReMouseOver(TObject*,UInt_t)", args);
2130}
2131
2132
2133////////////////////////////////////////////////////////////////////////////////
2134/// Emit UnMouseOver signal.
2135
2137{
2138 Longptr_t args[2];
2139 args[0] = (Longptr_t)obj;
2140 args[1] = state;
2141 Emit("UnMouseOver(TObject*,UInt_t)", args);
2142}
2143
2144////////////////////////////////////////////////////////////////////////////////
2145/// Emit Clicked signal.
2146
2148{
2149 Emit("Clicked(TObject*)", (Longptr_t)obj);
2150}
2151
2152////////////////////////////////////////////////////////////////////////////////
2153/// Emit Clicked signal with button id and modifier state.
2154
2155void TGLViewer::Clicked(TObject *obj, UInt_t button, UInt_t state)
2156{
2157 Longptr_t args[3];
2158 args[0] = (Longptr_t)obj;
2159 args[1] = button;
2160 args[2] = state;
2161 Emit("Clicked(TObject*,UInt_t,UInt_t)", args);
2162}
2163
2164
2165////////////////////////////////////////////////////////////////////////////////
2166/// Emit ReClicked signal with button id and modifier state.
2167
2169{
2170 Longptr_t args[3];
2171 args[0] = (Longptr_t)obj;
2172 args[1] = button;
2173 args[2] = state;
2174 Emit("ReClicked(TObject*,UInt_t,UInt_t)", args);
2175}
2176
2177////////////////////////////////////////////////////////////////////////////////
2178/// Emit UnClicked signal with button id and modifier state.
2179
2181{
2182 Longptr_t args[3];
2183 args[0] = (Longptr_t)obj;
2184 args[1] = button;
2185 args[2] = state;
2186 Emit("UnClicked(TObject*,UInt_t,UInt_t)", args);
2187}
2188
2189////////////////////////////////////////////////////////////////////////////////
2190/// Emit MouseIdle signal.
2191
2193{
2194 Longptr_t args[3];
2195 static UInt_t oldx = 0, oldy = 0;
2196
2197 if (oldx != posx || oldy != posy) {
2198 args[0] = (Longptr_t)shape;
2199 args[1] = posx;
2200 args[2] = posy;
2201 Emit("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", args);
2202 oldx = posx;
2203 oldy = posy;
2204 }
2205}
2206
2207/**************************************************************************/
2208/**************************************************************************/
2209////////////////////////////////////////////////////////////////////////////////
2210/// Calculate and return pixel distance to nearest viewer object from
2211/// window location px, py
2212/// This is provided for use when embedding GL viewer into pad
2213
2215{
2216 // Can't track the indvidual objects in rollover. Just set the viewer as the
2217 // selected object, and return 0 (object identified) so we receive ExecuteEvent calls
2218 gPad->SetSelected(this);
2219 return 0;
2220}
2221
2222////////////////////////////////////////////////////////////////////////////////
2223/// Process event of type 'event' - one of EEventType types,
2224/// occurring at window location px, py
2225/// This is provided for use when embedding GL viewer into pad
2226
2228{
2229 if (fEventHandler)
2230 return fEventHandler->ExecuteEvent(event, px, py);
2231}
2232
2233////////////////////////////////////////////////////////////////////////////////
2234/// Pass viewer for print capture by TGLOutput.
2235
2237{
2238 TGLOutput::Capture(*this);
2239}
2240
2241////////////////////////////////////////////////////////////////////////////////
2242/// Update GUI components for embedded viewer selection change.
2243
2245{
2246 if (!fGedEditor)
2247 return;
2248
2249 TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
2250
2251 if (selected) {
2252 fPShapeWrap->fPShape = selected;
2254 } else {
2255 fPShapeWrap->fPShape = 0;
2257 }
2258}
2259
2260////////////////////////////////////////////////////////////////////////////////
2261/// An overlay operation can result in change to an object.
2262/// Refresh geditor.
2263
2265{
2266 if (fGedEditor)
2267 {
2269 }
2270}
2271
2272////////////////////////////////////////////////////////////////////////////////
2273/// Update GED editor if it is set.
2274
2276{
2277 if (fGedEditor && (obj == 0 || fGedEditor->GetModel() == obj))
2278 {
2280 }
2281}
2282
2283////////////////////////////////////////////////////////////////////////////////
2284/// Set the event-handler. The event-handler is owned by the viewer.
2285/// If GLWidget is set, the handler is propagated to it.
2286///
2287/// If called with handler=0, the current handler will be deleted
2288/// (also from TGLWidget).
2289
2291{
2292 if (fEventHandler)
2293 delete fEventHandler;
2294
2295 fEventHandler = handler;
2296 if (fGLWidget)
2298}
2299
2300////////////////////////////////////////////////////////////////////////////////
2301/// Remove overlay element.
2302
2304{
2305 if (el == fCurrentOvlElm)
2306 {
2307 fCurrentOvlElm = 0;
2308 }
2310}
2311
2312////////////////////////////////////////////////////////////////////////////////
2313/// Reset current overlay-element to zero, eventually notifying the
2314/// old one that the mouse has left.
2315/// Usually called when mouse leaves the window.
2316
2318{
2319 if (fCurrentOvlElm)
2320 {
2322 fCurrentOvlElm = 0;
2323 RequestDraw();
2324 }
2325}
@ kButton1Down
Definition Buttons.h:17
#define GL_TRUE
Definition GL_glu.h:262
#define GL_QUADS
Definition GL_glu.h:290
#define GL_FALSE
Definition GL_glu.h:261
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
long Longptr_t
Definition RtypesCore.h:82
unsigned char UChar_t
Definition RtypesCore.h:38
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
short Short_t
Definition RtypesCore.h:39
double Double_t
Definition RtypesCore.h:59
short Color_t
Definition RtypesCore.h:92
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
#define GL_BGRA
Definition TGLViewer.cxx:61
Int_t gDebug
Definition TROOT.cxx:592
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:404
char * Form(const char *fmt,...)
@ kDragNone
#define gGLManager
Definition TVirtualGL.h:162
#define R__LOCKGUARD(mutex)
#define gPad
#define gVirtualX
Definition TVirtualX.h:338
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:30
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:33
The color creation and management class.
Definition TColor.h:19
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
Definition TColor.h:52
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:1822
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
Automatically rotates GL camera.
void Start()
Start the auto-rotator.
Bool_t IsRunning() const
TGLCamera * GetCamera() const
void Stop()
Stop the auto-rotator.
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
TGLVector3 Extents() const
TGLVertex3 Center() const
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
A GL overlay element which displays camera furstum.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition TGLCamera.h:44
virtual Bool_t IsPerspective() const
Definition TGLCamera.h:119
Double_t * GetCenterVec()
Definition TGLCamera.h:157
void DrawDebugAids() const
Draw out some debugging aids for the camera:
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)=0
void SetViewport(const TGLRect &viewport)
Set viewport extents from passed 'viewport' rect.
Definition TGLCamera.cxx:99
TGLMatrix & RefCamBase()
Definition TGLCamera.h:169
TGLVector3 ViewportDeltaToWorld(const TGLVertex3 &worldRef, Double_t viewportXDelta, Double_t viewportYDelta, TGLMatrix *modviewMat=0) const
Apply a 2D viewport delta (shift) to the projection of worldRef onto viewport, returning the resultan...
A collection of concrete TGLClip objects to be selected from.
Definition TGLClip.h:140
TGLClip * GetCurrentClip() const
Definition TGLClip.h:170
void SetupCurrentClip(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition TGLClip.cxx:435
void SetupCurrentClipIfInvalid(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition TGLClip.cxx:445
Class encapsulating a set of colors used throughout standard rendering.
Definition TGLUtil.h:836
TGLColor & Foreground()
Definition TGLUtil.h:852
void StdLightBackground()
Set defaults for light (white) background.
Definition TGLUtil.cxx:1389
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:1235
Color_t GetColorIndex() const
Returns color-index representing the color.
Definition TGLUtil.cxx:1217
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:214
void Init(int w, int h, int ms_samples=0)
Acquire GL resources for given width, height and number of multi-sampling samples.
Definition TGLFBO.cxx:73
void Bind()
Bind the frame-buffer object.
Definition TGLFBO.cxx:197
void SetAsReadBuffer()
Definition TGLFBO.cxx:261
void MakeFadeStep()
Make one fading step and request redraw.
Float_t fFadeTarget
Definition TGLViewer.h:438
Float_t fTime
Definition TGLViewer.h:439
TGLViewer * fViewer
Definition TGLViewer.h:437
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:54
virtual void SetPShape(TGLPhysicalShape *shape)
Set phys-shape, override of virtual from TGLPShapeRef.
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition TGLUtil.h:598
void Set(const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis=0)
Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.
Definition TGLUtil.cxx:736
TGLVector3 GetBaseVec(Int_t b) const
Definition TGLUtil.h:754
TGLVector3 GetTranslation() const
Return the translation component of matrix.
Definition TGLUtil.cxx:794
Orthographic projection camera.
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by 'box' and call Reset() to initialise...
virtual void Configure(Double_t zoom, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Configure the camera state.
static Bool_t Capture(TGLViewer &viewer, EFormat format, const char *filePath=0)
Capture viewer to file.
Definition TGLOutput.cxx:43
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.
TGLOverlayElement * GetOvlElement() const
virtual void Reset()
Reinitialise all data to null values.
Wrap TGLPysicalShape into TObject so that it can be edited using GED.
TGLPhysicalShape * fPShape
TGLPhysicalShape * GetPShape() const
Perspective projection camera - with characteristic foreshortening.
virtual void Configure(Double_t fov, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Configure the camera state.
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by 'box' and call Reset() to initialise...
Concrete physical shape - a GL drawable.
UInt_t ID() const
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
Viewport (pixel base) 2D rectangle class.
Definition TGLUtil.h: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
virtual void Stop()
Definition TGLViewer.h:417
void RequestDraw(Int_t milliSec, Short_t redrawLOD)
Definition TGLViewer.h:410
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: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
UInt_t * RawRecord(Int_t i)
void SetRawOnly(UInt_t *data)
Setup the record from raw buffer.
Standard selection record including information about containing scene and details ob out selected ob...
static Bool_t AreSameSelectionWise(const TGLSelectRecord &r1, const TGLSelectRecord &r2)
Check if the records imply the same selection result, that is, their secondary members are all equal.
Bool_t GetTransparent() const
TGLLogicalShape * GetLogShape() const
TGLPhysicalShape * GetPhysShape() const
virtual void Reset()
Reinitialise all data to null values.
void Print()
Print contents of the select record to stdout.
TGLSceneInfo * GetSceneInfo() const
Stopwatch object for timing GL work.
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:2351
static const UChar_t fgWhite[4]
Definition TGLUtil.h:1053
static void SetLineWidthScale(Float_t scale)
Set global line-width scale.
Definition TGLUtil.cxx:1901
static Int_t CheckError(const char *loc)
Check current GL error state, outputting details via ROOT Error method if one.
Definition TGLUtil.cxx:1640
static void ColorAlpha(const TGLColor &color, UChar_t alpha)
Set color from TGLColor and alpha value.
Definition TGLUtil.cxx:1699
static Int_t GetPickingRadius()
Returns picking radius.
Definition TGLUtil.cxx:1865
static void SetPointSizeScale(Float_t scale)
Set global point-size scale.
Definition TGLUtil.cxx:1885
static const UChar_t fgGreen[4]
Definition TGLUtil.h:1050
static void PointToViewport(Int_t &x, Int_t &y)
Convert from point/screen coordinates to GL viewport coordinates.
Definition TGLUtil.cxx:1817
static void DrawReferenceMarker(const TGLCamera &camera, const TGLVertex3 &pos, Float_t radius=3, const UChar_t *rgba=0)
Draw a sphere- marker on world-coordinate 'pos' with pixel radius 'radius'.
Definition TGLUtil.cxx:2473
static void DrawSimpleAxes(const TGLCamera &camera, const TGLBoundingBox &bbox, Int_t axesType)
Draw simple xyz-axes for given bounding-box.
Definition TGLUtil.cxx:2488
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'.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition TGLViewer.h:55
TGLRedrawTimer * fRedrawTimer
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
size scale for points
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
reference marker on?
Definition TGLViewer.h:151
virtual void RefreshPadEditor(TObject *obj=0)
Update GED editor if it is set.
Bool_t fAxesDepthTest
axes type
Definition TGLViewer.h:147
virtual void SetEventHandler(TGEventHandler *handler)
Set the event-handler.
TGLPerspectiveCamera fPerspectiveCameraYOZ
Definition TGLViewer.h:86
TGLOrthoCamera fOrthoXOYCamera
Definition TGLViewer.h:88
TGLSelectRecord fSelRec
select record in use as selected
Definition TGLViewer.h:112
void SetFader(Float_t x)
Definition TGLViewer.h:349
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.
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
void InitGL()
Initialise GL state.
virtual void SetupClipObject()
name says it all
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
debug mode (forced rebuild + draw scene/frustum/interest boxes)
Definition TGLViewer.h:157
static TGLColorSet fgDefaultColorSet
fade the view (0 - no fade/default, 1 - full fade/no rendering done)
Definition TGLViewer.h:161
TGEventHandler * fEventHandler
select record from last overlay select
Definition TGLViewer.h:119
TGLPerspectiveCamera fPerspectiveCameraXOY
Definition TGLViewer.h:87
TGLOrthoCamera fOrthoZnOYCamera
Definition TGLViewer.h:94
TGLRect fViewport
max time for scene rendering at high LOD (in ms)
Definition TGLViewer.h:139
virtual void SelectionChanged()
Update GUI components for embedded viewer selection change.
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 marker on?
Definition TGLViewer.h:149
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.
virtual void PadPaint(TVirtualPad *pad)
Entry point for updating viewer contents via VirtualViewer3D interface.
TGLPShapeObj * fPShapeWrap
GED editor.
Definition TGLViewer.h:121
TGLSelectRecord fSecSelRec
select record from last select (should go to context)
Definition TGLViewer.h:113
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
remove guides hidden-lines
Definition TGLViewer.h:148
TGLCamera & CurrentCamera() const
Definition TGLViewer.h:267
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
virtual void PrintObjects()
Pass viewer for print capture by TGLOutput.
Int_t fAxesType
smooth line edge rendering
Definition TGLViewer.h:146
void SetStereo(Bool_t stereo, Bool_t quad_buf=kTRUE)
Enable stereo rendering.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Process event of type 'event' - one of EEventType types, occurring at window location px,...
TImage * GetPictureUsingBB()
Returns current image.
TGLCamera & RefCamera(ECameraType camera)
Return camera reference by type.
TContextMenu * fContextMenu
external pad - remove replace with signal
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
draw quad buffer or left/right stereo in left/right half of window
Definition TGLViewer.h:102
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Calculate and return pixel distance to nearest viewer object from window location px,...
virtual void Render()
Normal rendering, used by mono and stereo rendering.
virtual void PostSceneBuildSetup(Bool_t resetCameras)
Perform post scene-build setup.
Float_t fStereoEyeOffsetFac
position of zero-parallax plane: 0 - near clipping plane, 1 - far clipping plane
Definition TGLViewer.h:103
virtual ~TGLViewer()
Destroy viewer object.
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
default file-name for SavePicture()
Definition TGLViewer.h:159
virtual void PostRender()
Restore state set in PreRender().
@ 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
TGLOrthoCamera fOrthoXOZCamera
Definition TGLViewer.h:89
Bool_t GetClipAutoUpdate() const
Definition TGLViewer.h:263
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
timer for triggering redraws
Definition TGLViewer.h:136
Bool_t RequestSecondarySelect(Int_t x, Int_t y)
Request secondary select.
TGedEditor * fGedEditor
event handler
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
color-set with light background
Definition TGLViewer.h:142
TGLColorSet fLightColorSet
color-set with dark background
Definition TGLViewer.h:141
TGLClipSet * fClipSet
Definition TGLViewer.h:109
Bool_t fStereo
Definition TGLViewer.h:100
virtual void PreRender()
Initialize objects that influence rendering.
virtual void UnMouseOver(TObject *obj, UInt_t state)
Emit UnMouseOver signal.
TVirtualPad * fPad
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
width scale for lines
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 point edge rendering
Definition TGLViewer.h:145
TGLManipSet * fSelectedPShapeRef
select record from last secondary select (should go to context)
Definition TGLViewer.h:114
TString fPictureFileName
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
viewport - drawn area
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:348
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.
Bool_t DoOverlaySelect(Int_t x, Int_t y)
Perform GL selection, picking overlay objects only.
Bool_t fDrawCameraCenter
reference position
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
const TGLPhysicalShape * GetSelected() const
Return selected physical shape.
Float_t fStereoFrustumAsymFac
Definition TGLViewer.h:104
Bool_t fDebugMode
cache logicals during scene rebuilds
Definition TGLViewer.h:156
TGLOrthoCamera fOrthoXnOYCamera
Definition TGLViewer.h:92
static Bool_t fgUseDefaultColorSetForNewViewers
a shared, default color-set
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.
TGLSelectRecord fCurrentSelRec
Definition TGLViewer.h:111
TGLViewer(const TGLViewer &)=delete
void DoDrawMono(Bool_t swap_buffers)
Draw out in monoscopic mode.
Bool_t fStereoQuadBuf
use stereo rendering
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
Definition TGLViewer.h:186
static void UseDefaultColorSetForNewViewers(Bool_t x)
Sets static flag that determines if new viewers should use the default color-set.
TGLOvlSelectRecord fOvlSelRec
current overlay element
Definition TGLViewer.h:117
TGLOverlayElement * fCurrentOvlElm
Definition TGLViewer.h:116
void SwapBuffers() const
Swap GL buffers.
void ResetCurrentCamera()
Resets position/rotation of current camera to default values.
Bool_t MakeCurrent()
Make the gl-context current.
void SwapBuffers()
Swap buffers.
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
const TGLFormat * GetPixelFormat() const
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:29
static TImage * Create()
Create an image.
Definition TImage.cxx:35
virtual void FromGLBuffer(UChar_t *, UInt_t, UInt_t)
Definition TImage.h:245
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:949
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition TObject.cxx:383
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:963
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:937
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:136
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2202
const char * Data() const
Definition TString.h:369
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:624
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:256
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
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:663
constexpr Double_t DegToRad()
Conversion from degree to radian:
Definition TMath.h:81
Int_t CeilNint(Double_t x)
Definition TMath.h:649
Double_t Tan(Double_t)
Definition TMath.h:597
Short_t Abs(Short_t d)
Definition TMathBase.h:120