//convHull can be either corrected input set, or existing convex hull List <ClientClusterable> GetBadgeList(List <Point> convHull) { var res = new List <ClientClusterable>(_doc.GetShapes().Count() / 2); var badges = _doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.Badge); foreach (IVdShape b in badges) { var clusterable = ((VdBadge)b).GetClusterable(); if (clusterable.Busy) { continue; } //if badge is in cluster and it's not in this cluster, ignore it if (clusterable.IsInCluster() && clusterable.ClusterId != Id()) { continue; } //if (!CoarseHitTest(clusterable)) // continue; if (ShapeUtils.FuzzyInside(clusterable.GetBounds(), convHull)) { res.Add(clusterable); } } return(res); }
/// <summary> /// call this when /// 1. user removes contact points so that local cursor needs to be removed /// 2. palette owner changes and we invalidate previous cursor /// </summary> /// <param name="ownId"></param> public void BeginFreeCursor(bool supressClusterMoveEvent) { //if currently we hold cursor on shape, remove it var ownedSh = DocTools.CursorOwnerToShape(_palette.GetOwnerId(), _doc.GetShapes()); if (ownedSh != null && ownedSh.GetCursor() != null) { _rt.clienRt.SendCursorRequest(false, _palette.GetOwnerId(), ownedSh.Id(), _doc.TopicId); if (_movementDetected) { if (ownedSh is VdBadge) { _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.BadgeMoved, ownedSh.GetCursor().OwnerId, _doc.DiscussionId, _doc.TopicId, Discussions.model.DeviceType.Wpf); } else if (!supressClusterMoveEvent && ownedSh is VdCluster) { _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.ClusterMoved, ownedSh.GetCursor().OwnerId, _doc.DiscussionId, _doc.TopicId, Discussions.model.DeviceType.Wpf); } else if (ownedSh is VdFreeForm) { _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.FreeDrawingMoved, ownedSh.GetCursor().OwnerId, _doc.DiscussionId, _doc.TopicId, Discussions.model.DeviceType.Wpf); } } if (_resizeDetected) { if (ownedSh is VdFreeForm) { _rt.clienRt.SendStatsEvent(Discussions.model.StEvent.FreeDrawingResize, ownedSh.GetCursor().OwnerId, _doc.DiscussionId, _doc.TopicId, Discussions.model.DeviceType.Wpf); } } _localCursorShape = null; if (localCursorChanged != null) { localCursorChanged(this); } } _movementDetected = false; _resizeDetected = false; }
//if we have editing permission for all own shapes, we can clear them all public void RemoveOwnShapes(int owner) { var ownShapes = _doc.GetShapes().Where(sh => sh.InitialOwner() == owner && sh.ShapeCode() != VdShapeType.Badge); foreach (var s in ownShapes) { if (!editingPermission(s)) { MessageBox.Show("To delete your shapes, wait until all your shapes are free of user cursors", "No permission", MessageBoxButton.OK, MessageBoxImage.Error); return; } } _doc.BeginClearShapesOfOwner(); }
private static IVdShape NearestShape(VdDocument doc, Point point) { IVdShape res = null; double minDist = double.MaxValue; foreach (var sh in doc.GetShapes()) { if (!sh.IsVisible()) { continue; } if (sh.ShapeCode() == VdShapeType.Badge) { continue; } double d_i = sh.distToFigure(point); if (sh.ShapeCode() == VdShapeType.Arrow) { d_i /= 2.0; } if (d_i < minDist) { minDist = d_i; res = sh; } } const double MAX_NEIGHBOURHOOD = 70; if (minDist > MAX_NEIGHBOURHOOD) { res = null; } return(res); }
static IVdShape NearestShape(VdDocument doc, Point point) { IVdShape res = null; double minDist = double.MaxValue; foreach (var sh in doc.GetShapes()) { double d_i = sh.distToFigure(point); if (d_i < minDist) { minDist = d_i; res = sh; } } const double MAX_NEIGHBOURHOOD = 150; if (minDist > MAX_NEIGHBOURHOOD) { res = null; } return(res); }