|
//############################################################################
// Author: Sharjith Nair
// Email: sharjith_ssn@hotmail.com
// Program: OpenGL, C++ MFC StereoLithography Data File Viewer Application
// Important Notice:
// This Idea and the Application is Copyright(c) Sharjith Nair 2002, 2003.
// You can freely use it as long as you credit me for it.
// No guarantee/warranty is given on this app and I will not be responsible
// for any damage to you, your property or any other person from using it.
// USE IT ON YOUR OWN RISK.
// Thankyou
// Sharjith Nair.
//#############################################################################
#if !defined(AFX_GLVIEW_H__859711F8_BE5E_4EFB_9EAB_84708FB5E343__INCLUDED_)
#define AFX_GLVIEW_H__859711F8_BE5E_4EFB_9EAB_84708FB5E343__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GLView.h : header file
//
#include "GLDisplayContext.h"
#include "GLObject.h"
#include "GLTrihedron.h"
#include "Point3D.h"
#define NUM_COLORS (sizeof(colorv) / sizeof(colorv[0]))
/////////////////////////////////////////////////////////////////////////////
// CGLView view
class CGLDisplayContext;
class CGLView
{
public:
CGLView(CWnd* pWnd, CGLDisplayContext* aContext, const double& range = 100);
~CGLView();
// Attributes
public:
HGLRC m_hRC; // Rendering Context
HDC m_hDC; // Device Context
CPalette m_GLPalette; // Logical Palette
HPALETTE m_hPalette,
m_hPalette2;
private:
GLdouble nRange;
GLdouble xRot;
GLdouble yRot;
GLdouble zRot;
GLdouble xTrans;
GLdouble yTrans;
GLdouble zTrans;
GLfloat m_bkRed;
GLfloat m_bkGreen;
GLfloat m_bkBlue;
GLDisplayMode displayMode;
bool m_antialias;
CGLTrihedron *myTrihedron;
// Color Indexes
struct colorIndexState
{
GLfloat amb[3]; /* ambient color / bottom of ramp */
GLfloat diff[3]; /* diffuse color / middle of ramp */
GLfloat spec[3]; /* specular color / top of ramp */
GLfloat ratio; /* ratio of diffuse to specular in ramp */
GLint indexes[3]; /* where ramp was placed in palette */
};
colorIndexState colorv[3];
CPoint DownPoint;
bool ZoomON;
bool PanON;
bool RotON;
bool gridOn;
// Operations
public:
void InitGL();
BOOL EnableRC(HDC m_hDC, HGLRC m_hRC, BOOL bEnable);
void RenderScene(GLenum mode);
void InitializePalette(void);
void ZoomView(CPoint, CPoint);
void PanView(CPoint, CPoint);
void RotateView(CPoint, CPoint);
void StopZooming(){ ZoomON = false; }
void StopPanning(){ PanON = false; }
void StopRotation(){ RotON = false; }
void TopView();
void BottomView();
void FrontView();
void BackView();
void LeftView();
void RightView();
void AxonView();
void FitAll();
void ZoomWindow(CRect zcRect);
void ResetView();
void PointToScreen(const CPoint3D& P, int& x, int& y);
void ScreenToPoint(const int& x, const int& y, CPoint3D& P);
void FitView();
void Fit3d(CRect zcRect);
void SetBackgroundColor(GLfloat, GLfloat, GLfloat);
void SetDisplayMode(const GLDisplayMode& aMode);
void SetAntiAliasing(const bool& mode);
void Select(const int& x, const int& y);
void MultiSelect(const int& x, const int& y);
void SweepSelect(const CRect& swRect);
int ProcessSelection(const int& x, const int& y, const int& sensitivity = 5);
int ProcessSweepSelection(const CRect& rect, unsigned long int* id);
virtual void Draw();
void ReSize(int cx, int cy);
void Refresh();
BOOL QueryNewPalette();
void PaletteChanged();
private:
CWnd* ptrWnd;
CGLDisplayContext* theContext;
};
#endif // !defined(AFX_GLVIEW_H__859711F8_BE5E_4EFB_9EAB_84708FB5E343__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.