#ifndef ROOT_TGLViewer
#define ROOT_TGLViewer
#include "TGLViewerBase.h"
#include "TGLRnrCtx.h"
#include "TGLSelectRecord.h"
#include "TVirtualViewer3D.h"
#include "TBuffer3D.h"
#include "TGLPerspectiveCamera.h"
#include "TGLOrthoCamera.h"
#include "TTimer.h"
#include "TPoint.h"
#include "GuiTypes.h"
#include "RQ_OBJECT.h"
#include <vector>
class TGLSceneBase;
class TGLRedrawTimer;
class TGLViewerEditor;
class TGLWidget;
class TGLLightSet;
class TGLClipSet;
class TGLManipSet;
class TGLCameraMarkupStyle;
class TGLContextIdentity;
class TContextMenu;
class TGLViewer : public TVirtualViewer3D,
public TGLViewerBase
{
RQ_OBJECT("TGLViewer")
friend class TGLOutput;
public:
enum ECameraType { kCameraPerspXOZ, kCameraPerspYOZ, kCameraPerspXOY,
kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY };
private:
TGLViewer(const TGLViewer &);
TGLViewer & operator=(const TGLViewer &);
void InitSecondaryObjects();
protected:
TVirtualPad * fPad;
TContextMenu * fContextMenu;
TGLPerspectiveCamera fPerspectiveCameraXOZ;
TGLPerspectiveCamera fPerspectiveCameraYOZ;
TGLPerspectiveCamera fPerspectiveCameraXOY;
TGLOrthoCamera fOrthoXOYCamera;
TGLOrthoCamera fOrthoXOZCamera;
TGLOrthoCamera fOrthoZOYCamera;
TGLCamera * fCurrentCamera;
TGLLightSet * fLightSet;
TGLClipSet * fClipSet;
TGLSelectRecord fCurrentSelRec;
TGLSelectRecord fSelRec;
TGLSelectRecord fSecSelRec;
TGLManipSet * fSelectedPShapeRef;
TGLOverlayElement * fCurrentOvlElm;
TGLOvlSelectRecord fOvlSelRec;
public:
enum EPushAction { kPushStd,
kPushCamCenter };
enum EDragAction { kDragNone,
kDragCameraRotate, kDragCameraTruck, kDragCameraDolly,
kDragOverlay };
protected:
EPushAction fPushAction;
EDragAction fAction;
TPoint fLastPos;
UInt_t fActiveButtonID;
TGLRedrawTimer * fRedrawTimer;
Float_t fMaxSceneDrawTimeHQ;
Float_t fMaxSceneDrawTimeLQ;
TGLRect fViewport;
Color_t fClearColor;
Int_t fAxesType;
Bool_t fAxesDepthTest;
Bool_t fReferenceOn;
TGLVertex3 fReferencePos;
Bool_t fDrawCameraCenter;
TGLCameraMarkupStyle * fCameraMarkup;
Bool_t fInitGL;
Bool_t fSmartRefresh;
Bool_t fDebugMode;
Bool_t fIsPrinting;
void InitGL();
void PreDraw();
void PostDraw();
void MakeCurrent() const;
void SwapBuffers() const;
void SetViewport(Int_t x, Int_t y, Int_t width, Int_t height);
void SetupCameras(Bool_t reset);
protected:
TGLWidget *fGLWindow;
Int_t fGLDevice;
TGLContextIdentity*fGLCtxId;
Bool_t fIgnoreSizesOnUpdate;
Bool_t fResetCamerasOnUpdate;
Bool_t fResetCamerasOnNextUpdate;
Bool_t fResetCameraOnDoubleClick;
public:
TGLViewer(TVirtualPad * pad, Int_t x, Int_t y, Int_t width, Int_t height);
TGLViewer(TVirtualPad * pad);
virtual ~TGLViewer();
virtual Bool_t CanLoopOnPrimitives() const { return kTRUE; }
virtual void PadPaint(TVirtualPad* pad);
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
virtual Bool_t PreferLocalFrame() const { return kTRUE; }
virtual void BeginScene() {}
virtual Bool_t BuildingScene() const { return kFALSE; }
virtual void EndScene() {}
virtual Int_t AddObject(const TBuffer3D&, Bool_t* = 0) { return TBuffer3D::kNone; }
virtual Int_t AddObject(UInt_t, const TBuffer3D&, Bool_t* = 0) { return TBuffer3D::kNone; }
virtual Bool_t OpenComposite(const TBuffer3D&, Bool_t* = 0) { return kFALSE; }
virtual void CloseComposite() {}
virtual void AddCompositeOp(UInt_t) {}
virtual void PrintObjects();
virtual void ResetCameras() { SetupCameras(kTRUE); }
virtual void ResetCamerasAfterNextUpdate() { fResetCamerasOnNextUpdate = kTRUE; }
virtual void RefreshPadEditor(TObject* = 0) {}
Int_t GetDev() const { return fGLDevice; }
Color_t GetClearColor() const { return fClearColor; }
void SetClearColor(Color_t col) { fClearColor = col; }
Bool_t GetSmartRefresh() const { return fSmartRefresh; }
void SetSmartRefresh(Bool_t smart_ref) { fSmartRefresh = smart_ref; }
TGLLightSet* GetLightSet() const { return fLightSet; }
TGLClipSet * GetClipSet() const { return fClipSet; }
TGLCamera & CurrentCamera() const { return *fCurrentCamera; }
TGLCamera & RefCamera(ECameraType camera);
void SetCurrentCamera(ECameraType camera);
void SetOrthoCamera(ECameraType camera, Double_t zoom, Double_t dolly,
Double_t center[3], Double_t hRotate, Double_t vRotate);
void SetPerspectiveCamera(ECameraType camera, Double_t fov, Double_t dolly,
Double_t center[3], Double_t hRotate, Double_t vRotate);
void GetGuideState(Int_t & axesType, Bool_t & axesDepthTest, Bool_t & referenceOn, Double_t* referencePos) const;
void SetGuideState(Int_t axesType, Bool_t axesDepthTest, Bool_t referenceOn, const Double_t* referencePos);
void SetDrawCameraCenter(Bool_t x);
Bool_t GetDrawCameraCenter() { return fDrawCameraCenter; }
void PickCameraCenter() { fPushAction = kPushCamCenter; RefreshPadEditor(this); }
TGLCameraMarkupStyle* GetCameraMarkup() const { return fCameraMarkup; }
void SetCameraMarkup(TGLCameraMarkupStyle* m) { fCameraMarkup = m; }
EPushAction GetPushAction() const { return fPushAction; }
EDragAction GetAction() const { return fAction; }
const TGLPhysicalShape * GetSelected() const;
Float_t GetMaxSceneDrawTimeHQ() const { return fMaxSceneDrawTimeHQ; }
Float_t GetMaxSceneDrawTimeLQ() const { return fMaxSceneDrawTimeLQ; }
void SetMaxSceneDrawTimeHQ(Float_t t) { fMaxSceneDrawTimeHQ = t; }
void SetMaxSceneDrawTimeLQ(Float_t t) { fMaxSceneDrawTimeLQ = t; }
void RequestDraw(Short_t LOD = TGLRnrCtx::kLODMed);
virtual void PreRender();
void DoDraw();
void DrawGuides();
void DrawCameraMarkup();
void DrawDebugInfo();
Bool_t RequestSelect(Int_t x, Int_t y, Bool_t trySecSel=kFALSE);
Bool_t DoSelect(Int_t x, Int_t y, Bool_t trySecSel=kFALSE);
void ApplySelection();
Bool_t RequestOverlaySelect(Int_t x, Int_t y);
Bool_t DoOverlaySelect(Int_t x, Int_t y);
void UpdateScene();
Bool_t GetIgnoreSizesOnUpdate() const { return fIgnoreSizesOnUpdate; }
void SetIgnoreSizesOnUpdate(Bool_t v) { fIgnoreSizesOnUpdate = v; }
void ResetCurrentCamera();
Bool_t GetResetCamerasOnUpdate() const { return fResetCamerasOnUpdate; }
void SetResetCamerasOnUpdate(Bool_t v) { fResetCamerasOnUpdate = v; }
Bool_t GetResetCameraOnDoubleClick() const { return fResetCameraOnDoubleClick; }
void SetResetCameraOnDoubleClick(Bool_t v) { fResetCameraOnDoubleClick = v; }
virtual void PostSceneBuildSetup(Bool_t resetCameras);
virtual void SelectionChanged();
virtual void OverlayDragFinished();
Bool_t HandleEvent(Event_t *ev);
Bool_t HandleButton(Event_t *ev);
Bool_t HandleDoubleClick(Event_t *ev);
Bool_t HandleConfigureNotify(Event_t *ev);
Bool_t HandleKey(Event_t *ev);
Bool_t HandleMotion(Event_t *ev);
Bool_t HandleExpose(Event_t *ev);
void Repaint();
ClassDef(TGLViewer,0)
};
class TGLRedrawTimer : public TTimer
{
private:
TGLViewer & fViewer;
Short_t fRedrawLOD;
Bool_t fPending;
public:
TGLRedrawTimer(TGLViewer & viewer) :
fViewer(viewer), fRedrawLOD(TGLRnrCtx::kLODHigh), fPending(kFALSE) {}
~TGLRedrawTimer() {}
void RequestDraw(Int_t milliSec, Short_t redrawLOD=TGLRnrCtx::kLODHigh)
{
if (fPending) TurnOff(); else fPending = kTRUE;
if (redrawLOD < fRedrawLOD) fRedrawLOD = redrawLOD;
TTimer::Start(milliSec, kTRUE);
}
virtual void Stop()
{
if (fPending) { TurnOff(); fPending = kFALSE; }
}
Bool_t Notify()
{
TurnOff();
fPending = kFALSE;
fViewer.RequestDraw(fRedrawLOD);
fRedrawLOD = TGLRnrCtx::kLODHigh;
return kTRUE;
}
};
#endif // ROOT_TGLViewer
Last update: Thu Jan 17 08:52:29 2008
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.