Beispiel #1
0
        private void DrawMethod(CGNode node, ref Dictionary <CGNode, EllipseShape> visited)
        {
            ArrowShape arrow = null;
            // When autoSize is on the rectangle parameter will be 'ignored'.
            EllipseShape blockShape = new EllipseShape(new Rectangle(1, 1, 70, 70));

            blockShape.Title = String.Format("{0}", node.Method.Name);
            visited.Add(node, blockShape);
            scene.Shapes.Add(blockShape);

            ConnectorGluePoint gluePointStart = null;
            ConnectorGluePoint gluePointEnd   = null;

            foreach (CGNode child in node.MethodCalls)
            {
                DrawMethod(child, ref visited);
                gluePointStart = new ConnectorGluePoint(new PointD(visited[node].Location.X + visited[node].Width / 2, visited[node].Location.Y + visited[node].Height));
                gluePointEnd   = new ConnectorGluePoint(new PointD(visited[child].Location.X + visited[child].Width / 2, visited[child].Location.Y));

                arrow = new ArrowShape(visited[node], gluePointStart, visited[child], gluePointEnd);
                arrow.ArrowKindHead = SolidV.Cairo.ArrowKinds.TriangleRoundArrow;
                arrow.ArrowKindTail = SolidV.Cairo.ArrowKinds.NoArrow;

                gluePointEnd.Parent   = visited[child];
                gluePointStart.Parent = visited[node];

                scene.Shapes.Add(arrow);
                visited[node].Items.Add(gluePointStart);
                visited[child].Items.Add(gluePointEnd);
            }
        }
Beispiel #2
0
        public void DrawFilter()
        {
            List <ArrowShape> arrows = new List <ArrowShape>();

            int          x = 100, y = 300;
            EllipseShape filter = new EllipseShape(new Cairo.Rectangle(x, y, 100, 50));

            filter.Style.Border = new SolidPattern(new Color(0, 0, 0));

            ConnectorGluePoint filterGlue = new ConnectorGluePoint(
                new PointD(filter.Location.X + (filter.Width / 2), filter.Location.Y));

            filter.Items.Add(filterGlue);
            filterGlue.Parent = filter;

            for (int i = 0; i < scene.Shapes.Count; i++)
            {
                var block = scene.Shapes[i];
                ConnectorGluePoint blockGlue = new ConnectorGluePoint(new PointD(block.Location.X
                                                                                 + block.Width / 2, block.Location.Y + block.Height));
                blockGlue.Parent = block;
                // Add the gluePoints to the shapes
                block.Items.Add(blockGlue);

                // Link the filter and the textBlock with an arrow
                ArrowShape arrow = new ArrowShape(block, blockGlue, filter, filterGlue);
                arrows.Add(arrow);
            }

            model.BeginUpdate();
            // Add all shapes to the scene
            scene.Shapes.Add(filter);
            foreach (ArrowShape a in arrows)
            {
                scene.Shapes.Add(a);
            }

            model.EndUpdate();
        }
Beispiel #3
0
        private void DrawBasicBlock(BasicBlock <Instruction> basicBlock,
                                    ref Dictionary <BasicBlock <Instruction>, TextBlockShape> visited)
        {
            if (visited.ContainsKey(basicBlock))
            {
                return;
            }

            ArrowShape arrow     = null;
            string     labelText = "";
            // When autoSize is on the rectangle parameter will be 'ignored'.
            TextBlockShape blockShape = new TextBlockShape(new Rectangle(1, 1, 50, 50), /*autosize*/ true);

            blockShape.Title     = String.Format("Block Name: {0}", basicBlock.Name);
            blockShape.BlockText = basicBlock.ToString();
            visited.Add(basicBlock, blockShape);
            scene.Shapes.Add(blockShape);

            ConnectorGluePoint gluePointStart = null;
            ConnectorGluePoint gluePointEnd   = null;

            SolidV.MVC.Label lb = null;

            foreach (BasicBlock <Instruction> successor in basicBlock.Successors)
            {
                DrawBasicBlock(successor, ref visited);

                gluePointStart = new ConnectorGluePoint(new PointD(visited[basicBlock].Location.X + visited[basicBlock].Width / 2, visited[basicBlock].Location.Y + visited[basicBlock].Height));
                gluePointEnd   = new ConnectorGluePoint(new PointD(visited[successor].Location.X + visited[successor].Width / 2, visited[successor].Location.Y));

                //arrow = new ArrowShape(visited[basicBlock], gluePointStart, visited[successor], gluePointEnd);
                arrow = new BezierCurvedArrowShape(visited[basicBlock], gluePointStart, visited[successor], gluePointEnd);
                arrow.ArrowKindHead = SolidV.Cairo.ArrowKinds.TriangleRoundArrow;
                arrow.ArrowKindTail = SolidV.Cairo.ArrowKinds.NoArrow;

                gluePointEnd.Parent   = visited[successor];
                gluePointStart.Parent = visited[basicBlock];

                switch (basicBlock.Last.OpCode.FlowControl)
                {
                case FlowControl.Cond_Branch:
                    if ((basicBlock.Last.Operand as Instruction).Offset == successor.First.Offset)
                    {
                        labelText = "IfTrue";
                    }
                    else
                    {
                        labelText = "IfFalse";
                    }
                    break;

                default:
                    labelText = "branch";
                    break;
                }

                lb        = new SolidV.MVC.Label(arrow, labelText);
                lb.Parent = arrow;
                arrow.Items.Add(lb);

                blockShape.Items.Add(arrow);

                visited[basicBlock].Items.Add(gluePointStart);
                visited[successor].Items.Add(gluePointEnd);
            }
        }