Exemplo n.º 1
0
        void StartMove(Pt p)
        {
            _moving = true;
            StroqSel ss = Selected.Contents as StroqSel;

            if (ss != null && ss.AllStroqs.Count > 10)
            {
                _movingLock = _mrec.BatchEdit();
            }
            Selected.Contents.StartMove(p);
            inqCanvas.Stroqs.Remove(Selected.Contents.Outline);
        }
Exemplo n.º 2
0
        private void DoLassoSelect(Stroq stroq)
        {
            StroqCollection stqs = _mathStroqs.HitTest(stroq, 50);

            Deselect();
            stroq.BackingStroke.DrawingAttributes.Color = Colors.Purple;
            Selected.Contents = new StroqSel(stqs, stroq, (Stroq s) => _mrec.Charreco.Classification(_mrec.Sim[s]),
                                             (Recognition r) => _mrec.Sim[r.strokes], inqCanvas.Stroqs);
            StroqSel Sel = (StroqSel)Selected.Contents;
            HashSet <Recognition> recogs = new HashSet <Recognition>(Sel.AllStroqs.Select((Stroq s) => _mrec.Charreco.Classification(_mrec.Sim[s]))
                                                                     .Where((Recognition r) => r != null));

            if (recogs.Count != 0)
            {
                showSidebarAlts(recogs, Sel.AllStroqs);
            }
        }
Exemplo n.º 3
0
        private bool LassoSelect(Stroq stroq)
        {
            if (stroq.OldPolylineCusps().Length <= 4 && stroq.Count > 4)
            {
                Stroq estroq            = stroq;
                CuspDetector.CuspSet cs = CuspDetector.FeaturePoints(estroq);

                Pt[] first = new Pt[cs.pts.Count / 2];
                for (int i = 0; i < first.Length; i++)
                {
                    if (cs.distances[i] > cs.dist / 2)
                    {
                        break;
                    }
                    else
                    {
                        first[i] = cs.pts[i];
                    }
                }
                Pt[] second = new Pt[cs.pts.Count - first.Length];
                for (int j = 0; j < second.Length; j++)
                {
                    second[j] = cs.pts[first.Length + j];
                }
                Stroq s1 = new Stroq(first);
                Stroq s2 = new Stroq(second);
                float d1, d2;
                s1.OldNearestPoint(s2[-1], out d1);
                s2.OldNearestPoint(s1[0], out d2);
                if (Math.Min(d1, d2) / Math.Max(estroq.GetBounds().Width, estroq.GetBounds().Height) < 0.3f)
                {
                    StroqCollection stqs  = _mathStroqs.HitTest(estroq, 50);
                    StroqCollection stqs2 = _mathStroqs.HitTest(estroq.Reverse1(), 50);
                    if (stqs2.Count > stqs.Count)
                    {
                        stqs = stqs2;
                    }
                    stqs.Remove(estroq);
                    StroqCollection stqs3 = new StroqCollection(stqs.Where((Stroq s) => _mrec.Charreco.Classification(_mrec.Sim[s]) != null));
                    stqs = stqs3;
                    Recognition rtemp = _mrec.ClassifyOneTemp(estroq);
                    if (stqs.Count > 0 && (rtemp == null || !rtemp.alts.Contains(new Recognition.Result(Unicode.S.SQUARE_ROOT))))
                    {
                        if (rtemp != null)
                        {
                            Console.WriteLine("select recognized for " + rtemp.allograph);
                        }

                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            Deselect();
                            stroq.BackingStroke.DrawingAttributes.Color = Colors.Purple;
                            Selected.Contents = new StroqSel(stqs, stroq, (Stroq s) => _mrec.Charreco.Classification(_mrec.Sim[s]),
                                                             (Recognition r) => _mrec.Sim[r.strokes], inqCanvas.Stroqs);
                            StroqSel Sel = (StroqSel)Selected.Contents;
                            HashSet <Recognition> recogs = new HashSet <Recognition>(Sel.AllStroqs.Select((Stroq s) => _mrec.Charreco.Classification(_mrec.Sim[s]))
                                                                                     .Where((Recognition r) => r != null));
                            if (recogs.Count != 0)
                            {
                                showSidebarAlts(recogs, Sel.AllStroqs);
                            }
                        }));

                        return(true);
                    }
                    else
                    {
                        // Generic additional selections would be called here.
                        return(false);
                    }
                }
            }
            return(false);
        }