void UpdateFront() { var newFrontEdges = new Set<CdtEdge>(); foreach (var t in addedTriangles) foreach (var e in t.Edges) if (e.CwTriangle == null || e.CcwTriangle == null) newFrontEdges.Insert(e); foreach (var e in newFrontEdges) AddEdgeToFront(e); }
private static bool SetOfActiveNodesIsLargerThanThreshold(Cluster ancestor, Node node, Set<Node> usedNodeSet, int threshold) { Cluster parent = Parent(node); do { foreach (var n in Children(parent)) { usedNodeSet.Insert(n); if (usedNodeSet.Count > threshold) return true; } if (parent == ancestor) break; parent = Parent(parent); } while (true); usedNodeSet.Insert(parent); return usedNodeSet.Count > threshold; }
Set<Tuple<int, int, int>> GetVisibleTilesSet() { int iLevel = GetBackgroundTileLevel(); GridTraversal grid = new GridTraversal(GeomGraph.BoundingBox, iLevel); var tiles = new Set<Triple>(); var visibleRectangle = GetVisibleRectangleInGraph(); var t1 = grid.PointToTuple(visibleRectangle.LeftBottom); var t2 = grid.PointToTuple(visibleRectangle.RightTop); for (int ix = t1.Item1; ix <= t2.Item1; ix++) for (int iy = t1.Item2; iy <= t2.Item2; iy++) { var t = new Triple(iLevel, ix, iy); TileType tileType; if (!_tileDictionary.TryGetValue(t, out tileType)) continue; if (tileType == TileType.Image) tiles.Insert(t); } return tiles; }
void FillExistingNodesEdges(Set<Node> existindNodes, Set<DrawingEdge> existingEdges) { foreach (var dro in _drawingObjectsToIViewerObjects.Keys) { var n = dro as Node; if (n != null && dro.IsVisible) //added: visibility existindNodes.Insert(n); else { var edge = dro as DrawingEdge; if (edge != null && dro.IsVisible) existingEdges.Insert((DrawingEdge) dro); } } }
private Set<Node> GetIntersectingVisibleRectangle(Set<Node> fakeTileNodes) { var rect = GetVisibleRectangleInGraph(); var nodes = new Set<Node>(); foreach (var node in fakeTileNodes) { IViewerObject o; if (!_drawingObjectsToIViewerObjects.TryGetValue(node, out o)) continue; var vnode = ((GraphmapsNode)o); if (NodeDotRect(vnode.LgNodeInfo).Intersects(rect)) { nodes.Insert(node); } } return nodes; }
void treeDataGridView_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Escape) treeDataGridView.ClearSelection(); if (e.KeyCode != Keys.Enter) return; var newDataFilter = new DataFilter { FilterSource = this, Analysis = new List<Analysis>() }; if (treeDataGridView.SelectedCells.Count == 0) return; var processedRows = new Set<int>(); foreach (DataGridViewCell cell in treeDataGridView.SelectedCells) { if (!processedRows.Insert(cell.RowIndex).WasInserted) continue; var rowIndexHierarchy = treeDataGridView.GetRowHierarchyForRowIndex(cell.RowIndex); var row = GetRowFromRowHierarchy(rowIndexHierarchy) as AnalysisRow; if (row != null) newDataFilter.Analysis.Add(row.Analysis); } if (AnalysisViewFilter != null) AnalysisViewFilter(this, new ViewFilterEventArgs(newDataFilter)); }
private List<SpectrumSourceGroup> applyAssemblyText(ISession session, string filepath) { var spectrumSources = session.Query<SpectrumSource>().ToList(); var sourcesByGroup = new Map<string, List<SpectrumSource>>(); var alreadyGroupedSources = new Set<string>(); var sourceGroups = new List<SpectrumSourceGroup>(); // open the assembly.txt file using (var assembleTxtFile = File.OpenText(filepath)) { string line; while ((line = assembleTxtFile.ReadLine()) != null) { if (line.Length == 0) continue; try { Regex groupFilemaskPair = new Regex("((\"(.+)\")|(\\S+))\\s+((\"(.+)\")|(\\S+))"); Match lineMatch = groupFilemaskPair.Match(line); string group = lineMatch.Groups[3].ToString() + lineMatch.Groups[4].ToString(); string filemask = lineMatch.Groups[7].ToString() + lineMatch.Groups[8].ToString(); // for wildcards, use old style behavior if (filemask.IndexOfAny("*?".ToCharArray()) > -1) { if (!Path.IsPathRooted(filemask)) filemask = Path.Combine(Path.GetDirectoryName(filepath), filemask); if (!sourcesByGroup.Contains(group)) sourcesByGroup[group] = new List<SpectrumSource>(); if (!Directory.Exists(Path.GetDirectoryName(filemask))) continue; var files = Directory.GetFiles(Path.GetDirectoryName(filemask), Path.GetFileName(filemask)); var sourceNames = files.Select(o => Path.GetFileNameWithoutExtension(o)); foreach (string sourceName in sourceNames) { var spectrumSource = spectrumSources.SingleOrDefault(o => o.Name == sourceName); if (spectrumSource == null) continue; var insertResult = alreadyGroupedSources.Insert(sourceName); if (insertResult.WasInserted) sourcesByGroup[group].Add(spectrumSource); } } else { // otherwise, match directly to source names string sourceName = Path.GetFileNameWithoutExtension(filemask); var spectrumSource = spectrumSources.SingleOrDefault(o => o.Name == sourceName); if (spectrumSource == null) continue; var insertResult = alreadyGroupedSources.Insert(sourceName); if (insertResult.WasInserted) sourcesByGroup[group].Add(spectrumSource); } } catch (Exception ex) { Program.HandleException(new Exception("Error reading assembly text from \"" + filepath + "\": " + ex.Message, ex)); } } } // remove existing groups RemoveGroupNode(_rootNode, false); sourceGroups.Add(new SpectrumSourceGroup { Name = "/" }); // build new group hierarchy foreach (var itr in sourcesByGroup) { if (itr.Value.IsNullOrEmpty()) continue; var ssg = new SpectrumSourceGroup { Name = itr.Key }; if (!alreadyGroupedSources.Contains(ssg.Name)) sourceGroups.Add(ssg); // decompose group path into segments, e.g. /foo/bar/ -> {foo, bar} IEnumerable<string> segments = ssg.Name.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); segments = segments.Take(segments.Count() - 1); // ignore the last segment var parentNode = _rootNode; foreach(string segment in segments) { var segmentNode = parentNode.Children.FirstOrDefault(o => o.Text == segment); if (segmentNode == null) { var segmentGroup = new SpectrumSourceGroup { Name = (parentNode.Text + "/").Replace("//", "/") + segment }; if (!alreadyGroupedSources.Contains(segmentGroup.Name)) sourceGroups.Add(segmentGroup); segmentNode = new tlvBranch { Text = segment, cms = cmRightClickGroupNode, Parent = parentNode, Children = new List<tlvBranch>(), Data = segmentGroup }; parentNode.Children.Add(segmentNode); } parentNode = segmentNode; } // parentNode is now the immediate parent of the current group var groupNode = new tlvBranch { Text = Path.GetFileName(ssg.Name), cms = cmRightClickGroupNode, Parent = parentNode, Children = new List<tlvBranch>(), Data = ssg }; foreach (var source in itr.Value) { var sourceNode = new tlvBranch { Text = Path.GetFileName(source.Name), Parent = groupNode, Data = source, cms = cmRightClickFileNode }; groupNode.Children.Add(sourceNode); lvNonGroupedFiles.Items.RemoveByKey(sourceNode.Text); } parentNode.Children.Add(groupNode); } tlvGroupedFiles.RefreshObject(_rootNode); tlvGroupedFiles.ExpandAll(); return sourceGroups.ToList(); }
void treeDataGridView_PreviewKeyDown (object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Escape) treeDataGridView.ClearSelection(); if (e.KeyCode != Keys.Enter) return; var newDataFilter = new DataFilter { FilterSource = this }; if (treeDataGridView.SelectedCells.Count == 0) return; var processedRows = new Set<int>(); var selectedSourceGroups = new List<SpectrumSourceGroup>(); var selectedSources = new List<SpectrumSource>(); var selectedSpectra = new List<Spectrum>(); var selectedAnalyses = new List<Analysis>(); var selectedPeptides = new List<Peptide>(); var selectedCharges = new List<int>(); var selectedMatches = new List<PeptideSpectrumMatchRow>(); foreach (DataGridViewCell cell in treeDataGridView.SelectedCells) { if (!processedRows.Insert(cell.RowIndex).WasInserted) continue; var rowIndexHierarchy = treeDataGridView.GetRowHierarchyForRowIndex(cell.RowIndex); Row row = GetRowFromRowHierarchy(rowIndexHierarchy); if (row is SpectrumSourceGroupRow) selectedSourceGroups.Add((row as SpectrumSourceGroupRow).SpectrumSourceGroup); else if (row is SpectrumSourceRow) selectedSources.Add((row as SpectrumSourceRow).SpectrumSource); else if (row is SpectrumRow) selectedSpectra.Add((row as SpectrumRow).Spectrum); else if (row is AnalysisRow) selectedAnalyses.Add((row as AnalysisRow).Analysis); else if (row is PeptideRow) selectedPeptides.Add((row as PeptideRow).Peptide); else if (row is ChargeRow) selectedCharges.Add((row as ChargeRow).Charge); else if (row is PeptideSpectrumMatchRow) selectedMatches.Add(row as PeptideSpectrumMatchRow); } if (selectedSourceGroups.Count > 0) newDataFilter.SpectrumSourceGroup = selectedSourceGroups; if (selectedSources.Count > 0) newDataFilter.SpectrumSource = selectedSources; if (selectedSpectra.Count > 0) newDataFilter.Spectrum = selectedSpectra; if (selectedAnalyses.Count > 0) newDataFilter.Analysis = selectedAnalyses; if (selectedPeptides.Count > 0) newDataFilter.Peptide = selectedPeptides; if (selectedCharges.Count > 0) newDataFilter.Charge = selectedCharges; // TODO: visualize multiple PSMs? //if (selectedMatches.Count > 0) if (SpectrumViewFilter != null) SpectrumViewFilter(this, new ViewFilterEventArgs(newDataFilter)); }