public static void SetupLineStyle(ILLineProperties wireprops) { if (wireprops.Style == LineStyle.Solid) { GL.Disable(EnableCap.LineStipple); } else { int stipFactr = 1; short stipple; if (wireprops.Style != LineStyle.UserPattern) { stipple = ILPanel.StippleFromLineStyle( wireprops.Style, ref stipFactr); } else { stipple = wireprops.Pattern; stipFactr = (int)wireprops.PatternScale; } GL.Enable(EnableCap.LineStipple); GL.LineStipple(stipFactr, stipple); } if (wireprops.Antialiasing && wireprops.Width > 1) { GL.Enable(EnableCap.LineSmooth); } else { GL.Disable(EnableCap.LineSmooth); } GL.LineWidth(wireprops.Width); GL.Color3(wireprops.Color); }
/// <summary> /// create lines composite shape /// </summary> /// <param name="panel">hosting panel</param> /// <param name="X">x coordinates vector </param> /// <param name="Y">y coordinates vector </param> /// <param name="Z">z coordinates vector </param> /// <param name="colors">matrix with <see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/> /// rows, 3 columns for (R,G,B) or 4 columns for /// (A,R,G,B) for every vertex specified by X,Y,Z. Elements must range from 0..255. If colors /// has 3 columns only, alpha values of 255 are used as default.</param> /// <param name="mapping">Mapping of shapes, composes shapes out of vertices. Matrix having /// 2 rows. Every element in a column specifies the index of a vertex according to its position in X,Y,Z. /// The 2 elements in a column therefore compose a single line. Vertices may get used arbitrary times /// (or not at all). All elements must be positive integer values in range /// 0...[<see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>-1].</param> public ILLines(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray colors, ILBaseArray mapping) : base(panel, 2, X, Y, Z, colors, mapping) { m_fillColor = Color.Blue; m_properties = new ILLineProperties(); m_properties.Color = Color.Blue; m_properties.Changed += new EventHandler(m_properties_Changed); }
/// <summary> /// Create new lines composite shapes, prepare memory for vertices only /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="numVertices">number of overall vertices in the shape</param> public ILLines(ILPanel panel, int numVertices) : base(panel, numVertices, 2) { m_fillColor = Color.Blue; m_properties = new ILLineProperties(); m_properties.Color = Color.Blue; m_properties.Changed += new EventHandler(m_properties_Changed); }
/// <summary> /// [internal] constructor - do not use this! Use ILPanel.Graphs.Add...() instead! /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="XData">x data array</param> /// <param name="YData">y data array</param> /// <param name="clippingContainer">hosting panels clipping data</param> public ILPlot2DGraph(ILPanel panel, ILBaseArray XData, ILBaseArray YData, ILClippingData clippingContainer) : base(panel, clippingContainer) { if (!XData.IsVector) { throw new ILArgumentException("Plot2D: supplied data must be a real vector!"); } if (!YData.IsVector) { throw new ILArgumentException("Plot2D: XData and YData must be real vectors!"); } if (YData.Length != XData.Length) { throw new ILArgumentException("Plot2D: XData and YData must have the same length!"); } int pos = 0; ILArray <float> dataX, dataY; C4bV3f vert = new C4bV3f(); if (XData is ILArray <float> ) { dataX = (ILArray <float>)XData; } else { dataX = ILMath.tosingle(XData); } if (YData is ILArray <float> ) { dataY = (ILArray <float>)YData; } else { dataY = ILMath.tosingle(YData); } m_vertices = new C4bV3f[dataX.Length + 1]; m_vertexCount = m_vertices.Length; m_startID = m_vertexCount - 1; m_updateCount = 0; m_properties = new ILLineProperties(); m_properties.Color = Color.DarkBlue; m_properties.Changed += new EventHandler(m_properties_Changed); foreach (float val in dataX.Values) { vert.Position = new ILPoint3Df(val, dataY.GetValue(pos), 0); vert.Color = m_properties.Color; m_vertices[pos++] = vert; } m_marker = new ILMarker(panel); m_marker.Changed += new EventHandler(m_marker_Changed); m_graphType = GraphType.Plot2D; updateClipping(); }
/// <summary> /// create new line, give vertices positions also /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="X">X coordinates</param> /// <param name="Y">Y coordinates</param> /// <param name="Z">Z coordinates</param> public ILLine(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z) : base(panel, X, Y, Z) { m_fillColor = Color.Black; m_border.Visible = false; m_oldestVertexID = 0; m_properties = new ILLineProperties(); m_properties.Changed += new EventHandler(m_properties_Changed); m_properties.Color = Color.Blue; m_shading = ShadingStyles.Flat; m_autoLimitsUpdateCount = Vertices.Length; }
/// <summary> /// create new bordered shape /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="numVertices">number of vertices, this bordered shape will be made out of</param> public ILBorderedShape(ILPanel panel, int numVertices) : base(panel, numVertices, numVertices) { m_border = new ILLineProperties(); m_border.Changed += new EventHandler(m_border_Changed); m_fillColor = Color.Yellow; m_border.Width = 1; m_border.Antialiasing = false; m_border.Color = Color.Bisque; m_shading = ShadingStyles.Flat; m_vertexStoresColor = false; }
/// <summary> /// create new lines composite shape /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="X">X coords vector</param> /// <param name="Y">Y coords vector</param> /// <param name="Z">Z coords vector</param> /// <param name="mapping">Mapping of shapes, composes shapes out of vertices. Matrix having /// 2 rows. Every element in a column specifies the index of a vertex according to its position in X,Y,Z. /// The 2 elements in a column therefore compose a single line. Vertices may get used arbitrary times /// (or not at all). All elements must be positive integer values in range /// 0...[<see cref="ILNumerics.Drawing.Shapes.ILShape.VertexCount"/>-1].</param> public ILLines(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray mapping) : base(panel, 2, X, Y, Z, mapping) { m_fillColor = Color.Blue; m_properties = new ILLineProperties(); m_properties.Color = Color.Blue; m_properties.Changed += new EventHandler(m_properties_Changed); ILColorEnumerator colors = new ILColorEnumerator(); for (int i = 0; i < m_vertCount; i++) { m_vertices[i].Color = colors.NextColor(); } }
/// <summary> /// construct new legend object /// </summary> internal ILLegend(ILPanel panel) { m_panel = panel; m_size = Size.Empty; m_border = new ILLineProperties(); m_border.Antialiasing = false; m_border.Color = Color.FromKnownColor(KnownColor.WindowFrame); m_border.Style = LineStyle.Solid; m_border.Width = 2; m_border.Changed += new EventHandler(m_border_Changed); m_location = Point.Empty; m_bgColor = Color.FromArgb(200, Color.FromKnownColor(KnownColor.ControlLight)); m_opacity = 0.9f; m_padding = new Padding(5); m_visible = false; }
/// <summary> /// create new line, determine number of vertices /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="numVertices">number of vertices for the line</param> public ILLine(ILPanel panel, int numVertices) : base(panel, numVertices) { if (numVertices < 2) { throw new ILArgumentException("line must have at least 2 points!"); } m_fillColor = Color.Black; m_border.Visible = false; m_oldestVertexID = 0; m_properties = new ILLineProperties(); m_properties.Changed += new EventHandler(m_properties_Changed); m_properties.Color = Color.Blue; m_autoLimitsUpdateCount = numVertices; m_shading = ShadingStyles.Flat; }
/// <summary> /// create new lit sink /// </summary> /// <param name="max">lenght of the squared ground</param> /// <param name="panel">panel hosting the scene</param> /// <param name="resolution">horizontal and vertical resolution</param> public ILLitSink(ILPanel panel, float max, int resolution) : base(panel) { m_max = max; m_res = resolution; m_lowCut = -3; m_gridProperties = new ILLineProperties(); m_gridProperties.Color = Color.LightBlue; m_gridProperties.Width = 1; m_gridProperties.Antialiasing = false; m_gridProperties.Style = LineStyle.Solid; m_gridSpacing = 1.0f; m_linesUpdateNeeded = false; m_timer = new Timer(); m_timer.Interval = int.MaxValue; m_timer.Tick += new EventHandler(m_timer_Tick); createShapes(); Invalidate(); }
/// <summary> /// [internal] constructor - do not use this! Use ILPanel.Graphs.Add...() instead! /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="sourceArray">data array</param> /// <param name="clippingContainer">hosting panels clipping data</param> public ILPlot2DGraph(ILPanel panel, ILBaseArray sourceArray, ILClippingData clippingContainer) : base(panel, clippingContainer) { if (object.Equals(sourceArray, null) || !sourceArray.IsVector || !sourceArray.IsNumeric) { throw new ILArgumentException("Plot2D: supplied data must be numeric (real valued) vector!"); } int pos = 0; ILArray <float> data; C4bV3f vert = new C4bV3f(); if (sourceArray is ILArray <float> ) { data = (ILArray <float>)sourceArray; } else { data = ILMath.tosingle(sourceArray); } m_vertices = new C4bV3f[data.Length + 1]; m_vertexCount = m_vertices.Length; m_updateCount = 0; m_startID = 0; m_properties = new ILLineProperties(); m_properties.Color = Color.DarkBlue; m_properties.Changed += new EventHandler(m_properties_Changed); foreach (float val in data.Values) { vert.Position = new ILPoint3Df(pos, val, 0); vert.Color = Color.Red; m_vertices[pos++] = vert; } m_marker = new ILMarker(panel); m_marker.Changed += new EventHandler(m_properties_Changed); m_graphType = GraphType.Plot2D; m_localClipping.Set(new ILPoint3Df(0, data.MinValue, 0), new ILPoint3Df(data.Length - 1, data.MaxValue, 0)); }
/// <summary> /// construct new filled graph /// </summary> /// <param name="panel">panel hosting the graph</param> /// <param name="X">X coords, if null, range 0..[cols of Z] will be created</param> /// <param name="Y">Y coords, if null, range 0..[rows of Z] will be created</param> /// <param name="Z">Z coords (heights)</param> /// <param name="C">Colors for Z</param> /// <param name="clippingContainer">gloabal limits of panel</param> public ILFilledGraph(ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray C, ILClippingData clippingContainer) : base(panel, clippingContainer) { #region argument checking m_localClipping.EventingSuspend(); if (Z == null || !Z.IsMatrix) { throw new ILArgumentException("ILFilledGraph: Z must be matrix!"); } if (!Z.IsNumeric) { throw new ILArgumentException("ILFilledGraph: Z must be numeric!"); } m_sourceArray = ILMath.tosingle(Z); m_rows = m_sourceArray.Dimensions[0]; m_cols = m_sourceArray.Dimensions[1]; ILArray <float> tmp; if (!object.Equals(X, null) && !X.IsEmpty) { if (!X.IsMatrix || !X.IsNumeric) { throw new ILArgumentException("ILFilledGraph: X must be numeric matrix!"); } if (X.Dimensions.IsSameSize(Z.Dimensions)) { tmp = ILMath.tosingle(X); tmp.ExportValues(ref m_xCoords); m_localClipping.XMax = tmp.MaxValue; m_localClipping.XMin = tmp.MinValue; } else { throw new ILArgumentException("ILFilledGraph: X must be of same size than Z!"); } } else { ILMath.tosingle(ILMath.repmat(ILMath.counter(0.0, 1.0, 1, m_cols), m_rows, 1)).ExportValues(ref m_xCoords); m_localClipping.XMin = 0; m_localClipping.XMax = m_cols - 1; } if (!object.Equals(Y, null) && !Y.IsEmpty) { if (!Y.IsMatrix || !Y.IsNumeric) { throw new ILArgumentException("ILFilledGraph: Y must be numeric matrix!"); } if (Y.Dimensions.IsSameSize(Z.Dimensions)) { tmp = ILMath.tosingle(Y); tmp.ExportValues(ref m_yCoords); m_localClipping.YMax = tmp.MaxValue; m_localClipping.YMin = tmp.MinValue; } else { throw new ILArgumentException("ILFilledGraph: Y must be same size than Z!"); } } else { ILMath.tosingle(ILMath.repmat(ILMath.counter(0.0, 1.0, m_rows, 1), 1, m_cols)).ExportValues(ref m_yCoords); m_localClipping.YMax = m_rows - 1; m_localClipping.YMin = 0; } if (object.Equals(C, null) || C.IsEmpty) { m_colors = null; } else { m_colors = ILMath.tosingle(C); } m_localClipping.ZMax = m_sourceArray.MaxValue; m_localClipping.ZMin = m_sourceArray.MinValue; #endregion m_Vertcount = m_rows * m_cols; m_vertexReady = false; m_indexReady = false; // default view properties m_opacity = 1.0f; m_wireLines = new ILLineProperties(); m_wireLines.Changed += new EventHandler(m_wireLines_Changed); m_filled = true; m_localClipping.EventingResume(); }
/// <summary> /// construct new filled graph /// </summary> /// <param name="panel">panel hosting the graph</param> /// <param name="X">X coords, if null, range 0..[cols of Z] will be created</param> /// <param name="Y">Y coords, if null, range 0..[rows of Z] will be created</param> /// <param name="Z">Z coords (heights)</param> /// <param name="C">Colors for Z</param> /// <param name="clippingContainer">gloabal limits of panel</param> public ILFilledGraph (ILPanel panel, ILBaseArray X, ILBaseArray Y, ILBaseArray Z, ILBaseArray C, ILClippingData clippingContainer) : base (panel, clippingContainer) { #region argument checking m_localClipping.EventingSuspend(); if (Z == null || !Z.IsMatrix) throw new ILArgumentException ("ILFilledGraph: Z must be matrix!"); if (!Z.IsNumeric) throw new ILArgumentException ("ILFilledGraph: Z must be numeric!"); m_sourceArray = ILMath.tosingle(Z); m_rows = m_sourceArray.Dimensions[0]; m_cols = m_sourceArray.Dimensions[1]; ILArray<float> tmp; if (!object.Equals (X,null) && !X.IsEmpty) { if (!X.IsMatrix || !X.IsNumeric) { throw new ILArgumentException ("ILFilledGraph: X must be numeric matrix!"); } if (X.Dimensions.IsSameSize(Z.Dimensions)) { tmp = ILMath.tosingle(X); tmp.ExportValues(ref m_xCoords); m_localClipping.XMax = tmp.MaxValue; m_localClipping.XMin = tmp.MinValue; } else { throw new ILArgumentException ("ILFilledGraph: X must be of same size than Z!"); } } else { ILMath.tosingle(ILMath.repmat(ILMath.counter(0.0,1.0,1,m_cols),m_rows,1)).ExportValues(ref m_xCoords); m_localClipping.XMin = 0; m_localClipping.XMax = m_cols-1; } if (!object.Equals(Y,null) && !Y.IsEmpty) { if (!Y.IsMatrix || !Y.IsNumeric) { throw new ILArgumentException ("ILFilledGraph: Y must be numeric matrix!"); } if (Y.Dimensions.IsSameSize(Z.Dimensions)) { tmp = ILMath.tosingle(Y); tmp.ExportValues(ref m_yCoords); m_localClipping.YMax = tmp.MaxValue; m_localClipping.YMin = tmp.MinValue; } else { throw new ILArgumentException ("ILFilledGraph: Y must be same size than Z!"); } } else { ILMath.tosingle(ILMath.repmat(ILMath.counter(0.0,1.0,m_rows,1),1,m_cols)).ExportValues(ref m_yCoords); m_localClipping.YMax = m_rows-1; m_localClipping.YMin = 0; } if (object.Equals(C,null) || C.IsEmpty) { m_colors = null; } else { m_colors = ILMath.tosingle(C); } m_localClipping.ZMax = m_sourceArray.MaxValue; m_localClipping.ZMin = m_sourceArray.MinValue; #endregion m_Vertcount = m_rows * m_cols; m_vertexReady = false; m_indexReady = false; // default view properties m_opacity = 1.0f; m_wireLines = new ILLineProperties(); m_wireLines.Changed += new EventHandler(m_wireLines_Changed); m_filled = true; m_localClipping.EventingResume(); }
/// <summary> /// create new lit 3D box /// </summary> /// <param name="panel">panel hosting the scene</param> /// <param name="min">minimum coordinates defining the box' dimensions (x,y,z)</param> /// <param name="max">minimum coordinates defining the box' dimensions (x,y,z)</param> /// <param name="fillColor">overall color for the box</param> /// <param name="topColor">color used to color the top edges of the box</param> public ILLitBox3D(ILPanel panel, ILPoint3Df min, ILPoint3Df max, Color fillColor, Color topColor) : base(panel) { m_lineProperties = new ILLineProperties(); m_lineProperties.Changed += new EventHandler(m_lineProperties_Changed); m_valLabel = new ILWorldLabel(panel); m_valLabel.Text = ""; // (max * 1000).Z.ToString("F3"); ILPoint3Df mi = ILPoint3Df.Min(min, max); ILPoint3Df ma = ILPoint3Df.Max(min, max); m_valLabel.PositionMax = new ILPoint3Df(ma.X, mi.Y, ma.Z); m_valLabel.PositionMin = new ILPoint3Df(mi.X, ma.Y, ma.Z);; m_topLabel = new ILShapeLabel(panel); m_topLabel.Color = Color.Blue; //m_topLabel.Font = new Font("Arial", 10, FontStyle.Bold); string tval = max.Z.ToString("F2"); m_topLabel.Text = String.Format("{0}", tval); m_topLabel.Anchor = new PointF(0.5f, 1); m_topColor = topColor; #region setup quads m_quads = new ILLitQuad[6]; // front ILLitQuad quad = new ILLitQuad(m_panel); quad.Vertices[0].Position = new ILPoint3Df(min.X, min.Y, min.Z); quad.Vertices[1].Position = new ILPoint3Df(min.X, min.Y, max.Z); quad.Vertices[2].Position = new ILPoint3Df(max.X, min.Y, max.Z); quad.Vertices[3].Position = new ILPoint3Df(max.X, min.Y, min.Z); m_quads[QuadIndices.front] = quad; // right quad = new ILLitQuad(m_panel); quad.Vertices[0].Position = new ILPoint3Df(max.X, min.Y, min.Z); quad.Vertices[1].Position = new ILPoint3Df(max.X, min.Y, max.Z); quad.Vertices[2].Position = new ILPoint3Df(max.X, max.Y, max.Z); quad.Vertices[3].Position = new ILPoint3Df(max.X, max.Y, min.Z); m_quads[QuadIndices.right] = quad; // back quad = new ILLitQuad(m_panel); quad.Vertices[0].Position = new ILPoint3Df(max.X, max.Y, min.Z); quad.Vertices[1].Position = new ILPoint3Df(max.X, max.Y, max.Z); quad.Vertices[2].Position = new ILPoint3Df(min.X, max.Y, max.Z); quad.Vertices[3].Position = new ILPoint3Df(min.X, max.Y, min.Z); m_quads[QuadIndices.back] = quad; // left quad = new ILLitQuad(m_panel); quad.Vertices[0].Position = new ILPoint3Df(min.X, max.Y, min.Z); quad.Vertices[1].Position = new ILPoint3Df(min.X, max.Y, max.Z); quad.Vertices[2].Position = new ILPoint3Df(min.X, min.Y, max.Z); quad.Vertices[3].Position = new ILPoint3Df(min.X, min.Y, min.Z); m_quads[QuadIndices.left] = quad; // top quad = new ILLitQuad(m_panel); quad.Vertices[0].Position = new ILPoint3Df(min.X, min.Y, max.Z); quad.Vertices[1].Position = new ILPoint3Df(max.X, min.Y, max.Z); quad.Vertices[2].Position = new ILPoint3Df(max.X, max.Y, max.Z); quad.Vertices[3].Position = new ILPoint3Df(min.X, max.Y, max.Z); m_quads[QuadIndices.top] = quad; // bottom quad = new ILLitQuad(m_panel); quad.Vertices[0].Position = new ILPoint3Df(min.X, min.Y, min.Z); quad.Vertices[1].Position = new ILPoint3Df(max.X, min.Y, min.Z); quad.Vertices[2].Position = new ILPoint3Df(max.X, max.Y, min.Z); quad.Vertices[3].Position = new ILPoint3Df(min.X, max.Y, min.Z); m_quads[QuadIndices.bottom] = quad; #endregion EventingSuspend(); foreach (ILLitQuad s in m_quads) { s.Label.Text = ""; s.Shading = ShadingStyles.Interpolate; s.Opacity = m_opacity; s.Border.Color = Color.Gray; s.Border.Width = 1; s.Border.Visible = true; s.Border.Antialiasing = false; Add(s); } EventingResume(); m_fillColor = fillColor; updateColors(); }
/// <summary> /// Draw the graph /// </summary> public override void Draw(ILRenderProperties p) { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); ILLineProperties wireprops = m_wireLines; ILOGLPanel.SetupLineStyle(wireprops); unsafe { fixed(float *pVertices = m_vertices) { // populate vertex array to GL GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f , 0, (IntPtr)pVertices); // general setup shading & transparency if (m_shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); //GL.Disable(EnableCap.DepthTest); } else { GL.ShadeModel(ShadingModel.Flat); //if (m_opacity < 1.0f) //else // GL.Enable(EnableCap.DepthTest); } GL.Enable(EnableCap.DepthTest); if (m_opacity == 1.0f && m_shading == ShadingStyles.Interpolate) { #region no transpareny GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.DepthTest); fixed(UInt32 *pGridIndices = m_gridIndices) fixed(UInt32 * pIndices = m_indices) { UInt32 *pGridIndWalk = pGridIndices; // first surface strip if (m_filled) { GL.DrawElements(BeginMode.TriangleStrip, m_stripesLen, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } // first grid strip if (m_wireLines.Visible) { if (!wireprops.Color.IsEmpty) { // if a color was specified, use it for wireframes! GL.DisableClientState(EnableCap.ColorArray); //GL.Color3(wireprops.ForeColor); // color for grid lines } GL.DrawElements(BeginMode.Lines, m_gridStripsLen + m_gridStripsLenOnce, // 2*(m_cols-1), DrawElementsType.UnsignedInt, (IntPtr)pGridIndWalk); pGridIndWalk += (m_gridStripsLen + m_gridStripsLenOnce); if (!wireprops.Color.IsEmpty) { GL.EnableClientState(EnableCap.ColorArray); } } for (int i = 1; i < m_stripesCount; i++) { // subsequent surface strips if (m_filled) { GL.DrawElements(BeginMode.TriangleStrip, m_stripesLen, DrawElementsType.UnsignedInt, (IntPtr)(pIndices + i * m_stripesLen)); } // subsequent grid strips if (m_wireLines.Visible) { GL.Disable(EnableCap.Blend); if (!wireprops.Color.IsEmpty) { // if a color was specified, use it for wireframes! GL.DisableClientState(EnableCap.ColorArray); //GL.Color3(wireprops.ForeColor); // color for grid lines } GL.DrawElements(BeginMode.Lines, m_gridStripsLen, DrawElementsType.UnsignedInt, (IntPtr)(pGridIndWalk)); pGridIndWalk += m_gridStripsLen; if (!wireprops.Color.IsEmpty) { GL.EnableClientState(EnableCap.ColorArray); } } } GL.Finish(); } #endregion } else { #region transparency or flat shading GL.Enable(EnableCap.Blend); fixed(UInt32 *pGridIndices = m_gridIndices) fixed(UInt32 * pIndices = m_indices) { UInt32 *pGridIndWalk = pGridIndices; // first surface strip if (m_filled) { GL.DrawElements(BeginMode.Triangles, m_stripesLen, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } // first grid strip if (m_wireLines.Visible) { GL.Disable(EnableCap.Blend); if (!wireprops.Color.IsEmpty) { // if a color was specified, use it for wireframes! GL.DisableClientState(EnableCap.ColorArray); GL.Color3(m_wireLines.Color); } GL.DrawElements(BeginMode.Lines, m_gridStripsLen + m_gridStripsLenOnce, DrawElementsType.UnsignedInt, (IntPtr)pGridIndWalk); pGridIndWalk += m_gridStripsLen + m_gridStripsLenOnce; if (!wireprops.Color.IsEmpty) { // if a color was specified, use it for wireframes! GL.EnableClientState(EnableCap.ColorArray); } GL.Enable(EnableCap.Blend); } for (int i = 1; i < m_stripesCount; i++) { // subsequent surface strips if (m_filled) { GL.DrawElements(BeginMode.Triangles, m_stripesLen, DrawElementsType.UnsignedInt, (IntPtr)(pIndices + i * m_stripesLen)); } // subsequent grid strips if (m_wireLines.Visible) { GL.Disable(EnableCap.Blend); if (!wireprops.Color.IsEmpty) { // if a color was specified, use it for wireframes! GL.DisableClientState(EnableCap.ColorArray); GL.Color3(m_wireLines.Color); } GL.DrawElements(BeginMode.Lines, m_gridStripsLen, DrawElementsType.UnsignedInt, (IntPtr)(pGridIndWalk)); if (!wireprops.Color.IsEmpty) { GL.EnableClientState(EnableCap.ColorArray); } GL.Enable(EnableCap.Blend); pGridIndWalk += m_gridStripsLen; } } GL.Finish(); } #endregion } } } //GL.Disable(EnableCap.Lighting); //GL.PopMatrix(); }
public static void SetupLineStyle(ILLineProperties wireprops) { if (wireprops.Style == LineStyle.Solid) { GL.Disable(EnableCap.LineStipple); } else { int stipFactr = 1; short stipple; if (wireprops.Style != LineStyle.UserPattern) stipple = ILPanel.StippleFromLineStyle( wireprops.Style, ref stipFactr); else { stipple = wireprops.Pattern; stipFactr = (int)wireprops.PatternScale; } GL.Enable(EnableCap.LineStipple); GL.LineStipple(stipFactr, stipple); } if (wireprops.Antialiasing && wireprops.Width > 1) GL.Enable(EnableCap.LineSmooth); else GL.Disable(EnableCap.LineSmooth); GL.LineWidth(wireprops.Width); GL.Color3(wireprops.Color); }
/// <summary> /// construct new legend object /// </summary> internal ILLegend (ILPanel panel) { m_panel = panel; m_size = Size.Empty; m_border = new ILLineProperties(); m_border.Antialiasing = false; m_border.Color = Color.FromKnownColor(KnownColor.WindowFrame); m_border.Style = LineStyle.Solid; m_border.Width = 2; m_border.Changed += new EventHandler(m_border_Changed); m_location = Point.Empty; m_bgColor = Color.FromArgb(200, Color.FromKnownColor (KnownColor.ControlLight)); m_opacity = 0.9f; m_padding = new Padding(5); m_visible = false; }