#include "TVirtualX.h"
#include "TString.h"
#include "TROOT.h"
#include "TGLRnrCtx.h"
#include "TGLSceneInfo.h"
#include "TGLSelectBuffer.h"
#include "TGLIncludes.h"
#include "TGLUtil.h"
#include <TError.h>
#include <TMathBase.h>
#include <algorithm>
#include <assert.h>
ClassImp(TGLRnrCtx)
TGLRnrCtx::TGLRnrCtx(TGLViewerBase* viewer) :
fViewer (viewer),
fCamera (0),
fSceneInfo (0),
fViewerLOD (kLODUndef),
fSceneLOD (kLODUndef),
fCombiLOD (kLODUndef),
fShapeLOD (kLODUndef),
fViewerStyle (kStyleUndef),
fSceneStyle (kStyleUndef),
fViewerClip (0),
fSceneClip (0),
fClip (0),
fDrawPass (kPassUndef),
fRenderTimeout(0.0),
fSelection (kFALSE),
fSecSelection (kFALSE),
fPickRadius (0),
fPickRectangle(0),
fSelectBuffer (0),
fDLCaptureOpen (kFALSE),
fGLCtxIdentity (0),
fQuadric (0)
{
fSelectBuffer = new TGLSelectBuffer;
fQuadric = gluNewQuadric();
gluQuadricOrientation(fQuadric, (GLenum)GLU_OUTSIDE);
gluQuadricNormals (fQuadric, (GLenum)GLU_SMOOTH);
if (fViewer == 0)
{
fViewerLOD = fSceneLOD = fCombiLOD = fShapeLOD = kLODHigh;
fViewerStyle = fSceneStyle = kFill;
fDrawPass = kPassFill;
}
}
TGLRnrCtx::~TGLRnrCtx()
{
gluDeleteQuadric(fQuadric);
delete fPickRectangle;
delete fSelectBuffer;
}
TGLSceneBase * TGLRnrCtx::GetScene()
{
return fSceneInfo->GetScene();
}
TGLSceneBase & TGLRnrCtx::RefScene()
{
return *fSceneInfo->GetScene();
}
void TGLRnrCtx::BeginSelection(Int_t x, Int_t y, Int_t r)
{
fSelection = kTRUE;
fSecSelection = kFALSE;
fPickRadius = r;
if (!fPickRectangle) fPickRectangle = new TGLRect;
fPickRectangle->Set(x, y, r, r);
glSelectBuffer(fSelectBuffer->GetBufSize(), fSelectBuffer->GetBuf());
}
void TGLRnrCtx::EndSelection(Int_t glResult)
{
fSelection = kFALSE;
fSecSelection = kFALSE;
fPickRadius = 0;
delete fPickRectangle; fPickRectangle = 0;
if (glResult < 0)
{
if (fSelectBuffer->CanGrow())
{
Warning("TGLRnrCtx::EndSelection",
"Select buffer size (%d) insufficient, doubling it.",
fSelectBuffer->GetBufSize());
fSelectBuffer->Grow();
}
else
{
Warning("TGLRnrCtx::EndSelection",
"Select buffer size (%d) insufficient. This is maximum.",
fSelectBuffer->GetBufSize());
}
}
fSelectBuffer->ProcessResult(glResult);
}
TGLRect * TGLRnrCtx::GetPickRectangle()
{
return fPickRectangle;
}
Int_t TGLRnrCtx::GetPickRadius()
{
return fPickRadius;
}
Bool_t TGLRnrCtx::IsDrawPassFilled() const
{
return fDrawPass == kPassFill || fDrawPass == kPassOutlineFill;
}
void TGLRnrCtx::OpenDLCapture()
{
assert(fDLCaptureOpen == kFALSE);
fDLCaptureOpen = kTRUE;
}
void TGLRnrCtx::CloseDLCapture()
{
assert(fDLCaptureOpen == kTRUE);
fDLCaptureOpen = kFALSE;
}
const char* TGLRnrCtx::StyleName(Short_t style)
{
switch (style)
{
case TGLRnrCtx::kFill: return "Filled Polys";
case TGLRnrCtx::kWireFrame: return "Wireframe";
case TGLRnrCtx::kOutline: return "Outline";
default: return "Oogaa-dooga style";
}
}
Last update: Thu Jan 17 08:52:13 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.