public override void Draw(ILRenderProperties p) { //System.Diagnostics.Debug.WriteLine("ILOGLGraphPlot2D_Draw"); #region draw line // draw linestrip - simple case - fast vertex rendering if (m_properties.Visible) { GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Texture2D); ILOGLPanel.SetupLineStyle(m_properties); unsafe { fixed(C4bV3f* pVertArr = m_vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f,0,(IntPtr)pVertArr); if (m_properties.Color.IsEmpty) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); } if (m_startID < 2) { GL.DrawArrays(BeginMode.LineStrip, m_startID, m_vertexCount-1); } else { GL.DrawArrays(BeginMode.LineStrip, m_startID, m_vertexCount-m_startID); GL.DrawArrays(BeginMode.LineStrip, 0, m_startID); } } } } #endregion #region draw markers if (m_marker.Visible) { m_marker.Shape.Draw(p, m_marker, m_vertices,0, m_vertexCount-1); } #endregion }
public override void Draw(ILRenderProperties props, ILShape shape, int[] indices) { System.Diagnostics.Debug.Assert(indices != null); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); ILShape<C4bV3f> cShape = (shape as ILShape<C4bV3f>); if (cShape is ILLines) { ILOGLPanel.SetupLineStyle((cShape as ILLines).Properties); GL.Disable(EnableCap.DepthTest); } fixed (int* pIndices = indices) fixed (C4bV3f* pVertices = cShape.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) GL.ShadeModel(ShadingModel.Smooth); else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); } GL.DrawElements(BeginMode.Lines, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } }
public override void Draw(ILRenderProperties props, ILShape shape) { if (shape.VertexCount == 0) return; GL.Enable(EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); //GL.Disable(EnableCap.PolygonOffsetFill); ILShape<C4fN3fV3f> cShape = (shape as ILShape<C4fN3fV3f>); fixed (C4fN3fV3f* pVertices = cShape.Vertices) { if (UseLight && (cShape is IILSupportsLight)) { setupLight(cShape as IILSupportsLight); } else { GL.Disable(EnableCap.Lighting); } GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) GL.ShadeModel(ShadingModel.Smooth); else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(shape.FillColor); } GL.DrawArrays(m_primitiveType, 0, cShape.VertexCount); } GL.Disable(EnableCap.Lighting); ILBorderedShape<C4fN3fV3f> bShape = (shape as ILBorderedShape<C4fN3fV3f>); if (bShape != null && bShape.Border.Visible) { fixed (C4fN3fV3f* pVertices = bShape.Vertices) { ILOGLPanel.SetupLineStyle(bShape.Border); GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); GL.DrawArrays(BeginMode.LineLoop, 0, bShape.VertexCount); } } }
protected override void IntDrawShape(ILRenderProperties props) { if (m_vertCount == 0 || m_vertCount >= VerticesPerShape) { m_renderer.Draw(props, this); } }
/// <summary> /// draw all markers (graph / legend) /// </summary> /// <param name="marker">the marker object (for properties)</param> /// <param name="vertices">coords, interleaved</param> /// <param name="vertcount">number of coords, special: -1 for legend rendering</param> /// <remarks>This function is reused for both: drawing in world coords (graph) and drawing in /// screen coords (legend). Latter case requires vertcount to be -1, vertices must contain /// at least 2 float values than!</remarks> internal override void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertcount) { if (vertcount > 0) { int inc = Math.Max(1, (vertcount / m_maxLabelsDrawn)); m_renderer.Begin(p); for (int i = 0; i < vertcount; i += inc) { #region draw textured points (slow version: textured quads) string expr = m_expression.Replace("\\index", i.ToString()); expr = expr.Replace("\\xvalue", vertices[i].XPosition.ToString(m_valueFormat)); expr = expr.Replace("\\yvalue", vertices[i].YPosition.ToString(m_valueFormat)); ILRenderQueue queue = m_interpreter.Transform(expr, m_font, marker.Color, m_renderer); #region determine size for markers in world coords (graph limits) float w, h; ILClippingData clip = m_panel.Limits; float s05x; float s05y; s05x = Math.Abs(queue.Size.Width * clip.WidthF / 2 / (m_panel.ClientSize.Width)); s05y = Math.Abs(queue.Size.Height * clip.HeightF / 2 / (m_panel.ClientSize.Height)); #endregion // this is slow! Todo: replace by point sprites! w = vertices[i].XPosition; h = vertices[i].YPosition; if (m_panel.ClipViewData && (w < clip.XMin || w > clip.XMax || h < clip.YMin || h > clip.YMax)) { continue; } m_renderer.Draw(queue, w - s05x, h + s05y, vertices[i].ZPosition, w + s05x, h - s05y, vertices[i].ZPosition, marker.Color); #endregion } m_renderer.End(p); } else if (vertcount == -1) { #region render for legend m_renderer.Begin(p); string expr = m_expression.Replace("\\index", "0"); expr = expr.Replace("\\xvalue", "0.2"); expr = expr.Replace("\\yvalue", "0.4"); ILRenderQueue queue = m_interpreter.Transform(expr, m_font, marker.Color, m_renderer); #region determine size for markers in SCREEN COORDS float w, h; ILClippingData clip = m_panel.Limits; float s05x; float s05y; s05x = Math.Abs(queue.Size.Width / 2); s05y = Math.Abs(queue.Size.Height / 2); #endregion // this is slow! Todo: replace by point sprites! w = vertices[0].XPosition; h = vertices[0].YPosition; m_renderer.Draw(queue, w - s05x, h - s05y, 0, w + s05x, h + s05y, 0, marker.Color); m_renderer.End(p); #endregion } }
public override void Draw(ILRenderProperties props, ILShape shape) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); ILLines lines = (shape as ILLines); ILOGLPanel.SetupLineStyle(lines.Properties); fixed(C4bV3f *pVertices = lines.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (lines.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(lines.FillColor); } GL.DrawArrays(BeginMode.LineStrip, 0, lines.VertexCount); } }
public override void Draw(ILRenderProperties props, ILShape shape, int[] indices) { System.Diagnostics.Debug.Assert(indices != null); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); ILShape <C4bV3f> cShape = (shape as ILShape <C4bV3f>); if (cShape is ILLines) { ILOGLPanel.SetupLineStyle((cShape as ILLines).Properties); GL.Disable(EnableCap.DepthTest); } fixed(int *pIndices = indices) fixed(C4bV3f * pVertices = cShape.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); } GL.DrawElements(BeginMode.Lines, indices.Length, DrawElementsType.UnsignedInt, (IntPtr)pIndices); } }
/// <summary> /// Draw this shape contained in this node (internal use) /// </summary> /// <param name="props"></param> public override void Draw(ILRenderProperties props) { if (m_shape != null) { m_shape.Draw(props); } }
public override void DrawToLegend(ILRenderProperties p, Rectangle sampleRect, Rectangle labelRect) { if (m_filled) { // draw inner filled area GL.ShadeModel(ShadingModel.Smooth); GL.Begin(BeginMode.TriangleStrip); GL.Color3(m_panel.Colormap[m_panel.Colormap.Length - 1]); GL.Vertex2(sampleRect.X, sampleRect.Y + sampleRect.Height); GL.Color3(m_panel.Colormap[(int)(m_panel.Colormap.Length / 2)]); GL.Vertex2(sampleRect.X, sampleRect.Y); GL.Vertex2(sampleRect.X + sampleRect.Width, sampleRect.Y + sampleRect.Height); GL.Color3(m_panel.Colormap[0]); GL.Vertex2(sampleRect.X + sampleRect.Width, sampleRect.Y); GL.End(); } if (m_wireLines.Visible) { ILNumerics.Drawing.Platform.OpenGL.ILOGLPanel.SetupLineStyle(m_wireLines); GL.Begin(BeginMode.LineStrip); GL.Vertex2(sampleRect.X, sampleRect.Y); GL.Vertex2(sampleRect.X + sampleRect.Width, sampleRect.Y); GL.Vertex2(sampleRect.X + sampleRect.Width, sampleRect.Y + sampleRect.Height); GL.Vertex2(sampleRect.X, sampleRect.Y + sampleRect.Height); GL.Vertex2(sampleRect.X, sampleRect.Y); GL.End(); } m_label.m_position.X = labelRect.X + labelRect.Width / 2; m_label.m_position.Y = labelRect.Y + labelRect.Height / 2; m_label.Anchor = new PointF(.5f, 0); // = TickLabelAlign.center | TickLabelAlign.vertCenter; m_label.Draw(p); }
/* In order to show up in the legend, the plot needs to * implement the IILLegendRenderer interface. Here this is * done very simple via a ILShapeLabel. The first one simple draws * the text "Bars" in the sample area of the legend. The original * ILLabel of the graph is then used to draw its text into the * label area of the legend. * Better implementations should check for * ** the drawing not to exceed the sampleArea and labelArea rectangles * ** use 2 distinct labels instead of one (performance) */ public void DrawToLegend(ILRenderProperties p, Rectangle sampleArea, Rectangle labelArea) { m_legendSampleLabel.Position = sampleArea.Location; m_legendSampleLabel.Draw(p); m_legendTextLabel.Position = labelArea.Location; m_legendTextLabel.Draw(p); }
public void Begin(ILRenderProperties p, ref double[] modelview) { if (modelview == null || modelview.Length < 12) { modelview = new double[16]; } GL.GetDouble(GetPName.ModelviewMatrix, modelview); Begin(p); }
/// <summary> /// (internally used) draws the plot /// </summary> /// <param name="props"></param> public override void Draw(ILRenderProperties props) { base.Draw(props); m_valLabel.Draw(props); ILPoint3Df labPos = m_quads[QuadIndices.top].Center; labPos.Z = Math.Max(m_quads[QuadIndices.top].Center.Z, m_quads[QuadIndices.bottom].Center.Z); m_topLabel.Draw(props, labPos); }
/// <summary> /// draws the whole rendering queue /// </summary> public virtual void Draw(ILRenderProperties p) { if (m_expression != m_cachedExpression) { interprete(m_expression); } m_renderer.Begin(p); m_renderer.Draw(m_renderQueue, offsetAlignment(m_renderQueue.Size), m_orientation, m_color); m_renderer.End(p); }
protected override void IntDrawLabel(ILRenderProperties props) { if (m_vertCount == 0 || m_vertCount >= VerticesPerShape) { if (!String.IsNullOrEmpty(m_label.Text) && m_vertCount > 1) { ILPoint3Df cent = m_vertices[0].Position + m_vertices[1].Position; m_label.Draw(props, cent / 2); } } }
public override void Draw(ILRenderProperties props, ILShape shape) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); ILLine line = (shape as ILLine); if (line != null && line.Border.Visible) { fixed(C4bV3f *pVertices = line.Vertices) { ILOGLPanel.SetupLineStyle(line.Border); GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); if (line.OldestVertexID == 0) { GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount); } else { GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID); GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices); GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID); } } } ILOGLPanel.SetupLineStyle(line.Properties); fixed(C4bV3f *pVertices = line.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (line.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(line.FillColor); } if (line.OldestVertexID == 0) { GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount); } else { GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID); GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices); GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID); } } }
/// <summary> /// (internal use) /// </summary> /// <param name="p">render properties</param> /// <param name="min">minimum coord for label area</param> /// <param name="max">maximum coord for label area</param> public void Draw(ILRenderProperties p, ILPoint3Df min, ILPoint3Df max) { if (!String.IsNullOrEmpty(Text)) { if (m_expression != m_cachedExpression) { interprete(m_expression); } m_renderer.Begin(p); m_renderer.Draw(m_renderQueue, min.X, min.Y, min.Z, max.X, max.Y, max.Z, m_color); m_renderer.End(p); } }
public override void Draw(ILRenderProperties props, ILShape shape) { if (shape.VertexCount == 0) { return; } GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); //GL.Disable(EnableCap.PolygonOffsetFill); ILShape <C4fN3fV3f> cShape = (shape as ILShape <C4fN3fV3f>); fixed(C4fN3fV3f *pVertices = cShape.Vertices) { if (UseLight && (cShape is IILSupportsLight)) { setupLight(cShape as IILSupportsLight); } else { GL.Disable(EnableCap.Lighting); } GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); if (cShape.Shading == ShadingStyles.Interpolate) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(shape.FillColor); } GL.DrawArrays(m_primitiveType, 0, cShape.VertexCount); } GL.Disable(EnableCap.Lighting); ILBorderedShape <C4fN3fV3f> bShape = (shape as ILBorderedShape <C4fN3fV3f>); if (bShape != null && bShape.Border.Visible) { fixed(C4fN3fV3f *pVertices = bShape.Vertices) { ILOGLPanel.SetupLineStyle(bShape.Border); GL.InterleavedArrays(InterleavedArrayFormat.C4fN3fV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); GL.DrawArrays(BeginMode.LineLoop, 0, bShape.VertexCount); } } }
/// <summary> /// draws the whole rendering queue /// </summary> public override void Draw(ILRenderProperties p) { if (m_expression != m_cachedExpression) { interprete(m_expression); } m_renderer.Begin(p); //offsetAlignment(m_size,ref m_position); m_renderer.Draw(m_renderQueue , m_minPosition.X, m_minPosition.Y, m_minPosition.Z , m_maxPosition.X, m_maxPosition.Y, m_maxPosition.Z , m_color); m_renderer.End(p); }
public void Begin(ILRenderProperties p) { if (GraphicsContext.CurrentContext == null) { throw new GraphicsContextException("No GraphicsContext is current in the calling thread."); } GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.DepthTest); }
/// <summary> /// Draw the legend onto a predefined bitmap or into GL context /// </summary> /// <param name="p">render properties</param> /// <param name="area">rectangle area defines region to draw legend contents into.</param> /// <remarks>This function does only render to a predefined bitmap, which must be given in p. Rendering to /// (dvice dependent) graphic contexts is done in derived implementations.</remarks> public virtual void Draw(ILRenderProperties p, Rectangle area) { if (m_panel == null || m_panel.Graphs == null) { return; } if (p.Graphics == null) { throw new ILArgumentException("ILLegend:Draw: unexpected parameter (bitmap) is null. This should be handled in derived classes!"); } // draw bg + border PointF p1, p2; float offsX = Math.Max(m_border.Width / 2.0f, 1.0f), offsY; p1 = new PointF(offsX, offsX); p2 = new PointF(m_size.Width - offsX, offsX); Pen pen = new Pen(m_border.Color, m_border.Width); // todo: implement dash styles p.Graphics.Clear(m_bgColor); p.Graphics.DrawLine(pen, p1, p2); p1.X = p2.X; p1.Y = m_size.Height - offsX; p.Graphics.DrawLine(pen, p2, p1); p2.X = offsX; p2.Y = p1.Y; p.Graphics.DrawLine(pen, p1, p2); p1.X = offsX; p1.Y = offsX; p.Graphics.DrawLine(pen, p2, p1); List <IILLegendRenderer> providers = new List <IILLegendRenderer>(10); foreach (ILGraph graph in m_panel.Graphs) { if (graph is IILLegendRenderer) { providers.Add(graph as IILLegendRenderer); } } // compute final example sizes to fit into my size offsX = m_size.Width * 0.1f; offsY = m_size.Height * 0.1f; area.Height = (int)(m_size.Height - 2 * offsY) / providers.Count; area.Width = (int)(m_size.Width - 2 * offsX) / providers.Count; area.X = (int)offsX; for (int i = 0; i < providers.Count; i++) { area.Y = (int)(offsY + i * area.Height); // todo: not implemented! providers[i].DrawToLegend(p, area, area); } }
/// <summary> /// draws the whole rendering queue /// </summary> public override void Draw(ILRenderProperties p) { if (!m_visible || String.IsNullOrEmpty(m_expression)) { return; } if (m_expression != m_cachedExpression) { interprete(m_expression); } m_renderer.Begin(p); Point renderPoint = offsetAlignment(m_size, m_position); m_renderer.Draw(m_renderQueue, renderPoint, m_orientation, m_color); m_renderer.End(p); }
protected override void IntDrawLabel(ILRenderProperties props) { if (m_vertCount >= VerticesPerShape) { ILPoint3Df cent = m_vertices[m_shapeIndices.GetValue(0)].Position; // draw label at center of first shape if (!String.IsNullOrEmpty(m_label.Text)) { for (int i = 1; i < VerticesPerShape; i++) { cent += m_vertices[m_shapeIndices.GetValue(i)].Position; } m_label.Draw(props, cent / VerticesPerShape); } } }
public void Begin(ILRenderProperties p) { if (GraphicsContext.CurrentContext == null) { throw new GraphicsContextException("No GraphicsContext is current in the calling thread."); } float[] viewport = new float[4]; GL.GetFloat(GetPName.Viewport, viewport); // Prepare to draw text. We want pixel perfect precision, so we setup a 2D mode, // with size equal to the window (in pixels). // While we could also render text in 3D mode, it would be very hard to get // pixel-perfect precision. GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.Ortho(viewport[0], viewport[2], viewport[3], viewport[1], -1.0, 1.0); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.DepthTest); if (p.Clipping) { GL.Disable(EnableCap.ClipPlane0); GL.Disable(EnableCap.ClipPlane1); GL.Disable(EnableCap.ClipPlane2); GL.Disable(EnableCap.ClipPlane3); GL.Disable(EnableCap.ClipPlane4); GL.Disable(EnableCap.ClipPlane5); } if (p.PassCount == 0) { m_xMin = float.MaxValue; m_xMax = float.MinValue; m_yMin = float.MaxValue; m_yMax = float.MinValue; } }
public override void Draw(ILRenderProperties p) { //System.Diagnostics.Debug.WriteLine("ILOGLGraphPlot2D_Draw"); #region draw line // draw linestrip - simple case - fast vertex rendering if (m_properties.Visible) { GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Texture2D); ILOGLPanel.SetupLineStyle(m_properties); unsafe { fixed(C4bV3f *pVertArr = m_vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertArr); if (m_properties.Color.IsEmpty) { GL.ShadeModel(ShadingModel.Smooth); } else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); } if (m_startID < 2) { GL.DrawArrays(BeginMode.LineStrip, m_startID, m_vertexCount - 1); } else { GL.DrawArrays(BeginMode.LineStrip, m_startID, m_vertexCount - m_startID); GL.DrawArrays(BeginMode.LineStrip, 0, m_startID); } } } } #endregion #region draw markers if (m_marker.Visible) { m_marker.Shape.Draw(p, m_marker, m_vertices, 0, m_vertexCount - 1); } #endregion }
public override void Draw(ILRenderProperties props) { if (!m_visible) { return; } if (m_childs != null && m_childs.Count > 0) { ILArray <int> indices = Computation.GetSortedIndices( m_centers, m_panel.Camera.Position); foreach (int i in indices.Values) { if (m_childs[i].Visible) { m_childs[i].Draw(props); } } } }
public override void Draw(ILRenderProperties props, ILShape shape) { GL.Enable(EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); ILLines lines = (shape as ILLines); ILOGLPanel.SetupLineStyle(lines.Properties); fixed (C4bV3f* pVertices = lines.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (lines.Shading == ShadingStyles.Interpolate) GL.ShadeModel(ShadingModel.Smooth); else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(lines.FillColor); } GL.DrawArrays(BeginMode.LineStrip, 0, lines.VertexCount); } }
protected override void IntDrawShape(ILRenderProperties props) { if (m_vertCount >= VerticesPerShape) { // draw from back to front if (m_oldCameraPosition != m_panel.Camera.Position || m_renderIndices == null) { if (m_shading == ShadingStyles.Flat && m_fillColor.A == byte.MaxValue) { m_shapeIndices.ExportValues(ref m_renderIndices); } else { sortPrimitives(); } } m_renderer.Draw(props, this, m_renderIndices); } }
public override void Draw(ILRenderProperties props, ILShape shape) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); ILPoints points = (shape as ILPoints); fixed(C4bV3f *pVertices = points.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (points.Shading == ShadingStyles.Flat) { GL.DisableClientState(EnableCap.ColorArray); GL.Color4(points.FillColor); } GL.Enable(EnableCap.PointSmooth); GL.PointSize(points.Width); GL.DrawArrays(BeginMode.Points, 0, points.VertexCount); } }
public override void Draw(ILRenderProperties props, ILShape shape) { GL.Enable(EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.DepthTest); ILLine line = (shape as ILLine); if (line != null && line.Border.Visible) { fixed (C4bV3f* pVertices = line.Vertices) { ILOGLPanel.SetupLineStyle(line.Border); GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); GL.DisableClientState(EnableCap.ColorArray); if (line.OldestVertexID == 0) { GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount); } else { GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID); GL.DrawElements(BeginMode.Lines,2,DrawElementsType.UnsignedInt, m_closeLoopIndices); GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID); } } } ILOGLPanel.SetupLineStyle(line.Properties); fixed (C4bV3f* pVertices = line.Vertices) { GL.InterleavedArrays(InterleavedArrayFormat.C4ubV3f, 0, (IntPtr)pVertices); if (line.Shading == ShadingStyles.Interpolate) GL.ShadeModel(ShadingModel.Smooth); else { GL.ShadeModel(ShadingModel.Flat); GL.DisableClientState(EnableCap.ColorArray); GL.Color4(line.FillColor); } if (line.OldestVertexID == 0) { GL.DrawArrays(BeginMode.LineStrip, 0, line.VertexCount); } else { GL.DrawArrays(BeginMode.LineStrip, line.OldestVertexID, line.VertexCount - line.OldestVertexID); GL.DrawElements(BeginMode.Lines, 2, DrawElementsType.UnsignedInt, m_closeLoopIndices); GL.DrawArrays(BeginMode.LineStrip, 0, line.OldestVertexID); } } }
/// <summary> /// (internal use) /// </summary> /// <param name="p">render properties</param> /// <param name="center">center position for the label</param> public void Draw(ILRenderProperties p, ILPoint3Df center) { if (!String.IsNullOrEmpty(Text)) { if (m_expression != m_cachedExpression) { interprete(m_expression); } double[] modelview = null; m_renderer.Begin(p, ref modelview); Point dest = m_panel.World2Screen(center, modelview); offsetAlignment(m_size, ref dest); if (m_fringeColor.IsEmpty) { m_renderer.Draw(m_renderQueue, dest, TextOrientation.Horizontal, m_color); } else { drawFringed(m_renderer, m_renderQueue, dest, TextOrientation.Horizontal, m_color); } m_renderer.End(p); } }
public override void DrawToLegend(ILRenderProperties p, Rectangle sampleArea, Rectangle labelArea) { if (p.Graphics != null) { // bitmap output is handled by base class base.DrawToLegend(p, sampleArea, labelArea); return; } int sampY = (int)(sampleArea.Top + sampleArea.Height / 2.0f); #region draw line if (m_properties.Visible) { ILNumerics.Drawing.Platform.OpenGL.ILOGLPanel.SetupLineStyle(m_properties); GL.Begin(BeginMode.Lines); GL.Vertex2(sampleArea.Left, sampY); GL.Vertex2(sampleArea.Right, sampY); GL.End(); } #endregion #region draw marker if (m_marker.Visible) { C4bV3f pos = new C4bV3f(); pos.XPosition = sampleArea.Left + sampleArea.Width / 2.0f; pos.YPosition = sampY; m_marker.Shape.Draw(p, m_marker, new C4bV3f[] { pos }, 0, -1); } #endregion //GL.Vertex2(sampleArea.Right,sampleArea.Bottom); //GL.Vertex2(sampleArea.Left,sampleArea.Bottom); m_label.m_position.X = labelArea.X + labelArea.Width / 2; m_label.m_position.Y = labelArea.Y + labelArea.Height / 2; m_label.Anchor = new PointF(.5f, .5f); // = TickLabelAlign.center | TickLabelAlign.vertCenter; m_label.Draw(p); }
public void End(ILRenderProperties p) { if (p.Clipping) { GL.Enable(EnableCap.ClipPlane0); GL.Enable(EnableCap.ClipPlane1); GL.Enable(EnableCap.ClipPlane2); GL.Enable(EnableCap.ClipPlane3); GL.Enable(EnableCap.ClipPlane4); GL.Enable(EnableCap.ClipPlane5); } GL.PopAttrib(); GL.MatrixMode(MatrixMode.Modelview); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); if (p.PassCount == 0) { if (p.MinX > m_xMin) { p.MinX = (int)m_xMin; } if (p.MaxX < m_xMax) { p.MaxX = (int)m_xMax; } if (p.MaxY < m_yMax) { p.MaxY = (int)m_yMax; } if (p.MinY > m_yMin) { p.MinY = (int)m_yMin; } } }
public abstract void Draw(ILRenderProperties props, ILShape shape);
/// <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(); }
/// <summary> /// (internal use) draws the whole scene graph /// </summary> /// <param name="p"></param> public override void Draw(ILRenderProperties p) { m_root.Draw(p); }
/// <summary> /// draw all lines for the axis /// </summary> /// <param name="g">graphics object (ignored)</param> /// <param name="background">true: draw lines in the back only, false: draw foreground lines</param> protected override void iDrawAxis(ILRenderProperties p, bool background) { // create vertex data: main axis and ticks if (!m_visible) return; int count = 8; float tickLen; float scale, offse, x, y, z , xmin = m_clipping.XMin , xmax = m_clipping.XMax , ymin = m_clipping.YMin , ymax = m_clipping.YMax , zmin = m_clipping.ZMin , zmax = m_clipping.ZMax; tickLen = m_labeledTicks.TickFraction * ((m_labeledTicks.Direction == TickDirection.Inside) ? m_clipping.WidthF : -m_clipping.WidthF); //ConfigureOGLLineProperties(LineStyle.Solid,1); // must draw ticks? bool drawticks,drawlines = false; if (m_labeledTicks.Display == TickDisplay.BothSides) { drawticks = true; } else { drawticks = (background && !m_layoutData.CameraPosition.LooksFromTop) ||(!background && m_layoutData.CameraPosition.LooksFromTop); } x = xmin; y = ymin; z = zmin; float x2, y2, tickLen2 = tickLen; switch (m_layoutData.CameraPosition.Quadrant) { case CameraQuadrant.TopLeftFront: // Q1 case CameraQuadrant.BottomLeftFront: x = xmin; x2 = xmin; y = ymax; y2 = ymin; //tickLen2 *= -1.0f; break; case CameraQuadrant.TopLeftBack: // Q2 case CameraQuadrant.BottomLeftBack: x = xmax; y = ymax; x2 = xmin; y2 = ymax; tickLen *= -1.0f; break; case CameraQuadrant.TopRightBack: // Q3 case CameraQuadrant.BottomRightBack: x = xmax; x2 = xmax; y = ymin; y2 = ymax; tickLen *= -1.0f; tickLen2 *= -1.0f; break; case CameraQuadrant.TopRightFront: case CameraQuadrant.BottomRightFront: // Q4 default: x = xmin; x2 = xmax; y = ymin; y2 = ymin; tickLen2 *= -1.0f; break; } if (background) { if (x == xmin) x = xmax; else x = xmin; if (y == ymin) y = ymax; else y = ymin; if (x2 == xmin) x2 = xmax; else x2 = xmin; if (y2 == ymin) y2 = ymax; else y2 = ymin; GL.Disable(EnableCap.DepthTest); if (m_farLines.Visible) { drawlines = true; ILOGLPanel.SetupLineStyle(m_farLines); } } else { if (m_nearLines.Visible) { drawlines = true; ILOGLPanel.SetupLineStyle(m_nearLines); } } if (drawlines) { GL.Begin(BeginMode.Lines); GL.Vertex3(x,y,z); z = zmax; GL.Vertex3(x,y,z); GL.Vertex3(x2,y2,z); z = zmin; GL.Vertex3(x2,y2,z); GL.End(); } if (m_labeledTicks.Display == TickDisplay.BothSides || (!background && drawlines)) { #region create ticks GL.Enable(EnableCap.DepthTest); if (background) { GL.Color3(m_labeledTicks.FarColor); tickLen *= -1.0f; tickLen2 *= -1.0f; } else GL.Color3(m_labeledTicks.NearColor); GL.Disable(EnableCap.LineStipple); GL.Begin(BeginMode.Lines); foreach (LabeledTick tick in m_labeledTicks) { if (tick.Position >= m_clipping.ZMin && tick.Position <= m_clipping.ZMax) { z = tick.Position; GL.Vertex3(x,y,z); x += tickLen; GL.Vertex3(x,y,z); x -= tickLen; GL.Vertex3(x2,y2,z); x2 += tickLen2; GL.Vertex3(x2,y2,z); x2 -= tickLen2; } } GL.End(); #endregion } if (background && m_grid.Visible) drawGrid(); }
/// <summary> /// draws the whole rendering queue /// </summary> public override void Draw(ILRenderProperties p) { if (m_expression != m_cachedExpression) interprete(m_expression); m_renderer.Begin(p); //offsetAlignment(m_size,ref m_position); m_renderer.Draw(m_renderQueue ,m_minPosition.X,m_minPosition.Y,m_minPosition.Z ,m_maxPosition.X,m_maxPosition.Y,m_maxPosition.Z ,m_color); m_renderer.End(p); }
/// <summary> /// swap buffers and finalize rendering /// </summary> /// <param name="p"></param> protected override void iRenderingState3(ILRenderProperties p) { try { p.Graphics = null; m_legend.Draw(p, Rectangle.Empty); #region screen label test, please delete me //label = new ILNumerics.Drawing.Labeling.ILLabel(this); //label.Position = new Point(30,40); //label.Text = "Screen"; //label.Renderer = TextRendererManager.GetDefault(CoordSystem.Screen); //label.Draw(g); #endregion //GL.MatrixMode(MatrixMode.Modelview); if (m_selectingMode == InteractiveModes.ZoomRectangle && m_isDragging) { drawSelectionRect(PointToClient(MousePosition)); } #if DRAWPLOTCUBESCREENRECT #region float[] viewport = new float[4]; GL.GetFloat(GetPName.Viewport, viewport); GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.Ortho(viewport[0], viewport[2], viewport[3], viewport[1], -1.0, 1.0); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); GL.Color3(Color.LightGray); GL.LineWidth(1f); GL.Begin(BeginMode.LineLoop); GL.Vertex2(m_plotBoxScreenRectF.Left * ClientSize.Width, m_plotBoxScreenRectF.Top * ClientSize.Height); GL.Vertex2(m_plotBoxScreenRectF.Right * ClientSize.Width, m_plotBoxScreenRectF.Top * ClientSize.Height); GL.Vertex2(m_plotBoxScreenRectF.Right * ClientSize.Width, m_plotBoxScreenRectF.Bottom * ClientSize.Height); GL.Vertex2(m_plotBoxScreenRectF.Left * ClientSize.Width, m_plotBoxScreenRectF.Bottom * ClientSize.Height); GL.End(); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); #endregion #endif //GL.Finish(); // update model matrix (to be avilable for zooming etc.) //GL.GetDouble(GetPName.ModelviewMatrix,m_modelViewMatrix); #if DRAWTEXTURESHEET #region // prepare GL float[] viewport = new float[4]; GL.GetFloat(GetPName.Viewport, viewport); GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.Ortho(viewport[0], viewport[2], viewport[3], viewport[1], -1.0, 1.0); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.DepthTest); // draw one large quad with whole texture sheet GL.Begin(BeginMode.Quads); GL.TexCoord2(0, 1); GL.Vertex2(0, ClientSize.Height / 2); // ul GL.TexCoord2(0, 0); GL.Vertex2(0, 0); // bl GL.TexCoord2(1, 0); GL.Vertex2(ClientSize.Width, 0); // br GL.TexCoord2(1, 1); GL.Vertex2(ClientSize.Width, ClientSize.Height / 2); // tr GL.End(); #endregion #endif SwapBuffers(); m_axes.XAxis.RenderState3(p); m_axes.YAxis.RenderState3(p); if (m_camera.SinRho > 1e-5) { m_axes.ZAxis.RenderState3(p); } if (false) { p.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red)), m_axes[0].Label.m_position, m_axes[0].Label.m_position); p.Graphics.DrawLine(new Pen(new SolidBrush(Color.Green)), m_axes[1].Label.m_position, m_axes[0].Label.m_position); p.Graphics.DrawLine(new Pen(new SolidBrush(Color.Blue)), m_axes[2].Label.m_position, m_axes[0].Label.m_position); } } catch (Exception exc) { // todo: exception handling } }
public abstract void DrawToLegend(ILRenderProperties p, Rectangle sampleRect, Rectangle labelRect);
protected override void iRenderingState1(ILRenderProperties p) { MakeCurrent(); }
/// <summary> /// (internal use) /// </summary> /// <param name="p">render properties</param> /// <param name="min">minimum coord for label area</param> /// <param name="max">maximum coord for label area</param> public void Draw(ILRenderProperties p, ILPoint3Df min, ILPoint3Df max) { if (!String.IsNullOrEmpty(Text)) { if (m_expression != m_cachedExpression) interprete(m_expression); m_renderer.Begin(p); m_renderer.Draw(m_renderQueue,min.X,min.Y,min.Z,max.X,max.Y,max.Z, m_color); m_renderer.End(p); } }
public override void DrawToLegend(ILRenderProperties p, Rectangle sampleRect, Rectangle labelRect) { if (m_filled) { // draw inner filled area GL.ShadeModel(ShadingModel.Smooth); GL.Begin(BeginMode.TriangleStrip); GL.Color3(m_panel.Colormap[m_panel.Colormap.Length-1]); GL.Vertex2(sampleRect.X,sampleRect.Y + sampleRect.Height); GL.Color3(m_panel.Colormap[(int)(m_panel.Colormap.Length/2)]); GL.Vertex2(sampleRect.X,sampleRect.Y); GL.Vertex2(sampleRect.X+sampleRect.Width,sampleRect.Y + sampleRect.Height); GL.Color3(m_panel.Colormap[0]); GL.Vertex2(sampleRect.X+sampleRect.Width,sampleRect.Y); GL.End(); } if (m_wireLines.Visible) { ILNumerics.Drawing.Platform.OpenGL.ILOGLPanel.SetupLineStyle(m_wireLines); GL.Begin(BeginMode.LineStrip); GL.Vertex2(sampleRect.X,sampleRect.Y); GL.Vertex2(sampleRect.X+sampleRect.Width,sampleRect.Y); GL.Vertex2(sampleRect.X+sampleRect.Width,sampleRect.Y + sampleRect.Height); GL.Vertex2(sampleRect.X,sampleRect.Y + sampleRect.Height); GL.Vertex2(sampleRect.X,sampleRect.Y); GL.End(); } m_label.m_position.X = labelRect.X + labelRect.Width / 2; m_label.m_position.Y = labelRect.Y + labelRect.Height / 2; m_label.Anchor = new PointF(.5f,.5f); // TickLabelAlign.center | TickLabelAlign.vertCenter; m_label.Draw(p); }
/// <summary> /// Draw the legend onto a predefined bitmap or into GL context /// </summary> /// <param name="p">render properties</param> /// <param name="area">rectangle area defines region to draw legend contents into.</param> /// <remarks>This function does only render to a predefined bitmap, which must be given in p. Rendering to /// (dvice dependent) graphic contexts is done in derived implementations.</remarks> public virtual void Draw(ILRenderProperties p, Rectangle area) { if (m_panel == null || m_panel.Graphs == null) return; if (p.Graphics == null) { throw new ILArgumentException("ILLegend:Draw: unexpected parameter (bitmap) is null. This should be handled in derived classes!"); } // draw bg + border PointF p1,p2; float offsX = Math.Max(m_border.Width / 2.0f,1.0f), offsY; p1 = new PointF(offsX,offsX); p2 = new PointF(m_size.Width-offsX,offsX); Pen pen = new Pen(m_border.Color,m_border.Width); // todo: implement dash styles p.Graphics.Clear(m_bgColor); p.Graphics.DrawLine(pen,p1,p2); p1.X = p2.X; p1.Y = m_size.Height - offsX; p.Graphics.DrawLine(pen,p2,p1); p2.X = offsX; p2.Y = p1.Y; p.Graphics.DrawLine(pen,p1,p2); p1.X = offsX; p1.Y = offsX; p.Graphics.DrawLine(pen,p2,p1); List<IILLegendRenderer> providers = new List<IILLegendRenderer>(10); foreach (ILGraph graph in m_panel.Graphs) { if (graph is IILLegendRenderer) { providers.Add(graph as IILLegendRenderer); } } // compute final example sizes to fit into my size offsX = m_size.Width * 0.1f; offsY = m_size.Height * 0.1f; area.Height = (int)(m_size.Height - 2 * offsY) / providers.Count; area.Width = (int)(m_size.Width - 2 * offsX) / providers.Count; area.X = (int)offsX; for (int i = 0; i < providers.Count; i++) { area.Y = (int)(offsY + i * area.Height); // todo: not implemented! providers[i].DrawToLegend(p,area,area); } }
/// <summary> /// (internal use) /// </summary> /// <param name="p">render properties</param> /// <param name="center">center position for the label</param> public void Draw(ILRenderProperties p, ILPoint3Df center ) { if (!String.IsNullOrEmpty(Text)) { if (m_expression != m_cachedExpression) interprete(m_expression); double[] modelview = null; m_renderer.Begin(p, ref modelview); Point dest = m_panel.World2Screen(center, modelview); offsetAlignment(m_size, ref dest); if (m_fringeColor.IsEmpty) { m_renderer.Draw(m_renderQueue, dest, TextOrientation.Horizontal, m_color); } else { drawFringed(m_renderer, m_renderQueue, dest, TextOrientation.Horizontal, m_color); } m_renderer.End(p); } }
/// <summary> /// draw all markers (graph / legend) /// </summary> /// <param name="marker">the marker object (for properties)</param> /// <param name="vertices">coords, interleaved</param> /// <param name="vertcount">number of coords, special: -1 for legend rendering</param> /// <remarks>This function is reused for both: drawing in world coords (graph) and drawing in /// screen coords (legend). Latter case requires vertcount to be -1, vertices must contain /// at least 2 float values than!</remarks> internal override void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertcount) { if (vertcount > 0) { int inc = Math.Max(1,(vertcount/m_maxLabelsDrawn)); m_renderer.Begin(p); for (int i = 0; i < vertcount; i += inc) { #region draw textured points (slow version: textured quads) string expr = m_expression.Replace("\\index",i.ToString()); expr = expr.Replace("\\xvalue",vertices[i].XPosition.ToString(m_valueFormat)); expr = expr.Replace("\\yvalue",vertices[i].YPosition.ToString(m_valueFormat)); ILRenderQueue queue = m_interpreter.Transform(expr,m_font,marker.Color,m_renderer); #region determine size for markers in world coords (graph limits) float w,h; ILClippingData clip = m_panel.Limits; float s05x; float s05y; s05x = Math.Abs(queue.Size.Width * clip.WidthF / 2 / (m_panel.ClientSize.Width)); s05y = Math.Abs(queue.Size.Height * clip.HeightF / 2 / (m_panel.ClientSize.Height)); #endregion // this is slow! Todo: replace by point sprites! w = vertices[i].XPosition; h = vertices[i].YPosition; if (m_panel.ClipViewData && (w < clip.XMin || w > clip.XMax || h < clip.YMin || h > clip.YMax)) { continue; } m_renderer.Draw(queue,w-s05x,h+s05y,vertices[i].ZPosition, w + s05x,h-s05y,vertices[i].ZPosition,marker.Color); #endregion } m_renderer.End(p); } else if (vertcount == -1) { #region render for legend m_renderer.Begin(p); string expr = m_expression.Replace("\\index","0"); expr = expr.Replace("\\xvalue","0.2"); expr = expr.Replace("\\yvalue","0.4"); ILRenderQueue queue = m_interpreter.Transform(expr,m_font,marker.Color,m_renderer); #region determine size for markers in SCREEN COORDS float w,h; ILClippingData clip = m_panel.Limits; float s05x; float s05y; s05x = Math.Abs(queue.Size.Width / 2 ); s05y = Math.Abs(queue.Size.Height / 2); #endregion // this is slow! Todo: replace by point sprites! w = vertices[0].XPosition; h = vertices[0].YPosition; m_renderer.Draw(queue,w-s05x,h-s05y,0,w + s05x,h+s05y,0,marker.Color); m_renderer.End(p); #endregion } }
public abstract void Draw(ILRenderProperties props, ILShape shape, int[] indices);
public void Begin (ILRenderProperties p, ref double[] modelview) { if (modelview == null || modelview.Length < 12) { modelview = new double[16]; } GL.GetDouble(GetPName.ModelviewMatrix,modelview); Begin(p); }
/// <summary> /// Render the OpenGL scene /// </summary> /// <param name="g"></param> protected override void iRenderingState2(ILRenderProperties p) { if (m_context == null || (!m_active && !m_drawHidden)) { return; } try { //System.Diagnostics.Debug.WriteLine(String.Format("ILOGLPanel{0}: RenderScene, Thread={1}" // ,this.GetHashCode(), System.Threading.Thread.CurrentThread.GetHashCode())); // draw background GL.ClearColor(m_backColor); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // draw back axis GL.Enable(EnableCap.DepthTest); if (m_fillBackground) { renderBackground(); } GL.Enable(EnableCap.Blend); //GL.MatrixMode(MatrixMode.Modelview); //GL.PushMatrix(); if (m_polyOffsetEnable) { GL.Enable(EnableCap.PolygonOffsetFill); } else { GL.Disable(EnableCap.PolygonOffsetFill); } GL.PolygonOffset(1.0f, 1.0f); GL.Disable(EnableCap.Blend); m_axes.XAxis.RenderState1(p); m_axes.YAxis.RenderState1(p); if (m_camera.SinRho > 1e-5) { m_axes.ZAxis.RenderState1(p); } if ((m_plotBoxScreenSizeMode != PlotBoxScreenSizeMode.StrictOptimal) || (p.PassCount > 0)) { #region enable clipping planes if (m_renderProperties.Clipping) { unsafe { fixed(double *pClip = m_clipplanes) { if (m_clippingView.WidthF > 0) { GL.ClipPlane(ClipPlaneName.ClipPlane0, pClip); GL.ClipPlane(ClipPlaneName.ClipPlane1, pClip + 4); GL.Enable(EnableCap.ClipPlane0); GL.Enable(EnableCap.ClipPlane1); } if (m_clippingView.HeightF > 0) { GL.ClipPlane(ClipPlaneName.ClipPlane2, pClip + 8); GL.ClipPlane(ClipPlaneName.ClipPlane3, pClip + 12); GL.Enable(EnableCap.ClipPlane2); GL.Enable(EnableCap.ClipPlane3); } if (m_clippingView.DepthF > 0) { GL.ClipPlane(ClipPlaneName.ClipPlane4, pClip + 16); GL.ClipPlane(ClipPlaneName.ClipPlane5, pClip + 20); GL.Enable(EnableCap.ClipPlane4); GL.Enable(EnableCap.ClipPlane5); } } } } #endregion // draw all graphs //GL.MatrixMode(MatrixMode.Modelview); //ILPoint3Df ab = m_clippingView.CenterToUnitCube(); //GL.Translate(ab.X, ab.Y, ab.Z); //ab = m_clippingView.ScaleToUnitCube(); //GL.Scale(ab.X, ab.Y, ab.Z); //Identity; //RotationZ(m_cameraPhi); #region lighting if (m_mustReconfigureLight) { m_mustReconfigureLight = false; if (m_lights.Enabled) { float[] tmpF = new float[4]; tmpF[3] = 1.0f; foreach (ILLight light in m_lights) { EnableCap lightID = EnableCap.Light0 + light.Index; if (!light.Enabled) { GL.Disable(lightID); continue; } GL.Enable(lightID); tmpF[0] = light.Position.X; tmpF[1] = light.Position.Y; tmpF[2] = light.Position.Z; GL.Lightv((LightName)lightID, LightParameter.Position, tmpF); tmpF[0] = (float)light.Ambient.R / 255; tmpF[1] = (float)light.Ambient.G / 255; tmpF[2] = (float)light.Ambient.B / 255; GL.Lightv((LightName)lightID, LightParameter.Ambient, tmpF); tmpF[0] = (float)light.Specular.R / 255; tmpF[1] = (float)light.Specular.G / 255; tmpF[2] = (float)light.Specular.B / 255; GL.Lightv((LightName)lightID, LightParameter.Specular, tmpF); tmpF[0] = (float)light.Diffuse.R / 255; tmpF[1] = (float)light.Diffuse.G / 255; tmpF[2] = (float)light.Diffuse.B / 255; GL.Lightv((LightName)lightID, LightParameter.Diffuse, tmpF); } } } #endregion #region graph rendering // Easy sorting - this expects a few graphs in the collection only. // For situations, where a large number of graphs need to be sorted here, // one may implement sorting in the way it is done in ILSceneGraph // (via ILNumerics.ILArray and ILMath.sort). //m_graphs.Sort(new ILNumerics.Drawing.Misc.ILGraphComparer()); m_sortingCacheList.Clear(); m_graphs.GetSortedList4Render(m_camera, m_sortingCacheList); foreach (ILGraph graph in m_sortingCacheList) { try { graph.Draw(p); } catch (Exception e) { #if TRACE m_errorCount++; if (m_errorCount < MAXERRORLOGCOUNT) { System.Diagnostics.Trace.TraceError(String.Format("[{0}].Draw() failed: {1}", graph.GetType().Name, e.ToString())); } else if (m_errorCount == MAXERRORLOGCOUNT) { System.Diagnostics.Trace.TraceError(String.Format("(more than {0} errors. Further reporting disabled.)", m_errorCount)); } #endif } } #endregion #region world label test, please delete me //ILNumerics.Drawing.Labeling.ILLabel label = new ILNumerics.Drawing.Labeling.ILLabel(this); //label.Position = new Point(0,0); //label.Text = "World"; //label.Renderer = TextRendererManager.GetDefault(CoordSystem.World3D); //label.Draw(g); #endregion #region disable clipping planes GL.Disable(EnableCap.ClipPlane0); GL.Disable(EnableCap.ClipPlane1); GL.Disable(EnableCap.ClipPlane2); GL.Disable(EnableCap.ClipPlane3); GL.Disable(EnableCap.ClipPlane4); GL.Disable(EnableCap.ClipPlane5); #endregion disable clipping planes } // render front axis //GL.MatrixMode(MatrixMode.Modelview); //GL.PopMatrix(); GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.LineSmooth); m_axes.XAxis.RenderState2(p); m_axes.YAxis.RenderState2(p); if (m_camera.SinRho > 1e-5) { m_axes.ZAxis.RenderState2(p); } } catch (Exception e) { // TODO: implement exception handling } }
public void Begin(ILRenderProperties p) { if (GraphicsContext.CurrentContext == null) throw new GraphicsContextException("No GraphicsContext is current in the calling thread."); GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.DepthTest); }
/// <summary> /// draw all lines for the axis /// </summary> /// <param name="p">render properties</param> /// <param name="background">true: draw lines in the back only, false: draw foreground lines</param> protected override void iDrawAxis(ILRenderProperties p, bool background) { // create vertex data: main axis and ticks if (m_visible) { float tickLen; float x, y, z , xmin = m_clipping.XMin , xmax = m_clipping.XMax , ymin = m_clipping.YMin , ymax = m_clipping.YMax , zmin = m_clipping.ZMin , zmax = m_clipping.ZMax; tickLen = m_labeledTicks.TickFraction * ((m_labeledTicks.Direction == TickDirection.Inside) ? -m_clipping.WidthF : m_clipping.WidthF); // must draw ticks? bool drawticks = false, drawlines = false; if (m_labeledTicks.Display == TickDisplay.BothSides) { drawticks = true; } else { drawticks = (background ^ m_layoutData.CameraPosition.LooksFromTop); } y = ymin; z = zmin; // determine which axis to draw: find front if (!m_layoutData.CameraPosition.LooksFromLeft && !m_layoutData.CameraPosition.Is2DView) { x = xmax; } else { x = xmin; tickLen *= -1.0f; } if (background) { if (x == xmin) { x = xmax; } else { x = xmin; } tickLen *= -1.0f; GL.Disable(EnableCap.DepthTest); if (m_farLines.Visible) { ILOGLPanel.SetupLineStyle(m_farLines); drawlines = true; } } else { if (m_nearLines.Visible) { ILOGLPanel.SetupLineStyle(m_nearLines); drawlines = true; } } if (drawlines) { GL.Begin(BeginMode.Lines); GL.Vertex3(x, y, z); y = ymax; GL.Vertex3(x, y, z); if (m_layoutData.CameraPosition.SinRho > 1e-5) { z = zmax; GL.Vertex3(x, y, z); y = ymin; GL.Vertex3(x, y, z); } GL.End(); } if (drawticks && drawlines) { #region create ticks if (!m_layoutData.CameraPosition.LooksFromTop) { //tickLen *= -1.0f; //x *= -1.0f; if (background) { GL.Color3(m_labeledTicks.NearColor); } else { GL.Color3(m_labeledTicks.FarColor); } } else { if (background) { GL.Color3(m_labeledTicks.FarColor); } else { GL.Color3(m_labeledTicks.NearColor); } } //scale = m_clipping.ScaleToUnitCube().Y; //offse = m_clipping.CenterToUnitCube().Y; GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.LineStipple); GL.Begin(BeginMode.Lines); foreach (LabeledTick tick in m_labeledTicks) { if (tick.Position >= ymin && tick.Position <= ymax) { y = tick.Position; if (m_layoutData.CameraPosition.SinRho > 1e-5) { z = zmax; GL.Vertex3(x, y, z); x += tickLen; GL.Vertex3(x, y, z); } else { x += tickLen; } z = zmin; GL.Vertex3(x, y, z); x -= tickLen; GL.Vertex3(x, y, z); } } GL.End(); } if (background && m_grid.Visible) { drawGrid(); } #endregion } }
/// <summary> /// draws the graph into the panel /// </summary> /// <param name="p">extended drawing properties</param> public abstract void Draw(ILRenderProperties p);
/// <summary> /// Render the OpenGL scene /// </summary> /// <param name="g"></param> protected override void iRenderingState2(ILRenderProperties p) { if (m_context == null || (!m_active && !m_drawHidden)) return; try { //System.Diagnostics.Debug.WriteLine(String.Format("ILOGLPanel{0}: RenderScene, Thread={1}" // ,this.GetHashCode(), System.Threading.Thread.CurrentThread.GetHashCode())); // draw background GL.ClearColor(m_backColor); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // draw back axis GL.Enable(EnableCap.DepthTest); if (m_fillBackground) renderBackground(); GL.Enable(EnableCap.Blend); //GL.MatrixMode(MatrixMode.Modelview); //GL.PushMatrix(); if (m_polyOffsetEnable) { GL.Enable(EnableCap.PolygonOffsetFill); } else { GL.Disable(EnableCap.PolygonOffsetFill); } GL.PolygonOffset(1.0f,1.0f); GL.Disable(EnableCap.Blend); m_axes.XAxis.RenderState1(p); m_axes.YAxis.RenderState1(p); if (m_camera.SinRho > 1e-5) m_axes.ZAxis.RenderState1(p); if ((m_plotBoxScreenSizeMode != PlotBoxScreenSizeMode.StrictOptimal) || (p.PassCount > 0)) { #region enable clipping planes if (m_renderProperties.Clipping) { unsafe { fixed (double* pClip = m_clipplanes) { if (m_clippingView.WidthF > 0) { GL.ClipPlane(ClipPlaneName.ClipPlane0, pClip); GL.ClipPlane(ClipPlaneName.ClipPlane1, pClip + 4); GL.Enable(EnableCap.ClipPlane0); GL.Enable(EnableCap.ClipPlane1); } if (m_clippingView.HeightF > 0) { GL.ClipPlane(ClipPlaneName.ClipPlane2, pClip + 8); GL.ClipPlane(ClipPlaneName.ClipPlane3, pClip + 12); GL.Enable(EnableCap.ClipPlane2); GL.Enable(EnableCap.ClipPlane3); } if (m_clippingView.DepthF > 0) { GL.ClipPlane(ClipPlaneName.ClipPlane4, pClip + 16); GL.ClipPlane(ClipPlaneName.ClipPlane5, pClip + 20); GL.Enable(EnableCap.ClipPlane4); GL.Enable(EnableCap.ClipPlane5); } } } } #endregion // draw all graphs //GL.MatrixMode(MatrixMode.Modelview); //ILPoint3Df ab = m_clippingView.CenterToUnitCube(); //GL.Translate(ab.X, ab.Y, ab.Z); //ab = m_clippingView.ScaleToUnitCube(); //GL.Scale(ab.X, ab.Y, ab.Z); //Identity; //RotationZ(m_cameraPhi); #region lighting if (m_mustReconfigureLight) { m_mustReconfigureLight = false; if (m_lights.Enabled) { float[] tmpF = new float[4]; tmpF[3] = 1.0f; foreach (ILLight light in m_lights) { EnableCap lightID = EnableCap.Light0 + light.Index; if (!light.Enabled) { GL.Disable(lightID); continue; } GL.Enable(lightID); tmpF[0] = light.Position.X; tmpF[1] = light.Position.Y; tmpF[2] = light.Position.Z; GL.Lightv((LightName)lightID, LightParameter.Position, tmpF); tmpF[0] = (float)light.Ambient.R / 255; tmpF[1] = (float)light.Ambient.G / 255; tmpF[2] = (float)light.Ambient.B / 255; GL.Lightv((LightName)lightID, LightParameter.Ambient, tmpF); tmpF[0] = (float)light.Specular.R / 255; tmpF[1] = (float)light.Specular.G / 255; tmpF[2] = (float)light.Specular.B / 255; GL.Lightv((LightName)lightID, LightParameter.Specular, tmpF); tmpF[0] = (float)light.Diffuse.R / 255; tmpF[1] = (float)light.Diffuse.G / 255; tmpF[2] = (float)light.Diffuse.B / 255; GL.Lightv((LightName)lightID, LightParameter.Diffuse, tmpF); } } } #endregion #region graph rendering // Easy sorting - this expects a few graphs in the collection only. // For situations, where a large number of graphs need to be sorted here, // one may implement sorting in the way it is done in ILSceneGraph // (via ILNumerics.ILArray and ILMath.sort). //m_graphs.Sort(new ILNumerics.Drawing.Misc.ILGraphComparer()); m_sortingCacheList.Clear(); m_graphs.GetSortedList4Render(m_camera, m_sortingCacheList); foreach (ILGraph graph in m_sortingCacheList) { try { graph.Draw(p); } catch (Exception e) { #if TRACE m_errorCount++; if (m_errorCount < MAXERRORLOGCOUNT) { System.Diagnostics.Trace.TraceError(String.Format("[{0}].Draw() failed: {1}",graph.GetType().Name,e.ToString())); } else if (m_errorCount == MAXERRORLOGCOUNT) { System.Diagnostics.Trace.TraceError(String.Format("(more than {0} errors. Further reporting disabled.)",m_errorCount)); } #endif } } #endregion #region world label test, please delete me //ILNumerics.Drawing.Labeling.ILLabel label = new ILNumerics.Drawing.Labeling.ILLabel(this); //label.Position = new Point(0,0); //label.Text = "World"; //label.Renderer = TextRendererManager.GetDefault(CoordSystem.World3D); //label.Draw(g); #endregion #region disable clipping planes GL.Disable(EnableCap.ClipPlane0); GL.Disable(EnableCap.ClipPlane1); GL.Disable(EnableCap.ClipPlane2); GL.Disable(EnableCap.ClipPlane3); GL.Disable(EnableCap.ClipPlane4); GL.Disable(EnableCap.ClipPlane5); #endregion disable clipping planes } // render front axis //GL.MatrixMode(MatrixMode.Modelview); //GL.PopMatrix(); GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.LineSmooth); m_axes.XAxis.RenderState2(p); m_axes.YAxis.RenderState2(p); if (m_camera.SinRho > 1e-5) m_axes.ZAxis.RenderState2(p); } catch (Exception e) { // TODO: implement exception handling } }
/// <summary> /// draw all lines for the x axis /// </summary> /// <param name="p">render properties</param> /// <param name="background">true: draw lines in the back only, false: draw foreground lines</param> protected override void iDrawAxis(ILRenderProperties p, bool background) { // create vertex data: main axis and ticks if (m_visible) { float tickLen; float x,y,z ,xmin = m_clipping.XMin ,xmax = m_clipping.XMax ,ymin = m_clipping.YMin ,ymax = m_clipping.YMax ,zmin = m_clipping.ZMin ,zmax = m_clipping.ZMax; tickLen = m_labeledTicks.TickFraction * ((m_labeledTicks.Direction == TickDirection.Inside) ? m_clipping.HeightF : -m_clipping.HeightF); // must draw ticks? bool drawticks = false, drawLines = false; if (m_labeledTicks.Display == TickDisplay.BothSides) { drawticks = true; } else { drawticks = (background && !m_layoutData.CameraPosition.LooksFromTop) ||(!background && m_layoutData.CameraPosition.LooksFromTop); } x = xmin; z = zmin; // determine which axis to draw: find front if (!m_layoutData.CameraPosition.LooksFromFront) { tickLen *= -1.0f; y = ymax; } else { y = ymin; } if (background) { if (m_farLines.Visible) { ILOGLPanel.SetupLineStyle(m_farLines); drawLines = true; } if (y == ymax) y = ymin; else y = ymax; GL.Disable(EnableCap.DepthTest); tickLen *= -1.0f; } else { if (m_nearLines.Visible) { ILOGLPanel.SetupLineStyle(m_nearLines); drawLines = true; } } if (drawLines) { GL.Begin(BeginMode.Lines); GL.Vertex3(x,y,z); x = xmax; GL.Vertex3(x,y,z); if (m_layoutData.CameraPosition.SinRho > 1e-5) { z = zmax; GL.Vertex3(x,y,z); x = xmin; GL.Vertex3(x,y,z); } GL.End(); } GL.Enable(EnableCap.DepthTest); if (drawticks && drawLines) { #region create ticks if (!m_layoutData.CameraPosition.LooksFromTop) { //tickLen *= -1.0f; //y *= -1.0f; if (background) GL.Color3(m_labeledTicks.NearColor); else GL.Color3(m_labeledTicks.FarColor); } else { if (background) GL.Color3(m_labeledTicks.FarColor); else GL.Color3(m_labeledTicks.NearColor); } //scale = m_clipping.ScaleToUnitCube().X; //offse = m_clipping.CenterToUnitCube().X; GL.Disable(EnableCap.LineStipple); GL.Begin(BeginMode.Lines); foreach (LabeledTick tick in m_labeledTicks) { if (tick.Position >= xmin && tick.Position <= xmax) { x = tick.Position; if (m_layoutData.CameraPosition.SinRho > 1e-5) { z = zmax; GL.Vertex3(x, y, z); y += tickLen; GL.Vertex3(x, y, z); } else { y += tickLen; } z = zmin; GL.Vertex3(x,y,z); y -= tickLen; GL.Vertex3(x,y,z); } } GL.End(); #endregion } if (background && m_grid.Visible) drawGrid(); } }
public void End(ILRenderProperties p) { GL.PopAttrib(); }
/// <summary> /// swap buffers and finalize rendering /// </summary> /// <param name="p"></param> protected override void iRenderingState3(ILRenderProperties p) { try { p.Graphics = null; m_legend.Draw(p, Rectangle.Empty); #region screen label test, please delete me //label = new ILNumerics.Drawing.Labeling.ILLabel(this); //label.Position = new Point(30,40); //label.Text = "Screen"; //label.Renderer = TextRendererManager.GetDefault(CoordSystem.Screen); //label.Draw(g); #endregion //GL.MatrixMode(MatrixMode.Modelview); if (m_selectingMode == InteractiveModes.ZoomRectangle && m_isDragging) drawSelectionRect(PointToClient(MousePosition)); #if DRAWPLOTCUBESCREENRECT #region float[] viewport = new float[4]; GL.GetFloat(GetPName.Viewport, viewport); GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.Ortho(viewport[0], viewport[2], viewport[3], viewport[1], -1.0, 1.0); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); GL.Color3(Color.LightGray); GL.LineWidth(1f); GL.Begin(BeginMode.LineLoop); GL.Vertex2(m_plotBoxScreenRectF.Left * ClientSize.Width, m_plotBoxScreenRectF.Top * ClientSize.Height); GL.Vertex2(m_plotBoxScreenRectF.Right * ClientSize.Width, m_plotBoxScreenRectF.Top * ClientSize.Height); GL.Vertex2(m_plotBoxScreenRectF.Right * ClientSize.Width, m_plotBoxScreenRectF.Bottom * ClientSize.Height); GL.Vertex2(m_plotBoxScreenRectF.Left * ClientSize.Width, m_plotBoxScreenRectF.Bottom * ClientSize.Height); GL.End(); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); #endregion #endif //GL.Finish(); // update model matrix (to be avilable for zooming etc.) //GL.GetDouble(GetPName.ModelviewMatrix,m_modelViewMatrix); #if DRAWTEXTURESHEET #region // prepare GL float[] viewport = new float[4]; GL.GetFloat(GetPName.Viewport, viewport); GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.Ortho(viewport[0], viewport[2], viewport[3], viewport[1], -1.0, 1.0); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit | AttribMask.ColorBufferBit); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.DepthTest); // draw one large quad with whole texture sheet GL.Begin(BeginMode.Quads); GL.TexCoord2(0,1); GL.Vertex2(0,ClientSize.Height/2); // ul GL.TexCoord2(0,0); GL.Vertex2(0,0); // bl GL.TexCoord2(1,0); GL.Vertex2(ClientSize.Width,0); // br GL.TexCoord2(1,1); GL.Vertex2(ClientSize.Width,ClientSize.Height/2); // tr GL.End(); #endregion #endif SwapBuffers(); m_axes.XAxis.RenderState3(p); m_axes.YAxis.RenderState3(p); if (m_camera.SinRho > 1e-5) m_axes.ZAxis.RenderState3(p); if (false) { p.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red)), m_axes[0].Label.m_position, m_axes[0].Label.m_position); p.Graphics.DrawLine(new Pen(new SolidBrush(Color.Green)), m_axes[1].Label.m_position, m_axes[0].Label.m_position); p.Graphics.DrawLine(new Pen(new SolidBrush(Color.Blue)), m_axes[2].Label.m_position, m_axes[0].Label.m_position); } } catch (Exception exc) { // todo: exception handling } }
/// <summary> /// Draws the graph into existing context /// </summary> public override void Draw(ILRenderProperties p) { if (m_panel.Camera.Rho > Math.PI/2) return; if (!m_isReady) Configure(); float zPos = m_zPosition; if (zPos == float.PositiveInfinity) { zPos = m_panel.Limits.ZMax; } else if (zPos == float.NegativeInfinity) { zPos = m_panel.Limits.ZMin; } GL.Translate(0.0f, 0.0f, zPos); GL.Enable(EnableCap.Blend); GL.Disable(EnableCap.DepthTest); GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ShadeModel(ShadingModel.Flat); unsafe { fixed (VERTEXTYPEDEF* pVertices = m_vertices) { GL.InterleavedArrays( InterleavedArrayFormat.C4ubV2f,0,(IntPtr)pVertices); if (m_filled) { fixed (UInt32* pIndices = m_indices) { for (int i = 0; i < m_stripesCount; i++) { GL.DrawElements(BeginMode.Triangles,m_stripesLen, DrawElementsType.UnsignedInt, (IntPtr)(pIndices+i*m_stripesLen)); } GL.Finish(); } } #region draw grid if (m_wireLines.Visible) { if (m_wireLines.Style == LineStyle.Solid) { GL.Disable(EnableCap.LineStipple); } else { int stipFactr = 1; short stipple; if (m_wireLines.Style != LineStyle.UserPattern) stipple = ILPanel.StippleFromLineStyle( m_wireLines.Style, ref stipFactr); else stipple = m_wireLines.Pattern; GL.Enable(EnableCap.LineStipple); GL.LineStipple((int)m_wireLines.PatternScale,stipple); } if (m_wireLines.Antialiasing) GL.Enable(EnableCap.LineSmooth); else GL.Disable(EnableCap.LineSmooth); GL.Disable(EnableCap.Blend); GL.LineWidth(m_wireLines.Width); if (m_wireLines.Color != System.Drawing.Color.Empty) { GL.DisableClientState(EnableCap.ColorArray); GL.Color3(m_wireLines.Color); } fixed (UInt32* pIndices = m_gridIndices) { GL.DrawElements(BeginMode.Lines, m_gridIndicesCount, DrawElementsType.UnsignedInt, (IntPtr)pIndices); GL.Finish(); } } #endregion } } GL.Translate(0.0f, 0.0f, -zPos); }
public override void DrawToLegend(ILRenderProperties p, Rectangle sampleArea, Rectangle labelArea) { if (p.Graphics != null) { // bitmap output is handled by base class base.DrawToLegend(p, sampleArea, labelArea); return; } int sampY = (int)(sampleArea.Top + sampleArea.Height / 2.0f); #region draw line if (m_properties.Visible) { ILNumerics.Drawing.Platform.OpenGL.ILOGLPanel.SetupLineStyle(m_properties); GL.Begin(BeginMode.Lines); GL.Vertex2(sampleArea.Left,sampY); GL.Vertex2(sampleArea.Right,sampY); GL.End(); } #endregion #region draw marker if (m_marker.Visible) { C4bV3f pos = new C4bV3f(); pos.XPosition = sampleArea.Left + sampleArea.Width / 2.0f; pos.YPosition = sampY; m_marker.Shape.Draw(p, m_marker,new C4bV3f[] {pos},0,-1); } #endregion //GL.Vertex2(sampleArea.Right,sampleArea.Bottom); //GL.Vertex2(sampleArea.Left,sampleArea.Bottom); m_label.m_position.X = labelArea.X + labelArea.Width / 2; m_label.m_position.Y = labelArea.Y + labelArea.Height / 2; m_label.Anchor = new PointF(.5f, .5f); // = TickLabelAlign.center | TickLabelAlign.vertCenter; m_label.Draw(p); }
internal override void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertCount) { // dummy. Nothing to do! }
internal override void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertCount) { if (vertCount == 0 && vertCount != -1) return; string texKey = Hash(); ILTextureData texData; if (!m_panel.TextureManager.Exists(texKey)) { storeBitmap(m_bitmap); } texData = m_panel.TextureManager.GetTextureItem(texKey,true); System.Diagnostics.Debug.Assert(texData != null,"The texture key for the bitmap was expected to exist in texture storage, but it was not found!"); // prepare for plotting GL.Color3(marker.Color); GL.PushAttrib(AttribMask.AllAttribBits); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Disable(EnableCap.DepthTest); RectangleF rectF = texData.TextureRectangle; float w,h; if (vertCount > 0) { #region draw textured points (slow version: textured quads) #region determine size for markers in world coords (graph limits) ILClippingData clip = m_panel.Limits; float s05x; float s05y; //if (m_marker.) s05x = Math.Abs(marker.Size * clip.WidthF / (m_panel.ClientSize.Width)); s05y = Math.Abs(marker.Size * clip.HeightF / (m_panel.ClientSize.Height)); #endregion // draw all markers using quads. // this is slow! Todo: replace by point sprites! GL.Begin(BeginMode.Quads); for (int i = 0; i < vertCount; i++) { w = vertices[i].Position.X; h = vertices[i].Position.Y; if (m_panel.ClipViewData && (w < clip.XMin || w > clip.XMax || h < clip.YMin || h > clip.YMax)) continue; w -= s05x; h -= s05y; GL.TexCoord2(rectF.Left,rectF.Bottom); GL.Vertex2(w,h); // ul GL.TexCoord2(rectF.Left,rectF.Top); GL.Vertex2(w,h + 2 * s05y); // bl w += 2 * s05x; GL.TexCoord2(rectF.Right,rectF.Top); GL.Vertex2(w,h + 2 * s05y); // br GL.TexCoord2(rectF.Right,rectF.Bottom); GL.Vertex2(w,h); // tr } GL.End(); #endregion } else if (vertCount == -1) { #region render to legend // draw all markers using quads. // this is slow! Todo: replace by point sprites! GL.Begin(BeginMode.Quads); w = vertices[0].XPosition - m_bitmap.Width / 2; h = vertices[0].YPosition - m_bitmap.Height / 2; GL.TexCoord2(rectF.Left,rectF.Top); GL.Vertex2(w,h); // ul GL.TexCoord2(rectF.Left,rectF.Bottom); GL.Vertex2(w,h + m_bitmap.Height); // bl w += m_bitmap.Width; GL.TexCoord2(rectF.Right,rectF.Bottom); GL.Vertex2(w,h + m_bitmap.Height); // br GL.TexCoord2(rectF.Right,rectF.Top); GL.Vertex2(w,h); // tr GL.End(); #endregion } GL.PopAttrib(); }