// dbscan from zealotDlg.cpp : implementation file
//
///////////////////////
///////////////////////
#include "stdafx.h"
#include "dbscan from zealot.h"
#include "dbscan from zealotDlg.h"
#include "finalPaint.h"
#include "finalPaint2.h"
#include <list>//跟queue有关
#include <iostream>
#include <queue>
#include <deque>
#include <stdlib.h>
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Abou
////////////////
using namespace std ;//不熟悉,可能会有问题,跟queue有关
class Time
{
private :
int Initialized;
__int64 Frequency;
__int64 BeginTime;
public :
Time()
{
Initialized = QueryPerformanceFrequency( (LARGE_INTEGER *)&Frequency );
}
BOOL Begin()
{
if( ! Initialized )
return 0;
return QueryPerformanceCounter( (LARGE_INTEGER *)&BeginTime );
}
double End()
{
if( ! Initialized )
return 0.0;
__int64 endtime;
QueryPerformanceCounter( (LARGE_INTEGER *)&endtime );
__int64 elapsed = endtime - BeginTime;
return (double)elapsed / (double)Frequency;
}
BOOL Available()
{ return Initialized; }
__int64 GetFreq()
{ return Frequency; }
};
typedef struct {
int x;
int y;
}point;
// Using queue with list
typedef list<int > INTLIST;
typedef queue<int> INTQUEUE;
/////////////////////////////////////////////函数原型定义
void expand(int,int);
//void create(basicNode **) ;//引用参数传递,无法写成void create(basicNode &),可能会有错!
int downfind(linkNode **);
//basicNode * getnext(void);//类内定义
void entag(int,int);
//void paint(int,int,int);
basicNode *crNode(int,int);
float distance(int,int);
//////////////////////////////////////////////////////////////
Time timer;/////
double timerUsed;
basicNode graphTable[TOTAL];
int i;
int j;
int count1=-1;
int id1=0;
int TOTALr=TOTAL;
basicNode *seed;
FILE *f;
long colorArray[20]={0x550000,0xff0000,0x005500,0x000055,0x0000ff,0x00ff00,0x0000aa,0xaa0000,0x00aa00,0x000000,
0xffa000,0xffff00,0x00ffff,0xff00ff,0x555500,0x005555,0x550055,0x88ff33,0x3493af,0x9f6526
};
//////////////////////////////////////////////////////////////
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDbscanfromzealotDlg dialog
CDbscanfromzealotDlg::CDbscanfromzealotDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDbscanfromzealotDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDbscanfromzealotDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDbscanfromzealotDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDbscanfromzealotDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDbscanfromzealotDlg, CDialog)
//{{AFX_MSG_MAP(CDbscanfromzealotDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDCrun, OnCrun)
ON_BN_CLICKED(IDpaint, Onpaint)
ON_BN_CLICKED(IDquit, Onquit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDbscanfromzealotDlg message handlers
BOOL CDbscanfromzealotDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//我 TODO: Add extra initialization here
///////////////////////////////////
m_strConnection=_T("Provider=MSDASQL;Data Source=sxdb");
m_ctrCmdText=_T("select * from Table1");
m_pRs=NULL;
m_piAdoRecordBinding=NULL;
::CoInitialize(NULL);
m_pRs.CreateInstance(__uuidof(Recordset));
//Recordset->没有自动提示,可能问题
m_pRs->Open((LPCTSTR)m_ctrCmdText,(LPCTSTR)m_strConnection,adOpenDynamic,adLockOptimistic,adCmdUnknown);
m_pRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID *)&m_piAdoRecordBinding);
m_piAdoRecordBinding->BindToRecordset(&m_rsRecSet);//m_piAdoRecordBinding->没有自动提示,可能问题
//有两行代码未加上,可能问题
m_pRs->MoveFirst();
///////////////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
}
void CDbscanfromzealotDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CDbscanfromzealotDlg::OnPaint()
{/////////////////////画图的初始化代码写在以下
int x1,y1;
CClientDC paintDC(this);
for(x1=300;x1<400;x1++) paintDC.SetPixel(x1,300,0x000000);//画出两条坐标轴
for(y1=300;y1>200;y1--) paintDC.SetPixel(300,y1,0x000000);
for(x1=900;x1<1000;x1++) paintDC.SetPixel(x1,300,0x000000);//画出两条坐标轴
for(y1=300;y1>200;y1--) paintDC.SetPixel(900,y1,0x000000);
m_pRs->MoveFirst();
int tempx,tempy;
for(i=0;i<=(TOTAL-1);i++)
{ tempx=m_rsRecSet.m_x;
tempy=m_rsRecSet.m_y;
m_pRs->MoveNext();
paintDC.SetPixel(300+tempx,300-tempy,0x000000);//画出原点阵,黑色
paintDC.SetPixel(300+tempx+1,300-tempy,0x000000);
paintDC.SetPixel(300+tempx,300-tempy+1,0x000000);
paintDC.SetPixel(300+tempx-1,300-tempy,0x000000);
paintDC.SetPixel(300+tempx,300-tempy-1,0x000000);
}
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSO
- 1
- 2
- 3
- 4
前往页