Skip to content
Snippets Groups Projects
Unverified Commit f0e86f28 authored by Matevž Tadel's avatar Matevž Tadel Committed by GitHub
Browse files

[TEve] Add XZ projection type. (#7269)


* Add XZ projection

* Get XZ Projection to work for geometry and axis drawing.

Co-authored-by: default avatarYang Hang <yanghang@chao-Lenovo-XiaoXin-300>
parent f8b99cba
No related branches found
No related tags found
No related merge requests found
......@@ -198,6 +198,7 @@
#pragma link C++ typedef TEveProjection::vPreScale_i;
#pragma link C++ class TEveRhoZProjection+;
#pragma link C++ class TEveRPhiProjection+;
#pragma link C++ class TEveXZProjection+;
#pragma link C++ class TEve3DProjection+;
#pragma link C++ class TEveProjectionManager+;
......
......@@ -26,7 +26,7 @@ class TEveTrans;
class TEveProjection
{
public:
enum EPType_e { kPT_Unknown, kPT_RPhi, kPT_RhoZ, kPT_3D, kPT_End }; // projection type
enum EPType_e { kPT_Unknown, kPT_RPhi, kPT_XZ, kPT_RhoZ, kPT_3D, kPT_End }; // projection type
enum EPProc_e { kPP_Plane, kPP_Distort, kPP_Full }; // projection procedure
enum EGeoMode_e { kGM_Unknown, kGM_Polygons, kGM_Segments }; // strategy for geometry projections
......@@ -202,6 +202,32 @@ public:
};
//==============================================================================
// TEveXZProjection
//==============================================================================
class TEveXZProjection : public TEveProjection
{
private:
TEveVector fProjectedCenter; // projected center of distortion.
public:
TEveXZProjection();
virtual ~TEveXZProjection() {}
virtual Bool_t Is2D() const { return kTRUE; }
virtual Bool_t Is3D() const { return kFALSE; }
virtual void ProjectPoint(Float_t& x, Float_t& y, Float_t& z, Float_t d, EPProc_e proc = kPP_Full);
virtual void SetCenter(TEveVector& v);
virtual Float_t* GetProjectedCenter() { return fProjectedCenter.Arr(); }
virtual void SetDirectionalVector(Int_t screenAxis, TEveVector& vec);
ClassDef(TEveXZProjection, 0); // XZ non-linear projection.
};
//==============================================================================
// TEve3DProjection
//==============================================================================
......
......@@ -109,6 +109,11 @@ void TEveProjectionManager::SetProjection(TEveProjection::EPType_e type)
fProjections[type] = new TEveRPhiProjection();
break;
}
case TEveProjection::kPT_XZ:
{
fProjections[type] = new TEveXZProjection();
break;
}
case TEveProjection::kPT_RhoZ:
{
fProjections[type] = new TEveRhoZProjection();
......
......@@ -50,6 +50,7 @@ TEveProjectionManagerEditor::TEveProjectionManagerEditor(const TGWindow *p,
f->AddFrame(lab, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 1, 31, 1, 2));
fType = new TGComboBox(f);
fType->AddEntry("RPhi", TEveProjection::kPT_RPhi);
fType->AddEntry("XZ", TEveProjection::kPT_XZ);
fType->AddEntry("RhoZ", TEveProjection::kPT_RhoZ);
fType->AddEntry("3D", TEveProjection::kPT_3D);
TGListBox* lb = fType->GetListBox();
......
......@@ -580,7 +580,6 @@ void TEveRhoZProjection::ProjectPoint(Float_t& x, Float_t& y, Float_t& z,
if (fUsePreScale)
PreScalePoint(y, x);
// distort
if (!fDisplaceOrigin) {
......@@ -762,9 +761,121 @@ void TEveRPhiProjection::ProjectPoint(Float_t& x, Float_t& y, Float_t& z,
y += fCenter.fY;
}
}
z = d;
}
/** \class TEveXZProjection
\ingroup TEve
XZ projection with distortion around given center.
*/
ClassImp(TEveXZProjection);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveXZProjection::TEveXZProjection() :
TEveProjection()
{
fType = kPT_XZ;
fGeoMode = kGM_Polygons;
fName = "XZ";
}
////////////////////////////////////////////////////////////////////////////////
/// Project point.
void TEveXZProjection::ProjectPoint(Float_t& x, Float_t& y, Float_t& z,
Float_t d, EPProc_e proc)
{
using namespace TMath;
if (fDisplaceOrigin)
{
x -= fCenter.fX;
y -= fCenter.fY;
z -= fCenter.fZ;
}
// projection
if (proc == kPP_Plane || proc == kPP_Full)
{
y = z;
z = d;
}
if (proc != kPP_Distort || proc == kPP_Full)
{
Float_t r, phi;
if (fUsePreScale)
{
r = Sqrt(x*x + y*y);
phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
PreScalePoint(r, phi);
x = r*Cos(phi);
y = r*Sin(phi);
}
if (!fDisplaceOrigin)
{
x -= fProjectedCenter.fX;
y -= fProjectedCenter.fY;
}
r = Sqrt(x*x + y*y);
phi = (x == 0.0f && y == 0.0f) ? 0.0f : ATan2(y, x);
if (r > fFixR)
r = fFixR + fPastFixRScale*(r - fFixR);
else if (r < -fFixR)
r = -fFixR + fPastFixRScale*(r + fFixR);
else
r = r * fScaleR / (1.0f + r*fDistortion);
x = r*Cos(phi);
y = r*Sin(phi);
if (!fDisplaceOrigin)
{
x += fProjectedCenter.fX;
y += fProjectedCenter.fY;
}
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set center of distortion (virtual method).
void TEveXZProjection::SetCenter(TEveVector& v)
{
fCenter = v;
if (fDisplaceOrigin)
{
fProjectedCenter.Set(0.f, 0.f, 0.f);
}
else
{
fProjectedCenter.fX = fCenter.fX;
fProjectedCenter.fY = fCenter.fZ;
fProjectedCenter.fZ = 0;
}
}
////////////////////////////////////////////////////////////////////////////////
/// Get direction in the unprojected space for axis index in the
/// projected space.
/// This is virtual method from base-class TEveProjection.
void TEveXZProjection::SetDirectionalVector(Int_t screenAxis, TEveVector& vec)
{
if (screenAxis == 0)
vec.Set(1.0f, 0.0f, 0.0f);
else if (screenAxis == 1)
vec.Set(0.0f, 0.0f, 1.0f);
}
/** \class TEve3DProjection
\ingroup TEve
3D scaling projection. One has to use pre-scaling to make any ise of this.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment