Refactoring

А я отдыхать
This commit is contained in:
2025-12-07 16:55:52 +03:00
parent ff06fd1db7
commit 8f7dfb2a45

View File

@@ -90,42 +90,41 @@ void Canvas::mousePressEvent(QMouseEvent* event)
} }
else if (mode == Mode::Parallel) { else if (mode == Mode::Parallel) {
static Line* first = nullptr;
Line* found = findAt(scene); Line* found = findAt(scene);
if (!found) { if (!found) {
first = nullptr; current_line = nullptr;
return; return;
} }
if (!first) { if (!current_line) {
first = found; current_line = found;
return; return;
} }
if (found == first){ if (found == current_line){
first = nullptr; current_line = nullptr;
return; return;
} }
if (!areAlreadyParallel(found, first)) { if (!areAlreadyParallel(found, current_line)) {
sys.addConstraintParallel(*found, *first, constraints_count++); sys.addConstraintParallel(*found, *current_line, constraints_count++);
parallelPairs.insert(makeOrderedPair(found, first)); parallelPairs.insert(makeOrderedPair(found, current_line));
first = nullptr; current_line = nullptr;
mode = Mode::None; mode = Mode::None;
} }
else { else {
#ifdef _DEBUG #ifdef _DEBUG
qDebug() << "Line" << first << "and" << found << "are parallel. Abort!"; qDebug() << "Line" << current_line << "and" << found << "are parallel. Abort!";
#endif #endif
QMessageBox::warning(this, QMessageBox::warning(this,
QString("Wrong"), QString("Wrong"),
QString("Parallel lines can not be more parallel!"), QString("Parallel lines can not be more parallel!"),
QMessageBox::Ok QMessageBox::Ok
); );
first = nullptr; current_line = nullptr;
return; return;
} }