]> OCCT Git - occt.git/commitdiff
0026357: Visualization - Panning zooms view if aspect ratio > 1
authorapl <apl@opencascade.com>
Fri, 19 Jun 2015 12:15:11 +0000 (15:15 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 25 Jun 2015 10:05:59 +0000 (13:05 +0300)
src/Graphic3d/Graphic3d_Camera.cxx
tests/bugs/vis/bug26357 [new file with mode: 0644]

index 19ee995ea89fbc78eb504ba1fafc205e50682982..eb4b85ea50c8f741fbde322537ae3152264e1522 100644 (file)
@@ -559,8 +559,18 @@ gp_Pnt Graphic3d_Camera::ConvertView2World (const gp_Pnt& thePnt) const
 gp_XYZ Graphic3d_Camera::ViewDimensions() const
 {
   // view plane dimensions
-  Standard_Real aSizeY = IsOrthographic() ? myScale : (2.0 * Distance() * Tan (DTR_HALF * myFOVy));
-  Standard_Real aSizeX = myAspect * aSizeY;
+  Standard_Real aSize = IsOrthographic() ? myScale : (2.0 * Distance() * Tan (DTR_HALF * myFOVy));
+  Standard_Real aSizeX, aSizeY;
+  if (myAspect > 1.0)
+  {
+    aSizeX = aSize * myAspect;
+    aSizeY = aSize;
+  }
+  else
+  {
+    aSizeX = aSize;
+    aSizeY = aSize / myAspect;
+  }
 
   // and frustum depth
   return gp_XYZ (aSizeX, aSizeY, myZFar - myZNear);
diff --git a/tests/bugs/vis/bug26357 b/tests/bugs/vis/bug26357
new file mode 100644 (file)
index 0000000..465346c
--- /dev/null
@@ -0,0 +1,51 @@
+puts "============"
+puts "CR26357"
+puts "============"
+puts ""
+
+#########################################################################
+puts "Panning regression after fixing 0026082"
+#########################################################################
+
+box b 100 100 100
+
+vinit View1 w=400 h=400
+vinit View2 w=200 h=400
+vinit View3 w=400 h=200
+vclear
+vaxo
+
+vdisplay b
+
+# Test panning with aspect ratio 1:1
+vactivate View1
+vfit
+vpan        200 0
+vmoveto     399 200
+checkcolor  399 200 0 1 1
+vpan       -200 0
+vmoveto     200 200
+checkcolor  200 200 0 1 1
+vdump ${imagedir}/${casename}_1.png
+
+# Test panning with aspect ratio 1:2
+vactivate View2
+vfit
+vpan        100 0
+vmoveto     199 100
+checkcolor  199 100 0 1 1
+vpan       -100 0
+vmoveto     100 100
+checkcolor  100 100 0 1 1
+vdump ${imagedir}/${casename}_2.png
+
+# Test panning with aspect ratio 2:1
+vactivate View3
+vfit
+vpan        200 0
+vmoveto     399 100
+checkcolor  399 100 0 1 1
+vpan       -200 0
+vmoveto     200 100
+checkcolor  200 100 0 1 1
+vdump ${imagedir}/${casename}_3.png