Example #1
0
 internal override void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertCount) {
     // dummy. Nothing to do! 
 }
Example #2
0
        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) {
            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();
        }
Example #4
0
        /// <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
            }

        }
        internal override void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertCount) {
            // some implementations need to know we are drawing in 
            // screen coords, vertcount give the signal: -1
            if (vertCount == 0 || vertCount < -1) return; 
            if (m_style != MarkerStyle.None) {
               if (m_style == MarkerStyle.Dot || m_style == MarkerStyle.Square) {
                    SetupMarkerStyle(marker);
                    unsafe { 
                        fixed(C4bV3f* pVertArr = vertices) {
                            //GL.TexCoord2(0.5,0.5); 
                            GL.InterleavedArrays(InterleavedArrayFormat.V2f,0,(IntPtr)pVertArr); 
                            GL.DrawArrays(BeginMode.Points,0,Math.Abs(vertCount)); 
                        }
                    }
                } else {
                    #region draw textured points (slow version: textured quads)
                    string markerTexKey = Hash(); 
                    ILTextureData texData; 
                    if (!m_panel.TextureManager.Exists(markerTexKey)) {
                        CacheMarkerBitmap();
                    }
                    texData = m_panel.TextureManager.GetTextureItem(markerTexKey,true); 
        System.Diagnostics.Debug.Assert(texData != null,"The texture for marker 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 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].XPosition; 
                            h = vertices[i].YPosition;           
                            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(); 
                    } else if (vertCount == -1) {
                        GL.Begin(BeginMode.Quads); 
                            w = vertices[0].XPosition - marker.Size / 2; 
                            h = vertices[0].XPosition - marker.Size / 2;           
                            GL.TexCoord2(rectF.Left,rectF.Top);              
                            GL.Vertex2(w,h);                                    // ul
                            GL.TexCoord2(rectF.Left,rectF.Bottom);                 
                            GL.Vertex2(w,h + marker.Size);                      // bl
                            w += marker.Size;                                
                            GL.TexCoord2(rectF.Right,rectF.Bottom);                
                            GL.Vertex2(w,h + marker.Size);                      // br
                            GL.TexCoord2(rectF.Right,rectF.Top);             
                            GL.Vertex2(w,h);                                    // tr
                        GL.End(); 
                    }
                    GL.PopAttrib();
                    #endregion
                }
           }
        } 
Example #6
0
 internal abstract void Draw(ILRenderProperties p, ILMarker marker, C4bV3f[] vertices, int startID, int vertCount);