📄 gcluserdoc.cpp
字号:
// GCluserDoc.cpp : implementation of the CGCluserDoc class
//
#include "stdafx.h"
#include "GCluser.h"
#include "GCluserDoc.h"
#include "process.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGCluserDoc
IMPLEMENT_DYNCREATE(CGCluserDoc, CDocument)
BEGIN_MESSAGE_MAP(CGCluserDoc, CDocument)
//{{AFX_MSG_MAP(CGCluserDoc)
ON_COMMAND(ID_CLUSER_MAX_DIST, OnCluserMaxDist)
ON_COMMAND(ID_CLUSER_MEAN_DIST, OnCluserMeanDist)
ON_COMMAND(ID_CLUSER_MIX_DIST, OnCluserMixDist)
ON_COMMAND(ID_K_MEAN_CLUSER, OnKMeanCluser)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGCluserDoc construction/destruction
CGCluserDoc::CGCluserDoc()
{
// TODO: add one-time construction code here
pClassification = NULL;
}
CGCluserDoc::~CGCluserDoc()
{
if (pClassification != NULL)
{
delete pClassification;
}
}
BOOL CGCluserDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CGCluserDoc serialization
void CGCluserDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CGCluserDoc diagnostics
#ifdef _DEBUG
void CGCluserDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CGCluserDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CGCluserDoc commands
BOOL CGCluserDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
pClassification = new Classification(lpszPathName);
return TRUE;
}
BOOL CGCluserDoc::CanCloseFrame(CFrameWnd* pFrame)
{
// TODO: Add your specialized code here and/or call the base class
return CDocument::CanCloseFrame(pFrame);
}
int * CGCluserDoc::GetSamples()
{
if (pClassification)
{
return pClassification->pSample;
}
else
{
AfxMessageBox("Error : No data");
exit(1);
}
}
int CGCluserDoc::GetNumDimension()
{
if (pClassification)
{
return pClassification->NumDimension;
}
else
{
AfxMessageBox("Error : No data");
exit(1);
}
}
int CGCluserDoc::GetNumClass()
{
if (pClassification)
{
return pClassification->NumClass;
}
else
{
AfxMessageBox("Error : No data");
exit(1);
}
}
int CGCluserDoc::GetNumSample()
{
if (pClassification)
{
return pClassification->NumSample;
}
else
{
AfxMessageBox("Error : No data");
exit(1);
}
}
void /*unsigned long _stdcall*/ RunClassifyThread(void *lpParam)
{
CGCluserDoc *pDoc = (CGCluserDoc *)lpParam;
if (pDoc==NULL) return;
if (pDoc->pClassification==NULL) return;
switch (pDoc->m_MenuCommand)
{
case ID_CLUSER_MAX_DIST: pDoc->pClassification->Cluser(MAX_DIST);
break;
case ID_CLUSER_MEAN_DIST: pDoc->pClassification->Cluser(MEAN_DIST);
break;
case ID_CLUSER_MIX_DIST: pDoc->pClassification->Cluser(MIN_DIST);
break;
case ID_K_MEAN_CLUSER:
break;
default: break;
}
}
void CGCluserDoc::OnCluserMaxDist()
{
// TODO: Add your command handler code here
m_MenuCommand = ID_CLUSER_MAX_DIST;
hThread=(HANDLE)_beginthread(RunClassifyThread,0,this);
}
void CGCluserDoc::OnCluserMeanDist()
{
// TODO: Add your command handler code here
m_MenuCommand = ID_CLUSER_MEAN_DIST;
hThread=(HANDLE)_beginthread(RunClassifyThread,0,this);
}
void CGCluserDoc::OnCluserMixDist()
{
// TODO: Add your command handler code here
m_MenuCommand = ID_CLUSER_MIX_DIST;
hThread=(HANDLE)_beginthread(RunClassifyThread,0,this);
}
void CGCluserDoc::OnKMeanCluser()
{
// TODO: Add your command handler code here
m_MenuCommand = ID_K_MEAN_CLUSER;
hThread=(HANDLE)_beginthread(RunClassifyThread,0,this);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -