예제 #1
0
        static public void Show(GraphBox p_region)
        {
            RuntimeGenericMenu menu = new RuntimeGenericMenu();

            menu.AddItem(new GUIContent("Delete Box"), false, DeleteBox, p_region);

            //menu.ShowAsContext();
            GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 200, 300, false, false);
        }
예제 #2
0
        public virtual void AddEdge(RGEdge edge, string parent)
        {
            allEdges.Add(edge);
            var graph = GetGraphBox(parent);

            if (graph == null)
            {
                graph = new GraphBox(parent);
                graphBoxs.Add(graph);
            }
            //graph.AddEdge(edge);
        }
예제 #3
0
파일: GraphView.cs 프로젝트: pshtif/Dash
        void ProcessRightClick(Event p_event, Rect p_rect)
        {
            if (p_event.button != 1)
            {
                return;
            }

            if (p_event.type == EventType.MouseUp)
            {
                if (!_rightDrag)
                {
                    NodeBase hitNode = Graph.HitsNode(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));
                    if (hitNode != null)
                    {
                        NodeContextMenu.Show(hitNode);
                    }
                    else
                    {
                        NodeConnection hitConnection = Graph.HitsConnection(
                            p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y),
                            12);

                        if (hitConnection != null)
                        {
                            ConnectionContextMenu.Show(hitConnection);
                        }
                        else
                        {
                            GraphBox hitRegion =
                                Graph.HitsBoxDrag(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));

                            if (hitRegion != null)
                            {
                                BoxContextMenu.Show(hitRegion);
                            }
                            else
                            {
                                CreateNodeContextMenu.ShowAsPopup();
                            }
                        }
                    }
                }
                else
                {
                    _rightDrag = false;
                }

                p_event.Use();

                DashEditorWindow.SetDirty(true);
            }
        }
예제 #4
0
        public virtual void AddNode(RGNode node, string parent, bool add)
        {
            if (add)
            {
                node.Data.mass = 1.0f;
                allNodes.Add(node);
            }

            var graph = GetGraphBox(parent);

            if (graph == null)
            {
                graph = new GraphBox(parent);
                graphBoxs.Add(graph);
            }
            //graph.AddNode(node);
        }
예제 #5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Counter++;
            if (Counter > 100)
            {
                Setup();
                Counter = 0;
            }
            ;
            if (graphics == null)
            {
                graphics = GraphBox.CreateGraphics();
            }


            GraphBox.Refresh();
            //GraphBox.Update();
        }
예제 #6
0
 // Update is called once per frame
 void FixedUpdate()
 {
     input = manager.GetProbeCell();
     if (input == null || input.occupant == null)
     {
         return;
     }
     points.Add(input.occupant.GetFrameOutput(manager.frame - 1));       //get value from source
     if (points.Count > 100)
     {
         points.RemoveAt(0);
     }
     SpriteRenderer[] s = GraphBox.GetComponentsInChildren <SpriteRenderer> ();
     for (int i = 0; i < s.Length; i++)
     {
         GameObject obj = s[i].gameObject;
         if (obj != GraphBox)
         {
             Destroy(obj);
         }
     }
     DisplayPlot();
 }
예제 #7
0
 // отрисовка графика
 private void BuildGraph_Click(object sender, EventArgs e)
 {
     GraphBox.Image = null;
     GraphBox.Update();
     RenderGraph.DrawingGraph(GraphBox, first.amplitude.sumOfAmplitude, first.amplitude.sizeMas, Pens.Red);
 }
예제 #8
0
파일: GraphView.cs 프로젝트: pshtif/Dash
        void ProcessLeftClick(Event p_event, Rect p_rect)
        {
            if (p_event.button != 0)
            {
                return;
            }

            if (p_event.type == EventType.MouseDown)
            {
                GUI.FocusControl("");
            }

            // Select
            if (p_event.type == EventType.MouseDown && !p_event.alt && Graph != null && !p_event.control)
            {
                DashEditorWindow.SetDirty(true);

                NodeBase hitNode      = Graph.HitsNode(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));
                int      hitNodeIndex = Graph.Nodes.IndexOf(hitNode);

                if (!SelectionManager.IsSelected(hitNodeIndex) && (!p_event.shift || hitNodeIndex == 0))
                {
                    SelectionManager.ClearSelection();
                }

                if (hitNodeIndex >= 0)
                {
                    AddSelectedNode(hitNodeIndex);

                    dragging = DraggingType.NODE_DRAG;
                }
                else
                {
                    GraphBox box = Graph.HitsBoxDrag(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));

                    if (box != null)
                    {
                        DashEditorCore.selectedBox = box;
                        DashEditorCore.selectedBox.StartDrag();
                        dragging = DraggingType.BOX_DRAG;
                    }
                    else
                    {
                        box = Graph.HitsBoxResize(p_event.mousePosition * Zoom - new Vector2(p_rect.x, p_rect.y));

                        if (box != null)
                        {
                            DashEditorCore.selectedBox = box;
                            DashEditorCore.selectedBox.StartResize();
                            dragging = DraggingType.BOX_RESIZE;
                        }
                        else
                        {
                            dragging = DraggingType.SELECTION;
                            DashEditorCore.selectedBox = null;
                            Graph.connectingNode       = null;
                            selectedRegion             = new Rect(p_event.mousePosition.x, p_event.mousePosition.y, 0, 0);
                        }
                    }
                }
            }

            // Dragging
            if (p_event.type == EventType.MouseDrag)
            {
                switch (dragging)
                {
                case DraggingType.NODE_DRAG:
                    Vector2 delta = p_event.alt ? Snapping.Snap(p_event.delta, new Vector2(10, 10)): p_event.delta;
                    SelectionManager.DragSelectedNodes(delta, Graph);
                    break;

                case DraggingType.BOX_DRAG:
                    DashEditorCore.selectedBox.Drag(new Vector2(p_event.delta.x * Zoom, p_event.delta.y * Zoom));
                    break;

                case DraggingType.BOX_RESIZE:
                    DashEditorCore.selectedBox.Resize(new Vector2(p_event.delta.x * Zoom, p_event.delta.y * Zoom));
                    break;

                case DraggingType.SELECTION:
                    selectedRegion.width  += p_event.delta.x;
                    selectedRegion.height += p_event.delta.y;
                    Rect fixedRect = FixRect(selectedRegion);
                    SelectionManager.SelectingNodes(Graph.Nodes.FindAll(n => n.IsInsideRect(fixedRect)).Select(n => n.Index).ToList());
                    break;
                }

                DashEditorWindow.SetDirty(true);
            }

            if (p_event.type == EventType.MouseUp)
            {
                if (dragging == DraggingType.SELECTION)
                {
                    SelectionManager.SelectingToSelected();
                }

                if (dragging == DraggingType.NODE_DRAG || dragging == DraggingType.BOX_DRAG || dragging == DraggingType.BOX_RESIZE)
                {
                    DashEditorCore.SetDirty();
                }

                dragging       = DraggingType.NONE;
                selectedRegion = Rect.zero;
                DashEditorWindow.SetDirty(true);
            }
        }
예제 #9
0
        private void UptateValues(object sender, PropertyChangedEventArgs e)
        {
            InvokeUI(() =>
            {
                switch (e.PropertyName)
                {
                case "Halted":
                    SetStartHaltButton(F.Halted);
                    D.SmokeStackClosed = false;
                    break;

                case "Start":
                    SetStartHaltButton(F.Halted);
                    D.Start = DateTime.Now;
                    break;

                case "StartTime":
                    L.Add($"Start Time: [{F.StartTime}]");
                    break;

                case "CloseSmokeAlert":
                    D.SmokeStackClosed = true;
                    string msg         = "Please close smokestack!";
                    L.Add(msg);
                    MessageBox.Show(msg, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;

                case "Status":
                    UpdateStatus();
                    break;

                case "Temperature":
                    D.CurrentTemperature = F.Temperature;
                    if (F.ProgramCounter > -1)
                    {
                        D.Measurements.Add(new Measurement(F.Temperature, DateTime.Now));
                    }
                    break;

                case "ProgramCounter":
                    D.ProgramCounter = F.ProgramCounter;
                    L.Add($"Current Block: {F.ProgramCounter}");
                    break;

                case "Heating":
                    D.Heatings.Add(new Heating(F.Heating, DateTime.Now));
                    L.Add($"Heating: {F.Heating}");
                    break;

                case "Program":
                    D.Plan = F.Program;
                    L.Add($"Program set to: [{F.Program.Name}]");
                    break;

                default:
                    L.Add($"Not Implemented Event: [{e.PropertyName}]");
                    break;
                }
                GraphBox.Invalidate();
            });
        }
예제 #10
0
 private void UpdateImageNow(object sender, EventArgs e)
 {
     GraphBox.Invalidate();
 }
예제 #11
0
 // Use this for initialization
 void Start()
 {
     GraphExtents = new Vector2(GraphBox.GetComponent <SpriteRenderer>().sprite.bounds.extents.x, GraphBox.GetComponent <SpriteRenderer>().sprite.bounds.extents.y);
 }