public static IVertex NewEdge(IVertex baseVertex, IVertex inputVertex) { NewEdge d = new NewEdge(baseVertex.Get("To:")); MinusZero.Instance.DefaultShow.ShowContentFloating(d); return(null); }
public bool registerEdge(NewEdge edge, Transform endTr, Transform connectionModule) { if (isAlreadyExistEdge(endTr)) { return(false); } else { edge_outputModule.Add(edge, new KeyValuePair <Transform, Transform>(endTr, connectionModule)); return(true); } }
protected override void OnAfterRender(bool firstRender) { if (firstRender) { Listener.OnResized += WindowResized; } if (Choice != NavChoice.Insert && (GraphMode == GraphMode.InsertNode || GraphMode == GraphMode.InsertEdge)) { GraphMode = GraphMode.Default; NewEdge = new NewEdge(); StateHasChanged(); } }
public virtual void MoveBegin() { currentEdge = Instantiate(edgePrefab).GetComponent <NewEdge>(); edges.Add(currentEdge); currentEdge.SetStartTarget(this); currentEdge.SetEndTarget(GameObject.Find("Controller").transform); //Ordering SpriteRenderer edgePointRenderer = GetComponentInChildren <SpriteRenderer>(); string sortingLayerName = edgePointRenderer.sortingLayerName; int sortingOrder = edgePointRenderer.sortingOrder; currentEdge.SetOrdering(sortingLayerName, sortingOrder); }
void MovableNodeHighlightingAtMouseCursor() { Vector3 worldMousePos = nodeCamera.ScreenToWorldPoint(Input.mousePosition); Collider2D[] overlapColls = Physics2D.OverlapPointAll(worldMousePos); Collider2D target = null; //ArrowInput,ArrowOutput 우선처리, 없다면 가장 마지막의 것을 채택 foreach (Collider2D coll in overlapColls) { NewEdge newEdge = coll.GetComponent <NewEdge>(); if (newEdge != null) { target = coll; break; } IMovable movableCode = coll.GetComponent <IMovable>(); if (movableCode != null) { target = coll; break; } } if (target == null) { frameHighlighting.gameObject.SetActive(false); } else { NewEdge isEdge = target.GetComponent <NewEdge>(); if (isEdge == null) { frameHighlighting.gameObject.SetActive(true); frameHighlighting.targetTr = target.transform; } //연결중인 엣지는 하이리팅하지않음. else if (!isEdge.endTarget.Equals(transform)) { isEdge.Highlighting(); } } }
public virtual void CreateEdge(Transform targetTr) { currentEdge = Instantiate(edgePrefab).GetComponent <NewEdge>(); if (EdgeManager.instance.registerEdge(currentEdge, targetTr, transform)) { IInputParam <T> targetInputModule = targetTr.GetComponent <IInputParam <T> >(); edges.Add(currentEdge); connectedInputModules.Add(targetInputModule); currentEdge.SetStartTarget(this); currentEdge.SetEndTarget(targetTr); //Ordering SpriteRenderer edgePointRenderer = GetComponentInChildren <SpriteRenderer>(); string sortingLayerName = edgePointRenderer.sortingLayerName; int sortingOrder = edgePointRenderer.sortingOrder; currentEdge.SetOrdering(sortingLayerName, sortingOrder); } else { Debug.LogWarning("Edge Register Failed : " + name + " -> " + targetTr.gameObject.name); Destroy(currentEdge.gameObject); } }
// Constructors // public MainViewModel(IWindowManager windowManager, IDialogsPresenter dialogsPresenter) { Document = new GraphDocument(); Algorithms = AlgorithmProvider.Instance.Algorithms; _repository = new GraphRepository(); _cursorModeManager = new CursorModeManager(); _zoomManager = new ZoomManager(); _eventWaiter = new AutoResetEvent(false); TableRows = new ObservableCollection <TableRow>(); WindowManager = windowManager; DialogPresenter = dialogsPresenter; MinElementX = 30; MinElementY = 30; IsNewEdgeEnabled = true; NewEdge = new NewEdge(new Vertex(0, 0), 0, 0); Init(); }
public void removeEdge(NewEdge edge, Transform endTr) { edge_outputModule[edge].Value.SendMessage("RemoveEdge", endTr); edge_outputModule.Remove(edge); Destroy(edge.gameObject); }
public void GraphModeChanged(GraphMode mode) { GraphMode = mode; NewEdge = new NewEdge(); StartAlgorithm = new StartAlgorithm(); }
void ProcessRightMouseClick() { //우클릭 시작 if (Input.GetMouseButtonDown(1)) { isGetTool = false; ResetMultySelectSystems(); boxLeftTopPos = nodeCamera.ScreenToWorldPoint(Input.mousePosition); Rclicked = true; //엣지 끊기 touchPos = nodeCamera.ScreenToWorldPoint(Input.mousePosition); Collider2D[] temps = Physics2D.OverlapPointAll(touchPos); foreach (Collider2D temp in temps) { NewEdge edgeComponent = temp.GetComponent <NewEdge>(); //엣지이면서 타겟이 마우스가 아닐때(아직 마우스로 연결중이면 무시) if (edgeComponent != null && !edgeComponent.endTarget.Equals(transform)) { EdgeManager.instance.removeEdge(edgeComponent, edgeComponent.endTarget); } } } if (Input.GetMouseButton(1)) { //크기조절 float xSize, ySize; Vector3 v3 = nodeCamera.ScreenToWorldPoint(Input.mousePosition); xSize = v3.x - boxLeftTopPos.x; ySize = v3.y - boxLeftTopPos.y; SelectBoxTr.localScale = new Vector3(xSize * 0.5f, ySize * 0.5f, 1); Vector3 boxOffset = boxLeftTopPos - transform.position; SelectBoxTr.localPosition = new Vector3(boxOffset.x, boxOffset.y, 0); //LockField가 있으면 빨간색으로 표시해줌 Collider2D[] colls = Physics2D.OverlapAreaAll(SelectBoxTr.position, SelectBoxTr.position + SelectBoxTr.lossyScale * 2); int i; for (i = 0; i < colls.Length; ++i) { if (colls[i].CompareTag("LockField")) { SelectBoxRenderer.color = new Color(1, 0, 0, 0.5f); break; } } if (i == colls.Length) { SelectBoxRenderer.color = new Color(1, 1, 1, 0.5f); } } if (Input.GetMouseButtonUp(1)) { Collider2D[] colls = Physics2D.OverlapAreaAll(SelectBoxTr.position, SelectBoxTr.position + SelectBoxTr.lossyScale * 2); //LockField가 껴있는지 체크 int i; for (i = 0; i < colls.Length; ++i) { if (colls[i].CompareTag("LockField")) { SelectBoxRenderer.color = new Color(1, 0, 0, 0.5f); break; } } if (i == colls.Length) { //콜라이더들 중 Movable인터페이스를 구현한 게임오브젝트 숫자를 구함 int movableCount = 0; foreach (Collider2D coll in colls) { IMovable temp = coll.GetComponent <IMovable>(); if (temp != null) { movableCount++; } } selectedObjects = new GameObject[movableCount]; moveIcons = new GameObject[movableCount]; int objectIdx = 0; foreach (Collider2D coll in colls) { IMovable temp = coll.GetComponent <IMovable>(); if (temp != null) { selectedObjects[objectIdx] = coll.gameObject; moveIcons[objectIdx] = Instantiate(movableIconObj, coll.transform.position - new Vector3(0, 0, 1), Quaternion.identity); moveIcons[objectIdx].transform.SetParent(coll.transform); objectIdx++; } } SelectBoxRenderer.color = new Color(1, 0, 0, 0.5f); } SelectBoxTr.localScale = new Vector3(0, 0, 1); Rclicked = false; } }
public virtual void MoveEnd(Vector2 pos, bool bGroup = false) { if (bGroup) { return; } bool bFoundInputModule = false; //colls에서 InputNode를 찾았는지 체크 Collider2D[] colls; colls = Physics2D.OverlapCircleAll(pos, autoAssignRadius); if (colls.Length > 0) { int min_dist_idx = -1; for (int i = 0; i < colls.Length; ++i) { Collider2D coll = colls[i]; if (coll.CompareTag("InputNode")) { //아직 최저가 결정되지 않았거나 최저보다 더 적을 때 갱신 if (min_dist_idx == -1 || Vector3.Distance(coll.transform.position, pos) < Vector3.Distance(colls[min_dist_idx].transform.position, pos)) { min_dist_idx = i; } } } if (min_dist_idx != -1) { IInputParam <T> nearestInputModule = colls[min_dist_idx].GetComponent <IInputParam <T> >(); if (nearestInputModule != null) { bool bExist = false; foreach (IInputParam <T> target in connectedInputModules) { if (target.Equals(nearestInputModule)) { bExist = true; break; } } if (!bExist) { if (EdgeManager.instance.registerEdge(currentEdge, colls[min_dist_idx].transform, transform)) { connectedInputModules.Add(nearestInputModule); currentEdge.SetEndTarget(colls[min_dist_idx].transform); Debug.Log(colls[min_dist_idx].gameObject.name + " connected"); bFoundInputModule = true; } else { Debug.LogWarning("Edge Register Failed : " + name + " -> " + colls[min_dist_idx].gameObject.name); } } } } } if (!bFoundInputModule) { edges.Remove(currentEdge); Destroy(currentEdge.gameObject); currentEdge = null; } isMoving = false; }