-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsPolygon.cpp
More file actions
73 lines (60 loc) · 1.26 KB
/
sPolygon.cpp
File metadata and controls
73 lines (60 loc) · 1.26 KB
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
72
73
#include "stdafx.h"
#include "sPolygon.h"
sPolygon::sPolygon()
{
name = "Polygon";
}
sPolygon::sPolygon(CPoint start, CPoint end)
{
name = "Polygon";
this->start = start;
this->end = end;
}
sPolygon::~sPolygon(void)
{
}
void sPolygon::DrawShape(CDC *pdc, CPoint start, CPoint end)
{
CPen* penne = new CPen(lineType, lineThickness, lineColor);
pdc->SelectObject(penne);
pdc->MoveTo(start);
pdc->LineTo(end);
if (points.size() == 0)
points.emplace_back(start);
points.emplace_back(end);
delete penne;
}
void sPolygon::DrawShape(CDC *pdc)
{
CPen* penne = new CPen(lineType, lineThickness, lineColor);
pdc->SelectObject(penne);
pdc->MoveTo(start);
pdc->LineTo(end);
for (int i = 0; i <= points.size()-2; i++)
{
pdc->MoveTo(points[i]);
pdc->LineTo(points[i+1]);
}
delete penne;
}
void sPolygon::DrawAuxiliary(CDC *pdc, CPoint start, CPoint end)
{
pdc->MoveTo(start);
pdc->LineTo(end);
}
string sPolygon::ToString()
{
CT2CA pszConvertedAnsiString (text);
std::string strStd (pszConvertedAnsiString);
string ret = name
+ "," + ltos(lineType)
+ "," + ltos(lineThickness)
+ "," + ltos(lineColor)
+ "," + strStd;
for (int i = 0; i < points.size(); i++)
{
ret += "," + ltos(points[i].x) + "," + ltos(points[i].y);
}
ret += "\n";
return ret;
}