-
Notifications
You must be signed in to change notification settings - Fork 12
/
object.cpp
174 lines (141 loc) · 3.96 KB
/
object.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "object.h"
struct SolarSystem::Object::ObjectData
{
// base parameters
QString stringType; // solar object type: Planet, Sattelite (Moon), Ring, Dwarf Planet, Solar System Body, Star, Asteroid, Galaxy
QString name; // base name
float orbitalSpeed; // base orbital speed, km/s
double mass; // base mass, kg
float meanRadius; // base radius, km
int surfaceTemp; // base surface temperature, K
float surfaceGRavity; // base surface gravity, m/s^2
double volume; // base volume, km^3
// programming type
SolarSystem::ObjectType solarType;
// periods
double siderealPeriod; // sidereal rotation period (around of axis)
double orbitalPeriod; // orbital rotation period (around of sun)
// solar system object description
QString description;
};
SolarSystem::Object::Object(QObject* parent):
QObject(parent), solarObjectData(new ObjectData)
{
solarObjectData->solarType = ObjectType::SolarSystemBody;
}
SolarSystem::Object::~Object()
{
delete solarObjectData;
}
SolarSystem::Object::Object(const SolarSystem::Object& obj):
Object(obj.parent())
{
solarObjectData = new SolarSystem::Object::ObjectData(*(obj.solarObjectData));
}
SolarSystem::Object& SolarSystem::Object::operator=(SolarSystem::Object obj)
{
// temp object swap
SolarSystem::swap(*this, obj);
return *this;
}
// interface
void SolarSystem::Object::setDescription(const QString& description)
{
solarObjectData->description = description;
}
QString SolarSystem::Object::description() const
{
return solarObjectData->description;
}
void SolarSystem::Object::setStringType(const QString& type)
{
solarObjectData->stringType = type;
}
QString SolarSystem::Object::stringType() const
{
return solarObjectData->stringType;
}
void SolarSystem::Object::setSolarObjectName(const QString& name)
{
solarObjectData->name = name;
}
QString SolarSystem::Object::solarObjectName() const
{
return solarObjectData->name;
}
void SolarSystem::Object::setOrbitalSpeed(float speed)
{
solarObjectData->orbitalSpeed = speed;
}
float SolarSystem::Object::orbitalSpeed() const
{
return solarObjectData->orbitalSpeed;
}
void SolarSystem::Object::setMass(double mass)
{
solarObjectData->mass = mass;
}
double SolarSystem::Object::mass() const
{
return solarObjectData->mass;
}
void SolarSystem::Object::setMeanRadius(float radius)
{
solarObjectData->meanRadius = radius;
}
float SolarSystem::Object::meanRadius() const
{
return solarObjectData->meanRadius;
}
void SolarSystem::Object::setSurfaceTemperature(int temperature)
{
solarObjectData->surfaceTemp = temperature;
}
int SolarSystem::Object::surfaceTemperature() const
{
return solarObjectData->surfaceTemp;
}
void SolarSystem::Object::setSurfaceGravity(float gravity)
{
solarObjectData->surfaceGRavity = gravity;
}
float SolarSystem::Object::surfaceGravity() const
{
return solarObjectData->surfaceGRavity;
}
void SolarSystem::Object::setVolume(double volume)
{
solarObjectData->volume = volume;
}
double SolarSystem::Object::volume() const
{
return solarObjectData->volume;
}
void SolarSystem::Object::setSolarType(ObjectType type)
{
solarObjectData->solarType = type;
}
SolarSystem::ObjectType SolarSystem::Object::solarType() const
{
return solarObjectData->solarType;
}
void SolarSystem::Object::setSiderealPeriod(double period)
{
solarObjectData->siderealPeriod = period;
}
double SolarSystem::Object::siderealPeriod() const
{
return solarObjectData->siderealPeriod;
}
void SolarSystem::Object::setOrbitalPeriod(double period)
{
solarObjectData->orbitalPeriod = period;
}
double SolarSystem::Object::orbitalPeriod() const
{
return solarObjectData->orbitalPeriod;
}
void SolarSystem::swap(SolarSystem::Object& lhs, SolarSystem::Object& rhs)
{
std::swap(lhs.solarObjectData, rhs.solarObjectData);
}