#include "TEveStraightLineSet.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TVirtualPad.h"
#include "TVirtualViewer3D.h"
#include "TRandom.h"
#include "TEveProjectionManager.h"
ClassImp(TEveStraightLineSet);
TEveStraightLineSet::TEveStraightLineSet(const Text_t* n, const Text_t* t):
TEveElement (),
TNamed (n, t),
fLinePlex (sizeof(Line_t), 4),
fMarkerPlex (sizeof(Marker_t), 8),
fOwnLinesIds (kFALSE),
fOwnMarkersIds (kFALSE),
fRnrMarkers (kTRUE),
fRnrLines (kTRUE),
fLastLine (0)
{
InitMainTrans();
fPickable = kTRUE;
fMainColorPtr = &fLineColor;
fLineColor = 4;
fMarkerColor = 2;
fMarkerStyle = 20;
}
void TEveStraightLineSet::AddLine(Float_t x1, Float_t y1, Float_t z1,
Float_t x2, Float_t y2, Float_t z2)
{
fLastLine = new (fLinePlex.NewAtom()) Line_t(x1, y1, z1, x2, y2, z2);
}
void TEveStraightLineSet::AddMarker(Int_t line, Float_t pos)
{
new (fMarkerPlex.NewAtom()) Marker_t(line, pos);
}
void TEveStraightLineSet::CopyVizParams(const TEveElement* el)
{
const TEveStraightLineSet* m = dynamic_cast<const TEveStraightLineSet*>(el);
if (m)
{
TAttLine::operator=(*m);
TAttMarker::operator=(*m);
fRnrMarkers = m->fRnrMarkers;
fRnrLines = m->fRnrLines;
}
TEveElement::CopyVizParams(el);
}
void TEveStraightLineSet::WriteVizParams(ostream& out, const TString& var)
{
TEveElement::WriteVizParams(out, var);
TString t = " " + var + "->";
TAttMarker::SaveMarkerAttributes(out, var);
TAttLine ::SaveLineAttributes (out, var);
out << t << "SetRnrMarkers(" << fRnrMarkers << ");\n";
out << t << "SetRnrLines(" << fRnrLines << ");\n";
}
TClass* TEveStraightLineSet::ProjectedClass() const
{
return TEveStraightLineSetProjected::Class();
}
void TEveStraightLineSet::ComputeBBox()
{
static const TEveException eH("TEveStraightLineSet::ComputeBBox ");
if(fLinePlex.Size() == 0) {
BBoxZero();
return;
}
BBoxInit();
TEveChunkManager::iterator li(fLinePlex);
while (li.next()) {
BBoxCheckPoint(((Line_t*)li())->fV1);
BBoxCheckPoint(((Line_t*)li())->fV2);
}
}
void TEveStraightLineSet::Paint(Option_t* )
{
static const TEveException eH("TEveStraightLineSet::Paint ");
TBuffer3D buff(TBuffer3DTypes::kGeneric);
buff.fID = this;
buff.fColor = GetMainColor();
buff.fTransparency = GetMainTransparency();
buff.fLocalFrame = kFALSE;
RefMainTrans().SetBuffer3D(buff);
buff.SetSectionsValid(TBuffer3D::kCore);
Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
if (reqSections != TBuffer3D::kNone)
Error(eH, "only direct GL rendering supported.");
}
ClassImp(TEveStraightLineSetProjected);
TEveStraightLineSetProjected::TEveStraightLineSetProjected() :
TEveStraightLineSet(), TEveProjected ()
{
}
void TEveStraightLineSetProjected::SetProjection(TEveProjectionManager* mng,
TEveProjectable* model)
{
TEveProjected::SetProjection(mng, model);
* (TAttMarker*)this = * dynamic_cast<TAttMarker*>(fProjectable);
* (TAttLine*) this = * dynamic_cast<TAttLine*>(fProjectable);
}
void TEveStraightLineSetProjected::SetDepth(Float_t d)
{
SetDepthCommon(d, this, fBBox);
TEveChunkManager::iterator li(fLinePlex);
while (li.next())
{
TEveStraightLineSet::Line_t& l = * (TEveStraightLineSet::Line_t*) li();
l.fV1[2] = fDepth;
l.fV2[2] = fDepth;
}
}
void TEveStraightLineSetProjected::UpdateProjection()
{
TEveProjection& proj = * fManager->GetProjection();
TEveStraightLineSet& orig = * dynamic_cast<TEveStraightLineSet*>(fProjectable);
fLinePlex.Reset(sizeof(Line_t), orig.GetLinePlex().Size());
Float_t p1[3];
Float_t p2[3];
TEveChunkManager::iterator li(orig.GetLinePlex());
TEveTrans& origTrans = orig.RefMainTrans();
Double_t s1, s2, s3;
Double_t x, y, z;
origTrans.GetScale(s1, s2, s3);
origTrans.GetPos(x, y, z);
TEveTrans mx;
mx.Scale(s1, s2, s3);
while (li.next())
{
Line_t* l = (Line_t*) li();
p1[0] = l->fV1[0]; p1[1] = l->fV1[1]; p1[2] = l->fV1[2];
p2[0] = l->fV2[0]; p2[1] = l->fV2[1]; p2[2] = l->fV2[2];
mx.MultiplyIP(p1);
mx.MultiplyIP(p2);
p1[0] += x; p1[1] += y; p1[2] += z;
p2[0] += x; p2[1] += y; p2[2] += z;
proj.ProjectPointFv(p1);
proj.ProjectPointFv(p2);
AddLine(p1[0], p1[1], fDepth, p2[0], p2[1], fDepth);
}
fMarkerPlex.Reset(sizeof(Marker_t), orig.GetMarkerPlex().Size());
TEveChunkManager::iterator mi(orig.GetMarkerPlex());
while (mi.next())
{
Marker_t *m = (Marker_t*) mi();
Line_t *lo = (Line_t*) orig.GetLinePlex().Atom(m->fLineID);
Line_t *lp = (Line_t*) fLinePlex.Atom(m->fLineID);
TEveVector t1, d, xx;
t1.Set(lo->fV1); xx.Set(lo->fV2); xx -= t1; xx *= m->fPos; xx += t1;
proj.ProjectVector(xx);
t1.Set(lp->fV1); d.Set(lp->fV2); d -= t1; xx -= t1;
AddMarker(m->fLineID, d.Dot(xx) / d.Mag2());
}
}
Last change: Fri Oct 31 16:21:02 2008
Last generated: 2008-10-31 16:21
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.