public override void DuplicateRow(GraphElement selectedElement, SortableExpandableRow insertTargetElement, bool insertAtEnd) { var insertCriteriaModelRow = insertTargetElement as CriteriaModelRow; var insertCriteriaSubSection = insertTargetElement as CriteriaSubSection; if (!(selectedElement is CriteriaModelRow criteriaModelRow) || insertCriteriaModelRow == null && insertCriteriaSubSection == null) { m_ParentElement.SetDragIndicatorVisible(false); return; } if (insertCriteriaModelRow != null) { var targetCriteriaModel = insertCriteriaModelRow.CriteriaModel; if (targetCriteriaModel == null) { return; } Store.Dispatch(new DuplicateCriteriaModelAction((ICriteriaModelContainer)criteriaModelRow.GraphElementModel, criteriaModelRow.CriteriaModel, (ICriteriaModelContainer)insertCriteriaModelRow.GraphElementModel, targetCriteriaModel, insertAtEnd)); return; } var criteriaModel = criteriaModelRow.CriteriaModel; Store.Dispatch(new DuplicateCriteriaModelAction((ICriteriaModelContainer)criteriaModelRow.GraphElementModel, criteriaModel, (ICriteriaModelContainer)insertCriteriaSubSection.GraphElementModel, targetCriteriaModel: null, insertAtEnd: true)); }
/// <summary> /// Updates the stroke flag in the simulation graphical layer (updates the function and current element if they were different from the function parameters) /// </summary> /// <param name="function"></param> /// <param name="element"></param> /// <returns></returns> private void UpdateTrace(GraphDiagram function, GraphElement element) { //The item to be noted is updated if it is not the same as the current if (this.presentElement != element) { this.presentElement = element; } //The stroke is placed on the current element if ((this.presentElement is GraphStart) || (this.presentElement is GraphFinish)) { this.graphTrace.Position = new Point(this.presentElement.Position.X - 12, this.presentElement.Position.Y + 3); } else if (this.presentElement is GraphModule) { this.graphTrace.Position = new Point(this.presentElement.Position.X - 14, this.presentElement.Position.Y + 9); } else if (this.presentElement is GraphConditional) { this.graphTrace.Position = new Point(this.presentElement.Position.X - 6, this.presentElement.Position.Y + 19); } else { throw new SimulatorException("Ningún otro elemento puede ser apuntado por la flecha"); } //Update the simulation layer of the current function if (this.presentFunction != function) { this.presentFunction.SimulatorLayer.Remove(this.graphTrace); this.presentFunction.SimulatorLayer.UpdateSurface(); this.presentFunction = function; this.presentFunction.SimulatorLayer.Add(this.graphTrace); } this.presentFunction.SimulatorLayer.UpdateSurface(); }
protected GraphSetting graphSetting; // 绘图参数配置对象 /// <summary> /// 构造函数 /// </summary> /// <param name="owner">注释所属的图元</param> /// <param name="location">图元的位置</param> /// <param name="elementSize">图元的大小</param> public RemarkGraphElement(GraphElement owner, Point location, Size elementSize) : base(location) { this.owner = owner; this.location = location; this.elementSize = elementSize; }
/// <summary> /// 执行命令 /// </summary> /// <param name="o">命令的参数</param> /// <returns>是否执行成功</returns> public override bool Execute(object o) { bool success = true; // 保存命令执行前的数据 if (firstCommand) // 只有第一条命令保存执行前的数据 { SaveBeforeExecute(flowChartManager.GetArguments()); } Hashtable dataTable = new Hashtable(); if (graphManager.SelectedGraphElementList.Count > 0) // 复制多个图元 { foreach (GraphElement graphElement in graphManager.SelectedGraphElementList) { dataTable[graphElement] = dataManager.GetData(graphElement); } } else // 复制单个图元 { GraphElement graphElement = graphManager.SelectedGraphElement; dataTable[graphElement] = dataManager.GetData(graphElement); } documentManager.CopyTable = CopyGraphElement(dataTable); if (success) // 保存命令执行后的数据 { SaveAfterExecute(flowChartManager.GetArguments()); } return(success); }
/// <summary> /// 获取连入的图元链表 /// </summary> /// <param name="graphElement">当前图元</param> /// <returns>连入的图元链表</returns> public List <GraphElement> GetPreviousGraphElements(GraphElement graphElement) { List <GraphElement> list = new List <GraphElement>(); if (graphElement is SlotContainer) // 当前图元是插槽容器 { SlotContainer slotContaienr = graphElement as SlotContainer; foreach (SlotGraphElement slot in slotContaienr.GetInSlotList()) { if (slot.Binded) { list.Add(slot.BindingConnector.Line); } } } else if (graphElement is ConnectorContainer) // 当前图元是连接线控制点容器 { ConnectorContainer line = graphElement as ConnectorContainer; if (line.InSlotContainer != null) { list.Add(line.InSlotContainer); } } return(list); }
// Use this for initialization void Start() { graphs = new GraphElement[MAX_NUMBER_GRAPHS]; graphPrefab = new GameObject[MAX_NUMBER_GRAPHS]; data = (Resources.Load("data") as TextAsset).text.Split('\n'); for (int graph = 0; graph < MAX_NUMBER_GRAPHS; graph++) { // position += MAX_NUMBER_GRAPHS/1920; graphs[graph] = new GraphElement(getNameOf(graph), graph); graphPrefab[graph] = Instantiate(graphTemplate) as GameObject; graphPrefab[graph].GetComponent <Transform> ().parent = GameObject.Find("Canvas").GetComponent <Transform> (); graphPrefab[graph].GetComponent <RectTransform> ().position = new Vector2(graphs[graph].positionX, graphs[graph].positionY); graphPrefab[graph].GetComponent <NodeManager> ().points = new GameObject[GraphingManager.MAX_NUMBER_POINTS]; graphPrefab[graph].GetComponent <NodeManager> ().lines = new GameObject[GraphingManager.MAX_NUMBER_POINTS - 1]; for (int point = 0; point < MAX_NUMBER_POINTS; point++) { GameObject pointCopy = Instantiate(pointTemplate) as GameObject; pointCopy.GetComponent <Transform> ().parent = graphPrefab[graph].GetComponent <Transform> (); graphPrefab[graph].GetComponent <NodeManager> ().points[point] = pointCopy; } for (int point = 0; point < MAX_NUMBER_POINTS - 1; point++) { GameObject lineCopy = Instantiate(lineTemplate) as GameObject; lineCopy.GetComponent <Transform> ().parent = graphPrefab[graph].GetComponent <Transform> (); graphPrefab[graph].GetComponent <NodeManager> ().lines[point] = lineCopy; } } }
public void RestoreSelectionForElement(GraphElement element) { var editorDataModel = Store.GetState().EditorDataModel; // Select upon creation... if (element is IHasGraphElementModel hasElementGraphModel && editorDataModel.ShouldSelectElementUponCreation(hasElementGraphModel)) { element.Select(GraphView, true); } // ...or regular selection // TODO: This bypasses the problems with selection in GraphView when selection contains // non layered elements (like Blackboard fields for example) { if (!GraphView.PersistentSelectionContainsElement(element) || GraphView.selection.Contains(element) && element.selected) { return; } element.selected = true; if (!GraphView.selection.Contains(element)) { selection.Add(element); } element.OnSelected(); // To ensure that the selected GraphElement gets unselected if it is removed from the GraphView. element.RegisterCallback <DetachFromPanelEvent>(OnSelectedElementDetachedFromPanel); element.MarkDirtyRepaint(); } }
void UpdatePropertyGridBinding() { if (editView.SelectedObjects.Count == 1) { GraphElement element = editView.SelectedObjects[0]; puzzlePropertyGrid.SelectedObject = element; puzzlePropertyGrid.ExpandAllGridItems(); } else { if (editView.ColorPaintingMode) { puzzlePropertyGrid.SelectedObject = editView.PaintingModeControl; } else if (editView.SampleDecorator != null) { puzzlePropertyGrid.SelectedObject = editView.SampleDecorator; } else { puzzlePropertyGrid.SelectedObject = editView.Graph.MetaData; } } if (puzzlePropertyGrid.SelectedObject is null) { puzzlePropertyLabel.Text = Resources.Lang.NoPropertyShown; } else { puzzlePropertyLabel.Text = Resources.Lang.ResourceManager.GetString(puzzlePropertyGrid.SelectedObject.GetType().Name) ?? puzzlePropertyGrid.SelectedObject.ToString(); } UpdateDecoratorPreview(true); }
public static void Serialize <T, TGraphView>(this GraphElement graphElement, T serializedGraphElement, TGraphView graphView) where T : ISerializedGraphElement where TGraphView : GraphView, IGraphViewCallback { if (serializedGraphElement == null) { throw new ArgumentNullException(nameof(serializedGraphElement)); } if (graphView == null) { throw new ArgumentNullException(nameof(graphView)); } serializedGraphElement.Guid = graphElement.persistenceKey; serializedGraphElement.TypeName = graphElement.GetType().AssemblyQualifiedName; serializedGraphElement.Position = graphElement.GetPosition(); var referenceGuids = serializedGraphElement.ReferenceGuids; switch (graphElement) { case Node node: node.Query <Port>().ForEach(port => referenceGuids.Add(port.persistenceKey)); break; case Edge edge: referenceGuids.Add(edge.input?.persistenceKey); referenceGuids.Add(edge.output?.persistenceKey); break; } if (graphElement is IFieldHolder fieldHolder) { var fieldRegister = new FieldValuesSetter(serializedGraphElement, graphView); fieldHolder.RegisterFields(fieldRegister); } }
IEnumerator TestThatViewportLimitsElementResize(GraphElement element) { Assert.That(element != null); Assert.That(element.IsResizable()); Rect elementRect = element.GetPosition(); var layoutMax = new Vector2(Window.rootVisualElement.layout.width, Window.rootVisualElement.layout.height); // (-10, +15) corresponds to a delta of (-10, -10) followed by a delta of (0, +25) to account for graphView dock bar at the top var delta = new Vector2(-10, 15); // Resize the element using lower right Resizer manipulator Vector2 start = element.hierarchy.parent.ChangeCoordinatesTo(Window.rootVisualElement, new Vector2(elementRect.xMax, elementRect.yMax) + delta); Helpers.MouseDownEvent(start); yield return(null); // Resize much bigger than the actual layout Vector2 target = element.hierarchy.parent.ChangeCoordinatesTo(Window.rootVisualElement, new Vector2(layoutMax.x + 1000, layoutMax.y + 1000)); Helpers.MouseMoveEvent(start, target); yield return(null); Helpers.MouseUpEvent(target); yield return(null); // Check that the new element's lower right corner does not exceed the viewport's width and height Rect newElementRect = element.hierarchy.parent.ChangeCoordinatesTo(Window.rootVisualElement, element.GetPosition()); var newPosition = new Vector2(newElementRect.xMax, newElementRect.yMax); Assert.That(newPosition, Is.EqualTo(layoutMax)); }
/// <summary> /// 执行命令 /// </summary> /// <param name="o">当前对象</param> /// <returns>是否执行成功</returns> public override bool Execute(object o) { bool success = true; GraphElement graphElement = o as GraphElement; DialogResult result = MessageBox.Show("是否确定删除选中的图元?", "删除操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) // 用户确认删除 { graphManager.CurrentCanvas.PaintCanvas = false; // 避免绘制时使用已经释放的资源 // 保存命令执行前的数据 if (firstCommand) // 只有第一条命令保存执行前的数据 { SaveBeforeExecute(flowChartManager.GetArguments()); } description = "删除图元 " + graphElement.Name; success = DeleteGraphElement(graphElement); } else { success = false; } // 保存命令执行后的数据 if (success) { flowChartManager.ContentChanged = true; SaveAfterExecute(flowChartManager.GetArguments()); } return(success); }
/// <summary> /// Press one of the mouse buttons (at the moment of pressing) /// </summary> /// <param name="e">Mouse Properties</param> public void MouseDown(MouseEventArgs e) { //If the initial connector is empty... if (this.initialConnector == null) { //You look for if you clicked on a different element of an arrow or a finish GraphElement element = GraphDiagram.GetElement(this.diagramLayer, e.Location); if ((element != null) && !((element is GraphArrow) || (element is GraphFinish))) { Connector connector = element.GetConnector(e.Location); if (connector != null) { this.initialConnector = connector; this.initFixed = true; } else { this.initialConnector = this.GetConnector(element, e.Location); } if (this.initialConnector.Parent is GraphConditional) { this.conditionalOut = ((GraphConditional)this.initialConnector.Parent).GetPredefOut(this.initialConnector); } element.DisableConnectors(); element.EnableConnector(this.initialConnector); this.tempGraphArrow.UpdateArrow(this.initialConnector.AbsCenter, e.Location); this.tempLayer.UpdateSurface(); } } }
public override void OnStartDragging(GraphElement ge) { if (ge is TokenDeclaration tokenDeclaration) { VseGraphView gView = GetFirstOfType <VseGraphView>(); VisualElement tokenParent = tokenDeclaration.parent; int childIndex = tokenDeclaration.FindIndexInParent(); gView.RemoveElement(tokenDeclaration); tokenDeclaration.SetClasses(); gView.AddElement(tokenDeclaration); // By removing the tokenDeclaration from the graph view, we also removed it from the selection. // We need to add the tokenDeclaration back in order to properly drag. tokenDeclaration.Select(gView, true); tokenDeclaration.BringToFront(); TokenDeclaration placeHolderTokenDeclaration = tokenDeclaration.Clone(); placeHolderTokenDeclaration.AddToClassList("placeHolder"); tokenParent.Insert(childIndex, placeHolderTokenDeclaration); placeHolderTokenDeclaration.MarkDirtyRepaint(); gView.AddPlaceholderToken(tokenDeclaration); } else { var originalWidth = ge.resolvedStyle.width; var originalHeight = ge.resolvedStyle.height; base.OnStartDragging(ge); // Revert to same width and height after element became unstacked ge.style.width = originalWidth; ge.style.height = originalHeight; } }
protected override void MoveRow(GraphElement selectedElement, SortableExpandableRow insertTargetElement, bool insertAtEnd) { if (!(selectedElement is ComponentRow componentRow) || !(insertTargetElement is ComponentRow insertComponentRowElement)) { m_ParentElement.SetDragIndicatorVisible(false); return; } var targetComponent = insertComponentRowElement.Component; if (targetComponent == null) { return; } var component = componentRow.Component; if (component == targetComponent) { return; } Assert.That(GraphElementModel is ComponentQueryDeclarationModel); Store.Dispatch(new MoveComponentInQueryAction((ComponentQueryDeclarationModel)GraphElementModel, component, targetComponent, insertAtEnd)); }
/// <summary> /// Press one of the mouse buttons (at the moment of release) /// </summary> /// <param name="e">Mouse Properties</param> public void MouseUp(MouseEventArgs e) { if (this.initialConnector != null) { GraphElement element = GraphDiagram.GetElement(this.diagramLayer, e.Location); if ((element != null) && !(element is GraphArrow)) { if (this.initialConnector.Parent == element) { if (this.initFixed) { Connector connector = element.GetConnector(e.Location); if (this.initialConnector == connector) { this.dragMode = false; } else if (connector != null) { this.finalConnector = this.presentConnector; this.Do(); } } else { this.dragMode = false; } } else if (!(element is GraphStart)) { this.finalConnector = this.presentConnector; this.Do(); } } } }
internal void AddNodeView(Vector2 pos, Node node) { GraphElement nodeView = null; if (node is RootTask rootTask) { nodeView = new RootTaskView(rootTask, pos); } else if (node is CompositeTask compositeTask) { nodeView = new CompositeTaskView(compositeTask, pos); } else if (node is DecoratorTask decoratorTask) { nodeView = new DecoratorTaskView(decoratorTask, pos); } else if (node is Task task) { nodeView = new TaskNodeView(task, pos); } else if (node is LogicNode logicNode) { nodeView = new LogicNodeView(logicNode, pos); } if (nodeView != null) { AddElement(nodeView); } }
internal void AddNodeView(Vector2 pos, Type type) { GraphElement nodeView = null; if (type.IsSubclassOf(typeof(RootTask))) { nodeView = new RootTaskView((RootTask)Activator.CreateInstance(type), pos); } else if (type.IsSubclassOf(typeof(CompositeTask))) { nodeView = new CompositeTaskView((CompositeTask)Activator.CreateInstance(type), pos); } else if (type.IsSubclassOf(typeof(DecoratorTask))) { nodeView = new DecoratorTaskView((DecoratorTask)Activator.CreateInstance(type), pos); } else if (type.IsSubclassOf(typeof(Task))) { nodeView = new TaskNodeView((Task)Activator.CreateInstance(type), pos); } else if (type.IsSubclassOf(typeof(LogicNode))) { nodeView = new LogicNodeView((LogicNode)Activator.CreateInstance(type), pos); } if (nodeView != null) { AddElement(nodeView); } }
/// <summary> /// 检查是否更新事件结点 /// </summary> /// <param name="graphElement">当前图元</param> /// <param name="eventNode">事件结点</param> /// <returns>是否需要更新</returns> protected virtual bool CheckCanBindEventNode(GraphElement graphElement, EventGraphElement eventNode) { bool avail = true; GraphManager graphManager = data as GraphManager; DataManager dataManager = graphManager.CurrentFlowChartManager.CurrentDataManager; IComparable com1; IComparable com2; if (graphElement is SlotContainer) // 插槽容器 { SlotContainer slotContainer = graphElement as SlotContainer; if (slotContainer.EventNode != null && slotContainer.EventNode != eventNode) { com1 = dataManager.GetData(slotContainer.EventNode) as IComparable; com2 = dataManager.GetData(eventNode) as IComparable; avail = (com1.CompareTo(com2) == 0); } } else if (graphElement is ConnectorContainer) // 连接线 { ConnectorContainer line = graphElement as ConnectorContainer; if (line.EventNode != null && line.EventNode != eventNode) { com1 = dataManager.GetData(line.EventNode) as IComparable; com2 = dataManager.GetData(eventNode) as IComparable; avail = (com1.CompareTo(com2) == 0); } } return(avail); }
/// <summary> /// 初始化 /// </summary> private void Init() { DataGridViewTextBoxColumn idColumn = new DataGridViewTextBoxColumn(); idColumn.Name = "ID"; idColumn.HeaderText = "ID"; DataGridViewTextBoxColumn textColumn = new DataGridViewTextBoxColumn(); textColumn.Name = "Text"; textColumn.HeaderText = "Text"; DataGridViewTextBoxColumn locationColumn = new DataGridViewTextBoxColumn(); locationColumn.Name = "Location"; locationColumn.HeaderText = "Location"; dataGridViewX1.Columns.Add(idColumn); dataGridViewX1.Columns.Add(textColumn); dataGridViewX1.Columns.Add(locationColumn); for (int i = 0; i < graphElementList.Count; i++) { GraphElement graphElement = graphElementList[i]; dataGridViewX1.Rows.Add(1); DataGridViewRow newRow = dataGridViewX1.Rows[i]; newRow.Cells["ID"].Value = graphElement.ID.ToString(); newRow.Cells["Text"].Value = graphElement.Text.ToString(); newRow.Cells["Location"].Value = string.Format("{0}, {1}", graphElement.Location.X, graphElement.Location.Y); } }
void AddToGraphView(GraphElement graphElement) { // exception thrown by graphview while in playmode // probably related to the undo selection thingy try { if (graphElement.parent == null) // Some elements (e.g. Placemats) come in already added to the right spot. { m_GraphView.AddElement(graphElement); } } catch (Exception e) { Debug.LogError(e); } if (graphElement is IHasGraphElementModel hasGraphElementModel && m_Store.GetState().EditorDataModel.ShouldSelectElementUponCreation(hasGraphElementModel)) { graphElement.Select(m_GraphView, true); } // Execute any extra stuff when element is added (graphElement as IVSGraphViewObserver)?.OnAddedToGraphView(); if (graphElement is StackNode || graphElement is Node || graphElement is Token || graphElement is Edge) { graphElement.RegisterCallback <MouseOverEvent>(m_GraphView.OnMouseOver); } }
/// <summary> /// 检查数据是否有效 /// </summary> public void CheckDataValid() { string requestReloadID = dataManager.RequestReloadID; if (requestReloadID != "") { DialogResult result = MessageBox.Show("发现绘图部分数据在程序外发生改变,需要重新编辑更新!", "数据一致性检查", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { string[] idArray = requestReloadID.Split(new char[] { ',' }); Hashtable argTable = new Hashtable(); argTable["globe_args"] = dataManager.GlobeArgs; argTable["requestReloadID"] = ""; argTable["forceReload"] = "1"; foreach (string id in idArray) { GraphElement graphElement = dataManager.FindGraphElementByID(int.Parse(id)); if (graphElement != null) { DataElement dataElement = dataManager.FindDataElementByID(int.Parse(id)); dataElement.ReloadData(argTable); graphManager.SelectGraphElement(graphElement, true); graphManager.EditDataElement(graphElement); } } } } }
internal void UpdateViewTransform(FindInGraphAdapter.FindSearcherItem item) { if (item == null) { return; } GraphElement elt = null; Vector3 frameTranslation; Vector3 frameScaling; if (ModelsToNodeMapping?.TryGetValue(item.Node, out elt) ?? false) { m_GraphView.ClearSelection(); m_GraphView.AddToSelection(elt); Rect rect = elt.parent.ChangeCoordinatesTo(m_GraphView.contentViewContainer, elt.localBound); GraphView.CalculateFrameTransform( rect, m_GraphView.layout, 30, out frameTranslation, out frameScaling ); } else { Debug.LogError("no ui mapping for " + item.Name); GraphView.CalculateFrameTransform( new Rect(item.Node.ParentStackModel?.Position ?? item.Node.Position, Vector2.one), m_GraphView.layout, 30, out frameTranslation, out frameScaling ); } m_GraphView.UpdateViewTransform(frameTranslation, frameScaling); }
/// <summary> /// 获取下一个图元数据 /// </summary> /// <param name="dataManager">数据管理器</param> /// <param name="graphElement">当前图元</param> /// <param name="metaData">图元数据</param> /// <param name="graphElementList">遍历过的图元链表</param> /// <param name="graphElementTable">绘图索引哈希表</param> private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List <GraphElement> graphElementList, Hashtable graphElementTable) { graphElementList.Add(graphElement); graphElementTable[graphElement] = metaData; List <GraphElement> list = dataManager.GetNextGraphElements(graphElement, false); foreach (GraphElement g in list) { object data = dataManager.GetData(g); if (!graphElementList.Contains(g)) { DataElement dataElement = dataManager.GetDataElement(g); FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType); newMetaData.DisplayText = g.TooltipText; newMetaData.AddPreviousMetaData(metaData); metaData.AddNextMetaData(newMetaData); FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable); } else { FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData; newMetaData.AddPreviousMetaData(metaData); metaData.AddNextMetaData(newMetaData); } } }
private static GraphElement CreateGraphXmlElement(XElement xmlElement, string file) { var graphElement = new GraphElement(); graphElement.Id = xmlElement.Attribute(StrLits.Guid).Value; graphElement.Uri = file; graphElement.LineNum = ((IXmlLineInfo)xmlElement).HasLineInfo() ? ((IXmlLineInfo)xmlElement).LineNumber : -1; graphElement.XmlElementName = xmlElement.Name.LocalName; if (xmlElement.Parent != null) { var parentId = xmlElement.Parent.Attribute(StrLits.Guid); if (parentId != null) { graphElement.ParentId = parentId.Value; } } foreach (var attribute in xmlElement.Attributes()) { if (attribute.Name.LocalName == StrLits.Guid) { continue; } if (!graphElement.Attributes.ContainsKey(attribute.Name.LocalName)) { graphElement.Attributes.Add(attribute.Name.LocalName, attribute.Value); } } return(graphElement); }
public IEnumerator EndToEndMoveDependencyWithPanning() { var stackModel0 = GraphModel.CreateStack(string.Empty, new Vector2(100, -100)); var stackModel1 = GraphModel.CreateStack(string.Empty, new Vector2(100, 100)); GraphModel.CreateEdge(stackModel1.InputPorts[0], stackModel0.OutputPorts[0]); Store.Dispatch(new RefreshUIAction(UpdateFlags.All)); yield return(null); GraphView.FrameAll(); yield return(null); bool needsMouseUp = false; try { using (var scheduler = GraphView.CreateTimerEventSchedulerWrapper()) { GraphElement stackNode = GraphView.UIController.ModelsToNodeMapping[stackModel0]; Vector2 startPos = stackNode.GetPosition().position; Vector2 otherStartPos = stackModel1.Position; Vector2 nodeRect = stackNode.hierarchy.parent.ChangeCoordinatesTo(Window.rootVisualElement, stackNode.layout.center); // Move the movable node. Vector2 pos = nodeRect; Vector2 target = new Vector2(Window.rootVisualElement.layout.xMax - 20, pos.y); needsMouseUp = true; bool changed = false; GraphView.viewTransformChanged += view => changed = true; Helpers.MouseDownEvent(pos); yield return(null); Helpers.MouseMoveEvent(pos, target); Helpers.MouseDragEvent(pos, target); yield return(null); scheduler.TimeSinceStartup += GraphViewTestHelpers.SelectionDraggerPanInterval; scheduler.UpdateScheduledEvents(); Helpers.MouseUpEvent(target); needsMouseUp = false; Assume.That(changed, Is.True); yield return(null); Vector2 delta = stackNode.GetPosition().position - startPos; Assert.That(stackModel1.Position, Is.EqualTo(otherStartPos + delta)); } } finally { if (needsMouseUp) { Helpers.MouseUpEvent(Vector2.zero); } } }
internal void AddElementForRebuild(GraphElement element) { bool wasPopulating = m_Populating; m_Populating = true; // disable creating node models when adding elements AddElement(element); m_Populating = wasPopulating; }
/// <summary> /// Deselects the item sent as a parameter /// </summary> /// <param name="element">Item to deselect</param> private void DeselectElement(GraphElement element) { //The item is deselected element.Selected = false; //Removed from the temporary layer this.selectLayer.RemoveElement(element); //If there is no element in the temporal layer... }
void AddElement(GraphElement element, bool isAlreadyInGraphView = false) { m_CurrentElements.Add(element); if (!isAlreadyInGraphView) { m_GraphView.AddElement(element); } }
public void Erase(GraphElement element) { Elements &= ~element; if (Elements == GraphElement.Space) { ElementColors = null; } }
void UpdateSpacingPositions(GraphElement selectedElement, Rect sourceRect) { ClearRectsToConsider(); GetRectsToConsiderInView(selectedElement); SortReferenceRects(); ComputeSpacingPositions(m_VerticalReferenceRects, sourceRect); ComputeSpacingPositions(m_HorizontalReferenceRects, sourceRect); }
public void Paint(int elementid, int color) { Elements |= (GraphElement)(1<<elementid); if(elementid != 0) { if(ElementColors == null) ElementColors = new int[12]; ElementColors[elementid] = color; } }
/// <summary> /// This default constructor creates graph with specified capacity; /// </summary> /// <param name="capacity"></param> public Graph(int capacity) { _elements = new List<GraphElement>(capacity); for(int i = 0; i < capacity; ++i) { var el = new GraphElement(i); _elements.Add(el); } }
public void Paint(GraphElement element, int color) { Elements |= element; if(element != GraphElement.Space) { if(ElementColors == null) ElementColors = new int[13]; int pos = (int)element; int offset = 0; while(pos != 0) { if((pos & 1) != 0) ElementColors[offset] = color; pos >>= 1; ++offset; } } }
public void Erase(GraphElement element) { Elements &= ~element; if(Elements == GraphElement.Space) ElementColors = null; }
public void Erase() { Elements = GraphElement.Space; ElementColors = null; }
public bool HasElement(GraphElement element) { return (Elements & element) == element; }
/// <summary> /// Creates copy of graph element. /// </summary> /// <returns> /// Clone of current object. /// </returns> public GraphElement Clone() { var clone = new GraphElement(Content, Id) { TaxonNumber = taxonNumber }; return clone; }