// $Source: /usr/local/SimSoft/SoftShop/XGraph/Views/OGLCam.h,v $
// $Revision: 1.19 $
// $Author: baum $
// $Date: 2001/11/29 15:52:24 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-20 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: OGLCam.h,v $
// Revision 1.19  2001/11/29 15:52:24  baum
// -In Kalender.cpp und Kalender.h Handsteuerung eingebaut
//

#ifndef _OGLCAMERA_H
#define _OGLCAMERA_H 1

#include "GL/gl.h"

#include "Vec3D.h"
#include "HMatrx3D.h"
#include "Angle.h"

#ifndef _GEOOBJECT_H
class GeoObject;
#endif

#ifdef _OGLCAMERA_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_VIEWS_DLL
#  undef _impexp
#  define _impexp
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUG__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif

//==================================================================
//		Class-Header
//		for class ViewPoint
//==================================================================

//##ModelId=4030D771006D
class _impexp ViewPoint {
  public:
    // default constructor
	//##ModelId=4030D771006E
    ViewPoint ();

    // constructor
	//##ModelId=4030D771006F
    ViewPoint (const Vec3D& cameraPos, const Vec3D& focus,
               const Vec3D& cameraUp);

    // copy constructor
	//##ModelId=4030D771007F
    ViewPoint (const ViewPoint&);

    // destructor
	//##ModelId=4030D7710081
    ~ViewPoint ();

    // assignment operator
	//##ModelId=4030D7710082
    ViewPoint& operator = (const ViewPoint&);

	//##ModelId=4030D771008D
    const Vec3D&   CameraPos () const;
	//##ModelId=4030D771008F
    const Vec3D&   Focus     () const;
	//##ModelId=4030D7710091
    const Vec3D&   CameraUp  () const;
	//##ModelId=4030D771009D
    Vec3D          ViewDir   () const;

  private:
	//##ModelId=4030D77100A0
    Vec3D   ObjEyePos;     // default: Vec3D (0,0,1)
	//##ModelId=4030D77100AC
    Vec3D   ObjViewCenter; // default: Vec3D (0,0,0)
	//##ModelId=4030D77100B1
    Vec3D   ObjViewUp;     // default: Vec3D (0,1,0)

  //friends
    friend class OGLCamera;
};

//==================================================================
//		Class-Header
//		for class OGLCamera
//==================================================================

//##ModelId=4030D7710167
class _impexp OGLCamera {
  public:
    // constructor
	//##ModelId=4030D7710177
    OGLCamera(const Vec3D& cameraPos, const Vec3D& focus, const Vec3D& cameraUp);
  
    // destructor
	//##ModelId=4030D7710186
    virtual ~OGLCamera();

    // manipulate the projection matrix
    // this is the default!!
	//##ModelId=4030D7710188
    void setToPerspectiveProj ();
	//##ModelId=4030D7710189
    void setToOrthogonalProj  ();
	//##ModelId=4030D771018A
    bool isOrthogonalProj     () const;

    // this is default behaviour
	//##ModelId=4030D7710196
    void setToGlobal ();

    // now it moves with an GeoObject!!
	//##ModelId=4030D7710197
    void setToLocal (const GeoObject *camObject);

    // define new Pos and View for Camera (as global)
	//##ModelId=4030D7710199
    void setCamera (const Vec3D& cameraPos, const Vec3D& focus, const Vec3D& cameraUp);
	//##ModelId=4030D77101A7
    void setCamera (const ViewPoint& newViewPos);

    // manipulate the camera
    // depending on the behaviour (global or local)
  
    // move Camera in the viewingplane 
	//##ModelId=4030D77101A9
    void move   (const Vec3D& moveVec);

    // zoom Camera away or to the Model
	//##ModelId=4030D77101B5
    void zoom   (const double& zoomVal);

    // walk with Camera
	//##ModelId=4030D77101B7
    void walk   (const double& walkVal);

    // rotate camera around Focus of View
	//##ModelId=4030D77101B9
    void rotateFocus  (const Angle& viewDirAngle, const Angle& viewUpAngle);

    // rotate Camera around local origin
	//##ModelId=4030D77101C7
    void rotateCamera (const Angle& viewDirAngle, const Angle& viewUpAngle);

    // detail-information about actual ViewPoint
	//##ModelId=4030D77101CA
    const ViewPoint& ActualViewPoint () const;
	//##ModelId=4030D77101D4
    const Vec3D&     CameraPos       () const;
	//##ModelId=4030D77101D6
    const Vec3D&     Focus           () const;
	//##ModelId=4030D77101D8
    const Vec3D&     CameraUp        () const;
	//##ModelId=4030D77101DA
    Vec3D            ViewDir         () const;
	//##ModelId=4030D77101E5
    GeoObject*       CameraObject    () const;
  
    // transform Camera for OpenGL
	//##ModelId=4030D77101E7
    void OGLModelView  ();
	//##ModelId=4030D77101E8
    const HMatrx3D& ModelViewMatrix  () const;

	//##ModelId=4030D77101EA
    void OGLProjection ();
	//##ModelId=4030D77101F4
    const HMatrx3D& ProjectionMatrix () const;

	//##ModelId=4030D77101F6
    void OGLSelection  (GLint posX, GLint posY, GLint width, GLint height);

	//##ModelId=4030D7710204
    void setPerspective (const double& newVisualAngle,  unsigned width, unsigned height,
                         const double& newNearClipDist, const double& newFarClipDist);

	//##ModelId=4030D7710213
    const double& VisualAngle     () const;
	//##ModelId=4030D7710215
    const double& setVisualAngle  (const double& newVisualAngle);

	//##ModelId=4030D7710217
    const double& AspectRatio     () const;
	//##ModelId=4030D7710219
    const double& setAspectRatio  (unsigned width, unsigned height);

	//##ModelId=4030D7710224
    const double& NearClipDist    () const;
	//##ModelId=4030D7710226
    const double& setNearClipDist (const double& newNearClipDist);

	//##ModelId=4030D7710232
    const double& FarClipDist     () const;
	//##ModelId=4030D7710234
    const double& setFarClipDist  (const double& newFarClipDist);

    // getting global vector out of ViewPlane-Pixels
	//##ModelId=4030D7710236
    Vec3D VectorFromPixels   (int x, int y);
	//##ModelId=4030D7710242
    Vec3D PositionFromPixels (int x, int y);

  private:
    // copy constructor declared, but not defined
	//##ModelId=4030D7710245
    OGLCamera (const OGLCamera&);

    // assignment operator declared, but not defined
	//##ModelId=4030D7710247
    OGLCamera& operator = (const OGLCamera&);

	//##ModelId=4030D7710253
    GeoObject *ObjCamObj;
  
	//##ModelId=4030D7710262
    ViewPoint ObjVPLocal;
	//##ModelId=4030D7710267
    ViewPoint ObjVP;

	//##ModelId=4030D7710273
    bool ObjIsOrtho;

	//##ModelId=4030D7710280
    double ObjFieldOfView;
	//##ModelId=4030D7710281
    double ObjOrtho;
	//##ModelId=4030D7710290
    double ObjAspect;
	//##ModelId=4030D7710291
    double ObjNearClip;
	//##ModelId=4030D771029F
    double ObjFarClip;

	//##ModelId=4030D77102A1
    GLint   ObjViewPort[4];

	//##ModelId=4030D77102B0
    HMatrx3D ObjProjection;
	//##ModelId=4030D77102C0
    HMatrx3D ObjModelview;

	//##ModelId=4030D77102C4
    void calcViewUp    ();
	//##ModelId=4030D77102C5
    void calcForLocal  ();
	//##ModelId=4030D77102CE
    void calcModelview ();

	//##ModelId=4030D77102F0
  typedef void (ProjectionFunc) (OGLCamera *who);
	//##ModelId=4030D77102D0
    ProjectionFunc *ObjProjectionFunc;

	//##ModelId=4030D77102DE
    static void calcPerspectiveProjection (OGLCamera *who);
	//##ModelId=4030D77102E1
    static void calcOrthogonalProjection  (OGLCamera *who);


};

#endif // !_OGLCAMERA_H


