[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view ViewToolbarFactory.java, 1.7, 1.8 Vie
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-09-14 16:23:08
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20840/src/net/sourceforge/bprocessor/gl/view Modified Files: ViewToolbarFactory.java View.java Display.java Log Message: Brunata Index: ViewToolbarFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewToolbarFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ViewToolbarFactory.java 18 Nov 2007 21:30:16 -0000 1.7 --- ViewToolbarFactory.java 14 Sep 2009 16:22:59 -0000 1.8 *************** *** 15,18 **** --- 15,19 ---- import javax.swing.ButtonGroup; import javax.swing.ImageIcon; + import javax.swing.JComponent; import javax.swing.JToggleButton; *************** *** 24,27 **** --- 25,67 ---- */ public class ViewToolbarFactory { + + private static ViewToolbarFactory instance; + + private JComponent s1; + private JToggleButton shading; + private JToggleButton solid; + private JToggleButton wireframe; + + private JComponent s2; + private JToggleButton noraster; + private JToggleButton grid; + private JToggleButton edges; + + /** + * + * @return me + */ + public static ViewToolbarFactory instance() { + if (instance == null) { + instance = new ViewToolbarFactory(); + } + return instance; + } + + /** + * + */ + public void setup() { + Toolbar toolbar = Toolbar.getInstance(); + toolbar.addButton(s1); + toolbar.addButton(shading); + toolbar.addButton(solid); + toolbar.addButton(wireframe); + toolbar.addButton(s2); + toolbar.addButton(noraster); + toolbar.addButton(grid); + toolbar.addButton(edges); + } + /** * Registers the buttons in the toolbar *************** *** 30,67 **** public void registerToolbar(Editor editor) { Toolbar tb = Toolbar.getInstance(); - tb.addSeparator(5); ButtonGroup bg = new ButtonGroup(); ! JToggleButton but = tb.registerAction(new ViewLighting(editor)); ! bg.add(but); ! but.setToolTipText("Shading"); ! but.setMnemonic(KeyEvent.VK_F5); ! but.setSelected(true); ! but = tb.registerAction(new ViewSolid(editor)); ! bg.add(but); ! but.setToolTipText("Solid"); ! but.setMnemonic(KeyEvent.VK_F7); ! but = tb.registerAction(new ViewWireframe(editor)); ! bg.add(but); ! but.setToolTipText("Wireframe"); ! but.setMnemonic(KeyEvent.VK_F8); ! tb.addSeparator(5); ! but = tb.registerAction(new ViewNoRaster(editor)); ! but.setSelected(true); ! but.setToolTipText("Shading no raster"); ! but.setMnemonic(KeyEvent.VK_F6); ! but = tb.registerAction(new ViewGrid(editor)); ! but.setToolTipText("Grid"); ! but.setSelected(true); ! but = tb.registerAction(new ViewEdges(editor)); ! but.setToolTipText("Edges"); ! but.setSelected(true); } --- 70,107 ---- public void registerToolbar(Editor editor) { Toolbar tb = Toolbar.getInstance(); ButtonGroup bg = new ButtonGroup(); ! s1 = tb.addSeparator(5); ! shading = tb.registerAction(new ViewLighting(editor)); ! bg.add(shading); ! shading.setToolTipText("Shading"); ! shading.setMnemonic(KeyEvent.VK_F5); ! shading.setSelected(true); ! solid = tb.registerAction(new ViewSolid(editor)); ! bg.add(solid); ! solid.setToolTipText("Solid"); ! solid.setMnemonic(KeyEvent.VK_F7); ! wireframe = tb.registerAction(new ViewWireframe(editor)); ! bg.add(wireframe); ! wireframe.setToolTipText("Wireframe"); ! wireframe.setMnemonic(KeyEvent.VK_F8); ! s2 = tb.addSeparator(5); ! noraster = tb.registerAction(new ViewNoRaster(editor)); ! noraster.setSelected(true); ! noraster.setToolTipText("Shading no raster"); ! noraster.setMnemonic(KeyEvent.VK_F6); ! grid = tb.registerAction(new ViewGrid(editor)); ! grid.setToolTipText("Grid"); ! grid.setSelected(true); ! edges = tb.registerAction(new ViewEdges(editor)); ! edges.setToolTipText("Edges"); ! edges.setSelected(true); } Index: Display.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/Display.java,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** Display.java 9 Sep 2009 10:31:03 -0000 1.96 --- Display.java 14 Sep 2009 16:22:59 -0000 1.97 *************** *** 875,879 **** ! private static boolean transparent(Surface surface) { Space front = surface.getFrontDomain(); Space back = surface.getBackDomain(); --- 875,884 ---- ! /** ! * ! * @param surface Surface ! * @return true if transparent ! */ ! public static boolean transparent(Surface surface) { Space front = surface.getFrontDomain(); Space back = surface.getBackDomain(); Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.290 retrieving revision 1.291 diff -C2 -d -r1.290 -r1.291 *** View.java 25 Jun 2009 22:17:40 -0000 1.290 --- View.java 14 Sep 2009 16:22:59 -0000 1.291 *************** *** 35,38 **** --- 35,39 ---- import java.util.ArrayList; + import java.util.Date; import java.util.HashSet; import java.util.Iterator; *************** *** 765,768 **** --- 766,773 ---- drawSpacePath(hitdetection); + + if (Editor.getViewing()) { + drawDate(); + } for (Widget widget : widgets) { *************** *** 1012,1015 **** --- 1017,1032 ---- /** + * + */ + public void drawDate() { + Date date = Project.getInstance().getDate(); + if (date != null) { + String string = date.toString(); + gl.glColor3d(0.1, 0.1, 0.1); + drawString(13, 13, 1, string); + } + } + + /** * Draw string at specified position * @param x The x position *************** *** 1866,1869 **** --- 1883,1954 ---- return selection; } + + /** + * + * @param x x + * @param y y + * @return surface + */ + public Surface getSelectedSurface(double x, double y) { + this.x = x; + this.y = y; + + picking = 10; + + editor.repaint(true); + + { + int bufferOffset = 0; + int names = 0; + long zMax = 0xFFFFFFFFL; + double nearestSurface = 1.0; + SelectionPath surface = null; + + for (int i = 0; i < hits; i++) { + names = selectBuffer.get(bufferOffset); + if (names > 0) { + long z1 = 0xFFFFFFFFL & selectBuffer.get(bufferOffset + 1); + long z2 = 0xFFFFFFFFL & selectBuffer.get(bufferOffset + 2); + double near = (double) z1 / (double) zMax; + double far = (double) z2 / (double) zMax; + near = (near + far) / 2; + bufferOffset += 2; + SelectionPath currentPath = new SelectionPath(); + if (names > 1) { + for (int namesIndex = 1; namesIndex < names; namesIndex++) { + Instance instance = (Instance)getObject(selectBuffer.get(bufferOffset + namesIndex)); + currentPath.addGeometricToPath(instance); + } + if (currentPath == null) { + bufferOffset += names + 1; + continue; + } + } + int id = selectBuffer.get(bufferOffset + names); + bufferOffset += names + 1; + Object current = getObject(id); + + if (current instanceof Surface) { + Surface it = (Surface) current; + if (!Display.transparent(it)) { + if (near < nearestSurface) { + nearestSurface = near; + currentPath.addGeometricToPath((Surface) current); + surface = currentPath; + } + } + } + } else { + bufferOffset += 3; + } + } + clearNames(); + if (surface != null) { + return ((Surface)surface.getLastInPath()); + } else { + return null; + } + } + } /** |