Ejemplo n.º 1
0
 public VdBadge(System.IO.BinaryReader r, int owner, int shapeId, int argPtId) :
     base(owner, shapeId)
 {
     _argPtId  = argPtId;
     _endpoint = new ClientClusterable(shapeId, boundsProvider);
     init(DaoUtils.UserIdToColor(owner));
 }
Ejemplo n.º 2
0
 //called only locally
 private void onClusterUncluster(ClientCluster cluster,
                                 ClientClusterable badge,
                                 bool plus, bool playImmidiately)
 {
     if (plus)
     {
         //cluster must exist
         clusterRebuildPending = true;
         _rt.clienRt.SendClusterBadgeRequest(badge.GetId(),
                                             cluster.GetId(),
                                             _palette.GetOwnerId(),
                                             TopicId,
                                             playImmidiately,
                                             -1);
     }
     else
     {
         //server checks if affected clsuter is empty
         clusterRebuildPending = true;
         _rt.clienRt.SendUnclusterBadgeRequest(badge.GetId(),
                                               cluster.GetId(),
                                               TopicId,
                                               _palette.GetOwnerId(),
                                               playImmidiately,
                                               -1);
     }
 }
Ejemplo n.º 3
0
 public VdBadge(System.IO.BinaryReader r, int owner, int shapeId, int argPtId):
     base(owner, shapeId)
 {
     _argPtId = argPtId;
     _endpoint = new ClientClusterable(shapeId, boundsProvider);
     init(DaoUtils.UserIdToColor(owner));
 }
Ejemplo n.º 4
0
 public VdBadge(double x, double y, int owner, int shapeId, int argPtId) :
     base(owner, shapeId)
 {
     _argPtId  = argPtId;
     _endpoint = new ClientClusterable(shapeId, boundsProvider);
     init(DaoUtils.UserIdToColor(owner));
     setBadgePos(x, y);
 }
Ejemplo n.º 5
0
 public VdBadge(double x, double y, int owner, int shapeId, int argPtId):
     base(owner, shapeId)
 {
     _argPtId = argPtId;
     _endpoint = new ClientClusterable(shapeId, boundsProvider);
     init(DaoUtils.UserIdToColor(owner));
     setBadgePos(x, y);    
 }
Ejemplo n.º 6
0
        public void Add(ClientClusterable badge)
        {
            if (_badges.Contains(badge))
            {
                throw new NotSupportedException("duplicate cluster entry");
            }

            _badges.Add(badge);
            badge.Cluster(GetId());
        }
Ejemplo n.º 7
0
        public void Add(ClientClusterable badge)
        {
            if (_badges.Contains(badge))
            {
                throw new NotSupportedException("duplicate cluster entry");
            }

            _badges.Add(badge);
            badge.Cluster(GetId());
        }
Ejemplo n.º 8
0
        //returns true if badge is probably inside cluster.
        //returns false if badge cannot be inside
        bool CoarseHitTest(ClientClusterable badge)
        {
            if (bezierBorder.Data == null)
            {
                return(true);
            }

            var borders = bezierBorder.Data.Bounds;

            borders.Offset(_offset.X, _offset.Y);

            return(borders.IntersectsWith(badge.GetBounds()));
        }
Ejemplo n.º 9
0
 //called only locally
 void onClusterUncluster(ClientCluster cluster,
                         ClientClusterable badge,
                         bool plus, bool playImmidiately)
 {
     if (plus)
     {
         //cluster must exist      
         clusterRebuildPending = true;
         _rt.clienRt.SendClusterBadgeRequest(badge.GetId(), 
                                             cluster.GetId(),
                                             _palette.GetOwnerId(),
                                             TopicId,
                                             playImmidiately,
                                             -1);
     }
     else
     {
         //server checks if affected clsuter is empty     
         clusterRebuildPending = true;
         _rt.clienRt.SendUnclusterBadgeRequest(badge.GetId(), 
                                              cluster.GetId(),                                                      
                                              TopicId, 
                                              _palette.GetOwnerId(),
                                              playImmidiately,
                                              -1);
     }             
 }
Ejemplo n.º 10
0
 public void Remove(ClientClusterable badge)
 {
     _badges.Remove(badge);
     badge.Uncluster();
 }
Ejemplo n.º 11
0
        //returns true if badge is probably inside cluster.
        //returns false if badge cannot be inside
        private bool CoarseHitTest(ClientClusterable badge)
        {
            if (bezierBorder.Data == null)
                return true;

            var borders = bezierBorder.Data.Bounds;
            borders.Offset(_offset.X, _offset.Y);

            return borders.IntersectsWith(badge.GetBounds());
        }
Ejemplo n.º 12
0
        //PRODUCER
        //if badge is not in any cluster and new bounds are fuzzily inside the cluster, then include
        //the badge into the cluster and rebuild cluster hull
        public void ClusterableMoved(ClientClusterable badge)
        {
            if (badge.Busy)
                return;

            //hull doesn't exist
            if (convexHull.Points.Count <= 2)
                return;

            var contents = GetBadgeList(convexHull.Points.ToList());
            var added = contents.Except(_endpoint.GetClusterables());
            var removed = _endpoint.GetClusterables().Except(contents);
            foreach (var a in added)
            {
                if (a.Busy)
                    continue;

                if (a.IsInCluster())
                    continue;

                a.SetBusy();
                _onClusterUncluster(GetCluster(), a, true, /*a == added.Last()*/true);
            }
            foreach (var r in removed)
            {
                if (r.Busy)
                    continue;

                if (!r.IsInCluster())
                    continue;

                r.SetBusy();
                _onClusterUncluster(GetCluster(), r, false, /*r == removed.Last()*/true);
            }

            ////moved shape is in cluster, but not in our one
            //if (badge.IsInCluster() && badge.ClusterId!= Id())
            //    return;

            ////if (!CoarseHitTest(badge))
            ////    return;

            //var willBeInTheCluster = ShapeUtils.FuzzyInside(badge.GetBounds(), convexHull.Points.ToList());
            //var nowInTheCluster = badge.ClusterId == Id();

            ////send cluster edit operation
            //if (nowInTheCluster && !willBeInTheCluster)
            //{
            //    badge.SetBusy();
            //    _onClusterUncluster(GetCluster(), badge, true, true);
            //}
            //else if (!nowInTheCluster && willBeInTheCluster)
            //{
            //    badge.SetBusy();
            //    _onClusterUncluster(GetCluster(), badge, false, true);
            //}

            //if (nowInTheCluster != willBeInTheCluster)
            //{
            //    badge.SetBusy();
            //    var contents = GetBadgeList(convexHull.Points.ToList());

            //    var added = contents.Except(_endpoint.GetClusterables());
            //    var removed = _endpoint.GetClusterables().Except(contents);

            //    foreach (var a in added)
            //    {
            //        _onClusterUncluster(GetCluster(), a, true, true);
            //    }
            //    foreach (var r in removed)
            //        _onClusterUncluster( GetCluster(), r, false, true);
            //}
        }
Ejemplo n.º 13
0
        //PRODUCER
        //if badge is not in any cluster and new bounds are fuzzily inside the cluster, then include
        //the badge into the cluster and rebuild cluster hull
        public void ClusterableMoved(ClientClusterable badge)
        {
            if (badge.Busy)
            {
                return;
            }

            //hull doesn't exist
            if (convexHull.Points.Count <= 2)
            {
                return;
            }

            var contents = GetBadgeList(convexHull.Points.ToList());
            var added    = contents.Except(_endpoint.GetClusterables());
            var removed  = _endpoint.GetClusterables().Except(contents);

            foreach (var a in added)
            {
                if (a.Busy)
                {
                    continue;
                }

                if (a.IsInCluster())
                {
                    continue;
                }

                a.SetBusy();
                _onClusterUncluster(GetCluster(), a, true, /*a == added.Last()*/ true);
            }
            foreach (var r in removed)
            {
                if (r.Busy)
                {
                    continue;
                }

                if (!r.IsInCluster())
                {
                    continue;
                }

                r.SetBusy();
                _onClusterUncluster(GetCluster(), r, false, /*r == removed.Last()*/ true);
            }

            ////moved shape is in cluster, but not in our one
            //if (badge.IsInCluster() && badge.ClusterId!= Id())
            //    return;

            ////if (!CoarseHitTest(badge))
            ////    return;

            //var willBeInTheCluster = ShapeUtils.FuzzyInside(badge.GetBounds(), convexHull.Points.ToList());
            //var nowInTheCluster = badge.ClusterId == Id();

            ////send cluster edit operation
            //if (nowInTheCluster && !willBeInTheCluster)
            //{
            //    badge.SetBusy();
            //    _onClusterUncluster(GetCluster(), badge, true, true);
            //}
            //else if (!nowInTheCluster && willBeInTheCluster)
            //{
            //    badge.SetBusy();
            //    _onClusterUncluster(GetCluster(), badge, false, true);
            //}

            //if (nowInTheCluster != willBeInTheCluster)
            //{
            //    badge.SetBusy();
            //    var contents = GetBadgeList(convexHull.Points.ToList());

            //    var added = contents.Except(_endpoint.GetClusterables());
            //    var removed = _endpoint.GetClusterables().Except(contents);

            //    foreach (var a in added)
            //    {
            //        _onClusterUncluster(GetCluster(), a, true, true);
            //    }
            //    foreach (var r in removed)
            //        _onClusterUncluster( GetCluster(), r, false, true);
            //}
        }
Ejemplo n.º 14
0
 public void Remove(ClientClusterable badge)
 {
     _badges.Remove(badge);
     badge.Uncluster();
 }