Beispiel #1
0
        private void TransitionTimerTick(object sender, EventArgs e)
        {
            _transitionCounter += _transitionTimer.Interval;
            if (_transitionCounter >= Interval)
            {
                _transitionCounter = 0;
                _transitionState++;
                if (_transitionState == 2)
                {
                    _xAxis.Generate(_transitionCanvas);
                    _yAxis.GenerateAxis(_transitionCanvas.ScaleData.MaxData);
                }
                if (_transitionState == 3)
                {
                    //reset timer info
                    _transitionTimer.Stop();

                    //switch canvas data
                    _canvasData       = _transitionCanvas;
                    _scaleData        = _canvasData.ScaleData;
                    _transitionCanvas = null;

                    ////swap buffers in graphs
                    CanvasCollection.SwapBuffers();
                    ////reset alpha blend
                    CanvasCollection.AlphaBlend(1f);
                    _transitionState = 0;
                    ShowUI();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initialises the capture graph with the default graph collection
        /// </summary>
        public void Initialise()
        {
            //clear the canvas collection and crreate default graphs
            CanvasCollection.Clear();
            DataVolume = new GraphCanvas("Traffic Volume", CanvasManager.SimpleShader2D)
            {
                Color = Color4.Firebrick
            };
            PacketCount = new GraphCanvas("Packet Count", CanvasManager.SimpleShader2D)
            {
                Color = Color4.DarkSlateBlue
            };

            MatchingCounts.Clear();

            var colors = FilterColors(CanvasManager.FileManager.CountCache.FilterFiles.Count);

            for (int k = 0; k < CanvasManager.FileManager.CountCache.FilterFiles.Count; k++)
            {
                var    filter = CanvasManager.FileManager.CountCache.FilterFiles[k];
                string name   = filter.Filename;
                name = name.Substring(name.LastIndexOf('\\') + 1, name.LastIndexOf('.') - name.LastIndexOf('\\') - 1);
                MatchingCounts.Add(new GraphCanvas(name, CanvasManager.SimpleShader2D)
                {
                    Color         = colors[k],
                    ScaleFunction = new GraphScaleConfig(GraphScaleFunction.Maximum, GraphScaleTarget.PacketCount),
                    GraphType     = GraphType.SolidGraph
                });
            }

            //set the shaders for the axis and background ui
            _yAxis      = new GraphYAxis(CanvasManager.SimpleShader2D);
            _background = new GraphBackground(CanvasManager.SimpleShader2D);
            _xAxis      = new GraphXAxis(CanvasManager.SimpleShader2D);

            //initialise the border
            Border = new GLSLVertexBuffer <Vector2>();
            Border.SetAttributeInfo(CanvasManager.SimpleShader2D.AttributeCoord2D, 2);

            //set the default graph types
            DataVolume.GraphType  = GraphType.LineGraph;
            PacketCount.GraphType = GraphType.SolidGraph;

            //sett eh default grraph scale funtions
            DataVolume.ScaleFunction  = new GraphScaleConfig(GraphScaleFunction.Maximum, GraphScaleTarget.DataVolume);
            PacketCount.ScaleFunction = new GraphScaleConfig(GraphScaleFunction.Maximum, GraphScaleTarget.PacketCount);

            //add the default graphs to the canvas collection
            CanvasCollection.Add(PacketCount);

            foreach (GraphCanvas canvas in MatchingCounts)
            {
                CanvasCollection.Add(canvas);
            }

            CanvasCollection.Add(DataVolume);
        }
Beispiel #3
0
        /// <summary>
        /// Constructs an uninitialised CaptureGraph object, which can display multiple graph canvases simultaneously
        /// </summary>
        public CaptureGraph()
        {
            _canvasReady     = false;
            _transitionState = 0;

            //set graph start offsets
            _positionOffset = new Vector2(-1, -1);

            //initialise timer
            _transitionTimer          = new Timer();
            _transitionTimer.Interval = 40;
            _transitionTimer.Tick    += TransitionTimerTick;

            //construct empty canvas collection
            CanvasCollection = new CanvasCollection();
            MatchingCounts   = new List <GraphCanvas>();
        }
Beispiel #4
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);
        }