TridStereoGLFrame Class Reference

#include <TridStereoGLFrame.h>

Inheritance diagram for TridStereoGLFrame:

TridGLFrame GuiBase TridSketchList List of all members.

Public Member Functions

 TridStereoGLFrame (TridPage *tp, TGWindow &parent, TridControl *tc, double eyespace=1, const TridPOV &min=kTridPOV_DefaultRangeLow, const TridPOV &max=kTridPOV_DefaultRangeHigh)
virtual ~TridStereoGLFrame ()
virtual void Update ()
virtual void TransformToPOV ()
virtual void SetupProjection ()
virtual Bool_t HandleMotion (Event_t *ev)
virtual void SetEyespace (double eyespace)

Protected Attributes

double fEyeSpace
Int_t fWhichEye

Detailed Description

Definition at line 24 of file TridStereoGLFrame.h.


Constructor & Destructor Documentation

TridStereoGLFrame::TridStereoGLFrame ( TridPage tp,
TGWindow &  parent,
TridControl tc,
double  eyespace = 1,
const TridPOV min = kTridPOV_DefaultRangeLow,
const TridPOV max = kTridPOV_DefaultRangeHigh 
)

Definition at line 19 of file TridStereoGLFrame.cxx.

References fEyeSpace, and TridGLFrame::SetupOpenGL().

00024   : TridGLFrame( tp, parent, tc, min, max )
00025 {
00026   //
00027   // 'scale' is the way to scale OpenGL units to window size.  This is a course control,
00028   // overridden by the user.
00029   //
00030   // Min/max x/y are not limits for drawing, but rather limits to how far the POV center can be moved.
00031   // These should compare roughly with the drawable area.
00032   // 
00033   //
00034   fEyeSpace = eyespace;
00035 
00036   // Do my own setup.
00037   SetupOpenGL();
00038 
00039   cout << "TridStereoGLFrame constructor." << endl;
00040 }

TridStereoGLFrame::~TridStereoGLFrame (  )  [virtual]

Definition at line 43 of file TridStereoGLFrame.cxx.

00044 {
00045   cout << "TridStereoGLFrame destructor." << endl;
00046 }


Member Function Documentation

Bool_t TridStereoGLFrame::HandleMotion ( Event_t *  ev  )  [virtual]

Reimplemented from TridGLFrame.

Definition at line 49 of file TridStereoGLFrame.cxx.

References TridGLFrame::fButton, TridGLFrame::fButtonTraveled, TridGLFrame::fMouseLast_x, TridGLFrame::fMouseLast_y, and TridGLFrame::HandleMotion().

00050 {
00051   Int_t startx = fMouseLast_x;
00052   Int_t stopx  = ev->fX;
00053 
00054   Int_t starty = fMouseLast_y;
00055   Int_t stopy  = ev->fY;
00056 
00057   // Adjust for viewport.
00058   if(fMouseLast_x > (int)fWidth/2 ) {    
00059     startx = startx - fWidth/2;
00060     stopx  = stopx  - fWidth/2;
00061   } 
00062 
00063   TridGLFrame::HandleMotion(fButton, startx, starty, stopx, stopy);
00064 
00065   fButtonTraveled += abs(ev->fX - fMouseLast_x) + abs(ev->fY - fMouseLast_y);
00066 
00067   fMouseLast_x = ev->fX;
00068   fMouseLast_y = ev->fY;
00069 
00070   return true;
00071 }

virtual void TridStereoGLFrame::SetEyespace ( double  eyespace  )  [inline, virtual]

Reimplemented from TridGLFrame.

Definition at line 37 of file TridStereoGLFrame.h.

References fEyeSpace, Particle::Sign(), and Update().

00037 { fEyeSpace = TMath::Sign(eyespace,fEyeSpace); Update(); };

void TridStereoGLFrame::SetupProjection (  )  [virtual]

Reimplemented from TridGLFrame.

Definition at line 111 of file TridStereoGLFrame.cxx.

References TridGLFrame::fDrawContext.

00112 {
00113   // Adjust perspective for the true width.
00114   gluPerspective(30.0f,(GLfloat)fDrawContext->fWidth/2/(GLfloat)fDrawContext->fHeight,0.1f,100.0f);
00115 }

void TridStereoGLFrame::TransformToPOV (  )  [virtual]

Reimplemented from TridGLFrame.

Definition at line 118 of file TridStereoGLFrame.cxx.

References fEyeSpace, TridGLFrame::fPOV, fWhichEye, TridPOV::GetDist(), TridPOV::GetPhi(), TridPOV::GetTheta(), TridPOV::GetX(), TridPOV::GetY(), TridPOV::GetZ(), and TridGLFrame::NormalizeAndClipPOV().

Referenced by Update().

00119 {
00120   // Clip the POV so it conforms to limits.
00121   NormalizeAndClipPOV();
00122 
00123    // Need to manipulate the ModelView matrix to move our model around.
00124   glMatrixMode(GL_MODELVIEW);
00125   
00126   // Reset to 0,0,0; no rotation, no scaling.
00127   glLoadIdentity(); 
00128   
00129   // Pull back so we can look at it.
00130   glTranslatef(0.0f,0.0f,-fPOV.GetDist());
00131   
00132   // Add eyespace
00133   if(fWhichEye==0)
00134     glTranslatef(-fEyeSpace*0.5, 0.0f,0.0f);
00135   else
00136     glTranslatef( fEyeSpace*0.5, 0.0f,0.0f);
00137   
00138     
00139   // Rotate to our view.
00140   glRotatef(fPOV.GetTheta(),1.0f,0.0f,0.0f); // Rotate to elevation.
00141   if(fPOV.GetPhi()!=0)
00142     glRotatef(fPOV.GetPhi()  ,0.0f,1.0f,0.0f); // Rotate to side
00143   
00144   // Move to our viewpoint.
00145   glTranslatef(-fPOV.GetX(), -fPOV.GetY(), -fPOV.GetZ());  // Move to our viewpoint.
00146   
00147   TVector3 rightdir(-1,0,0); // If no rotation, right is -x
00148   rightdir.Rotate(-fPOV.GetPhi()*TMath::Pi()/180., // phi in radians. 
00149                    TVector3(0,1,0)); // Rotate about y axis
00150 
00151 }

void TridStereoGLFrame::Update (  )  [virtual]

Reimplemented from TridGLFrame.

Definition at line 76 of file TridStereoGLFrame.cxx.

References TridGLFrame::ClearViewport(), TridGLFrame::DrawHUD(), TridGLFrame::DrawObjects(), TridGLFrame::fDrawContext, TridGLFrame::fFrameTime, fWhichEye, TridGLFrame::SetupLighting(), TridGLFrame::SetupOptions(), TridGLFrame::SwapBuffers(), and TransformToPOV().

Referenced by SetEyespace().

00077 {
00078   // Clears and redraws the OpenGL viewport.
00079   struct timeval timestart,timeend;
00080   gettimeofday(&timestart,0);
00081 
00082   // Unsure that our window is the current one for OpenGL.
00083   // (This call must be atomic!)
00084   glXMakeCurrent(fDrawContext->fDisplay, fDrawContext->fWindow, fDrawContext->fglxContext);
00085   ClearViewport();      // Wipe blank. (Could be later, but we are double-buffering.)
00086  
00087   fWhichEye = 0;
00088   glViewport(0,0,fWidth/2,fHeight);
00089   TransformToPOV();     // Set the cmera in world coordinates
00090   SetupOptions();       // Change OpenGL options
00091   SetupLighting();      // Put in light sources
00092   DrawObjects();        // Draw the Sketches
00093   DrawHUD();            // Put on the overlay.
00094 
00095   fWhichEye = 1;
00096   glViewport(fWidth/2,0,fWidth/2,fHeight);
00097   TransformToPOV();     // Set the cmera in world coordinates
00098   SetupOptions();       // Change OpenGL options
00099   SetupLighting();      // Put in light sources
00100   DrawObjects();        // Draw the Sketches
00101   DrawHUD();            // Put on the overlay.
00102 
00103   glFlush();            // Send commands to X server
00104   SwapBuffers();
00105   gettimeofday(&timeend,0);
00106   
00107   fFrameTime = (timeend.tv_sec - timestart.tv_sec) +
00108     (timeend.tv_usec - timestart.tv_usec) * 0.000001;
00109 }


Member Data Documentation

double TridStereoGLFrame::fEyeSpace [protected]

Definition at line 37 of file TridStereoGLFrame.h.

Referenced by SetEyespace(), TransformToPOV(), and TridStereoGLFrame().

Int_t TridStereoGLFrame::fWhichEye [protected]

Definition at line 41 of file TridStereoGLFrame.h.

Referenced by TransformToPOV(), and Update().


The documentation for this class was generated from the following files:
Generated on Thu Apr 10 23:03:51 2014 for loon by  doxygen 1.4.7