public void Draw(float xShift)
        {
            if (!Enabled)
            {
                return;
            }

            Matrix4 tmp = Matrix4.CreateTranslation(xShift, 0, 0) *
                          Matrix4.Scale(2f / CanvasManager.CurrentCanvasData.ScaleData.BaseScale, 1, 1) *
                          Matrix4.CreateTranslation(-1, 0, 0);
            Matrix4 transform;

            GL.Uniform4(_uniformColor, SelectionColor);

            //Draw Marks
            foreach (var mark in MarkList.Marks)
            {
                transform = mark.InitialTransform * tmp;
                GL.UniformMatrix4(_uniformTransform, false, ref transform);

                _selectionBlock.BeginDraw();
                _selectionBlock.Draw(BeginMode.TriangleStrip);
                _selectionBlock.EndDraw();
            }

            transform = _initialTransform * tmp;

            GL.UniformMatrix4(_uniformTransform, false, ref transform);
            GL.Uniform4(_uniformColor, SelectorColor);

            _selectionBlock.BeginDraw();
            _selectionBlock.Draw(BeginMode.TriangleStrip);
            _selectionBlock.EndDraw();
        }
        public void DrawBackBuffer(GraphScaleData scaleData)
        {
            if (Hide || _backData == null)
            {
                return;
            }
            float height = ScaleFunction.ScaledHeight(scaleData);

            Matrix4 transform = Matrix4.CreateTranslation(scaleData.XShift, 0, 0) * Matrix4.Scale(2 / scaleData.BaseScale, 2 / height, 1) * Matrix4.CreateTranslation(-1, -1, 0);

            GL.UniformMatrix4(_shaderProgram.UniformTransform, false, ref transform);

            if (_drawMode == BeginMode.Lines || _drawMode == BeginMode.LineLoop || _drawMode == BeginMode.LineStrip)
            {
                GL.LineWidth(2f);
            }
            else if (_drawMode == BeginMode.Points)
            {
                GL.PointSize(2f);
            }

            if (_alphaBlend > 0)
            {
                Color4 col = Color;
                col.A = 1 - _alphaBlend;
                GL.Uniform4(_shaderProgram.UniformColor, col);
            }
            else
            {
                GL.Uniform4(_shaderProgram.UniformColor, Color);
            }

            if (_graphType == GraphType.SolidGraph)
            {
                _backBuffer.SetAttributeInfo(_shaderProgram.AttributeCoord2D, 2);

                _backBuffer.BeginDraw();
                _backBuffer.Draw(_drawMode);
                _backBuffer.EndDraw();

                _backBuffer.SetAttributeInfo(_shaderProgram.AttributeCoord2D, 2, false, 2 * Vector2.SizeInBytes);
                GL.Uniform4(_shaderProgram.UniformColor, Color4.Black);
                GL.LineWidth(1f);

                _backBuffer.BeginDraw();
                _backBuffer.Draw(BeginMode.LineStrip, _backData.Length / 2);
                _backBuffer.EndDraw();
            }
            else
            {
                _backBuffer.BeginDraw();
                _backBuffer.Draw(_drawMode, _backData.Length / 2);
                _backBuffer.EndDraw();
            }
        }
Exemple #3
0
        public void Draw(float xShift, float baseScale)
        {
            GL.Enable(EnableCap.ScissorTest);
            GL.Scissor((int)(CanvasManager.CanvasLocationX - 1), 0,
                       (int)(CanvasManager.CanvasWidth + 2),
                       CanvasManager.ControlHeight);

            double  scale     = 2.0 / (double)baseScale;
            Matrix4 transform = Matrix4.CreateTranslation(xShift, 0, 0) * Matrix4.Scale((float)scale /*2f / baseScale*/, 1f, 1f) * Matrix4.CreateTranslation(-1f, -1f, 0) * CanvasManager.ViewportTransform;

            GL.UniformMatrix4(_uniformTransform, false, ref transform);
            GL.Uniform4(_uniformColor, GridColor);

            if (DrawMajorGridlines)
            {
                GL.LineWidth(1.25f);
                _gridMajorBuffer.BeginDraw();
                _gridMajorBuffer.Draw(BeginMode.Lines);
                _gridMajorBuffer.EndDraw();
            }
            if (DrawMinorGridlines && _minorGrid != null)
            {
                GL.LineWidth(0.75f);
                _gridMinorBuffer.BeginDraw();
                _gridMinorBuffer.Draw(BeginMode.Lines);
                _gridMinorBuffer.EndDraw();
            }

            if (_majorTick != null)
            {
                GL.LineWidth(2f);
                GL.Uniform4(_uniformColor, TickColor);

                _tickMajorBuffer.BeginDraw();
                _tickMajorBuffer.Draw(BeginMode.Lines);
                _tickMajorBuffer.EndDraw();
            }

            if (DrawMinorTicks && _minorTick != null)
            {
                //transform = Matrix4.Scale(1, MinorTickScale, 1) * transform; //shift x down for ticks
                GL.UniformMatrix4(_uniformTransform, false, ref transform);

                GL.LineWidth(1.5f);
                _tickMinorBuffer.BeginDraw();
                _tickMinorBuffer.Draw(BeginMode.Lines);
                _tickMinorBuffer.EndDraw();
            }
            GL.Disable(EnableCap.ScissorTest);
        }