Fix rubberbox coordinates 17/15017/3
Bruno JOFRET [Fri, 8 Aug 2014 15:41:16 +0000 (17:41 +0200)]
Change-Id: I54e935e853e00c0815d9fe0b4f342d982c0c586e

scilab/CHANGES_5.5.X
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DrawerVisitor.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/interaction/OnePointRubberBox.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/interaction/RubberBox.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/interaction/TwoPointsRubberBox.java

index 48c7edc..ac8f5d8 100644 (file)
@@ -190,6 +190,8 @@ Scilab Bug Fixes
 
 * Bug #13527 fixed - hilb did not check correctly the type of first input argument.
 
+* Bug #13554 fixed - rubberbox returns wrong values.
+
 
 Xcos Bug Fixes
 ==============
index 342d305..20a1985 100755 (executable)
@@ -1251,6 +1251,10 @@ public class DrawerVisitor implements Visitor, Drawer, GraphicView {
         return figure;
     }
 
+    public Axes getAxes() {
+        return currentAxes;
+    }
+
     private Geometry cube;
     public Geometry getCube() {
         if (cube == null) {
index 8dc4d2a..cc2d9c1 100644 (file)
@@ -34,26 +34,15 @@ public class OnePointRubberBox extends RubberBox implements PointRubberBox {
 
     public OnePointRubberBox(DrawerVisitor drawerVisitor, double initialRect[]) {
         super(drawerVisitor);
-        firstPoint = new Vector3d(initialRect[0], initialRect[1], 0);
+        double[][] factors = axes.getScaleTranslateFactors();
+        firstPoint = new Vector3d(initialRect[0] * factors[0][0] + factors[1][0],
+                initialRect[1] * factors[0][1] + factors[1][1],
+                0);
         secondPoint = firstPoint;
         status = Status.WAIT_POINT_B;
         setEnable(true);
     }
 
-    public double[] getResults() {
-        double result[] = {
-            mouseButton - 1,
-            Math.min(firstPoint.getX(), secondPoint.getX()),
-            Math.max(firstPoint.getY(), secondPoint.getY()),
-            Math.max(firstPoint.getZ(), secondPoint.getZ()),
-            Math.abs(firstPoint.getX() - secondPoint.getX()),
-            Math.abs(firstPoint.getY() - secondPoint.getY()),
-            Math.abs(firstPoint.getZ() - secondPoint.getZ())
-        };
-
-        return result;
-    }
-
     @Override
     public void mouseClicked(MouseEvent e) {
         mouseButton = e.getButton();
index 32cc099..d62bf47 100644 (file)
@@ -122,6 +122,7 @@ public class RubberBox extends FigureInteraction implements PostRendered, MouseL
      */
     protected RubberBox(DrawerVisitor drawerVisitor) {
         super(drawerVisitor);
+        axes = drawerVisitor.getAxes();
         status = Status.WAIT_POINT_A;
     }
 
@@ -520,4 +521,19 @@ public class RubberBox extends FigureInteraction implements PostRendered, MouseL
     @Override
     public void keyReleased(KeyEvent e) {
     }
+    
+    public double[] getResults() {
+        double[][] factors = axes.getScaleTranslateFactors();
+        double result[] = {
+            mouseButton - 1,
+            (Math.min(firstPoint.getX(), secondPoint.getX()) - factors[1][0]) / factors[0][0],
+            (Math.max(firstPoint.getY(), secondPoint.getY()) - factors[1][1]) / factors[0][1],
+            (Math.max(firstPoint.getZ(), secondPoint.getZ()) - factors[1][2]) / factors[0][2],
+            (Math.abs(firstPoint.getX() - secondPoint.getX())) / factors[0][0],
+            (Math.abs(firstPoint.getY() - secondPoint.getY())) / factors[0][1],
+            (Math.abs(firstPoint.getZ() - secondPoint.getZ())) / factors[0][2]
+        };
+
+        return result;
+    }
 }
index e6d741b..2031461 100644 (file)
@@ -27,17 +27,4 @@ public class TwoPointsRubberBox extends RubberBox implements PointRubberBox {
         super(drawerVisitor);
     }
 
-    public double[] getResults() {
-        double result[] = {
-            mouseButton - 1,
-            Math.min(firstPoint.getX(), secondPoint.getX()),
-            Math.max(firstPoint.getY(), secondPoint.getY()),
-            Math.max(firstPoint.getZ(), secondPoint.getZ()),
-            Math.abs(firstPoint.getX() - secondPoint.getX()),
-            Math.abs(firstPoint.getY() - secondPoint.getY()),
-            Math.abs(firstPoint.getZ() - secondPoint.getZ())
-        };
-
-        return result;
-    }
 }