Logo ROOT  
Reference Guide
TView3D.h
Go to the documentation of this file.
1// @(#)root/g3d:$Id$
2// Author: Rene Brun 19/02/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12
13#ifndef ROOT_TView3D
14#define ROOT_TView3D
15
16
17/////////////////////////////////////////////////////////////////////////
18// //
19// TView3D //
20// //
21/////////////////////////////////////////////////////////////////////////
22
23
24#include "TView.h"
25
26class TSeqCollection;
27class TVirtualPad;
28
29class TView3D : public TView {
30
31protected:
32 Double_t fLatitude; //View angle latitude
33 Double_t fLongitude; //View angle longitude
34 Double_t fPsi; //View angle psi
35 Double_t fDview; //Distance from COP to COV
36 Double_t fDproj; //Distance from COP to projection plane
37 Double_t fUpix; // pad X size in pixels
38 Double_t fVpix; // pad Y size in pixels
39 Double_t fTN[16]; //
40 Double_t fTB[16]; //
41 Double_t fRmax[3]; //Upper limits of object
42 Double_t fRmin[3]; //Lower limits of object
43 Double_t fUVcoord[4]; //Viewing window limits
44 Double_t fTnorm[16]; //Transformation matrix
45 Double_t fTback[16]; //Back transformation matrix
46 Double_t fX1[3]; //First coordinate of X axis
47 Double_t fX2[3]; //Second coordinate of X axis
48 Double_t fY1[3]; //First coordinate of Y axis
49 Double_t fY2[3]; //Second coordinate of Y axis
50 Double_t fZ1[3]; //First coordinate of Z axis
51 Double_t fZ2[3]; //Second coordinate of Z axis
52 Int_t fSystem; //Coordinate system
53 TSeqCollection *fOutline; //Collection of outline's objects
54 Bool_t fDefaultOutline; //Set to TRUE if outline is default cube
55 Bool_t fAutoRange; //Set to TRUE if range computed automatically
56 Bool_t fChanged; //! Set to TRUE after ExecuteRotateView
57
58 TView3D(const TView3D&); // Not implemented
59 TView3D& operator=(const TView3D&); // Not implemented
60
61 void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep);
62
63
64public:
65 // TView3D status bits
66 enum {
67 kPerspective = BIT(6)
68 };
69
70 TView3D();
71 TView3D(Int_t system, const Double_t *rmin, const Double_t *rmax);
72 virtual ~TView3D();
73
74 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);
75 virtual void DefinePerspectiveView();
76 virtual void DefineViewDirection(const Double_t *s, const Double_t *c,
77 Double_t cosphi, Double_t sinphi,
78 Double_t costhe, Double_t sinthe,
79 Double_t cospsi, Double_t sinpsi,
80 Double_t *tnorm, Double_t *tback);
81 virtual void DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax);
82 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
83 virtual void ExecuteRotateView(Int_t event, Int_t px, Int_t py);
84 virtual void FindScope(Double_t *scale, Double_t *center, Int_t &irep);
85 virtual Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio);
86 virtual Double_t GetDview() const {return fDview;}
87 virtual Double_t GetDproj() const {return fDproj;}
88 virtual Double_t GetExtent() const;
89 virtual Bool_t GetAutoRange() {return fAutoRange;}
90 virtual Double_t GetLatitude() {return fLatitude;}
91 virtual Double_t GetLongitude() {return fLongitude;}
92 virtual Double_t GetPsi() {return fPsi;}
93 virtual void GetRange (Float_t *min, Float_t *max);
94 virtual void GetRange (Double_t *min, Double_t *max);
95 virtual Double_t *GetRmax() {return fRmax;}
96 virtual Double_t *GetRmin() {return fRmin;}
97 virtual TSeqCollection *GetOutline() {return fOutline; }
98 virtual Double_t *GetTback() {return fTback;}
99 virtual Double_t *GetTN() {return fTN;}
100 virtual Double_t *GetTnorm() {return fTnorm;}
101 virtual Int_t GetSystem() {return fSystem;}
102 virtual void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const;
103 virtual Double_t GetWindowWidth() const {return 0.5*(fUVcoord[1]-fUVcoord[0]);}
104 virtual Double_t GetWindowHeight() const {return 0.5*(fUVcoord[3]-fUVcoord[2]);}
105 virtual void FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn);
106 virtual void FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2);
107 virtual void FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2);
108 virtual Bool_t IsClippedNDC(Double_t *p) const;
109 virtual Bool_t IsPerspective() const {return TestBit(kPerspective);}
110 virtual Bool_t IsViewChanged() const {return fChanged;}
111 virtual void NDCtoWC(const Float_t *pn, Float_t *pw);
112 virtual void NDCtoWC(const Double_t *pn, Double_t *pw);
113 virtual void NormalWCtoNDC(const Float_t *pw, Float_t *pn);
114 virtual void NormalWCtoNDC(const Double_t *pw, Double_t *pn);
115 virtual void PadRange(Int_t rback);
116 virtual void ResizePad();
117 virtual void SetAutoRange(Bool_t autorange=kTRUE) {fAutoRange=autorange;}
118 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);
119 virtual void SetDefaultWindow();
120 virtual void SetDview(Double_t dview) {fDview=dview;}
121 virtual void SetDproj(Double_t dproj) {fDproj=dproj;}
122 virtual void SetLatitude(Double_t latitude) {fLatitude = latitude;}
123 virtual void SetLongitude(Double_t longitude) {fLongitude = longitude;}
124 virtual void SetPsi(Double_t psi) {fPsi = psi;}
125 virtual void SetOutlineToCube();
126 virtual void SetParallel(); // *MENU*
127 virtual void SetPerspective(); // *MENU*
128 virtual void SetRange(const Double_t *min, const Double_t *max);
129 virtual void SetRange(Double_t x0, Double_t y0, Double_t z0, Double_t x1, Double_t y1, Double_t z1, Int_t flag=0);
130 virtual void SetSystem(Int_t system) {fSystem = system;}
131 virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep);
132 virtual void SetViewChanged(Bool_t flag=kTRUE) {fChanged = flag;}
133 virtual void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv);
134 virtual void WCtoNDC(const Float_t *pw, Float_t *pn);
135 virtual void WCtoNDC(const Double_t *pw, Double_t *pn);
136
137//--
138 virtual void MoveFocus(Double_t *center, Double_t dx, Double_t dy, Double_t dz, Int_t nsteps=10,
139 Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0);
140 virtual void MoveViewCommand(Char_t chCode, Int_t count=1);
141 virtual void MoveWindow(Char_t option);
142
143 virtual void AdjustScales(TVirtualPad *pad=0);
144 virtual void Centered3DImages(TVirtualPad *pad=0);
145 virtual void Centered(); // *MENU*
146 virtual void FrontView(TVirtualPad *pad=0);
147 virtual void Front(); // *MENU*
148
149 virtual void ZoomIn(); // *MENU*
150 virtual void ZoomOut(); // *MENU*
151 virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor = 1.25 );
152 virtual void UnzoomView(TVirtualPad *pad=0,Double_t unZoomFactor = 1.25);
153
154 virtual void RotateView(Double_t phi, Double_t theta, TVirtualPad *pad=0);
155 virtual void SideView(TVirtualPad *pad=0);
156 virtual void Side(); // *MENU*
157 virtual void TopView(TVirtualPad *pad=0);
158 virtual void Top(); // *MENU*
159
160 virtual void ToggleRulers(TVirtualPad *pad=0);
161 virtual void ShowAxis(); // *MENU*
162 virtual void ToggleZoom(TVirtualPad *pad=0);
163 virtual void ZoomMove(); // *MENU*
164 virtual void Zoom(); // *MENU*
165 virtual void UnZoom(); // *MENU*
166
167 static void AdjustPad(TVirtualPad *pad=0);
168
169 ClassDef(TView3D,3); //3-D View
170};
171
172#endif
173
#define c(i)
Definition: RSha256.hxx:101
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
char Char_t
Definition: RtypesCore.h:29
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
#define BIT(n)
Definition: Rtypes.h:83
A doubly linked list.
Definition: TList.h:44
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Sequenceable collection abstract base class.
The 3D view class.
Definition: TView3D.h:29
virtual void Zoom()
Definition: TView3D.cxx:1935
Double_t fDproj
Definition: TView3D.h:36
virtual Bool_t IsViewChanged() const
Definition: TView3D.h:110
Bool_t fDefaultOutline
Definition: TView3D.h:54
virtual void UnzoomView(TVirtualPad *pad=0, Double_t unZoomFactor=1.25)
unZOOM this view.
Definition: TView3D.cxx:1650
Double_t fTB[16]
Definition: TView3D.h:40
virtual void SetViewChanged(Bool_t flag=kTRUE)
Definition: TView3D.h:132
TView3D()
Default constructor.
Definition: TView3D.cxx:108
Double_t fUpix
Definition: TView3D.h:37
virtual void Side()
Definition: TView3D.cxx:1932
Double_t fX2[3]
Definition: TView3D.h:47
Bool_t fChanged
Definition: TView3D.h:56
static void AdjustPad(TVirtualPad *pad=0)
Force the current pad to be updated.
Definition: TView3D.cxx:1538
virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor=1.25)
ZOOM this view.
Definition: TView3D.cxx:1659
virtual void SetPerspective()
Set perspective option.
Definition: TView3D.cxx:1314
Double_t fPsi
Definition: TView3D.h:34
virtual ~TView3D()
TView3D default destructor.
Definition: TView3D.cxx:275
virtual void Centered3DImages(TVirtualPad *pad=0)
Move view into the center of the scene.
Definition: TView3D.cxx:1634
virtual TSeqCollection * GetOutline()
Definition: TView3D.h:97
virtual Int_t GetSystem()
Definition: TView3D.h:101
virtual void SetParallel()
Set the parallel option (default).
Definition: TView3D.cxx:1303
Double_t fLongitude
Definition: TView3D.h:33
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.
Definition: TView3D.cxx:1554
Double_t fZ1[3]
Definition: TView3D.h:50
Double_t fUVcoord[4]
Definition: TView3D.h:43
virtual void FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2)
Find critical PHI sectors.
Definition: TView3D.cxx:805
Double_t fZ2[3]
Definition: TView3D.h:51
TView3D & operator=(const TView3D &)
Assignment operator.
Definition: TView3D.cxx:234
Double_t fY1[3]
Definition: TView3D.h:48
virtual void PadRange(Int_t rback)
Set the correct window size for lego and surface plots.
Definition: TView3D.cxx:1157
virtual void SetAutoRange(Bool_t autorange=kTRUE)
Definition: TView3D.h:117
virtual Double_t GetWindowWidth() const
Definition: TView3D.h:103
virtual Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio)
Return distance to axis from point px,py.
Definition: TView3D.cxx:970
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Transfer point from world to normalized coordinates.
Definition: TView3D.cxx:1478
Double_t fTback[16]
Definition: TView3D.h:45
Double_t fTnorm[16]
Definition: TView3D.h:44
void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view direction (in spherical coordinates).
Definition: TView3D.cxx:1436
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.
Definition: TView3D.cxx:619
virtual void SetSystem(Int_t system)
Definition: TView3D.h:130
Double_t fLatitude
Definition: TView3D.h:32
virtual void NormalWCtoNDC(const Float_t *pw, Float_t *pn)
Transfer vector of NORMAL from word to normalized coordinates.
Definition: TView3D.cxx:1099
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.
Definition: TView3D.cxx:1682
virtual void DefinePerspectiveView()
Define perspective view.
Definition: TView3D.cxx:399
virtual Double_t GetPsi()
Definition: TView3D.h:92
virtual Bool_t GetAutoRange()
Definition: TView3D.h:89
virtual void AdjustScales(TVirtualPad *pad=0)
Adjust all sides of view in respect of the biggest one.
Definition: TView3D.cxx:1616
virtual void MoveWindow(Char_t option)
Move view window :
Definition: TView3D.cxx:1786
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.
Definition: TView3D.cxx:1236
virtual void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv)
Set viewing window.
Definition: TView3D.cxx:1385
virtual void SetLongitude(Double_t longitude)
Definition: TView3D.h:123
virtual Double_t * GetTN()
Definition: TView3D.h:99
virtual void SideView(TVirtualPad *pad=0)
Set to side view.
Definition: TView3D.cxx:1575
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view parameters.
Definition: TView3D.cxx:1396
virtual void FindScope(Double_t *scale, Double_t *center, Int_t &irep)
Find centre of a MIN-MAX scope and scale factors.
Definition: TView3D.cxx:932
virtual Double_t GetLatitude()
Definition: TView3D.h:90
virtual void SetRange(const Double_t *min, const Double_t *max)
Set Range function.
Definition: TView3D.cxx:1326
virtual Bool_t IsClippedNDC(Double_t *p) const
Check if point is clipped in perspective view.
Definition: TView3D.cxx:1055
virtual void TopView(TVirtualPad *pad=0)
Set to top view.
Definition: TView3D.cxx:1591
virtual void Top()
Definition: TView3D.cxx:1933
virtual void SetDview(Double_t dview)
Definition: TView3D.h:120
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)
Transfer point from normalized to world coordinates.
Definition: TView3D.cxx:1069
virtual Double_t GetWindowHeight() const
Definition: TView3D.h:104
virtual void ResizePad()
Recompute window for perspective view.
Definition: TView3D.cxx:1404
Double_t fY2[3]
Definition: TView3D.h:49
virtual void SetDefaultWindow()
Set default viewing window.
Definition: TView3D.cxx:1251
virtual void Front()
Definition: TView3D.cxx:1930
Double_t fX1[3]
Definition: TView3D.h:46
virtual void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const
Get current window extent.
Definition: TView3D.cxx:1044
virtual void ExecuteRotateView(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TView3D.cxx:641
virtual void FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn)
Find Z component of NORMAL in normalized coordinates.
Definition: TView3D.cxx:785
Double_t fTN[16]
Definition: TView3D.h:39
virtual void UnZoom()
Definition: TView3D.cxx:1936
virtual Bool_t IsPerspective() const
Definition: TView3D.h:109
Bool_t fAutoRange
Definition: TView3D.h:55
virtual void ZoomMove()
Definition: TView3D.cxx:1934
virtual Double_t GetDview() const
Definition: TView3D.h:86
virtual void ToggleZoom(TVirtualPad *pad=0)
Turn on /off the interactive option to Zoom / Move / Change attributes of 3D axis correspond this vie...
Definition: TView3D.cxx:1608
Double_t fRmin[3]
Definition: TView3D.h:42
Double_t fRmax[3]
Definition: TView3D.h:41
virtual Double_t GetLongitude()
Definition: TView3D.h:91
virtual void MoveViewCommand(Char_t chCode, Int_t count=1)
Definition: TView3D.cxx:1738
virtual void ToggleRulers(TVirtualPad *pad=0)
Turn on /off 3D axis.
Definition: TView3D.cxx:1599
virtual void ZoomOut()
Zoom out.
Definition: TView3D.cxx:1841
virtual void SetPsi(Double_t psi)
Definition: TView3D.h:124
virtual Double_t * GetTnorm()
Definition: TView3D.h:100
virtual Double_t * GetTback()
Definition: TView3D.h:98
virtual Double_t * GetRmax()
Definition: TView3D.h:95
Double_t fDview
Definition: TView3D.h:35
virtual void Centered()
Definition: TView3D.cxx:1929
@ kPerspective
Definition: TView3D.h:67
virtual Double_t * GetRmin()
Definition: TView3D.h:96
virtual void SetLatitude(Double_t latitude)
Definition: TView3D.h:122
virtual void FrontView(TVirtualPad *pad=0)
Set to front view.
Definition: TView3D.cxx:1583
virtual Double_t GetDproj() const
Definition: TView3D.h:87
virtual Double_t GetExtent() const
Get maximum view extent.
Definition: TView3D.cxx:1016
TSeqCollection * fOutline
Definition: TView3D.h:53
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)
Definition: TView3D.cxx:513
virtual void GetRange(Float_t *min, Float_t *max)
Get Range function.
Definition: TView3D.cxx:1028
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TView3D.cxx:627
virtual void ZoomIn()
Zoom in.
Definition: TView3D.cxx:1821
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.
Definition: TView3D.cxx:871
Int_t fSystem
Definition: TView3D.h:52
virtual void SetOutlineToCube()
This is a function which creates default outline.
Definition: TView3D.cxx:1291
virtual void SetDproj(Double_t dproj)
Definition: TView3D.h:121
Double_t fVpix
Definition: TView3D.h:38
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.
Definition: TView3D.cxx:297
virtual void ShowAxis()
Definition: TView3D.cxx:1931
See TView3D.
Definition: TView.h:25
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double s