Logo ROOT   6.08/07
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 #ifndef ROOT_TView
25 #include "TView.h"
26 #endif
27 
28 class TSeqCollection;
29 class TVirtualPad;
30 
31 class TView3D : public TView {
32 
33 protected:
34  Double_t fLatitude; //View angle latitude
35  Double_t fLongitude; //View angle longitude
36  Double_t fPsi; //View angle psi
37  Double_t fDview; //Distance from COP to COV
38  Double_t fDproj; //Distance from COP to projection plane
39  Double_t fUpix; // pad X size in pixels
40  Double_t fVpix; // pad Y size in pixels
41  Double_t fTN[16]; //
42  Double_t fTB[16]; //
43  Double_t fRmax[3]; //Upper limits of object
44  Double_t fRmin[3]; //Lower limits of object
45  Double_t fUVcoord[4]; //Viewing window limits
46  Double_t fTnorm[16]; //Transformation matrix
47  Double_t fTback[16]; //Back transformation matrix
48  Double_t fX1[3]; //First coordinate of X axis
49  Double_t fX2[3]; //Second coordinate of X axis
50  Double_t fY1[3]; //First coordinate of Y axis
51  Double_t fY2[3]; //Second coordinate of Y axis
52  Double_t fZ1[3]; //First coordinate of Z axis
53  Double_t fZ2[3]; //Second coordinate of Z axis
54  Int_t fSystem; //Coordinate system
55  TSeqCollection *fOutline; //Collection of outline's objects
56  Bool_t fDefaultOutline; //Set to TRUE if outline is default cube
57  Bool_t fAutoRange; //Set to TRUE if range computed automatically
58  Bool_t fChanged; //! Set to TRUE after ExecuteRotateView
59 
60  TView3D(const TView3D&); // Not implemented
61  TView3D& operator=(const TView3D&); // Not implemented
62 
63  void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep);
64 
65 
66 public:
67  // TView3D status bits
68  enum {
70  };
71 
72  TView3D();
73  TView3D(Int_t system, const Double_t *rmin, const Double_t *rmax);
74  virtual ~TView3D();
75 
76  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);
77  virtual void DefinePerspectiveView();
78  virtual void DefineViewDirection(const Double_t *s, const Double_t *c,
79  Double_t cosphi, Double_t sinphi,
80  Double_t costhe, Double_t sinthe,
81  Double_t cospsi, Double_t sinpsi,
82  Double_t *tnorm, Double_t *tback);
83  virtual void DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax);
84  virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
85  virtual void ExecuteRotateView(Int_t event, Int_t px, Int_t py);
86  virtual void FindScope(Double_t *scale, Double_t *center, Int_t &irep);
87  virtual Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio);
88  virtual Double_t GetDview() const {return fDview;}
89  virtual Double_t GetDproj() const {return fDproj;}
90  virtual Double_t GetExtent() const;
91  virtual Bool_t GetAutoRange() {return fAutoRange;}
92  virtual Double_t GetLatitude() {return fLatitude;}
93  virtual Double_t GetLongitude() {return fLongitude;}
94  virtual Double_t GetPsi() {return fPsi;}
95  virtual void GetRange (Float_t *min, Float_t *max);
96  virtual void GetRange (Double_t *min, Double_t *max);
97  virtual Double_t *GetRmax() {return fRmax;}
98  virtual Double_t *GetRmin() {return fRmin;}
99  virtual TSeqCollection *GetOutline() {return fOutline; }
100  virtual Double_t *GetTback() {return fTback;}
101  virtual Double_t *GetTN() {return fTN;}
102  virtual Double_t *GetTnorm() {return fTnorm;}
103  virtual Int_t GetSystem() {return fSystem;}
104  virtual void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const;
105  virtual Double_t GetWindowWidth() const {return 0.5*(fUVcoord[1]-fUVcoord[0]);}
106  virtual Double_t GetWindowHeight() const {return 0.5*(fUVcoord[3]-fUVcoord[2]);}
107  virtual void FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn);
108  virtual void FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2);
109  virtual void FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2);
110  virtual Bool_t IsClippedNDC(Double_t *p) const;
111  virtual Bool_t IsPerspective() const {return TestBit(kPerspective);}
112  virtual Bool_t IsViewChanged() const {return fChanged;}
113  virtual void NDCtoWC(const Float_t *pn, Float_t *pw);
114  virtual void NDCtoWC(const Double_t *pn, Double_t *pw);
115  virtual void NormalWCtoNDC(const Float_t *pw, Float_t *pn);
116  virtual void NormalWCtoNDC(const Double_t *pw, Double_t *pn);
117  virtual void PadRange(Int_t rback);
118  virtual void ResizePad();
119  virtual void SetAutoRange(Bool_t autorange=kTRUE) {fAutoRange=autorange;}
120  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);
121  virtual void SetDefaultWindow();
122  virtual void SetDview(Double_t dview) {fDview=dview;}
123  virtual void SetDproj(Double_t dproj) {fDproj=dproj;}
124  virtual void SetLatitude(Double_t latitude) {fLatitude = latitude;}
125  virtual void SetLongitude(Double_t longitude) {fLongitude = longitude;}
126  virtual void SetPsi(Double_t psi) {fPsi = psi;}
127  virtual void SetOutlineToCube();
128  virtual void SetParallel(); // *MENU*
129  virtual void SetPerspective(); // *MENU*
130  virtual void SetRange(const Double_t *min, const Double_t *max);
131  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);
132  virtual void SetSystem(Int_t system) {fSystem = system;}
133  virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep);
134  virtual void SetViewChanged(Bool_t flag=kTRUE) {fChanged = flag;}
135  virtual void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv);
136  virtual void WCtoNDC(const Float_t *pw, Float_t *pn);
137  virtual void WCtoNDC(const Double_t *pw, Double_t *pn);
138 
139 //--
140  virtual void MoveFocus(Double_t *center, Double_t dx, Double_t dy, Double_t dz, Int_t nsteps=10,
141  Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0);
142  virtual void MoveViewCommand(Char_t chCode, Int_t count=1);
143  virtual void MoveWindow(Char_t option);
144 
145  virtual void AdjustScales(TVirtualPad *pad=0); // *MENU*
146  virtual void Centered3DImages(TVirtualPad *pad=0);
147  virtual void Centered(); // *MENU*
148  virtual void FrontView(TVirtualPad *pad=0);
149  virtual void Front(); // *MENU*
150 
151  virtual void ZoomIn(); // *MENU*
152  virtual void ZoomOut(); // *MENU*
153  virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor = 1.25 );
154  virtual void UnzoomView(TVirtualPad *pad=0,Double_t unZoomFactor = 1.25);
155 
156  virtual void RotateView(Double_t phi, Double_t theta, TVirtualPad *pad=0);
157  virtual void SideView(TVirtualPad *pad=0);
158  virtual void Side(); // *MENU*
159  virtual void TopView(TVirtualPad *pad=0);
160  virtual void Top(); // *MENU*
161 
162  virtual void ToggleRulers(TVirtualPad *pad=0);
163  virtual void ShowAxis(); // *MENU*
164  virtual void ToggleZoom(TVirtualPad *pad=0);
165  virtual void ZoomMove(); // *MENU*
166  virtual void Zoom(); // *MENU*
167  virtual void UnZoom(); // *MENU*
168 
169  static void AdjustPad(TVirtualPad *pad=0);
170 
171  ClassDef(TView3D,3); //3-D View
172 };
173 
174 #endif
175 
virtual void ResizePad()
Recompute window for perspective view.
Definition: TView3D.cxx:1461
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Transfer point from world to normalized coordinates.
Definition: TView3D.cxx:1535
virtual Double_t GetLatitude()
Definition: TView3D.h:92
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:1732
Double_t fUpix
Definition: TView3D.h:39
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TView3D.cxx:686
Double_t fPsi
Definition: TView3D.h:36
Double_t fVpix
Definition: TView3D.h:40
Int_t fSystem
Definition: TView3D.h:54
virtual void SetViewChanged(Bool_t flag=kTRUE)
Definition: TView3D.h:134
virtual Double_t GetDview() const
Definition: TView3D.h:88
virtual void SetOutlineToCube()
This is a function which creates default outline.
Definition: TView3D.cxx:1348
Double_t fLatitude
Definition: TView3D.h:34
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:310
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:678
Double_t fTB[16]
Definition: TView3D.h:42
virtual void UnZoom()
Definition: TView3D.cxx:1986
Double_t fRmin[3]
Definition: TView3D.h:44
float Float_t
Definition: RtypesCore.h:53
return c
virtual Double_t GetPsi()
Definition: TView3D.h:94
virtual void ZoomMove()
Definition: TView3D.cxx:1984
virtual Bool_t IsClippedNDC(Double_t *p) const
Check if point is clipped in perspective view.
Definition: TView3D.cxx:1114
virtual void ZoomOut()
Zoom out.
Definition: TView3D.cxx:1891
virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor=1.25)
ZOOM this view.
Definition: TView3D.cxx:1709
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:157
Double_t fZ1[3]
Definition: TView3D.h:52
virtual void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const
Get current window extent.
Definition: TView3D.cxx:1103
#define BIT(n)
Definition: Rtypes.h:120
See TView3D.
Definition: TView.h:29
virtual Double_t GetWindowHeight() const
Definition: TView3D.h:106
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:1658
Bool_t fChanged
Definition: TView3D.h:58
virtual void Centered()
Definition: TView3D.cxx:1979
Bool_t fDefaultOutline
Definition: TView3D.h:56
Double_t fTN[16]
Definition: TView3D.h:41
virtual void SetDview(Double_t dview)
Definition: TView3D.h:122
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:1293
virtual void PadRange(Int_t rback)
Set the correct window size for lego and surface plots.
Definition: TView3D.cxx:1214
virtual void MoveViewCommand(Char_t chCode, Int_t count=1)
Definition: TView3D.cxx:1788
virtual void NormalWCtoNDC(const Float_t *pw, Float_t *pn)
Transfer vector of NORMAL from word to normalized coordinates.
Definition: TView3D.cxx:1156
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:864
virtual void Zoom()
Definition: TView3D.cxx:1985
Double_t fRmax[3]
Definition: TView3D.h:43
virtual void ShowAxis()
Definition: TView3D.cxx:1981
Double_t fTback[16]
Definition: TView3D.h:47
virtual void SetParallel()
Set the parallel option (default).
Definition: TView3D.cxx:1360
virtual Double_t * GetTback()
Definition: TView3D.h:100
virtual ~TView3D()
TView3D default destructor.
Definition: TView3D.cxx:275
void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view direction (in spherical coordinates).
Definition: TView3D.cxx:1493
Sequenceable collection abstract base class.
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
TView3D & operator=(const TView3D &)
Assignment operator.
Definition: TView3D.cxx:234
virtual void DefinePerspectiveView()
Define perspective view.
Definition: TView3D.cxx:458
virtual Double_t GetExtent() const
Get maximum view extent.
Definition: TView3D.cxx:1075
virtual void SetDproj(Double_t dproj)
Definition: TView3D.h:123
virtual Double_t GetWindowWidth() const
Definition: TView3D.h:105
virtual Int_t GetSystem()
Definition: TView3D.h:103
virtual void Centered3DImages(TVirtualPad *pad=0)
Move view into the center of the scene.
Definition: TView3D.cxx:1684
virtual void ZoomIn()
Zoom in.
Definition: TView3D.cxx:1871
virtual void SetLongitude(Double_t longitude)
Definition: TView3D.h:125
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Set view parameters.
Definition: TView3D.cxx:1453
Double_t fX2[3]
Definition: TView3D.h:49
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:991
Double_t fLongitude
Definition: TView3D.h:35
virtual void TopView(TVirtualPad *pad=0)
Set to top view.
Definition: TView3D.cxx:1641
virtual void FrontView(TVirtualPad *pad=0)
Set to front view.
Definition: TView3D.cxx:1633
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
virtual Double_t * GetTnorm()
Definition: TView3D.h:102
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)
Transfer point from normalized to world coordinates.
Definition: TView3D.cxx:1128
virtual void SetAutoRange(Bool_t autorange=kTRUE)
Definition: TView3D.h:119
A doubly linked list.
Definition: TList.h:47
virtual Double_t * GetTN()
Definition: TView3D.h:101
Double_t fDview
Definition: TView3D.h:37
virtual void AdjustScales(TVirtualPad *pad=0)
Adjust all sides of view in respect of the biggest one.
Definition: TView3D.cxx:1666
Double_t fX1[3]
Definition: TView3D.h:48
virtual void SetSystem(Int_t system)
Definition: TView3D.h:132
virtual Bool_t IsPerspective() const
Definition: TView3D.h:111
virtual Double_t GetLongitude()
Definition: TView3D.h:93
virtual void ToggleRulers(TVirtualPad *pad=0)
Turn on /off 3D axis.
Definition: TView3D.cxx:1649
The 3D view class.
Definition: TView3D.h:31
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:930
virtual void ExecuteRotateView(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TView3D.cxx:700
virtual void Top()
Definition: TView3D.cxx:1983
Double_t fDproj
Definition: TView3D.h:38
virtual void Side()
Definition: TView3D.cxx:1982
Double_t fZ2[3]
Definition: TView3D.h:53
virtual void SetPerspective()
Set perspective option.
Definition: TView3D.cxx:1371
virtual void SetLatitude(Double_t latitude)
Definition: TView3D.h:124
virtual void Front()
Definition: TView3D.cxx:1980
virtual Double_t * GetRmax()
Definition: TView3D.h:97
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:1604
static const double x1[5]
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:572
double Double_t
Definition: RtypesCore.h:55
virtual void SetDefaultWindow()
Set default viewing window.
Definition: TView3D.cxx:1308
Double_t y[n]
Definition: legend1.C:17
virtual void GetRange(Float_t *min, Float_t *max)
Get Range function.
Definition: TView3D.cxx:1087
virtual void SetPsi(Double_t psi)
Definition: TView3D.h:126
virtual Double_t * GetRmin()
Definition: TView3D.h:98
virtual void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv)
Set viewing window.
Definition: TView3D.cxx:1442
virtual void SideView(TVirtualPad *pad=0)
Set to side view.
Definition: TView3D.cxx:1625
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
char Char_t
Definition: RtypesCore.h:29
TView3D()
Default constructor.
Definition: TView3D.cxx:108
TSeqCollection * fOutline
Definition: TView3D.h:55
virtual void MoveWindow(Char_t option)
Move view window :
Definition: TView3D.cxx:1836
Double_t fY1[3]
Definition: TView3D.h:50
virtual TSeqCollection * GetOutline()
Definition: TView3D.h:99
Double_t fTnorm[16]
Definition: TView3D.h:46
virtual Bool_t GetAutoRange()
Definition: TView3D.h:91
Double_t fUVcoord[4]
Definition: TView3D.h:45
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:1029
virtual Double_t GetDproj() const
Definition: TView3D.h:89
Double_t fY2[3]
Definition: TView3D.h:51
virtual void SetRange(const Double_t *min, const Double_t *max)
Set Range function.
Definition: TView3D.cxx:1383
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void UnzoomView(TVirtualPad *pad=0, Double_t unZoomFactor=1.25)
unZOOM this view.
Definition: TView3D.cxx:1700
virtual Bool_t IsViewChanged() const
Definition: TView3D.h:112
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:844
static void AdjustPad(TVirtualPad *pad=0)
Force the current pad to be updated.
Definition: TView3D.cxx:1588
Bool_t fAutoRange
Definition: TView3D.h:57