Inheritance: DiagramSelectableElement
        /// <summary>
        /// Create a DiagramNode.
        /// </summary>
        private DiagramNode CreateNode(Person person, NodeType type, bool clickEvent, double scale)
        {
            DiagramNode node = CreateNode(person, type, clickEvent);

            node.Scale = scale;
            return(node);
        }
Exemple #2
0
        private Vector CalcRepulsionForce(DiagramNode a, DiagramNode b)
        {
            if (a == b)
            {
                return(new Vector(0, 0));
            }
            double distance = a.GetDistanceToNode(b); // ik vraag me af of GetDistanceToNode wel slim is om te gebruiken, forces zijn hier door discreet, want hij bepaalt
            // eerst bij elke hoek hij het dichtste bij is.


            //double distance = (a.Pos - b.Pos).Length;
            var proximity = Math.Max(distance, 1);

            // Onderstaande code stond eerst aan maar zorgt voor discrete overgangen, forces die ineens omflippen
            //if (proximity > GetDefaultRepulsionHorizon(a, b)) {
            //    return new Vector(0, 0);
            //}

            // Coulomb's Law: F = k(Qq/r^2)
            var force = -(GetRepulsionConstant(a, b) / Math.Pow(proximity, 2));
            //var angle = GetBearingAngle(a, b);

            //return new Vector(force * Math.Cos(angle), force * Math.Sin(angle));
            var vector = b.Pos - a.Pos;

            if (vector.Length > 0)
            {
                vector.Normalize();
            }

            force = Math.Min(1e4, Math.Max(-1e4, force));
            return(vector * force);
        }
Exemple #3
0
        /// <summary>
        /// Provides positions and dimensions of elements in a BPMN process diagram as
        /// provided by <seealso cref="RepositoryService.getProcessDiagram(string)"/>.
        /// </summary>
        /// <param name="bpmnModel">
        ///          BPMN 2.0 XML document </param>
        /// <param name="imageStream">
        ///          BPMN 2.0 diagram in PNG format (JPEG and other formats supported
        ///          by <seealso cref="ImageIO"/> may also work) </param>
        /// <returns> Layout of the process diagram </returns>
        /// <returns> null when parameter imageStream is null </returns>
        public virtual DiagramLayout getBpmnProcessDiagramLayout(Document bpmnModel, Stream imageStream)
        {
            if (imageStream == null)
            {
                return(null);
            }
            DiagramNode diagramBoundsXml = getDiagramBoundsFromBpmnDi(bpmnModel);
            DiagramNode diagramBoundsImage;

            if (isExportedFromAdonis50(bpmnModel))
            {
                int offsetTop    = 29; // Adonis header
                int offsetBottom = 61; // Adonis footer
                diagramBoundsImage = getDiagramBoundsFromImage(imageStream, offsetTop, offsetBottom);
            }
            else
            {
                diagramBoundsImage = getDiagramBoundsFromImage(imageStream);
            }

            IDictionary <string, DiagramNode> listOfBounds = new Dictionary <string, DiagramNode>();

            listOfBounds[diagramBoundsXml.Id] = diagramBoundsXml;
            //    listOfBounds.putAll(getElementBoundsFromBpmnDi(bpmnModel));
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            listOfBounds.putAll(fixFlowNodePositionsIfModelFromAdonis(bpmnModel, getElementBoundsFromBpmnDi(bpmnModel)));

            IDictionary <string, DiagramElement> listOfBoundsForImage = transformBoundsForImage(diagramBoundsImage, diagramBoundsXml, listOfBounds);

            return(new DiagramLayout(listOfBoundsForImage));
        }
Exemple #4
0
        public void OnGet()
        {
            var filePath = "Learning Outcomes.xlsx";
            var courses  = fileService.ReadCourses(filePath);

            var nodes = new List <DiagramNode>();

            foreach (var c in courses)
            {
                var node = new DiagramNode();
                node.Children = (from course in courses
                                 where course.Prerequisites.Contains(c.Name)
                                 select course.Name).ToArray();
                node.Annotations = new List <DiagramNodeAnnotation>();
                node.Annotations.Add(new DiagramNodeAnnotation()
                {
                    Content = c.Name
                });
                nodes.Add(node);
            }

            var connectors = new List <DiagramConnector>();

            //connectors.Add(new DiagramConnector() { Id="connector1", SourceID=})

            ViewData["Nodes"] = courses;

            ViewData["getNodeDefaults"]      = "getNodeDefaults";
            ViewData["getConnectorDefaults"] = "getConnectorDefaults";
        }
 public DiagramNode GetNode(DiagramContext context)
 {
     if (node == null) {
         node = context.FindNode (nodeId);
     }
     return node;
 }
Exemple #6
0
        public void RedrawOnTickSetBack()
        {
            // Add Input Node for DiagramNode with 3 Outputs.
            AnonymousNode sourceNode = new AnonymousNode(AnonNodeHelper.SourceNode, 3);

            Frame[] inputs = sourceNode.Process(null, 0);

            // Generate DiagramNode and add referencevideo.
            Node.Input reference = new Node.Input();
            reference.Source = sourceNode.Outputs[0];
            DiagramNode diaNode = new DiagramNode();

            diaNode.ReferenceVideo = reference;
            diaNode.Inputs.Add(reference);

            // Add other Outputs as Inputs to DiagramNode.
            Node.Input video = new Node.Input();
            video.Source = sourceNode.Outputs[1];
            diaNode.Inputs.Add(video);

            // Generate sample GraphType to DiagramGraph.
            DiagramGraph pixDiff = new DiagramGraph();

            pixDiff.Video = video;
            pixDiff.Type  = new PixelDiff();
            diaNode.Graphs.Add(pixDiff);

            diaNode.Process(inputs, 0);
            diaNode.Process(inputs, 1);
            Assert.Equal(diaNode.Graphs[0].Data.Count, 2);
            diaNode.Process(inputs, 0);
            Assert.Equal(diaNode.Graphs[0].Data.Count, 1);
        }
Exemple #7
0
        public void TestNoDrawingIfDiagramNodeNotEnabled()
        {
            // Add Input Node for DiagramNode with 3 Outputs.
            AnonymousNode sourceNode = new AnonymousNode(AnonNodeHelper.SourceNode, 3);

            Frame[] inputs = sourceNode.Process(null, 0);

            // Generate DiagramNode and add referencevideo.
            Node.Input reference = new Node.Input();
            reference.Source = sourceNode.Outputs[0];
            DiagramNode diaNode = new DiagramNode();

            diaNode.ReferenceVideo = reference;
            diaNode.Inputs.Add(reference);

            // Add other Outputs as Inputs to DiagramNode.
            Node.Input video = new Node.Input();
            video.Source = sourceNode.Outputs[1];
            diaNode.Inputs.Add(video);

            // Generate sample GraphType to DiagramGraph.
            DiagramGraph pixDiff = new DiagramGraph();

            pixDiff.Video = video;
            pixDiff.Type  = new PixelDiff();
            diaNode.Graphs.Add(pixDiff);

            diaNode.IsEnabled = false;

            diaNode.Process(inputs, 0);

            Assert.Empty(diaNode.Graphs[0].Data);
        }
Exemple #8
0
        protected internal virtual IDictionary <string, DiagramNode> getElementBoundsFromBpmnDi(Document bpmnModel)
        {
            IDictionary <string, DiagramNode> listOfBounds = new Dictionary <string, DiagramNode>();
            // iterate over all DI shapes
            NodeList shapes = bpmnModel.getElementsByTagNameNS(BpmnParser.BPMN_DI_NS, "BPMNShape");

            for (int i = 0; i < shapes.Length; i++)
            {
                Element shape         = (Element)shapes.item(i);
                string  bpmnElementId = shape.getAttribute("bpmnElement");
                // get bounds of shape
                NodeList childNodes = shape.ChildNodes;
                for (int j = 0; j < childNodes.Length; j++)
                {
                    Node childNode = childNodes.item(j);
                    if (childNode is Element && BpmnParser.BPMN_DC_NS.Equals(childNode.NamespaceURI) && "Bounds".Equals(childNode.LocalName))
                    {
                        DiagramNode bounds = parseBounds((Element)childNode);
                        bounds.Id = bpmnElementId;
                        listOfBounds[bpmnElementId] = bounds;
                        break;
                    }
                }
            }
            return(listOfBounds);
        }
    public ClassDiagramRoot()
    {
        bar = new DiagramToolBar ();
        bar.position.x = 6;
        bar.position.y = 60;
        bar.Add (new DiagramToolElement (bar, Config.TEX_TOOL_COMPOSITE, Config.TEX_TOOL_REFERENCE, new DiagramDefaultTool ()));
        bar.Add (new DiagramToolElement (bar, Config.TEX_TOOL_COMPOSITE, Config.TEX_TOOL_REFERENCE, new DiagramConnectTool ()));
        bar.Add (new DiagramToolElement (bar, Config.TEX_TOOL_COMPOSITE, Config.TEX_TOOL_REFERENCE, new DiagramConnectTool ()));
        bar.Add (new DiagramToolElement (bar, Config.TEX_TOOL_COMPOSITE, Config.TEX_TOOL_REFERENCE, new DiagramConnectTool ()));

        DiagramNode node1 = new DiagramNode ();
        node1.attributes.Add (new Attribute ());
        node1.attributes.Add (new Attribute ());
        node1.attributes.Add (new Attribute ());
        DiagramNode node2 = new DiagramNode ();
        DiagramNode node3 = new DiagramNode ();
        DiagramEdge edge1 = new DiagramEdge ();

        edge1.SetSource (node1);
        edge1.SetTarget (node2);

        node1.edges.Add (edge1);
        nodes.Add (node1);
        nodes.Add (node2);
        nodes.Add (node3);

        classes = new ClassNode [1];
        classes [0] = new ClassNode ();
        diagramName = "diagram name";
        types = new string[]{"int", "float", "string", "bool", "Color", "Vector2", "Vector3", "Vector4", "AnimationCurve","Rect", "Texture", "Texture2D", "Object"};
    }
        public async Task <IActionResult> PutDiagramNode(int id, DiagramNode diagramNode)
        {
            if (id != diagramNode.DiagramMemberId)
            {
                return(BadRequest());
            }

            _context.Entry(diagramNode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiagramNodeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #11
0
        internal override void ComputeCustom(DiagramNode node)
        {
            Diagram diagram       = node.Diagram;
            int     oldPixelIndex = diagram.currentPixelIndex;
            DiagramDerivativeDirection oldDirection = diagram.derivativeDirection;

            Value cubemapValue = node.argumentValues[0];
            Value heightValue  = node.argumentValues[1];

            diagram.currentPixelIndex  -= 10;
            diagram.derivativeDirection = DiagramDerivativeDirection.NegativeX;
            node.ComputeArgumentNodes();
            Vector3 x = cubemapValue.Vector3 * heightValue.Float;

            diagram.currentPixelIndex  -= 10;
            diagram.derivativeDirection = DiagramDerivativeDirection.PositiveX;
            node.ComputeArgumentNodes();
            x -= cubemapValue.Vector3 * heightValue.Float;

            diagram.currentPixelIndex  -= 10;
            diagram.derivativeDirection = DiagramDerivativeDirection.NegativeY;
            node.ComputeArgumentNodes();
            Vector3 y = cubemapValue.Vector3 * heightValue.Float;

            diagram.currentPixelIndex  -= 10;
            diagram.derivativeDirection = DiagramDerivativeDirection.PositiveY;
            node.ComputeArgumentNodes();
            y -= cubemapValue.Vector3 * heightValue.Float;

            node.computedValue.Vector3 = Vector3.Cross(y, x).normalized;

            diagram.currentPixelIndex   = oldPixelIndex;
            diagram.derivativeDirection = oldDirection;
        }
        private void ConnectToNearbyLink(DiagramNode node)
        {
            var outLink = diagram.Links.Where(l => l.Origin is DummyNode).OrderBy(l =>
                                                                                  MindFusion.Utilities.Distance(node.GetCenter(), l.StartPoint)).FirstOrDefault();

            if (outLink != null)
            {
                var distance = MindFusion.Utilities.Distance(node.GetCenter(), outLink.StartPoint);
                if (distance < 90)
                {
                    outLink.Origin = node;
                    outLink.Route();
                    return;
                }
            }

            var inLink = diagram.Links.Where(l => l.Destination is DummyNode).OrderBy(l =>
                                                                                      MindFusion.Utilities.Distance(node.GetCenter(), l.EndPoint)).FirstOrDefault();

            if (inLink != null)
            {
                var distance = MindFusion.Utilities.Distance(node.GetCenter(), inLink.EndPoint);
                if (distance < 90)
                {
                    inLink.Destination = node;
                    inLink.Route();
                    return;
                }
            }
        }
 public DiagramWindowNode(int index, DiagramNode node, SerializedProperty nodeSP, DiagramWindow window)
 {
     this.index             = index;
     this.node              = node;
     this.nodeSP            = nodeSP;
     this.window            = window;
     propertyNameLabelWidth = 0f;
     nodeNameLabelWidth     = GUI.skin.label.CalcSize(new GUIContent(node.Name)).x;
     nodeRect.width         = nodeNameLabelWidth;
     for (int i = 0, l = node.PropertyCount; i < l; i++)
     {
         float labelWidth = GUI.skin.label.CalcSize(new GUIContent(node.GetPropertyName(i))).x;
         if (labelWidth > nodeRect.width)
         {
             nodeRect.width = labelWidth;
         }
         if (labelWidth > propertyNameLabelWidth)
         {
             propertyNameLabelWidth = labelWidth;
         }
     }
     nodeRect.width += DOUBLE_PADDING;
     if (node.Function == null || node.Function.type != FunctionType.Input)
     {
         nodeRect.height = Mathf.Max(1, node.PropertyCount) * CONNECTOR_OFFSET_Y + 22f;
     }
     else
     {
         nodeRect.height = CONNECTOR_OFFSET_Y + 22f;
     }
     nodeRect.x = node.position.x;
     nodeRect.y = node.position.y;
 }
    public void AddNode()
    {
        DiagramNode newNode = new DiagramNode ();

        Rect newRect = new Rect (newNode.rect);
        List<DiagramNode> nodes = context.editor.GetRoot().nodes;
        int size = nodes.Count;
        if (0 < size) {
            while (true) {
                bool exist = false;
                foreach (DiagramNode c in nodes) {
                    if (c.rect.x == newRect.x && c.rect.y == newRect.y) {
                        exist = true;
                        break;
                    }
                }
                if (exist) {
                    newRect.x += 20;
                    newRect.y += 20;
                } else {
                    break;
                }
            }
        }
        newNode.rect = newRect;
        nodes.Add (newNode);
    }
Exemple #15
0
        private void AddNode(DiagramNode diagramNode)
        {
            ContentPresenter contentPresenter = new ContentPresenter();

            contentPresenter.Content = diagramNode;
            // ReSharper disable TooWideLocalVariableScope
            FrameworkElementFactory diagramNodeViewFactory = null;

            // ReSharper restore TooWideLocalVariableScope
            if (diagramNode is UmlDiagramClass)
            {
                diagramNodeViewFactory = new FrameworkElementFactory(typeof(UmlDiagramClassView));
            }
            else if (diagramNode is UmlDiagramNote)
            {
                diagramNodeViewFactory = new FrameworkElementFactory(typeof(UmlDiagramNoteView));
            }
            else if (diagramNode is UmlDiagramMethodNode)
            {
                diagramNodeViewFactory = new FrameworkElementFactory(typeof(UmlDiagramMethodNodeView));
            }
            if (diagramNodeViewFactory != null)
            {
                contentPresenter.ContentTemplate = new DataTemplate {
                    VisualTree = diagramNodeViewFactory
                };
                Children.Add(contentPresenter);
            }
        }
Exemple #16
0
        /// <summary>
        /// Animate the new person that was added to the diagram.
        /// </summary>
        private void AnimateNewPerson()
        {
            // The new person is optional, can be null.
            if (newPerson == null)
            {
                return;
            }

            // Get the UI element to animate.
            DiagramNode node = logic.GetDiagramNode(newPerson);

            if (node != null)
            {
                // Create the new person animation.
                DoubleAnimation anim = new DoubleAnimation(0, 1, App.GetAnimationDuration(Const.NewPersonAnimationDuration));

                // Animate the node.
                ScaleTransform transform = new ScaleTransform();
                transform.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
                transform.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
                node.RenderTransform = transform;
            }

            newPerson = null;
        }
Exemple #17
0
 private static double GetDefaultRepulsionHorizon(DiagramNode diagramNode1, DiagramNode diagramNode2)
 {
     if (diagramNode1 is UmlDiagramClass && diagramNode2 is UmlDiagramNote || diagramNode2 is UmlDiagramClass && diagramNode1 is UmlDiagramNote)
     {
         return(100.0);
     }
     return(200.0); //500
 }
Exemple #18
0
 private double GetRepulsionConstant(DiagramNode diagramNode1, DiagramNode diagramNode2)
 {
     if (diagramNode1 is UmlDiagramClass && diagramNode2 is UmlDiagramNote || diagramNode2 is UmlDiagramClass && diagramNode1 is UmlDiagramNote)
     {
         return(1e5);
     }
     return(repulsionForceSetting.ParameterValue);
 }
Exemple #19
0
 private void DrawTotalForce(DiagramNode node, DrawingContext dc, Pen pen)
 {
     //Vector3D force = new Vector3D(0,0,0);
     //foreach (var value in node.Forces.Values) {
     //    force += value;
     //}
     DrawForce(node, node.Force, dc, pen);
 }
 public void Remove(DiagramNode Node)
 {
     if (Context.Entry(Node).State == EntityState.Detached)
     {
         context.DiagramNodes.Attach(Node);
     }
     context.DiagramNodes.Remove(Node);
 }
Exemple #21
0
 private void diagram1_NodeClicked(object sender, NodeEventArgs e)
 {
     if (e.MouseButton == MouseButton.Right)
     {
         Point point = diagramView1.DocToClient((e.MousePosition));
         point.X = point.X + diagramView1.Bounds.X;
         contextMenuStrip1.Show(this, point);
         nod = e.Node;
     }
 }
        public BaseConnection(DiagramNode from, DiagramNode to)
            : base(null, null)
        {
            this.Source   = from;
            this.Target   = to;
            this.LineType = null;
            this.ZOrder   = ++GroupableNode.ZOrderCounter;

            RecalculateConnectionPosition(null, null);
        }
Exemple #23
0
        protected internal virtual DiagramNode parseBounds(Element boundsElement)
        {
            DiagramNode bounds = new DiagramNode();

            bounds.X      = Convert.ToDouble(boundsElement.getAttribute("x"));
            bounds.Y      = Convert.ToDouble(boundsElement.getAttribute("y"));
            bounds.Width  = Convert.ToDouble(boundsElement.getAttribute("width"));
            bounds.Height = Convert.ToDouble(boundsElement.getAttribute("height"));
            return(bounds);
        }
Exemple #24
0
        private void DrawForce(DiagramNode node, ForceType type, DrawingContext dc, Pen pen)
        {
            if (!node.Forces.ContainsKey(type))
            {
                return;
            }
            var force = node.Forces[type];

            DrawForce(node, force, dc, pen);
        }
 public void EnsureCode(IDocumentationBuilder _, DiagramNode codeFor, string description, string imageUrl, string filenameSearch, string codeSearch)
 {
     _.ShowTutorialStep(new TutorialStep(description,
                                         () => EnsureCodeInEditableFile(codeFor, filenameSearch, codeSearch)),
                        b =>
     {
         _.Paragraph(string.Format("Right-Click on the Node and choose Open->{0}", filenameSearch));
         _.ImageByUrl(imageUrl);
     });
 }
        public BaseConnection(DiagramNode from, DiagramNode to)
            : base(null, null)
        {
            this.Source = from;
            this.Target = to;
            this.LineType = null;
            this.ZOrder = ++GroupableNode.ZOrderCounter;

            RecalculateConnectionPosition(null, null);
        }
Exemple #27
0
            private IEnumerable <Tuple <string, string, string> > SortHierarchyLevels(IEnumerable <IDiagramNode> hierarchyLevelNodes)
            {
                List <Tuple <string, string, string> > list = new List <Tuple <string, string, string> >();

                foreach (IDiagramNode node in hierarchyLevelNodes)
                {
                    list.Add(new Tuple <string, string, string>(DiagramNode.GetTopAncestor(node).Text, node.ParentNode.Text, node.Text));
                }
                return(list);
            }
Exemple #28
0
        protected internal virtual DiagramNode ParseBounds(XmlElement boundsElement)
        {
            var bounds = new DiagramNode();

            bounds.X      = Convert.ToDouble(boundsElement.Attributes["x"]);
            bounds.Y      = Convert.ToDouble(boundsElement.Attributes["y"]);
            bounds.Width  = Convert.ToDouble(boundsElement.Attributes["width"]);
            bounds.Height = Convert.ToDouble(boundsElement.Attributes["height"]);
            return(bounds);
        }
Exemple #29
0
 void ModuleItemNode_Expanded(DiagramNode sender, RoutedEventArgs eventArguments)
 {
     try
     {
         MyScrollViewer.AutoScrollTarget = sender.Location;
     }
     catch (Exception ex)
     {
         ShowException(ex.Message);
     }
 }
Exemple #30
0
 protected override void UpdateForcesOverride(Diagram diagram, double contentWidth, double contentHeight)
 {
     foreach (var node1 in diagram.ForceAcceptingNodes)
     {
         DiagramNode tmpNode = node1;
         foreach (var node2 in diagram.ForceExertingNodes.Where(n => n != tmpNode))
         {
             node1.AddForce(ForceType.Repulsion, CalcRepulsionForce(node1, node2) * node1.ForceMultiplier * node2.ForceMultiplier);
         }
     }
 }
Exemple #31
0
 public Device FindDevice(DiagramNode node)
 {
     foreach (var item in AllDevice)
     {
         if (item.shapenode.Id == node.Id)
         {
             return(item);
         }
     }
     return(null);
 }
Exemple #32
0
        public static Node CreateNode(DiagramNode node)
        {
            Node newNode = new Node(node.Name);

            newNode.Attr.Shape     = _figureAdapter.Adapt(node.Type);
            newNode.Attr.FillColor = _colorAdapter.Adapt(node.FillColor);
            newNode.Attr.Color     = _colorAdapter.Adapt(node.DrawColor);
            newNode.LabelText      = node.Name;
            _graph.AddNode(newNode);
            return(newNode);
        }
Exemple #33
0
        DiagramNode _rightNode; //вершина по которой щелкнули правой кнопкой

        private void DdNodeClicked(object sender, NodeEventArgs e)
        {
            myContextMenu.IsEnabled  = false;
            myContextMenu.Visibility = Visibility.Collapsed;
            if (e.MouseButton == MouseButton.Right && CanEdit)
            {
                myContextMenu.Visibility = Visibility.Visible;
                myContextMenu.IsEnabled  = true;
                _rightNode = e.Node;
                myContextMenu.DataContext = MenuOptionsNode;
            }
        }
Exemple #34
0
        /// <summary>
        /// A node was clicked, make that node the primary node.
        /// </summary>
        private void OnNodeClick(object sender, RoutedEventArgs e)
        {
            // Get the node that was clicked.
            DiagramNode node = sender as DiagramNode;

            if (node != null)
            {
                // Make it the primary node. This raises the CurrentChanged
                // event, which repopulates the diagram.
                logic.Family.Current = node.Person;
            }
        }
        protected DiagramSelectionBorder CalculateNodeBorder(DiagramNode node)
        {
            var border = new DiagramSelectionBorder();

            var bounds = node.Bounds;

            border.ResizeInfos.Add(new ResizeInfo(bounds.TopLeft, ResizeDirection.DescendingTopLeft));
            border.ResizeInfos.Add(new ResizeInfo(new Point((bounds.Left + bounds.Right) / 2, bounds.Top), ResizeDirection.VerticalTop));
            border.ResizeInfos.Add(new ResizeInfo(bounds.TopRight, ResizeDirection.AscendingTopRight));
            border.ResizeInfos.Add(new ResizeInfo(new Point(bounds.Right, (bounds.Top + bounds.Bottom) / 2), ResizeDirection.HorizontalRight));
            border.ResizeInfos.Add(new ResizeInfo(bounds.BottomRight, ResizeDirection.DescendingBottomRight));
            border.ResizeInfos.Add(new ResizeInfo(new Point((bounds.Left + bounds.Right) / 2, bounds.Bottom), ResizeDirection.VerticalBottom));
            border.ResizeInfos.Add(new ResizeInfo(bounds.BottomLeft, ResizeDirection.AscendingBottomLeft));
            border.ResizeInfos.Add(new ResizeInfo(new Point(bounds.Left, (bounds.Top + bounds.Bottom) / 2), ResizeDirection.HorizontalLeft));

            return border;
        }
        protected override System.Windows.Media.Geometry CalculateNodeGeometry(DiagramNode node)
        {
            Rect rect = node.Bounds;
            List<Point> points  = new List<Point>();
            points.Add(new Point((rect.Left + rect.Right) / 2, rect.Top));
            points.Add(new Point(rect.Right, (rect.Top + rect.Bottom) / 2));
            points.Add(new Point((rect.Left + rect.Right) / 2, rect.Bottom));
            points.Add(new Point(rect.Left, (rect.Top + rect.Bottom) / 2));

            PathGeometry pathGeometry = new PathGeometry();

            PathFigure figure = new PathFigure();
            figure.IsClosed = true;
            figure.IsFilled = true;
            figure.StartPoint = points[0];
            for (int i = 1; i < 4; i++)
            {
                LineSegment lineSegment = new LineSegment(points[i], true);
                figure.Segments.Add(lineSegment);
            }
            pathGeometry.Figures.Add(figure);

            return pathGeometry;
        }
 public NodeHandle(DiagramNode node, int  position)
 {
     this.node = node;
     pos = position;
 }
        private void StartEdit(DiagramNode node)
        {
            Network network = _project.Network;
            if (network == null)
                return;

            NetworkNode netNode = network.Nodes.FindById(Int32.Parse(node.Uid));

            DiagramNodeEx nodeEx = new DiagramNodeEx(node, netNode);

            DiagramNetwork.BeginEdit(nodeEx);
        }
 protected abstract Geometry CalculateNodeGeometry(DiagramNode node);
 protected override Geometry CalculateNodeGeometry(DiagramNode node)
 {
     return new RectangleGeometry(node.Bounds, node.RadiusX, node.RadiusY);
 }
        public void StartEdit(DiagramNode node)
        {
            Network network = this.Network;
            if (network == null)
                return;

            NetworkNode netNode = network.Nodes.FindById(Int32.Parse(node.Uid));

            DiagramNodeEx nodeEx = new DiagramNodeEx(node, netNode);

            Diagram.BeginEdit(nodeEx);
        }
Exemple #42
0
		public void TestDiagramNode()
		{
			// Add Input Node for DiagramNode with 3 Outputs.
			AnonymousNode sourceNode = new AnonymousNode(AnonNodeHelper.SourceNode, 3);
			Frame[] inputs = sourceNode.Process(null, 0);

			// Generate DiagramNode and add referencevideo.
			Node.Input reference = new Node.Input();
			reference.Source = sourceNode.Outputs[0];
			DiagramNode diaNode = new DiagramNode();
			diaNode.ReferenceVideo = reference;
			diaNode.Inputs.Add(reference);

			// Add other Outputs as Inputs to DiagramNode.
			Node.Input video = new Node.Input();
			video.Source = sourceNode.Outputs[1];
			diaNode.Inputs.Add(video);
			Node.Input annVid = new Node.Input();
			annVid.Source = sourceNode.Outputs[2];
			diaNode.Inputs.Add(annVid);

			// Generate and add all GraphTypes to DiagramGraph once.
			DiagramGraph pixDiff = new DiagramGraph();
			pixDiff.Video = video;
			pixDiff.Type = new PixelDiff();
			DiagramGraph pseudoNoiseRatio = new DiagramGraph();
			pseudoNoiseRatio.Video = video;
			pseudoNoiseRatio.Type = new PeakSignalNoiseRatio();
			DiagramGraph inBlFreq = new DiagramGraph();
			inBlFreq.Video = annVid;
			inBlFreq.Type = new IntraBlockFrequency();
			DiagramGraph decDiff = new DiagramGraph();
			decDiff.Video = annVid;
			decDiff.Type = new DecisionDiff();
			DiagramGraph art = new DiagramGraph();
			art.Video = video;
			art.Type = new Artifacts();
			diaNode.Graphs.Add(pixDiff);
			diaNode.Graphs.Add(pseudoNoiseRatio);
			diaNode.Graphs.Add(inBlFreq);
			diaNode.Graphs.Add(decDiff);
			diaNode.Graphs.Add(art);
			diaNode.Process(inputs, 0);

			// Calculate expected results independently from DiagramGraph methods.
			double mse = 0.0;
			double pixDifference = 0.0;
			double intrablocks = 0.0;
			double artifacts = 0.0;
			for (int x = 0; x < inputs[0].Size.Width; x++) {
				for (int y = 0; y < inputs[0].Size.Height; y++) {
					pixDifference += Math.Abs(inputs[0][x, y].R - inputs[1][x, y].R) + Math.Abs(inputs[0][x, y].G - inputs[1][x, y].G) + Math.Abs(inputs[0][x, y].B - inputs[1][x, y].B);
					mse += Math.Pow(((inputs[0][x, y].R + inputs[0][x, y].G + inputs[0][x, y].B) - (inputs[1][x, y].R +
						inputs[1][x, y].G + inputs[1][x, y].B)), 2);
					var difference = Math.Abs(inputs[0][x, y].R - inputs[1].GetPixelOrBlack(x, y).R);
					difference += Math.Abs(inputs[0][x, y].G - inputs[1].GetPixelOrBlack(x, y).G);
					difference += Math.Abs(inputs[0][x, y].B - inputs[1].GetPixelOrBlack(x, y).B);
					if (difference >= 40)
						artifacts += 1;
				}
			}

			foreach (MacroblockDecision d in ((AnnotatedFrame)inputs[2]).Decisions)
			{
				if (d.PartitioningDecision == MacroblockPartitioning.Intra16x16 | d.PartitioningDecision == MacroblockPartitioning.Intra4x4 | d.PartitioningDecision == MacroblockPartitioning.Intra8x8 | d.PartitioningDecision == MacroblockPartitioning.IntraPCM) {
					intrablocks++;
				}
			}

			double decDifference = 0.0;
			if (((AnnotatedFrame)inputs[0]) is AnnotatedFrame && ((AnnotatedFrame)inputs[2]) is AnnotatedFrame && ((AnnotatedFrame)inputs[0]).Size.Height == ((AnnotatedFrame)inputs[2]).Size.Height
				&& ((AnnotatedFrame)inputs[0]).Size.Width == ((AnnotatedFrame)inputs[2]).Size.Width) {
				AnnotatedFrame annFrame = ((AnnotatedFrame)inputs[0]);
				AnnotatedFrame annRef = ((AnnotatedFrame)inputs[2]);
				for (int i = 0; i < annFrame.Decisions.GetLength(0); i++) {
					for (int j = 0; j < annFrame.Decisions.GetLength(1); j++) {
						if (annFrame.Decisions[i, j].PartitioningDecision == annRef.Decisions[i, j].PartitioningDecision)
							decDifference++;
					}
				}
				decDifference /= annFrame.Decisions.Length;
				decDifference *= 100;
			}
			intrablocks = 100 * intrablocks / ((AnnotatedFrame) inputs[2]).Decisions.Length;
			pixDifference = 100 * pixDifference / (765 * inputs[0].Size.Height * inputs[0].Size.Width);
			mse *= (double)1 / (3 * inputs[1].Size.Height * inputs[1].Size.Width);
			double psnr;
			if (mse == 0.0)
				psnr = 0.0;
			psnr = 10 * Math.Log10((Math.Pow((Math.Pow(2, 24) - 1), 2)) / mse);
			artifacts = 100 * artifacts / (inputs[0].Size.Height * inputs[0].Size.Width);
			Assert.Equal(pixDifference, diaNode.Graphs[0].Data[0].Value);
			Assert.Equal(psnr, diaNode.Graphs[1].Data[0].Value);
			Assert.Equal(intrablocks, diaNode.Graphs[2].Data[0].Value, 7);
			Assert.Equal(decDifference, diaNode.Graphs[3].Data[0].Value, 7);
			Assert.Equal(artifacts, diaNode.Graphs[4].Data[0].Value, 7);
		}
 public void AddAttribute(DiagramNode node)
 {
     Attribute attribute = new Attribute ();
     node.attributes.Add(attribute );
 }
 public void SetTarget(DiagramNode node)
 {
     EdgeAnchorHandle handle = new EdgeAnchorHandle ();
     handle.nodeId = node.uuid;
     targetAnchor = handle;
     targetAnchor.node = node;
 }
 protected override System.Windows.Media.Geometry CalculateNodeGeometry(DiagramNode node)
 {
     return new EllipseGeometry(node.Bounds);
 }
        //public IShape CalculateShape(DiagramItem item)
        //{
        //    var label = item as DiagramLabel;
        //    if (label == null)
        //        throw new DiagramException("Тип объекта не соответствует типу отрисовщика!");
        //    return CalculateLabelShape(label);
        //}
        //protected IShape CalculateLabelShape(DiagramLabel label)
        //{
        //    FontFamily = label.FontFamily;
        //    FontSize = label.FontSize;
        //    FontStretch = label.FontStretch;
        //    FontStyle = label.FontStyle;
        //    FontWeight = label.FontWeight;
        //    Foreground = label.Foreground;
        //    var node = label.Owner as DiagramNode;
        //    if (node != null)
        //    {
        //        return CalculateLabelOnNode(label, node);
        //    }
        //    var edge = label.Owner as DiagramEdge;
        //    if (edge != null)
        //    {
        //        return CalculateLabelOnEdge(label, edge);
        //    }
        //    return null;
        //}
        protected virtual Geometry CalculateLabelOnNode(DiagramLabel label, DiagramNode node)
        {
            var textSize = GetTextSize(label.Text);
            var nodeRect = node.Bounds;
            var origin = new Point((nodeRect.Right + nodeRect.Left) / 2, (nodeRect.Bottom + nodeRect.Top) / 2);
            origin.Offset(label.RelativePosition.X, label.RelativePosition.Y);

            origin.Offset(-textSize.Width / 2, -textSize.Height / 2);

            return new RectangleGeometry(new Rect(origin.X, origin.Y, textSize.Width,
                textSize.Height));
        }
 public MessageConnection(DiagramNode from, DiagramNode to)
     : base(from, to)
 {
 }
 public EventConnection(DiagramNode from, DiagramNode to)
     : base(from, to)
 {
 }
Exemple #49
0
		public void RedrawOnTickSetBack()
		{
			// Add Input Node for DiagramNode with 3 Outputs.
			AnonymousNode sourceNode = new AnonymousNode(AnonNodeHelper.SourceNode, 3);
			Frame[] inputs = sourceNode.Process(null, 0);

			// Generate DiagramNode and add referencevideo.
			Node.Input reference = new Node.Input();
			reference.Source = sourceNode.Outputs[0];
			DiagramNode diaNode = new DiagramNode();
			diaNode.ReferenceVideo = reference;
			diaNode.Inputs.Add(reference);

			// Add other Outputs as Inputs to DiagramNode.
			Node.Input video = new Node.Input();
			video.Source = sourceNode.Outputs[1];
			diaNode.Inputs.Add(video);

			// Generate sample GraphType to DiagramGraph.
			DiagramGraph pixDiff = new DiagramGraph();
			pixDiff.Video = video;
			pixDiff.Type = new PixelDiff();
			diaNode.Graphs.Add(pixDiff);

			diaNode.Process(inputs, 0);
			diaNode.Process(inputs, 1);
			Assert.Equal(diaNode.Graphs[0].Data.Count, 2);
			diaNode.Process(inputs, 0);
			Assert.Equal(diaNode.Graphs[0].Data.Count, 1);
		}
Exemple #50
0
		public void TestNoDrawingIfDiagramNodeNotEnabled()
		{
			// Add Input Node for DiagramNode with 3 Outputs.
			AnonymousNode sourceNode = new AnonymousNode(AnonNodeHelper.SourceNode, 3);
			Frame[] inputs = sourceNode.Process(null, 0);

			// Generate DiagramNode and add referencevideo.
			Node.Input reference = new Node.Input();
			reference.Source = sourceNode.Outputs[0];
			DiagramNode diaNode = new DiagramNode();
			diaNode.ReferenceVideo = reference;
			diaNode.Inputs.Add(reference);

			// Add other Outputs as Inputs to DiagramNode.
			Node.Input video = new Node.Input();
			video.Source = sourceNode.Outputs[1];
			diaNode.Inputs.Add(video);

			// Generate sample GraphType to DiagramGraph.
			DiagramGraph pixDiff = new DiagramGraph();
			pixDiff.Video = video;
			pixDiff.Type = new PixelDiff();
			diaNode.Graphs.Add(pixDiff);

			diaNode.IsEnabled = false;

			diaNode.Process(inputs, 0);

			Assert.Empty(diaNode.Graphs[0].Data);
		}
 public override bool HitTest(DiagramNode node , DiagramContext context , Vector2 position)
 {
     bool selected = context.GetSelection().GetElements().Contains(node);
     if(selected){
     TEMP =  DiagramUtil.TranslateRect(addAttributeToolRect , node.rect.x , node.rect.y );
         if(TEMP.Contains(position)){
             return true;
         }
     }
     return false;
 }
 public virtual void DrawNode(DiagramNode node , DiagramContext context)
 {
 }
    public override void DrawNode(DiagramNode node ,DiagramContext context)
    {
        bool selected = context.GetSelection().GetElements().Contains(node);
        GUI.Box (node.rect, "");

        if(selected){

            GUIStyle style = new GUIStyle (GUIStyle.none);
            style.normal.background = Config.TEX_ADD;

            TEMP =  DiagramUtil.TranslateRect(addAttributeToolRect , node.rect.x , node.rect.y );
            if (GUI.Button (TEMP, "", style)) {
                context.GetCommand().AddAttribute(node);
            }

        }

        TEMP =  DiagramUtil.TranslateRect(iconRect , node.rect.x , node.rect.y );

        if (node.iconPath != null) {
            node.texIcon = Config.loadTexture (node.iconPath);
        }
        if (node.texIcon == null) {
            node.texIcon = Config.TEX_NO_IMAGE;
        }

        node.iconStyle.normal.background = node.texIcon;
        if (GUI.Button (TEMP, "", node.iconStyle)) {
            string path = EditorUtility.OpenFilePanel ("Select Icon", "Assets", "");
            if (path != null) {
                if (Application.dataPath.Length < path.Length) {
                    path = path.Substring (Application.dataPath.Length);
                    char[] chTrims = {'/', '\\'};
                    path = path.TrimStart (chTrims);
                    node.iconPath = path;
                }
            }
        }

        TEMP = DiagramUtil.TranslateRect( new  Rect (iconRect.x + iconRect.width + 10, iconRect.y + 8, node.rect.width - (iconRect.x + iconRect.width + 8) - 20, 16) , node.rect.x , node.rect.y);
        if (selected) {
            node.name = GUI.TextField (TEMP, node.name);
        } else {
            GUI.Label (TEMP, node.name);
        }

        for (int index = 0; index < node.attributes.Count; index++) {
            Attribute attr = (Attribute)node.attributes[index];
            float nwidth = 50;
            float twidth = 90;
            float y = 60 + 18 * index;

            Rect irect =new Rect (12, y, 16, 16);
            Rect nrect = new Rect (irect.x + irect.width + 4, y, nwidth, 16);
            Rect crect = new Rect (nrect.x + nwidth, y, 8, 16);
            Rect trect = new Rect (crect.x + crect.width - 10, y, twidth, 16);

            Texture2D texIcon = null;
            string attrIconPath = attr.iconPath;
            if (attrIconPath != null) {
                texIcon = Config.loadTexture (attrIconPath);
            }
            if (texIcon == null) {
                texIcon = Config.TEX_NO_IMAGE_16;
            }
            GUIStyle attrIconStyle = new GUIStyle (GUIStyle.none);
            attrIconStyle.normal.background = texIcon;

            TEMP = DiagramUtil.TranslateRect( irect,node.rect.x , node.rect.y);
            if (GUI.Button (TEMP, "", attrIconStyle)) {
                string path = EditorUtility.OpenFilePanel ("Select Icon", "Assets", "");
                if (path != null) {
                    if (Application.dataPath.Length < path.Length) {
                        path = path.Substring (Application.dataPath.Length);
                        char[] chTrims = {'/', '\\'};
                        path = path.TrimStart (chTrims);
                        attr.iconPath = path;
                    }
                }
            }

            if (selected) {
                TEMP = DiagramUtil.TranslateRect( nrect,node.rect.x , node.rect.y);
                attr.name = GUI.TextField (TEMP, attr.name);
                TEMP = DiagramUtil.TranslateRect( crect,node.rect.x , node.rect.y);
                GUI.Label (TEMP, ":");
                TEMP = DiagramUtil.TranslateRect( trect,node.rect.x , node.rect.y);
                attr.type = DrawTypeField (TEMP, attr.type);
            } else {
                TEMP = DiagramUtil.TranslateRect( nrect,node.rect.x , node.rect.y);
                GUI.Label (TEMP, attr.name);
                TEMP = DiagramUtil.TranslateRect( crect,node.rect.x , node.rect.y);
                GUI.Label (TEMP, ":");
                TEMP = DiagramUtil.TranslateRect( trect,node.rect.x , node.rect.y);
                DrawTypeField (TEMP, attr.type);
                //GUI.Label (trect, attr.type);
            }

            if (selected) {

                GUIStyle style = new GUIStyle (GUIStyle.none);
                style.normal.background = Config.TEX_TOOL_REMOVE_MINI;
                TEMP = DiagramUtil.TranslateRect(new Rect (trect.x + trect.width - 4, y, 13, 16),node.rect.x , node.rect.y);
                if (GUI.Button (TEMP, "", style)) {
                    node.attributes.Remove (attr);
                }
            }

        }
    }
 public DiagramNodeEx(DiagramNode _node, NetworkNode _netNode)
 {
     DiagramNode = _node;
     NetworkNode = _netNode;
 }
 public void DeleteNode(DiagramNode node)
 {
     context.editor.GetRoot ().nodes.Remove (node);
     context.GetSelection ().RemoveElement (node);
 }
 public virtual bool HitTest(DiagramNode node , DiagramContext context , Vector2 position)
 {
     return false;
 }
 public void SetSource(DiagramNode node)
 {
     EdgeAnchorHandle handle = new EdgeAnchorHandle ();
     handle.nodeId = node.uuid;
     sourceAnchor = handle;
     sourceAnchor.node = node;
 }
 public CommandConnection(DiagramNode from, DiagramNode to)
     : base(from, to)
 {
 }