protected void BindHyperArcToNodeShapes(hyperarc ha) { BindingOperations.ClearBinding((HyperArcShape)ha.DisplayShape.Shape, HyperArcShape.NodeCentersProperty); var multiBinding = new MultiBinding { Mode = BindingMode.OneWay, Converter = new HyperArcNodeLocationsConverter() }; foreach (node n in ha.nodes) { var icon = ((DisplayShape)n.DisplayShape).icon; var binding = new Binding { Source = icon, Mode = BindingMode.OneWay, Path = new PropertyPath(IconShape.CenterProperty) }; multiBinding.Bindings.Add(binding); } ((HyperArcShape)ha.DisplayShape.Shape).SetBinding(HyperArcShape.NodeCentersProperty, multiBinding); if (((HyperArcShape)ha.DisplayShape.Shape).Controller is InferredHyperArcController) { ((InferredHyperArcController)((HyperArcShape)ha.DisplayShape.Shape).Controller).BindToArcs(); } }
public override void HyperArcPropertyChanged(hyperarc h) { base.HyperArcPropertyChanged(h); if (propagateChange) { if (rW.graphGUIK == this) { // then need to update the node names in both L and R var LHyper = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, h.name)); rW.graphGUIL.propagateChange = false; rW.graphGUIL.ApplyHyperArcFormatting(LHyper, h, true); var RHyper = rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, h.name)); rW.graphGUIR.propagateChange = false; rW.graphGUIR.ApplyHyperArcFormatting(RHyper, h, true); } else if (this == rW.graphGUIL) { var Knode = rW.graphGUIK.graph.hyperarcs.Find(b => string.Equals(b.name, h.name)); if (Knode != null) { rW.graphGUIK.propagateChange = false; rW.graphGUIK.ApplyHyperArcFormatting(Knode, h, true); } } } else { propagateChange = true; } }
/* this way we can use the same beginNewArc method for both rule display * and graph display by just overriding this small method. */ protected virtual hyperarc InstantiateNewHyperArc() { var newHA = new hyperarc(graph.makeUniqueHyperArcName()); graph.addHyperArc(newHA); return(newHA); }
public override void DisconnectHyperArcConnection(hyperarc h, node n) { base.DisconnectHyperArcConnection(h, n); if (propagateChange) { if (rW.graphGUIK == this) { // then need to update the arc names in both L and R var LHyper = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, h.name)); var LNode = rW.rule.L.nodes.Find(b => string.Equals(b.name, n.name)); rW.graphGUIL.propagateChange = false; rW.graphGUIL.DisconnectHyperArcConnection(LHyper, LNode); var RHyper = rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, h.name)); var RNode = rW.rule.R.nodes.Find(b => string.Equals(b.name, n.name)); rW.graphGUIR.propagateChange = false; rW.graphGUIR.DisconnectHyperArcConnection(RHyper, RNode); } else if (this == rW.graphGUIL) { var KHyper = rW.graphGUIK.graph.hyperarcs.Find(b => string.Equals(b.name, h.name)); var KNode = rW.graphGUIK.graph.nodes.Find(b => string.Equals(b.name, n.name)); if ((KHyper != null) && (KNode != null)) { rW.graphGUIK.propagateChange = false; rW.graphGUIK.DisconnectHyperArcConnection(KHyper, KNode); } } } else { propagateChange = true; } }
public void ApplyHyperArcFormatting(hyperarc victim, hyperarc datum, Boolean IncludeController) { /* Update Common Properties */ victim.DisplayShape.Stroke = datum.DisplayShape.Stroke; victim.DisplayShape.Fill = datum.DisplayShape.Fill; victim.DisplayShape.StrokeThickness = datum.DisplayShape.StrokeThickness; if (IncludeController) { if (((HyperArcShape)victim.DisplayShape.Shape).Controller.GetType().Equals( ((HyperArcShape)datum.DisplayShape.Shape).Controller.GetType())) { ((HyperArcShape)datum.DisplayShape.Shape).Controller.copyValueTo( ((HyperArcShape)victim.DisplayShape.Shape).Controller); } else { ((HyperArcShape)victim.DisplayShape.Shape).Controller = ((HyperArcShape)datum.DisplayShape.Shape).Controller.copy((HyperArcShape)victim.DisplayShape.Shape); } ((HyperArcShape)victim.DisplayShape.Shape).Controller.Redraw(); RedrawResizeAndReposition(); } storeOnUndoStack(); }
private static IList <Connection> HyperBorderArcs(designGraph graph, hyperarc pNodeHy) { if (pNodeHy.nodes.Count == 1) { return(pNodeHy.nodes[0].arcs.Where(a => a is Connection).Cast <Connection>().ToList()); } return(DBGBinary.HyperarcBorderArcsFinder(pNodeHy)); }
private static void PreceedingFinder(hyperarc sccHy, Dictionary <hyperarc, List <hyperarc> > blockingDic) { Preceedings.Add(sccHy); foreach (var value in blockingDic[sccHy]) { PreceedingFinder(value, blockingDic); } }
public virtual void HyperArcNameChanged(hyperarc a, string NewName) { if (a != null) { a.name = NewName; } storeOnUndoStack(); }
private static IEnumerable <hyperarc> OtherHyperarcFinder(Connection pHyArc, hyperarc pNodeHy, List <hyperarc> seperateHys) { if (pNodeHy.nodes.Any(n => n.name == pHyArc.From.name)) { return(seperateHys.Where(sh => sh.nodes.Any(n => n.name == pHyArc.To.name))); } return(seperateHys.Where(sh => sh.nodes.Any(n => n.name == pHyArc.From.name))); }
protected void RemoveHyperArcFromGraph(hyperarc a) { var aDS = (HyperArcShape)a.DisplayShape.Shape; var aIS = ((DisplayShape)a.DisplayShape).icon; hyperarcIcons.Remove(aIS); hyperarcShapes.Remove(aDS); // this finally purges the node corresponding to the shape deleted graph.removeHyperArc(a); }
protected virtual void completeNewHyperArcConnection(hyperarc h, node nodeToAttach) { if (nodeToAttach != null) { h.ConnectTo(nodeToAttach); BindHyperArcToNodeShapes(h); } nullNodeIcons.Remove(activeNullNode); activeNullNode = null; ((HyperArcIconShape)((DisplayShape)h.DisplayShape).icon).newConnection = null; mainObject.propertyUpdate(); storeOnUndoStack(); }
public void AddHyperArcShape(hyperarc h, Point?point = null) { if (!(h.DisplayShape is DisplayShape)) { h.DisplayShape = new DisplayShape((string)Application.Current.Resources["StarHyper"], ShapeRepresents.HyperArc, h); } hyperarcShapes.Add((HyperArcShape)h.DisplayShape.Shape); if (point.HasValue) { ((HyperArcShape)h.DisplayShape.Shape).Center = point.Value; } hyperarcIcons.Add(h, (HyperArcShape)h.DisplayShape.Shape); BindHyperArcToNodeShapes(h); }
private static void PreceedingFinder(hyperarc sccHy, Dictionary <hyperarc, List <hyperarc> > blockingDic) { co++; if (co != 1) { Preceedings.Add(sccHy); } foreach (var value in blockingDic[sccHy]) { if (visited.Contains(value)) { continue; } visited.Add(value); PreceedingFinder(value, blockingDic); } }
private static void PreceedingFinder(hyperarc sccHy, Dictionary <hyperarc, List <hyperarc> > blockingDic) { Counter0++; if (Counter0 != 1) { Preceedings.Add(sccHy); } foreach (var value in blockingDic[sccHy].Where(v => v != null)) { if (Visited.Contains(value)) { continue; } Visited.Add(value); PreceedingFinder(value, blockingDic); } }
internal static List <Connection> HyperarcBorderArcsFinder(hyperarc sccHy) { var borders = new List <Connection>(); foreach (Component node in sccHy.nodes) { foreach (Connection arc in node.arcs.Where(a => a is Connection)) { //var otherNode = arc.otherNode(node); //arc.From == node ? arc.To : arc.From; if (sccHy.nodes.Contains(arc.otherNode(node))) { continue; } borders.Add(arc); } } return(borders); }
public void AddKHyperToLandR(hyperarc h) { var Larc = (ruleHyperarc)(h).copy(); var Rarc = (ruleHyperarc)(h).copy(); rW.graphGUIL.graph.addHyperArc(Larc); rW.graphGUIR.graph.addHyperArc(Rarc); rW.graphGUIL.AddHyperArcShape(Larc); rW.graphGUIR.AddHyperArcShape(Rarc); foreach (var n in h.nodes) { Larc.ConnectTo(rW.graphGUIL.graph.nodes.Find(b => (b.name == n.name))); Rarc.ConnectTo(rW.graphGUIR.graph.nodes.Find(b => (b.name == n.name))); } rW.graphGUIL.BindHyperArcToNodeShapes(Larc); rW.graphGUIR.BindHyperArcToNodeShapes(Rarc); }
internal static void StronglyConnectedComponents(designGraph assemblyGraph, hyperarc seperate, int cndDir) { // The function takes every hyperarc with "seperate" lable and generates its SCCs with respect to // the candidate direction. After generation, a new hyperarc is added to the graph with local lable "SCC". var stack = new Stack <Component>(); var visited = new HashSet <Component>(); var globalVisited = new HashSet <Component>(); foreach (Component node in seperate.nodes.Where(n => !globalVisited.Contains(n))) { stack.Clear(); visited.Clear(); stack.Push(node); while (stack.Count > 0) { var pNode = stack.Pop(); visited.Add(pNode); globalVisited.Add(pNode); foreach (Connection pNodeArc in pNode.arcs.Where(a => a.GetType() == typeof(Connection))) { if (Removable(pNodeArc, cndDir)) { continue; } var otherNode = (Component)(pNodeArc.From == pNode ? pNodeArc.To : pNodeArc.From); if (visited.Contains(otherNode)) { continue; } stack.Push(otherNode); } } if (visited.Count == seperate.nodes.Count) { continue; } var last = assemblyGraph.addHyperArc(visited.Cast <node>().ToList()); last.localLabels.Add(DisConstants.SCC); } }
private static hyperarc BlockingSccFinder(designGraph graph, hyperarc sccHy, Connection arc) { if (sccHy.nodes.Contains(arc.From)) { foreach (var hy in graph.hyperarcs.Where(h => h.localLabels.Contains(DisConstants.SCC))) { if (hy.nodes.Contains(arc.To)) { return(hy); } } } foreach (var hy in graph.hyperarcs.Where(h => h.localLabels.Contains(DisConstants.SCC))) { if (hy.nodes.Contains(arc.From)) { return(hy); } } return(null); }
protected override void completeNewHyperArcConnection(hyperarc h, node nodeToAttach) { base.completeNewHyperArcConnection(h, nodeToAttach); if (nodeToAttach == null) { return; } if (propagateChange) { if (rW.graphGUIK == this) { // then need to update the arc names in both L and R var LHyper = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, h.name)); var LNode = rW.rule.L.nodes.Find(b => string.Equals(b.name, nodeToAttach.name)); rW.graphGUIL.propagateChange = false; rW.graphGUIL.completeNewHyperArcConnection(LHyper, LNode); var RHyper = rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, h.name)); var RNode = rW.rule.R.nodes.Find(b => string.Equals(b.name, nodeToAttach.name)); rW.graphGUIR.propagateChange = false; rW.graphGUIR.completeNewHyperArcConnection(RHyper, RNode); } else if (this == rW.graphGUIL) { var KHyper = rW.graphGUIK.graph.hyperarcs.Find(b => string.Equals(b.name, h.name)); var KNode = rW.graphGUIK.graph.nodes.Find(b => string.Equals(b.name, nodeToAttach.name)); if ((KHyper != null) && (KNode != null)) { rW.graphGUIK.propagateChange = false; rW.graphGUIK.completeNewHyperArcConnection(KHyper, KNode); } } } else { propagateChange = true; } }
public virtual void HyperArcPropertyChanged(hyperarc h) { storeOnUndoStack(); }
internal static void GenerateOptions(designGraph assemblyGraph, hyperarc seperate, Dictionary <hyperarc, List <hyperarc> > blockingDic) { // This sorting is not necessary, but I think it will speed up the search. Let's see! blockingDic = blockingDic.OrderBy(a => a.Value.Count).ToDictionary(x => x.Key, x => x.Value); var localRemovableHy = new List <List <hyperarc> >(); var trash = new List <hyperarc>(); var visitedStatesCount = 0; var visitedStates = new List <hyperarc>(); while (visitedStatesCount != blockingDic.Count) { foreach (var sccHy in blockingDic.Keys.Where(scc => !visitedStates.Contains(scc))) { if (blockingDic[sccHy].Count == 0) { sccHy.localLabels.Add(DisConstants.Removable); trash.Add(sccHy); visitedStatesCount++; visitedStates.Add(sccHy); localRemovableHy.Add(new List <hyperarc> { sccHy }); } else { if (blockingDic[sccHy].All(trash.Contains)) { Preceedings.Clear(); visitedStatesCount++; visitedStates.Add(sccHy); PreceedingFinder(sccHy, blockingDic); Preceedings = Updates.UpdatePreceedings(Preceedings); var nodes = new List <node>(); foreach (var hyperarc in Preceedings) { nodes.AddRange(hyperarc.nodes); } if (nodes.Count == seperate.nodes.Count) { continue; } assemblyGraph.addHyperArc(nodes); assemblyGraph.hyperarcs[assemblyGraph.hyperarcs.Count - 1].localLabels.Add( DisConstants.Removable); trash.Add(sccHy); localRemovableHy.Add(new List <hyperarc>(Preceedings)); Preceedings.Clear(); } } } } //I am not done yet, not all of the options are generated by this point! for (var i = 0; i < localRemovableHy.Count - 1; i++) { for (var j = i + 1; j < localRemovableHy.Count; j++) { if (localRemovableHy[i].All(localRemovableHy[j].Contains) || localRemovableHy[j].All(localRemovableHy[i].Contains)) { continue; } var merged = new List <hyperarc>(); merged.AddRange(localRemovableHy[i]); foreach (var l in localRemovableHy[j].Where(l => !merged.Contains(l))) { merged.Add(l); } var exists = false; for (var k = j + 1; k < localRemovableHy.Count; k++) { if (localRemovableHy[k].All(merged.Contains) && merged.All(localRemovableHy[k].Contains)) { exists = true; break; } } if (exists) { continue; } var nodes = new List <node>(); foreach (var hy in merged) { nodes.AddRange(hy.nodes); } if (nodes.Count == seperate.nodes.Count) { continue; } assemblyGraph.addHyperArc(nodes); assemblyGraph.hyperarcs[assemblyGraph.hyperarcs.Count - 1].localLabels.Add( DisConstants.Removable); localRemovableHy.Add(merged); } } //for (var i = 0; i < assemblyGraph.hyperarcs.Count; i++) //{ // var hyScc = assemblyGraph.hyperarcs[i]; // if (hyScc.localLabels.Contains(DisConstants.SCC) && // !hyScc.localLabels.Contains(DisConstants.Removable)) // assemblyGraph.hyperarcs.Remove(hyScc); //} foreach (var SCCHy in assemblyGraph.hyperarcs.Where(hyScc => hyScc.localLabels.Contains(DisConstants.SCC) && !hyScc.localLabels.Contains(DisConstants.Removable)).ToList()) { assemblyGraph.hyperarcs.Remove(SCCHy); } }
public override void HyperArcNameChanged(hyperarc h, string NewName) { if (!string.Equals(h.name, NewName)) { #region RenamedNodeInK // then need to update the hyperarc names in both L and R if (rW.graphGUIK == this) { var Lhyperarc = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, h.name)); Lhyperarc.name = NewName; var hI = ((DisplayShape)Lhyperarc.DisplayShape).icon; var mbe = BindingOperations.GetMultiBindingExpression(hI, IconShape.DisplayTextProperty); mbe.UpdateTarget(); var Rhyperarc = rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, h.name)); Rhyperarc.name = NewName; hI = ((DisplayShape)Rhyperarc.DisplayShape).icon; mbe = BindingOperations.GetMultiBindingExpression(hI, IconShape.DisplayTextProperty); mbe.UpdateTarget(); } #endregion else { #region RenamedNodeInLorR - CheckForBreakingACommonNodeRelationship // does renaming breaks a common hyperarcs relationship then need to deleted the hyperarc from K var Khyperarc = rW.graphGUIK.graph.hyperarcs.Find(b => string.Equals(b.name, h.name)); if (Khyperarc != null) { rW.graphGUIK.RemoveHyperArcFromGraph(Khyperarc); } #endregion #region RenamedNodeInLorR - CheckForCreatingACommonNodeRelationship // does renaming results in a common hyperarc then need to copy it into K var match = false; // finding the active graph canvas if (rW.graphGUIL == this) { match = rW.rule.R.hyperarcs.Exists(b => string.Equals(b.name, NewName)); } else if (rW.graphGUIR == this) { match = rW.rule.L.hyperarcs.Exists(b => string.Equals(b.name, NewName)); } if (match) { var Lhyperarc = h; if (rW.graphGUIR == this) { Lhyperarc = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, NewName)); } var tempHyper = (ruleHyperarc)Lhyperarc.copy(); tempHyper.name = NewName; //add it to K graph // the hyperarc need to be added to K in the same location as it was in L graph rW.graphGUIK.AddHyperArcShape(tempHyper); rW.graphGUIK.graph.addHyperArc(tempHyper); } #endregion } mainObject.propertyUpdate(this); //mainObject.property.FreeArcEmbedRulePrpt.Update(rW.rule); } base.HyperArcNameChanged(h, NewName); }
// OptimizedSCC is the modified SCC. In this class, a dictionary of SCCs for each direction is created // to take benefit from premade SCC hyperarcs. The dictionary will be updated after each "apply" internal static void StronglyConnectedComponents(designGraph assemblyGraph, hyperarc seperateHy, int cndDir) { var preAddedSccs = new List <Component>(); if (BeamSearch.SccTracker.Keys.Contains(cndDir)) { foreach (var premadeSCC in BeamSearch.SccTracker[cndDir]) { var c = 0; foreach (var node in premadeSCC) { c += seperateHy.nodes.Count(n => n.name == node.name); } if (c != premadeSCC.Count) { continue; } var nodes = new List <node>(); foreach (var n in premadeSCC) { nodes.AddRange(seperateHy.nodes.Where(a => a.name == n.name)); } var last = assemblyGraph.addHyperArc(nodes); last.localLabels.Add(DisConstants.SCC); preAddedSccs.AddRange(premadeSCC); } //foreach (var premadeSCC in DisassemblyProcess.SccTracker[cndDir].Where(pmSCC => pmSCC.All(n => seperateHy.nodes.Contains(n)))) //{ // var last = assemblyGraph.addHyperArc(premadeSCC); // last.localLabels.Add(DisConstants.SCC); // preAddedSccs.AddRange(premadeSCC); //} } var globalVisited = new List <Component>(); var stack = new Stack <Component>(); var visited = new HashSet <Component>(); var sccTrackerNodes = new List <List <Component> >(); foreach (Component node in seperateHy.nodes.Where(n => !globalVisited.Contains(n))) { if (preAddedSccs.Any(n => n.name == node.name)) { continue; } stack.Clear(); visited.Clear(); stack.Push(node); while (stack.Count > 0) { var pNode = stack.Pop(); visited.Add(pNode); globalVisited.Add(pNode); foreach (Connection pNodeArc in pNode.arcs.Where(a => a.GetType() == typeof(Connection))) { if (SCC.Removable(pNodeArc, cndDir)) { continue; } var otherNode = (Component)(pNodeArc.From == pNode ? pNodeArc.To : pNodeArc.From); if (visited.Contains(otherNode)) { continue; } stack.Push(otherNode); } } assemblyGraph.addHyperArc(visited.Cast <node>().ToList()); assemblyGraph.hyperarcs[assemblyGraph.hyperarcs.Count - 1].localLabels.Add(DisConstants.SCC); sccTrackerNodes.Add(visited.ToList()); } if (BeamSearch.SccTracker.Keys.Contains(cndDir)) { BeamSearch.SccTracker[cndDir] = sccTrackerNodes; } else { BeamSearch.SccTracker.Add(cndDir, sccTrackerNodes); } }
public void Add(hyperarc h, FrameworkElement hyperarcshape) { var icon = new HyperArcIconShape(h, (HyperArcShape)hyperarcshape, gd); base.Add(icon, h); }
internal static List <option> GenerateOptions(designGraph assemblyGraph, hyperarc seperate, Dictionary <hyperarc, List <hyperarc> > blockingDic, List <option> gOptions) { var freeSCCs = blockingDic.Keys.Where(k => blockingDic[k].Count == 0).ToList(); var combinations = CombinationsCreatorPro(assemblyGraph, freeSCCs); var options = new List <option>(); //AddingOptionsToGraph(assemblyGraph, combinations, seperate.nodes.Count); options.AddRange(AddingOptionsToGraph(combinations, seperate, options, gOptions)); var counter = 0; var cp1 = new List <List <hyperarc> >(); var cp2 = new List <List <hyperarc> >(); do { if (counter == 0) { cp1 = combinations; } cp2.Clear(); foreach (var opt in cp1) { freeSCCs.Clear(); foreach (var key in blockingDic.Keys) { if (opt.Contains(key) || blockingDic[key].Count == 0) { continue; } if (!blockingDic[key].All(bl => opt.Contains(bl))) { continue; } var newOp = new List <hyperarc>(opt) { key }; if (!cp1.Where(cp => cp.All(hy => newOp.Contains(hy))).Any(cp => newOp.All(cp.Contains))) { freeSCCs.Add(key); } } if (freeSCCs.Count == 0) { continue; } combinations = CombinationsCreatorPro2(assemblyGraph, freeSCCs, opt); var combAndPar = AddingParents(opt, combinations); options.AddRange(AddingOptionsToGraph(combAndPar, seperate, options, gOptions)); cp2.AddRange(combAndPar); } counter = 1; cp1 = new List <List <hyperarc> >(cp2); } while (cp1.Count > 0); foreach (var SCCHy in assemblyGraph.hyperarcs.Where(hyScc => hyScc.localLabels.Contains(DisConstants.SCC) && !hyScc.localLabels.Contains(DisConstants.Removable)).ToList()) { assemblyGraph.hyperarcs.Remove(SCCHy); } return(options); }
private void txtLabels_LostFocus(object sender, RoutedEventArgs e) { if (hyperarcs.Count == 0) { return; } MultiBindingExpression mbe; var caretIndex = txtLabels.CaretIndex; var origLength = txtLabels.Text.Length; var oldLabels = firstHyperArc.localLabels; var newLabels = StringCollectionConverter.Convert(txtLabels.Text); if ((gui is RuleDisplay) && (gui == ((RuleDisplay)gui).rW.graphGUIK)) { var rW = ((RuleDisplay)gui).rW; var Larc = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); var Rarc = rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); var removedKLabels = oldLabels.Where(a => !newLabels.Contains(a)).ToList(); foreach (string a in removedKLabels) { Larc.localLabels.Remove(a); Rarc.localLabels.Remove(a); } var newLLabels = new List <string>(Larc.localLabels.Union(newLabels)); Larc.localLabels.Clear(); foreach (string a in newLLabels) { Larc.localLabels.Add(a); } var nI = ((HyperArcShape)Larc.DisplayShape.Shape).icon; mbe = BindingOperations.GetMultiBindingExpression(nI, IconShape.DisplayTextProperty); mbe.UpdateTarget(); var newRLabels = new List <string>(Rarc.localLabels.Union(newLabels)); Rarc.localLabels.Clear(); foreach (string a in newRLabels) { Rarc.localLabels.Add(a); } nI = ((HyperArcShape)Rarc.DisplayShape.Shape).icon; mbe = BindingOperations.GetMultiBindingExpression(nI, IconShape.DisplayTextProperty); mbe.UpdateTarget(); } else if (gui is RuleDisplay) { // this is a rule LHS or RHS var rW = ((RuleDisplay)gui).rW; hyperarc otherHyperArc = null; otherHyperArc = gui == rW.graphGUIL ? rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)) : rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); if (otherHyperArc != null) { var Klabels = new List <string>(otherHyperArc.localLabels.Intersect(newLabels)); otherHyperArc = rW.graphGUIK.graph.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); otherHyperArc.localLabels.Clear(); foreach (string a in Klabels) { otherHyperArc.localLabels.Add(a); } var nI = ((HyperArcShape)otherHyperArc.DisplayShape.Shape).icon; mbe = BindingOperations.GetMultiBindingExpression(nI, IconShape.DisplayTextProperty); mbe.UpdateTarget(); } } firstHyperArc.localLabels.Clear(); foreach (string a in newLabels) { firstHyperArc.localLabels.Add(a); } mbe = BindingOperations.GetMultiBindingExpression(hyperArcIcon, IconShape.DisplayTextProperty); mbe.UpdateTarget(); Update(); TextBoxHelper.SetCaret(txtLabels, caretIndex, origLength); }
public virtual void DisconnectHyperArcConnection(hyperarc h, node n) { h.DisconnectFrom(n); BindHyperArcToNodeShapes(h); storeOnUndoStack(); }
private static List <hyperarc> ScrewedToScc(designGraph assemblyGraph, List <hyperarc> freeSccs, hyperarc hy) { var screwed = new List <hyperarc>(); foreach (var scc in freeSccs) { if ( assemblyGraph.arcs.Where(a => a is Connection).Cast <Connection>().Any( a => ((hy.nodes.Contains(a.From) && scc.nodes.Contains(a.To)) || (scc.nodes.Contains(a.From) && hy.nodes.Contains(a.To))) && (a.Fasteners.Count > 0))) { screwed.Add(scc); } } return(screwed); }
private static List <option> AddingOptionsToGraph(List <List <hyperarc> > combAndPar, hyperarc seperate, List <option> options, List <option> gOptions) { var optionList = new List <option>(); var sep = seperate.nodes.Count; foreach (var opt in combAndPar) { //var nodes = new List<node>(); //var rule = new grammarRule(); //rule.L = new designGraph(); //var newOption = new option(rule); //foreach (var hy in opt) // nodes.AddRange(hy.nodes); //var otherHalf = seperate.nodes.Where(n => !nodes.Contains(n)).ToList(); //if (nodes.Count == sep) continue; //if (optionList.Any(o => o.nodes.All(nodes.Contains) && nodes.All(o.nodes.Contains))) continue; //if (optionList.Any(o => o.nodes.All(otherHalf.Contains) && otherHalf.All(o.nodes.Contains))) continue; //if (options.Any(o => o.nodes.All(nodes.Contains) && nodes.All(o.nodes.Contains))) continue; //if (options.Any(o => o.nodes.All(otherHalf.Contains) && otherHalf.All(o.nodes.Contains))) continue; //if (gOptions.Any(o => o.nodes.All(nodes.Contains) && nodes.All(o.nodes.Contains))) continue; //if (gOptions.Any(o => o.nodes.All(otherHalf.Contains) && otherHalf.All(o.nodes.Contains))) continue; //newOption.nodes.AddRange(nodes); //optionList.Add(newOption); } return(optionList); }
private void txtVariables_LostFocus(object sender, RoutedEventArgs e) { if (hyperarcs.Count == 0) { return; } var caretIndex = txtVariables.CaretIndex; var origLength = txtVariables.Text.Length; var oldVars = firstHyperArc.localVariables; var newVars = DoubleCollectionConverter.Convert(txtVariables.Text); if ((gui is RuleDisplay) && (gui == ((RuleDisplay)gui).rW.graphGUIK)) { var rW = ((RuleDisplay)gui).rW; var Larc = rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); var Rarc = rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); var removedKVars = oldVars.Where(a => !newVars.Contains(a)).ToList(); foreach (double a in removedKVars) { Larc.localVariables.Remove(a); Rarc.localVariables.Remove(a); } var newLVars = new List <double>(Larc.localVariables.Union(newVars)); Larc.localVariables.Clear(); foreach (double a in newLVars) { Larc.localVariables.Add(a); } var newRVars = new List <double>(Rarc.localVariables.Union(newVars)); Rarc.localVariables.Clear(); foreach (double a in newRVars) { Rarc.localVariables.Add(a); } } else if (gui is RuleDisplay) { // this is a rule LHS or RHS var rW = ((RuleDisplay)gui).rW; hyperarc otherArc = null; otherArc = gui == rW.graphGUIL ? rW.rule.R.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)) : rW.rule.L.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); if (otherArc != null) { var KVars = new List <double>(otherArc.localVariables.Intersect(newVars)); otherArc = rW.graphGUIK.graph.hyperarcs.Find(b => string.Equals(b.name, firstHyperArc.name)); otherArc.localVariables.Clear(); foreach (double a in KVars) { otherArc.localVariables.Add(a); } } } firstHyperArc.localVariables.Clear(); foreach (double d in newVars) { firstHyperArc.localVariables.Add(d); } Update(); TextBoxHelper.SetCaret(txtVariables, caretIndex, origLength); }