📄 contourgldoc.cpp
字号:
// ContourGLDoc.cpp : implementation of the CContourGLDoc class
//
#include "stdafx.h"
#include "Contour.h"
#include "ContourGL.h"
#include "ContourGLDoc.h"
#ifdef LINE
#undef LINE
#endif
#define LINE(a,b,c,d) line2(a,b,c,d)
void line2(double x1, double y1, double x2, double y2)
{
glColor3f(0,0,0);
glBegin(GL_LINES);
glVertex2d(x1,y1);
glVertex2d(x2,y2);
glEnd();
}
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CContourGLDoc
IMPLEMENT_DYNCREATE(CContourGLDoc, CDocument)
BEGIN_MESSAGE_MAP(CContourGLDoc, CDocument)
//{{AFX_MSG_MAP(CContourGLDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CContourGLDoc construction/destruction
CContourGLDoc::CContourGLDoc()
{
// TODO: add one-time construction code here
}
CContourGLDoc::~CContourGLDoc()
{
}
BOOL CContourGLDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CContourGLDoc serialization
void CContourGLDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CContourGLDoc diagnostics
#ifdef _DEBUG
void CContourGLDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CContourGLDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CContourGLDoc commands
void CContourGLDoc::Draw()
{
// Plot data
// Uncomment this line to try CGLContour plotting
// m_glContour.Generate();
// Plotting strip generated by CLineStripList
// generating info
m_listContour.Generate();
// draw line strips
CLineStripList* pStripList;
CLineStrip* pStrip;
int i,index;
CLineStripList::iterator pos;
CLineStrip::iterator pos2;
double pLimits[4];
double x,y;
m_listContour.GetLimits(pLimits);
for (i=0;i<m_listContour.GetNPlanes();i++)
{
pStripList=m_listContour.GetLines(i);
ASSERT(pStripList);
for (pos=pStripList->begin(); pos != pStripList->end() ; pos++)
{
pStrip=(*pos);
ASSERT(pStrip);
if (pStrip->empty())
continue;
// putting point at start and end of strip
glBegin(GL_POINTS);
glColor4f(1,0,0,.8f);
// retreiving index
index=pStrip->front();
// drawing
x=m_listContour.GetXi(index);
y=m_listContour.GetYi(index);
glVertex2f((GLfloat)(pLimits[0]+x),(GLfloat)(pLimits[2]+y));
// retreiving index
glColor4f(0,0,1,.8f);
index=pStrip->back();
// drawing
x=m_listContour.GetXi(index);
y=m_listContour.GetYi(index);
glVertex2f((GLfloat)(pLimits[0]+x),(GLfloat)(pLimits[2]+y));
glEnd();
glColor3f(i/(float)m_listContour.GetNPlanes(),
i/(float)m_listContour.GetNPlanes(),
1.f-i/(float)m_listContour.GetNPlanes());
glBegin(GL_LINE_STRIP);
for (pos2=pStrip->begin(); pos2 != pStrip->end() ; pos2++)
{
// retreiving index
index=(*pos2);
// drawing
x=m_listContour.GetXi(index);
y=m_listContour.GetYi(index);
glVertex2f((GLfloat)(pLimits[0]+x),(GLfloat)(pLimits[2]+y));
}
glEnd();
}
}
}
void CContourGLDoc::GetGLLimits(double pLimits[])
{
// drawing
m_glContour.GetLimits(pLimits);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -