SegsLineDrawerGL.java

Go to the documentation of this file.
00001 /*
00002  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
00003  * Copyright (C) 2007 - INRIA - Jean-Baptiste Silvy
00004  * desc : Class drawing the line part of arrows 
00005  * 
00006  * This file must be used under the terms of the CeCILL.
00007  * This source file is licensed as described in the file COPYING, which
00008  * you should have received as part of this distribution.  The terms
00009  * are also available at    
00010  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
00011  *
00012  */
00013 
00014 
00015 package org.scilab.modules.renderer.segsDrawing;
00016 
00017 import javax.media.opengl.GL;
00018 
00019 import org.scilab.modules.renderer.drawers.LineDrawerGL;
00020 import org.scilab.modules.renderer.utils.glTools.GLTools;
00021 
00026 public class SegsLineDrawerGL extends LineDrawerGL {
00027 
00028         
00032         public SegsLineDrawerGL() {
00033                 super();
00034         }
00035         
00041         public void setLineParameters(float thickness, int lineStyle) {
00042                 // colors is specified for each segment
00043                 super.setLineParameters(0, thickness, lineStyle);
00044         }
00045         
00056         public void drawSegs(double[] startXCoords, double[] endXCoords, double[] startYCoords, double[] endYCoords,
00057                                                  double[] startZCoords, double[] endZCoords, int[] colors) {
00058                 int nbSegs = startXCoords.length;
00059                 GL gl = getGL();
00060                 
00061                 GLTools.beginDashMode(gl, getLineStyle(), getThickness());
00062                 
00063                 gl.glBegin(GL.GL_LINES);
00064                 
00065                 for (int i = 0; i < nbSegs; i++) {
00066                         int sciColorIndex = getColorMap().convertScilabToColorMapIndex(colors[i]);
00067                         double[] curColor = getColorMap().getColor(sciColorIndex);
00068                         gl.glColor3d(curColor[0], curColor[1], curColor[2]);
00069                         
00070                         gl.glVertex3d(startXCoords[i], startYCoords[i], startZCoords[i]);
00071                         gl.glVertex3d(endXCoords[i], endYCoords[i], endZCoords[i]);
00072                 }
00073                 
00074                 gl.glEnd();
00075                 
00076                 GLTools.endDashMode(gl);
00077                 
00078         }
00079         
00080 }

Generated on Tue Sep 9 17:48:30 2008 for Scilab [trunk] by  doxygen 1.5.5