ROOT logo
// @(#)root/g3d:$Id: TView3D.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Rene Brun 19/02/2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/


#ifndef ROOT_TView3D
#define ROOT_TView3D


/////////////////////////////////////////////////////////////////////////
//                                                                     //
// TView3D                                                             //
//                                                                     //
/////////////////////////////////////////////////////////////////////////


#ifndef ROOT_TView
#include "TView.h"
#endif

class TSeqCollection;
class TVirtualPad;

class TView3D : public TView {

protected:
   Double_t        fLatitude;         //View angle latitude
   Double_t        fLongitude;        //View angle longitude
   Double_t        fPsi;              //View angle psi
   Double_t        fDview;            //Distance from COP to COV
   Double_t        fDproj;            //Distance from COP to projection plane
   Double_t        fUpix;             // pad X size in pixels
   Double_t        fVpix;             // pad Y size in pixels
   Double_t        fTN[16];           //
   Double_t        fTB[16];           //
   Double_t        fRmax[3];          //Upper limits of object
   Double_t        fRmin[3];          //Lower limits of object
   Double_t        fUVcoord[4];       //Viewing window limits
   Double_t        fTnorm[16];        //Transformation matrix
   Double_t        fTback[16];        //Back transformation matrix
   Double_t        fX1[3];            //First coordinate of X axis
   Double_t        fX2[3];            //Second coordinate of X axis
   Double_t        fY1[3];            //First coordinate of Y axis
   Double_t        fY2[3];            //Second coordinate of Y axis
   Double_t        fZ1[3];            //First coordinate of Z axis
   Double_t        fZ2[3];            //Second coordinate of Z axis
   Int_t           fSystem;           //Coordinate system
   TSeqCollection *fOutline;          //Collection of outline's objects
   Bool_t          fDefaultOutline;   //Set to TRUE if outline is default cube
   Bool_t          fAutoRange;        //Set to TRUE if range computed automatically
   Bool_t          fChanged;          //! Set to TRUE after ExecuteRotateView

   TView3D(const TView3D&); // Not implemented
   TView3D& operator=(const TView3D&); // Not implemented

   void            ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep);


public:
   // TView3D status bits
   enum {
      kPerspective  = BIT(6)
   };

   TView3D();
   TView3D(Int_t system, const Double_t *rmin, const Double_t *rmax);
   virtual ~TView3D();

   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);
   virtual void     DefinePerspectiveView();
   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);
   virtual void      DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax);
   virtual void      ExecuteEvent(Int_t event, Int_t px, Int_t py);
   virtual void      ExecuteRotateView(Int_t event, Int_t px, Int_t py);
   virtual void      FindScope(Double_t *scale, Double_t *center, Int_t &irep);
   virtual Int_t     GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio);
   virtual Double_t  GetDview() const {return fDview;}
   virtual Double_t  GetDproj() const {return fDproj;}
   virtual Double_t  GetExtent() const;
   virtual Bool_t    GetAutoRange() {return fAutoRange;}
   virtual Double_t  GetLatitude() {return fLatitude;}
   virtual Double_t  GetLongitude() {return fLongitude;}
   virtual Double_t  GetPsi() {return fPsi;}
   virtual void      GetRange (Float_t *min, Float_t *max);
   virtual void      GetRange (Double_t *min, Double_t *max);
   virtual Double_t *GetRmax() {return fRmax;}
   virtual Double_t *GetRmin() {return fRmin;}
   virtual TSeqCollection *GetOutline() {return fOutline; }
   virtual Double_t *GetTback() {return fTback;}
   virtual Double_t *GetTN() {return fTN;}
   virtual Double_t *GetTnorm() {return fTnorm;}
   virtual Int_t     GetSystem() {return fSystem;}
   virtual void      GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const;
   virtual Double_t  GetWindowWidth() const {return 0.5*(fUVcoord[1]-fUVcoord[0]);}
   virtual Double_t  GetWindowHeight() const {return 0.5*(fUVcoord[3]-fUVcoord[2]);}
   virtual void      FindNormal(Double_t x, Double_t  y, Double_t z, Double_t &zn);
   virtual void      FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2);
   virtual void      FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2);
   virtual Bool_t    IsClippedNDC(Double_t *p) const;
   virtual Bool_t    IsPerspective() const {return TestBit(kPerspective);}
   virtual Bool_t    IsViewChanged() const {return fChanged;}
   virtual void      NDCtoWC(const Float_t *pn, Float_t *pw);
   virtual void      NDCtoWC(const Double_t *pn, Double_t *pw);
   virtual void      NormalWCtoNDC(const Float_t *pw, Float_t *pn);
   virtual void      NormalWCtoNDC(const Double_t *pw, Double_t *pn);
   virtual void      PadRange(Int_t rback);
   virtual void      ResizePad();
   virtual void      SetAutoRange(Bool_t autorange=kTRUE) {fAutoRange=autorange;}
   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);
   virtual void      SetDefaultWindow();
   virtual void      SetDview(Double_t dview) {fDview=dview;}
   virtual void      SetDproj(Double_t dproj) {fDproj=dproj;}
   virtual void      SetLatitude(Double_t latitude) {fLatitude = latitude;}
   virtual void      SetLongitude(Double_t longitude) {fLongitude = longitude;}
   virtual void      SetPsi(Double_t psi) {fPsi = psi;}
   virtual void      SetOutlineToCube();
   virtual void      SetParallel(); // *MENU*
   virtual void      SetPerspective(); // *MENU*
   virtual void      SetRange(const Double_t *min, const Double_t *max);
   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);
   virtual void      SetSystem(Int_t system) {fSystem = system;}
   virtual void      SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep);
   virtual void      SetViewChanged(Bool_t flag=kTRUE) {fChanged = flag;}
   virtual void      SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv);
   virtual void      WCtoNDC(const Float_t *pw, Float_t *pn);
   virtual void      WCtoNDC(const Double_t *pw, Double_t *pn);

//--
   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);
   virtual void      MoveViewCommand(Char_t chCode, Int_t count=1);
   virtual void      MoveWindow(Char_t option);

   virtual void      AdjustScales(TVirtualPad *pad=0); // *MENU*
   virtual void      Centered3DImages(TVirtualPad *pad=0);
   virtual void      Centered();                       // *MENU*
   virtual void      FrontView(TVirtualPad *pad=0);
   virtual void      Front();                          // *MENU*

   virtual void      ZoomIn(); // *MENU*
   virtual void      ZoomOut(); // *MENU*
   virtual void      ZoomView(TVirtualPad *pad=0, Double_t zoomFactor = 1.25 );
   virtual void      UnzoomView(TVirtualPad *pad=0,Double_t unZoomFactor = 1.25);

   virtual void      RotateView(Double_t phi, Double_t theta, TVirtualPad *pad=0);
   virtual void      SideView(TVirtualPad *pad=0);
   virtual void      Side();                          // *MENU*
   virtual void      TopView(TVirtualPad *pad=0);
   virtual void      Top();                           // *MENU*

   virtual void      ToggleRulers(TVirtualPad *pad=0);
   virtual void      ShowAxis();                      // *MENU*
   virtual void      ToggleZoom(TVirtualPad *pad=0);
   virtual void      ZoomMove();                      // *MENU*
   virtual void      Zoom();                          // *MENU*
   virtual void      UnZoom();                        // *MENU*

   static  void      AdjustPad(TVirtualPad *pad=0);

   ClassDef(TView3D,3);  //3-D View
};

#endif

 TView3D.h:1
 TView3D.h:2
 TView3D.h:3
 TView3D.h:4
 TView3D.h:5
 TView3D.h:6
 TView3D.h:7
 TView3D.h:8
 TView3D.h:9
 TView3D.h:10
 TView3D.h:11
 TView3D.h:12
 TView3D.h:13
 TView3D.h:14
 TView3D.h:15
 TView3D.h:16
 TView3D.h:17
 TView3D.h:18
 TView3D.h:19
 TView3D.h:20
 TView3D.h:21
 TView3D.h:22
 TView3D.h:23
 TView3D.h:24
 TView3D.h:25
 TView3D.h:26
 TView3D.h:27
 TView3D.h:28
 TView3D.h:29
 TView3D.h:30
 TView3D.h:31
 TView3D.h:32
 TView3D.h:33
 TView3D.h:34
 TView3D.h:35
 TView3D.h:36
 TView3D.h:37
 TView3D.h:38
 TView3D.h:39
 TView3D.h:40
 TView3D.h:41
 TView3D.h:42
 TView3D.h:43
 TView3D.h:44
 TView3D.h:45
 TView3D.h:46
 TView3D.h:47
 TView3D.h:48
 TView3D.h:49
 TView3D.h:50
 TView3D.h:51
 TView3D.h:52
 TView3D.h:53
 TView3D.h:54
 TView3D.h:55
 TView3D.h:56
 TView3D.h:57
 TView3D.h:58
 TView3D.h:59
 TView3D.h:60
 TView3D.h:61
 TView3D.h:62
 TView3D.h:63
 TView3D.h:64
 TView3D.h:65
 TView3D.h:66
 TView3D.h:67
 TView3D.h:68
 TView3D.h:69
 TView3D.h:70
 TView3D.h:71
 TView3D.h:72
 TView3D.h:73
 TView3D.h:74
 TView3D.h:75
 TView3D.h:76
 TView3D.h:77
 TView3D.h:78
 TView3D.h:79
 TView3D.h:80
 TView3D.h:81
 TView3D.h:82
 TView3D.h:83
 TView3D.h:84
 TView3D.h:85
 TView3D.h:86
 TView3D.h:87
 TView3D.h:88
 TView3D.h:89
 TView3D.h:90
 TView3D.h:91
 TView3D.h:92
 TView3D.h:93
 TView3D.h:94
 TView3D.h:95
 TView3D.h:96
 TView3D.h:97
 TView3D.h:98
 TView3D.h:99
 TView3D.h:100
 TView3D.h:101
 TView3D.h:102
 TView3D.h:103
 TView3D.h:104
 TView3D.h:105
 TView3D.h:106
 TView3D.h:107
 TView3D.h:108
 TView3D.h:109
 TView3D.h:110
 TView3D.h:111
 TView3D.h:112
 TView3D.h:113
 TView3D.h:114
 TView3D.h:115
 TView3D.h:116
 TView3D.h:117
 TView3D.h:118
 TView3D.h:119
 TView3D.h:120
 TView3D.h:121
 TView3D.h:122
 TView3D.h:123
 TView3D.h:124
 TView3D.h:125
 TView3D.h:126
 TView3D.h:127
 TView3D.h:128
 TView3D.h:129
 TView3D.h:130
 TView3D.h:131
 TView3D.h:132
 TView3D.h:133
 TView3D.h:134
 TView3D.h:135
 TView3D.h:136
 TView3D.h:137
 TView3D.h:138
 TView3D.h:139
 TView3D.h:140
 TView3D.h:141
 TView3D.h:142
 TView3D.h:143
 TView3D.h:144
 TView3D.h:145
 TView3D.h:146
 TView3D.h:147
 TView3D.h:148
 TView3D.h:149
 TView3D.h:150
 TView3D.h:151
 TView3D.h:152
 TView3D.h:153
 TView3D.h:154
 TView3D.h:155
 TView3D.h:156
 TView3D.h:157
 TView3D.h:158
 TView3D.h:159
 TView3D.h:160
 TView3D.h:161
 TView3D.h:162
 TView3D.h:163
 TView3D.h:164
 TView3D.h:165
 TView3D.h:166
 TView3D.h:167
 TView3D.h:168
 TView3D.h:169
 TView3D.h:170
 TView3D.h:171
 TView3D.h:172
 TView3D.h:173
 TView3D.h:174
 TView3D.h:175