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

📄 tspsaview.cpp

📁  针对基于遗传算法的TSP 问题求解, 尝试了多种遗传操作, 分析了这些操作在遗传算法中的作用, 讨论了基因片段保序在利用遗传算法求解TSP 问题中的重要性.
💻 CPP
字号:
// TspSAView.cpp : implementation of the CTspSAView class
//

#include "stdafx.h"
#include "TspSA.h"

#include "TspSADoc.h"
#include "TspSAView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTspSAView

IMPLEMENT_DYNCREATE(CTspSAView, CListView)

BEGIN_MESSAGE_MAP(CTspSAView, CListView)
	//{{AFX_MSG_MAP(CTspSAView)
		// 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
	// Standard printing commands
	ON_MESSAGE(WYWM_INFOVIEWAPPENDINFO, OnAppendOutputInfo)
	ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTspSAView construction/destruction

CTspSAView::CTspSAView()
{
	// TODO: add construction code here

}

CTspSAView::~CTspSAView()
{
}

BOOL CTspSAView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	cs.style |= WS_HSCROLL | WS_VSCROLL;
	cs.style |= LVS_REPORT; // | LVS_NOCOLUMNHEADER;

	return CListView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTspSAView drawing

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

void CTspSAView::OnInitialUpdate()
{
	CListView::OnInitialUpdate();

	CListCtrl& control = GetListCtrl();
	control.InsertColumn(0, _T(""),LVCFMT_LEFT );
	control.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER );

//	control.SetExtendedStyle( LVS_EX_FULLROWSELECT );


	// TODO: You may populate your ListView with items by directly accessing
	//  its list control through a call to GetListCtrl().
}

/////////////////////////////////////////////////////////////////////////////
// CTspSAView printing

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

void CTspSAView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

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

/////////////////////////////////////////////////////////////////////////////
// CTspSAView diagnostics

#ifdef _DEBUG
void CTspSAView::AssertValid() const
{
	CListView::AssertValid();
}

void CTspSAView::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CTspSAView message handlers

void CTspSAView::AddString(CString strAppendString)
{
	CListCtrl& control = GetListCtrl();

	int nIndex = control.GetItemCount();

	nIndex = control.GetItemCount();
	
	control.InsertItem( nIndex, strAppendString );
	control.EnsureVisible( nIndex, FALSE );
}

void CTspSAView::OnAppendOutputInfo(WPARAM pString, LPARAM nType)
{
	CString *pAddstring = (CString*)pString;
	AddString( *pAddstring );
}

void CTspSAView::ClearInfos()
{
	CListCtrl& control = GetListCtrl();
	control.DeleteAllItems();
}

⌨️ 快捷键说明

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