#include "TGLTransManip.h"
#include "TGLPhysicalShape.h"
#include "TGLCamera.h"
#include "TGLIncludes.h"
ClassImp(TGLTransManip)
TGLTransManip::TGLTransManip()
{
}
TGLTransManip::TGLTransManip(TGLPhysicalShape * shape) :
TGLManip(shape)
{
}
TGLTransManip::~TGLTransManip()
{
}
void TGLTransManip::Draw(const TGLCamera & camera) const
{
if (!fShape) {
return;
}
const TGLBoundingBox & box = fShape->BoundingBox();
Double_t baseScale;
TGLVector3 axisScale[3];
CalcDrawScale(box, camera, baseScale, axisScale);
TGLPhysicalShape::EManip manip = fShape->GetManip();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
if (manip & TGLPhysicalShape::kTranslateX) {
glPushName(1);
TGLUtil::DrawLine(box.Center(), axisScale[0], TGLUtil::kLineHeadArrow,
baseScale, fSelectedWidget == 1 ? fgYellow : fgRed);
glPopName();
} else {
TGLUtil::DrawLine(box.Center(), axisScale[0], TGLUtil::kLineHeadArrow,
baseScale, fgGrey);
}
if (manip & TGLPhysicalShape::kTranslateY) {
glPushName(2);
TGLUtil::DrawLine(box.Center(), axisScale[1], TGLUtil::kLineHeadArrow,
baseScale, fSelectedWidget == 2 ? fgYellow : fgGreen);
glPopName();
} else {
TGLUtil::DrawLine(box.Center(), axisScale[1], TGLUtil::kLineHeadArrow,
baseScale, fgGrey);
}
if (manip & TGLPhysicalShape::kTranslateZ) {
glPushName(3);
TGLUtil::DrawLine(box.Center(), axisScale[2], TGLUtil::kLineHeadArrow,
baseScale, fSelectedWidget == 3 ? fgYellow : fgBlue);
glPopName();
} else {
TGLUtil::DrawLine(box.Center(), axisScale[2], TGLUtil::kLineHeadArrow,
baseScale, fgGrey);
}
TGLUtil::DrawSphere(box.Center(), baseScale/2.0, fgWhite);
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
}
Bool_t TGLTransManip::HandleMotion(const Event_t & event,
const TGLCamera & camera)
{
if (fActive) {
TGLVector3 shift =
camera.ViewportDeltaToWorld( fShape->BoundingBox().Center(),
event.fX - fLastMouse.GetX(),
-event.fY + fLastMouse.GetY() );
UInt_t axisIndex = fSelectedWidget - 1;
TGLVector3 widgetAxis = fShape->BoundingBox().Axis(axisIndex, kTRUE);
TGLVector3 constrainedShift = widgetAxis * Dot(shift, widgetAxis);
fShape->Translate(constrainedShift);
fLastMouse.SetX(event.fX);
fLastMouse.SetY(event.fY);
return kTRUE;
}
return kFALSE;
}
Last change: Wed Jun 25 08:41:26 2008
Last generated: 2008-06-25 08:41
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.