📄 nbc_algorithmview.cpp
字号:
// NBC_AlgorithmView.cpp : implementation of the CNBC_AlgorithmView class
//
#include "stdafx.h"
#include "NBC_Algorithm.h"
#include "NBC_AlgorithmDoc.h"
#include "NBC_AlgorithmView.h"
#include "MyDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNBC_AlgorithmView
IMPLEMENT_DYNCREATE(CNBC_AlgorithmView, CView)
BEGIN_MESSAGE_MAP(CNBC_AlgorithmView, CView)
//{{AFX_MSG_MAP(CNBC_AlgorithmView)
ON_COMMAND(ID_DEER95, OnDeer95)
ON_COMMAND(ID_ELK93, OnElk93)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CNBC_AlgorithmView construction/destruction
CNBC_AlgorithmView::CNBC_AlgorithmView()
{
// TODO: add construction code here
mark=0;
temp_first_tra=NULL;
}
CNBC_AlgorithmView::~CNBC_AlgorithmView()
{
}
BOOL CNBC_AlgorithmView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CNBC_AlgorithmView drawing
void CNBC_AlgorithmView::OnDraw(CDC* pDC)
{
CNBC_AlgorithmDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPen mypen;
mypen.CreatePen(PS_SOLID,1,RGB(0,255,0));
pDC->SelectObject(&mypen);
/*mypoint *mp=new mypoint;
CFile Openfile("elk93.txt",CFile::modeRead);
Openfile.Read(&mp,1);*/
if(mark==0)
{
//
pDC->TextOut(100,100,"轨道聚类算法演示");
}
else if(mark==1)
{
pDC->TextOut(100,100,"数据处理中,请稍后.......");
}
else
{
double x;
double y;
int id=0;
int num;
int temid;
ifstream infile;
if(mark==2)
{
infile.open("deer95.txt",ios::in);
}
else
{
infile.open("elk93.txt",ios::in);
}
infile>>num;
infile>>temid;
infile>>x;
infile>>y;
pDC->MoveTo((int)x,(int)y);
while(!infile.eof())
{
infile>>num;
infile>>temid;
infile>>x;
infile>>y;
if(temid==id)
{
pDC->LineTo((int)x,(int)y);
}
else
{
pDC->MoveTo((int)x,(int)y);
id=temid;
}
}
mypen.DeleteObject();
CPen mypen1;
mypen1.CreatePen(PS_SOLID,2,RGB(255,0,0));
pDC->SelectObject(&mypen1);
infile.close();
TRA *current_tra=temp_first_tra;
point *tp;
while(current_tra!=NULL)
{
tp=current_tra->first_point;
pDC->MoveTo((int)tp->x,(int)tp->y);
tp=tp->next;
while(tp!=NULL)
{
pDC->LineTo((int)tp->x,(int)tp->y);
tp=tp->next;
}
current_tra=current_tra->next;
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CNBC_AlgorithmView printing
BOOL CNBC_AlgorithmView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CNBC_AlgorithmView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CNBC_AlgorithmView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CNBC_AlgorithmView diagnostics
#ifdef _DEBUG
void CNBC_AlgorithmView::AssertValid() const
{
CView::AssertValid();
}
void CNBC_AlgorithmView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CNBC_AlgorithmDoc* CNBC_AlgorithmView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CNBC_AlgorithmDoc)));
return (CNBC_AlgorithmDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CNBC_AlgorithmView message handlers
void CNBC_AlgorithmView::OnDeer95()
{
// TODO: Add your command handler code here
MyDialog dlg;
int mk;
if(dlg.DoModal()==IDOK)
{
mk=dlg.m_ek;
Trajectory tra1;
line *first_line;
line *last_line;
tra1.ATP_Algorithm("deer95.txt",10);
first_line=tra1.get_first_line();
last_line=tra1.get_last_line();
LS_CLUSTERING ls(mk,first_line,last_line);
ls.CalcNDFs();
ls.ls_clustering();
ls.check_tra_num(9);
ls.output_cluster();
cluster *first_cl=ls.get_first_cluster();
RTG rtgs(5,20,first_cl);
rtgs.get_Rtra();
temp_first_tra=rtgs.get_first_tra();
mark=2;
Invalidate(FALSE);
}
}
void CNBC_AlgorithmView::OnElk93()
{
// TODO: Add your command handler code here
MyDialog dlg;
int mk;
if(dlg.DoModal()==IDOK)
{
mk=dlg.m_ek;
Trajectory tra1;
line *first_line;
line *last_line;
tra1.ATP_Algorithm("elk93.txt",12.6);
first_line=tra1.get_first_line();
last_line=tra1.get_last_line();
LS_CLUSTERING ls(mk,first_line,last_line);
ls.CalcNDFs();
ls.ls_clustering();
ls.check_tra_num(14);
ls.output_cluster();
cluster *first_cl=ls.get_first_cluster();
RTG rtgs(15,25,first_cl);
rtgs.get_Rtra();
temp_first_tra=rtgs.get_first_tra();
mark=3;
Invalidate(FALSE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -