Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4636/src/net/sourceforge/bprocessor/gl/view
Modified Files:
View.java
Log Message:
Widgets are being implemented
Index: View.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v
retrieving revision 1.175
retrieving revision 1.176
diff -C2 -d -r1.175 -r1.176
*** View.java 25 Jan 2007 12:14:30 -0000 1.175
--- View.java 26 Jan 2007 14:04:57 -0000 1.176
***************
*** 8,15 ****
import net.sourceforge.bprocessor.gl.GLView;
- import net.sourceforge.bprocessor.gl.tool.ClickBox;
import net.sourceforge.bprocessor.gl.tool.SpaceTool;
import net.sourceforge.bprocessor.gl.model.GlObject;
import net.sourceforge.bprocessor.gl.model.Intersection;
import net.sourceforge.bprocessor.gui.Toolbar;
--- 8,17 ----
import net.sourceforge.bprocessor.gl.GLView;
import net.sourceforge.bprocessor.gl.tool.SpaceTool;
import net.sourceforge.bprocessor.gl.model.GlObject;
import net.sourceforge.bprocessor.gl.model.Intersection;
+ import net.sourceforge.bprocessor.gl.model.Label;
+ import net.sourceforge.bprocessor.gl.model.SpaceBox;
+ import net.sourceforge.bprocessor.gl.model.Widget;
import net.sourceforge.bprocessor.gui.Toolbar;
***************
*** 360,363 ****
--- 362,370 ----
*/
private Set glObjects3D;
+
+ /**
+ * A list of Widget objects displayed on top of the 3d model.
+ */
+ private List<Widget> widgets;
/** Max number of clipplanes */
***************
*** 480,484 ****
colorMap = new HashMap();
glObjects3D = new HashSet();
!
Toolbar tb = Toolbar.getInstance();
tb.addSeparator(3);
--- 487,492 ----
colorMap = new HashMap();
glObjects3D = new HashSet();
! widgets = new LinkedList<Widget>();
!
Toolbar tb = Toolbar.getInstance();
tb.addSeparator(3);
***************
*** 652,655 ****
--- 660,668 ----
gl.glLoadIdentity();
drawSpacePath(hitdetection);
+
+ for (Widget widget : widgets) {
+ widget.display(gl, glu, hitdetection);
+ }
+
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
***************
*** 1033,1036 ****
--- 1046,1085 ----
}
+ private void drawPath(LinkedList<Space> path, boolean selection) {
+ LinkedList<Label> labels = new LinkedList<Label>();
+ Label divider = new Label(">>");
+ boolean first = true;
+ for (Space space : path) {
+ if (!first) {
+ labels.add(divider);
+ } else {
+ first = false;
+ }
+ labels.add(new SpaceBox(space));
+ }
+
+ int x = 5;
+ int y = (int) height - 15;
+ for (Label label : labels) {
+ label.setX(x);
+ label.setY(y);
+ x += label.width() + 6;
+ }
+
+ gl.glColor3f(1, 0, 0);
+ gl.glPushMatrix();
+ gl.glTranslated(0, 0, 0.5);
+ for (Label label : labels) {
+ if (selection) {
+ pushName(gl, label);
+ }
+ label.display(gl, glu, selection);
+ if (selection) {
+ popName(gl);
+ }
+ }
+ gl.glPopMatrix();
+ }
+
/**
* Draw the space path
***************
*** 1046,1090 ****
path.addFirst(active);
}
! String name = "";
! Iterator it = path.iterator();
! if (it.hasNext()) {
! Space sp = (Space)it.next();
! if (sp.getClassification() != null) {
! name = sp.getClassification().toString();
! } else {
! name = sp.getName();
! }
! int sepLength = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, " >> ");;
! int length = 0;
! int nameLength = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, name);
! if (selection) {
! drawClickBox(5 + length, height - 15, 0.5,
! nameLength, 10, new ClickBox(sp));
! }
! length = nameLength;
! while (it.hasNext()) {
! sp = (Space)it.next();
! if (sp.getClassification() != null) {
! name = name + " >> " + sp.getClassification().toString();
! } else {
! name = name + " >> " + sp.getName();
! }
! length += sepLength;
! nameLength = glut.glutBitmapLength(GLUT.BITMAP_HELVETICA_12, sp.getName());
! if (selection) {
! drawClickBox(5 + length, height - 15, 0.5,
! nameLength, 10, new ClickBox(sp));
! }
! length += nameLength;
! }
! }
! if (!selection) {
! gl.glColor3d(1.0, 0.0, 0.0);
! gl.glPushMatrix();
! gl.glTranslated(5, height - 15, 0.5);
! gl.glRasterPos2i(0, 0);
! glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, name);
! gl.glPopMatrix();
! }
}
--- 1095,1099 ----
path.addFirst(active);
}
! drawPath(path, selection);
}
***************
*** 3387,3389 ****
--- 3396,3414 ----
this.glObjects3D.add(glo);
}
+
+ /**
+ *
+ * @param widget Widget
+ */
+ public void add(Widget widget) {
+ widgets.add(widget);
+ }
+
+ /**
+ *
+ * @param widget Widget
+ */
+ public void remove(Widget widget) {
+ widgets.remove(widget);
+ }
}
|