示例#1
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
            }
        }
示例#2
0
 /// <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);
 }