[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] libvob/doc/pegboard/vob_event_action--mudyc peg...
From: |
Matti Katila |
Subject: |
[ff-cvs] libvob/doc/pegboard/vob_event_action--mudyc peg... |
Date: |
Thu, 18 Sep 2003 07:13:13 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Matti Katila <address@hidden> 03/09/18 07:13:12
Modified files:
doc/pegboard/vob_event_action--mudyc: peg.rst
Log message:
select vob impl
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/doc/pegboard/vob_event_action--mudyc/peg.rst.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: libvob/doc/pegboard/vob_event_action--mudyc/peg.rst
diff -u libvob/doc/pegboard/vob_event_action--mudyc/peg.rst:1.2
libvob/doc/pegboard/vob_event_action--mudyc/peg.rst:1.3
--- libvob/doc/pegboard/vob_event_action--mudyc/peg.rst:1.2 Mon Sep 15
04:28:13 2003
+++ libvob/doc/pegboard/vob_event_action--mudyc/peg.rst Thu Sep 18 07:13:12 2003
@@ -5,8 +5,8 @@
:Authors: Matti J. Katila
:Date-Created: 2003-09-08
-:Last-Modified: $Date: 2003/09/15 08:28:13 $
-:Revision: $Revision: 1.2 $
+:Last-Modified: $Date: 2003/09/18 11:13:12 $
+:Revision: $Revision: 1.3 $
:Status: Incomplete
:Stakeholders: mudyc, tjl
:Scope: Minor
@@ -47,37 +47,186 @@
::
- public abstract class AbstractSelectionVob {
-
- protected final org.nongnu.libvob.lava.placeable.Placeable mask;
- protected final Vob selectUpVob, selectDownVob, selectActivatedVob;
-
- public AbstractSelectionVob(
- org.nongnu.libvob.lava.placeable.Placeable mask,
- Vob normalUpVob, Vob preSelectVob, Vob activatedVob
- {
+ package org.nongnu.libvob.vobs;
+ import org.nongnu.libvob.*;
+ import org.nongnu.libvob.gl.*;
+ import org.nongnu.libvob.util.*;
+ import java.awt.*;
+
+
+ /** An abstract vob which is selectable, i.e. when mouse
+ * is pressed above it the vob is visualized differently.
+ */
+ public abstract class AbstractSelectVob extends AbstractVob {
+ public static boolean dbg = false;
+ static private void p(String s) {
System.out.println("AbstractSelectVob:: "+s); }
+
+ protected final org.nongnu.libvob.lava.placeable.Placeable mask;
+
+ /** The vob visualizing of three possible select modes.
+ * In OpenGL the vobs must be GL.Renderable1JavaObject.
+ */
+ protected final Vob normal, pre, post;
+
+ /** A renderable vob which is used in OpenGL side to
+ * switch the modes inside one vob scene.
+ */
+ protected Vob select = null;
+
+ /** @param mask A Placeable object which is
+ */
+ public AbstractSelectVob(org.nongnu.libvob.lava.placeable.Placeable
mask) {
+ this(mask,
+ selectVob(Color.white),
+ selectVob(Color.yellow),
+ selectVob(Color.red));
+ }
+
+ static private Vob selectVob(Color color) {
+ return
+ GLCache.getCallListCoorded(
+ "PushAttrib ENABLE_BIT CURRENT_BIT TEXTURE_BIT\n"+
+ "Disable TEXTURE_2D \n"+
+ "Color "+ ColorUtil.colorGLString(color) +"\n"+
+ "Begin QUADS \n"+
+ "Vertex 0 0 \n"+
+ "Vertex 0 1 \n"+
+ "Vertex 1 1 \n"+
+ "Vertex 1 0 \n"+
+ "End\n"+
+ "PopAttrib");
+ }
+
+
+ public AbstractSelectVob(
+ org.nongnu.libvob.lava.placeable.Placeable mask,
+ Vob normalVob, Vob preSelectVob, Vob postActivatedVob)
+ {
this.mask = mask;
- this.selectUpVob = normalUpVob;
- this.selectDownVob = preSelectVob;
- this.selectActivatedVob = activatedVob;
- }
-
-
- public static int createControlCS(VobScene vs, Object key) {
- vs.orthoCS(0, key,0, 1,2,3,4); // put placeholders
- }
-
- static public class ControlState { private ControlState() {; } }
-
- /** Enumeration of control line.
- */
- static public final ControlState
- selectUp = new ControlState(),
- selectDown = new ControlState(),
- selectionActivated = new ControlState();
-
- public static void setControl(VobScene currentVS, int controlCS,
- ControlState state) { ; }
+ this.normal = normalVob;
+ this.pre = preSelectVob;
+ this.post = postActivatedVob;
+ select = GLRen.createSelectVob((GL.Renderable1JavaObject) normal,
+ (GL.Renderable1JavaObject) pre,
+ (GL.Renderable1JavaObject) post);
+ }
+
+
+ public void render(Graphics g, boolean fast,
+ RenderInfo info1, RenderInfo info2) {
+ throw new Error("Not implemented");
+ }
+
+ public int putGL(VobScene vs, int box, int controlCS) {
+ if (select == null)
+ select = GLRen.createSelectVob((GL.Renderable1JavaObject)
normal,
+ (GL.Renderable1JavaObject) pre,
+ (GL.Renderable1JavaObject) post);
+ vs.map.put(select, box, controlCS);
+ return 0;
+ }
+
+ private static final Object baseKey = "SelectVobControlLine";
+ private static int baseControlCS(VobScene vs, Object key) {
+ if (vs.matcher.getCS(0, key) < 2)
+ vs.translateCS(0, key,0,0);
+ return vs.matcher.getCS(0, key);
+ }
+ private static int realControlCS(VobScene vs, int control,
+ Object key) {
+ if (vs.matcher.getCS(control, key) < 2)
+ // default normal
+ vs.orthoBoxCS(control, key,0, 0,0, 1,1, 1,1);
+ return vs.matcher.getCS(control, key);
+ }
+
+ static public class ControlState { private ControlState() {; } }
+
+ /** Enumeration of control state.
+ */
+ static public final ControlState
+ normalState = new ControlState(),
+ preState = new ControlState(),
+ postState = new ControlState();
+
+
+ /** Get the coordinate system of mode selection control.
+ * @param vs The current VobScene
+ * @param controlKey The key for this control coordinate
+ * system. The key must be unique.
+ */
+ public static int getControl(VobScene vs,
+ Object controlKey)
+ {
+ int control = baseControlCS(vs, baseKey);
+ return realControlCS(vs, control, controlKey);
+ }
+
+
+ /** Set the coordinate system for controling the selection mode.
+ * @param vs The current VobScene
+ * @param controlKey The key for this control coordinate
+ * system. The key must be unique.
+ * @param state The state of three possible selection
+ * modes .
+ */
+ public static int setControl(VobScene vs,
+ Object controlKey, ControlState state) {
+ int control = baseControlCS(vs, baseKey);
+ int cs = realControlCS(vs, control, controlKey);
+ if (dbg) p("cs: "+control+" real: "+cs);
+ float width = -1;
+ if (state == normalState) {
+ if (dbg) p("normal");
+ width = 1;
+ } else if (state == preState) {
+ if (dbg) p("pre");
+ width = 2;
+ } else {
+ if (dbg) p("post");
+ width = 3;
+ }
+ vs.coords.setOrthoBoxParams(cs, 0,0,0, 1,1, width, width );
+ return cs;
+ }
+
}
+
+
+
+We also need OpenGL renderable which can multiplex between three vobs.
+The change is trivial and belongs to libvob/include/vob/vobs/Trivial.hxx ::
+
+
+ /** A Vob to draw a selection with 3 'selection modes'.
+ * 2nd coordinate system is used to select the current mode.
+ * The mode is represented by a vob. These 3 possibile 'selection mode'
+ * vobs are set in parameters.
+ * <p>
+ * Modes(2nd cs square size width):
+ * <=1 normal,
+ * <= 2 pre selection and
+ * other is post selection.
+ */
+ struct SelectVob {
+ enum { NTrans = 2 };
+
+ Vob1 * normal,
+ * preSelect,
+ * postSelect;
+
+ template<class F> void params(F &f) {
+ f(normal, preSelect, postSelect);
+ }
+
+ template<class T> void render(const T &t0, const T &t1) const {
+ Pt box = t1.getSqSize();
+ if (box.x <= 1) normal->render1(t0);
+ else if (box.x <= 2) preSelect->render1(t0);
+ else postSelect->render1(t0);
+ }
+
+ };
+ VOB_DEFINED(SelectVob);