/* (non-Javadoc) * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable, int, int, int, int) */ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { this.width = width; this.height = height; // GL gl = drawable.getGL(); gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); double ratio = (double) width / (double) height; double w = 2; double h = 2; if (width < height) { h = h / ratio; } else { w = w * ratio; } int mode = Options.getProjectionMode(); if (mode == Options.PERSPECTIVE) { // For Perspective projection glu.gluPerspective(45, (double) (width) / (double) (height), 0.001, 1000); } else if (mode == Options.ORTHOGRAPHIC) { // For Orthogonal projection gl.glOrtho(-1 * w, w, -1 * h, h, -10000, 10000); } gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); for (Iterator<GLBrush> it = displayList.iterator(); it.hasNext(); ) { GLBrush brush = it.next(); brush.setScreenSize(width, height); } }
private void resetExtent() { extent = 0; for (Iterator<GLBrush> it = displayList.iterator(); it.hasNext(); ) { GLBrush obj = it.next(); double ex = obj.getExtent(); ex *= 2; extent = Math.max(extent, ex); translate = (float) (-1.5 * extent); scale = 2 / extent; } }
private void draw(GLAutoDrawable drawable) { if (modeFlag) { modeFlag = false; reshape(drawable, 0, 0, width, height); } // GL gl = drawable.getGL(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); loadDefaults(gl); for (Iterator<GLBrush> it = displayList.iterator(); it.hasNext(); ) { GLBrush brush = it.next(); brush.draw(gl, glu, glut); } }
public void openFile(String infoFile) { DataInfo info = FileUtils.parseInfoFile(infoFile); GLBrush offBrush = null; offBrush = new OffRendererTime(); ((OffRendererTime) offBrush).setMesh(info); if (!displayList.isEmpty()) { displayList.remove(0); } addGLBrush(offBrush); offBrush.setScreenSize(width, height); double ex = offBrush.getExtent(); ex *= 2; extent = ex; // Math.max(extent, ex); translate = (float) (-1.5 * extent); scale = 2 / extent; reset(); }
public void transform(float x1, float y1, float x2, float y2, boolean sc) { x1 = 2 * x1 / width - 1; y1 = 2 * y1 / height - 1; x2 = 2 * x2 / width - 1; y2 = 2 * y2 / height - 1; if (displayList.size() == 0) { return; } GLBrush brush = displayList.get(cur); if (!sc) { brush.translate(x1, -1 * y1, x2, -1 * y2); } else { brush.scale(x1, -1 * y1, x2, -1 * y2); } // case Options.TRANSLATE : // brush.translate(x1, -1 * y1,x2,-1 * y2); // break; // } }
/** * @param x * @param y */ public void mouseClicked(MouseEvent e) { GLBrush brush = displayList.get(cur); brush.mouseClicked(e); }
public static void reset() { if (volRenderer.displayList.size() > 0) { GLBrush brush = volRenderer.displayList.get(volRenderer.cur); brush.reset(); } }