Author: paperwing
Date: 2012-03-07 15:58:24 -0800 (Wed, 07 Mar 2012)
New Revision: 28450

Added:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
Log:
Basic rendering of light representation to show light position completed; needs 
to stop drawing the light unless it is being drag-moved

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-03-07 22:42:21 UTC (rev 28449)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-03-07 23:58:24 UTC (rev 28450)
@@ -220,7 +220,6 @@
                gl.glEnable(GL2.GL_LIGHTING);
                gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, 
FloatBuffer.wrap(global));
                gl.glShadeModel(GL2.GL_SMOOTH);
-
                /*
                
                float[] ambient = { 0.4f, 0.4f, 0.4f, 1.0f };

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
      2012-03-07 22:42:21 UTC (rev 28449)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
      2012-03-07 23:58:24 UTC (rev 28450)
@@ -26,6 +26,7 @@
 import org.cytoscape.paperwing.internal.rendering.PositionCameraProcedure;
 import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderArcEdgesProcedure;
+import org.cytoscape.paperwing.internal.rendering.RenderLightsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderNodeLabelsProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderNodesProcedure;
 import org.cytoscape.paperwing.internal.rendering.RenderSelectionBoxProcedure;
@@ -63,6 +64,7 @@
                renderProcedures.add(new RenderSelectionBoxProcedure());
                
                renderProcedures.add(new RenderNodeLabelsProcedure());
+               renderProcedures.add(new RenderLightsProcedure());
        }
        
        @Override

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
        2012-03-07 22:42:21 UTC (rev 28449)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
        2012-03-07 23:58:24 UTC (rev 28450)
@@ -14,36 +14,29 @@
        /** The array of lights present in the scene */
        private Light[] lights;
        
-       /** The previous projected position of lights used for drag-moving 
lights */
-       private Vector3[] lightPreviousProjections;
+       /**
+        * An array of booleans that indicates whether a representation of a 
light should be drawn to show its position
+        */
+       private boolean[] displayLight;
        
-       /** The current projected position of lights used for drag-moving 
lights */
-       private Vector3[] lightCurrentProjections;
-
-       /** The projected distance of a light 
-       
        /**
         * Create a default {@link LightingData} object with default lights, 
all turned off.
         */
        public LightingData() {
                lights = new Light[NUM_LIGHTS];
+               displayLight = new boolean[NUM_LIGHTS];
                
-               lightPreviousProjections = new Vector3[NUM_LIGHTS];
-               lightCurrentProjections = new Vector3[NUM_LIGHTS];
-               
                for (int i = 0; i < NUM_LIGHTS; i++) {
                        lights[i] = new Light();
-                       
-                       lightPreviousProjections[i] = new Vector3();
-                       lightCurrentProjections[i] = new Vector3();
+                       displayLight[i] = false;
                }
-               
        }
        
        /** 
         * Obtain the light with the given index 
         * 
         * @param index The index of the desired light, ranging from 0 to 
LightingData.NUM_LIGHTS (default 8)
+        * @return The {@link Light} object representing the desired light.
         */
        public Light getLight(int index) {
                return lights[index];
@@ -58,7 +51,14 @@
                return lights;
        }
        
+       /**
+        * Check if a representation of the given light should be drawn to 
indicate its position.
+        * 
+        * @param index The index of the light, ranging from 0 to 
LightingData.NUM_LIGHTS (default 8)
+        * @return Whether or not the light at the given index should be drawn.
+        */
+       public boolean displayLight(int index) {
+               return displayLight[index];
+       }
        
-       
-       
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
  2012-03-07 22:42:21 UTC (rev 28449)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/input/LightMovementInputHandler.java
  2012-03-07 23:58:24 UTC (rev 28450)
@@ -1,5 +1,6 @@
 package org.cytoscape.paperwing.internal.input;
 
+import org.cytoscape.paperwing.internal.WindVisualLexicon;
 import org.cytoscape.paperwing.internal.data.GraphicsData;
 import org.cytoscape.paperwing.internal.data.GraphicsSelectionData;
 import org.cytoscape.paperwing.internal.data.LightingData;
@@ -8,6 +9,7 @@
 import org.cytoscape.paperwing.internal.tools.GeometryToolkit;
 import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
 import org.cytoscape.paperwing.internal.tools.SimpleCamera;
+import org.cytoscape.view.model.CyNetworkView;
 
 import com.jogamp.newt.event.KeyEvent;
 import com.jogamp.newt.event.MouseEvent;
@@ -75,6 +77,16 @@
                                        (float) newLightPosition.y(), 
                                        (float) newLightPosition.z(), 
                                        1.0f);
+                       
+                       updateLightVisualProperties(light, 
graphicsData.getNetworkView());
                }
        }
+       
+       private void updateLightVisualProperties(Light light, CyNetworkView 
networkView) {
+               float[] lightPosition = light.getPosition();
+               
+               
networkView.setVisualProperty(WindVisualLexicon.LIGHT_X_LOCATION, (double) 
lightPosition[0]);
+               
networkView.setVisualProperty(WindVisualLexicon.LIGHT_Y_LOCATION, (double) 
lightPosition[1]);
+               
networkView.setVisualProperty(WindVisualLexicon.LIGHT_Z_LOCATION, (double) 
lightPosition[2]);
+       }
 }

Added: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
                          (rev 0)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
  2012-03-07 23:58:24 UTC (rev 28450)
@@ -0,0 +1,50 @@
+package org.cytoscape.paperwing.internal.rendering;
+
+import javax.media.opengl.GL2;
+
+import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.data.LightingData;
+import org.cytoscape.paperwing.internal.lighting.Light;
+import org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer;
+import 
org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer.ShapeType;
+
+/**
+ * This {@link ReadOnlyGraphicsProcedure} object is responsible for drawing 
the representations of scene lights
+ * to help with visualizing their locations.
+ */
+public class RenderLightsProcedure implements ReadOnlyGraphicsProcedure {
+
+       private ScalableShapeDrawer shapeDrawer;
+       
+       public RenderLightsProcedure() {
+               shapeDrawer = new ScalableShapeDrawer();
+       }
+       
+       @Override
+       public void initialize(GraphicsData graphicsData) {
+               GL2 gl = graphicsData.getGlContext();
+               
+               shapeDrawer.initialize(gl);
+       }
+
+       @Override
+       public void execute(GraphicsData graphicsData) {
+               
+               GL2 gl = graphicsData.getGlContext();
+               
+               LightingData lightingData = graphicsData.getLightingData();
+               
+               // Draw the light at index 0
+               Light light = lightingData.getLight(0);
+               float[] lightPosition = light.getPosition();
+               
+               gl.glPushMatrix();
+               gl.glTranslatef(lightPosition[0], lightPosition[1], 
lightPosition[2]);
+               
+               gl.glColor3f(1.0f, 1.0f, 0.6f);
+               shapeDrawer.drawShape(gl, ShapeType.SHAPE_SPHERE);
+                               
+               gl.glPopMatrix();
+       }
+
+}


Property changes on: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLightsProcedure.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to