📄 text3dview.cpp
字号:
// Text3DView.cpp : implementation of the CText3DView class
//
#include "stdafx.h"
#include "Text3D.h"
#include "Text3DDoc.h"
#include "Text3DView.h"
//wb add down
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifndef WIN32
#include <unistd.h>
#endif
typedef enum {RESERVED, M_SIDE, M_EDGE, M_WHOLE, O_SIDE, O_EDGE, O_WHOLE,
T_SIDE, T_EDGE, T_WHOLE, H_SIDE, H_EDGE, H_WHOLE,REPEAT_SIDE, REPEAT_EDGE, REPEAT1,
REPEAT2_SIDE, REPEAT2_EDGE,REPEAT2, REPEAT3_SIDE, REPEAT3_EDGE,REPEAT3,
REPEAT4_SIDE, REPEAT4_EDGE,REPEAT4} displayLists;
GLfloat sideColor[] = {0.0, 0.0, 0.5, 1.0};
GLfloat edgeColor[] = {0.7, 0.7, 0.0, 1.0};
GLfloat shininess[] = {128.0};
GLfloat mat_specular[] = {0.7, 0.7, 0.7, 1.0};
GLfloat width = 0.0;
GLfloat width2 = 2.0;
GLfloat letterM[][3] =
{
{-3.125000, 0.000000, 0.000000},
{-3.125000, 6.208000, 0.000000},
{-1.233000, 6.208000, 0.000000},
{0.003000, 1.484000, 0.000000},
{1.223000, 6.208000, 0.000000},
{3.123000, 6.208000, 0.000000},
{3.123000, 0.000000, 0.000000},
{1.923000, 0.000000, 0.000000},
{1.923000, 5.010000, 0.000000},
{0.659000, 0.000000, 0.000000},
{-0.649000, 0.000000, 0.000000},
{-1.925000, 5.010000, 0.000000},
{-1.925000, 0.000000, 0.000000}
};
GLfloat letterO[][3] =
{
{-3.038000, 3.102000, 0.000000},
{-2.974000, 3.874000, 0.000000},
{-2.827000, 4.440000, 0.000000},
{-2.802000, 4.508000, 0.000000},
{-2.544000, 5.042000, 0.000000},
{-2.502000, 5.110000, 0.000000},
{-2.223000, 5.479000, 0.000000},
{-2.132000, 5.576000, 0.000000},
{-1.784000, 5.869000, 0.000000},
{-1.678000, 5.940000, 0.000000},
{-1.260000, 6.155000, 0.000000},
{-1.148000, 6.198000, 0.000000},
{-0.677000, 6.321000, 0.000000},
{-0.638000, 6.328000, 0.000000},
{-0.002000, 6.378000, 0.000000},
{0.634000, 6.328000, 0.000000},
{1.107000, 6.210000, 0.000000},
{1.144000, 6.198000, 0.000000},
{1.570000, 6.002000, 0.000000},
{1.674000, 5.940000, 0.000000},
{2.038000, 5.661000, 0.000000},
{2.128000, 5.576000, 0.000000},
{2.428000, 5.217000, 0.000000},
{2.504000, 5.104000, 0.000000},
{2.762000, 4.598000, 0.000000},
{2.798000, 4.508000, 0.000000},
{2.960000, 3.913000, 0.000000},
{2.970000, 3.862000, 0.000000},
{3.034000, 3.102000, 0.000000},
{2.970000, 2.342000, 0.000000},
{2.815000, 1.745000, 0.000000},
{2.798000, 1.696000, 0.000000},
{2.554000, 1.182000, 0.000000},
{2.504000, 1.100000, 0.000000},
{2.221000, 0.726000, 0.000000},
{2.128000, 0.628000, 0.000000},
{1.776000, 0.332000, 0.000000},
{1.674000, 0.264000, 0.000000},
{1.256000, 0.049000, 0.000000},
{1.144000, 0.006000, 0.000000},
{0.672000, -0.117000, 0.000000},
{0.634000, -0.124000, 0.000000},
{-0.002000, -0.174000, 0.000000},
{-0.638000, -0.124000, 0.000000},
{-1.112000, -0.006000, 0.000000},
{-1.148000, 0.006000, 0.000000},
{-1.576000, 0.202000, 0.000000},
{-1.678000, 0.264000, 0.000000},
{-2.041000, 0.540000, 0.000000},
{-2.132000, 0.628000, 0.000000},
{-2.430000, 0.983000, 0.000000},
{-2.502000, 1.094000, 0.000000},
{-2.773000, 1.622000, 0.000000},
{-2.802000, 1.696000, 0.000000},
{-2.962000, 2.258000, 0.000000},
{-2.974000, 2.330000, 0.000000},
{-1.736000, 3.102000, 10000.0},
{-1.710000, 3.578000, 0.000000},
{-1.644000, 3.934000, 0.000000},
{-1.503000, 4.328000, 0.000000},
{-1.494000, 4.346000, 0.000000},
{-1.352000, 4.593000, 0.000000},
{-1.306000, 4.656000, 0.000000},
{-1.120000, 4.857000, 0.000000},
{-1.040000, 4.926000, 0.000000},
{-0.825000, 5.067000, 0.000000},
{-0.726000, 5.116000, 0.000000},
{-0.480000, 5.200000, 0.000000},
{-0.402000, 5.218000, 0.000000},
{-0.041000, 5.257000, 0.000000},
{-0.002000, 5.258000, 0.000000},
{0.361000, 5.227000, 0.000000},
{0.400000, 5.220000, 0.000000},
{0.650000, 5.147000, 0.000000},
{0.726000, 5.116000, 0.000000},
{0.950000, 4.990000, 0.000000},
{1.038000, 4.926000, 0.000000},
{1.239000, 4.736000, 0.000000},
{1.306000, 4.656000, 0.000000},
{1.462000, 4.413000, 0.000000},
{1.498000, 4.342000, 0.000000},
{1.635000, 3.964000, 0.000000},
{1.644000, 3.934000, 0.000000},
{1.710000, 3.568000, 0.000000},
{1.736000, 3.102000, 0.000000},
{1.710000, 2.636000, 0.000000},
{1.642000, 2.268000, 0.000000},
{1.508000, 1.886000, 0.000000},
{1.496000, 1.860000, 0.000000},
{1.351000, 1.610000, 0.000000},
{1.304000, 1.546000, 0.000000},
{1.115000, 1.343000, 0.000000},
{1.036000, 1.276000, 0.000000},
{0.823000, 1.135000, 0.000000},
{0.724000, 1.086000, 0.000000},
{0.480000, 1.001000, 0.000000},
{0.400000, 0.984000, 0.000000},
{0.035000, 0.946000, 0.000000},
{-0.002000, 0.946000, 0.000000},
{-0.368000, 0.979000, 0.000000},
{-0.402000, 0.986000, 0.000000},
{-0.653000, 1.057000, 0.000000},
{-0.726000, 1.088000, 0.000000},
{-0.952000, 1.213000, 0.000000},
{-1.040000, 1.278000, 0.000000},
{-1.240000, 1.467000, 0.000000},
{-1.306000, 1.548000, 0.000000},
{-1.460000, 1.788000, 0.000000},
{-1.494000, 1.858000, 0.000000},
{-1.639000, 2.251000, 0.000000},
{-1.644000, 2.270000, 0.000000},
{-1.710000, 2.626000, 0.000000}
};
GLfloat letterT[][3] =
{
{-0.640000, 0.000000, 0.000000},
{-0.640000, 5.104000, 0.000000},
{-2.476000, 5.104000, 0.000000},
{-2.476000, 6.208000, 0.000000},
{2.476000, 6.208000, 0.000000},
{2.476000, 5.104000, 0.000000},
{0.640000, 5.104000, 0.000000},
{0.640000, 0.000000, 0.000000}
};
GLfloat letterH[][3] =
{
{-2.570000, 0.000000, 0.000000},
{-2.570000, 6.208000, 0.000000},
{-1.282000, 6.208000, 0.000000},
{-1.282000, 3.900000, 0.000000},
{1.280000, 3.900000, 0.000000},
{1.280000, 6.208000, 0.000000},
{2.568000, 6.208000, 0.000000},
{2.568000, 0.000000, 0.000000},
{1.280000, 0.000000, 0.000000},
{1.280000, 2.760000, 0.000000},
{-1.282000, 2.760000, 0.000000},
{-1.282000, 0.000000, 0.000000}
};
static void checkErrors(void)
{
GLenum error;
while ((error = glGetError()) != GL_NO_ERROR) {
fprintf(stderr, "Error: %s\n", (char *) gluErrorString(error));
}
}
void repeat(int j)
{
if(j == 2){
glPushMatrix();
glTranslatef((31 * -0.34) , 9.3, -9.6);
glCallList(REPEAT1);
glPopMatrix();
}
if(j == 3){
glPushMatrix();
glTranslatef(31 * -0.34, 9.3, -9.6);
glCallList(REPEAT1);
glPopMatrix();
glPushMatrix();
glTranslatef(31 * -.09, 9.3, -9.6);
glCallList(REPEAT2);
glPopMatrix();
}
if(j == 4){
glPushMatrix();
glTranslatef(31 * -0.34, 9.3, -9.6);
glCallList(REPEAT1);
glPopMatrix();
glPushMatrix();
glTranslatef(31 * -.09, 9.3, -9.6);
glCallList(REPEAT2);
glPopMatrix();
glPushMatrix();
glTranslatef(31 * 0.12, 9.3, -9.6);
glCallList(REPEAT3);
glPopMatrix();
}
}
//wb add up
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CText3DView
IMPLEMENT_DYNCREATE(CText3DView, CView)
BEGIN_MESSAGE_MAP(CText3DView, CView)
//{{AFX_MSG_MAP(CText3DView)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_ERASEBKGND()
ON_WM_SIZE()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CText3DView construction/destruction
CText3DView::CText3DView()
{
//add down
m_pDC = NULL;
//add up
}
CText3DView::~CText3DView()
{
}
BOOL CText3DView::PreCreateWindow(CREATESTRUCT& cs)
{
//add down
cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
//add up
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CText3DView drawing
void CText3DView::OnDraw(CDC* pDC)
{
CText3DDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//add down
DrawScene();
//add up
}
/////////////////////////////////////////////////////////////////////////////
// CText3DView printing
BOOL CText3DView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CText3DView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CText3DView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CText3DView diagnostics
#ifdef _DEBUG
void CText3DView::AssertValid() const
{
CView::AssertValid();
}
void CText3DView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CText3DDoc* CText3DView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CText3DDoc)));
return (CText3DDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CText3DView message handlers
int CText3DView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -