Locus No Pilotus
Project of four first grade MIPT DAFE/RSE students (for engineering practical work in the second semester) in Qt C++
Loading...
Searching...
No Matches
lib::TrappyCircle Class Reference

Опасная зона More...

#include <trappy_circle.h>

Inheritance diagram for lib::TrappyCircle:
Collaboration diagram for lib::TrappyCircle:

Public Member Functions

 TrappyCircle (const TrappyCircle &)=default
 
 TrappyCircle (Point center={0, 0}, double radius=0)
 
 TrappyCircle (TrappyCircle &&)=default
 
Point GetCenter () const
 
virtual unsigned short GetId () const
 Возвращает значение ид. объекта внутри файла
 
QJsonObject GetJsonInfo () const override
 
double GetRadius () const
 
bool IsChanged (const QJsonObject &trappy_circle_obj) const override
 
TrappyCircleoperator= (const TrappyCircle &)=default
 
TrappyCircleoperator= (TrappyCircle &&)=default
 
bool operator== (const TrappyCircle &) const
 
void SetCenter (const Point &center)
 
virtual void SetId (unsigned short id)
 Устанавливает значение ид. объекта внутри файла
 
void SetJsonInfo (const QJsonObject &trappy_circle_obj) override
 
void SetRadius (double r)
 

Private Member Functions

void CheckErrorValues () const override
 Проверяет данные в классе на валидность
 

Private Attributes

Point center_
 
unsigned short id_ {USHRT_MAX}
 Идентификатор объекта внутри файла
 
double radius_
 

Detailed Description

Опасная зона

Constructor & Destructor Documentation

◆ TrappyCircle() [1/3]

lib::TrappyCircle::TrappyCircle ( Point center = {0, 0},
double radius = 0 )
10 : center_{center}, radius_{radius} {
11 if (radius < 0)
12 throw std::invalid_argument(
13 "TrappyCircles cannot have of negative radius!");
14
16}
Point center_
Definition trappy_circle.h:49
void CheckErrorValues() const override
Проверяет данные в классе на валидность
Definition trappy_circle.cpp:66
double radius_
Definition trappy_circle.h:50
Here is the call graph for this function:

◆ TrappyCircle() [2/3]

lib::TrappyCircle::TrappyCircle ( const TrappyCircle & )
default

◆ TrappyCircle() [3/3]

lib::TrappyCircle::TrappyCircle ( TrappyCircle && )
default

Member Function Documentation

◆ CheckErrorValues()

void lib::TrappyCircle::CheckErrorValues ( ) const
overrideprivatevirtual

Проверяет данные в классе на валидность

Exceptions
std::invalid_argumentесли одна из коорд. центра превышает максимально допустимое значение
std::invalid_argumentесли радиус превышает максимально допустимое значение

Implements lib::JSONable.

66 {
68 throw std::invalid_argument("Exceeding the maximum permissible values!");
69}
constexpr double max_coord
Definition base.h:12
double y
Definition point.h:18
double x
Definition point.h:17
Here is the caller graph for this function:

◆ GetCenter()

Point lib::TrappyCircle::GetCenter ( ) const
inline
24{ return center_; }
Here is the caller graph for this function:

◆ GetId()

virtual unsigned short lib::JSONable::GetId ( ) const
inlinevirtualinherited

Возвращает значение ид. объекта внутри файла

Returns
unsigned short: идентификатор объекта внутри файла
26{ return id_; }
unsigned short id_
Идентификатор объекта внутри файла
Definition base.h:40
Here is the caller graph for this function:

◆ GetJsonInfo()

QJsonObject lib::TrappyCircle::GetJsonInfo ( ) const
overridevirtual

Implements lib::JSONable.

18 {
19 QVariantMap trappy_circle_map;
20
21 trappy_circle_map.insert("Id", GetId());
22 trappy_circle_map.insert("X", center_.x);
23 trappy_circle_map.insert("Y", center_.y);
24 trappy_circle_map.insert("Radius", radius_);
25
26 return QJsonObject::fromVariantMap(trappy_circle_map);
27}
virtual unsigned short GetId() const
Возвращает значение ид. объекта внутри файла
Definition base.h:26
Here is the call graph for this function:

◆ GetRadius()

double lib::TrappyCircle::GetRadius ( ) const
inline
25{ return radius_; }
Here is the caller graph for this function:

◆ IsChanged()

bool lib::TrappyCircle::IsChanged ( const QJsonObject & trappy_circle_obj) const
overridevirtual

Implements lib::JSONable.

54 {
55 Point c = {trappy_circle_obj.value("X").toDouble(),
56 trappy_circle_obj.value("Y").toDouble()};
57 double r = trappy_circle_obj.value("Radius").toDouble();
58 return c != center_ || abs(r - radius_) > 10.E-7;
59}
Here is the caller graph for this function:

◆ operator=() [1/2]

TrappyCircle & lib::TrappyCircle::operator= ( const TrappyCircle & )
default

◆ operator=() [2/2]

TrappyCircle & lib::TrappyCircle::operator= ( TrappyCircle && )
default

◆ operator==()

bool lib::TrappyCircle::operator== ( const TrappyCircle & tr_circle) const
61 {
62 return center_ == tr_circle.GetCenter() &&
63 abs(radius_ - tr_circle.GetRadius()) < 10.E-7;
64}
Here is the call graph for this function:

◆ SetCenter()

void lib::TrappyCircle::SetCenter ( const Point & center)
inline
27 {
28 center_ = center;
30 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetId()

virtual void lib::JSONable::SetId ( unsigned short id)
inlinevirtualinherited

Устанавливает значение ид. объекта внутри файла

Parameters
idновый идентификатор объекта
32{ id_ = id; }
Here is the caller graph for this function:

◆ SetJsonInfo()

void lib::TrappyCircle::SetJsonInfo ( const QJsonObject & trappy_circle_obj)
overridevirtual

Implements lib::JSONable.

29 {
30 if (!(trappy_circle_obj.contains("X") && trappy_circle_obj.contains("Y") &&
31 trappy_circle_obj.contains("Radius") &&
32 trappy_circle_obj.contains("Id")))
33 throw std::invalid_argument(
34 "Invalid file format: missing X,Y,Radius or Id field in "
35 "TrappyCircles!");
36
37 double x = trappy_circle_obj.value("X").toDouble();
38 double y = trappy_circle_obj.value("Y").toDouble();
39 double r = trappy_circle_obj.value("Radius").toDouble();
40
41 SetCenter({x, y});
42 SetRadius(r);
43
44 unsigned short id =
45 static_cast<unsigned short>(trappy_circle_obj.value("Id").toInt());
46 if (id < 20000 || id > 29999)
47 throw std::invalid_argument(
48 "Invalid file format: incorrect id in 'Trappy_Circle'!");
49 SetId(id);
50
52}
virtual void SetId(unsigned short id)
Устанавливает значение ид. объекта внутри файла
Definition base.h:32
void SetRadius(double r)
Definition trappy_circle.h:32
void SetCenter(const Point &center)
Definition trappy_circle.h:27
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRadius()

void lib::TrappyCircle::SetRadius ( double r)
inline
32 {
33 radius_ = r;
35 }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ center_

Point lib::TrappyCircle::center_
private

◆ id_

unsigned short lib::JSONable::id_ {USHRT_MAX}
privateinherited

Идентификатор объекта внутри файла

40{USHRT_MAX};

◆ radius_

double lib::TrappyCircle::radius_
private

The documentation for this class was generated from the following files: