SubwinLineBoxDrawer.java

Go to the documentation of this file.
00001 /*
00002  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
00003  * Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy
00004  * desc : Parent class for drawing different kind of axes box 
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 package org.scilab.modules.renderer.subwinDrawing;
00015 
00016 import javax.media.opengl.GL;
00017 
00018 import org.scilab.modules.renderer.utils.geom3D.Vector3D;
00019 import org.scilab.modules.renderer.utils.glTools.GLTools;
00020 
00021 
00026 public abstract class SubwinLineBoxDrawer extends SubwinBoxDrawer {
00027 
00028         private int lineColor;
00029         private int lineStyle;
00030         private float lineThickness;
00031         private int hiddenAxisColor;
00032         
00036         public SubwinLineBoxDrawer() {
00037                 super();
00038                 hiddenAxisColor = 0;
00039                 lineColor = 0;
00040                 lineStyle = 0;
00041                 lineThickness = 0.0f;
00042         }
00043         
00048         public void setLineColor(int colorIndex) {
00049                 this.lineColor = colorIndex;
00050         }
00051         
00055         public double[] getLineColor() {
00056                 return getColorMap().getColor(lineColor);
00057         }
00058         
00063         public void setLineStyle(int lineStyle) {
00064                 this.lineStyle = lineStyle;
00065         }
00066         
00070         public int getLineStyle() {
00071                 return lineStyle;
00072         }
00073         
00078         public void setThickness(float thickness) {
00079                 this.lineThickness = thickness;
00080         }
00081         
00085         public float getThickness() {
00086                 return lineThickness;
00087         }
00088         
00093         public void setHiddenAxisColor(int colorIndex) {
00094                 this.hiddenAxisColor = colorIndex;
00095         }
00096         
00100         public double[] getHiddenAxisColor() {
00101                 return getColorMap().getColor(hiddenAxisColor);
00102         }
00103         
00111         public void setBoxParameters(int hiddenAxisColor, int lineColor,
00112                                                                  int lineStyle, float thickness) {
00113                 setHiddenAxisColor(hiddenAxisColor);
00114                 setLineColor(lineColor);
00115                 setLineStyle(lineStyle);
00116                 setThickness(thickness);
00117         }
00118         
00123         protected void drawHalfBox(int concealedCornerIndex) {
00124                 GL gl = getGL();
00125                 
00126                 
00127                 GLTools.beginDashMode(gl, getLineStyle(), getThickness());
00128                 
00129                 double[] color = getLineColor();
00130                 gl.glColor3d(color[0], color[1], color[2]);
00131                 
00132                 gl.glBegin(GL.GL_LINE_LOOP);
00133                 for (int i = 0; i < HALF_BOX_LINES[concealedCornerIndex].length; i++) {
00134                         Vector3D curVertex = getBoxCorner(HALF_BOX_LINES[concealedCornerIndex][i]);
00135                         gl.glVertex3d(curVertex.getX(), curVertex.getY(), curVertex.getZ());
00136                 }
00137                 gl.glEnd();
00138                 GLTools.endDashMode(gl);
00139         }
00140         
00141         
00142         
00147         protected void drawFrontTrihedron(int concealedCornerIndex) {
00148                 GL gl = getGL();
00149                 
00150                 // set dash mode
00151                 GLTools.beginDashMode(gl, getLineStyle(), getThickness());
00152                 
00153                 double[] color = getLineColor();
00154                 gl.glColor3d(color[0], color[1], color[2]);
00155                 
00156                 gl.glBegin(GL.GL_LINES);
00157                 for (int i = 0; i < FRONT_TRIHEDRON[concealedCornerIndex].length; i++) {
00158                         for (int j = 0; j < FRONT_TRIHEDRON[concealedCornerIndex][i].length; j++) {
00159                                 Vector3D curVertex = getBoxCorner(FRONT_TRIHEDRON[concealedCornerIndex][i][j]);
00160                                 gl.glVertex3d(curVertex.getX(), curVertex.getY(), curVertex.getZ());
00161                         }
00162                 }
00163                 gl.glEnd();
00164                 GLTools.endDashMode(gl);
00165         }
00166         
00171         protected void drawTrihedron(int concealedCornerIndex) {
00172                 GL gl = getGL();
00173                 
00174                 // the concealed line is draw wiht dashes
00175                 GLTools.beginDashMode(gl, 2, getThickness());
00176                 
00177                 double[] hiddenColor = getHiddenAxisColor();
00178                 gl.glColor3d(hiddenColor[0], hiddenColor[1], hiddenColor[2]);
00179                 
00180                 gl.glBegin(GL.GL_LINES);
00181                 for (int i = 0; i < BACK_TRIHEDRON[concealedCornerIndex].length; i++) {
00182                         for (int j = 0; j < BACK_TRIHEDRON[concealedCornerIndex][i].length; j++) {
00183                                 Vector3D curVertex = getBoxCorner(BACK_TRIHEDRON[concealedCornerIndex][i][j]);
00184                                 gl.glVertex3d(curVertex.getX(), curVertex.getY(), curVertex.getZ());
00185                         }
00186                 }
00187                 gl.glEnd();
00188                 
00189                 GLTools.endDashMode(gl);
00190                 
00191                 
00192         }
00193 
00194 }

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