-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ccircle.cpp
106 lines (93 loc) · 2.28 KB
/
Ccircle.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "Ccircle.h"
#include<fstream>
Ccircle::Ccircle(Point P1, Point P2, GfxInfo FigureGfxInfo) :CFigure(FigureGfxInfo)
{
Center= P1;
Radius= P2;
radius = CalcDistance(P1, P2);
pvid = ID;
}
Ccircle::Ccircle()
{
}
void Ccircle::Draw(Output* pOut) const
{
pOut->DrawCircle(Center, Radius, FigGfxInfo, Selected);
}
void Ccircle::PrintInfo(Output* pOut)
{
string c = to_string(Center.x) + "," + to_string(Center.y)+" Radius "+to_string(Radius.x)+","+to_string(Radius.y);
string Id = to_string(ID);
string isselected = to_string(Selected);
pOut->PrintMessage("Figure type: Circle,Center: " + c + " ID: " + Id + " Is selected: " + isselected);
}
bool Ccircle::IsOnFig(int x, int y) //Checks to deciding the click is on figure or not //BISHOY
{
Point P;
P.x = x;
P.y = y;
//to see if the point lie on the circle or not //BISHOY
return (radius >= CalcDistance(Center, P));
}
void Ccircle::MOVE(Point p)
{
C0 = Center;
float rlen = sqrt(pow((Radius.x - Center.x), 2) + pow((Radius.y - Center.y), 2));
Center.x = p.x;
Center.y = p.y;
Radius.x = p.x + rlen;
Radius.y = p.y;
pvid = ID;
}
Point Ccircle::getcenter()
{
return C0;
}
void Ccircle::GetTheCorner(Point A)
{
}
void Ccircle::Resize(Point A)
{
Radius = A;
radius = CalcDistance(A, Center);
}
void Ccircle::Save(ofstream& OutFile)
{
OutFile << "Circle\t"<< pvid<<"\t" << Center.x << "\t" << Center.y << "\t" << Radius.x << "\t" << Radius.y << "\t" << ConvertColorToString(FigGfxInfo.DrawClr) << "\t";
if (FigGfxInfo.isFilled)
{
OutFile << ConvertColorToString(FigGfxInfo.FillClr) << endl;
}
else
{
OutFile << "NOCOLOR" << endl;
}
}
void Ccircle::Load(ifstream& InFile)
{
string DrawClr;
string FillClr;
InFile >> pvid >> Center.x >> Center.y >> Radius.x >> Radius.y;
InFile >> DrawClr;
FigGfxInfo.DrawClr = ConvertStringToColor(DrawClr);
InFile >> FillClr;
if (FillClr == "NOCOLOR")
{
FigGfxInfo.isFilled = false;
}
else {
FigGfxInfo.isFilled = true;
FigGfxInfo.FillClr = ConvertStringToColor(FillClr);
}
Selected = false;
FigGfxInfo.BorderWdth = UI.PenWidth;
radius = CalcDistance(Center, Radius);
}
int Ccircle::iffigtype()
{
return 1;
}
ShapesMenuItem Ccircle::Returnshapestype()
{
return ITM_CIR;
}