Fix rubberbox coordinates
[scilab.git] / scilab / modules / renderer / src / java / org / scilab / modules / renderer / JoGLView / interaction / RubberBox.java
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;
+    }
 }