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) {
static Line* first = nullptr;
Line* found = findAt(scene);
if (!found) {
first = nullptr;
current_line = nullptr;
return;
}
if (!first) {
first = found;
if (!current_line) {
current_line = found;
return;
}
if (found == first){
first = nullptr;
if (found == current_line){
current_line = nullptr;
return;
}
if (!areAlreadyParallel(found, first)) {
sys.addConstraintParallel(*found, *first, constraints_count++);
parallelPairs.insert(makeOrderedPair(found, first));
first = nullptr;
if (!areAlreadyParallel(found, current_line)) {
sys.addConstraintParallel(*found, *current_line, constraints_count++);
parallelPairs.insert(makeOrderedPair(found, current_line));
current_line = nullptr;
mode = Mode::None;
}
else {
#ifdef _DEBUG
qDebug() << "Line" << first << "and" << found << "are parallel. Abort!";
qDebug() << "Line" << current_line << "and" << found << "are parallel. Abort!";
#endif
QMessageBox::warning(this,
QString("Wrong"),
QString("Parallel lines can not be more parallel!"),
QMessageBox::Ok
);
first = nullptr;
current_line = nullptr;
return;
}