#include "TGLManipSet.h"
#include "TGLTransManip.h"
#include "TGLScaleManip.h"
#include "TGLRotateManip.h"
#include "TGLPhysicalShape.h"
#include "TGLRnrCtx.h"
#include "TGLSelectRecord.h"
#include "TGLIncludes.h"
#include <KeySymbols.h>
#include <TVirtualX.h>
ClassImp(TGLManipSet);
TGLManipSet::TGLManipSet() :
fType (kTrans),
fDrawBBox (kFALSE)
{
fManip[kTrans] = new TGLTransManip;
fManip[kScale] = new TGLScaleManip;
fManip[kRotate] = new TGLRotateManip;
}
TGLManipSet::~TGLManipSet()
{
for (Int_t i=kTrans; i<kEndType; ++i)
delete fManip[i];
}
void TGLManipSet::SetPShape(TGLPhysicalShape* shape)
{
TGLPShapeRef::SetPShape(shape);
for (Int_t i=kTrans; i<kEndType; ++i)
fManip[i]->Attach(shape);
}
Bool_t TGLManipSet::MouseEnter(TGLOvlSelectRecord& )
{
TGLManip* manip = GetCurrentManip();
manip->SetActive(kFALSE);
manip->SetSelectedWidget(0);
return kTRUE;
}
Bool_t TGLManipSet::Handle(TGLRnrCtx& rnrCtx,
TGLOvlSelectRecord& selRec,
Event_t* event)
{
TGLManip* manip = GetCurrentManip();
switch (event->fType)
{
case kButtonPress:
{
return manip->HandleButton(*event, rnrCtx.RefCamera());
}
case kButtonRelease:
{
manip->SetActive(kFALSE);
return kTRUE;
}
case kMotionNotify:
{
if (manip->GetActive())
return manip->HandleMotion(*event, rnrCtx.RefCamera());
if (selRec.GetCurrItem() != manip->GetSelectedWidget())
{
manip->SetSelectedWidget(selRec.GetCurrItem());
return kTRUE;
}
return kFALSE;
}
case kGKeyPress:
{
switch (rnrCtx.GetEventKeySym())
{
case kKey_V: case kKey_v:
SetManipType(kTrans);
return kTRUE;
case kKey_C: case kKey_c:
SetManipType(kRotate);
return kTRUE;
case kKey_X: case kKey_x:
SetManipType(kScale);
return kTRUE;
default:
return kFALSE;
}
}
default:
{
return kFALSE;
}
}
}
void TGLManipSet::MouseLeave()
{
TGLManip* manip = GetCurrentManip();
manip->SetActive(kFALSE);
manip->SetSelectedWidget(0);
}
void TGLManipSet::Render(TGLRnrCtx& rnrCtx)
{
if (fPShape == 0)
return;
if (rnrCtx.Selection())
{
TGLUtil::SetDrawQuality(12);
fManip[fType]->Draw(rnrCtx.RefCamera());
TGLUtil::ResetDrawQuality();
} else {
fManip[fType]->Draw(rnrCtx.RefCamera());
}
if (fDrawBBox && ! rnrCtx.Selection())
{
if (rnrCtx.SceneStyle() == TGLRnrCtx::kFill ||
rnrCtx.SceneStyle() == TGLRnrCtx::kWireFrame)
{
glColor3d(1.0, 1.0, 1.0);
} else {
glColor3d(1.0, 0.0, 0.0);
}
glDisable(GL_LIGHTING);
fPShape->BoundingBox().Draw();
glEnable(GL_LIGHTING);
}
}
void TGLManipSet::SetManipType(Int_t type)
{
if (type < 0 || type >= kEndType)
return;
fType = (EManip) type;
}
Last change: Mon Nov 24 08:19:15 2008
Last generated: 2008-11-24 08:19
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.