Skip to content

Commit fc1eac5

Browse files
committed
finish macrocing in data_manager.cpp and update names for private methods everywhere
1 parent adc575d commit fc1eac5

39 files changed

+379
-549
lines changed

data_tools/data_manager/data_manager.cpp

Lines changed: 164 additions & 327 deletions
Large diffs are not rendered by default.

data_tools/data_manager/data_manager.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class DataManager {
2323
// ---------------------- Target methods ----------------------
2424

2525
// for gui::Target
26-
void Add(gui::Target* t);
26+
void Add(gui::Target* target_ptr);
2727
void Add(std::vector<gui::Target*>);
2828
void Set(std::vector<gui::Target*>);
2929

@@ -52,7 +52,7 @@ class DataManager {
5252
// ---------------------- Hill methods ----------------------
5353

5454
// for gui::Hill
55-
void Add(gui::Hill* h);
55+
void Add(gui::Hill* hill_ptr);
5656
void Add(std::vector<gui::Hill*>);
5757
void Set(std::vector<gui::Hill*>);
5858

@@ -81,7 +81,7 @@ class DataManager {
8181
// ---------------------- TrappyCircle methods ----------------------
8282

8383
// for gui::TrappyCircle
84-
void Add(gui::TrappyCircle* tr_c);
84+
void Add(gui::TrappyCircle* trappy_circle);
8585
void Add(std::vector<gui::TrappyCircle*>);
8686
void Set(std::vector<gui::TrappyCircle*>);
8787

@@ -110,7 +110,7 @@ class DataManager {
110110
// ---------------------- TrappyLine methods ----------------------
111111

112112
// for gui::TrappyLine
113-
void Add(gui::TrappyLine* tr_l);
113+
void Add(gui::TrappyLine* trappy_line);
114114
void Add(std::vector<gui::TrappyLine*>);
115115
void Set(std::vector<gui::TrappyLine*>);
116116

@@ -151,19 +151,19 @@ class DataManager {
151151
*/
152152
bool RemoveAllDuplicates();
153153

154-
unsigned short GetMinId(gui::ObjectType obj_type);
155-
156154
private:
157155
/**
158156
* @brief Проверяет данные в DataManager на валидность
159157
* @throw std::invalid_argument: если объектов какого-либо вектора > 10000
160158
*/
161-
void CheckErrorValues();
159+
void CheckErrorValues_();
160+
161+
unsigned short GetMinId_(gui::ObjectType obj_type);
162162

163163
std::vector<std::unique_ptr<gui::Hill>> hills_;
164164
std::vector<std::unique_ptr<gui::Target>> targets_;
165-
std::vector<std::unique_ptr<gui::TrappyCircle>> tr_circles_;
166-
std::vector<std::unique_ptr<gui::TrappyLine>> tr_lines_;
165+
std::vector<std::unique_ptr<gui::TrappyCircle>> trappy_circles_;
166+
std::vector<std::unique_ptr<gui::TrappyLine>> trappy_lines_;
167167
};
168168

169169
} // namespace data_tools

data_tools/plot_area/check_errors.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bool IsPointInsideHill(lib::Point point, std::vector<lib::Point> vertices) {
2222
return inside;
2323
}
2424

25-
void PlotArea::CheckIntersectionsBetweenTrappyCircles() {
25+
void PlotArea::CheckIntersectionsBetweenTrappyCircles_() {
2626
if (manager_->GetTrappyCircles().empty()) return;
2727

2828
for (size_t i = 0; i < manager_->GetTrappyCircles().size() - 1; i++) {
@@ -44,7 +44,7 @@ void PlotArea::CheckIntersectionsBetweenTrappyCircles() {
4444
}
4545
}
4646

47-
void PlotArea::CheckIntersectionsBetweenHills() {
47+
void PlotArea::CheckIntersectionsBetweenHills_() {
4848
if (manager_->GetHillsPtrs().empty()) return;
4949

5050
for (size_t i = 0; i < manager_->GetHills().size() - 1; i++) {
@@ -75,9 +75,9 @@ void PlotArea::CheckIntersectionsBetweenHills() {
7575
}
7676
}
7777

78-
void PlotArea::CheckTrappyCircles() {
78+
void PlotArea::CheckTrappyCircles_() {
7979
// Проверка на пересечения с другими TrappyCircle
80-
CheckIntersectionsBetweenTrappyCircles();
80+
CheckIntersectionsBetweenTrappyCircles_();
8181

8282
if (manager_->GetTrappyCircles().empty()) return;
8383

@@ -118,7 +118,7 @@ void PlotArea::CheckTrappyCircles() {
118118
}
119119
}
120120

121-
void PlotArea::CheckTrappyLines() {
121+
void PlotArea::CheckTrappyLines_() {
122122
auto l = manager_->GetTrappyLinesPtrs().size();
123123
auto n = manager_->GetTargetsPtrs().size() + amount_of_robots_ - 1;
124124
if (l == 0) return;
@@ -128,7 +128,7 @@ void PlotArea::CheckTrappyLines() {
128128
throw std::invalid_argument("There are too many TrappyLines here!");
129129
}
130130

131-
void PlotArea::CheckTargets() {
131+
void PlotArea::CheckTargets_() {
132132
if (manager_->GetTargetsPtrs().size() > 30) {
133133
std::string text = "There are too many Targets: ";
134134
text += std::to_string(manager_->GetTargetsPtrs().size());
@@ -138,10 +138,10 @@ void PlotArea::CheckTargets() {
138138
}
139139
}
140140

141-
void PlotArea::CheckHills() {
141+
void PlotArea::CheckHills_() {
142142
for (const auto& hill : manager_->GetHills()) {
143143
// Проверка на пересечения с другими Hill
144-
CheckIntersectionsBetweenHills();
144+
CheckIntersectionsBetweenHills_();
145145

146146
// Проверка на выпуклость многоугольника
147147
// Определяем знак векторного произведения

data_tools/plot_area/plot_area.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ void PlotArea::ReDrawTrajectory() {
2828
ReDraw();
2929

3030
try {
31-
CheckTrappyCircles();
32-
CheckHills();
33-
CheckTrappyLines();
34-
CheckTargets();
31+
CheckTrappyCircles_();
32+
CheckHills_();
33+
CheckTrappyLines_();
34+
CheckTargets_();
3535

36-
CalculateTrajectory();
36+
CalculateTrajectory_();
3737
trajectory_->Draw(plot_.get());
3838
plot_->replot();
3939
} catch (const std::exception& e) {
4040
QMessageBox::warning(plot_.get(), "Cannot calculate trajectory!", e.what());
4141
}
4242
}
4343

44-
void PlotArea::CalculateTrajectory() {
44+
void PlotArea::CalculateTrajectory_() {
4545
auto lib_targets = std::vector<lib::Target>(manager_->GetTargets().size());
4646
for (size_t i = 0; i < lib_targets.size(); i++)
4747
lib_targets[i] = manager_->GetTargets()[i].GetData();

data_tools/plot_area/plot_area.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PlotArea {
3838

3939
private:
4040
/// @brief Расчет вектора сегментов по заданным объектам на полотне
41-
void CalculateTrajectory();
41+
void CalculateTrajectory_();
4242

4343
// i love unique_ptr's, i love logic schemes
4444
std::unique_ptr<QCustomPlot> plot_;
@@ -49,12 +49,13 @@ class PlotArea {
4949

5050
unsigned short amount_of_robots_ = 1;
5151

52-
void CheckHills();
53-
void CheckTrappyCircles();
54-
void CheckTrappyLines();
55-
void CheckTargets();
56-
void CheckIntersectionsBetweenTrappyCircles();
57-
void CheckIntersectionsBetweenHills();
52+
void CheckHills_();
53+
void CheckTrappyCircles_();
54+
void CheckTrappyLines_();
55+
void CheckTargets_();
56+
57+
void CheckIntersectionsBetweenTrappyCircles_();
58+
void CheckIntersectionsBetweenHills_();
5859
};
5960

6061
} // namespace data_tools

data_tools/tables_connection/tables_connection.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ void TablesConnection::Setup(DataManager* manager, PlotArea* area) {
1010

1111
// MARK: U.T. by Targets
1212

13-
void TablesConnection::UpdateTable(const std::vector<gui::Target>& targets) {
14-
DisableTablesConnections();
13+
void TablesConnection::UpdateTable_(const std::vector<gui::Target>& targets) {
14+
DisableTablesConnections_();
1515

1616
if (targets.empty()) {
1717
targets_table_->setColumnCount(0);
@@ -46,13 +46,13 @@ void TablesConnection::UpdateTable(const std::vector<gui::Target>& targets) {
4646
}
4747

4848
targets_table_->update();
49-
UpdateTablesConnections();
49+
UpdateTablesConnections_();
5050
}
5151

5252
// MARK: U.T. by Hills
5353

54-
void TablesConnection::UpdateTable(const std::vector<gui::Hill>& hills) {
55-
DisableTablesConnections();
54+
void TablesConnection::UpdateTable_(const std::vector<gui::Hill>& hills) {
55+
DisableTablesConnections_();
5656

5757
if (hills.empty()) {
5858
hills_table_->setColumnCount(0);
@@ -110,14 +110,14 @@ void TablesConnection::UpdateTable(const std::vector<gui::Hill>& hills) {
110110
}
111111

112112
hills_table_->update();
113-
UpdateTablesConnections();
113+
UpdateTablesConnections_();
114114
}
115115

116116
// MARK: U.T. by Tr. Lines
117117

118-
void TablesConnection::UpdateTable(
118+
void TablesConnection::UpdateTable_(
119119
const std::vector<gui::TrappyLine>& trappy_lines) {
120-
DisableTablesConnections();
120+
DisableTablesConnections_();
121121

122122
if (trappy_lines.empty()) {
123123
tr_lines_table_->setColumnCount(0);
@@ -176,14 +176,14 @@ void TablesConnection::UpdateTable(
176176
}
177177

178178
tr_lines_table_->update();
179-
UpdateTablesConnections();
179+
UpdateTablesConnections_();
180180
}
181181

182182
// MARK: U.T. by Tr. Circles
183183

184-
void TablesConnection::UpdateTable(
184+
void TablesConnection::UpdateTable_(
185185
const std::vector<gui::TrappyCircle>& trappy_circles) {
186-
DisableTablesConnections();
186+
DisableTablesConnections_();
187187

188188
if (trappy_circles.empty()) {
189189
tr_circles_table_->setColumnCount(0);
@@ -226,25 +226,25 @@ void TablesConnection::UpdateTable(
226226
}
227227

228228
tr_circles_table_->update();
229-
UpdateTablesConnections();
229+
UpdateTablesConnections_();
230230
}
231231

232232
void TablesConnection::UpdateTable(gui::ObjectType obj_type) {
233233
switch (obj_type) {
234234
case gui::ObjectType::Targets:
235-
UpdateTable(manager_->GetTargets());
235+
UpdateTable_(manager_->GetTargets());
236236
break;
237237

238238
case gui::ObjectType::Hills:
239-
UpdateTable(manager_->GetHills());
239+
UpdateTable_(manager_->GetHills());
240240
break;
241241

242242
case gui::ObjectType::TrappyCircles:
243-
UpdateTable(manager_->GetTrappyCircles());
243+
UpdateTable_(manager_->GetTrappyCircles());
244244
break;
245245

246246
case gui::ObjectType::TrappyLines:
247-
UpdateTable(manager_->GetTrappyLines());
247+
UpdateTable_(manager_->GetTrappyLines());
248248
break;
249249
}
250250
}
@@ -255,7 +255,7 @@ void TablesConnection::UpdateTables() {
255255
UpdateTable(gui::ObjectType::TrappyCircles);
256256
UpdateTable(gui::ObjectType::TrappyLines);
257257

258-
UpdateTablesConnections();
258+
UpdateTablesConnections_();
259259
}
260260

261261
// TODO: переписать так, чтобы оно меняло конкретное поле, а не целую точку
@@ -401,49 +401,49 @@ void TablesConnection::TrappyLinesItemChanged(int row, int column) {
401401
// MARK: Remove Items
402402

403403
void TablesConnection::RemoveTargetItem() {
404-
DisableTablesConnections();
404+
DisableTablesConnections_();
405405

406406
manager_->Remove(gui::ObjectType::Targets, selected_column_);
407407
area_->ReDraw();
408408
UpdateTable(gui::ObjectType::Targets);
409409
UpdateTable(gui::ObjectType::TrappyLines);
410410

411-
UpdateTablesConnections();
411+
UpdateTablesConnections_();
412412
}
413413

414414
void TablesConnection::RemoveHillItem() {
415-
DisableTablesConnections();
415+
DisableTablesConnections_();
416416

417417
manager_->Remove(gui::ObjectType::Hills, selected_column_);
418418
area_->ReDraw();
419419
UpdateTable(gui::ObjectType::Hills);
420420

421-
UpdateTablesConnections();
421+
UpdateTablesConnections_();
422422
}
423423

424424
void TablesConnection::RemoveTrappyCircleItem() {
425-
DisableTablesConnections();
425+
DisableTablesConnections_();
426426

427427
manager_->Remove(gui::ObjectType::TrappyCircles, selected_column_);
428428
area_->ReDraw();
429429
UpdateTable(gui::ObjectType::TrappyCircles);
430430

431-
UpdateTablesConnections();
431+
UpdateTablesConnections_();
432432
}
433433

434434
void TablesConnection::RemoveTrappyLineItem() {
435-
DisableTablesConnections();
435+
DisableTablesConnections_();
436436

437437
manager_->Remove(gui::ObjectType::TrappyLines, selected_column_);
438438
area_->ReDraw();
439439
UpdateTable(gui::ObjectType::TrappyLines);
440440

441-
UpdateTablesConnections();
441+
UpdateTablesConnections_();
442442
}
443443

444444
// MARK: Update Connections
445445

446-
void TablesConnection::UpdateTablesConnections() {
446+
void TablesConnection::UpdateTablesConnections_() {
447447
QObject::connect(targets_table_.get(), &QTableWidget::cellChanged, this,
448448
&TablesConnection::TargetsItemChanged);
449449

@@ -457,7 +457,7 @@ void TablesConnection::UpdateTablesConnections() {
457457
&TablesConnection::TrappyLinesItemChanged);
458458
}
459459

460-
void TablesConnection::DisableTablesConnections() {
460+
void TablesConnection::DisableTablesConnections_() {
461461
QObject::disconnect(targets_table_.get(), &QTableWidget::cellChanged, this,
462462
&TablesConnection::TargetsItemChanged);
463463

@@ -471,7 +471,7 @@ void TablesConnection::DisableTablesConnections() {
471471
&TablesConnection::TrappyLinesItemChanged);
472472
}
473473

474-
void TablesConnection::UpdateRemoveButtonConnections() {
474+
void TablesConnection::UpdateRemoveButtonConnections_() {
475475
// активируем кнопки при выборе любой клетки
476476
QObject::connect(targets_table_.get(), &QTableWidget::cellClicked, this,
477477
&TablesConnection::EnableRemoveTargetButton);

0 commit comments

Comments
 (0)