ROOT logo
// $Id: PupilInfo.h 2363 2010-04-06 20:49:16Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#ifndef GledCore_PupilInfo_H
#define GledCore_PupilInfo_H

#include <Glasses/SubShellInfo.h>
#include <Glasses/CameraInfo.h>
#include <Glasses/ZNode.h>
#include <Gled/GCondition.h>
#include <Eye/Ray.h>

#include <Stones/ZColor.h>

class PupilInfo : public SubShellInfo
{
  // 7777 AddViewInclude(GL/glew.h)
  MAC_RNR_FRIENDS(PupilInfo);
  friend class Pupil;

public:
  enum Projection_e { P_Perspective, P_Orthographic };
  enum PrivRayQN_e  { PRQN_offset = RayNS::RQN_user_0,
		      PRQN_resize_window,
		      PRQN_camera_home,
		      PRQN_smooth_camera_home,
		      PRQN_redraw,
		      PRQN_dump_image
  };

private:
  void		_init();

protected:
  // Basic config.
  Int_t		mMaxRnrDepth;	// X{gS} 7 Value(-range=>[1,1000,1,1], -join=>1)
  Bool_t        bAutoRedraw;    // X{GS} 7 Bool()
  Int_t		mWidth;         // X{gS} Ray{Resize} 7 Value(-range=>[0,4096,1], -join=>1)
  Int_t		mHeight;        // X{gS} Ray{Resize} 7 Value(-range=>[0,4096,1])
  ZColor	mClearColor;	// X{PRGS} 7 ColorButt()

  // CameraInfo.
  ZLink<ZNode>	mCameraBase;	// X{gE} L{}

  ZLink<ZNode>	mLookAt;	// X{gE} L{}
  Float_t	mLookAtMinDist; // X{gS} 7 Value(-range=>[0,1000,1,1000])

  ZLink<ZNode>	mUpReference;	// X{gE} L{}
  UChar_t	mUpRefAxis;	// X{gS} 7 Value(-range=>[1,3,1,1], -join=>1)
  Bool_t	bUpRefLockDir;	// X{gS} 7 Bool()
  Float_t	mUpRefMinAngle;	// X{gS} 7 Value(-range=>[0,90,1,100])

  Projection_e	mProjMode;	// X{GS} 7 PhonyEnum()
  Float_t	mZFov;		// X{gS} 7 Value(-width=>6, -range=>[1e-6,180,  1,1000], -join=>1)
  Float_t	mZSize;		// X{gS} 7 Value(-width=>6, -range=>[1e-6,1000, 1,1000])
  Float_t	mYFac;		// X{gS} 7 Value(-width=>6, -range=>[1e-6,1000, 1,1000], -join=>1)
  Float_t	mXDist;		// X{gS} 7 Value(-width=>6, -range=>[1e-6,1000, 1,1000])
  Float_t	mNearClip;	// X{gS} 7 Value(-width=>6, -range=>[0,100000,1,1000],-join=>1)
  Float_t	mFarClip;	// X{gS} 7 Value(-width=>6, -range=>[0,100000,1,1000])
  Float_t	mZoomFac;       // X{gS} 7 Value(-width=>6, -range=>[1,2,1,10000])
  Float_t   	mDefZFov;	// X{gS}
  Float_t   	mDefZSize;	// X{gS}
  Float_t       mMinZFov;	// X{gS}
  Float_t       mMaxZFov;	// X{gS}

  // Basic rendering options.
  Int_t		mFrontMode;	// X{gS} 7 PhonyEnum(-vals=>[GL_POINT,Point, GL_LINE,Line, GL_FILL,Fill],-width=>6,-join=>1)
  Int_t		mBackMode;	// X{gS} 7 PhonyEnum(-vals=>[GL_POINT,Point, GL_LINE,Line, GL_FILL,Fill],-width=>6)
  Bool_t	bLiMo2Side;	// X{gS} 7 Bool(-join=>1)
  Bool_t	bBlend;		// X{gS} 7 Bool()

  // User interaction and feedback.
  Float_t	mMSRotFac;	// X{gS} 7 Value(-range=>[-1000,1000,1,100], -join=>1)
  Float_t	mMSMoveFac;	// X{gS} 7 Value(-range=>[-1000,1000,1,100])
  Float_t	mMoveOM;	// X{gS} 7 Value(-range=>[-30,30,1,100], -join=>1)
  Float_t	mAccelExp;	// X{gS} 7 Value(-range=>[-10,10,1,1000])

  Float_t	mCHSize;	// X{GS} 7 Value(-range=>[0,1,  1,1000], -width=>4, -join=>1)
  Float_t       mMPSize;        // X{GS} 7 Value(-range=>[0,1,  1,1000], -width=>4)
  Float_t       mHomeAnimTime;  // X{GS} 7 Value(-range=>[0,10, 1,1000])

  Bool_t	bShowRPS;	// X{gS} 7 Bool(-join=>1)
  Bool_t	bShowView;	// X{gS} 7 Bool(-join=>1)
  Bool_t	bRnrNames;	// X{gS} 7 Bool()
  Bool_t	bRnrFakeOverlayInCapture; // X{GS} 7 Bool()

  UInt_t	mBuffSize;	// X{gS} 7 Value(-range=>[0,65535,1])
  Int_t		mPickR;		// X{gS} 7 Value(-range=>[0,100,1],-join=>1)
  UChar_t       mPickDisp;      // X{gS} 7 PhonyEnum(-vals=>[0,Default, 1,"Z-distance", 2,"Z-percentage"], -width=>9, -join=>1)
  Int_t         mPickMaxN;      // X{GS} 7 Value(-range=>[1,100,1])

  Int_t		mPopupDx;	// X{GS} 7 Value(-range=>[-2000,2000,1,1], -join=>1)
  Int_t		mPopupDy;	// X{GS} 7 Value(-range=>[-2000,2000,1,1])
  Float_t	mPopupFx;	// X{GS} 7 Value(-range=>[-10,10,1,10], -join=>1)
  Float_t	mPopupFy;	// X{GS} 7 Value(-range=>[-10,10,1,10])

  ZLink<ZGlass> mOverlay;       // X{GS} L{f}
  FID_t         mOverlay_fid;   //!

  ZLink<ZGlass> mEventHandler;     // X{GS} L{f}
  FID_t         mEventHandler_fid; //!

  Bool_t        bAllowHandlerSwitchInPupil; // X{GS} 7 Bool()

  Bool_t        bStereo;               // X{GS}
  Double_t      mStereoZeroParallax;   // X{GS} 7 Value(-range=>[-1,1, 1,1000])
  Double_t      mStereoEyeOffsetFac;   // X{GS} 7 Value(-range=>[ 0,2, 1,1000])
  Double_t      mStereoFrustumAsymFac; // X{GS} 7 Value(-range=>[ 0,2, 1,1000])

  // Locals where GL renderer stores actual parameters used for last render.
  // Protect with a lock?
  // Should this be passed in some struct when in event-handling?
  // Store last / current with a lock?
  ZTrans*  mRnrCamFix;   //! X{G}
  Int_t    mRnrScreenW;  //! X{G}
  Int_t    mRnrScreenH;  //! X{G}

  Int_t    mMouseX;      //! X{G}
  Int_t    mMouseY;      //! X{G}
  Int_t    mMouseDragDX; //! X{G}
  Int_t    mMouseDragDY; //! X{G}
  ZPoint   mMouseRayPos; //! X{R}
  ZPoint   mMouseRayDir; //! X{R}

  // Direct dump hack.
  GCondition mDirectDumpCond; //!
  // Could have max wait time.

public:
  PupilInfo(const Text_t* n="PupilInfo", const Text_t* t=0) :
    SubShellInfo(n,t) { _init(); }

  void SetCameraBase(ZNode* camerabase);
  void SetLookAt(ZNode* lookat);
  void SetUpReference(ZNode* upreference);

  void ImportCameraInfo(CameraInfo* cam_info); // X{E} C{1} 7 MCWButt()

  void SmoothCameraHome(ZNode* new_base=0);    // X{E} C{1} 7 MCWButt()

  void Zoom(Float_t delta);       // X{E}
  void ZoomFac(Float_t fac);      // X{E}
  void Home(Bool_t smooth=false); // X{E}

  void SetupZFov (Float_t zfov);
  void SetupZSize(Float_t zsize);

  ZTrans* ToPupilFrame(ZNode* node);
  ZTrans* ToCameraFrame(ZNode* node);

  Bool_t  TransformMouseRayVectors(ZNode* ref, ZPoint& pos, ZPoint& dir);

  void EmitResizeRay();           // X{E} 7 MButt(-join=>1)
  void EmitCameraHomeRay();       // X{E} 7 MButt()
  void EmitSmoothCameraHomeRay(); // X{E} 7 MButt()

  void EmitRedrawRay(Bool_t signal_p=false);
  void EmitDumpImageRay(const TString& filename, Int_t n_tiles=1,
                        Bool_t copy_p=false, Bool_t signal_p=false);

  void Redraw();                                  // X{E} 7 MButt(-join=>1)
  void RedrawWaitSignal();

  void DumpImage(const TString& filename="screenshot", Int_t n_tiles=1,
                 Bool_t copy_p=false);            // X{E} 7 MCWButt()
  void DumpImageWaitSignal(const TString& filename="screenshot", Int_t n_tiles=1,
                           Bool_t copy_p=false);

  void ReceiveDumpFinishedSignal();

  static Bool_t sStereoDefault;

#include "PupilInfo.h7"
  ClassDef(PupilInfo, 1);
}; // endclass PupilInfo


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