-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMap11.cpp
71 lines (62 loc) · 1.19 KB
/
Map11.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "stdafx.h"
#include "Map11.h"
CMap11::CMap11()
{
}
void CMap11::Draw(CDC * pDC)
{
CPen pen1(PS_SOLID, 1, RGB(0, 0, 0));
CPen *oldPen = pDC->SelectObject(&pen1);
int size1 = pts.size();
for (int i = 0; i<size1; i++)
{
if (i == 0)
{
pDC->MoveTo(pts[i]);
CString t0;
t0.Format("%d -> %d,%d", i, pts[i].x, pts[i].y);
pDC->TextOut(pts[i].x, pts[i].y, t0);
}
else
{
pDC->LineTo(pts[i]);
CString t;
t.Format("%d -> %d,%d", i, pts[i].x, pts[i].y);
pDC->TextOut(pts[i].x, pts[i].y, t);
}
}
pDC->LineTo(pts[0]);
clockJudge();
CPen pen2(PS_SOLID, 2, RGB(0, 0, 255));
oldPen = pDC->SelectObject(&pen2);
CPoint p;
p.x = (xmin + xmax) / 2.0;
p.y = (ymin + ymax) / 2.0;
CString t2;
if(this->clockWise==true)
t2.Format("˳ʱÕë");
else
t2.Format("ÄæʱÕë");
pDC->TextOut(p.x + 10, p.y - 10, t2);
pDC->SelectObject(oldPen);
}
void CMap11::clockJudge()
{
int size = pts.size();
for (int i = 0; i < size; i++)
{
if (pts[i].x == this->xmax)
{
CVector v1(pts[i], pts[i - 1]);
CVector v2(pts[i], pts[i + 1]);
if (v1.crossProduct(v2) > 0)
this -> clockWise = false;
else
this->clockWise = true;
break;
}
}
}
CMap11::~CMap11()
{
}