public void Draw(ILRenderQueue renderQueue, Point position, TextOrientation orientation, Color color) { Draw(renderQueue,position.X,position.Y,0,position.X + renderQueue.Size.Width,position.Y+renderQueue.Size.Height,0,color); }
/// <summary> /// Draws all items contained in a given render queue /// </summary> /// <param name="queue">render queue</param> /// <param name="x1">x1-position</param> /// <param name="y1">y1-position</param> /// <param name="z1">z1-position</param> /// <param name="x2">x2-position</param> /// <param name="y2">y2-position</param> /// <param name="z2">z2-position</param> /// <param name="color">base color for items not containing individual colors</param> /// <remarks><para>The render queue must contain only keys for already cached items!</para> /// <para>The color parameter serves as a global color definition. It may be overwritten /// by individual color specifications of the queue items.</para> /// <para>Use this function to draw the render queue in world coords. The position parameters mark the upper left /// and lower right corner of the quads to contain the render queue content.</para> /// </remarks> public void Draw(ILRenderQueue queue, float x1, float y1, float z1, float x2, float y2, float z2, Color color) { float x, y, xm, ym; xm = (x2 - x1)/(queue.Size.Width); ym = (y2 - y1)/(queue.Size.Height); x = 0.5f; y = 0.5f; int lineHeight = 0; m_textureManager.Reset(); GLColor3(color); foreach (ILRenderQueueItem item in queue) { // special symbols & control sequences switch (item.Key) { case "\r": x = 0.5f; break; case "\n": x = 0.5f; y += lineHeight; lineHeight = 0; break; default: //since textures (may) lay on different sheets in GL memory, // we cannot switch them in between Begin() and End(), // we must start a new Begin with each Quad :( // possible workaround: If only one sheet is used, draw all // quads at once. ILTextureData textData = m_textureManager.GetTextureItem(item.Key,true); if (item.Color != Color.Empty) { GLColor3(item.Color); } else { GLColor3(color); } GL.Begin(BeginMode.Quads); RectangleF rectF = textData.TextureRectangle; GL.TexCoord2(rectF.Left,rectF.Bottom); GL.Vertex3(x*xm + x1,(y + textData.Height + item.Offset.Y-1)*ym+y1,z1); // ul GL.TexCoord2(rectF.Left,rectF.Top); GL.Vertex3(x*xm + x1,(y+ item.Offset.Y)*ym+y1,z1); // bl x += textData.Width-1; GL.TexCoord2(rectF.Right,rectF.Top); GL.Vertex3(x*xm + x1,(y+ item.Offset.Y)*ym+y1,z1); // br GL.TexCoord2(rectF.Right,rectF.Bottom); GL.Vertex3(x*xm + x1,(y + textData.Height+ item.Offset.Y-1)*ym+y1,z1); // tr if (textData.Height > lineHeight) lineHeight = textData.Height; GL.End(); #if BOUNDINGBOXES_ITEM //// define DEBUG symbol to draw bounding box around each item (debug feature) // todo: modify to draw in world coords if needed!! //GL.Color3(Color.Red); //GL.Begin(BeginMode.LineLoop); // w-= textData.Width; // GL.Vertex2(w,h + textData.Height); // ul // GL.Vertex2(w,h); // bl // w += textData.Width; // GL.Vertex2(w,h); // br // GL.Vertex2(w,h + textData.Height); // tr //GL.End(); #endif break; } } #if BOUNDINGBOXES //// define debugsymbol "BOUNDINGBOXES", to draw bounding box around whole expression // todo: modify to draw in world coords if needed!! //GL.Disable(EnableCap.Texture2D); //GL.Color3(Color.Red); //GL.LineWidth(1); //GL.Begin(BeginMode.LineLoop); // GL.Vertex2(0,0); // ul // GL.Vertex2(0,queue.Size.Height); // bl // GL.Vertex2(queue.Size.Width,queue.Size.Height); // br // GL.Vertex2(queue.Size.Width,0); // tr //GL.End(); //GL.Enable(EnableCap.Texture2D); #endif }
/// <summary> /// create single labeled tick /// </summary> /// <param name="position">position</param> /// <param name="queue">render queue used to render the item</param> public LabeledTick(float position, ILRenderQueue queue) { Position = position; Queue = queue; }
/// <summary> /// interprete the expression and cache render queue /// </summary> /// <param name="expression"></param> protected void interprete(string expression) { if (m_renderQueue != null) m_renderQueue.Clear(); m_renderQueue = m_interpreter.Transform(expression,m_font,m_color,m_renderer); m_size = m_renderQueue.Size; m_cachedExpression = expression; }
/// <summary> /// [abstract] Create a new labeling element /// </summary> /// <param name="panel">panel hosting the element</param> /// <param name="font">default font for the element</param> /// <param name="color">default color for the element</param> /// <param name="coordSystem">world / screen rendering method</param> public ILLabelingElement (ILPanel panel, Font font, Color color, CoordSystem coordSystem) { if (font != null) { m_font = font; } else { m_font = new System.Drawing.Font( System.Drawing.FontFamily.GenericSansSerif,10.0f); } m_color = color; m_orientation = TextOrientation.Horizontal; m_renderQueue = null; m_size = Size.Empty; m_expression = string.Empty; // init interpreter & renderer m_renderer = panel.TextRendererManager.GetDefault(coordSystem); m_renderer.CacheCleared += new EventHandler(m_renderer_CacheCleared); m_interpreter = new ILSimpleTexInterpreter(); }