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 "TClass.h"
41#include "TEnv.h"
42
43// For event type translation ExecuteEvent
44#include "Buttons.h"
45#include "GuiTypes.h"
46
47#include "TVirtualGL.h"
48
49#include "TGLWidget.h"
50#include "TGLFBO.h"
51#include "TGLViewerEditor.h"
52#include "TGedEditor.h"
53#include "TGLPShapeObj.h"
54
55#include "KeySymbols.h"
56#include "TContextMenu.h"
57#include "TImage.h"
58
59#include <stdexcept>
60
61#ifndef GL_BGRA
62#define GL_BGRA GL_BGRA_EXT
63#endif
64
65/** \class TGLViewer
66\ingroup opengl
67Base GL viewer object - used by both standalone and embedded (in pad)
68GL. Contains core viewer objects :
69
70GL scene - collection of main drawn objects - see TGLStdScene
71Cameras (fXyzzCamera) - ortho and perspective cameras - see TGLCamera
72Clipping (fClipXyzz) - collection of clip objects - see TGLClip
73Manipulators (fXyzzManip) - collection of manipulators - see TGLManip
74
75It maintains the current active draw styles, clipping object,
76manipulator, camera etc.
77
78TGLViewer is 'GUI free' in that it does not derive from any ROOT GUI
79TGFrame etc - see TGLSAViewer for this. However it contains GUI
80GUI style methods HandleButton() etc to which GUI events can be
81directed from standalone frame or embedding pad to perform
82interaction.
83
84Also, the TGLWidget needs to be created externally. It is not owned
85by the viewer.
86
87For embedded (pad) GL this viewer is created directly by plugin
88manager. For standalone the derived TGLSAViewer is.
89*/
90
92
95
96////////////////////////////////////////////////////////////////////////////////
97
99 Int_t width, Int_t height) :
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
160 SetViewport(x, y, width, height);
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%lx)->DoDraw()", (ULong_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%lx)->DoDraw(kFALSE)", (ULong_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 {
915 fbo->Init(w, h, fGLWidget->GetPixelFormat()->GetSamples());
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%lx)->DoDraw(kFALSE)", (ULong_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%lx)->DoDraw(kFALSE)", (ULong_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%lx)->DoDraw(kFALSE)", (ULong_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();
1120 Int_t height = TMath::Nint(scale*fViewport.Height());
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);
1204 Double_t size = fOverallBoundingBox.Extents().Mag() / 200.0;
1205 TGLUtil::DrawSphere(TGLVertex3(0.0, 0.0, 0.0), size, TGLUtil::fgWhite);
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%lx)->DoSelect(%d, %d)", (ULong_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%lx)->DoSecondarySelect(%d, %d)", (ULong_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%lx, pshape=0x%lx).\n",
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%lx)->DoOverlaySelect(%d, %d)", (ULong_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/// Returns true if current color set is dark.
1708
1710{
1712}
1713
1714/**************************************************************************/
1715// Viewport
1716/**************************************************************************/
1717
1718////////////////////////////////////////////////////////////////////////////////
1719/// Set viewer viewport (window area) with bottom/left at (x,y), with
1720/// dimensions 'width'/'height'
1721
1723{
1724 if (fStereo && ! fStereoQuadBuf) width /= 2;
1725
1726 // Only process if changed
1727 if (fViewport.X() == x && fViewport.Y() == y &&
1728 fViewport.Width() == width && fViewport.Height() == height) {
1729 return;
1730 }
1731
1732 fViewport.Set(x, y, width, height);
1734
1735 if (gDebug > 2) {
1736 Info("TGLViewer::SetViewport", "updated - corner %d,%d dimensions %d,%d", x, y, width, height);
1737 }
1738}
1739
1741{
1742 // Set viewer viewport from TGLRect.
1743
1744 SetViewport(vp.X(), vp.Y(), vp.Width(), vp.Height());
1745}
1746
1747/**************************************************************************/
1748// Camera methods
1749/**************************************************************************/
1750
1751////////////////////////////////////////////////////////////////////////////////
1752/// Return camera reference by type.
1753
1755{
1756 // TODO: Move these into a vector!
1757 switch(cameraType) {
1758 case kCameraPerspXOZ:
1759 return fPerspectiveCameraXOZ;
1760 case kCameraPerspYOZ:
1761 return fPerspectiveCameraYOZ;
1762 case kCameraPerspXOY:
1763 return fPerspectiveCameraXOY;
1764 case kCameraOrthoXOY:
1765 return fOrthoXOYCamera;
1766 case kCameraOrthoXOZ:
1767 return fOrthoXOZCamera;
1768 case kCameraOrthoZOY:
1769 return fOrthoZOXCamera;
1770 case kCameraOrthoZOX:
1771 return fOrthoZOYCamera;
1772 case kCameraOrthoXnOY:
1773 return fOrthoXnOYCamera;
1774 case kCameraOrthoXnOZ:
1775 return fOrthoXnOZCamera;
1776 case kCameraOrthoZnOY:
1777 return fOrthoZnOYCamera;
1778 case kCameraOrthoZnOX:
1779 return fOrthoZnOXCamera;
1780 default:
1781 Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1782 return *fCurrentCamera;
1783 }
1784}
1785
1786////////////////////////////////////////////////////////////////////////////////
1787/// Set current active camera - 'cameraType' one of:
1788/// kCameraPerspX, kCameraPerspY, kCameraPerspZ,
1789/// kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY,
1790/// kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY
1791
1793{
1794 if (IsLocked()) {
1795 Error("TGLViewer::SetCurrentCamera", "expected kUnlocked, found %s", LockName(CurrentLock()));
1796 return;
1797 }
1798
1799 // TODO: Move these into a vector!
1800 TGLCamera *prev = fCurrentCamera;
1801 switch (cameraType)
1802 {
1803 case kCameraPerspXOZ: {
1805 break;
1806 }
1807 case kCameraPerspYOZ: {
1809 break;
1810 }
1811 case kCameraPerspXOY: {
1813 break;
1814 }
1815 case kCameraOrthoXOY: {
1817 break;
1818 }
1819 case kCameraOrthoXOZ: {
1821 break;
1822 }
1823 case kCameraOrthoZOY: {
1825 break;
1826 }
1827 case kCameraOrthoZOX: {
1829 break;
1830 }
1831 case kCameraOrthoXnOY: {
1833 break;
1834 }
1835 case kCameraOrthoXnOZ: {
1837 break;
1838 }
1839 case kCameraOrthoZnOY: {
1841 break;
1842 }
1843 case kCameraOrthoZnOX: {
1845 break;
1846 }
1847 default: {
1848 Error("TGLViewer::SetCurrentCamera", "invalid camera type");
1849 break;
1850 }
1851 }
1852
1853 if (fCurrentCamera != prev)
1854 {
1855 // Ensure any viewport has been propagated to the current camera
1857 RefreshPadEditor(this);
1858
1859 if (fAutoRotator)
1860 {
1861 if (fAutoRotator->IsRunning())
1862 {
1863 fAutoRotator->Stop();
1864 }
1865 else
1866 {
1868 {
1870 }
1871 }
1872 }
1873
1875 }
1876}
1877
1878////////////////////////////////////////////////////////////////////////////////
1879/// Set an orthographic camera to supplied configuration - note this
1880/// does not need to be the current camera - though you will not see
1881/// the effect if it is not.
1882///
1883/// 'camera' defines the ortho camera - one of kCameraOrthoXOY / XOZ / ZOY
1884/// 'left' / 'right' / 'top' / 'bottom' define the WORLD coordinates which
1885/// correspond with the left/right/top/bottom positions on the GL viewer viewport
1886/// E.g. for kCameraOrthoXOY camera left/right are X world coords,
1887/// top/bottom are Y world coords
1888/// As this is an orthographic camera the other axis (in eye direction) is
1889/// no relevant. The near/far clip planes are set automatically based in scene
1890/// contents
1891
1893 Double_t zoom, Double_t dolly,
1894 Double_t center[3],
1895 Double_t hRotate, Double_t vRotate)
1896{
1897 // TODO: Move these into a vector!
1898 switch(camera) {
1899 case kCameraOrthoXOY: {
1900 fOrthoXOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1903 }
1904 break;
1905 }
1906 case kCameraOrthoXOZ: {
1907 fOrthoXOZCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1910 }
1911 break;
1912 }
1913 case kCameraOrthoZOY: {
1914 fOrthoZOYCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1917 }
1918 break;
1919 }
1920 case kCameraOrthoZOX: {
1921 fOrthoZOXCamera.Configure(zoom, dolly, center, hRotate, vRotate);
1924 }
1925 break;
1926 }
1927 default: {
1928 Error("TGLViewer::SetOrthoCamera", "invalid camera type");
1929 break;
1930 }
1931 }
1932}
1933
1934////////////////////////////////////////////////////////////////////////////////
1935/// Set a perspective camera to supplied configuration - note this
1936/// does not need to be the current camera - though you will not see
1937/// the effect if it is not.
1938///
1939/// - 'camera' defines the persp camera - one of kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY
1940/// - 'fov' - field of view (lens angle) in degrees (clamped to 0.1 - 170.0)
1941/// - 'dolly' - distance from 'center'
1942/// - 'center' - world position from which dolly/hRotate/vRotate are measured
1943/// camera rotates round this, always facing in (in center of viewport)
1944/// - 'hRotate' - horizontal rotation from initial configuration in degrees
1945/// - 'hRotate' - vertical rotation from initial configuration in degrees
1946
1948 Double_t fov, Double_t dolly,
1949 Double_t center[3],
1950 Double_t hRotate, Double_t vRotate)
1951{
1952 // TODO: Move these into a vector!
1953 switch(camera) {
1954 case kCameraPerspXOZ: {
1955 fPerspectiveCameraXOZ.Configure(fov, dolly, center, hRotate, vRotate);
1958 }
1959 break;
1960 }
1961 case kCameraPerspYOZ: {
1962 fPerspectiveCameraYOZ.Configure(fov, dolly, center, hRotate, vRotate);
1965 }
1966 break;
1967 }
1968 case kCameraPerspXOY: {
1969 fPerspectiveCameraXOY.Configure(fov, dolly, center, hRotate, vRotate);
1972 }
1973 break;
1974 }
1975 default: {
1976 Error("TGLViewer::SetPerspectiveCamera", "invalid camera type");
1977 break;
1978 }
1979 }
1980}
1981
1982////////////////////////////////////////////////////////////////////////////////
1983/// Change base-vectors defining the camera-base transformation of current
1984/// camera. hAxis and vAxis are the default directions for forward
1985/// (inverted) and upwards.
1986
1988{
1990 cb.Set(cb.GetTranslation(), vAxis, hAxis);
1992 if (redraw)
1993 RequestDraw();
1994}
1995
1996////////////////////////////////////////////////////////////////////////////////
1997/// Get the auto-rotator for this viewer.
1998
2000{
2001 if (fAutoRotator == 0)
2002 fAutoRotator = new TGLAutoRotator(this);
2003 return fAutoRotator;
2004}
2005
2006////////////////////////////////////////////////////////////////////////////////
2007/// Set the auto-rotator for this viewer. The old rotator is deleted.
2008
2010{
2011 delete fAutoRotator;
2012 fAutoRotator = ar;
2013}
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Enable stereo rendering.
2017/// If quad_buf is true rendering is done into separate left and right GL
2018/// buffers. This requires hardware support. Otherwise left and right images
2019/// get rendered into left and right half of the window.
2020/// Note that mouse highlighting and selection will not work exactly right
2021/// as image for each eye gets slightly shifted and there are two different
2022/// directions through the mouse pointer, one for each eye.
2023
2024void TGLViewer::SetStereo(Bool_t stereo, Bool_t quad_buf)
2025{
2026 if (stereo != fStereo)
2027 {
2028 fStereo = stereo;
2029 fStereoQuadBuf = quad_buf;
2030 if (fStereo)
2032 else
2034 }
2036}
2037
2038/**************************************************************************/
2039// Guide methods
2040/**************************************************************************/
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Fetch the state of guides (axes & reference markers) into arguments
2044
2045void TGLViewer::GetGuideState(Int_t & axesType, Bool_t & axesDepthTest, Bool_t & referenceOn, Double_t referencePos[3]) const
2046{
2047 axesType = fAxesType;
2048 axesDepthTest = fAxesDepthTest;
2049
2050 referenceOn = fReferenceOn;
2051 referencePos[0] = fReferencePos.X();
2052 referencePos[1] = fReferencePos.Y();
2053 referencePos[2] = fReferencePos.Z();
2054}
2055
2056////////////////////////////////////////////////////////////////////////////////
2057/// Set the state of guides (axes & reference markers) from arguments.
2058
2059void TGLViewer::SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t referencePos[3])
2060{
2061 fAxesType = axesType;
2062 fAxesDepthTest = axesDepthTest;
2063 fReferenceOn = referenceOn;
2064 if (referencePos)
2065 fReferencePos.Set(referencePos[0], referencePos[1], referencePos[2]);
2066 if (fGLDevice != -1)
2067 gGLManager->MarkForDirectCopy(fGLDevice, kTRUE);
2068 RequestDraw();
2069}
2070
2071////////////////////////////////////////////////////////////////////////////////
2072/// Draw camera look at and rotation point.
2073
2075{
2077 RequestDraw();
2078}
2079
2080// Selected physical
2081////////////////////////////////////////////////////////////////////////////////
2082/// Return selected physical shape.
2083
2085{
2086 return fSelectedPShapeRef->GetPShape();
2087}
2088
2089/**************************************************************************/
2090/**************************************************************************/
2091
2092////////////////////////////////////////////////////////////////////////////////
2093/// Emit MouseOver signal.
2094
2096{
2097 Emit("MouseOver(TGLPhysicalShape*)", (Long_t)shape);
2098}
2099
2100////////////////////////////////////////////////////////////////////////////////
2101/// Emit MouseOver signal.
2102
2104{
2105 Long_t args[2];
2106 args[0] = (Long_t)shape;
2107 args[1] = state;
2108 Emit("MouseOver(TGLPhysicalShape*,UInt_t)", args);
2109}
2110
2111////////////////////////////////////////////////////////////////////////////////
2112/// Emit MouseOver signal.
2113
2115{
2116 Long_t args[2];
2117 args[0] = (Long_t)obj;
2118 args[1] = state;
2119 Emit("MouseOver(TObject*,UInt_t)", args);
2120}
2121
2122////////////////////////////////////////////////////////////////////////////////
2123/// Emit MouseOver signal.
2124
2126{
2127 Long_t args[2];
2128 args[0] = (Long_t)obj;
2129 args[1] = state;
2130 Emit("ReMouseOver(TObject*,UInt_t)", args);
2131}
2132
2133
2134////////////////////////////////////////////////////////////////////////////////
2135/// Emit UnMouseOver signal.
2136
2138{
2139 Long_t args[2];
2140 args[0] = (Long_t)obj;
2141 args[1] = state;
2142 Emit("UnMouseOver(TObject*,UInt_t)", args);
2143}
2144
2145////////////////////////////////////////////////////////////////////////////////
2146/// Emit Clicked signal.
2147
2149{
2150 Emit("Clicked(TObject*)", (Long_t)obj);
2151}
2152
2153////////////////////////////////////////////////////////////////////////////////
2154/// Emit Clicked signal with button id and modifier state.
2155
2156void TGLViewer::Clicked(TObject *obj, UInt_t button, UInt_t state)
2157{
2158 Long_t args[3];
2159 args[0] = (Long_t)obj;
2160 args[1] = button;
2161 args[2] = state;
2162 Emit("Clicked(TObject*,UInt_t,UInt_t)", args);
2163}
2164
2165
2166////////////////////////////////////////////////////////////////////////////////
2167/// Emit ReClicked signal with button id and modifier state.
2168
2170{
2171 Long_t args[3];
2172 args[0] = (Long_t)obj;
2173 args[1] = button;
2174 args[2] = state;
2175 Emit("ReClicked(TObject*,UInt_t,UInt_t)", args);
2176}
2177
2178////////////////////////////////////////////////////////////////////////////////
2179/// Emit UnClicked signal with button id and modifier state.
2180
2182{
2183 Long_t args[3];
2184 args[0] = (Long_t)obj;
2185 args[1] = button;
2186 args[2] = state;
2187 Emit("UnClicked(TObject*,UInt_t,UInt_t)", args);
2188}
2189
2190////////////////////////////////////////////////////////////////////////////////
2191/// Emit MouseIdle signal.
2192
2194{
2195 Long_t args[3];
2196 static UInt_t oldx = 0, oldy = 0;
2197
2198 if (oldx != posx || oldy != posy) {
2199 args[0] = (Long_t)shape;
2200 args[1] = posx;
2201 args[2] = posy;
2202 Emit("MouseIdle(TGLPhysicalShape*,UInt_t,UInt_t)", args);
2203 oldx = posx;
2204 oldy = posy;
2205 }
2206}
2207
2208/**************************************************************************/
2209/**************************************************************************/
2210////////////////////////////////////////////////////////////////////////////////
2211/// Calculate and return pixel distance to nearest viewer object from
2212/// window location px, py
2213/// This is provided for use when embedding GL viewer into pad
2214
2216{
2217 // Can't track the indvidual objects in rollover. Just set the viewer as the
2218 // selected object, and return 0 (object identified) so we receive ExecuteEvent calls
2219 gPad->SetSelected(this);
2220 return 0;
2221}
2222
2223////////////////////////////////////////////////////////////////////////////////
2224/// Process event of type 'event' - one of EEventType types,
2225/// occurring at window location px, py
2226/// This is provided for use when embedding GL viewer into pad
2227
2229{
2230 if (fEventHandler)
2231 return fEventHandler->ExecuteEvent(event, px, py);
2232}
2233
2234////////////////////////////////////////////////////////////////////////////////
2235/// Pass viewer for print capture by TGLOutput.
2236
2238{
2239 TGLOutput::Capture(*this);
2240}
2241
2242////////////////////////////////////////////////////////////////////////////////
2243/// Update GUI components for embedded viewer selection change.
2244
2246{
2247 if (!fGedEditor)
2248 return;
2249
2250 TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
2251
2252 if (selected) {
2253 fPShapeWrap->fPShape = selected;
2255 } else {
2256 fPShapeWrap->fPShape = 0;
2258 }
2259}
2260
2261////////////////////////////////////////////////////////////////////////////////
2262/// An overlay operation can result in change to an object.
2263/// Refresh geditor.
2264
2266{
2267 if (fGedEditor)
2268 {
2270 }
2271}
2272
2273////////////////////////////////////////////////////////////////////////////////
2274/// Update GED editor if it is set.
2275
2277{
2278 if (fGedEditor && (obj == 0 || fGedEditor->GetModel() == obj))
2279 {
2281 }
2282}
2283
2284////////////////////////////////////////////////////////////////////////////////
2285/// Set the event-handler. The event-handler is owned by the viewer.
2286/// If GLWidget is set, the handler is propagated to it.
2287///
2288/// If called with handler=0, the current handler will be deleted
2289/// (also from TGLWidget).
2290
2292{
2293 if (fEventHandler)
2294 delete fEventHandler;
2295
2296 fEventHandler = handler;
2297 if (fGLWidget)
2299}
2300
2301////////////////////////////////////////////////////////////////////////////////
2302/// Remove overlay element.
2303
2305{
2306 if (el == fCurrentOvlElm)
2307 {
2308 fCurrentOvlElm = 0;
2309 }
2311}
2312
2313////////////////////////////////////////////////////////////////////////////////
2314/// Reset current overlay-element to zero, eventually notifying the
2315/// old one that the mouse has left.
2316/// Usually called when mouse leaves the window.
2317
2319{
2320 if (fCurrentOvlElm)
2321 {
2323 fCurrentOvlElm = 0;
2324 RequestDraw();
2325 }
2326}
@ 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
unsigned char UChar_t
Definition: RtypesCore.h:36
const Bool_t kFALSE
Definition: RtypesCore.h:90
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
short Short_t
Definition: RtypesCore.h:37
double Double_t
Definition: RtypesCore.h:57
short Color_t
Definition: RtypesCore.h:81
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
#define GL_BGRA
Definition: TGLViewer.cxx:62
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:59
#define gROOT
Definition: TROOT.h:406
char * Form(const char *fmt,...)
@ kDragNone
#define gGLManager
Definition: TVirtualGL.h:162
#define R__LOCKGUARD(mutex)
#define gPad
Definition: TVirtualPad.h:287
#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:51
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
Automatically rotates GL camera.
void Start()
Start the auto-rotator.
Bool_t IsRunning() const
TGLCamera * GetCamera() const
void Stop()
Stop the auto-rotator.
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
TGLVector3 Extents() const
TGLVertex3 Center() const
void Draw(Bool_t solid=kFALSE) const
Draw the bounding box as either wireframe (default) of solid using current GL color.
A GL overlay element which displays camera furstum.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:43
virtual Bool_t IsPerspective() const
Definition: TGLCamera.h:118
Double_t * GetCenterVec()
Definition: TGLCamera.h:156
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:168
TGLVector3 ViewportDeltaToWorld(const TGLVertex3 &worldRef, Double_t viewportXDelta, Double_t viewportYDelta, TGLMatrix *modviewMat=0) const
Apply a 2D viewport delta (shift) to the projection of worldRef onto viewport, returning the resultan...
Definition: TGLCamera.cxx:546
A collection of concrete TGLClip objects to be selected from.
Definition: TGLClip.h:140
TGLClip * GetCurrentClip() const
Definition: TGLClip.h:170
void SetupCurrentClip(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition: TGLClip.cxx:435
void SetupCurrentClipIfInvalid(const TGLBoundingBox &sceneBBox)
Setup current clipping object for given scene bounding box.
Definition: TGLClip.cxx:445
Class encapsulating a set of colors used throughout standard rendering.
Definition: TGLUtil.h:835
TGLColor & Foreground()
Definition: TGLUtil.h:851
void StdLightBackground()
Set defaults for light (white) background.
Definition: TGLUtil.cxx:1390
TGLColor & Background()
Definition: TGLUtil.h:850
void SetColor(Int_t r, Int_t g, Int_t b, Int_t a=255)
Set color with Int_t values.
Definition: TGLUtil.cxx:1236
Color_t GetColorIndex() const
Returns color-index representing the color.
Definition: TGLUtil.cxx:1218
Identifier of a shared GL-context.
Definition: TGLContext.h:81
void DeleteGLResources()
Delete GL resources registered for destruction.
Definition: TGLContext.cxx:522
void Release(TGLContext *ctx)
Remove context ctx from the list of references.
Definition: TGLContext.cxx:496
void AddRef(TGLContext *ctx)
Add context ctx to the list of references.
Definition: TGLContext.cxx:487
Frame-buffer object.
Definition: TGLFBO.h:18
void Unbind()
Unbind the frame-buffer object.
Definition: TGLFBO.cxx:214
void Init(int w, int h, int ms_samples=0)
Acquire GL resources for given width, height and number of multi-sampling samples.
Definition: TGLFBO.cxx:73
void Bind()
Bind the frame-buffer object.
Definition: TGLFBO.cxx:197
void SetAsReadBuffer()
Definition: TGLFBO.cxx:261
void MakeFadeStep()
Make one fading step and request redraw.
Definition: TGLViewer.cxx:1579
Float_t fFadeTarget
Definition: TGLViewer.h:440
Float_t fTime
Definition: TGLViewer.h:441
TGLViewer * fViewer
Definition: TGLViewer.h:439
Int_t GetSamples() const
Get the number of samples for multi-sampling.
Definition: TGLFormat.cxx:211
Encapsulates a set of lights for OpenGL.
Definition: TGLLightSet.h:22
void StdSetupLights(const TGLBoundingBox &bbox, const TGLCamera &camera, Bool_t debug=kFALSE)
Setup lights for current given bounding box and camera.
Definition: TGLLightSet.cxx:76
Bool_t TakeLock(ELock lock) const
Lock the object in mode 'lock'.
Definition: TGLLockable.cxx:32
ELock CurrentLock() const
Definition: TGLLockable.h:61
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the 'lock' argument.
Definition: TGLLockable.cxx:51
static const char * LockName(ELock lock)
Return name-string for given lock-type.
Definition: TGLLockable.cxx:69
Bool_t IsLocked() const
Definition: TGLLockable.h:60
Bool_t IsDrawOrSelectLock() const
Definition: TGLLockable.h:63
virtual Bool_t SupportsSecondarySelect() const
Combine all available manipulators in a collection.
Definition: TGLManipSet.h:23
void SetDrawBBox(Bool_t bb)
Definition: TGLManipSet.h:55
virtual void SetPShape(TGLPhysicalShape *shape)
Set phys-shape, override of virtual from TGLPShapeRef.
Definition: TGLManipSet.cxx:64
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:597
void Set(const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis=0)
Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.
Definition: TGLUtil.cxx:737
TGLVector3 GetBaseVec(Int_t b) const
Definition: TGLUtil.h:753
TGLVector3 GetTranslation() const
Return the translation component of matrix.
Definition: TGLUtil.cxx:795
Orthographic projection camera.
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by 'box' and call Reset() to initialise...
virtual void Configure(Double_t zoom, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Configure the camera state.
static Bool_t Capture(TGLViewer &viewer, EFormat format, const char *filePath=0)
Capture viewer to file.
Definition: TGLOutput.cxx:42
@ kEPS_BSP
Definition: TGLOutput.h:28
@ kPDF_BSP
Definition: TGLOutput.h:28
An overlay element.
Definition: TGLOverlay.h:23
virtual Bool_t MouseEnter(TGLOvlSelectRecord &selRec)
Mouse has entered this element.
Definition: TGLOverlay.cxx:25
virtual Bool_t MouseStillInside(TGLOvlSelectRecord &selRec)
Definition: TGLOverlay.cxx:30
virtual void MouseLeave()
Mouse has left the element.
Definition: TGLOverlay.cxx:56
TGLOverlayElement * GetOvlElement() const
virtual void Reset()
Reinitialise all data to null values.
Wrap TGLPysicalShape into TObject so that it can be edited using GED.
Definition: TGLPShapeObj.h:21
TGLPhysicalShape * fPShape
Definition: TGLPShapeObj.h:23
TGLPhysicalShape * GetPShape() const
Definition: TGLPShapeRef.h:36
Perspective projection camera - with characteristic foreshortening.
virtual void Configure(Double_t fov, Double_t dolly, Double_t center[3], Double_t hRotate, Double_t vRotate)
Configure the camera state.
virtual void Setup(const TGLBoundingBox &box, Bool_t reset=kTRUE)
Setup camera limits suitable to view the world volume defined by 'box' and call Reset() to initialise...
Concrete physical shape - a GL drawable.
UInt_t ID() const
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
Viewport (pixel base) 2D rectangle class.
Definition: TGLUtil.h:421
Int_t Y() const
Definition: TGLUtil.h:447
Int_t Height() const
Definition: TGLUtil.h:451
Int_t Width() const
Definition: TGLUtil.h:449
void Set(Int_t x, Int_t y, Int_t width, Int_t height)
Definition: TGLUtil.h:470
Int_t X() const
Definition: TGLUtil.h:445
Double_t Aspect() const
Definition: TGLUtil.h:499
virtual void Stop()
Definition: TGLViewer.h:419
void RequestDraw(Int_t milliSec, Short_t redrawLOD)
Definition: TGLViewer.h:412
void SetRenderScale(Float_t s)
Definition: TGLRnrCtx.h:245
void SetSceneInfo(TGLSceneInfo *si)
Definition: TGLRnrCtx.h:168
TGLColorSet * ChangeBaseColorSet(TGLColorSet *set)
Change the default/bottom color-set.
Definition: TGLRnrCtx.cxx:304
void SetRenderTimeOut(Double_t tout)
Definition: TGLRnrCtx.h:211
void SetShapeLOD(Short_t LOD)
Definition: TGLRnrCtx.h:178
@ kLODHigh
Definition: TGLRnrCtx.h:67
void BeginSelection(Int_t x, Int_t y, Int_t r=3)
Setup context for running selection.
Definition: TGLRnrCtx.cxx:205
@ kIfClosest
Definition: TGLRnrCtx.h:83
Short_t SelectTransparents() const
Definition: TGLRnrCtx.h:227
Float_t GetRenderScale() const
Definition: TGLRnrCtx.h:244
void SetSecSelection(Bool_t secSel)
Definition: TGLRnrCtx.h:225
TGLColorSet * GetBaseColorSet()
Returns the current base color-set.
Definition: TGLRnrCtx.cxx:314
TGLSelectBuffer * GetSelectBuffer() const
Definition: TGLRnrCtx.h:231
void SetGLCtxIdentity(TGLContextIdentity *cid)
Definition: TGLRnrCtx.h:255
void SetGrabImage(Bool_t gi)
Definition: TGLRnrCtx.h:266
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Definition: TGLRnrCtx.cxx:278
Bool_t GetGrabImage() const
Definition: TGLRnrCtx.h:267
void StartStopwatch()
Start the stopwatch.
Definition: TGLRnrCtx.cxx:166
void StopStopwatch()
Stop the stopwatch.
Definition: TGLRnrCtx.cxx:179
void EndSelection(Int_t glResult)
End selection.
Definition: TGLRnrCtx.cxx:219
void SetDrawPass(Short_t dpass)
Definition: TGLRnrCtx.h:205
@ kPassFill
Definition: TGLRnrCtx.h:55
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
Definition: TGLSceneBase.h:33
virtual void PostRender(TGLRnrCtx &rnrCtx)
Perform post-render clean-up.
virtual void PreRender(TGLRnrCtx &rnrCtx)
Perform pre-render initialization - fill rnrCtx with values stored during PreDraw().
Base class for extended scene context.
Definition: TGLSceneInfo.h:27
TGLSceneBase * GetScene() const
Definition: TGLSceneInfo.h:83
Implements VirtualViewer3D interface and fills the base-class visualization structures from pad conte...
Definition: TGLScenePad.h:25
virtual void PadPaintFromViewer(TGLViewer *viewer)
Entry point for requesting update of scene's contents from gl-viewer.
TVirtualPad * GetPad() const
Definition: TGLScenePad.h:61
UInt_t * RawRecord(Int_t i)
void SetRawOnly(UInt_t *data)
Setup the record from raw buffer.
Standard selection record including information about containing scene and details ob out selected ob...
static Bool_t AreSameSelectionWise(const TGLSelectRecord &r1, const TGLSelectRecord &r2)
Check if the records imply the same selection result, that is, their secondary members are all equal.
Bool_t GetTransparent() const
TGLLogicalShape * GetLogShape() const
TGLPhysicalShape * GetPhysShape() const
virtual void Reset()
Reinitialise all data to null values.
void Print()
Print contents of the select record to stdout.
TGLSceneInfo * GetSceneInfo() const
Stopwatch object for timing GL work.
Definition: TGLStopwatch.h:33
void Start()
Start timing.
Double_t End()
End timing, return total time since Start(), in milliseconds.
Wrapper class for various misc static functions - error checking, draw helpers etc.
Definition: TGLUtil.h:878
static void DrawSphere(const TGLVertex3 &position, Double_t radius, const UChar_t rgba[4])
Draw sphere, centered on vertex 'position', with radius 'radius', color 'rgba'.
Definition: TGLUtil.cxx:2352
static const UChar_t fgWhite[4]
Definition: TGLUtil.h:1052
static void SetLineWidthScale(Float_t scale)
Set global line-width scale.
Definition: TGLUtil.cxx:1902
static Int_t CheckError(const char *loc)
Check current GL error state, outputting details via ROOT Error method if one.
Definition: TGLUtil.cxx:1641
static void ColorAlpha(const TGLColor &color, UChar_t alpha)
Set color from TGLColor and alpha value.
Definition: TGLUtil.cxx:1700
static Int_t GetPickingRadius()
Returns picking radius.
Definition: TGLUtil.cxx:1866
static void SetPointSizeScale(Float_t scale)
Set global point-size scale.
Definition: TGLUtil.cxx:1886
static const UChar_t fgGreen[4]
Definition: TGLUtil.h:1049
static void PointToViewport(Int_t &x, Int_t &y)
Convert from point/screen coordinates to GL viewport coordinates.
Definition: TGLUtil.cxx:1818
static void DrawReferenceMarker(const TGLCamera &camera, const TGLVertex3 &pos, Float_t radius=3, const UChar_t *rgba=0)
Draw a sphere- marker on world-coordinate 'pos' with pixel radius 'radius'.
Definition: TGLUtil.cxx:2474
static void DrawSimpleAxes(const TGLCamera &camera, const TGLBoundingBox &bbox, Int_t axesType)
Draw simple xyz-axes for given bounding-box.
Definition: TGLUtil.cxx:2489
3 component (x/y/z) vector class.
Definition: TGLUtil.h:247
Double_t Mag() const
Definition: TGLUtil.h:297
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:83
Double_t X() const
Definition: TGLUtil.h:118
Double_t Z() const
Definition: TGLUtil.h:122
void Set(Double_t x, Double_t y, Double_t z)
Definition: TGLUtil.h:209
Double_t Y() const
Definition: TGLUtil.h:120
virtual void PreRenderOverlaySelection()
Perform minimal initialization for overlay selection.
SceneInfoList_t fScenes
Definition: TGLViewerBase.h:74
TGLRnrCtx * fRnrCtx
Definition: TGLViewerBase.h:62
TGLCamera * fCamera
Definition: TGLViewerBase.h:64
Bool_t FindClosestOpaqueRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved and whose result is not transparent, starting from posit...
virtual void ResetSceneInfos()
Force rebuild of view-dependent scene-info structures.
TGLSceneInfo * AddScene(TGLSceneBase *scene)
Add new scene, appropriate scene-info is created.
virtual void RemoveOverlayElement(TGLOverlayElement *el)
Remove overlay element.
TGLClip * fClip
Definition: TGLViewerBase.h:65
virtual void RenderOverlay(Int_t state, Bool_t selection)
Render overlay objects.
virtual void Render()
Render all scenes.
virtual void PostRenderOverlaySelection()
Perform cleanup after overlay selection.
virtual void PreRender()
Initialize render-context, setup camera, GL, render-area.
virtual void PostRender()
Function called after rendering is finished.
Bool_t FindClosestOverlayRecord(TGLOvlSelectRecord &rec, Int_t &recIdx)
Find next overlay-select record that can be resolved, starting from position 'recIdx'.
virtual void MergeSceneBBoxes(TGLBoundingBox &bbox)
Merge bounding-boxes of all active registered scenes.
TGLBoundingBox fOverallBoundingBox
Definition: TGLViewerBase.h:77
std::list< TGLSceneInfo * > SceneInfoList_t
Definition: TGLViewerBase.h:43
virtual void RenderSelectedForHighlight()
Render selected objects from all scenes for highlight.
SceneInfoList_t::iterator SceneInfoList_i
Definition: TGLViewerBase.h:44
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
Bool_t FindClosestRecord(TGLSelectRecord &rec, Int_t &recIdx)
Find next select record that can be resolved, starting from position 'recIdx'.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:57
TGLRedrawTimer * fRedrawTimer
Definition: TGLViewer.h:137
virtual void MouseOver(TGLPhysicalShape *)
Emit MouseOver signal.
Definition: TGLViewer.cxx:2095
void SetDrawCameraCenter(Bool_t x)
Draw camera look at and rotation point.
Definition: TGLViewer.cxx:2074
TGLAutoRotator * fAutoRotator
Definition: TGLViewer.h:99
Float_t fLineScale
size scale for points
Definition: TGLViewer.h:145
void FadeView(Float_t alpha)
Draw a rectangle (background color and given alpha) across the whole viewport.
Definition: TGLViewer.cxx: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:98
TGLCameraOverlay * fCameraOverlay
reference marker on?
Definition: TGLViewer.h:153
virtual void RefreshPadEditor(TObject *obj=0)
Update GED editor if it is set.
Definition: TGLViewer.cxx:2276
Bool_t fAxesDepthTest
axes type
Definition: TGLViewer.h:149
virtual void SetEventHandler(TGEventHandler *handler)
Set the event-handler.
Definition: TGLViewer.cxx:2291
TGLPerspectiveCamera fPerspectiveCameraYOZ
Definition: TGLViewer.h:88
TGLOrthoCamera fOrthoXOYCamera
Definition: TGLViewer.h:90
TGLSelectRecord fSelRec
select record in use as selected
Definition: TGLViewer.h:114
void SetFader(Float_t x)
Definition: TGLViewer.h:351
virtual void ReMouseOver(TObject *obj, UInt_t state)
Emit MouseOver signal.
Definition: TGLViewer.cxx:2125
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:95
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:2304
void InitGL()
Initialise GL state.
Definition: TGLViewer.cxx:409
virtual void SetupClipObject()
name says it all
Definition: TGLViewer.cxx:468
void SetAutoRotator(TGLAutoRotator *ar)
Set the auto-rotator for this viewer. The old rotator is deleted.
Definition: TGLViewer.cxx:2009
virtual void Clicked(TObject *obj)
Emit Clicked signal.
Definition: TGLViewer.cxx:2148
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:159
static TGLColorSet fgDefaultColorSet
fade the view (0 - no fade/default, 1 - full fade/no rendering done)
Definition: TGLViewer.h:163
TGEventHandler * fEventHandler
select record from last overlay select
Definition: TGLViewer.h:121
TGLPerspectiveCamera fPerspectiveCameraXOY
Definition: TGLViewer.h:89
TGLOrthoCamera fOrthoZnOYCamera
Definition: TGLViewer.h:96
TGLRect fViewport
max time for scene rendering at high LOD (in ms)
Definition: TGLViewer.h:141
virtual void SelectionChanged()
Update GUI components for embedded viewer selection change.
Definition: TGLViewer.cxx:2245
virtual void UnClicked(TObject *obj, UInt_t button, UInt_t state)
Emit UnClicked signal with button id and modifier state.
Definition: TGLViewer.cxx:2181
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:1947
TGLVertex3 fReferencePos
reference marker on?
Definition: TGLViewer.h:151
Bool_t RequestOverlaySelect(Int_t x, Int_t y)
Post request for secondary selection rendering of selected object around the window point (x,...
Definition: TGLViewer.cxx: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:2193
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:2059
void DoDraw(Bool_t swap_buffers=kTRUE)
Draw out the viewer.
Definition: TGLViewer.cxx:548
TGLOrthoCamera fOrthoZOYCamera
Definition: TGLViewer.h:92
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:123
TGLSelectRecord fSecSelRec
select record from last select (should go to context)
Definition: TGLViewer.h:115
TGLWidget * fGLWidget
Definition: TGLViewer.h:187
void DrawDebugInfo()
If in debug mode draw camera aids and overall bounding box.
Definition: TGLViewer.cxx: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:150
TGLCamera & CurrentCamera() const
Definition: TGLViewer.h:269
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ,...
Definition: TGLViewer.cxx:1792
void SetupCameras(Bool_t reset)
Setup cameras for current bounding box.
Definition: TGLViewer.cxx:367
Bool_t fResetCamerasOnUpdate
Definition: TGLViewer.h:193
virtual void PrintObjects()
Pass viewer for print capture by TGLOutput.
Definition: TGLViewer.cxx:2237
Int_t fAxesType
smooth line edge rendering
Definition: TGLViewer.h:148
void SetStereo(Bool_t stereo, Bool_t quad_buf=kTRUE)
Enable stereo rendering.
Definition: TGLViewer.cxx:2024
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:2228
TImage * GetPictureUsingBB()
Returns current image.
Definition: TGLViewer.cxx:985
TGLCamera & RefCamera(ECameraType camera)
Return camera reference by type.
Definition: TGLViewer.cxx:1754
TContextMenu * fContextMenu
external pad - remove replace with signal
Definition: TGLViewer.h:83
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:104
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Calculate and return pixel distance to nearest viewer object from window location px,...
Definition: TGLViewer.cxx:2215
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:105
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:161
virtual void PostRender()
Restore state set in PreRender().
Definition: TGLViewer.cxx:537
@ kDragCameraDolly
Definition: TGLViewer.h:130
void UpdateScene(Bool_t redraw=kTRUE)
Force update of pad-scenes.
Definition: TGLViewer.cxx:336
TGLOrthoCamera fOrthoZOXCamera
Definition: TGLViewer.h:93
Bool_t SavePictureUsingFBO(const TString &fileName, Int_t w, Int_t h, Float_t pixel_object_scale=0)
Save current image in various formats (gif, gif+, jpg, png).
Definition: TGLViewer.cxx:891
friend class TGLAutoRotator
Definition: TGLViewer.h:60
TGLOrthoCamera fOrthoXOZCamera
Definition: TGLViewer.h:91
Bool_t GetClipAutoUpdate() const
Definition: TGLViewer.h:265
virtual void OverlayDragFinished()
An overlay operation can result in change to an object.
Definition: TGLViewer.cxx:2265
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:1892
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:138
Bool_t RequestSecondarySelect(Int_t x, Int_t y)
Request secondary select.
Definition: TGLViewer.cxx:1382
TGedEditor * fGedEditor
event handler
Definition: TGLViewer.h:122
void SetViewport(Int_t x, Int_t y, Int_t width, Int_t height)
Set viewer viewport (window area) with bottom/left at (x,y), with dimensions 'width'/'height'.
Definition: TGLViewer.cxx:1722
Float_t fPointScale
color-set with light background
Definition: TGLViewer.h:144
TGLColorSet fLightColorSet
color-set with dark background
Definition: TGLViewer.h:143
TGLClipSet * fClipSet
Definition: TGLViewer.h:111
Bool_t fStereo
Definition: TGLViewer.h:102
virtual void PreRender()
Initialize objects that influence rendering.
Definition: TGLViewer.cxx:483
virtual void UnMouseOver(TObject *obj, UInt_t state)
Emit UnMouseOver signal.
Definition: TGLViewer.cxx:2137
TVirtualPad * fPad
Definition: TGLViewer.h:80
virtual void ReClicked(TObject *obj, UInt_t button, UInt_t state)
Emit ReClicked signal with button id and modifier state.
Definition: TGLViewer.cxx:2169
Bool_t fResetCamerasOnNextUpdate
Definition: TGLViewer.h:194
Bool_t fSmoothPoints
width scale for lines
Definition: TGLViewer.h:146
TGLOrthoCamera fOrthoZnOXCamera
Definition: TGLViewer.h:97
Float_t fMaxSceneDrawTimeLQ
max time for scene rendering at high LOD (in ms)
Definition: TGLViewer.h:139
Bool_t fSmoothLines
smooth point edge rendering
Definition: TGLViewer.h:147
TGLManipSet * fSelectedPShapeRef
select record from last secondary select (should go to context)
Definition: TGLViewer.h:116
TString fPictureFileName
Definition: TGLViewer.h:160
void ClearCurrentOvlElm()
Reset current overlay-element to zero, eventually notifying the old one that the mouse has left.
Definition: TGLViewer.cxx:2318
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:142
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:350
TGLLightSet * fLightSet
Definition: TGLViewer.h:109
Bool_t RequestSelect(Int_t x, Int_t y)
Post request for selection render pass viewer, picking objects around the window point (x,...
Definition: TGLViewer.cxx:1306
void SetClearColor(Color_t col)
Set background method.
Definition: TGLViewer.cxx:1672
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:152
void ReinitializeCurrentCamera(const TGLVector3 &hAxis, const TGLVector3 &vAxis, Bool_t redraw=kTRUE)
Change base-vectors defining the camera-base transformation of current camera.
Definition: TGLViewer.cxx:1987
Bool_t IsColorSetDark() const
Returns true if current color set is dark.
Definition: TGLViewer.cxx:1709
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:1999
TGLPerspectiveCamera fPerspectiveCameraXOZ
Definition: TGLViewer.h:87
const TGLPhysicalShape * GetSelected() const
Return selected physical shape.
Definition: TGLViewer.cxx:2084
TGLViewer(const TGLViewer &)
Float_t fStereoFrustumAsymFac
Definition: TGLViewer.h:106
Bool_t fDebugMode
cache logicals during scene rebuilds
Definition: TGLViewer.h:158
TGLOrthoCamera fOrthoXnOYCamera
Definition: TGLViewer.h:94
static Bool_t fgUseDefaultColorSetForNewViewers
a shared, default color-set
Definition: TGLViewer.h:164
void GetGuideState(Int_t &axesType, Bool_t &axesDepthTest, Bool_t &referenceOn, Double_t *referencePos) const
Fetch the state of guides (axes & reference markers) into arguments.
Definition: TGLViewer.cxx:2045
TGLSelectRecord fCurrentSelRec
Definition: TGLViewer.h:113
void DoDrawMono(Bool_t swap_buffers)
Draw out in monoscopic mode.
Definition: TGLViewer.cxx:626
Bool_t fStereoQuadBuf
use stereo rendering
Definition: TGLViewer.h:103
@ kCameraPerspXOY
Definition: TGLViewer.h:63
@ kCameraPerspXOZ
Definition: TGLViewer.h:63
@ kCameraOrthoXnOZ
Definition: TGLViewer.h:65
@ kCameraPerspYOZ
Definition: TGLViewer.h:63
@ kCameraOrthoZnOY
Definition: TGLViewer.h:65
@ kCameraOrthoZOY
Definition: TGLViewer.h:64
@ kCameraOrthoXOY
Definition: TGLViewer.h:64
@ kCameraOrthoZOX
Definition: TGLViewer.h:64
@ kCameraOrthoZnOX
Definition: TGLViewer.h:65
@ kCameraOrthoXOZ
Definition: TGLViewer.h:64
@ kCameraOrthoXnOY
Definition: TGLViewer.h:65
TGLContextIdentity * fGLCtxId
for embedded gl viewer
Definition: TGLViewer.h:189
Int_t fGLDevice
Definition: TGLViewer.h:188
static void UseDefaultColorSetForNewViewers(Bool_t x)
Sets static flag that determines if new viewers should use the default color-set.
Definition: TGLViewer.cxx:1691
TGLOvlSelectRecord fOvlSelRec
current overlay element
Definition: TGLViewer.h:119
TGLOverlayElement * fCurrentOvlElm
Definition: TGLViewer.h:118
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:285
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:351
virtual TObject * GetModel() const
Definition: TGedEditor.h:90
An abstract interface to image processing library.
Definition: TImage.h:29
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
virtual void FromGLBuffer(UChar_t *, UInt_t, UInt_t)
Definition: TImage.h:245
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:877
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TObject.cxx:311
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:865
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
Basic string class.
Definition: TString.h:131
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2177
const char * Data() const
Definition: TString.h:364
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition: TTimer.cxx:256
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h: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:703
constexpr Double_t DegToRad()
Conversion from degree to radian:
Definition: TMath.h:82
Int_t CeilNint(Double_t x)
Definition: TMath.h:689
Double_t Tan(Double_t)
Definition: TMath.h:635
Short_t Abs(Short_t d)
Definition: TMathBase.h:120