From c281150b050b1848177e3e2316986ca48644d89f Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 29 Jun 2008 17:09:57 -0700 Subject: [PATCH] checkpoint darcs-hash:20080630000957-5007d-923a1fa7bfa97ab550d25790323f82b6d2e5be0b.gz --- src/edu/berkeley/qfat/MeshViewer.java | 20 +++++++++++++++++-- src/edu/berkeley/qfat/Viewer.java | 35 +++++++++------------------------ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/edu/berkeley/qfat/MeshViewer.java b/src/edu/berkeley/qfat/MeshViewer.java index 5110455..01bb8bb 100644 --- a/src/edu/berkeley/qfat/MeshViewer.java +++ b/src/edu/berkeley/qfat/MeshViewer.java @@ -13,6 +13,24 @@ import edu.berkeley.qfat.geom.Point; public class MeshViewer extends Viewer { + public int whichNeighbor = 1; + + public double temp; + public boolean tileon = true; + public boolean tilemeshon = false; + public boolean goalon = true; + public boolean anneal = false; + public boolean hillclimb = false; + public boolean neighbors = false; + public boolean neighborsWire = false; + public boolean neighborsWireOne = false; + public boolean errorNormals = false; + + public boolean force = false; + public Matrix[] transforms; + public Mesh.Vertex[] points; + public int breaks = 0; + public int temps; public int accepts; public int vertss; @@ -67,8 +85,6 @@ public class MeshViewer extends Viewer { public void _display(GLAutoDrawable drawable, GL gl) { if (transforms==null) return; - - glcanvas.setSize(f.getWidth(), f.getHeight() - 100); Graphics2D g = (Graphics2D)f.getGraphics(); g.setColor(Color.black); diff --git a/src/edu/berkeley/qfat/Viewer.java b/src/edu/berkeley/qfat/Viewer.java index eccb6b6..92be445 100644 --- a/src/edu/berkeley/qfat/Viewer.java +++ b/src/edu/berkeley/qfat/Viewer.java @@ -14,32 +14,12 @@ import edu.berkeley.qfat.geom.Point; public abstract class Viewer implements GLEventListener, MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { Mesh.Vertex closest = null; + Matrix projection = null; - public boolean force = false; public Mesh tile = new Mesh(false); public Mesh goal = new Mesh(false); - public Matrix[] transforms; - public Mesh.Vertex[] points; - - public int whichNeighbor = 1; - - public double temp; - public boolean tileon = true; - public boolean tilemeshon = false; - public boolean goalon = true; - public boolean anneal = false; - public boolean hillclimb = false; - public boolean neighbors = false; - public boolean neighborsWire = false; - public boolean neighborsWireOne = false; - public boolean errorNormals = false; - - public int breaks = 0; - boolean alt = false; - boolean shift = false; - boolean control = false; - Matrix projection = null; + JFrame f; GLCanvas glcanvas; Point clickPoint = null; @@ -53,6 +33,10 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot float anglex = 0; float angley = 0; + boolean alt = false; + boolean shift = false; + boolean control = false; + public abstract void _display(GLAutoDrawable drawable, GL gl); public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); @@ -60,6 +44,7 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot this.projection = Matrix.getProjectionMatrix(gl); } + /** return the position of the mouse as a point in window-space */ public Point getMouse() { return new Point(mousex, glcanvas.getHeight()-mousey, 0); } @@ -92,12 +77,12 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot clickPoint = getMouse(); clickClosest = closest == null ? null : closest.getPoint(); } + public void mouseReleased(MouseEvent e) { clickPoint = null; clickClosest = null; } - public void mouseMoved(MouseEvent e) { mousex = e.getX(); mousey = e.getY(); @@ -128,17 +113,15 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot public Viewer(JFrame f) { this.f = f; - - GLCapabilities glcaps = new GLCapabilities(); glcanvas = new GLCanvas(); glcanvas.addGLEventListener(this); f.add(glcanvas, BorderLayout.CENTER); - glcanvas.addMouseListener(this); glcanvas.addMouseMotionListener(this); glcanvas.addMouseWheelListener(this); glcanvas.addKeyListener(this); } + public void repaint() { glcanvas.repaint(); } -- 1.7.10.4