public DiagramNode GetNode(DiagramContext context)
 {
     if (node == null) {
         node = context.FindNode (nodeId);
     }
     return node;
 }
 public override void OnDrag(DiagramContext context, Vector2 position)
 {
     anchor.relative = true;
     Vector2 delta = context.GetDragDelta ();
     anchor.position.x += delta.x;
     anchor.position.y += delta.y;
 }
    public override bool OnGUI(DiagramContext context)
    {
        Event e = Event.current;
        switch (e.type) {

        case EventType.KeyDown:
            {
                Debug.Log ("key down  " + e.keyCode);
            if(e.keyCode == KeyCode.Escape){
                Debug.Log  ("key down !!!! " + e.keyCode);
                context.editor.GetRoot().SetDefaultTool();
                context.editor.Repaint();

            }
                break;
            }
        case EventType.KeyUp:
            {
                break;
            }

        }

        return true;
    }
 public override DiagramElement HitTest(DiagramContext context, Vector2 position)
 {
     if (DiagramUtil.ExpandRect (GetRect (), 6, 6).Contains (position)) {
         return this;
     }
     return null;
 }
 public static void DeleteConnector(List <HierarchicalDetail> data)
 {
     foreach (HierarchicalDetail hdata in data)
     {
         HierarchicalDetail originalData = DiagramContext.HierarchicalDetails.Single(h => h.Name == hdata.Name);
         DiagramContext.HierarchicalDetails.DeleteOnSubmit(originalData);
         DiagramContext.SubmitChanges();
     }
 }
        /// <summary>
        /// Creates the join according to given definition.
        /// </summary>
        /// <param name="definition">The definition of join.</param>
        /// <param name="context">The context of <see cref="DiagramDefinition" /> where join will be displayed.</param>
        /// <returns>Join drawing.</returns>
        public override JoinDrawing CreateJoin(JoinDefinition definition, DiagramContext context)
        {
            if (_joinFactory == null)
            {
                return(null);
            }

            return(_joinFactory(definition));
        }
 public static void DeleteShape(List <HierarchicalData> data)
 {
     foreach (HierarchicalData hdata in data)
     {
         HierarchicalData originalData = DiagramContext.HierarchicalDatas.Single(h => h.Name == hdata.Name);
         DiagramContext.HierarchicalDatas.DeleteOnSubmit(originalData);
         DiagramContext.SubmitChanges();
     }
 }
 public static void UpdateConnector(List <HierarchicalDetail> data)
 {
     foreach (HierarchicalDetail hdata in data)
     {
         HierarchicalDetail originalData = DiagramContext.HierarchicalDetails.Single(h => h.Name == hdata.Name);
         originalData.SourceNode = hdata.SourceNode;
         originalData.TargetNode = hdata.TargetNode;
         DiagramContext.SubmitChanges();
     }
 }
 public virtual void Draw(DiagramContext context)
 {
     EdgeHandle[] handles = GetEdgeHandles ();
     for (int i = 0; i < handles.Length -1; i++) {
         EdgeHandle handle1 = handles [i];
         EdgeHandle handle2 = handles [i + 1];
         EdgeAdapter adapter = context.GetEdgeAdapter(typeId);
         drawLine (handle1.position, handle2.position, lineColor, false, adapter.GetSourceAnchorTexture(), adapter.GetTargetAnchorTexture());
     }
 }
 public static void UpdateShape(List <HierarchicalData> data)
 {
     foreach (HierarchicalData hdata in data)
     {
         HierarchicalData originalData = DiagramContext.HierarchicalDatas.Single(h => h.Name == hdata.Name);
         originalData.Description = hdata.Description;
         originalData.Color       = hdata.Color;
         DiagramContext.SubmitChanges();
     }
 }
 public override void OnDrag(DiagramContext context , Vector2 position)
 {
     Debug.Log(" OnDrag!!! ");
     Vector2 delta = context.GetDragDelta();
     foreach(DiagramElement element in context.GetSelection().GetElements()){
         if(element is DiagramNode){
             DiagramNode node = (DiagramNode)element;
             node.rect.x += delta.x;
             node.rect.y += delta.y;
         }
     }
 }
 public DiagramElement HitTest(DiagramContext context,Vector2 position)
 {
     //Debug.Log(" node log  " + position);
     if(rect.Contains(position)){
         return this;
     }
     NodeAdapter adapter = context.GetNodeAdapter(typeId);
     if(adapter.HitTest(this , context , position)){
         return this;
     }
     return null;
 }
    public virtual void Draw(DiagramContext context)
    {
        diagramName = GUI.TextField (diagramNameRect, diagramName);

        foreach (DiagramNode node in nodes) {
            node.DrawNode (context);
        }

        foreach (DiagramNode node in nodes) {
            node.DrawEdge (context);
        }
    }
 public DiagramElement HitTest(DiagramContext context, Vector2 position)
 {
     EdgeHandle[] handles = GetEdgeHandles ();
     TEMP_POSITIONS.Clear ();
     for (int i = 0; i < handles.Length; i++) {
         EdgeHandle handle1 = handles [i];
         TEMP_POSITIONS.Add (handle1.position);
     }
     if (DiagramUtil.ContainsEdge (TEMP_POSITIONS, position, 4)) {
         return this;
     }
     return null;
 }
    public override void OnDrag(DiagramContext context, Vector2 position)
    {
        int pos = nodeHandle.GetPosition ();
        Vector2 delta = context.GetDragDelta ();
        foreach (DiagramElement element in context.GetSelection().GetElements()) {
            if (element is DiagramNode) {
                DiagramNode node = (DiagramNode)element;
                Debug.Log( " resize delta !!! " + delta);
                Debug.Log( " resize !!! " + node.rect);
                switch (pos) {
                case NodeHandle.POS_TOP_LEFT:
                    {
                        Resize (ref node.rect,delta.x, delta.y, -delta.x, -delta.y);
                        break;
                    }
                case NodeHandle.POS_TOP:{
                        Resize (ref node.rect,0, delta.y, 0, -delta.y);
                        break;
                    }
                case NodeHandle.POS_TOP_RIGHT:{
                        Resize (ref node.rect, 0, delta.y , delta.x, -delta.y);
                        break;
                    }
                case NodeHandle.POS_LEFT:{
                        Resize (ref node.rect,delta.x, 0, -delta.x, 0);
                        break;
                    }
                case NodeHandle.POS_RIGHT:{
                    Resize (ref node.rect,0, 0, delta.x, 0);
                        break;
                    }
                case NodeHandle.POS_BOTTOM_LEFT:{
                    Resize (ref node.rect,delta.x, 0, -delta.x, delta.y);
                        break;
                    }
                case NodeHandle.POS_BOTTOM:{
                    Resize (ref node.rect,0, 0, 0, delta.y);
                        break;
                    }
                case NodeHandle.POS_BOTTOM_RIGHT:{
                    Resize (ref node.rect,0, 0, delta.x, delta.y);
                        break;
                    }

                }
            }
        }
    }
Exemple #16
0
        private DiagramContext getContext()
        {
            if (_context == null)
            {
                var testCanvas = new DiagramCanvas();
                var diagramDef = new DiagramDefinition(null);
                foreach (var item in _items.Values)
                {
                    diagramDef.DrawItem(item);
                }

                var provider = new DrawingProvider(testCanvas, new TestDrawingFactory());
                _context = provider.Display(diagramDef);

                testCanvas.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
                testCanvas.Arrange(new Rect(new Point(), testCanvas.DesiredSize));
            }

            return(_context);
        }
    public override void OnDrop(DiagramContext context, Vector2 position)
    {
        anchor.relative = false;
        DiagramNode targetNode = null;
        anchor.relativePosition = new Vector2(0.5f,0.5f);
        foreach (DiagramNode node in context.editor.GetRoot().nodes) {
            DiagramElement element = node.HitTest (context, position);
            if (element is DiagramNode) {
                targetNode = (DiagramNode)element;
            }
        }

        if (targetNode != null) {
            if (targetNode != anchor.GetNode (context)) {
                anchor.node = targetNode;
                anchor.nodeId = targetNode.uuid;
            }else{
                anchor.relativePosition.x = (position.x - targetNode.rect.x) /targetNode.rect.width;
                anchor.relativePosition.y = (position.y - targetNode.rect.y) /targetNode.rect.height;
                Debug.Log(anchor.relativePosition);
            }
        }
    }
 public virtual void Draw(DiagramContext context)
 {
 }
 public override DiagramTool GetTool(DiagramContext context)
 {
     return bar.GetActiveTool().GetTool ();
 }
    public void UpdateAnchor(DiagramContext context)
    {
        //
        Rect sourceRect = sourceAnchor.GetNode (context).rect;
        Rect targetRect = targetAnchor.GetNode (context).rect;

        Vector2 pointA = new Vector2 (sourceRect.x + sourceRect.width / 2, sourceRect.y + sourceRect.height / 2);
        Vector2 pointB = new Vector2 (targetRect.x + targetRect.width / 2, targetRect.y + targetRect.height / 2);

        bool source = false;
        bool target = false;
        if (sourceAnchor.relative) {
            //
        } else {
            if (sourceAnchor.relativePosition == EdgeAnchorHandle.CENTER) {
                sourceAnchor.position = GetAnchorPos (pointB, sourceRect, pointA);
            } else {
                //if (!((sourceAnchor.relativePosition.x == 1.0f || sourceAnchor.relativePosition.x == 0.0f) && (sourceAnchor.relativePosition.y == 1.0f || sourceAnchor.relativePosition.y == 0.0f))) {
                    source = true;
                //} else {
                //	float tempX = sourceRect.x + sourceRect.width * sourceAnchor.relativePosition.x;
                //	float tempY = sourceRect.y + sourceRect.height * sourceAnchor.relativePosition.y;
                //	sourceAnchor.position.x = tempX;
                //	sourceAnchor.position.y = tempY;
                //}
            }
        }

        if (targetAnchor.relative) {
            //
        } else {
            if (targetAnchor.relativePosition == EdgeAnchorHandle.CENTER) {
                targetAnchor.position = GetAnchorPos (pointA, targetRect, pointB);
            } else {
                //if (!((targetAnchor.relativePosition.x == 1.0f || targetAnchor.relativePosition.x == 0.0f) && (targetAnchor.relativePosition.y == 1.0f || targetAnchor.relativePosition.y == 0.0f))) {
                    target = true;
                //} else {
                //	targetAnchor.position.x = targetRect.x + targetRect.width * targetAnchor.relativePosition.x;
                //	targetAnchor.position.y = targetRect.y + targetRect.height * targetAnchor.relativePosition.y;
                //}
            }
        }

        Log(" source anchor = " + sourceAnchor.relativePosition);
        Log(" target anchor = " + targetAnchor.relativePosition);
        if (source || target) {
            if (source && target) {
                pointA = new Vector2 (sourceRect.x + sourceRect.width * sourceAnchor.relativePosition.x, sourceRect.y + sourceRect.height * sourceAnchor.relativePosition.y);
                pointB = new Vector2 (targetRect.x + targetRect.width * targetAnchor.relativePosition.x, targetRect.y + targetRect.height * targetAnchor.relativePosition.y);
            } else if (source && !target) {
                pointA = new Vector2 (sourceRect.x + sourceRect.width * sourceAnchor.relativePosition.x, sourceRect.y + sourceRect.height * sourceAnchor.relativePosition.y);
            } else if (!source && target) {
                pointB = new Vector2 (targetRect.x + targetRect.width * targetAnchor.relativePosition.x, targetRect.y + targetRect.height * targetAnchor.relativePosition.y);
            }
            if (source && target) {
                sourceAnchor.position = GetAnchorPos (pointB, sourceRect, pointA);
                targetAnchor.position = GetAnchorPos (pointA, targetRect, pointB);
            } else if (source && !target) {
                Log(" source ");
                sourceAnchor.position = GetAnchorPos (pointB, sourceRect, pointA);
            } else if (!source && target) {
                Log(" target ");
                targetAnchor.position = GetAnchorPos (pointA, targetRect, pointB);
            }
        }
        if(!sourceRect.Contains(pointA)){
            LogError(" source Error pointA ! ");
        }
        if(!sourceRect.Contains(sourceAnchor.position)){
            LogError(" source Error ! ");
        }
        if(!targetRect.Contains(targetAnchor.position)){
            LogError(" target Error ! ");
        }

        Log(" source anchor = " + sourceAnchor.position + "  sourceRect = "  + sourceRect);
        Log("  pointA = " + pointA + " " + sourceRect.Contains(pointA));
        Log(" target anchor = " + targetAnchor.position + "  targetRect = "  + targetRect);
        Log("  pointB = " + pointB + " " + targetRect.Contains(pointB));
    }
 public void Draw(DiagramContext context)
 {
     Vector2 positionTemp = new Vector2 ();
     positionTemp.x = position.x;
     positionTemp.y = position.y;
     DiagramToolElement activeTool = null;
     foreach (DiagramToolElement tool in tools) {
         tool.Draw (positionTemp);
         positionTemp.x += tool.rect.width;
     }
 }
    public override void Draw(DiagramContext context)
    {
        bar.Draw (context);

        base.Draw (context);
    }
 public virtual void DrawHandle(DiagramContext context)
 {
 }
 public virtual void DrawNode(DiagramNode node , DiagramContext context)
 {
 }
 public override void DrawHandle(DiagramContext context)
 {
     foreach(NodeHandle handle in  handles){
         handle.Draw(context);
     }
 }
 public virtual void DrawNode(DiagramContext context)
 {
     NodeAdapter adapter = context.GetNodeAdapter(typeId);
     adapter.DrawNode(this , context);
 }
 public virtual void OnDrag(DiagramContext context , Vector2 position)
 {
 }
 public virtual void DrawEdge(DiagramContext context)
 {
     foreach (DiagramEdge edge in edges) {
         edge.Draw (context);
     }
 }
 public abstract bool OnGUI(DiagramContext context);
 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 bool HitTest(DiagramNode node , DiagramContext context , Vector2 position)
 {
     return false;
 }
 public override void DrawHandle(DiagramContext context)
 {
     foreach (EdgeHandle handle in GetEdgeHandles()) {
         handle .Draw (context);
     }
 }
Exemple #33
0
 /// <summary>
 /// Creates the join according to given definition.
 /// </summary>
 /// <param name="definition">The definition of join.</param>
 /// <param name="context">The context of <see cref="DiagramDefinition" /> where join will be displayed.</param>
 /// <returns>Join drawing.</returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public override JoinDrawing CreateJoin(JoinDefinition definition, DiagramContext context)
 {
     throw new NotImplementedException();
 }
 public virtual DiagramElement HitTest(DiagramContext context , Vector2 position)
 {
     return this;
 }
 public DiagramEditorWindow()
 {
     diagramContext = new DiagramContext (this);
 }
    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);
                }
            }

        }
    }
Exemple #37
0
 public HMLService(DiagramContext context)
 {
     _context = context ?? throw new System.ArgumentNullException(nameof(context));
 }
 public override void Draw(DiagramContext context)
 {
 }
Exemple #39
0
 public override JoinDrawing CreateJoin(JoinDefinition definition, DiagramContext context)
 {
     return(new CompositionJoin(definition));
 }