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;}
984 }
else if (axis == 2) {
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;
1883 R__b >> single;
fPsi = single;
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t MoveWindow
Option_t Option_t TPoint TPoint const char y1
virtual void Streamer(TBuffer &)
static TAxis3D * ToggleRulers(TVirtualPad *pad=nullptr)
Turn ON / OFF the "Ruler", TAxis3D object attached to the current pad.
static TAxis3D * ToggleZoom(TVirtualPad *pad=nullptr)
Turn ON / OFF the "Ruler" and "zoom mode" of the TAxis3D object attached to the current pad (if pad =...
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
TObject * GetParent() const
Return pointer to parent of this buffer.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=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
void Delete(Option_t *option="") override=0
Delete this object.
void Paint(Option_t *option="") override
Paint all objects in this collection.
const char * GetName() const override
Returns name of object.
TObject & operator=(const TObject &rhs)
TObject assignment operator.
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
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.
TView3D()
Default constructor.
void NDCtoWC(const Float_t *pn, Float_t *pw) override
Transfer point from normalized to world coordinates.
void ToggleRulers(TVirtualPad *pad=nullptr) override
Turn on /off 3D axis.
void FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2) override
Find critical PHI sectors.
void ZoomIn() override
Zoom in.
Int_t GetSystem() override
void ZoomOut() override
Zoom out.
void FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn) override
Find Z component of NORMAL in normalized coordinates.
TView3D & operator=(const TView3D &)
Assignment operator.
void ExecuteRotateView(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
void SetPerspective() override
Set perspective option.
Double_t GetPsi() override
void SetParallel() override
Set the parallel option (default).
void DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax) override
Draw the outline of a cube while rotating a 3-d object in the pad.
Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio) override
Return distance to axis from point px,py.
void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view direction (in spherical coordinates).
void FrontView(TVirtualPad *pad=nullptr) override
Set to front view.
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) override
Move focus to a different box position and extent in nsteps.
Bool_t IsPerspective() const override
void SetRange(const Double_t *min, const Double_t *max) override
Set Range function.
void Centered3DImages(TVirtualPad *pad=nullptr) override
Move view into the center of the scene.
void NormalWCtoNDC(const Float_t *pw, Float_t *pn) override
Transfer vector of NORMAL from word to normalized coordinates.
void FindScope(Double_t *scale, Double_t *center, Int_t &irep) override
Find centre of a MIN-MAX scope and scale factors.
void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const override
Get current window extent.
void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep) override
Set view parameters.
void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv) override
Set viewing window.
void GetRange(Float_t *min, Float_t *max) override
Get Range function.
void DefinePerspectiveView() override
Define perspective view.
void MoveViewCommand(Char_t chCode, Int_t count=1) override
void ToggleZoom(TVirtualPad *pad=nullptr) override
Turn on /off the interactive option to Zoom / Move / Change attributes of 3D axis correspond this vie...
~TView3D() override
TView3D default destructor.
Double_t GetExtent() const override
Get maximum view extent.
void AdjustScales(TVirtualPad *pad=nullptr) override
Adjust all sides of view in respect of the biggest one.
void ZoomView(TVirtualPad *pad=nullptr, Double_t zoomFactor=1.25) override
ZOOM this view.
void UnzoomView(TVirtualPad *pad=nullptr, Double_t unZoomFactor=1.25) override
unZOOM this view.
static void AdjustPad(TVirtualPad *pad=nullptr)
Force the current pad to be updated.
void WCtoNDC(const Float_t *pw, Float_t *pn) override
Transfer point from world to normalized coordinates.
Bool_t IsClippedNDC(Double_t *p) const override
Check if point is clipped in perspective view.
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) override
Store axis coordinates in the NDC system.
void PadRange(Int_t rback) override
Set the correct window size for lego and surface plots.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
void FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2) override
Find critical THETA sectors for given PHI sector.
void TopView(TVirtualPad *pad=nullptr) override
Set to top view.
void SetOutlineToCube() override
This is a function which creates default outline.
void MoveWindow(Char_t option) override
Move view window :
TSeqCollection * fOutline
void RotateView(Double_t phi, Double_t theta, TVirtualPad *pad=nullptr) override
API to rotate view and adjust the pad provided it the current one.
void ResizePad() override
Recompute window for perspective view.
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) override
Define view direction (in spherical coordinates)
void SideView(TVirtualPad *pad=nullptr) override
Set to side view.
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) override
Define axis vertices.
void SetDefaultWindow() override
Set default viewing window.
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.
TClass * IsA() const override
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.