checkpoint
[anneal.git] / src / edu / berkeley / qfat / Viewer.java
index 89ba7b3..1464020 100644 (file)
@@ -18,17 +18,16 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
     public Mesh tile = new Mesh(false);
     public Mesh goal = new Mesh(false);
 
+    private int mousex;
+    private int mousey;
     private Matrix projection = null;
 
     JFrame f;
     GLCanvas glcanvas;
-    Point clickPoint = null;
+
+    private Point clickPoint = null;
     Point clickClosest = null;
 
-    int mousex;
-    int mousey;
-    float tx = 0;
-    float ty = 0;
     float tz = 0;
     float anglex = 0;
     float angley = 0;
@@ -119,12 +118,16 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
         gl.glDrawBuffer(GL.GL_FRONT);
     }
 
-
     /** return the position of the mouse as a point in window-space */
     public Point getMouse() {
         return new Point(mousex, glcanvas.getHeight()-mousey, 0);
     }
 
+    /** return the position where the mouse button was pressed, or null if it is not currently pressed */
+    public Point getMouseClick() {
+        return clickPoint;
+    }
+
     public void mouseWheelMoved(MouseWheelEvent e) {
         tz -= e.getWheelRotation();
     }
@@ -166,17 +169,11 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
 
     public void mouseDragged(MouseEvent e) {
         if (shift) {
-            /*
-            tx += (mousex - e.getX())/(float)20;
-            ty += (mousey - e.getY())/(float)20;
-            */
             if (closest != null && projection != null && clickClosest != null) {
                 synchronized(this) {
                     Vec d1 = projection.inverse().times(getMouse()).minus(projection.inverse().times(clickPoint));
                     Vec delta = d1.plus(clickClosest).minus(closest.getPoint());
-                    //System.out.println(delta + " " + closest.getPoint());
-                    System.out.println(getMouse().minus(clickPoint));
-                    closest.move(Matrix.translate(delta), false);
+                    closest.move(delta, false);
                 }
             }
         } else {