Skip to content

Commit

Permalink
code beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
UmbrellaLeaf5 committed May 9, 2024
1 parent c67bd31 commit f57bfb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
27 changes: 13 additions & 14 deletions main/mainwindow_connections/interaction_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,25 @@ void MainWindow::mousePressSelectSecondTarget(QMouseEvent* mouse_event) {
if (ui->plot->selectedGraphs().empty()) return;

for (const auto& t_ptr : manager_->GetTargetsPtrs()) {
if (t_ptr->GetGraphPtr() == ui->plot->selectedGraphs()[0]) {
size_t last = manager_->GetTrappyLines().size() - 1;
if (t_ptr->GetGraphPtr() != ui->plot->selectedGraphs()[0]) continue;

// если это та же точка - пропускаем
if (manager_->GetTrappyLinesPtrs()[last]->GetTargetsPtrs().second ==
t_ptr)
continue;
size_t last = manager_->GetTrappyLines().size() - 1;

manager_->GetTrappyLinesPtrs()[last]->SetSecondTarget(t_ptr);
// если это та же точка - пропускаем
if (manager_->GetTrappyLinesPtrs()[last]->GetTargetsPtrs().second == t_ptr)
continue;

DisconnectObject(gui::ObjectType::TrappyLines);
what_obj_addition_ = WhatObjectAddition::Nothing;
manager_->GetTrappyLinesPtrs()[last]->SetSecondTarget(t_ptr);

area_->Redraw();
DisconnectObject(gui::ObjectType::TrappyLines);
what_obj_addition_ = WhatObjectAddition::Nothing;

// после финального добавления обновляем таблицу
t_connection_->UpdateTable(gui::ObjectType::TrappyLines);
area_->Redraw();

return;
}
// после финального добавления обновляем таблицу
t_connection_->UpdateTable(gui::ObjectType::TrappyLines);

return;
}
}

Expand Down
11 changes: 8 additions & 3 deletions main/mainwindow_connections/other_connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ void MainWindow::on_pushButtonAddHill_clicked() {
}

void MainWindow::on_pushButtonEditObjects_clicked() {
DeleteLastAddedObject();
manager_->RemoveAllDuplicates();
t_connection_->UpdateTables();

ui->plotSettingsDockWidget->setVisible(true);
on_actionBeautify_triggered();
}

void MainWindow::on_actionBeautify_triggered() {
ui->plot->xAxis->setScaleRatio(ui->plot->yAxis, 1.0);
ui->plot->replot();
ui->plot->xAxis->setScaleRatio(ui->plot->yAxis);
area_->Redraw();
}

void MainWindow::on_targetAddFromTablePushButton_clicked() {
Expand All @@ -87,10 +88,12 @@ void MainWindow::on_xAxis_rangeChanged(QCPRange range) {
range.upper = max_scale;
range.lower = max_scale - (range.upper - range.lower);
}

if (range.lower < -max_scale) {
range.lower = -max_scale;
range.upper = -max_scale + (range.upper - range.lower);
}

if (range.upper - range.lower < min_scale) {
double mid = (range.upper + range.lower) / 2;
range.lower = mid - min_scale / 2;
Expand All @@ -105,10 +108,12 @@ void MainWindow::on_yAxis_rangeChanged(QCPRange range) {
range.upper = max_scale;
range.lower = max_scale - (range.upper - range.lower);
}

if (range.lower < -max_scale) {
range.lower = -max_scale;
range.upper = -max_scale + (range.upper - range.lower);
}

if (range.upper - range.lower < min_scale) {
double mid = (range.upper + range.lower) / 2;
range.lower = mid - min_scale / 2;
Expand Down

0 comments on commit f57bfb9

Please sign in to comment.