Skip to content

Commit

Permalink
fix: FS#1147 - View > Zoom to selection with only vertical / horizont…
Browse files Browse the repository at this point in the history
…al line
  • Loading branch information
qcad committed Dec 13, 2014
1 parent 796f514 commit 8ab591e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/RGraphicsView.cpp
Expand Up @@ -203,7 +203,7 @@ bool RGraphicsView::zoomToSelection() {
return false;
}
RBox selectionBox = document->getSelectionBox();
if (selectionBox.isValid() && selectionBox.getWidth()>RS::PointTolerance && selectionBox.getHeight()>RS::PointTolerance) {
if (selectionBox.isValid() && (selectionBox.getWidth()>RS::PointTolerance || selectionBox.getHeight()>RS::PointTolerance)) {
zoomTo(selectionBox, getMargin());
return true;
}
Expand Down Expand Up @@ -280,12 +280,16 @@ void RGraphicsView::zoomTo(const RBox& window, int margin) {

saveViewport();

RVector f;
RVector f(RMAXDOUBLE, RMAXDOUBLE);
double w = window.getWidth();
double h = window.getHeight();

f.x = (getWidth() - 2 * margin) / w;
f.y = (getHeight() - 2 * margin) / h;
if (w>1.0e-6) {
f.x = (getWidth() - 2 * margin) / w;
}
if (h>1.0e-6) {
f.y = (getHeight() - 2 * margin) / h;
}

f.x = f.y = qMin(f.x, f.y);

Expand Down

0 comments on commit 8ab591e

Please sign in to comment.