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
data_tools::DataManager Class Reference

Класс, хранящий gui объекты и связывающий их с QCustomPlot. More...

#include <data_manager.h>

Collaboration diagram for data_tools::DataManager:

Public Member Functions

 DataManager ()=default
 
void Add (const lib::Hill &data)
 
void Add (const lib::Target &data)
 
void Add (const lib::TrappyCircle &data)
 
void Add (const lib::TrappyLine &data)
 
void Add (const std::vector< lib::Hill > &)
 
void Add (const std::vector< lib::Target > &)
 
void Add (const std::vector< lib::TrappyCircle > &)
 
void Add (const std::vector< lib::TrappyLine > &)
 
void Add (gui::Hill *h)
 
void Add (gui::Target *t)
 
void Add (gui::TrappyCircle *tr_c)
 
void Add (gui::TrappyLine *tr_l)
 
void Add (lib::Hill &data)
 
void Add (lib::Target &data)
 
void Add (lib::TrappyCircle &data)
 
void Add (lib::TrappyLine &data)
 
void Add (std::vector< gui::Hill * >)
 
void Add (std::vector< gui::Target * >)
 
void Add (std::vector< gui::TrappyCircle * >)
 
void Add (std::vector< gui::TrappyLine * >)
 
void Add (std::vector< lib::Hill > &)
 
void Add (std::vector< lib::Target > &)
 
void Add (std::vector< lib::TrappyCircle > &)
 
void Add (std::vector< lib::TrappyLine > &)
 
void Clear ()
 Очищает все вектора объектов
 
std::vector< gui::HillGetHills () const
 Возвращает значение Hills.
 
std::vector< gui::Hill * > GetHillsPtrs ()
 Возвращает значение Hills.
 
unsigned short GetMinId (gui::ObjectType obj_type)
 
std::vector< gui::TargetGetTargets () const
 Возвращает значение Targets.
 
std::vector< gui::Target * > GetTargetsPtrs ()
 Возвращает значение Targets.
 
std::vector< gui::TrappyCircleGetTrappyCircles () const
 Возвращает значение TrappyCircles.
 
std::vector< gui::TrappyCircle * > GetTrappyCirclesPtrs ()
 Возвращает значение TrappyCircles.
 
std::vector< gui::TrappyLineGetTrappyLines () const
 Возвращает значение TrappyLines.
 
std::vector< gui::TrappyLine * > GetTrappyLinesPtrs ()
 Возвращает значение TrappyLines.
 
void Remove (gui::ObjectType obj_type, size_t index)
 Удаляет объект из менеджера по индексу
 
bool RemoveAllDuplicates ()
 Удаляет все повторяющиеся объекты в векторах объектов
 
bool RemoveLastDuplicate ()
 Удаляет последний объект в векторах, если он является дупликатом другого
 
void Set (const std::vector< lib::Hill > &)
 
void Set (const std::vector< lib::Target > &)
 
void Set (const std::vector< lib::TrappyCircle > &)
 
void Set (const std::vector< lib::TrappyLine > &)
 
void Set (std::vector< gui::Hill * >)
 
void Set (std::vector< gui::Target * >)
 
void Set (std::vector< gui::TrappyCircle * >)
 
void Set (std::vector< gui::TrappyLine * >)
 
void Set (std::vector< lib::Hill > &)
 
void Set (std::vector< lib::Target > &)
 
void Set (std::vector< lib::TrappyCircle > &)
 
void Set (std::vector< lib::TrappyLine > &)
 

Private Member Functions

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

Private Attributes

std::vector< std::unique_ptr< gui::Hill > > hills_
 
std::vector< std::unique_ptr< gui::Target > > targets_
 
std::vector< std::unique_ptr< gui::TrappyCircle > > tr_circles_
 
std::vector< std::unique_ptr< gui::TrappyLine > > tr_lines_
 

Detailed Description

Класс, хранящий gui объекты и связывающий их с QCustomPlot.

Constructor & Destructor Documentation

◆ DataManager()

data_tools::DataManager::DataManager ( )
default

Member Function Documentation

◆ Add() [1/24]

void data_tools::DataManager::Add ( const lib::Hill & data)
162 {
163 hills_.emplace_back(new gui::Hill(data));
164
167}
void CheckErrorValues()
Проверяет данные в DataManager на валидность
Definition data_manager.cpp:415
bool RemoveLastDuplicate()
Удаляет последний объект в векторах, если он является дупликатом другого
Definition data_manager.cpp:421
std::vector< std::unique_ptr< gui::Hill > > hills_
Definition data_manager.h:163
Фигура рельефа с высотой
Definition hill.h:15
Here is the call graph for this function:

◆ Add() [2/24]

void data_tools::DataManager::Add ( const lib::Target & data)
69 {
70 if (targets_.empty())
71 targets_.emplace_back(new gui::Airport(data));
72 else
73 targets_.emplace_back(new gui::Target(data));
74
77}
std::vector< std::unique_ptr< gui::Target > > targets_
Definition data_manager.h:164
Фигура контрольной точки, откуда происходит запуск
Definition airport.h:14
Фигура контрольной точки
Definition target.h:13
Here is the call graph for this function:

◆ Add() [3/24]

void data_tools::DataManager::Add ( const lib::TrappyCircle & data)
252 {
253 tr_circles_.emplace_back(new gui::TrappyCircle(data));
254
257}
std::vector< std::unique_ptr< gui::TrappyCircle > > tr_circles_
Definition data_manager.h:165
Фигура опасной зоны
Definition trappy_circle.h:14
Here is the call graph for this function:

◆ Add() [4/24]

void data_tools::DataManager::Add ( const lib::TrappyLine & data)
342 {
343 tr_lines_.emplace_back(new gui::TrappyLine(data));
344
347}
std::vector< std::unique_ptr< gui::TrappyLine > > tr_lines_
Definition data_manager.h:166
Фигура линии опасного перелета
Definition trappy_line.h:14
Here is the call graph for this function:

◆ Add() [5/24]

void data_tools::DataManager::Add ( const std::vector< lib::Hill > & new_hills)
186 {
187 for (const auto& hill : new_hills) Add(hill);
188
191}
void Add(gui::Target *t)
Definition data_manager.cpp:49
Here is the call graph for this function:

◆ Add() [6/24]

void data_tools::DataManager::Add ( const std::vector< lib::Target > & new_targets)
96 {
97 for (const auto& target : new_targets) Add(target);
98
101}
Here is the call graph for this function:

◆ Add() [7/24]

void data_tools::DataManager::Add ( const std::vector< lib::TrappyCircle > & new_tr_circles)
276 {
277 for (const auto& tr_circle : new_tr_circles) Add(tr_circle);
278
281}
Here is the call graph for this function:

◆ Add() [8/24]

void data_tools::DataManager::Add ( const std::vector< lib::TrappyLine > & new_tr_lines)
366 {
367 for (auto& tr_line : new_tr_lines) Add(tr_line);
368
371}
Here is the call graph for this function:

◆ Add() [9/24]

void data_tools::DataManager::Add ( gui::Hill * h)
147 {
148 hills_.emplace_back(h);
150
153}
unsigned short GetMinId(gui::ObjectType obj_type)
Definition data_manager.cpp:493
const lib::Hill & GetData() const
Definition hill.h:41
virtual void SetId(unsigned short id)
Устанавливает значение ид. объекта внутри файла
Definition base.h:32
Here is the call graph for this function:

◆ Add() [10/24]

void data_tools::DataManager::Add ( gui::Target * t)
49 {
50 if (targets_.empty()) t = new gui::Airport(*t);
51
52 targets_.emplace_back(t);
54
57}
lib::Target & GetData()
Definition target.h:31
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Add() [11/24]

void data_tools::DataManager::Add ( gui::TrappyCircle * tr_c)
237 {
238 tr_circles_.emplace_back(tr_c);
240
243}
const lib::TrappyCircle & GetData() const
Definition trappy_circle.h:39
Here is the call graph for this function:

◆ Add() [12/24]

void data_tools::DataManager::Add ( gui::TrappyLine * tr_l)
327 {
328 tr_lines_.emplace_back(tr_l);
330
333}
const lib::TrappyLine & GetData() const
Definition trappy_line.h:50
Here is the call graph for this function:

◆ Add() [13/24]

void data_tools::DataManager::Add ( lib::Hill & data)
155 {
156 hills_.emplace_back(new gui::Hill(data));
157
160}
Here is the call graph for this function:

◆ Add() [14/24]

void data_tools::DataManager::Add ( lib::Target & data)
59 {
60 if (targets_.empty())
61 targets_.emplace_back(new gui::Airport(data));
62 else
63 targets_.emplace_back(new gui::Target(data));
64
67}
Here is the call graph for this function:

◆ Add() [15/24]

void data_tools::DataManager::Add ( lib::TrappyCircle & data)
245 {
246 tr_circles_.emplace_back(new gui::TrappyCircle(data));
247
250}
Here is the call graph for this function:

◆ Add() [16/24]

void data_tools::DataManager::Add ( lib::TrappyLine & data)
335 {
336 tr_lines_.emplace_back(new gui::TrappyLine(data));
337
340}
Here is the call graph for this function:

◆ Add() [17/24]

void data_tools::DataManager::Add ( std::vector< gui::Hill * > new_hills)
169 {
170 for (const auto& hill : new_hills) {
171 Add(hill);
172 hill->GetData().SetId(GetMinId(gui::ObjectType::Hills));
173 }
174
177}
Here is the call graph for this function:

◆ Add() [18/24]

void data_tools::DataManager::Add ( std::vector< gui::Target * > new_targets)
79 {
80 for (const auto& target : new_targets) {
81 Add(target);
82 target->GetData().SetId(GetMinId(gui::ObjectType::Targets));
83 }
84
87}
Here is the call graph for this function:

◆ Add() [19/24]

void data_tools::DataManager::Add ( std::vector< gui::TrappyCircle * > new_tr_circles)
259 {
260 for (const auto& tr_circle : new_tr_circles) {
261 Add(tr_circle);
262 tr_circle->GetData().SetId(GetMinId(gui::ObjectType::TrappyCircles));
263 }
264
267}
Here is the call graph for this function:

◆ Add() [20/24]

void data_tools::DataManager::Add ( std::vector< gui::TrappyLine * > new_tr_lines)
349 {
350 for (const auto& tr_line : new_tr_lines) {
351 Add(tr_line);
352 tr_line->GetData().SetId(GetMinId(gui::ObjectType::TrappyLines));
353 }
354
357}
Here is the call graph for this function:

◆ Add() [21/24]

void data_tools::DataManager::Add ( std::vector< lib::Hill > & new_hills)
179 {
180 for (const auto& hill : new_hills) Add(hill);
181
184}
Here is the call graph for this function:

◆ Add() [22/24]

void data_tools::DataManager::Add ( std::vector< lib::Target > & new_targets)
89 {
90 for (const auto& target : new_targets) Add(target);
91
94}
Here is the call graph for this function:

◆ Add() [23/24]

void data_tools::DataManager::Add ( std::vector< lib::TrappyCircle > & new_tr_circles)
269 {
270 for (const auto& tr_circle : new_tr_circles) Add(tr_circle);
271
274}
Here is the call graph for this function:

◆ Add() [24/24]

void data_tools::DataManager::Add ( std::vector< lib::TrappyLine > & new_tr_lines)
359 {
360 for (auto& tr_line : new_tr_lines) Add(tr_line);
361
364}
Here is the call graph for this function:

◆ CheckErrorValues()

void data_tools::DataManager::CheckErrorValues ( )
private

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

Exceptions
std::invalid_argumentесли объектов какого-либо вектора > 10000
415 {
416 if (targets_.size() > 10000 || hills_.size() > 10000 ||
417 tr_circles_.size() > 10000 || tr_lines_.size() > 10000)
418 throw std::invalid_argument("Exceeding the maximum objects number!");
419}
Here is the caller graph for this function:

◆ Clear()

void data_tools::DataManager::Clear ( )

Очищает все вектора объектов

38 {
39 targets_.clear();
40 tr_circles_.clear();
41 tr_lines_.clear();
42 hills_.clear();
43
45}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHills()

std::vector< gui::Hill > data_tools::DataManager::GetHills ( ) const

Возвращает значение Hills.

Returns
std::vector<gui::Hill>: объекты рельефа
226 {
227 auto res = std::vector<gui::Hill>();
228 for (auto& hill_ptr_ : hills_) {
229 res.push_back(*hill_ptr_);
230 }
231
232 return res;
233}
Here is the caller graph for this function:

◆ GetHillsPtrs()

std::vector< gui::Hill * > data_tools::DataManager::GetHillsPtrs ( )

Возвращает значение Hills.

Returns
std::vector<gui::Hill*>: указатели на объекты рельефа
217 {
218 auto res = std::vector<gui::Hill*>();
219 for (auto& hill_ptr_ : hills_) {
220 res.push_back(hill_ptr_.get());
221 }
222
223 return res;
224}
Here is the caller graph for this function:

◆ GetMinId()

unsigned short data_tools::DataManager::GetMinId ( gui::ObjectType obj_type)
493 {
494 std::vector<unsigned short> ids;
495 switch (obj_type) {
497 for (auto& t : targets_) ids.push_back(t->GetData().GetId());
498 unsigned short id = 10000;
499 while (!(ids.empty() || find(ids.begin(), ids.end(), id) == ids.end()))
500 id++;
501
502 return id;
503 }
505 for (auto& trc : tr_circles_) ids.push_back(trc->GetData().GetId());
506 unsigned short id = 20000;
507 while (!(ids.empty() || find(ids.begin(), ids.end(), id) == ids.end()))
508 id++;
509
510 return id;
511 }
513 for (auto& trl : tr_lines_) ids.push_back(trl->GetData().GetId());
514 unsigned short id = 30000;
515 while (!(ids.empty() || find(ids.begin(), ids.end(), id) == ids.end()))
516 id++;
517
518 return id;
519 }
521 for (auto& h : hills_) ids.push_back(h->GetData().GetId());
522 unsigned short id = 40000;
523 while (!(ids.empty() || find(ids.begin(), ids.end(), id) == ids.end()))
524 id++;
525
526 return id;
527 }
528 }
529
530 // this case is impossible
531 return SHRT_MAX;
532}
Here is the caller graph for this function:

◆ GetTargets()

std::vector< gui::Target > data_tools::DataManager::GetTargets ( ) const

Возвращает значение Targets.

Returns
std::vector<gui::Target>: объекты к.т.
136 {
137 auto res = std::vector<gui::Target>();
138 for (auto& target_ptr_ : targets_) {
139 res.push_back(*target_ptr_);
140 }
141
142 return res;
143}
Here is the caller graph for this function:

◆ GetTargetsPtrs()

std::vector< gui::Target * > data_tools::DataManager::GetTargetsPtrs ( )

Возвращает значение Targets.

Returns
std::vector<gui::Target*>: указатели на объекты к.т.
127 {
128 auto res = std::vector<gui::Target*>();
129 for (auto& target_ptr_ : targets_) {
130 res.push_back(target_ptr_.get());
131 }
132
133 return res;
134}
Here is the caller graph for this function:

◆ GetTrappyCircles()

std::vector< gui::TrappyCircle > data_tools::DataManager::GetTrappyCircles ( ) const

Возвращает значение TrappyCircles.

Returns
std::vector<gui::TrappyCircle>: объекты опасной зоны
316 {
317 auto res = std::vector<gui::TrappyCircle>();
318 for (auto& tr_circle_ptr : tr_circles_) {
319 res.push_back(*tr_circle_ptr);
320 }
321
322 return res;
323}
Here is the caller graph for this function:

◆ GetTrappyCirclesPtrs()

std::vector< gui::TrappyCircle * > data_tools::DataManager::GetTrappyCirclesPtrs ( )

Возвращает значение TrappyCircles.

Returns
std::vector<gui::TrappyCircle*>: указатели на объекты опасной зоны
307 {
308 auto res = std::vector<gui::TrappyCircle*>();
309 for (auto& tr_circle_ptr : tr_circles_) {
310 res.push_back(tr_circle_ptr.get());
311 }
312
313 return res;
314}
Here is the caller graph for this function:

◆ GetTrappyLines()

std::vector< gui::TrappyLine > data_tools::DataManager::GetTrappyLines ( ) const

Возвращает значение TrappyLines.

Returns
std::vector<gui::TrappyLine>: объекты оп. перелета
406 {
407 auto res = std::vector<gui::TrappyLine>();
408 for (auto& tr_line_ptr : tr_lines_) {
409 res.push_back(*tr_line_ptr);
410 }
411
412 return res;
413}
Here is the caller graph for this function:

◆ GetTrappyLinesPtrs()

std::vector< gui::TrappyLine * > data_tools::DataManager::GetTrappyLinesPtrs ( )

Возвращает значение TrappyLines.

Returns
std::vector<gui::TrappyLine*>: указатели на объекты оп. перелета
397 {
398 auto res = std::vector<gui::TrappyLine*>();
399 for (auto& tr_line_ptr : tr_lines_) {
400 res.push_back(tr_line_ptr.get());
401 }
402
403 return res;
404}
Here is the caller graph for this function:

◆ Remove()

void data_tools::DataManager::Remove ( gui::ObjectType obj_type,
size_t index )

Удаляет объект из менеджера по индексу

Parameters
obj_typeтип объекта
indexиндекс объекта в его векторе
6 {
7 switch (obj_type) {
9 targets_.erase(targets_.begin() + index);
10
11 // если был удалён первый, не явл. последним, меняем следующий на аэропорт
12 if (index == 0 && !targets_.empty()) {
13 targets_[0].reset(new gui::Airport(targets_[0]->GetData()));
14 }
15
16 break;
17 }
18
20 hills_.erase(hills_.begin() + index);
21 break;
22 }
23
25 tr_circles_.erase(tr_circles_.begin() + index);
26 break;
27 }
28
30 tr_lines_.erase(tr_lines_.begin() + index);
31 break;
32 }
33 }
34
36}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveAllDuplicates()

bool data_tools::DataManager::RemoveAllDuplicates ( )

Удаляет все повторяющиеся объекты в векторах объектов

Returns
true: если был удалён хоть один объект
false: если не был
455 {
456 bool res = false;
457
458 if (!targets_.empty())
459 for (size_t i = 0; i < targets_.size() - 1; i++)
460 for (size_t j = i + 1; j < targets_.size(); j++)
461 if (*targets_[i] == *targets_[j]) {
463 res = true;
464 }
465
466 if (!hills_.empty())
467 for (size_t i = 0; i < hills_.size() - 1; i++)
468 for (size_t j = i + 1; j < hills_.size(); j++)
469 if (*hills_[i] == *hills_[j]) {
471 res = true;
472 }
473
474 if (!tr_circles_.empty())
475 for (size_t i = 0; i < tr_circles_.size() - 1; i++)
476 for (size_t j = i + 1; j < tr_circles_.size(); j++)
477 if (*tr_circles_[i] == *tr_circles_[j]) {
479 res = true;
480 }
481
482 if (!tr_lines_.empty())
483 for (size_t i = 0; i < tr_lines_.size() - 1; i++)
484 for (size_t j = i + 1; j < tr_lines_.size(); j++)
485 if (*tr_lines_[i] == *tr_lines_[j]) {
487 res = true;
488 }
489
490 return res;
491}
void Remove(gui::ObjectType obj_type, size_t index)
Удаляет объект из менеджера по индексу
Definition data_manager.cpp:6
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveLastDuplicate()

bool data_tools::DataManager::RemoveLastDuplicate ( )

Удаляет последний объект в векторах, если он является дупликатом другого

Returns
true: если был удалён хоть один объект
false: если не был
421 {
422 bool res = false;
423
424 if (!targets_.empty())
425 for (size_t i = 0; i < targets_.size() - 1; i++)
426 if (*targets_[i] == *targets_[targets_.size() - 1]) {
428 res = true;
429 }
430
431 if (!hills_.empty())
432 for (size_t i = 0; i < hills_.size() - 1; i++)
433 if (*hills_[i] == *hills_[hills_.size() - 1]) {
435 res = true;
436 }
437
438 if (!tr_circles_.empty())
439 for (size_t i = 0; i < tr_circles_.size() - 1; i++)
440 if (*tr_circles_[i] == *tr_circles_[tr_circles_.size() - 1]) {
442 res = true;
443 }
444
445 if (!tr_lines_.empty())
446 for (size_t i = 0; i < tr_lines_.size() - 1; i++)
447 if (*tr_lines_[i] == *tr_lines_[tr_lines_.size() - 1]) {
449 res = true;
450 }
451
452 return res;
453}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Set() [1/12]

void data_tools::DataManager::Set ( const std::vector< lib::Hill > & hills)
209 {
210 hills_.clear();
211 Add(hills);
212
215}
bool RemoveAllDuplicates()
Удаляет все повторяющиеся объекты в векторах объектов
Definition data_manager.cpp:455
Here is the call graph for this function:

◆ Set() [2/12]

void data_tools::DataManager::Set ( const std::vector< lib::Target > & targets)
119 {
120 targets_.clear();
121 Add(targets);
122
125}
Here is the call graph for this function:

◆ Set() [3/12]

void data_tools::DataManager::Set ( const std::vector< lib::TrappyCircle > & tr_circles)
299 {
300 tr_circles_.clear();
301 Add(tr_circles);
302
305}
Here is the call graph for this function:

◆ Set() [4/12]

void data_tools::DataManager::Set ( const std::vector< lib::TrappyLine > & tr_lines)
389 {
390 tr_lines_.clear();
391 Add(tr_lines);
392
395}
Here is the call graph for this function:

◆ Set() [5/12]

void data_tools::DataManager::Set ( std::vector< gui::Hill * > hills)
193 {
194 hills_.clear();
195 Add(hills);
196
199}
Here is the call graph for this function:

◆ Set() [6/12]

void data_tools::DataManager::Set ( std::vector< gui::Target * > targets)
103 {
104 targets_.clear();
105 Add(targets);
106
109}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Set() [7/12]

void data_tools::DataManager::Set ( std::vector< gui::TrappyCircle * > tr_circles)
283 {
284 tr_circles_.clear();
285 Add(tr_circles);
286
289}
Here is the call graph for this function:

◆ Set() [8/12]

void data_tools::DataManager::Set ( std::vector< gui::TrappyLine * > tr_lines)
373 {
374 tr_lines_.clear();
375 Add(tr_lines);
376
379}
Here is the call graph for this function:

◆ Set() [9/12]

void data_tools::DataManager::Set ( std::vector< lib::Hill > & hills)
201 {
202 hills_.clear();
203 Add(hills);
204
207}
Here is the call graph for this function:

◆ Set() [10/12]

void data_tools::DataManager::Set ( std::vector< lib::Target > & targets)
111 {
112 targets_.clear();
113 Add(targets);
114
117}
Here is the call graph for this function:

◆ Set() [11/12]

void data_tools::DataManager::Set ( std::vector< lib::TrappyCircle > & tr_circles)
291 {
292 tr_circles_.clear();
293 Add(tr_circles);
294
297}
Here is the call graph for this function:

◆ Set() [12/12]

void data_tools::DataManager::Set ( std::vector< lib::TrappyLine > & tr_lines)
381 {
382 tr_lines_.clear();
383 Add(tr_lines);
384
387}
Here is the call graph for this function:

Member Data Documentation

◆ hills_

std::vector<std::unique_ptr<gui::Hill> > data_tools::DataManager::hills_
private

◆ targets_

std::vector<std::unique_ptr<gui::Target> > data_tools::DataManager::targets_
private

◆ tr_circles_

std::vector<std::unique_ptr<gui::TrappyCircle> > data_tools::DataManager::tr_circles_
private

◆ tr_lines_

std::vector<std::unique_ptr<gui::TrappyLine> > data_tools::DataManager::tr_lines_
private

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