⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gxb_3041222098view.cpp

📁 zuoye j kjaflk jlka jlk j
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// gxb_3041222098View.cpp : implementation of the CGxb_3041222098View class
//

#include "stdafx.h"
#include "gxb_3041222098.h"

#include "gxb_3041222098Doc.h"
#include "gxb_3041222098View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGxb_3041222098View

IMPLEMENT_DYNCREATE(CGxb_3041222098View, CView)

BEGIN_MESSAGE_MAP(CGxb_3041222098View, CView)
	//{{AFX_MSG_MAP(CGxb_3041222098View)
	ON_WM_CREATE()
	ON_WM_DESTROY()
	ON_WM_ERASEBKGND()
	ON_WM_KEYDOWN()
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEWHEEL()
	ON_WM_RBUTTONDOWN()
	ON_WM_SIZE()
	ON_WM_TIMER()
	ON_COMMAND(ID_ch_ch1, Onchch1)
	ON_COMMAND(ID_ch_ch2, Onchch2)
	ON_COMMAND(ID_ch_ch3, Onchch3)
	ON_COMMAND(ID_ch_ch4, Onchch4)
	ON_COMMAND(ID_ch_ch5, Onchch5)
	ON_COMMAND(ID_ch_ch6, Onchch6)
	ON_COMMAND(ID_ch_ch7, Onchch7)
	ON_COMMAND(ID_ch_ch8, Onchch8)
	ON_COMMAND(ID_ch_ch9, Onchch9)
	ON_COMMAND(ID_zft_zft, Onzftzft)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGxb_3041222098View construction/destruction

CGxb_3041222098View::CGxb_3041222098View()
{
	// TODO: add construction code here
    m_timer = 1;
	m_theta[0] = 0;
	m_theta[1] = 0;
	m_theta[2] = 0;

	m_axis = 1;

	viewer[0] = 0.0;
	viewer[1] = 0.0;
	viewer[2] = 3.0;
        
	m_vertices[0][0]=-1;m_vertices[0][1]=-1;m_vertices[0][2]= 1;
	m_vertices[1][0]=-1;m_vertices[1][1]= 1;m_vertices[1][2]= 1;
	m_vertices[2][0]= 1;m_vertices[2][1]= 1;m_vertices[2][2]= 1;
	m_vertices[3][0]= 1;m_vertices[3][1]=-1;m_vertices[3][2]= 1;
	m_vertices[4][0]=-1;m_vertices[4][1]=-1;m_vertices[4][2]=-1;
	m_vertices[5][0]=-1;m_vertices[5][1]= 1;m_vertices[5][2]=-1;
	m_vertices[6][0]= 1;m_vertices[6][1]= 1;m_vertices[6][2]=-1;
	m_vertices[7][0]= 1;m_vertices[7][1]=-1;m_vertices[7][2]=-1;

	m_colors[0][0]= 0;m_colors[0][1]= 0;m_colors[0][2]= 1;
	m_colors[1][0]= 0;m_colors[1][1]= 1;m_colors[1][2]= 1;
    m_colors[2][0]= 1;m_colors[2][1]= 1;m_colors[2][2]= 1;
	m_colors[3][0]= 1;m_colors[3][1]= 0;m_colors[3][2]= 1;
	m_colors[4][0]= 0;m_colors[4][1]= 0;m_colors[4][2]= 0;
	m_colors[5][0]= 0;m_colors[5][1]= 1;m_colors[5][2]= 0;
	m_colors[6][0]= 1;m_colors[6][1]= 1;m_colors[6][0]= 0;
	m_colors[7][0]= 1;m_colors[7][1]= 0;m_colors[7][2]= 0;
}

CGxb_3041222098View::~CGxb_3041222098View()
{
}

BOOL CGxb_3041222098View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
cs.style|= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CGxb_3041222098View drawing

void CGxb_3041222098View::OnDraw(CDC* pDC)
{
	CGxb_3041222098Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
DrawScene();
}

/////////////////////////////////////////////////////////////////////////////
// CGxb_3041222098View printing

BOOL CGxb_3041222098View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CGxb_3041222098View::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// TODO: add extra initializationbefore printing
	CView::OnBeginPrinting(pDC, pInfo);
}

void CGxb_3041222098View::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// TODO: add cleanup after printing
	CView::OnEndPrinting(pDC, pInfo);
}

/////////////////////////////////////////////////////////////////////////////
// CGxb_3041222098View diagnostics

#ifdef _DEBUG
void CGxb_3041222098View::AssertValid() const
{
	CView::AssertValid();
}

void CGxb_3041222098View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CGxb_3041222098Doc* CGxb_3041222098View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGxb_3041222098Doc)));
	return (CGxb_3041222098Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CGxb_3041222098View message handlers

int CGxb_3041222098View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	m_pDC = new CClientDC(this);	// get device context
	if( m_pDC == NULL )
	{
		::AfxMessageBox( "fail to get device context" );
		return FALSE;
	}

	if( !SetupPixelFormat() )	// setup pixel format
	{
		::AfxMessageBox( "SetupPixelFormat failed" );
		return FALSE;
	}
	
	// get rendering context
	if( ( m_hRC = wglCreateContext(m_pDC->GetSafeHdc()) ) == 0 )
	{
		::AfxMessageBox( "wglCreateContext failed" );
		return FALSE;
	}

	// make current rendering context
	if( wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC) == FALSE )
	{
		::AfxMessageBox( "wglMakeCurrent failed" );
		return FALSE;
	}
     KillTimer(m_timer);
	 SetTimer(m_timer,1,NULL);

	return 0;
}

void CGxb_3041222098View::OnDestroy() 
{
	CView::OnDestroy();
	
	// TODO: Add your message handler code here
	if( wglMakeCurrent(0,0)==FALSE)
		::AfxMessageBox("wglMakeCurrent failed");

	if(m_hRC && (wglDeleteContext(m_hRC)==FALSE))
		::AfxMessageBox("wglDeleteContext failed");

	if(m_pDC)
		delete m_pDC;
}

BOOL CGxb_3041222098View::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	
	return TRUE;
}

void CGxb_3041222098View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
		switch(nChar)
	{
	case 'X':
		m_axis = 0;
		break;
	case 'Y':
		m_axis = 1;
		break;
	case 'Z':
		m_axis = 2;
		break;
	case 'Q':
	case VK_ESCAPE:
	exit(1);

	if(nChar == VK_LEFT)
		viewer[0] -=0.5;
	if(nChar == VK_RIGHT)
		viewer[0] +=0.5;
	if(nChar == VK_DOWN)
		viewer[1] -=0.5;
	if(nChar == VK_UP)
		viewer[1] +=0.5;
	if(nChar == VK_HOME)
		viewer[2] -=0.5;
	if(nChar == VK_END)
		viewer[2] +=0.5;

	
	}
	CView::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CGxb_3041222098View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
		m_axis = 0;
	CView::OnLButtonDown(nFlags, point);
}

BOOL CGxb_3041222098View::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) 
{
	// TODO: Add your message handler code here and/or call default
		m_axis = 1;
	return CView::OnMouseWheel(nFlags, zDelta, pt);
}

void CGxb_3041222098View::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
		m_axis = 2;
	CView::OnRButtonDown(nFlags, point);
}

void CGxb_3041222098View::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glViewport(0,0,cx,cy);

    if(cx<=cy)
	    glOrtho(-2.0,2.0,-2.0*cy/cx,2.0*cy/cx,-20.0,20.0);
	else
        glOrtho(-2.0*cy/cx,2.0*cy/cx,-2.0,2.0,-20.0,20.0);
}

void CGxb_3041222098View::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(nIDEvent == m_timer)
	{
	  m_theta[m_axis] += 2.0;
	  if( m_theta[m_axis] > 360.0)
		  m_theta[m_axis] -=360.0;
	  Invalidate();
	}
	else
	CView::OnTimer(nIDEvent);
}

void CGxb_3041222098View::Onchch1() 
{
	// TODO: Add your command handler code here
	abc=2;
	DrawScene();
}

void CGxb_3041222098View::Onchch2() 
{
	// TODO: Add your command handler code here
	abc=3;
	DrawScene();
}

void CGxb_3041222098View::Onchch3() 
{
	// TODO: Add your command handler code here
		abc=4;
	DrawScene();
}

void CGxb_3041222098View::Onchch4() 
{
	// TODO: Add your command handler code here
	abc=5;
	DrawScene();
}

void CGxb_3041222098View::Onchch5() 
{
	// TODO: Add your command handler code here
	abc=5;
	DrawScene();
}

void CGxb_3041222098View::Onchch6() 
{
	// TODO: Add your command handler code here
	abc=7;
	DrawScene();
}

void CGxb_3041222098View::Onchch7() 
{
	// TODO: Add your command handler code here
	abc=8;
	DrawScene();
}

void CGxb_3041222098View::Onchch8() 
{
	// TODO: Add your command handler code here
		abc=9;
	DrawScene();
}

void CGxb_3041222098View::Onchch9() 
{
	// TODO: Add your command handler code here
		abc=9;
	DrawScene();
}

void CGxb_3041222098View::Onzftzft() 
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -