private void DrawLocationLink(LocationLink link, Matrix ViewProjMatrix) { LocationObj locA = link.A; LocationObj locB = link.B; if (!link.LinksVisible(_Parent.Downsample)) return; if (!locA.VolumePositionHasBeenCalculated) return; if (!locB.VolumePositionHasBeenCalculated) return; //Don't draw if the link falls within the radius of the location we are drawing if (link.LinksOverlap(Parent.Section.Number)) return; if (locA.Parent == null) return; StructureType type = new StructureType(locA.Parent.Type); if (type == null) return; int distanceFactor = link.maxSection - link.minSection; if (distanceFactor == 0) distanceFactor = 1; //Give the colors a nudge towards red or blue depending on the direction to the link double directionFactor = 1; directionFactor = link.maxSection == _Parent.Section.Number ? 1 : -1; Microsoft.Xna.Framework.Color color = GetLocationLinkColor(type.Color, distanceFactor, directionFactor, LastMouseOverObject == link); _Parent.LineManager.Draw(link.lineGraphic, (float)link.Radius, color, ViewProjMatrix, 0, null); }
private bool RemoveLocationLinkFromSectionSearchGrids(LocationLink linkView) { bool success = false; for (int iSection = linkView.minSection; iSection <= linkView.maxSection; iSection++) { if (parent.Section.VolumeViewModel.SectionViewModels.ContainsKey(iSection) == false) continue; // Debug.WriteLine(iSection.ToString() + " remove : " + linkView.ToString()); LineSearchGrid<LocationLink> searchGrid = GetSearchGrid(iSection); if (searchGrid == null) continue; GridLineSegment line; bool sectionSuccess = searchGrid.TryRemove(linkView, out line); Debug.Assert(sectionSuccess); success = success || sectionSuccess; //Free all the memory for the search grid if this was the last location link if (searchGrid.Count == 0) { TryRemoveSearchGrid(iSection); } } return success; }
public OverlappedLocation(LocationLink linkObj, LocationObj location, GridCircle circle) : base(location) { link = linkObj; gridCircle = circle; }
private bool AddLocationLinkToSectionSearchGrids(LocationObj AObj, LocationObj BObj, LocationLink linkView) { int minSection = AObj.Section < BObj.Section ? AObj.Section : BObj.Section; int maxSection = AObj.Section < BObj.Section ? BObj.Section : AObj.Section; GridLineSegment lineSegment = new GridLineSegment(AObj.VolumePosition, BObj.VolumePosition); bool success = false; //Add a grid line segment to each section the link intersects for (int iSection = minSection; iSection <= maxSection; iSection++) { //TODO: Check for missing sections! if (parent.Section.VolumeViewModel.SectionViewModels.ContainsKey(iSection) == false) continue; //int EstimatedLinks = Store.Locations.GetObjectsForSection(iSection).Count; //if (EstimatedLinks < 2000) int EstimatedLinks = 2500; LineSearchGrid<LocationLink> searchGrid = GetOrAddSearchGrid(iSection, EstimatedLinks); // Debug.WriteLine(iSection.ToString() + " add : " + linkView.ToString() + " " + searchGrid.Count.ToString()); //Debug.Assert(false == searchGrid.Contains(linkView)); bool sectionSuccess = searchGrid.TryAdd(lineSegment, linkView); success = success || sectionSuccess; //I had this on one line, but short-circuit logic had me beating my head against the wall for too long //Debug.Assert(success); } return success; }