private static void Draw(XGraphics g, IRenderableNet n, LayoutProvider layout, NetworkColorizer colorizer)
 {
     lock (n)
     {
         if (g == null)
             return;
         g.SmoothingMode = PdfSharp.Drawing.XSmoothingMode.HighQuality;
         g.Clear(Color.White);
         foreach (var e in n.GetEdgeArray())
             if (string.Compare(e.Item1, e.Item2) >= 0)
                 DrawEdge(g, e, layout, colorizer);
         foreach (string v in n.GetVertexArray())
             DrawVertex(g, v, layout, colorizer);
     }
 }
 private static void Draw(XGraphics g, IRenderableNet n, LayoutProvider layout, NetworkColorizer colorizer)
 {
     lock (n)
     {
         if (g == null)
         {
             return;
         }
         g.SmoothingMode = PdfSharp.Drawing.XSmoothingMode.HighQuality;
         g.Clear(Color.White);
         foreach (var e in n.GetEdgeArray())
         {
             if (string.Compare(e.Item1, e.Item2) >= 0)
             {
                 DrawEdge(g, e, layout, colorizer);
             }
         }
         foreach (string v in n.GetVertexArray())
         {
             DrawVertex(g, v, layout, colorizer);
         }
     }
 }
Example #3
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            // Create an identity matrix, apply orthogonal projection and viewport
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, Width, Height, 0, -1, 1);
            GL.Viewport(0, 0, Width, Height);

            // Apply the proper scaling
            Origin      = Renderer.ScreenToWorld(new Vector3(0, 0, 0));
            Bottomright = Renderer.ScreenToWorld(new Vector3(Renderer.RenderWidth, Renderer.RenderHeight, 0));

            // Apply panning and zooming state
            GL.Scale(_zoom, _zoom, _zoom);
            GL.Translate(_panningTranslationX + _panningDeltaX, _panningTranslationY + _panningdeltaY, 0);

            // Store matrices for unprojecting ...
            GL.GetDouble(GetPName.ModelviewMatrix, matView);
            GL.GetDouble(GetPName.ProjectionMatrix, matProj);
            GL.GetInteger(GetPName.Viewport, viewport);

            // Clear the buffer
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.ClearColor(_colorizer.DefaultBackgroundColor);

            foreach (string v in _network.GetVertexArray())
            {
                rendered[v] = false;
            }

            // Draw the edges
            foreach (var edge in _network.GetEdgeArray())
            {
                if (string.Compare(edge.Item1, edge.Item2) >= 0)
                {
                    DrawEdge(edge.Item1, edge.Item2, _colorizer[edge], ComputeEdgeThickness(edge));
                }
                else
                {
                    DrawEdge(edge.Item2, edge.Item1, _colorizer[edge], ComputeEdgeThickness(edge));
                }
            }

            if (SelectedVertex != null)
            {
                foreach (string w in this._network.GetSuccessorArray(SelectedVertex))
                {
                    DrawEdge(SelectedVertex, w, Color.Red, ComputeEdgeThickness(new Tuple <string, string>(SelectedVertex, w)), true);
                }
            }

            // Draw the vertices
            foreach (string v in _network.GetVertexArray())
            {
                DrawVertex(v, _colorizer[v], (int)(30 * _zoom), ComputeNodeSize(v));
            }

            if (SelectedVertex != null)
            {
                DrawVertex(SelectedVertex, Color.Red, (int)(10 * _zoom), ComputeNodeSize(SelectedVertex), true);
            }

            if (_drawMarker)
            {
                DrawMarker(Colorizer.DefaultSelectedVertexColor, 20, MarkerSize);
            }

            // Swap screen and backbuffer
            SwapBuffers();

            if (_grabbingFrame)
            {
                GrabImage();
            }
        }