bprocessor-commit Mailing List for B-processor (Page 165)
Status: Pre-Alpha
Brought to you by:
henryml
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(117) |
Aug
(151) |
Sep
(157) |
Oct
(81) |
Nov
(117) |
Dec
(119) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(183) |
Feb
(130) |
Mar
(117) |
Apr
(61) |
May
(82) |
Jun
(45) |
Jul
(149) |
Aug
(173) |
Sep
(199) |
Oct
(165) |
Nov
(107) |
Dec
(137) |
2007 |
Jan
(124) |
Feb
(58) |
Mar
(123) |
Apr
(80) |
May
(130) |
Jun
(64) |
Jul
(31) |
Aug
(42) |
Sep
(114) |
Oct
(167) |
Nov
(239) |
Dec
(200) |
2008 |
Jan
(43) |
Feb
(43) |
Mar
(4) |
Apr
(9) |
May
(5) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(13) |
Oct
(9) |
Nov
(12) |
Dec
|
2009 |
Jan
|
Feb
(20) |
Mar
(7) |
Apr
(12) |
May
(34) |
Jun
(72) |
Jul
|
Aug
(3) |
Sep
(31) |
Oct
(2) |
Nov
(8) |
Dec
(4) |
2010 |
Jan
(5) |
Feb
(32) |
Mar
(8) |
Apr
(7) |
May
(36) |
Jun
|
Jul
(11) |
Aug
(15) |
Sep
(7) |
Oct
(2) |
Nov
(13) |
Dec
(80) |
2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
(12) |
May
(32) |
Jun
(9) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(8) |
2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(22) |
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: rimestad <rim...@us...> - 2005-08-26 12:15:23
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23236/model Modified Files: Surface.java Log Message: Changede the calculation of the normal Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Surface.java 25 Aug 2005 14:32:37 -0000 1.12 --- Surface.java 26 Aug 2005 12:15:15 -0000 1.13 *************** *** 132,135 **** --- 132,151 ---- /** + * Get the front Space + * @return The space in front of the surfacespace + */ + public Space getFrontSpace() { + return null; + } + + /** + * Get the rear Space + * @return The rear space + */ + public Space getRearSpace() { + return null; + } + + /** * Returns the normal to this * @return A vector normal for this surface, null if the surface consists of only one edge *************** *** 137,154 **** public Vertex normal() { if (edges.size() > 1) { - Iterator it = edges.iterator(); EdgeFacade ef = EdgeFacade.getInstance(); ! Edge e1 = ef.findById(((Edge)it.next()).getId()); ! Edge e2 = ef.findById(((Edge)it.next()).getId()); Vertex v1 = e1.getFrom(); Vertex v2 = e1.getTo(); ! Vertex v3 = e2.getTo(); ! ! if (v3.equals(v2) || v3.equals(v1)) { ! v3 = e2.getFrom(); } ! Vertex v2v1 = v1.minus(v2); ! Vertex v2v3 = v3.minus(v2); ! return v2v1.cross(v2v3); } return null; --- 153,177 ---- public Vertex normal() { if (edges.size() > 1) { EdgeFacade ef = EdgeFacade.getInstance(); ! Edge e1 = ef.findById(((Edge)edges.get(0)).getId()); ! Edge e2 = ef.findById(((Edge)edges.get(1)).getId()); Vertex v1 = e1.getFrom(); Vertex v2 = e1.getTo(); ! Vertex v3 = null; ! ! if (e2.otherVertex(v1) == null) { ! v3 = e2.otherVertex(v2); ! // v2 is the center ! Vertex v2v1 = v2.minus(v1); ! Vertex v2v3 = v2.minus(v3); ! return v2v3.cross(v2v1); ! } else if (e2.otherVertex(v2) == null) { ! // v1 is the center ! v3 = e2.otherVertex(v1); ! Vertex v1v2 = v1.minus(v2); ! Vertex v1v3 = v1.minus(v3); ! return v1v3.cross(v1v2); } ! return null; } return null; |
From: rimestad <rim...@us...> - 2005-08-25 16:08:20
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19563 Modified Files: ViewFactory.java Log Message: Added buttons for draw mode Index: ViewFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ViewFactory.java 17 Aug 2005 08:58:49 -0000 1.3 --- ViewFactory.java 25 Aug 2005 16:08:12 -0000 1.4 *************** *** 66,69 **** --- 66,75 ---- but = tb.registerAction(new ViewyzAction(glv)); but.setToolTipText("yz-plane"); + but = tb.registerAction(new ViewWireframe(glv)); + but.setToolTipText("Wireframe"); + but = tb.registerAction(new ViewSolid(glv)); + but.setToolTipText("Solid"); + but = tb.registerAction(new ViewLighting(glv)); + but.setToolTipText("Shading"); } *************** *** 218,220 **** --- 224,313 ---- } } + + /** + * The viewwireframe inner class + */ + class ViewWireframe extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ViewWireframe(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("wireframeicon.png"); + ImageIcon im = new ImageIcon(url); + putValue(Action.SMALL_ICON, im); + } + + /** + * Called when the button is pressed + * @param e The ActionEvent + */ + public void actionPerformed(ActionEvent e) { + glv.getView().changeDrawMode(View.WIREFRAME_MODE); + glv.repaint(); + } + } + + /** + * The viewSolid inner class + */ + class ViewSolid extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ViewSolid(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("solidicon.png"); + ImageIcon im = new ImageIcon(url); + putValue(Action.SMALL_ICON, im); + } + + /** + * Called when the button is pressed + * @param e The ActionEvent + */ + public void actionPerformed(ActionEvent e) { + glv.getView().changeDrawMode(View.SOLID_MODE); + glv.repaint(); + } + } + + /** + * The viewlighting inner class + */ + class ViewLighting extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ViewLighting(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("lightingicon.png"); + ImageIcon im = new ImageIcon(url); + putValue(Action.SMALL_ICON, im); + } + + /** + * Called when the button is pressed + * @param e The ActionEvent + */ + public void actionPerformed(ActionEvent e) { + glv.getView().changeDrawMode(View.LIGHTING_MODE); + glv.repaint(); + } + } } |
From: rimestad <rim...@us...> - 2005-08-25 16:07:11
|
Update of /cvsroot/bprocessor/gl/src/gfx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19038 Added Files: wireframeicon.png solidicon.png lightingicon.png Log Message: initial inport --- NEW FILE: lightingicon.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: solidicon.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: wireframeicon.png --- (This appears to be a binary file; contents omitted.) |
From: Michael L. <he...@us...> - 2005-08-25 14:34:14
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28158/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java Log Message: Small change Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractView.java 25 Aug 2005 09:47:01 -0000 1.10 --- AbstractView.java 25 Aug 2005 14:34:07 -0000 1.11 *************** *** 131,135 **** public static void setTransparency(int percent) { byte b = (byte)0xff; //(byte)(255 * (percent / 100)); ! log.info(b); for (int i = 0; i < transparency.length; i++) { transparency[i] = b; --- 131,135 ---- public static void setTransparency(int percent) { byte b = (byte)0xff; //(byte)(255 * (percent / 100)); ! log.info("value = " + b); for (int i = 0; i < transparency.length; i++) { transparency[i] = b; *************** *** 705,711 **** int bufferOffset = 0; int names = 0; ! int minZ = Integer.MAX_VALUE; ! int z1; ! int z2; Long id = null; Integer intId; --- 705,711 ---- int bufferOffset = 0; int names = 0; ! long minZ = Integer.MAX_VALUE; ! long z1; ! long z2; Long id = null; Integer intId; *************** *** 716,723 **** --- 716,727 ---- z1 = selectBuffer.get(bufferOffset); z2 = selectBuffer.get(bufferOffset + 1); + bufferOffset += 2; if (z1 < minZ) { minZ = z1; id = new Long((new Integer(selectBuffer.get(bufferOffset))).longValue()); + double far = z1 / 0xFFFFFFFF; + double near = z2 / 0xFFFFFFFF; + System.out.println("z1 = " + far + "z2 = " + near); } bufferOffset += names; |
From: Michael L. <he...@us...> - 2005-08-25 14:32:47
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27697/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Added Files: Plane.java Log Message: Added a Plane class Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Surface.java 22 Aug 2005 08:46:44 -0000 1.11 --- Surface.java 25 Aug 2005 14:32:37 -0000 1.12 *************** *** 132,136 **** /** ! * returns the normal to this * @return A vector normal for this surface, null if the surface consists of only one edge */ --- 132,136 ---- /** ! * Returns the normal to this * @return A vector normal for this surface, null if the surface consists of only one edge */ *************** *** 154,157 **** --- 154,176 ---- return null; } + + /** + * Returns the Plane that this Surface lies in + * @return The Plane for this Surface + */ + + Plane plane() { + double d = 0; + Vertex n = normal(); + double l = n.length(); + n.scale(1 / l); + double a = n.getX(); + double b = n.getY(); + double c = n.getZ(); + Edge e1 = (Edge) edges.get(0); + Vertex v1 = e1.getFrom(); + d = -(a * v1.getX() + b * v1.getY() + c * v1.getZ()); + return new Plane(a, b, c, d); + } /** --- NEW FILE: Plane.java --- //--------------------------------------------------------------------------------- // $Id: Plane.java,v 1.1 2005/08/25 14:32:37 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; /** * The Plane * A Plane is defined by the equation * Ax + By + Cy + D = 0 */ public class Plane { /** The coefficient a */ private double a; /** The coefficient b */ private double b; /** The coefficient c */ private double c; /** The coefficient d */ private double d; /** * Constructor * @param a the a * @param b the b * @param c the c * @param d the d */ public Plane(double a, double b, double c, double d) { super(); this.a = a; this.b = b; this.c = c; this.d = d; } /** * Find the intersection with the ray (x y t) * @param x the x * @param y the y * @return the intersection with the (x y t) ray */ double intersection(double x, double y) { return 0; } } |
From: rimestad <rim...@us...> - 2005-08-25 09:50:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30928 Modified Files: MoveTool.java Log Message: repaired tool so that it does not use special variables Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MoveTool.java 19 Aug 2005 09:50:44 -0000 1.3 --- MoveTool.java 25 Aug 2005 09:50:45 -0000 1.4 *************** *** 38,41 **** --- 38,47 ---- private int moveMode = XY; + /** The previous X coordinate */ + private int lastX = 0; + + /** The previous Y cordinate */ + private int lastY = 0; + /** * The Constructor *************** *** 46,49 **** --- 52,65 ---- } + /** + * Invoked when a mouse button has been pressed on a component. + * @param e The MouseEvent object + */ + protected void pressed(MouseEvent e) { + super.pressed(e); + lastX = e.getX(); + lastY = e.getY(); + } + /** * Invoked when the mouse is held pressed and moved *************** *** 51,59 **** */ protected void dragged(MouseEvent e) { if (viewType == View.VIEW_3D) { ! int x = e.getX(); ! int y = e.getY(); ! double deltaX = x - pressPos[0]; ! double deltaY = y - pressPos[1]; double[] coords; if (selectedSurface != null) { --- 67,75 ---- */ protected void dragged(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); if (viewType == View.VIEW_3D) { ! double deltaX = x - lastX; ! double deltaY = y - lastY; double[] coords; if (selectedSurface != null) { *************** *** 98,103 **** } if (selectedVertex != null) { - int x = e.getX(); - int y = e.getY(); View view = glv.getView(); double[] coords = view.toCanvasCoords(new double[]{x, y}); --- 114,117 ---- *************** *** 106,113 **** } else if (selectedSurface != null) { View view = glv.getView(); - int x = e.getX(); - int y = e.getY(); double[] coordsa = view.toCanvasCoords(new double[]{x, y}); ! double[] coordsb = view.toCanvasCoords(new double[]{pressPos[0], pressPos[1]}); double[] delta = new double[] {coordsa[0] - coordsb[0], coordsa[1] - coordsb[1], --- 120,125 ---- } else if (selectedSurface != null) { View view = glv.getView(); double[] coordsa = view.toCanvasCoords(new double[]{x, y}); ! double[] coordsb = view.toCanvasCoords(new double[]{lastX, lastY}); double[] delta = new double[] {coordsa[0] - coordsb[0], coordsa[1] - coordsb[1], *************** *** 124,131 **** } else if (selectedEdge != null) { View view = glv.getView(); - int x = e.getX(); - int y = e.getY(); double[] coordsa = view.toCanvasCoords(new double[]{x, y}); ! double[] coordsb = view.toCanvasCoords(new double[]{pressPos[0], pressPos[1]}); double[] delta = new double[] {coordsa[0] - coordsb[0], coordsa[1] - coordsb[1], --- 136,141 ---- } else if (selectedEdge != null) { View view = glv.getView(); double[] coordsa = view.toCanvasCoords(new double[]{x, y}); ! double[] coordsb = view.toCanvasCoords(new double[]{lastX, lastY}); double[] delta = new double[] {coordsa[0] - coordsb[0], coordsa[1] - coordsb[1], *************** *** 143,148 **** updateVertex(from, coordsa); } ! pressPos[0] = e.getX(); ! pressPos[1] = e.getY(); } --- 153,158 ---- updateVertex(from, coordsa); } ! lastX = x; ! lastY = y; } |
From: rimestad <rim...@us...> - 2005-08-25 09:49:26
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30700 Modified Files: AbstractTool.java Log Message: added 8,9,0 keypress as change of drawing method, wireframe, solid and lighting Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AbstractTool.java 23 Aug 2005 11:55:38 -0000 1.9 --- AbstractTool.java 25 Aug 2005 09:49:17 -0000 1.10 *************** *** 33,43 **** /** The mouse position last time the mouse was pressed initializes to (0,0) */ ! protected int[] pressPos = new int[2]; /** The mouse movement in x axis since press */ ! protected int dx = 0; /** The mouse movement in y axis since press */ ! protected int dy = 0; /** An vertex counter */ --- 33,43 ---- /** The mouse position last time the mouse was pressed initializes to (0,0) */ ! protected static int[] pressPos = new int[2]; /** The mouse movement in x axis since press */ ! protected static int dx = 0; /** The mouse movement in y axis since press */ ! protected static int dy = 0; /** An vertex counter */ *************** *** 54,68 **** /** The zoom action listener */ ! private ActionListener zoomAction; /** The move action listener */ ! private ActionListener moveAction; /** The carmera move timer */ ! private Timer timer; /** The 3DView */ protected GLView glv = null; /** * KeyListener for the GL Canvas --- 54,72 ---- /** The zoom action listener */ ! private static ActionListener zoomAction; /** The move action listener */ ! private static ActionListener moveAction; /** The carmera move timer */ ! private static Timer timer; /** The 3DView */ protected GLView glv = null; + static { + timer = new Timer(40, null); + } + /** * KeyListener for the GL Canvas *************** *** 71,76 **** public AbstractTool(GLView glv) { this.glv = glv; - - timer = new Timer(40, null); timer.start(); moveAction = new CameraMoveTimer(this, glv); --- 75,78 ---- *************** *** 112,116 **** } else if (e.getKeyChar() == KeyEvent.VK_4) { glv.changeView(View.VIEW_YZ); ! } glv.repaint(); } --- 114,124 ---- } else if (e.getKeyChar() == KeyEvent.VK_4) { glv.changeView(View.VIEW_YZ); ! } else if (e.getKeyChar() == KeyEvent.VK_8) { ! glv.getView().changeDrawMode(View.WIREFRAME_MODE); ! } else if (e.getKeyChar() == KeyEvent.VK_9) { ! glv.getView().changeDrawMode(View.SOLID_MODE); ! } else if (e.getKeyChar() == KeyEvent.VK_0) { ! glv.getView().changeDrawMode(View.LIGHTING_MODE); ! } glv.repaint(); } |
From: rimestad <rim...@us...> - 2005-08-25 09:47:12
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30393 Modified Files: AbstractView.java Log Message: Added lighting and changed when what is drawn Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AbstractView.java 22 Aug 2005 14:30:57 -0000 1.9 --- AbstractView.java 25 Aug 2005 09:47:01 -0000 1.10 *************** *** 37,64 **** private static Logger log = Logger.getLogger(AbstractView.class); - /** the color of the x axis */ - public static final double[] X_AXIS_COLOR = new double[] {0.0, 1.0, 0.0}; - - /** the color of the y axis */ - public static final double[] Y_AXIS_COLOR = new double[] {1.0, 0.0, 0.0}; - - /** the color of the z axis */ - public static final double[] Z_AXIS_COLOR = new double[] {0.0, 0.0, 1.0}; - - /** the std line color*/ - public static final double[] STD_LINE_COLOR = new double[] {0.1, 0.1, 0.1}; - - /** Used for the actual drawing line */ - public static final double[] DRAW_COLOR = new double[] {1.0, 1.0, 0.0}; - - /** Used for the actual drawing line */ - public static final double[] GRID_COLOR = new double[] {0.85, 0.85, 0.85, 0.8}; - - /** Surface color for all not selected surfaces */ - public static final double[] SURFACE_COLOR = new double[] {0.93, 0.93, 0.93, 0.95}; - - /** Used for selected objects */ - public static final double[] SELECTED_COLOR = new double[] {1.0, 0.4, 1.0, 0.95}; - /** The view transformation matrix (it is shown transposed) see p. 187 [GL BIBLE]*/ protected static double[] viewTrans = new double[] {1.0, 0.0, 0.0, 0.0, --- 37,40 ---- *************** *** 139,142 **** --- 115,140 ---- private int selectMode; + /** The drawing mode. Either wireframe, solid og lighting */ + protected int drawMode = WIREFRAME_MODE; + + /** The transparency of surfaces */ + protected static byte[] transparency = new byte[128]; + + static { + setTransparency(100); + }; + + /** + * Set the transparency pattern + * @param percent the percent of visible surface; + */ + public static void setTransparency(int percent) { + byte b = (byte)0xff; //(byte)(255 * (percent / 100)); + log.info(b); + for (int i = 0; i < transparency.length; i++) { + transparency[i] = b; + } + } + /** * The constructor *************** *** 162,170 **** this.aspect = this.width / this.height; - - gl.glEnable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_LINE_SMOOTH); - gl.glEnable(GL.GL_POINT_SMOOTH); - gl.glEnable(GL.GL_BLEND); gl.glClearColor(0.7f, 0.7f, 0.7f, 0.0f); --- 160,163 ---- *************** *** 180,184 **** gl = gld.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); glu = gld.getGLU(); --- 173,176 ---- *************** *** 191,203 **** gl.glRenderMode(GL.GL_SELECT); } ! camera(gld); picking = 0; gl.glLineWidth(1.0f); grid(); gl.glLineWidth(3.0f); coords(); ! gl.glColor3dv(STD_LINE_COLOR); gl.glLineWidth(2.0f); drawAll(gld); --- 183,224 ---- gl.glRenderMode(GL.GL_SELECT); } ! camera(gld); picking = 0; + gl.glEnable(GL.GL_LINE_SMOOTH); + gl.glEnable(GL.GL_POINT_SMOOTH); + //gl.glEnable(GL.GL_POLYGON_SMOOTH); + gl.glEnable(GL.GL_BLEND); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + gl.glDepthMask(true); + + // grid and coords are always completely lit + gl.glDisable(GL.GL_DEPTH_TEST); + gl.glDisable(GL.GL_LIGHTING); gl.glLineWidth(1.0f); grid(); gl.glLineWidth(3.0f); + gl.glEnable(GL.GL_DEPTH_TEST); coords(); ! gl.glEnable(GL.GL_LIGHTING); ! ! // set up lighting for the model ! if (drawMode == LIGHTING_MODE) { ! gl.glShadeModel(GL.GL_SMOOTH); ! gl.glEnable(GL.GL_LIGHTING); ! gl.glEnable(GL.GL_LIGHT0); ! gl.glEnable(GL.GL_COLOR_MATERIAL); ! gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1); ! //gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); ! gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE); ! gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] {0.3f, 0.3f, 0.3f, 1.0f}); ! gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, new float[] {0.7f, 0.7f, 0.7f, 1.0f}); ! } else { ! gl.glDisable(GL.GL_COLOR_MATERIAL); ! gl.glDisable(GL.GL_LIGHTING); ! } ! ! gl.glColor3fv(STD_LINE_COLOR); gl.glLineWidth(2.0f); drawAll(gld); *************** *** 268,271 **** --- 289,312 ---- gl.glInitNames(); if (mode[0] != GL.GL_SELECT) { + gl.glEnable(GL.GL_DEPTH_TEST); + // draw selected surface + if (selectedSurface != null) { + gl.glColor3fv(SELECTED_COLOR); + selectedSurface = SurfaceFacade.getInstance().findById(selectedSurface.getId()); + drawSurface(selectedSurface); + } + + // draw all the surfaces in the model + if (drawMode != WIREFRAME_MODE) { + Iterator it = surfaces.iterator(); + gl.glColor3fv(SURFACE_COLOR); + while (it.hasNext()) { + Surface s = (Surface)it.next(); + if (!s.equals(selectedSurface)) { + drawSurface(s); + } + } + } + // draw activeEdge different if it is parallel with axis if (activeEdge != null) { *************** *** 273,283 **** Vertex from = activeEdge.getFrom(); if (from.getY() == to.getY() && from.getZ() == to.getZ()) { ! gl.glColor3dv(X_AXIS_COLOR); } else if (from.getX() == to.getX() && from.getZ() == to.getZ()) { ! gl.glColor3dv(Y_AXIS_COLOR); } else if (from.getX() == to.getX() && from.getY() == to.getY()) { ! gl.glColor3dv(Z_AXIS_COLOR); } else { ! gl.glColor3dv(STD_LINE_COLOR); } gl.glBegin(GL.GL_LINES); --- 314,324 ---- Vertex from = activeEdge.getFrom(); if (from.getY() == to.getY() && from.getZ() == to.getZ()) { ! gl.glColor3fv(X_AXIS_COLOR); } else if (from.getX() == to.getX() && from.getZ() == to.getZ()) { ! gl.glColor3fv(Y_AXIS_COLOR); } else if (from.getX() == to.getX() && from.getY() == to.getY()) { ! gl.glColor3fv(Z_AXIS_COLOR); } else { ! gl.glColor3fv(STD_LINE_COLOR); } gl.glBegin(GL.GL_LINES); *************** *** 291,301 **** if (alignPoint != null && alignVertex != null) { if (alignPoint[1] == alignVertex.getY() && alignPoint[2] == alignVertex.getZ()) { ! gl.glColor3dv(X_AXIS_COLOR); } else if (alignPoint[0] == alignVertex.getX() && alignPoint[2] == alignVertex.getZ()) { ! gl.glColor3dv(Y_AXIS_COLOR); } else if (alignPoint[0] == alignVertex.getX() && alignPoint[1] == alignVertex.getY()) { ! gl.glColor3dv(Z_AXIS_COLOR); } else { ! gl.glColor3dv(DRAW_COLOR); } gl.glBegin(GL.GL_LINES); --- 332,342 ---- if (alignPoint != null && alignVertex != null) { if (alignPoint[1] == alignVertex.getY() && alignPoint[2] == alignVertex.getZ()) { ! gl.glColor3fv(X_AXIS_COLOR); } else if (alignPoint[0] == alignVertex.getX() && alignPoint[2] == alignVertex.getZ()) { ! gl.glColor3fv(Y_AXIS_COLOR); } else if (alignPoint[0] == alignVertex.getX() && alignPoint[1] == alignVertex.getY()) { ! gl.glColor3fv(Z_AXIS_COLOR); } else { ! gl.glColor3fv(DRAW_COLOR); } gl.glBegin(GL.GL_LINES); *************** *** 317,321 **** // draw selected vertex if (selectedVertex != null) { ! gl.glColor4dv(SELECTED_COLOR); gl.glPointSize(5.0f); gl.glBegin(GL.GL_POINTS); --- 358,362 ---- // draw selected vertex if (selectedVertex != null) { ! gl.glColor3fv(SELECTED_COLOR); gl.glPointSize(5.0f); gl.glBegin(GL.GL_POINTS); *************** *** 328,332 **** // draw selected edge if (selectedEdge != null) { ! gl.glColor4dv(SELECTED_COLOR); selectedEdge = EdgeFacade.getInstance().findById(selectedEdge.getId()); Vertex to = selectedEdge.getTo(); --- 369,373 ---- // draw selected edge if (selectedEdge != null) { ! gl.glColor3fv(SELECTED_COLOR); selectedEdge = EdgeFacade.getInstance().findById(selectedEdge.getId()); Vertex to = selectedEdge.getTo(); *************** *** 338,369 **** } ! // draw selected surface ! if (selectedSurface != null) { ! gl.glColor4dv(SELECTED_COLOR); ! selectedSurface = SurfaceFacade.getInstance().findById(selectedSurface.getId()); ! drawSurface(selectedSurface); ! } ! ! Iterator it = surfaces.iterator(); ! gl.glColor4dv(SURFACE_COLOR); ! while (it.hasNext()) { ! Surface s = (Surface)it.next(); ! if (!s.equals(selectedSurface)) { ! drawSurface(s); ! } ! } ! ! it = edges.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); ! while (it.hasNext()) { ! Edge e = (Edge)it.next(); if (!e.equals(selectedEdge)) { drawEdge(e); } ! } } else { if (selectMode == SURFACES) { Iterator it = surfaces.iterator(); ! gl.glColor4dv(SURFACE_COLOR); while (it.hasNext()) { Surface s = (Surface)it.next(); --- 379,397 ---- } ! // draw all the edges in the model ! Iterator eit = edges.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); ! while (eit.hasNext()) { ! Edge e = (Edge)eit.next(); if (!e.equals(selectedEdge)) { drawEdge(e); } ! } ! ! // HERE STARTS SELECTION MODE DRAWING } else { if (selectMode == SURFACES) { Iterator it = surfaces.iterator(); ! gl.glColor3fv(SURFACE_COLOR); while (it.hasNext()) { Surface s = (Surface)it.next(); *************** *** 377,381 **** if (selectMode == EDGES) { Iterator it = edges.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); --- 405,409 ---- if (selectMode == EDGES) { Iterator it = edges.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); *************** *** 389,393 **** if (selectMode == VERTICES) { Iterator it = vertices.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); while (it.hasNext()) { Vertex v = (Vertex)it.next(); --- 417,421 ---- if (selectMode == VERTICES) { Iterator it = vertices.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { Vertex v = (Vertex)it.next(); *************** *** 406,412 **** --- 434,449 ---- */ private void drawSurface(Surface s) { + //gl.glEnable(GL.GL_POLYGON_STIPPLE); + //gl.glDisable(GL.GL_BLEND); + //glblend.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + //gl.glPolygonStipple(transparency); List l = s.getEdges(); if (l != null) { gl.glBegin(GL.GL_POLYGON); + if (drawMode == LIGHTING_MODE) { + Vertex norm = s.normal(); + norm.scale(1 / norm.length()); + gl.glNormal3d(norm.getX(), norm.getY(), norm.getZ()); + } Vertex previous = null; Edge previousEdge = null; *************** *** 421,433 **** gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); previous = temp; ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); } else { temp = previousEdge.otherVertex(previous); gl.glVertex3d(temp.getX(), temp.getY(), temp.getZ()); previous = e.otherVertex(temp); ! if (previous == null) { ! log.warn("[drawSurface] could not find vertex " + temp + " on " + e); ! } else { ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); } } --- 458,474 ---- gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); previous = temp; ! if (i == l.size() - 1) { ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! } } else { temp = previousEdge.otherVertex(previous); gl.glVertex3d(temp.getX(), temp.getY(), temp.getZ()); previous = e.otherVertex(temp); ! if (i == l.size() - 1) { ! if (previous == null) { ! log.warn("[drawSurface] could not find vertex " + temp + " on " + e); ! } else { ! gl.glVertex3d(previous.getX(), previous.getY(), previous.getZ()); ! } } } *************** *** 437,440 **** --- 478,483 ---- gl.glEnd(); } + //gl.glDisable(GL.GL_POLYGON_STIPPLE); + //gl.glEnable(GL.GL_DEPTH_TEST); } *************** *** 475,479 **** Iterator it = edges.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); --- 518,522 ---- Iterator it = edges.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { Edge e = (Edge)it.next(); *************** *** 481,484 **** --- 524,528 ---- } } + /** * Draw all surfaces *************** *** 491,495 **** Iterator it = surfaces.iterator(); ! gl.glColor3dv(STD_LINE_COLOR); while (it.hasNext()) { Surface s = (Surface)it.next(); --- 535,539 ---- Iterator it = surfaces.iterator(); ! gl.glColor3fv(STD_LINE_COLOR); while (it.hasNext()) { Surface s = (Surface)it.next(); *************** *** 499,502 **** --- 543,547 ---- } } + /** * Change the rotation about the x axis. Only usable in 3D *************** *** 734,737 **** --- 779,792 ---- /** + * Change the drawing mode + * @param mode The mode one of the statics WIREFRAME_MODE, SOLID_MODE or LIGHTING_MODE + */ + public void changeDrawMode(int mode) { + if (mode <= 2 && mode >= 0) { + drawMode = mode; + } + } + + /** * The camera init function * @param gld The GLDrawable object |
From: rimestad <rim...@us...> - 2005-08-25 09:45:52
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30237 Modified Files: View.java Log Message: Added static final colors Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** View.java 17 Aug 2005 10:56:15 -0000 1.5 --- View.java 25 Aug 2005 09:45:42 -0000 1.6 *************** *** 29,32 **** --- 29,65 ---- /** The y z plane view */ public static final int VIEW_YZ = 3; + + /** the color of the x axis */ + public static final float[] X_AXIS_COLOR = new float[] {0.0f, 1.0f, 0.0f}; + + /** the color of the y axis */ + public static final float[] Y_AXIS_COLOR = new float[] {1.0f, 0.0f, 0.0f}; + + /** the color of the z axis */ + public static final float[] Z_AXIS_COLOR = new float[] {0.0f, 0.0f, 1.0f}; + + /** the std line color*/ + public static final float[] STD_LINE_COLOR = new float[] {0.1f, 0.1f, 0.1f}; + + /** Used for the actual drawing line */ + public static final float[] DRAW_COLOR = new float[] {1.0f, 1.0f, 0.0f}; + + /** Used for the actual drawing line */ + public static final float[] GRID_COLOR = new float[] {0.85f, 0.85f, 0.85f, 0.8f}; + + /** Surface color for all not selected surfaces */ + public static final float[] SURFACE_COLOR = new float[] {0.93f, 0.93f, 0.93f}; + + /** Used for selected objects */ + public static final float[] SELECTED_COLOR = new float[] {1.0f, 0.4f, 1.0f}; + + /** Can be used for setting wireframe mode */ + public static final int WIREFRAME_MODE = 0; + + /** Can be used for setting solid mode */ + public static final int SOLID_MODE = 1; + + /** Can be used for setting lighting mode */ + public static final int LIGHTING_MODE = 2; /** *************** *** 129,131 **** --- 162,170 ---- */ public Object getObjectAtPoint(double x, double y); + + /** + * Change the drawing mode + * @param mode The mode one of the statics WIREFRAME_MODE, SOLID_MODE or LIGHTING_MODE + */ + public void changeDrawMode(int mode); } |
From: rimestad <rim...@us...> - 2005-08-25 09:44:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29979 Modified Files: ViewXY.java View3D.java ViewXZ.java ViewYZ.java Log Message: changed color use Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** View3D.java 17 Aug 2005 11:03:22 -0000 1.6 --- View3D.java 25 Aug 2005 09:44:18 -0000 1.7 *************** *** 28,32 **** /** The rotation about the Y axis */ ! private static double rotationY = 130; /** --- 28,32 ---- /** The rotation about the Y axis */ ! private static double rotationZ = 130; /** *************** *** 50,55 **** int[] viewport = new int[] {0, 0, (int)width, (int)height}; - gl.glShadeModel(GL.GL_SMOOTH); //hacking linux - gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); --- 50,53 ---- *************** *** 61,79 **** if (aspect < 1.0) { // fovy, aspect, near, far (relative to camera position) ! glu.gluPerspective(aspect * 60.0, 1.0, 0.5, 50.0 * getZoomFactor()); } else { ! glu.gluPerspective(60.0, aspect, 0.5, 50.0 * getZoomFactor()); } gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); ! glu.gluLookAt(0.0 + center[0], ! 25.0 * getZoomFactor() + center[1], ! 0.0 + center[2], center[0], center[1], center[2], 0.0, 0.0, 1.0); ! gl.glMultMatrixd(viewTrans); gl.glRotated(rotationX, 1.0, 0.0, 0.0); ! gl.glRotated(rotationY, 0.0, 0.0, 1.0); } --- 59,78 ---- if (aspect < 1.0) { // fovy, aspect, near, far (relative to camera position) ! glu.gluPerspective(aspect * 60.0, 1.0, 2.0 / getZoomFactor(), 100.0 * getZoomFactor()); } else { ! glu.gluPerspective(60.0, aspect, 2.0 / getZoomFactor(), 100.0 * getZoomFactor()); } gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); ! ! gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] {0.0f, 0.0f, 0.0f, 1.0f}); ! glu.gluLookAt(0.0 + center[0], 25.0 * getZoomFactor() + center[1], 0.0 + center[2], center[0], center[1], center[2], 0.0, 0.0, 1.0); ! ! //gl.glMultMatrixd(viewTrans); gl.glRotated(rotationX, 1.0, 0.0, 0.0); ! gl.glRotated(rotationZ, 0.0, 0.0, 1.0); } *************** *** 105,109 **** */ public void translateRotationY(double change) { ! rotationY -= change / width; } --- 104,108 ---- */ public void translateRotationY(double change) { ! rotationZ -= change / width; } *************** *** 118,130 **** size /= aspect; } ! gl.glColor4dv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, -size, -0.001); ! gl.glVertex3d((double) x, size, -0.001); } for (int y = -(int)size; y <= (int)size; y++) { ! gl.glVertex3d(-size, (double) y, -0.001); ! gl.glVertex3d(size, (double) y, -0.001); } gl.glEnd(); --- 117,129 ---- size /= aspect; } ! gl.glColor4fv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, -size, -0.01); ! gl.glVertex3d((double) x, size, -0.01); } for (int y = -(int)size; y <= (int)size; y++) { ! gl.glVertex3d(-size, (double) y, -0.01); ! gl.glVertex3d(size, (double) y, -0.01); } gl.glEnd(); *************** *** 136,146 **** protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3dv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(10.0, 0.0, 0.0); ! gl.glColor3dv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 10.0, 0.0); ! gl.glColor3dv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.0, 10.0); --- 135,145 ---- protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3fv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(10.0, 0.0, 0.0); ! gl.glColor3fv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 10.0, 0.0); ! gl.glColor3fv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.0, 10.0); Index: ViewYZ.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewYZ.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ViewYZ.java 23 Aug 2005 11:59:42 -0000 1.4 --- ViewYZ.java 25 Aug 2005 09:44:18 -0000 1.5 *************** *** 91,95 **** size = this.size * getZoomFactor() / aspect; } ! gl.glColor4dv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int y = -(int)size; y <= size; y++) { --- 91,95 ---- size = this.size * getZoomFactor() / aspect; } ! gl.glColor4fv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int y = -(int)size; y <= size; y++) { *************** *** 109,116 **** protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3dv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 10.0, 0.0); ! gl.glColor3dv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.0, 10.0); --- 109,116 ---- protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3fv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 10.0, 0.0); ! gl.glColor3fv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.0, 10.0); Index: ViewXY.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewXY.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ViewXY.java 23 Aug 2005 11:59:07 -0000 1.4 --- ViewXY.java 25 Aug 2005 09:44:18 -0000 1.5 *************** *** 90,94 **** size = this.size * getZoomFactor() / aspect; } ! gl.glColor4dv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { --- 90,94 ---- size = this.size * getZoomFactor() / aspect; } ! gl.glColor4fv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { *************** *** 108,115 **** protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3dv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(10.0, 0.0, 0.0); ! gl.glColor3dv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 10.0, 0.0); --- 108,115 ---- protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3fv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(10.0, 0.0, 0.0); ! gl.glColor3fv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 10.0, 0.0); Index: ViewXZ.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewXZ.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ViewXZ.java 23 Aug 2005 11:59:25 -0000 1.4 --- ViewXZ.java 25 Aug 2005 09:44:18 -0000 1.5 *************** *** 93,97 **** size = this.size * getZoomFactor() / aspect; } ! gl.glColor4dv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { --- 93,97 ---- size = this.size * getZoomFactor() / aspect; } ! gl.glColor4fv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { *************** *** 111,118 **** protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3dv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(10.0, 0.0, 0.0); ! gl.glColor3dv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.0, 10.0); --- 111,118 ---- protected void coords() { gl.glBegin(GL.GL_LINES); ! gl.glColor3fv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(10.0, 0.0, 0.0); ! gl.glColor3fv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); gl.glVertex3d(0.0, 0.0, 10.0); |
From: Jesper P. <je...@us...> - 2005-08-24 06:58:45
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15909 Modified Files: PersistenceManager.java Log Message: Fix import and save attribute values Index: PersistenceManager.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/xml/PersistenceManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PersistenceManager.java 4 Aug 2005 10:48:30 -0000 1.4 --- PersistenceManager.java 24 Aug 2005 06:58:37 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.model.xml; + import net.sourceforge.bprocessor.model.AttributeFacade; import net.sourceforge.bprocessor.model.ConstructionSpace; import net.sourceforge.bprocessor.model.ConstructionSpaceFacade; *************** *** 134,138 **** net.sourceforge.bprocessor.model.Attribute am = ! new net.sourceforge.bprocessor.model.Attribute(a.getName(), a.getType(), null); mapper.put(new Long(a.getId()), am.getId()); --- 135,141 ---- net.sourceforge.bprocessor.model.Attribute am = ! new net.sourceforge.bprocessor.model.Attribute(a.getName(), a.getType(), a.getValue()); ! ! am = AttributeFacade.getInstance().create(am); mapper.put(new Long(a.getId()), am.getId()); *************** *** 153,159 **** ConstructionSpace csm = new ConstructionSpace(cs.getName()); - mapper.put(new Long(cs.getId()), csm.getId()); - csm = ConstructionSpaceFacade.getInstance().create(csm); } } --- 156,162 ---- ConstructionSpace csm = new ConstructionSpace(cs.getName()); csm = ConstructionSpaceFacade.getInstance().create(csm); + + mapper.put(new Long(cs.getId()), csm.getId()); } } *************** *** 170,176 **** FunctionalSpace fsm = new FunctionalSpace(fs.getName()); - mapper.put(new Long(fs.getId()), fsm.getId()); - fsm = FunctionalSpaceFacade.getInstance().create(fsm); } } --- 173,179 ---- FunctionalSpace fsm = new FunctionalSpace(fs.getName()); fsm = FunctionalSpaceFacade.getInstance().create(fsm); + + mapper.put(new Long(fs.getId()), fsm.getId()); } } *************** *** 189,195 **** new net.sourceforge.bprocessor.model.Element(e.getName()); - mapper.put(new Long(e.getId()), em.getId()); - em = ElementFacade.getInstance().create(em); } } --- 192,198 ---- new net.sourceforge.bprocessor.model.Element(e.getName()); em = ElementFacade.getInstance().create(em); + + mapper.put(new Long(e.getId()), em.getId()); } } *************** *** 208,214 **** new net.sourceforge.bprocessor.model.Part(p.getName()); - mapper.put(new Long(p.getId()), pm.getId()); - pm = PartFacade.getInstance().create(pm); } } --- 211,217 ---- new net.sourceforge.bprocessor.model.Part(p.getName()); pm = PartFacade.getInstance().create(pm); + + mapper.put(new Long(p.getId()), pm.getId()); } } *************** *** 229,235 **** sm.setConstructor(s.isConstructor()); - mapper.put(new Long(s.getId()), sm.getId()); - sm = SurfaceFacade.getInstance().create(sm); } } --- 232,238 ---- sm.setConstructor(s.isConstructor()); sm = SurfaceFacade.getInstance().create(sm); + + mapper.put(new Long(s.getId()), sm.getId()); } } *************** *** 248,254 **** new net.sourceforge.bprocessor.model.Edge(e.getName()); - mapper.put(new Long(e.getId()), em.getId()); - em = EdgeFacade.getInstance().create(em); } } --- 251,257 ---- new net.sourceforge.bprocessor.model.Edge(e.getName()); em = EdgeFacade.getInstance().create(em); + + mapper.put(new Long(e.getId()), em.getId()); } } *************** *** 272,278 **** vm.setW(v.getW()); - mapper.put(new Long(v.getId()), vm.getId()); - vm = VertexFacade.getInstance().create(vm); } } --- 275,281 ---- vm.setW(v.getW()); vm = VertexFacade.getInstance().create(vm); + + mapper.put(new Long(v.getId()), vm.getId()); } } *************** *** 634,637 **** --- 637,641 ---- ax.setName(a.getName()); ax.setType(a.getType()); + ax.setValue(a.getValue()); bp.getAttribute().add(ax); |
From: Jesper P. <je...@us...> - 2005-08-24 06:58:14
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15811 Added Files: AttributeFacade.java Log Message: Initial import --- NEW FILE: AttributeFacade.java --- //--------------------------------------------------------------------------------- // $Id: AttributeFacade.java,v 1.1 2005/08/24 06:58:06 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import net.sourceforge.bprocessor.model.db.HibernateUtil; import org.apache.log4j.Logger; import org.hibernate.Session; import org.hibernate.Transaction; /** * Facade for attribute */ public class AttributeFacade { /** The logger */ private static Logger log = Logger.getLogger(AttributeFacade.class); /** The instance */ private static AttributeFacade instance; /** * Constructor */ private AttributeFacade() { } /** * Get the instance * @return The instance */ public static synchronized AttributeFacade getInstance() { if (instance == null) { instance = new AttributeFacade(); } return instance; } /** * Create an attribute * @param a The attribute * @return The created attribute */ public synchronized Attribute create(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); Transaction tx = session.beginTransaction(); session.save(a); tx.commit(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } finally { hu.closeSession(); } return a; } /** * Update an attribute * @param a The attribute */ public synchronized void update(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); Transaction tx = session.beginTransaction(); session.update(a); tx.commit(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } finally { hu.closeSession(); } } /** * Remove an attribute * @param a The attribute */ public synchronized void remove(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); Transaction tx = session.beginTransaction(); session.delete(a); tx.commit(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } finally { hu.closeSession(); } } /** * Find a attribute by id * @param id The id * @return The attribute */ public synchronized Attribute findById(Long id) { Attribute result = null; HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); Transaction tx = session.beginTransaction(); result = (Attribute)session.load(Attribute.class, id); tx.commit(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } finally { hu.closeSession(); } return result; } } |
From: Jesper P. <je...@us...> - 2005-08-24 06:57:41
|
Update of /cvsroot/bprocessor/model/src/etc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15744 Modified Files: bprocessor.xsd Log Message: Save the attribute value (string encoded) Index: bprocessor.xsd =================================================================== RCS file: /cvsroot/bprocessor/model/src/etc/bprocessor.xsd,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bprocessor.xsd 28 Jul 2005 06:52:58 -0000 1.2 --- bprocessor.xsd 24 Aug 2005 06:57:32 -0000 1.3 *************** *** 13,16 **** --- 13,17 ---- <xsd:element name="name" type="xsd:string"/> <xsd:element name="type" type="xsd:string"/> + <xsd:element name="value" type="xsd:string"/> </xsd:sequence> </xsd:complexType> |
From: Nordholt <nor...@us...> - 2005-08-23 12:11:13
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11833 Modified Files: Edge.java Log Message: Added method to get all surfaces an edge is a part of Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Edge.java 16 Aug 2005 11:45:03 -0000 1.5 --- Edge.java 23 Aug 2005 12:11:03 -0000 1.6 *************** *** 11,14 **** --- 11,16 ---- import org.apache.log4j.Logger; + import java.util.Set; + /** * The edge *************** *** 170,172 **** --- 172,182 ---- return "Edge[id=" + id + ",name=" + name + ",from=" + from + ",to=" + to + "]"; } + + /** + * Gets all surfaces this edge is a part of. + * @return the set of surfaces + */ + public Set getSurfaces() { + return SurfaceFacade.getInstance().findByEdge(this); + } } |
From: Nordholt <nor...@us...> - 2005-08-23 11:59:50
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8531 Modified Files: ViewYZ.java Log Message: The grid is can be seen in this view now, and selection works with gl Index: ViewYZ.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewYZ.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ViewYZ.java 17 Aug 2005 08:57:52 -0000 1.3 --- ViewYZ.java 23 Aug 2005 11:59:42 -0000 1.4 *************** *** 11,15 **** import net.java.games.jogl.GL; import net.java.games.jogl.GLDrawable; - import net.java.games.jogl.GLU; import org.apache.log4j.Logger; --- 11,14 ---- *************** *** 43,50 **** gl = gld.getGL(); ! GLU glu = gld.getGLU(); ! gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); double size = this.size * getZoomFactor(); if (width <= height) { --- 42,54 ---- gl = gld.getGL(); ! glu = gld.getGLU(); ! int[] viewport = new int[] {0, 0, (int)width, (int)height}; ! gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); + //Set the PickMatrix if we are trying to pick something + if (picking > 0) { + glu.gluPickMatrix(x, viewport[3] - y, 5, 5, viewport); + } double size = this.size * getZoomFactor(); if (width <= height) { *************** *** 90,99 **** gl.glBegin(GL.GL_LINES); for (int y = -(int)size; y <= size; y++) { ! gl.glVertex3d(90.0, (double)y, -size); ! gl.glVertex3d(90.0, (double)y, size); } for (int z = -(int)size; z <= size; z++) { ! gl.glVertex3d(90.0, -size, (double)z); ! gl.glVertex3d(90.0, size, (double)z); } gl.glEnd(); --- 94,103 ---- gl.glBegin(GL.GL_LINES); for (int y = -(int)size; y <= size; y++) { ! gl.glVertex3d(80.0, (double)y, -size); ! gl.glVertex3d(80.0, (double)y, size); } for (int z = -(int)size; z <= size; z++) { ! gl.glVertex3d(80.0, -size, (double)z); ! gl.glVertex3d(80.0, size, (double)z); } gl.glEnd(); |
From: Nordholt <nor...@us...> - 2005-08-23 11:59:35
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8461 Modified Files: ViewXZ.java Log Message: The grid is can be seen in this view now, and selection works with gl Index: ViewXZ.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewXZ.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ViewXZ.java 17 Aug 2005 08:57:52 -0000 1.3 --- ViewXZ.java 23 Aug 2005 11:59:25 -0000 1.4 *************** *** 11,15 **** import net.java.games.jogl.GL; import net.java.games.jogl.GLDrawable; - import net.java.games.jogl.GLU; import org.apache.log4j.Logger; --- 11,14 ---- *************** *** 43,51 **** gl = gld.getGL(); ! GLU glu = gld.getGLU(); // Matrix mode have to be projection for perspecive gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); double size = this.size * getZoomFactor(); if (width <= height) { --- 42,55 ---- gl = gld.getGL(); ! glu = gld.getGLU(); ! int[] viewport = new int[] {0, 0, (int)width, (int)height}; // Matrix mode have to be projection for perspecive gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); + //Set the PickMatrix if we are trying to pick something + if (picking > 0) { + glu.gluPickMatrix(x, viewport[3] - y, 5, 5, viewport); + } double size = this.size * getZoomFactor(); if (width <= height) { *************** *** 92,101 **** gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, 90.0, -size); ! gl.glVertex3d((double) x, 90.0, size); } for (int z = -(int)size; z <= (int)size; z++) { ! gl.glVertex3d(-size, 90.0, (double) z); ! gl.glVertex3d(size, 90.0, (double) z); } gl.glEnd(); --- 96,105 ---- gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, 80.0, -size); ! gl.glVertex3d((double) x, 80.0, size); } for (int z = -(int)size; z <= (int)size; z++) { ! gl.glVertex3d(-size, 80.0, (double) z); ! gl.glVertex3d(size, 80.0, (double) z); } gl.glEnd(); |
From: Nordholt <nor...@us...> - 2005-08-23 11:59:15
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8392 Modified Files: ViewXY.java Log Message: The grid is can be seen in this view now, and selection works with gl Index: ViewXY.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewXY.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ViewXY.java 17 Aug 2005 08:57:52 -0000 1.3 --- ViewXY.java 23 Aug 2005 11:59:07 -0000 1.4 *************** *** 11,15 **** import net.java.games.jogl.GL; import net.java.games.jogl.GLDrawable; - import net.java.games.jogl.GLU; import org.apache.log4j.Logger; --- 11,14 ---- *************** *** 43,50 **** gl = gld.getGL(); ! GLU glu = gld.getGLU(); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); double size = this.size * getZoomFactor(); if (width <= height) { --- 42,54 ---- gl = gld.getGL(); ! glu = gld.getGLU(); ! int[] viewport = new int[] {0, 0, (int)width, (int)height}; gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); + //Set the PickMatrix if we are trying to pick something + if (picking > 0) { + glu.gluPickMatrix(x, viewport[3] - y, 5, 5, viewport); + } double size = this.size * getZoomFactor(); if (width <= height) { *************** *** 89,98 **** gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, -size, -90.0); ! gl.glVertex3d((double) x, size, -90.0); } for (int y = -(int)size; y <= (int)size; y++) { ! gl.glVertex3d(-size, (double) y, -90.0); ! gl.glVertex3d(size, (double) y, -90.0); } gl.glEnd(); --- 93,102 ---- gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, -size, -80.0); ! gl.glVertex3d((double) x, size, -80.0); } for (int y = -(int)size; y <= (int)size; y++) { ! gl.glVertex3d(-size, (double) y, -80.0); ! gl.glVertex3d(size, (double) y, -80.0); } gl.glEnd(); |
From: Nordholt <nor...@us...> - 2005-08-23 11:57:07
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8024 Modified Files: SelectTool.java Log Message: support for deleting surfaces and edges Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SelectTool.java 22 Aug 2005 14:30:59 -0000 1.7 --- SelectTool.java 23 Aug 2005 11:56:48 -0000 1.8 *************** *** 22,25 **** --- 22,26 ---- import java.awt.event.MouseEvent; + import java.awt.event.KeyEvent; import java.util.Iterator; *************** *** 91,95 **** Notifier.getInstance().sendNotification(n); } - int x = e.getX(); int y = e.getY(); --- 92,95 ---- *************** *** 111,168 **** coordsx[0] == 0 && coordsx[1] == 0 && coordsx[2] == 0 && coordsy[0] == 0 && coordsy[1] == 0 && coordsy[2] == 0) { - Object o; viewType = View.VIEW_3D; ! o = view.getObjectAtPoint(x, y); ! if (o instanceof Vertex) { ! Vertex vertex = (Vertex)o; ! Notification n = new Notification(Notification.VERTEX_SELECTED, vertex.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! if (o instanceof Edge) { ! Edge edge = (Edge)o; ! Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! if (o instanceof Surface) { ! Surface surface = (Surface)o; Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } ! ! } else { ! Vertex v = vertexCollide(coords); ! if (v != null) { ! Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); Notifier.getInstance().sendNotification(n); - } else { - Edge edge = edgeCollide(coords); - if (edge != null) { - Surface sur = null; - if (e.getClickCount() >= 2) { - Set s = SurfaceFacade.getInstance().findByEdge(edge); - Iterator i = s.iterator(); - if (i.hasNext()) { - sur = (Surface)i.next(); - } - } - if (sur != null) { - Notification n = new Notification(Notification.SURFACE_SELECTED, sur.getId()); - Notifier.getInstance().sendNotification(n); - } else { - Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); - Notifier.getInstance().sendNotification(n); - } - } else { - Surface surface = surfaceCollide(coords, viewType); - if (surface != null) { - Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); - Notifier.getInstance().sendNotification(n); - } - } } ! } ! } } - /** --- 111,135 ---- coordsx[0] == 0 && coordsx[1] == 0 && coordsx[2] == 0 && coordsy[0] == 0 && coordsy[1] == 0 && coordsy[2] == 0) { viewType = View.VIEW_3D; ! } ! Vertex v = vertexCollide(coords); ! if ((v != null) && (viewType != View.VIEW_3D)) { ! Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); ! Notifier.getInstance().sendNotification(n); ! } else { ! Object selectObject; ! selectObject = view.getObjectAtPoint(x, y); ! if (selectObject instanceof Surface) { ! Surface surface = (Surface)selectObject; Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } else if (selectObject instanceof Edge) { ! Edge edge = (Edge)selectObject; ! Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); Notifier.getInstance().sendNotification(n); } ! } ! } } /** *************** *** 173,287 **** } - /** - * Check if this coordinate collides with an Surface - * @param coord The coordinate to check for collision at - * @param viewType The type of the view - * @return The excisting surface on that coord, null if there ain't any - */ - protected Surface surfaceCollide(double[] coord, int viewType) { - double x = 0; - double y = 0; - Set surfaces = SurfaceFacade.getInstance().findAll(); - Iterator surfaceIt = surfaces.iterator(); - while (surfaceIt.hasNext()) { - Surface s = (Surface)surfaceIt.next(); - List edgeSet = s.getEdges(); - int crossCount = 0; - Iterator edgeIt = edgeSet.iterator(); - while (edgeIt.hasNext()) { - Edge e = (Edge)edgeIt.next(); - boolean upCross = false; - boolean downCross = false; - double[] first = new double[]{0 , 0}; - double[] last = new double[]{0 , 0}; - double[] to = new double[]{0 , 0}; - double[] from = new double[]{0 , 0}; - if (viewType == View.VIEW_XY) { - to[0] = e.getTo().getX(); - to[1] = e.getTo().getY(); - from[0] = e.getFrom().getX(); - from[1] = e.getFrom().getY(); - x = coord[0]; - y = coord[1]; - } - if (viewType == View.VIEW_XZ) { - to[0] = e.getTo().getX(); - to[1] = e.getTo().getZ(); - from[0] = e.getFrom().getX(); - from[1] = e.getFrom().getZ(); - x = coord[0]; - y = coord[2]; - } - if (viewType == View.VIEW_YZ) { - to[0] = e.getTo().getZ(); - to[1] = e.getTo().getY(); - from[0] = e.getFrom().getZ(); - from[1] = e.getFrom().getY(); - x = coord[2]; - y = coord[1]; - } - if (to[0] < from[0]) { - first = to; - last = from; - } else { - first = from; - last = to; - } - if (first[1] < y && last[1] > y) { - upCross = true; - } else { - if (first[1] > y && last[1] < y) { - downCross = true; - } - } - double right = ((last[0] - first[0]) * (y - first[1]) - - (x - first[0]) * (last[1] - first[1])); - if (downCross && right > 0) { - crossCount++; - } - if (upCross && right < 0) { - crossCount++; - } - } - if (crossCount % 2 == 1) { - return s; - } - } - return null; - } - - /** - * Check if this coordinate collide with an edge - * @param coord The coordinate to check for collision at - * @return The excisting edge on that coord, null if there ain't any - */ - protected Edge edgeCollide(double[] coord) { - Set edges = EdgeFacade.getInstance().findAll(); - Iterator it = edges.iterator(); - while (it.hasNext()) { - Edge e = (Edge)it.next(); - double[] r = new double[] {e.getTo().getX() - e.getFrom().getX(), - e.getTo().getY() - e.getFrom().getY(), - e.getTo().getZ() - e.getFrom().getZ()}; - double[] ppo = new double[] {coord[0] - e.getFrom().getX(), - coord[1] - e.getFrom().getY(), - coord[2] - e.getFrom().getZ()}; - double normr = Math.abs(Math.sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2])); - double[] temp = new double[] {r[1] * ppo[2] - ppo[1] * r[2], - r[2] * ppo[0] - ppo[2] * r[0], - r[0] * ppo[1] - ppo[0] * r[1]}; - double t = Math.abs(Math.sqrt(temp[0] * temp[0] + - temp[1] * temp[1] + - temp[2] * temp[2])); - double normppo = Math.abs(Math.sqrt(ppo[0] * ppo[0] + ppo[1] * ppo[1] + ppo[2] * ppo[2])); - double rppo = r[0] * ppo[0] + r[1] * ppo[1] + r[2] * ppo[2]; - - if (t / normr < EPSILON && normppo <= normr && rppo > 0) { - return e; - } - } - return null; - } - /** * Check if this cordinate collide with another vertex --- 140,143 ---- *************** *** 311,315 **** return Math.abs(a - b) < EPSILON; } ! /** * Handle a notification --- 167,237 ---- return Math.abs(a - b) < EPSILON; } ! ! ! /** ! * Invoked when a key has been pressed. Lets user delete what is selected. ! * @param e The KeyEvent ! */ ! public void keyPressed(KeyEvent e) { ! if (e.getKeyCode() == KeyEvent.VK_DELETE) { ! if (selectedSurface != null) { ! Notification n = new Notification(Notification.SURFACE_DESELECTED, ! selectedSurface.getId()); ! Notifier.getInstance().sendNotification(n); ! deleteSurface(selectedSurface); ! } else if (selectedEdge != null) { ! if (selectedEdge.getSurfaces().size() < 1) { ! Notification n = new Notification(Notification.EDGE_DESELECTED, ! selectedEdge.getId()); ! Notifier.getInstance().sendNotification(n); ! deleteEdge(selectedEdge); ! } ! } ! } else { ! super.keyPressed(e); ! } ! } ! ! ! /** ! * Deletes a surface and its edges if it is safe to do so. ! * @param surface the surface to delete ! */ ! private void deleteSurface(Surface surface) { ! List edges = surface.getEdges(); ! Iterator it = edges.iterator(); ! Edge edge = null; ! removeSurface(surface); ! while (it.hasNext()) { ! edge = (Edge)it.next(); ! deleteEdge(edge); ! } ! ! } ! ! /** ! * Deletes an edge and it's endpoint vertecies if it is safe to do so. ! * @param edge the edge to delete ! */ ! private void deleteEdge(Edge edge) { ! Set surfaces = edge.getSurfaces(); ! if (surfaces.size() < 1) { ! removeEdge(edge); ! deleteVertex(edge.getTo()); ! deleteVertex(edge.getFrom()); ! } ! } ! ! /** ! * Deletes a vertex if it is safe to do so. ! * @param vertex the vertex to delete ! */ ! private void deleteVertex(Vertex vertex) { ! Set edges = vertex.getEdges(); ! if (edges.size() < 1) { ! removeVertex(vertex); ! } ! } ! /** * Handle a notification |
From: Nordholt <nor...@us...> - 2005-08-23 11:55:48
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7768 Modified Files: AbstractTool.java Log Message: Added method to remove a surface for good Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractTool.java 17 Aug 2005 09:01:26 -0000 1.8 --- AbstractTool.java 23 Aug 2005 11:55:38 -0000 1.9 *************** *** 112,116 **** } else if (e.getKeyChar() == KeyEvent.VK_4) { glv.changeView(View.VIEW_YZ); ! } glv.repaint(); } --- 112,116 ---- } else if (e.getKeyChar() == KeyEvent.VK_4) { glv.changeView(View.VIEW_YZ); ! } glv.repaint(); } *************** *** 345,348 **** --- 345,356 ---- return s; } + + /** + * Remove a Surface for good + * @param s Surface to remove + */ + protected void removeSurface(Surface s) { + SurfaceFacade.getInstance().remove(s); + } /** |
From: Nordholt <nor...@us...> - 2005-08-23 11:53:36
|
Update of /cvsroot/bprocessor/build/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7313 Modified Files: README Log Message: Added desribtion of delete key Index: README =================================================================== RCS file: /cvsroot/bprocessor/build/doc/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README 19 Aug 2005 09:45:15 -0000 1.2 --- README 23 Aug 2005 11:53:29 -0000 1.3 *************** *** 36,45 **** COMMA : Zoom out When using the move tool in 3D view: ! A: XY movement mode ! S: XZ movement mode ! Z: decrease movement speed ! X: increase movement speed Homepage: --- 36,47 ---- COMMA : Zoom out + DELETE : Delete the selected object. + When using the move tool in 3D view: ! A : XY movement mode ! S : XZ movement mode ! Z : Decrease movement speed ! X : Increase movement speed Homepage: |
From: Jesper P. <je...@us...> - 2005-08-23 10:49:53
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25524 Added Files: FilePropertiesActionListener.java Log Message: Initial import --- NEW FILE: FilePropertiesActionListener.java --- //--------------------------------------------------------------------------------- // $Id: FilePropertiesActionListener.java,v 1.1 2005/08/23 10:49:45 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.actions; import net.sourceforge.bprocessor.gui.properties.PropertiesDialog; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import org.apache.log4j.Logger; /** * The file->properties action listener */ public class FilePropertiesActionListener implements ActionListener { /** The logger */ private static Logger log = Logger.getLogger(FilePropertiesActionListener.class); /** * FilePropertiesActionListener */ public FilePropertiesActionListener() { } /** * Action performed * @param e The action event */ public void actionPerformed(ActionEvent e) { PropertiesDialog pd = new PropertiesDialog(); pd.show(); } } |
From: Jesper P. <je...@us...> - 2005-08-23 10:48:39
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25253 Added Files: GenericDatabase.java HSQLDB.java PostgreSQL.java PropertiesDialog.java VisualDatabase.java Log Message: Initial import --- NEW FILE: HSQLDB.java --- //--------------------------------------------------------------------------------- // $Id: HSQLDB.java,v 1.1 2005/08/23 10:48:31 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.properties; import net.sourceforge.bprocessor.model.db.AbstractDatabase; import java.awt.BorderLayout; import javax.swing.ButtonGroup; import javax.swing.JPanel; import javax.swing.JRadioButton; import org.apache.log4j.Logger; /** * HyperSonic SQL */ public class HSQLDB extends AbstractDatabase implements VisualDatabase { /** The logger */ private static Logger log = Logger.getLogger(HSQLDB.class); /** The panel */ private JPanel panel; /** Memory */ private JRadioButton memory; /** File */ private JRadioButton file; /** * Constructor */ public HSQLDB() { super(net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().getUrl(), net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().getUser(), net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().getPassword(), net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().getAutodrop()); panel = new JPanel(); panel.setLayout(new BorderLayout()); ButtonGroup group = new ButtonGroup(); memory = new JRadioButton("Memory"); group.add(memory); file = new JRadioButton("File"); group.add(file); if (getUrl().indexOf("mem") != -1) { memory.setSelected(true); } else { //file.setSelected(true); } panel.add(memory, BorderLayout.NORTH); //panel.add(file, BorderLayout.SOUTH); } /** * Get the panel * @return The panel */ public JPanel getPanel() { return panel; } /** * Apply the changes */ public void apply() { if (memory.isSelected()) { setUrl("jdbc:hsqldb:mem:bprocessor"); setUser(""); setPassword(""); setAutodrop(true); } else { setUrl("jdbc:hsqldb:file:bprocessor"); setUser(""); setPassword(""); setAutodrop(true); } } /** * Get the name * @return The name of the database */ public String getName() { return net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().getName(); } /** * Get the type * @return The type of the database */ public int getType() { return net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().getType(); } /** * Is the database enabled ? * @return True if enabled; otherwise false */ public boolean isEnabled() { return net.sourceforge.bprocessor.model.db.HSQLDB.getInstance().isEnabled(); } /** * String representation * @return The representation */ public String toString() { return getName(); } } --- NEW FILE: PropertiesDialog.java --- //--------------------------------------------------------------------------------- // $Id: PropertiesDialog.java,v 1.1 2005/08/23 10:48:31 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.properties; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTabbedPane; import org.apache.log4j.Logger; /** * The properties dialog class */ public class PropertiesDialog extends JDialog { /** The logger */ private static Logger log = Logger.getLogger(PropertiesDialog.class); /** The database panel */ private DatabasePanel databasePanel; /** * Constructor */ public PropertiesDialog() { setTitle("Properties"); databasePanel = new DatabasePanel(); JTabbedPane tp = new JTabbedPane(); tp.addTab("Database", databasePanel); JPanel buttonPanel = new JPanel(); JButton ok = new JButton("Ok"); ok.addActionListener(new OkAction()); buttonPanel.add(ok); JButton cancel = new JButton("Cancel"); cancel.addActionListener(new CancelAction()); buttonPanel.add(cancel); getContentPane().add(tp, BorderLayout.CENTER); getContentPane().add(buttonPanel, BorderLayout.SOUTH); pack(); } /** * Database panel */ class DatabasePanel extends JPanel { /** The selected database */ private VisualDatabase selected; /** * Constructor */ DatabasePanel() { JComboBox cb = new JComboBox(); VisualDatabase db = new HSQLDB(); if (db.isEnabled()) { cb.addItem(db); } db = new PostgreSQL(); if (db.isEnabled()) { cb.addItem(db); } selected = (VisualDatabase)cb.getSelectedItem(); cb.addItemListener(new DatabaseListener(cb)); setLayout(new BorderLayout()); add(cb, BorderLayout.NORTH); add(selected.getPanel(), BorderLayout.CENTER); } /** * Get the selected database * @return The selected database */ VisualDatabase getSelected() { return selected; } /** * Set the selected database * @param database The selected database */ void setSelected(VisualDatabase database) { remove(selected.getPanel()); selected = database; add(selected.getPanel(), BorderLayout.CENTER); } } /** * Database listener */ class DatabaseListener implements ItemListener { /** Databases */ private JComboBox databases; /** * Constructor * @param databases The database list */ DatabaseListener(JComboBox databases) { this.databases = databases; } /** * Item state changed * @param event The event */ public void itemStateChanged(ItemEvent event) { databasePanel.setSelected((VisualDatabase)databases.getSelectedItem()); } } /** * Ok action */ class OkAction implements ActionListener { /** * Action performed * @param event The event */ public void actionPerformed(ActionEvent event) { VisualDatabase db = databasePanel.getSelected(); db.apply(); Settings settings = Settings.getInstance(); settings.setProperty(Settings.DATABASE_TYPE, Integer.toString(db.getType())); settings.setProperty(Settings.CONNECTION_URL, db.getUrl()); settings.setProperty(Settings.CONNECTION_USER, db.getUser()); settings.setProperty(Settings.CONNECTION_PASSWORD, db.getPassword()); settings.setProperty(Settings.CONNECTION_AUTODROP, Boolean.toString(db.getAutodrop())); settings.apply(); log.info("Activating database: " + db.getName()); dispose(); } } /** * Cancel action */ class CancelAction implements ActionListener { /** * Action performed * @param event The event */ public void actionPerformed(ActionEvent event) { dispose(); } } } --- NEW FILE: PostgreSQL.java --- //--------------------------------------------------------------------------------- // $Id: PostgreSQL.java,v 1.1 2005/08/23 10:48:31 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.properties; import org.apache.log4j.Logger; /** * PostgreSQL */ public class PostgreSQL extends GenericDatabase { /** The logger */ private static Logger log = Logger.getLogger(PostgreSQL.class); /** * Constructor */ public PostgreSQL() { super(net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().getUrl(), net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().getUser(), net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().getPassword(), net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().getAutodrop()); String std = getUrl(); String h = ""; String p = ""; String d = ""; if (std.indexOf("//") != -1) { std = std.substring(std.indexOf("//") + 2); h = std.substring(0, std.indexOf(":")); p = std.substring(std.indexOf(":") + 1, std.indexOf("/")); d = std.substring(std.indexOf("/") + 1); } iHost.setText(h); iPort.setText(p); iDatabase.setText(d); } /** * Apply the changes */ public void apply() { String h = iHost.getText(); if (h == null) { h = "localhost"; } else { h = h.trim(); } String p = iPort.getText(); if (p == null) { p = "5432"; } else { p = p.trim(); } String d = iDatabase.getText(); if (d == null) { d = "bprocessor"; } else { d = d.trim(); } String u = iUser.getText(); if (u == null) { u = ""; } else { u = u.trim(); } String pwd = iPassword.getText(); if (pwd == null) { pwd = ""; } else { pwd = pwd.trim(); } setUrl("jdbc:postgresql://" + h + ":" + p + "/" + d); setUser(u); setPassword(pwd); setAutodrop(iAutodrop.isSelected()); } /** * Get the name * @return The name of the database */ public String getName() { return net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().getName(); } /** * Get the type * @return The type of the database */ public int getType() { return net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().getType(); } /** * Is the database enabled ? * @return True if enabled; otherwise false */ public boolean isEnabled() { return net.sourceforge.bprocessor.model.db.PostgreSQL.getInstance().isEnabled(); } } --- NEW FILE: VisualDatabase.java --- //--------------------------------------------------------------------------------- // $Id: VisualDatabase.java,v 1.1 2005/08/23 10:48:31 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.properties; import net.sourceforge.bprocessor.model.db.Database; import javax.swing.JPanel; /** * Visual database */ public interface VisualDatabase extends Database { /** * Get the panel * @return The panel */ public JPanel getPanel(); /** * Apply the changes */ public void apply(); } --- NEW FILE: GenericDatabase.java --- //--------------------------------------------------------------------------------- // $Id: GenericDatabase.java,v 1.1 2005/08/23 10:48:31 jews Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.properties; import net.sourceforge.bprocessor.model.db.AbstractDatabase; import java.awt.GridLayout; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import org.apache.log4j.Logger; /** * Generic database */ public abstract class GenericDatabase extends AbstractDatabase implements VisualDatabase { /** The logger */ private static Logger log = Logger.getLogger(GenericDatabase.class); /** The panel */ protected JPanel panel; /** Host */ protected JLabel lHost; /** Host */ protected JTextField iHost; /** Port */ protected JLabel lPort; /** Port */ protected JTextField iPort; /** Database */ protected JLabel lDatabase; /** Database */ protected JTextField iDatabase; /** User */ protected JLabel lUser; /** User */ protected JTextField iUser; /** Password */ protected JLabel lPassword; /** Password */ protected JTextField iPassword; /** Autodrop */ protected JLabel lAutodrop; /** Auto drop */ protected JCheckBox iAutodrop; /** * Constructor * @param url The url * @param user The user * @param password The password * @param autodrop The autodrop */ public GenericDatabase(String url, String user, String password, boolean autodrop) { super(url, user, password, autodrop); panel = new JPanel(); panel.setLayout(new GridLayout(6, 2)); lHost = new JLabel("Host"); iHost = new JTextField(); lPort = new JLabel("Port"); iPort = new JTextField(); lDatabase = new JLabel("Database"); iDatabase = new JTextField(); lUser = new JLabel("User"); iUser = new JTextField(getUser()); lPassword = new JLabel("Password"); iPassword = new JTextField(getPassword()); lAutodrop = new JLabel("Auto drop"); iAutodrop = new JCheckBox(); iAutodrop.setSelected(getAutodrop()); panel.add(lHost); panel.add(iHost); panel.add(lPort); panel.add(iPort); panel.add(lDatabase); panel.add(iDatabase); panel.add(lUser); panel.add(iUser); panel.add(lPassword); panel.add(iPassword); panel.add(lAutodrop); panel.add(iAutodrop); } /** * Get the panel * @return The panel */ public JPanel getPanel() { return panel; } /** * Apply the changes */ public abstract void apply(); /** * Get the name * @return The name of the database */ public abstract String getName(); /** * Get the type * @return The type of the database */ public abstract int getType(); /** * Is the database enabled ? * @return True if enabled; otherwise false */ public abstract boolean isEnabled(); /** * String representation * @return The representation */ public String toString() { return getName(); } } |
From: Jesper P. <je...@us...> - 2005-08-23 10:47:35
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25043 Modified Files: GUI.java Log Message: Enable properties for application Index: GUI.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/GUI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GUI.java 4 Aug 2005 06:06:48 -0000 1.6 --- GUI.java 23 Aug 2005 10:47:27 -0000 1.7 *************** *** 16,19 **** --- 16,20 ---- import net.sourceforge.bprocessor.gui.actions.FileExportActionListener; import net.sourceforge.bprocessor.gui.actions.FileImportActionListener; + import net.sourceforge.bprocessor.gui.actions.FilePropertiesActionListener; import net.sourceforge.bprocessor.gui.actions.ToolsDetachActionListener; import net.sourceforge.bprocessor.gui.actions.ToolsJoinActionListener; *************** *** 114,118 **** JMenuItem fileProperties = new JMenuItem("Properties"); fileProperties.setMnemonic(KeyEvent.VK_P); ! fileProperties.setEnabled(false); file.add(fileProperties); --- 115,119 ---- JMenuItem fileProperties = new JMenuItem("Properties"); fileProperties.setMnemonic(KeyEvent.VK_P); ! fileProperties.addActionListener(new FilePropertiesActionListener()); file.add(fileProperties); *************** *** 130,133 **** --- 131,146 ---- edit.setMnemonic(KeyEvent.VK_E); + JMenuItem editUndo = new JMenuItem("Undo"); + editUndo.setMnemonic(KeyEvent.VK_N); + editUndo.setEnabled(false); + edit.add(editUndo); + + JMenuItem editRedo = new JMenuItem("Redo"); + editRedo.setMnemonic(KeyEvent.VK_R); + editRedo.setEnabled(false); + edit.add(editRedo); + + edit.addSeparator(); + JMenuItem editCut = new JMenuItem("Cut"); editCut.setMnemonic(KeyEvent.VK_U); |
From: Michael L. <he...@us...> - 2005-08-22 14:31:14
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28239/src/net/sourceforge/bprocessor/gl/tool Modified Files: ToolFactory.java SelectTool.java Added Files: PencilTool.java Removed Files: DebugTool.java Log Message: Vertex selection in getObjectAt() --- DebugTool.java DELETED --- Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ToolFactory.java 10 Aug 2005 12:42:46 -0000 1.3 --- ToolFactory.java 22 Aug 2005 14:30:59 -0000 1.4 *************** *** 44,48 **** /** debug tool */ ! private DebugTool debug; /** --- 44,48 ---- /** debug tool */ ! private PencilTool debug; /** *************** *** 55,59 **** move = new MoveTool(glv); extrusion = new ExtrusionTool(glv); ! debug = new DebugTool(glv); Toolbar tb = Toolbar.getInstance(); --- 55,59 ---- move = new MoveTool(glv); extrusion = new ExtrusionTool(glv); ! debug = new PencilTool(glv); Toolbar tb = Toolbar.getInstance(); *************** *** 239,243 **** this.glv = glv; ClassLoader cl = Thread.currentThread().getContextClassLoader(); ! URL url = cl.getResource("selecticon.png"); ImageIcon im = new ImageIcon(url); putValue(Action.SMALL_ICON, im); --- 239,243 ---- this.glv = glv; ClassLoader cl = Thread.currentThread().getContextClassLoader(); ! URL url = cl.getResource("drawicon.png"); ImageIcon im = new ImageIcon(url); putValue(Action.SMALL_ICON, im); Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SelectTool.java 19 Aug 2005 09:49:20 -0000 1.6 --- SelectTool.java 22 Aug 2005 14:30:59 -0000 1.7 *************** *** 114,117 **** --- 114,122 ---- viewType = View.VIEW_3D; o = view.getObjectAtPoint(x, y); + if (o instanceof Vertex) { + Vertex vertex = (Vertex)o; + Notification n = new Notification(Notification.VERTEX_SELECTED, vertex.getId()); + Notifier.getInstance().sendNotification(n); + } if (o instanceof Edge) { Edge edge = (Edge)o; *************** *** 123,127 **** Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } } else { Vertex v = vertexCollide(coords); --- 128,133 ---- Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } ! } else { Vertex v = vertexCollide(coords); --- NEW FILE: PencilTool.java --- //--------------------------------------------------------------------------------- // $Id: PencilTool.java,v 1.1 2005/08/22 14:30:59 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gl.tool; import java.awt.event.MouseEvent; import java.util.LinkedList; import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; /** * The DebugTool */ public class PencilTool extends SelectTool { /** The height */ private int height = 0; /** The current number of surfaces */ private int number = 0; /** The current factor */ private int factor = 0; /** * Constructor * @param glv The GLView */ public PencilTool(GLView glv) { super(glv); } /** * Create n surfaces to test performance. * @param n The number of surfaces to create */ void createSurfaces(int n) { double coords[] = new double[3]; coords[0] = -1; coords[1] = height; coords[2] = -1; Vertex a = createVertex(coords); coords[0] = 1; coords[1] = height; coords[2] = -1; Vertex b = createVertex(coords); coords[0] = 1; coords[1] = height; coords[2] = 1; Vertex c = createVertex(coords); coords[0] = -1; coords[1] = height; coords[2] = 1; height++; Vertex d = createVertex(coords); Edge e1 = createEdge(a, b); Edge e2 = createEdge(b, c); Edge e3 = createEdge(c, d); Edge e4 = createEdge(d, a); LinkedList edges = new LinkedList(); edges.add(e1); edges.add(e2); edges.add(e3); edges.add(e4); Surface s = createSurface(edges); } /** * Invoked when a mouse button has been pressed on a component. * @param e The MouseEvent object */ protected void pressed(MouseEvent e) { super.pressed(e); int x = e.getX(); int y = e.getY(); View v = glv.getView(); } /** * Invoked when the mouse cursor has been moved * @param e The MouseEvent object */ protected void moved(MouseEvent e) { int x = e.getX(); int y = e.getY(); View v = glv.getView(); } /** * Invoked when the mouse is held pressed and moved * @param e The MouseEvent object */ protected void dragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); View v = glv.getView(); } /** * Invoked when a mouse button has been released on a component. * @param e The MouseEvent */ protected void released(MouseEvent e) { int x = e.getX(); int y = e.getY(); View v = glv.getView(); } } |
From: Michael L. <he...@us...> - 2005-08-22 14:31:08
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28239/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java Log Message: Vertex selection in getObjectAt() Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractView.java 17 Aug 2005 17:39:19 -0000 1.8 --- AbstractView.java 22 Aug 2005 14:30:57 -0000 1.9 *************** *** 72,75 **** --- 72,79 ---- private static final int SURFACES = 1; + /** Select for for selecting vertices */ + + private static final int VERTICES = 2; + /** The width of the window */ protected static double width; *************** *** 251,256 **** --- 255,263 ---- */ protected void drawAll(GLDrawable gld) { + Set surfaces = SurfaceFacade.getInstance().findAll(); Set edges = EdgeFacade.getInstance().findAll(); + Set vertices = VertexFacade.getInstance().findAll(); + int[] mode = new int[1]; gl.glGetIntegerv(GL.GL_RENDER_MODE, mode); *************** *** 379,382 **** --- 386,401 ---- } } + + if (selectMode == VERTICES) { + Iterator it = vertices.iterator(); + gl.glColor3dv(STD_LINE_COLOR); + while (it.hasNext()) { + Vertex v = (Vertex)it.next(); + int name = v.getId().intValue(); + gl.glPushName(name); + drawVertex(v); + gl.glPopName(); + } + } } } *************** *** 435,438 **** --- 454,467 ---- } } + + /** + * Draw a Vertex + * @param v The Vertex to draw + */ + private void drawVertex(Vertex v) { + gl.glBegin(GL.GL_POINTS); + gl.glVertex3d(v.getX(), v.getY(), v.getZ()); + gl.glEnd(); + } /** *************** *** 670,673 **** --- 699,713 ---- this.x = x; this.y = y; + + // indicating that I am trying to pick(used in camera) + picking = 10; + selectMode = VERTICES; + //repainting to get selection buffer + glv.repaint(true); + id = processSelect(); + if (id != null) { + Vertex v = VertexFacade.getInstance().findById(id); + return v; + } //indicating that I am trying to pick(used in camera) picking = 10; |