Skip to content

Commit

Permalink
Replace manual comparisons with standard library tools
Browse files Browse the repository at this point in the history
  • Loading branch information
wawuwo committed Mar 8, 2024
1 parent 36f0bd9 commit 44ef1f7
Showing 1 changed file with 28 additions and 56 deletions.
84 changes: 28 additions & 56 deletions qucs/schematic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,14 +1304,10 @@ QRect Schematic::sizeOfSelection() const
}
isAnySelected = true;
pc->entireBounds(x1, y1, x2, y2);
if (x1 < xmin)
xmin = x1;
if (x2 > xmax)
xmax = x2;
if (y1 < ymin)
ymin = y1;
if (y2 > ymax)
ymax = y2;
xmin = std::min(x1, xmin);
xmax = std::max(x2, xmax);
ymin = std::min(y1, ymin);
ymax = std::max(y2, ymax);
}

// find boundings of all wires
Expand All @@ -1320,25 +1316,17 @@ QRect Schematic::sizeOfSelection() const
continue;
}
isAnySelected = true;
if (pw->x1 < xmin)
xmin = pw->x1;
if (pw->x2 > xmax)
xmax = pw->x2;
if (pw->y1 < ymin)
ymin = pw->y1;
if (pw->y2 > ymax)
ymax = pw->y2;
xmin = std::min(pw->x1, xmin);
xmax = std::max(pw->x2, xmax);
ymin = std::min(pw->y1, ymin);
ymax = std::max(pw->y2, ymax);

if (auto *pl = pw->Label; pl) { // check position of wire label
pl->getLabelBounding(x1, y1, x2, y2);
if (x1 < xmin)
xmin = x1;
if (x2 > xmax)
xmax = x2;
if (y1 < ymin)
ymin = y1;
if (y2 > ymax)
ymax = y2;
xmin = std::min(x1, xmin);
xmax = std::max(x2, xmax);
ymin = std::min(y1, ymin);
ymax = std::max(y2, ymax);
}
}

Expand All @@ -1351,14 +1339,10 @@ QRect Schematic::sizeOfSelection() const
if (auto *pl = pn->Label; pl) { // check position of node label
isAnySelected = true;
pl->getLabelBounding(x1, y1, x2, y2);
if (x1 < xmin)
xmin = x1;
if (x2 > xmax)
xmax = x2;
if (y1 < ymin)
ymin = y1;
if (y2 > ymax)
ymax = y2;
xmin = std::min(x1, xmin);
xmax = std::max(x2, xmax);
ymin = std::min(y1, ymin);
ymax = std::max(y2, ymax);
}
}

Expand All @@ -1369,27 +1353,19 @@ QRect Schematic::sizeOfSelection() const
}
isAnySelected = true;
pd->Bounding(x1, y1, x2, y2);
if (x1 < xmin)
xmin = x1;
if (x2 > xmax)
xmax = x2;
if (y1 < ymin)
ymin = y1;
if (y2 > ymax)
ymax = y2;
xmin = std::min(x1, xmin);
xmax = std::max(x2, xmax);
ymin = std::min(y1, ymin);
ymax = std::max(y2, ymax);

for (Graph *pg : pd->Graphs)
// test all markers of diagram
for (Marker *pm : pg->Markers) {
pm->Bounding(x1, y1, x2, y2);
if (x1 < xmin)
xmin = x1;
if (x2 > xmax)
xmax = x2;
if (y1 < ymin)
ymin = y1;
if (y2 > ymax)
ymax = y2;
xmin = std::min(x1, xmin);
xmax = std::max(x2, xmax);
ymin = std::min(y1, ymin);
ymax = std::max(y2, ymax);
}
}

Expand All @@ -1400,14 +1376,10 @@ QRect Schematic::sizeOfSelection() const
}
isAnySelected = true;
pp->Bounding(x1, y1, x2, y2);
if (x1 < xmin)
xmin = x1;
if (x2 > xmax)
xmax = x2;
if (y1 < ymin)
ymin = y1;
if (y2 > ymax)
ymax = y2;
xmin = std::min(x1, xmin);
xmax = std::max(x2, xmax);
ymin = std::min(y1, ymin);
ymax = std::max(y2, ymax);
}

if (!isAnySelected) {
Expand Down

0 comments on commit 44ef1f7

Please sign in to comment.