12#include "RConfigure.h"
118 for (i = 0; i < 3; i++) {
168 if (
gPad)
gPad->Range(-1, -1, 1, 1);
172 for (i = 0; i < 3; i++) {
173 if (rmin)
fRmin[i] = rmin[i];
175 if (rmax)
fRmax[i] = rmax[i];
198 fLatitude(tv.fLatitude),
199 fLongitude(tv.fLongitude),
206 fOutline(tv.fOutline),
207 fDefaultOutline(tv.fDefaultOutline),
208 fAutoRange(tv.fAutoRange),
209 fChanged(tv.fChanged)
211 for (
Int_t i=0; i<16; i++) {
217 for(
Int_t i=0; i<3; i++) {
227 for(
Int_t i=0; i<4; i++)
250 for(
Int_t i=0; i<16; i++) {
256 for(
Int_t i=0; i<3; i++) {
266 for(
Int_t i=0; i<4; i++)
309 Int_t inodes[4][8] = {
310 { 2,3,4,1, 6,7,8,5 },
311 { 3,4,1,2, 7,8,5,6 },
312 { 1,2,3,4, 5,6,7,8 },
315 Int_t ixyminmax[16][4] = {
339 if (
fTnorm[ 8] <= 0) icase += 1;
340 if (
fTnorm[ 9] <= 0) icase += 2;
341 for (
Int_t i=0; i<8; ++i) {
342 Int_t k = inodes[icase][i] - 1;
349 if (
fTnorm[10] < 0) icase += 4;
350 if (
fTnorm[ 6] < 0) icase += 8;
351 ix1 = ixyminmax[icase][0];
352 ix2 = ixyminmax[icase][1];
353 iy1 = ixyminmax[icase][2];
354 iy2 = ixyminmax[icase][3];
355 iz1 = (icase < 8) ? 1 : 3;
356 iz2 = (icase < 8) ? 5 : 7;
404 for (i=0; i<3; i++) cov[i] = 0.5*(
fRmax[i]+
fRmin[i]);
429 t12[12] = -(cov[0]*t12[0]+cov[1]*t12[4]+cov[2]*t12[8]);
430 t12[13] = -(cov[0]*t12[1]+cov[1]*t12[5]+cov[2]*t12[9]);
431 t12[14] = -(cov[0]*t12[2]+cov[1]*t12[6]+cov[2]*t12[10]);
455 fTnorm[0] = t12[0] + a2*t12[2];
456 fTnorm[1] = t12[1] + b2*t12[2];
460 fTnorm[4] = t12[4] + a2*t12[6];
461 fTnorm[5] = t12[5] + b2*t12[6];
465 fTnorm[8] = t12[8] + a2*t12[10];
466 fTnorm[9] = t12[9] + b2*t12[10];
470 fTnorm[12] = t12[12] + a2*t12[14];
471 fTnorm[13] = t12[13] + b2*t12[14];
536 tran[0] = 1 / scalex;
539 tran[3] = -
c[0] / scalex;
542 tran[5] = 1 / scaley;
544 tran[7] = -
c[1] / scaley;
548 tran[10] = 1 / scalez;
549 tran[11] = -
c[2] / scalez;
588 for (i = 1; i <= 3; ++i) {
589 for (k = 1; k <= 4; ++k) {
590 tnorm[k + (i << 2)] = rota[(i << 2) - 4]*tran[k - 1] + rota[(i
591 << 2) - 3]*tran[k + 3] + rota[(i << 2) - 2]*tran[k +7]
592 + rota[(i << 2) - 1]*tran[k + 11];
607 for (i = 1; i <= 3; ++i) {
608 for (k = 1; k <= 4; ++k) {
609 tback[k + (i << 2)] = tran[(i << 2) - 4]*rota[(k << 2) - 4] +
610 tran[(i << 2) - 3]*rota[(k << 2) - 3] + tran[(i << 2) -2]
611 *rota[(k << 2) - 2] + tran[(i << 2) - 1]*rota[(k <<2) - 1];
643 static Int_t system, framewasdrawn;
644 static Double_t xrange, yrange,
xmin,
ymin, longitude1, latitude1, longitude2, latitude2;
645 static Double_t newlatitude, newlongitude, oldlatitude, oldlongitude;
652 if (!
gPad->IsEditable())
return;
673 x =
gPad->PixeltoX(px);
674 y =
gPad->PixeltoY(py);
678 longitude1 = 180*(
x-
xmin)/xrange;
679 latitude1 = 90*(
y-
ymin)/yrange;
681 latitude1 = 90*(
x-
xmin)/xrange;
682 longitude1 = 180*(
y-
ymin)/yrange;
684 newlongitude = oldlongitude = -90 -
gPad->GetPhi();
685 newlatitude = oldlatitude = 90 -
gPad->GetTheta();
700 x =
gPad->PixeltoX(px);
701 y =
gPad->PixeltoY(py);
703 longitude2 = 180*(
x-
xmin)/xrange;
704 latitude2 = 90*(
y-
ymin)/yrange;
706 latitude2 = 90*(
x-
xmin)/xrange;
707 longitude2 = 180*(
y-
ymin)/yrange;
709 dlongitude = longitude2 - longitude1;
710 dlatitude = latitude2 - latitude1;
711 newlatitude = oldlatitude + dlatitude;
712 newlongitude = oldlongitude - dlongitude;
714 ResetView(newlongitude, newlatitude, psideg, irep);
719 SetView(newlongitude, newlatitude, psideg, irep);
720 gPad->SetPhi(-90-newlongitude);
721 gPad->SetTheta(90-newlatitude);
728 if (
gROOT->IsEscaped()) {
732 SetView(oldlongitude, oldlatitude, psideg, irep);
733 gPad->SetPhi(-90-oldlongitude);
734 gPad->SetTheta(90-oldlatitude);
749 if (viewer && !strcmp(viewer->IsA()->
GetName(),
"TView3Der3DPad")) {
750 gPad->ReleaseViewer3D();
758 SetView(newlongitude, newlatitude, psideg, irep);
759 gPad->SetPhi(-90-newlongitude);
760 gPad->SetTheta(90-newlatitude);
814 if (aphi[kphi + 1] == aphi[1]) aphi[kphi + 1] += 360;
817 aphi[kphi + 2] = (aphi[1] + aphi[kphi + 1]) / (
float)2. + 180;
818 aphi[kphi + 3] = aphi[1] + 360;
824 for (i = 1; i <= kphi; ++i) {
826 phi2 =
kRad*aphi[i + 1];
829 if (
x1 >= 0 &&
x2 > 0)
continue;
830 if (
x1 <= 0 &&
x2 < 0)
continue;
836 Error(
"FindPhiSectors",
"something strange: num. of critical sector not equal 2");
843 phi1 =
kRad*(aphi[iphi[0]] + aphi[iphi[0] + 1]) / (
float)2.;
844 phi2 =
kRad*(aphi[iphi[1]] + aphi[iphi[1] + 1]) / (
float)2.;
847 if ((z1 <= z2 && iopt == 1) || (z1 > z2 && iopt == 2)) {
882 ath[kth + 2] = 0.5*(ath[1] + ath[kth + 1]) + 180;
883 ath[kth + 3] = ath[1] + 360;
891 for (i = 1; i <= kth; ++i) {
896 if (z1 >= 0 && z2 > 0)
continue;
897 if (z1 <= 0 && z2 < 0)
continue;
903 Error(
"FindThetaSectors",
"Something strange: num. of critical sectors not equal 2");
911 th1 =
kRad*(ath[ith[0]] + ath[ith[0] + 1]) / (
float)2.;
912 th2 =
kRad*(ath[ith[1]] + ath[ith[1] + 1]) / (
float)2.;
915 if ((z1 <= z2 && iopt == 1) || (z1 > z2 && iopt == 2)) {
937 for (
Int_t i = 0; i < 3; i++) {
938 if (
fRmin[i] >=
fRmax[i]) { irep = -1;
return;}
980 y1 =
gPad->YtoAbsPixel(
fX1[1]);
982 y2 =
gPad->YtoAbsPixel(
fX2[1]);
983 }
else if (axis == 2) {
985 y1 =
gPad->YtoAbsPixel(
fY1[1]);
987 y2 =
gPad->YtoAbsPixel(
fY2[1]);
990 y1 =
gPad->YtoAbsPixel(
fZ1[1]);
992 y2 =
gPad->YtoAbsPixel(
fZ2[1]);
1003 if (
c <= 0)
return 9999;
1030 for (
Int_t i = 0; i < 3; max[i] =
fRmax[i], min[i] =
fRmin[i], i++) { }
1038 for (
Int_t i = 0; i < 3; max[i] =
fRmax[i], min[i] =
fRmin[i], i++) { }
1071 Float_t x = pn[0],
y = pn[1], z = pn[2];
1101 Double_t x,
y, z, a1, a2, a3, b1, b2, b3,
c1,
c2,
c3;
1115 pn[0] =
x*(b2*
c3 - b3*
c2) +
y*(b3*
c1 - b1*
c3) + z*(b1*
c2 - b2*
c1);
1116 pn[1] =
x*(
c2*a3 -
c3*a2) +
y*(
c3*a1 -
c1*a3) + z*(
c1*a2 -
c2*a1);
1117 pn[2] =
x*(a2*b3 - a3*b2) +
y*(a3*b1 - a1*b3) + z*(a1*b2 - a2*b1);
1129 Double_t x,
y, z, a1, a2, a3, b1, b2, b3,
c1,
c2,
c3;
1143 pn[0] =
x*(b2*
c3 - b3*
c2) +
y*(b3*
c1 - b1*
c3) + z*(b1*
c2 - b2*
c1);
1144 pn[1] =
x*(
c2*a3 -
c3*a2) +
y*(
c3*a1 -
c1*a3) + z*(
c1*a2 -
c2*a1);
1145 pn[2] =
x*(a2*b3 - a3*b2) +
y*(a3*b1 - a1*b3) + z*(a1*b2 - a2*b1);
1160 Double_t x,
y, z, r1, r2, r3, xx, yy, smax[2];
1163 for (i = 1; i <= 2; ++i) {
1164 smax[i - 1] =
fTnorm[(i << 2) - 1];
1165 for (k = 1; k <= 3; ++k) {
1166 if (
fTnorm[k + (i << 2) - 5] < 0) {
1167 smax[i - 1] +=
fTnorm[k + (i << 2) - 5]*
fRmin[k-1];
1169 smax[i - 1] +=
fTnorm[k + (i << 2) - 5]*
fRmax[k-1];
1187 ymin - dyr*
gPad->GetBottomMargin(),
1197 xgraf[0] = -smax[0];
1198 xgraf[1] = -smax[0];
1199 xgraf[2] = -smax[0];
1200 xgraf[3] = -smax[0];
1203 ygraf[0] = -smax[1];
1205 ygraf[2] = -smax[1];
1208 ygraf[4] = -smax[1];
1209 for (i = 1; i <= 8; ++i) {
1212 z = 0.5*((1 - r3)*
fRmin[2] + (r3 + 1)*
fRmax[2]);
1216 if (ygraf[1] >= yy) ygraf[1] = yy;
1217 if (ygraf[2] <= yy) ygraf[2] = yy;
1220 if (ygraf[5] >= yy) ygraf[5] = yy;
1221 if (ygraf[4] <= yy) ygraf[4] = yy;
1223 if (
TMath::Abs(yy - ygraf[0]) <= 1
e-4) xgraf[0] = xx;
1224 if (
TMath::Abs(yy - ygraf[3]) <= 1
e-4) xgraf[3] = xx;
1226 if (i % 2 == 0) r2 = -r2;
1229 gPad->PaintFillArea(6, xgraf, ygraf);
1238 for (
Int_t i=0;i<3;i++) {
1265 du = 0.5*screen_factor*
fDproj;
1329 for (
Int_t i = 0; i < 3;
fRmax[i] = max[i],
fRmin[i] = min[i], i++) { }
1333 Error(
"SetRange",
"problem setting view");
1356 rmin[0] = x0 < rmin[0] ? x0 : rmin[0];
1357 rmin[1] = y0 < rmin[1] ? y0 : rmin[1];
1358 rmin[2] = z0 < rmin[2] ? z0 : rmin[2];
1359 rmax[0] =
x1 > rmax[0] ?
x1 : rmax[0];
1360 rmax[1] = y1 > rmax[1] ? y1 : rmax[1];
1361 rmax[2] = z1 > rmax[2] ? z1 : rmax[2];
1366 rmin[0] = x0 > rmin[0] ? x0 : rmin[0];
1367 rmin[1] = y0 > rmin[1] ? y0 : rmin[1];
1368 rmin[2] = z0 > rmin[2] ? z0 : rmin[2];
1369 rmax[0] =
x1 < rmax[0] ?
x1 : rmax[0];
1370 rmax[1] = y1 < rmax[1] ? y1 : rmax[1];
1371 rmax[2] = z1 < rmax[2] ? z1 : rmax[2];
1375 rmin[0] = x0; rmax[0] =
x1;
1376 rmin[1] = y0; rmax[1] = y1;
1377 rmin[2] = z0; rmax[2] = z1;
1398 ResetView(longitude, latitude, psi, irep);
1445 Error(
"ResetView",
"Error in min-max scope");
1480 Float_t x = pw[0],
y = pw[1], z = pw[2];
1484 for (
Int_t i=0; i<3; i++) {
1516 for (
Int_t i=0; i<3; i++) {
1541 if (!thisPad) thisPad =
gPad;
1563 if (!thisPad) thisPad =
gPad;
1623 for (i=0;i<3; i++) maxSide =
TMath::Max(maxSide,max[i]-min[i]);
1625 for (i=0;i<3; i++) max[i] += maxSide - (max[i]-min[i]);
1639 for (i=0;i<3; i++) {
1640 if (max[i] > 0) min[i] = -max[i];
1641 else max[i] = -min[i];
1652 if (
TMath::Abs(unZoomFactor) < 0.001)
return;
1665 for (i=0;i<3; i++) {
1669 Double_t s = (max[i]-min[i])/(2*zoomFactor);
1686 if (nsteps<1)
return;
1693 for (i=0; i<3; i++) {
1708 dox =
fc*(dx-od[0]);
1709 doy =
fc*(dy-od[1]);
1710 doz =
fc*(dz-od[2]);
1711 for (i=0; i<nsteps; i++) {
1718 for (j=0; j<3; j++) {
1719 fRmin[j] = oc[j]-od[j];
1720 fRmax[j] = oc[j]+od[j];
1740 if (count <= 0) count = 1;
1861void TView3D::Streamer(
TBuffer &R__b)
1875 TObject::Streamer(R__b);
1876 TAttLine::Streamer(R__b);
1882 R__b >> single;
fPsi = single;
1899 TObject::Streamer(R__b);
1900 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)