12#include "RConfigure.h"
119 for (i = 0; i < 3; i++) {
169 if (
gPad)
gPad->Range(-1, -1, 1, 1);
173 for (i = 0; i < 3; i++) {
174 if (rmin)
fRmin[i] = rmin[i];
176 if (rmax)
fRmax[i] = rmax[i];
199 fLatitude(tv.fLatitude),
200 fLongitude(tv.fLongitude),
207 fOutline(tv.fOutline),
208 fDefaultOutline(tv.fDefaultOutline),
209 fAutoRange(tv.fAutoRange),
210 fChanged(tv.fChanged)
212 for (
Int_t i=0; i<16; i++) {
218 for(
Int_t i=0; i<3; i++) {
228 for(
Int_t i=0; i<4; i++)
251 for(
Int_t i=0; i<16; i++) {
257 for(
Int_t i=0; i<3; i++) {
267 for(
Int_t i=0; i<4; i++)
310 Int_t inodes[4][8] = {
311 { 2,3,4,1, 6,7,8,5 },
312 { 3,4,1,2, 7,8,5,6 },
313 { 1,2,3,4, 5,6,7,8 },
316 Int_t ixyminmax[16][4] = {
340 if (
fTnorm[ 8] <= 0) icase += 1;
341 if (
fTnorm[ 9] <= 0) icase += 2;
342 for (
Int_t i=0; i<8; ++i) {
343 Int_t k = inodes[icase][i] - 1;
350 if (
fTnorm[10] < 0) icase += 4;
351 if (
fTnorm[ 6] < 0) icase += 8;
352 ix1 = ixyminmax[icase][0];
353 ix2 = ixyminmax[icase][1];
354 iy1 = ixyminmax[icase][2];
355 iy2 = ixyminmax[icase][3];
356 iz1 = (icase < 8) ? 1 : 3;
357 iz2 = (icase < 8) ? 5 : 7;
405 for (i=0; i<3; i++) cov[i] = 0.5*(
fRmax[i]+
fRmin[i]);
430 t12[12] = -(cov[0]*t12[0]+cov[1]*t12[4]+cov[2]*t12[8]);
431 t12[13] = -(cov[0]*t12[1]+cov[1]*t12[5]+cov[2]*t12[9]);
432 t12[14] = -(cov[0]*t12[2]+cov[1]*t12[6]+cov[2]*t12[10]);
456 fTnorm[0] = t12[0] + a2*t12[2];
457 fTnorm[1] = t12[1] + b2*t12[2];
461 fTnorm[4] = t12[4] + a2*t12[6];
462 fTnorm[5] = t12[5] + b2*t12[6];
466 fTnorm[8] = t12[8] + a2*t12[10];
467 fTnorm[9] = t12[9] + b2*t12[10];
471 fTnorm[12] = t12[12] + a2*t12[14];
472 fTnorm[13] = t12[13] + b2*t12[14];
537 tran[0] = 1 / scalex;
540 tran[3] = -
c[0] / scalex;
543 tran[5] = 1 / scaley;
545 tran[7] = -
c[1] / scaley;
549 tran[10] = 1 / scalez;
550 tran[11] = -
c[2] / scalez;
589 for (i = 1; i <= 3; ++i) {
590 for (k = 1; k <= 4; ++k) {
591 tnorm[k + (i << 2)] = rota[(i << 2) - 4]*tran[k - 1] + rota[(i
592 << 2) - 3]*tran[k + 3] + rota[(i << 2) - 2]*tran[k +7]
593 + rota[(i << 2) - 1]*tran[k + 11];
608 for (i = 1; i <= 3; ++i) {
609 for (k = 1; k <= 4; ++k) {
610 tback[k + (i << 2)] = tran[(i << 2) - 4]*rota[(k << 2) - 4] +
611 tran[(i << 2) - 3]*rota[(k << 2) - 3] + tran[(i << 2) -2]
612 *rota[(k << 2) - 2] + tran[(i << 2) - 1]*rota[(k <<2) - 1];
644 static Int_t system, framewasdrawn;
645 static Double_t xrange, yrange,
xmin,
ymin, longitude1, latitude1, longitude2, latitude2;
646 static Double_t newlatitude, newlongitude, oldlatitude, oldlongitude;
653 if (!
gPad->IsEditable())
return;
674 x =
gPad->PixeltoX(px);
675 y =
gPad->PixeltoY(py);
679 longitude1 = 180*(
x-
xmin)/xrange;
680 latitude1 = 90*(
y-
ymin)/yrange;
682 latitude1 = 90*(
x-
xmin)/xrange;
683 longitude1 = 180*(
y-
ymin)/yrange;
685 newlongitude = oldlongitude = -90 -
gPad->GetPhi();
686 newlatitude = oldlatitude = 90 -
gPad->GetTheta();
701 x =
gPad->PixeltoX(px);
702 y =
gPad->PixeltoY(py);
704 longitude2 = 180*(
x-
xmin)/xrange;
705 latitude2 = 90*(
y-
ymin)/yrange;
707 latitude2 = 90*(
x-
xmin)/xrange;
708 longitude2 = 180*(
y-
ymin)/yrange;
710 dlongitude = longitude2 - longitude1;
711 dlatitude = latitude2 - latitude1;
712 newlatitude = oldlatitude + dlatitude;
713 newlongitude = oldlongitude - dlongitude;
715 ResetView(newlongitude, newlatitude, psideg, irep);
720 SetView(newlongitude, newlatitude, psideg, irep);
721 gPad->SetPhi(-90-newlongitude);
722 gPad->SetTheta(90-newlatitude);
729 if (
gROOT->IsEscaped()) {
733 SetView(oldlongitude, oldlatitude, psideg, irep);
734 gPad->SetPhi(-90-oldlongitude);
735 gPad->SetTheta(90-oldlatitude);
750 if (viewer && !strcmp(viewer->IsA()->
GetName(),
"TView3Der3DPad")) {
751 gPad->ReleaseViewer3D();
759 SetView(newlongitude, newlatitude, psideg, irep);
760 gPad->SetPhi(-90-newlongitude);
761 gPad->SetTheta(90-newlatitude);
815 if (aphi[kphi + 1] == aphi[1]) aphi[kphi + 1] += 360;
818 aphi[kphi + 2] = (aphi[1] + aphi[kphi + 1]) / (
float)2. + 180;
819 aphi[kphi + 3] = aphi[1] + 360;
825 for (i = 1; i <= kphi; ++i) {
827 phi2 =
kRad*aphi[i + 1];
830 if (
x1 >= 0 &&
x2 > 0)
continue;
831 if (
x1 <= 0 &&
x2 < 0)
continue;
837 Error(
"FindPhiSectors",
"something strange: num. of critical sector not equal 2");
844 phi1 =
kRad*(aphi[iphi[0]] + aphi[iphi[0] + 1]) / (
float)2.;
845 phi2 =
kRad*(aphi[iphi[1]] + aphi[iphi[1] + 1]) / (
float)2.;
848 if ((z1 <= z2 && iopt == 1) || (z1 > z2 && iopt == 2)) {
883 ath[kth + 2] = 0.5*(ath[1] + ath[kth + 1]) + 180;
884 ath[kth + 3] = ath[1] + 360;
892 for (i = 1; i <= kth; ++i) {
897 if (z1 >= 0 && z2 > 0)
continue;
898 if (z1 <= 0 && z2 < 0)
continue;
904 Error(
"FindThetaSectors",
"Something strange: num. of critical sectors not equal 2");
912 th1 =
kRad*(ath[ith[0]] + ath[ith[0] + 1]) / (
float)2.;
913 th2 =
kRad*(ath[ith[1]] + ath[ith[1] + 1]) / (
float)2.;
916 if ((z1 <= z2 && iopt == 1) || (z1 > z2 && iopt == 2)) {
938 for (
Int_t i = 0; i < 3; i++) {
939 if (
fRmin[i] >=
fRmax[i]) { irep = -1;
return;}
981 y1 =
gPad->YtoAbsPixel(
fX1[1]);
983 y2 =
gPad->YtoAbsPixel(
fX2[1]);
984 }
else if (axis == 2) {
986 y1 =
gPad->YtoAbsPixel(
fY1[1]);
988 y2 =
gPad->YtoAbsPixel(
fY2[1]);
991 y1 =
gPad->YtoAbsPixel(
fZ1[1]);
993 y2 =
gPad->YtoAbsPixel(
fZ2[1]);
1004 if (
c <= 0)
return 9999;
1031 for (
Int_t i = 0; i < 3; max[i] =
fRmax[i], min[i] =
fRmin[i], i++) { }
1039 for (
Int_t i = 0; i < 3; max[i] =
fRmax[i], min[i] =
fRmin[i], i++) { }
1072 Float_t x = pn[0],
y = pn[1], z = pn[2];
1102 Double_t x,
y, z, a1, a2, a3, b1, b2, b3,
c1,
c2,
c3;
1116 pn[0] =
x*(b2*
c3 - b3*
c2) +
y*(b3*
c1 - b1*
c3) + z*(b1*
c2 - b2*
c1);
1117 pn[1] =
x*(
c2*a3 -
c3*a2) +
y*(
c3*a1 -
c1*a3) + z*(
c1*a2 -
c2*a1);
1118 pn[2] =
x*(a2*b3 - a3*b2) +
y*(a3*b1 - a1*b3) + z*(a1*b2 - a2*b1);
1130 Double_t x,
y, z, a1, a2, a3, b1, b2, b3,
c1,
c2,
c3;
1144 pn[0] =
x*(b2*
c3 - b3*
c2) +
y*(b3*
c1 - b1*
c3) + z*(b1*
c2 - b2*
c1);
1145 pn[1] =
x*(
c2*a3 -
c3*a2) +
y*(
c3*a1 -
c1*a3) + z*(
c1*a2 -
c2*a1);
1146 pn[2] =
x*(a2*b3 - a3*b2) +
y*(a3*b1 - a1*b3) + z*(a1*b2 - a2*b1);
1161 Double_t x,
y, z, r1, r2, r3, xx, yy, smax[2];
1164 for (i = 1; i <= 2; ++i) {
1165 smax[i - 1] =
fTnorm[(i << 2) - 1];
1166 for (k = 1; k <= 3; ++k) {
1167 if (
fTnorm[k + (i << 2) - 5] < 0) {
1168 smax[i - 1] +=
fTnorm[k + (i << 2) - 5]*
fRmin[k-1];
1170 smax[i - 1] +=
fTnorm[k + (i << 2) - 5]*
fRmax[k-1];
1188 ymin - dyr*
gPad->GetBottomMargin(),
1198 xgraf[0] = -smax[0];
1199 xgraf[1] = -smax[0];
1200 xgraf[2] = -smax[0];
1201 xgraf[3] = -smax[0];
1204 ygraf[0] = -smax[1];
1206 ygraf[2] = -smax[1];
1209 ygraf[4] = -smax[1];
1210 for (i = 1; i <= 8; ++i) {
1213 z = 0.5*((1 - r3)*
fRmin[2] + (r3 + 1)*
fRmax[2]);
1217 if (ygraf[1] >= yy) ygraf[1] = yy;
1218 if (ygraf[2] <= yy) ygraf[2] = yy;
1221 if (ygraf[5] >= yy) ygraf[5] = yy;
1222 if (ygraf[4] <= yy) ygraf[4] = yy;
1224 if (
TMath::Abs(yy - ygraf[0]) <= 1
e-4) xgraf[0] = xx;
1225 if (
TMath::Abs(yy - ygraf[3]) <= 1
e-4) xgraf[3] = xx;
1227 if (i % 2 == 0) r2 = -r2;
1230 gPad->PaintFillArea(6, xgraf, ygraf);
1239 for (
Int_t i=0;i<3;i++) {
1266 du = 0.5*screen_factor*
fDproj;
1330 for (
Int_t i = 0; i < 3;
fRmax[i] = max[i],
fRmin[i] = min[i], i++) { }
1334 Error(
"SetRange",
"problem setting view");
1357 rmin[0] = x0 < rmin[0] ? x0 : rmin[0];
1358 rmin[1] = y0 < rmin[1] ? y0 : rmin[1];
1359 rmin[2] = z0 < rmin[2] ? z0 : rmin[2];
1360 rmax[0] =
x1 > rmax[0] ?
x1 : rmax[0];
1361 rmax[1] = y1 > rmax[1] ? y1 : rmax[1];
1362 rmax[2] = z1 > rmax[2] ? z1 : rmax[2];
1367 rmin[0] = x0 > rmin[0] ? x0 : rmin[0];
1368 rmin[1] = y0 > rmin[1] ? y0 : rmin[1];
1369 rmin[2] = z0 > rmin[2] ? z0 : rmin[2];
1370 rmax[0] =
x1 < rmax[0] ?
x1 : rmax[0];
1371 rmax[1] = y1 < rmax[1] ? y1 : rmax[1];
1372 rmax[2] = z1 < rmax[2] ? z1 : rmax[2];
1376 rmin[0] = x0; rmax[0] =
x1;
1377 rmin[1] = y0; rmax[1] = y1;
1378 rmin[2] = z0; rmax[2] = z1;
1399 ResetView(longitude, latitude, psi, irep);
1446 Error(
"ResetView",
"Error in min-max scope");
1481 Float_t x = pw[0],
y = pw[1], z = pw[2];
1485 for (
Int_t i=0; i<3; i++) {
1517 for (
Int_t i=0; i<3; i++) {
1542 if (!thisPad) thisPad =
gPad;
1564 if (!thisPad) thisPad =
gPad;
1624 for (i=0;i<3; i++) maxSide =
TMath::Max(maxSide,max[i]-min[i]);
1626 for (i=0;i<3; i++) max[i] += maxSide - (max[i]-min[i]);
1640 for (i=0;i<3; i++) {
1641 if (max[i] > 0) min[i] = -max[i];
1642 else max[i] = -min[i];
1653 if (
TMath::Abs(unZoomFactor) < 0.001)
return;
1666 for (i=0;i<3; i++) {
1670 Double_t s = (max[i]-min[i])/(2*zoomFactor);
1687 if (nsteps<1)
return;
1694 for (i=0; i<3; i++) {
1709 dox =
fc*(dx-od[0]);
1710 doy =
fc*(dy-od[1]);
1711 doz =
fc*(dz-od[2]);
1712 for (i=0; i<nsteps; i++) {
1719 for (j=0; j<3; j++) {
1720 fRmin[j] = oc[j]-od[j];
1721 fRmax[j] = oc[j]+od[j];
1741 if (count <= 0) count = 1;
1862void TView3D::Streamer(
TBuffer &R__b)
1876 TObject::Streamer(R__b);
1877 TAttLine::Streamer(R__b);
1883 R__b >> single;
fPsi = single;
1900 TObject::Streamer(R__b);
1901 TAttLine::Streamer(R__b);
static const double x2[5]
static const double x1[5]
static struct mg_connection * fc(struct mg_context *ctx)
static TAxis3D * ToggleZoom(TVirtualPad *pad=0)
Turn ON / OFF the "Ruler" and "zoom mode" of the TAxis3D object attached to the current pad (if pad =...
static TAxis3D * ToggleRulers(TVirtualPad *pad=0)
Turn ON / OFF the "Ruler", TAxis3D object attached to the current pad.
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
TObject * GetParent() const
Return pointer to parent of this buffer.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t GetVersionOwner() const =0
virtual Int_t ReadStaticArray(Bool_t *b)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Delete(Option_t *option="")=0
Delete this object.
virtual void Paint(Option_t *option="")
Paint all objects in this collection.
virtual const char * GetName() const
Returns name of object.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kMustCleanup
if object destructor must call RecursiveRemove()
static void DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax)
Draw cube outline with 3d polylines.
virtual void UnzoomView(TVirtualPad *pad=0, Double_t unZoomFactor=1.25)
unZOOM this view.
TView3D()
Default constructor.
static void AdjustPad(TVirtualPad *pad=0)
Force the current pad to be updated.
virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor=1.25)
ZOOM this view.
virtual void SetPerspective()
Set perspective option.
virtual ~TView3D()
TView3D default destructor.
virtual void Centered3DImages(TVirtualPad *pad=0)
Move view into the center of the scene.
virtual Int_t GetSystem()
virtual void SetParallel()
Set the parallel option (default).
virtual void RotateView(Double_t phi, Double_t theta, TVirtualPad *pad=0)
API to rotate view and adjust the pad provided it the current one.
virtual void FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2)
Find critical PHI sectors.
TView3D & operator=(const TView3D &)
Assignment operator.
virtual void PadRange(Int_t rback)
Set the correct window size for lego and surface plots.
virtual Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio)
Return distance to axis from point px,py.
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Transfer point from world to normalized coordinates.
void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view direction (in spherical coordinates).
virtual void DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax)
Draw the outline of a cube while rotating a 3-d object in the pad.
virtual void NormalWCtoNDC(const Float_t *pw, Float_t *pn)
Transfer vector of NORMAL from word to normalized coordinates.
virtual void MoveFocus(Double_t *center, Double_t dx, Double_t dy, Double_t dz, Int_t nsteps=10, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)
Move focus to a different box position and extent in nsteps.
virtual void DefinePerspectiveView()
Define perspective view.
virtual Double_t GetPsi()
virtual void AdjustScales(TVirtualPad *pad=0)
Adjust all sides of view in respect of the biggest one.
virtual void MoveWindow(Char_t option)
Move view window :
virtual void SetAxisNDC(const Double_t *x1, const Double_t *x2, const Double_t *y1, const Double_t *y2, const Double_t *z1, const Double_t *z2)
Store axis coordinates in the NDC system.
virtual void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv)
Set viewing window.
virtual void SideView(TVirtualPad *pad=0)
Set to side view.
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view parameters.
virtual void FindScope(Double_t *scale, Double_t *center, Int_t &irep)
Find centre of a MIN-MAX scope and scale factors.
virtual void SetRange(const Double_t *min, const Double_t *max)
Set Range function.
virtual Bool_t IsClippedNDC(Double_t *p) const
Check if point is clipped in perspective view.
virtual void TopView(TVirtualPad *pad=0)
Set to top view.
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)
Transfer point from normalized to world coordinates.
virtual void ResizePad()
Recompute window for perspective view.
virtual void SetDefaultWindow()
Set default viewing window.
virtual void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const
Get current window extent.
virtual void ExecuteRotateView(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
virtual void FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn)
Find Z component of NORMAL in normalized coordinates.
virtual Bool_t IsPerspective() const
virtual void ToggleZoom(TVirtualPad *pad=0)
Turn on /off the interactive option to Zoom / Move / Change attributes of 3D axis correspond this vie...
virtual void MoveViewCommand(Char_t chCode, Int_t count=1)
virtual void ToggleRulers(TVirtualPad *pad=0)
Turn on /off 3D axis.
virtual void ZoomOut()
Zoom out.
virtual void FrontView(TVirtualPad *pad=0)
Set to front view.
virtual Double_t GetExtent() const
Get maximum view extent.
TSeqCollection * fOutline
virtual void DefineViewDirection(const Double_t *s, const Double_t *c, Double_t cosphi, Double_t sinphi, Double_t costhe, Double_t sinthe, Double_t cospsi, Double_t sinpsi, Double_t *tnorm, Double_t *tback)
Define view direction (in spherical coordinates)
virtual void GetRange(Float_t *min, Float_t *max)
Get Range function.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
virtual void ZoomIn()
Zoom in.
virtual void FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2)
Find critical THETA sectors for given PHI sector.
virtual void SetOutlineToCube()
This is a function which creates default outline.
virtual void AxisVertex(Double_t ang, Double_t *av, Int_t &ix1, Int_t &ix2, Int_t &iy1, Int_t &iy2, Int_t &iz1, Int_t &iz2)
Define axis vertices.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual void Modified(Bool_t flag=1)=0
virtual void AbsCoordinates(Bool_t set)=0
virtual void SetTheta(Double_t theta=30)=0
virtual void SetPhi(Double_t phi=30)=0
Abstract 3D shapes viewer.
double dist(Rotation3D const &r1, Rotation3D const &r2)
static constexpr double s
Short_t Max(Short_t a, Short_t b)
Double_t Sqrt(Double_t x)