📄 gaview.cpp
字号:
// GAView.cpp : implementation of the CGAView class
//
#include "stdafx.h"
#include "GA.h"
#include <math.h>
#include <stdio.h>
#include "GADoc.h"
#include "GAView.h"
#include <time.h>
#include <stdlib.h>
#include "dlgBackground.h"
#include "dlgFittingProcess.h"
#include "dlgPlotting.h"
#include "dlgKnot.h"
#include "dlgRMS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// global variable
/////////////////////////////////////////////////////////////////////////////
extern float check,checkb;
extern const int number = 7;
extern int area;
int scale = 200;
/////////////////////////////////////////////////////////////////////////////
// CGAView
IMPLEMENT_DYNCREATE(CGAView, CView)
BEGIN_MESSAGE_MAP(CGAView, CView)
//{{AFX_MSG_MAP(CGAView)
ON_COMMAND(ID_Menu_GA, OnMenuGA)
ON_COMMAND(ID_Menu_Fitting, OnMenuFitting)
ON_COMMAND(ID_Menu_InitialPopulation, OnMenuInitialPopulation)
ON_COMMAND(ID_Menu_Knots, OnMenuKnots)
ON_COMMAND(ID_Menu_BodyPlan, OnMenuBodyPlan)
ON_COMMAND(ID_Menu_Plan, OnMenuPlan)
ON_COMMAND(ID_Menu_RMS, OnMenuRMS)
ON_COMMAND(ID_Menu_Surface, OnMenuSurface)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CGAView construction/destruction
CGAView::CGAView()
{
// TODO: add construction code here
}
CGAView::~CGAView()
{
}
BOOL CGAView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CGAView drawing
//drawing cubic b-spline curve based on data points
void CGAView::OnDraw(CDC* pDC)
{
CGADoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//----------------------------------------------------------------------*
//Sets the y- and z-extents of the window associated with the device context
//----------------------------------------------------------------------*
int gx = 8000;
int gy = 8000;
switch(mat.getArea()){
case 1:{
CRect rect;
GetClientRect (&rect);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(gx, gy);
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(+400,rect.Height()-200);
original.drawO(pDC);
break;
}
case 2:{
CRect rect;
GetClientRect (&rect);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(gx, gy);
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(+400,rect.Height()-200);
matInitial.draw(pDC);
break;
}
case 3:{
CRect rect;
GetClientRect (&rect);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(gx, gy);
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(+400,rect.Height()-200);
mat.drawFitness(pDC);
break;
}
case 4:{
CRect rect;
GetClientRect (&rect);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(8000, 8000);
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(-50,rect.Height()-200);
mat.drawPlan(pDC);
break;
}
case 5:{
CRect rect;
GetClientRect (&rect);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(8000, 8000);
pDC->SetViewportExt(rect.Width(),-rect.Height());
pDC->SetViewportOrg(+50,rect.Height()-300);
mat.drawSurf(pDC);
break;
}
ReleaseDC (pDC);
}
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CGAView printing
BOOL CGAView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CGAView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CGAView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CGAView diagnostics
#ifdef _DEBUG
void CGAView::AssertValid() const
{
CView::AssertValid();
}
void CGAView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CGADoc* CGAView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGADoc)));
return (CGADoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CGAView message handlers
extern float y[],z[];
void CGAView::OnMenuGA()
{
// TODO: Add your command handler code here
CdlgBackground dlg;
dlg.DoModal();
Invalidate();
UpdateWindow();
}
/////////////////////////////////////////////////////////////////////////////
void CGAView::OnMenuFitting()
{
// TODO: Add your command handler code here
CdlgFittingProcess dlg2;
dlg2.DoModal();
Invalidate();
UpdateWindow();
}
void CGAView::OnMenuInitialPopulation()
{
// TODO: Add your command handler code here
CdlgPlotting dlg1;
dlg1.DoModal();
Invalidate();
UpdateWindow();
}
void CGAView::OnMenuKnots()
{
// TODO: Add your command handler code here
CdlgKnot dlg3;
dlg3.DoModal();
Invalidate();
UpdateWindow();
}
void CGAView::OnMenuBodyPlan()
{
// TODO: Add your command handler code here
area = 3;
Invalidate();
UpdateWindow();
}void CGAView::OnMenuPlan()
{
// TODO: Add your command handler code here
area = 4;
Invalidate();
UpdateWindow();
}
void CGAView::OnMenuRMS()
{
// TODO: Add your command handler code here
CdlgRMS dlg4;
dlg4.DoModal();
Invalidate();
UpdateWindow();
}
void CGAView::OnMenuSurface()
{
// TODO: Add your command handler code here
area = 5;
Invalidate();
UpdateWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -