예제 #1
0
        public void DrawGraph()
        {
            if (!_canvasReady)
            {
                return;
            }

            CanvasManager.SimpleShader2D.UseProgram();
            GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            GL.Viewport((int)CanvasManager.CanvasLocationX, (int)CanvasManager.CanvasLocationY, (int)CanvasManager.CanvasWidth, (int)CanvasManager.CanvasHeight);
            GL.Scissor((int)CanvasManager.CanvasLocationX, (int)CanvasManager.CanvasLocationY, (int)CanvasManager.CanvasWidth, (int)CanvasManager.CanvasHeight);
            GL.Enable(EnableCap.ScissorTest);

            var scale = new GraphScaleData(_scaleData);

            if (_transitionState == 1) //reposition
            {
                float factor = _transitionCounter / Interval;
                //x difference
                scale.XShift = _scaleData.XShift + (_transitionCanvas.ScaleData.XShift - _scaleData.XShift) * factor;
                //scale difference
                scale.BaseScale = _scaleData.BaseScale + (_transitionCanvas.ScaleData.BaseScale - _scaleData.BaseScale) * factor;
            }
            else if (_transitionState == 2)
            {
                scale.XShift    = _transitionCanvas.ScaleData.XShift;
                scale.BaseScale = _transitionCanvas.ScaleData.BaseScale;
            }
            else
            {
                scale.XShift    = _scaleData.XShift;
                scale.BaseScale = _scaleData.BaseScale;
            }

            if (_transitionState == 2) //blend colors
            {
                //DataVolume.AlphaBlend = 1 - _transitionCounter / Interval;
                //PacketCount.AlphaBlend = 1 - _transitionCounter / Interval;
                CanvasCollection.AlphaBlend(1 - _transitionCounter / Interval);
            }

            _background.Draw(scale.XShift);

            ////draw data volume
            //DataVolume.Draw(scale);
            ////draw packet count
            //PacketCount.Draw(scale);
            //
            CanvasCollection.DrawCollection(scale);

            if (_transitionState == 2)
            {
                //DataVolume.DrawBackBuffer(scale.BaseScale, _transitionCanvas.ScaleData.MaxData, scale.XShift);
                //PacketCount.DrawBackBuffer(scale.BaseScale, _transitionCanvas.ScaleData.MaxCount, scale.XShift);
                CanvasCollection.DrawCollectionBackBuffer(scale);
            }

            //////reset viewport
            GL.Viewport(0, 0, CanvasManager.ControlWidth, CanvasManager.ControlHeight);
            GL.Disable(EnableCap.ScissorTest);

            Matrix4 transform = CanvasManager.ViewportTransform;

            GL.UniformMatrix4(CanvasManager.SimpleShader2D.UniformTransform, false, ref transform);
            GL.Uniform4(CanvasManager.SimpleShader2D.UniformColor, Color4.Black);
            GL.LineWidth(2f);

            Border.BeginDraw();
            Border.Draw(BeginMode.LineLoop);
            Border.EndDraw();

            //transform.Invert();
            //float left = -(transform.M11 - transform.M41);
            //float right = transform.M11 + transform.M41;
            _yAxis.Draw(_scaleData.MaxData);
            _xAxis.Draw(scale.XShift, scale.BaseScale);
        }