Refactoring
А я отдыхать
This commit is contained in:
23
Canvas.cpp
23
Canvas.cpp
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user