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