Fix bug on surface selection in ged 76/12776/1
Calixte DENIZET [Tue, 1 Oct 2013 15:12:08 +0000 (17:12 +0200)]
Change-Id: Ie617cdceff21f4fc05dc5f0ee15408f7f8239420

scilab/modules/gui/src/java/org/scilab/modules/gui/editor/GEDPicker.java

index ca2af37..cd06ca9 100644 (file)
@@ -241,7 +241,7 @@ public class GEDPicker {
     /**
      * Surface picker, given a plot3d/fac3d/grayplot/matplot object it checks if the click
      * was over it
-     *
+     * 
      * @param obj The given surface object uid
      * @param position Mouse click position in pixels
      * @return true if picked the surface otherwise returns false
@@ -250,9 +250,13 @@ public class GEDPicker {
 
         String figure = (String)GraphicController.getController().getProperty(obj, GraphicObjectProperties.__GO_PARENT_FIGURE__);
         double[] mat = DrawerVisitor.getVisitor(figure).getAxesDrawer().getProjection(axesUID).getMatrix();
+       double[][] factors = axes.getScaleTranslateFactors();
 
         Vector3d v0 = AxesDrawer.unProject(axes, new Vector3d(1.0f * position[0], 1.0f * position[1], 0.0));
         Vector3d v1 = AxesDrawer.unProject(axes, new Vector3d(1.0f * position[0], 1.0f * position[1], 1.0));
+       v0 = new Vector3d((v0.getX() - factors[1][0]) / factors[0][0], (v0.getY() - factors[1][1]) / factors[0][1], (v0.getZ() - factors[1][2]) / factors[0][2]);
+       v1 = new Vector3d((v1.getX() - factors[1][0]) / factors[0][0], (v1.getY() - factors[1][1]) / factors[0][1], (v1.getZ() - factors[1][2]) / factors[0][2]);
+       
         Vector3d Dir = v0.minus(v1).getNormalized();
         Z = 2.0;
         double curZ = SurfaceData.pickSurface(obj, v0.getX(), v0.getY(), v0.getZ(),