public static float OldNearestPoint(this Stroq s, Pt p, out float dist) { float tval = s.OldStroke().NearestPoint(new Point((int)(p.X * OldStrokeStuff.Scale + 0.5), (int)(p.Y * OldStrokeStuff.Scale + 0.5)), out dist); dist /= (float)OldStrokeStuff.Scale; return(tval); }
public static Microsoft.Ink.Stroke TheStroke(Stroq s) { object val; Cache c = s.Property.TryGetValue(CacheGuid, out val) ? (Cache)val : new Cache(s); return(c.Cached()); }
public void Consume(Stroq stroq) { Rect bb = stroq.BoundingRect; double w = bb.Width/LineGraphCanvas.ActualWidth; double x = bb.X/LineGraphCanvas.ActualWidth; OnSelectionChange(x, x + w); }
public Cache(Stroq sq) { _owner = sq; _owner.PointChanged += (s, ix) => _dirty = true; _owner.PointsCleared += (s) => _dirty = true; _owner.PointsModified += (s, m) => _dirty = true; }
private bool ScribbleDelete(Stroq stroq, out StroqCollection erasedStroqs) { bool canBeScribble = stroq.OldPolylineCusps().Length > 4; if (stroq.OldPolylineCusps().Length == 4) { int[] pcusps = stroq.OldPolylineCusps(); Deg a1 = fpdangle(stroq[0], stroq[pcusps[1]], stroq[pcusps[2]] - stroq[pcusps[1]]); Deg a2 = fpdangle(stroq[pcusps[1]], stroq[pcusps[1]], stroq[pcusps[3]] - stroq[pcusps[1]]); if (a1 < 35 && a2 < 35) { canBeScribble = stroq.BackingStroke.HitTest(stroq.ConvexHull().First(), 1); } } if (canBeScribble) { IEnumerable <Pt> hull = stroq.ConvexHull(); StroqCollection stqs = inqCanvas.Stroqs.HitTest(hull, 1); if (stqs.Count > 1) { inqCanvas.Stroqs.Remove(stqs); erasedStroqs = stqs; inqCanvas.Stroqs.Remove(stroq); return(true); } } erasedStroqs = null; return(false); }
public XyAxis(Rect rect) { _rect = rect; _stroq = new Stroq(); _stroq.Points.Add(new Point(rect.X, rect.Y)); _stroq.Points.Add(new Point(rect.X, rect.Y + rect.Height)); _stroq.Points.Add(new Point(rect.X + rect.Width, rect.Y + rect.Height)); _hotspots = new Dictionary<XyAxisLabelPosition, Rect>(); int maxDelta = 100; int nw = (int) _rect.Width/3; int nh = (int) _rect.Height/3; var ytop = new Rect(_rect.X - maxDelta, _rect.Y, nw, nh); var ycenter = new Rect(_rect.X - maxDelta, _rect.Y + nh, nw, nh); var ybottom = new Rect(_rect.X - maxDelta, _rect.Y + nh*2, nw, nh); var xleft = new Rect(_rect.X, _rect.Y + _rect.Height, nw, nh); var xcenter = new Rect(_rect.X + nw, _rect.Y + _rect.Height, nw, nh); var xright = new Rect(_rect.X + nw*2, _rect.Y + _rect.Height, nw, nh); _hotspots[XyAxisLabelPosition.Y_Top] = ytop; _hotspots[XyAxisLabelPosition.Y_Center] = ycenter; _hotspots[XyAxisLabelPosition.Y_Bottom] = ybottom; _hotspots[XyAxisLabelPosition.X_Left] = xleft; _hotspots[XyAxisLabelPosition.X_Center] = xcenter; _hotspots[XyAxisLabelPosition.X_Right] = xright; }
private bool IsLassoSelect(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); } return(true); } else { // Generic additional selections would be called here. return(false); } } } return(false); }
public static bool GeometryContains(Geometry hull, Stroq s) { for (int i = 0; i < s.Count(); i++) { if (!hull.FillContains(s[i])) { return(false); } } return(true); }
/// <summary> /// Only to be called if you don't want the result cached, otherwise do stroq.OldStroke(). /// </summary> public static Stroke Convert(Stroq ins, Ink ink) { if (ink == null) { ink = new Ink(); } return(ink.CreateStroke(ins.Select((p) => { Vec r = ((Vec)p) * Scale; return new System.Drawing.Point((int)(r.X + 0.5), (int)(r.Y + 0.5)); }).ToArray())); }
public IList<IGesture> Recognize(Stroq stroq) { var result = new List<IGesture>(); foreach (IGesture gesture in _gestures) { if (gesture.Recognize(stroq)) { result.Add(gesture); return result; } } return result; }
public bool Recognize(Stroq stroq) { _stroq = stroq; _bb = stroq.BoundingRect; if (_bb.Width < 120 || _bb.Height < 120) return false; var left = new Stroq(); var right = new Stroq(); stroq.SplitTrBl(out left, out right); Vector2 rightLine = MathUtil.ApproximateLine(right.Points, true).GetDirection(); Vector2 leftLine = MathUtil.ApproximateLine(left.Points, true).GetDirection(); return leftLine.Dot(rightLine) < 0.3; }
/// <summary> /// Note: this should be expected to be significantly slower because it has to convert all the strokes into the same Ink before it can /// run the old FindIntersections(). /// </summary> public static float[] OldFindIntersections(this Stroq s, StroqCollection ss) { Stroke oldStroke = s.OldStroke(); Ink ink = oldStroke.Ink; List <int> ids = new List <int>(); foreach (Stroq st in ss) { if (st != s) { ids.Add(st.OldStroke(ink).Id); } } return(oldStroke.FindIntersections(ink.CreateStrokes(ids.ToArray()))); }
/// <summary> /// Create a selection of inq strokes /// </summary> /// <param name="contents">The set of stroqs to be selected.</param> /// <param name="outline">The outline to be used for the selection; can be null.</param> /// <param name="stroq2char">Delegate taking a Stroq as input and returns the (character) Recognition record the stroke is a part of.</param> /// <param name="char2stroqs">Given a Recognition, return the Stroqs that compose it.</param> /// <param name="dispstrs">A StroqCollection controlling what Stroqs are displayed; the outline is automatically removed from here on deselection. /// Can be null.</param> public StroqSel(IEnumerable<Stroq> contents, Stroq outline, Func<Stroq, Recognition> stroq2char, Func<Recognition, IEnumerable<Stroq>> char2stroqs, StroqCollection dispstrs) { // sc would be Charreco.Classification(s); sqs the mapping of r.strokes AllStroqs = new StroqCollection(contents); Outline = outline; ReRecStroqs = new StroqCollection(); HashSet<Stroq> additional = new HashSet<Stroq>(); foreach (Stroq ss in AllStroqs) { Recognition r = stroq2char(ss); if (r == null || r.levelsetby != 0) ReRecStroqs.Add(ss); else additional.UnionWith(char2stroqs(r)); } AllStroqs.Add(additional); _displayedStrokes = dispstrs; }
public void Consume(Stroq stroq) { Point pos = stroq.BackingStroke.GetRenderingSegments().Last().Position; int index = PointToConstraintIndex(new Point(pos.X, pos.Y)); IEnumerable<PieSlice> existingSlices = _selectedSlices.Where(x => x.Index == index); if (existingSlices.Count() > 0) { _selectedSlices.Remove(existingSlices.ElementAt(0)); } else { _selectedSlices.Add(_availableSlices[index]); } Update(); OnSelectionChange(this, _availableSlices[index]); }
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); } }
private void StroqChanged(Stroq s) { if (StrokesDeleting != null) { StrokesDeleting(Ink.CreateStrokes(new int[] { this[s].Id })); } _map2.Remove(_map[s].Id); _ink.DeleteStroke(_map[s]); Stroke st = s.OldStroke(Ink); _map[s] = st; _map2.Add(st.Id, s); if (StrokesAdded != null) { StrokesAdded(Ink.CreateStrokes(new int[] { st.Id })); } }
/// <summary> /// Create a selection of inq strokes /// </summary> /// <param name="contents">The set of stroqs to be selected.</param> /// <param name="outline">The outline to be used for the selection; can be null.</param> /// <param name="stroq2char">Delegate taking a Stroq as input and returns the (character) Recognition record the stroke is a part of.</param> /// <param name="char2stroqs">Given a Recognition, return the Stroqs that compose it.</param> /// <param name="dispstrs">A StroqCollection controlling what Stroqs are displayed; the outline is automatically removed from here on deselection. /// Can be null.</param> public StroqSel(IEnumerable <Stroq> contents, Stroq outline, Func <Stroq, Recognition> stroq2char, Func <Recognition, IEnumerable <Stroq> > char2stroqs, StroqCollection dispstrs) // sc would be Charreco.Classification(s); sqs the mapping of r.strokes { AllStroqs = new StroqCollection(contents); Outline = outline; ReRecStroqs = new StroqCollection(); HashSet <Stroq> additional = new HashSet <Stroq>(); foreach (Stroq ss in AllStroqs) { Recognition r = stroq2char(ss); if (r == null || r.levelsetby != 0) { ReRecStroqs.Add(ss); } else { additional.UnionWith(char2stroqs(r)); } } AllStroqs.Add(additional); _displayedStrokes = dispstrs; }
private void StroqChanged(Stroq s, Mat?m) { if (!m.HasValue) { StroqChanged(s); } else { Stroke ms = _map[s]; System.Drawing.Drawing2D.Matrix mm = new System.Drawing.Drawing2D.Matrix( (float)m.Value[0, 0], (float)m.Value[0, 1], (float)m.Value[1, 0], (float)m.Value[1, 1], (float)(m.Value[0, 2] * OldStrokeStuff.Scale), (float)(m.Value[1, 2] * OldStrokeStuff.Scale)); ms.Transform(mm); if (StrokeTransformed != null) { StrokeTransformed(ms, mm); } } }
public static Stroke OldStroke(this Stroq s, Ink ink) { return(OldStrokeStuff.Convert(s, ink)); }
public static Stroke OldStroke(this Stroq s) { return(OldStrokeStuff.TheStroke(s)); }
private bool LassoSelect(InqCanvas.StroqCollectedEventArgs e) { if (e.Stroq.OldPolylineCusps().Length <= 4 && e.Stroq.Count > 4) { Stroq estroq = e.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); Deselect(); estroq.BackingStroke.DrawingAttributes.Color = Colors.Purple; Selected.Contents = new StroqSel(stqs, estroq, (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; }
public void AfterClone(Stroq oldStroq, Stroq newStroq) { _owner = newStroq; }
public static float OldNearestPoint(this Stroq s, Pt p) { return(s.OldStroke().NearestPoint(new Point((int)(p.X * OldStrokeStuff.Scale + 0.5), (int)(p.Y * OldStrokeStuff.Scale + 0.5)))); }
void IPassable.StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e) { //Probably need to change the stroke to the coordinates of this canvas e.Stroke.DrawingAttributes.Color = Colors.Red; //inqCanvas.Stroqs.Add(e.Stroke); Matrix m = new Matrix(); m.Translate(-UserControlX, -UserControlY); m.Scale(1 / UserControlScaleX, 1 / UserControlScaleY); e.Stroke.Transform(m, false); Stroq stroq = new Stroq(e.Stroke); inqCanvas.Stroqs.Add(stroq); /* If we get here, it's a real stroke (not movement), so deselect any selection */ Deselect(); /* check for scribble delete */ if (ScribbleDelete(stroq)) return; /* check for lassos/circles around stuff */ if (LassoSelect(stroq)) return; _mathStroqs.Add(stroq); }
public void OnPointerReleased(object sender, PointerRoutedEventArgs e) { if (!_isPointerPressed) { e.Handled = true; return; } Children.Clear(); PointerPoint pt = e.GetCurrentPoint(this); _inkManager.ProcessPointerUp(pt); _currentStroq.Points.Add(new Point(pt.Position.X, pt.Position.Y)); Rect inqBounds = _currentStroq.BoundingRect; foreach (IInqConsumer consumer in _inqConsumers.ToList()) { GeneralTransform g = consumer.Element.TransformToVisual(this); Point p = g.TransformPoint(new Point(0, 0)); Rect r = g.TransformBounds(new Rect(0, 0, consumer.Element.ActualWidth, consumer.Element.ActualHeight)); r.Intersect(inqBounds); if (!r.IsEmpty) { InkStroke first = _inkManager.GetStrokes().First(); first.Selected = true; _inkManager.MoveSelected(new Point(-p.X, -p.Y)); IReadOnlyList<InkStroke> inkStrokes = _inkManager.GetStrokes(); if (inkStrokes.Count != 1) throw new Exception("InkManager must exactly one stroke at the time."); _currentStroq.BackingStroke = inkStrokes.First().Clone(); if (_currentStroq.BackingStroke == null) { Debug.WriteLine("should not be null!"); } consumer.Consume(_currentStroq.GetTranslated(new Point(-p.X, -p.Y))); first.Selected = false; } } _currentStroq = null; _inkManager.DeleteAll(); Children.Clear(); _isPointerPressed = false; e.Handled = true; }
public Stroke this[Stroq s] { get { return(_map[s]); } }
public static IEnumerable <Pt> OldGetFlattenedBezierPoints(this Stroq s) { return(s.OldStroke().GetFlattenedBezierPoints().Select((Point p) => new Pt(p.X / OldStrokeStuff.Scale, p.Y / OldStrokeStuff.Scale))); }
public virtual void Consume( Stroq stroke ) { // Do nothing by default. }
public static int[] OldPolylineCusps(this Stroq s) { return(s.OldStroke().PolylineCusps); }
private bool ScribbleDelete(Stroq stroq) { bool canBeScribble = stroq.OldPolylineCusps().Length > 4; if (stroq.OldPolylineCusps().Length == 4) { int[] pcusps = stroq.OldPolylineCusps(); Deg a1 = fpdangle(stroq[0], stroq[pcusps[1]], stroq[pcusps[2]] - stroq[pcusps[1]]); Deg a2 = fpdangle(stroq[pcusps[1]], stroq[pcusps[1]], stroq[pcusps[3]] - stroq[pcusps[1]]); if (a1 < 35 && a2 < 35) canBeScribble = stroq.BackingStroke.HitTest(stroq.ConvexHull().First(), 1); } if (canBeScribble) { IEnumerable<Pt> hull = stroq.ConvexHull(); StroqCollection stqs = inqCanvas.Stroqs.HitTest(hull, 1); if (stqs.Count > 1) { inqCanvas.Stroqs.Remove(stqs); _mathStroqs.Remove(stqs); inqCanvas.Stroqs.Remove(stroq); return true; } } return false; }
public void OnPointerPressed(object sender, PointerRoutedEventArgs e) { Children.Clear(); _isPointerPressed = true; _inkManager.DeleteAll(); _currentStroq = new Stroq(); PointerPoint pt = e.GetCurrentPoint(this); _previousContactPt = pt.Position; _inkManager.ProcessPointerDown(pt); _currentStroq.Points.Add(new Point(pt.Position.X, pt.Position.Y)); e.Handled = true; }
public void Consume(Stroq stroq) { if (stroq.BoundingRect.Width < 5) return; stroq.Translate(new Point(-60, 0)); IList<IGesture> recognizedGestures = _gesturizer.Recognize(stroq); foreach (IGesture recognizedGesture in recognizedGestures) { if (recognizedGesture is ScribbleGesture) { foreach (Stroq hitStroq in _scribbleGesture.HitStroqs) { LineConstraintRange r; _stroqRangeMapping.TryGetValue(hitStroq, out r); if (r != null) { Ranges.Remove(r); if (_rangeTxtMapping.ContainsKey(r)) { Canvas.Children.Remove(_rangeTxtMapping[r]); _rangeTxtMapping.Remove(r); } _stroqRangeMapping.Remove(hitStroq); } _scribbleGesture.StroqsToCheck.Remove(hitStroq); DrawRanges(); OnLineConstraintChange(this); } return; } } Rect bb = stroq.BoundingRect; double rangeMin = MathUtil.Clamp(0, 1, bb.X/(Canvas.ActualWidth)); double rangeMax = MathUtil.Clamp(0, 1, (bb.X + bb.Width)/(Canvas.ActualWidth)); foreach (LineConstraintRange r in Ranges.ToList()) { if ((r.Min <= rangeMax && r.Max >= rangeMax) || (r.Max >= rangeMin && r.Min <= rangeMin) || (r.Min >= rangeMin && r.Max <= rangeMax)) { Ranges.Remove(r); if (_rangeTxtMapping.ContainsKey(r)) { Canvas.Children.Remove(_rangeTxtMapping[r]); _rangeTxtMapping.Remove(r); } _stroqRangeMapping.Remove(r._stroq); _scribbleGesture.StroqsToCheck.Remove(r._stroq); } } var range = new LineConstraintRange(rangeMin, rangeMax); Ranges.Add(range); double w = (range.Max - range.Min)*Canvas.ActualWidth; var s = new Stroq(); s.Points.Add(new Point(range.Min*Canvas.ActualWidth, Canvas.ActualHeight/2)); s.Points.Add(new Point(range.Min*Canvas.ActualWidth + w, Canvas.ActualHeight/2)); range._stroq = s; _scribbleGesture.StroqsToCheck.Add(s); _stroqRangeMapping.Add(s, range); DrawRanges(); OnLineConstraintChange(this); }
public async void Consume(Stroq stroq) { stroq.ClipTo(new Rect(0, 0, ActualWidth, ActualHeight)); _scribbleGesture.StroqsToCheck = _stroqs.ToList(); IList<IGesture> recognizedGestures = _gesturizer.Recognize(stroq.Clone()); foreach (IGesture recognizedGesture in recognizedGestures.ToList()) { if (recognizedGesture is ScribbleGesture) { foreach (Stroq hitStroq in _scribbleGesture.HitStroqs) { _stroqs.Remove(hitStroq); _textStroqs.Remove(hitStroq); if (_textStroqs.Count == 0) { _queryStrings.Clear(); OnTextChange(this); _axisAnnotations.Clear(); } foreach (Stroq queryStroq in _queryStroqs.ToList()) { if (hitStroq == queryStroq) _queryStroqs.Remove(queryStroq); } if (_xyAxis != null && hitStroq == _xyAxis.Stroq) { _xyAxis = null; _axisAnnotations.Clear(); OnAxisChange(this); } } continue; } if (recognizedGesture is XyAxisGesture && _xyAxis != null) { recognizedGestures.Remove(recognizedGesture); } if (recognizedGesture is XyAxisGesture && _xyAxis == null) { var axisGesture = (XyAxisGesture) recognizedGesture; _xyAxis = new XyAxis(axisGesture.BoundingRect); _stroqs.Add(_xyAxis.Stroq); OnAxisChange(this); foreach (Rect hotspot in _xyAxis._hotspots.Values) { var r = new Rectangle(); r.Width = hotspot.Width; r.Height = hotspot.Height; r.Fill = new SolidColorBrush(Colors.Red); Children.Add(r); SetLeft(r, hotspot.X); SetTop(r, hotspot.Y); } } } if (recognizedGestures.Count == 0) { if (_xyAxis != null) { Rect stroqBB = stroq.BoundingRect.Clone(); stroqBB.Intersect(_xyAxis.Stroq.BoundingRect); if (!stroqBB.IsEmpty && stroqBB.Area()/stroq.BoundingRect.Area() > 0.5) { _queryStroqs.Add(stroq); OnQueryChange(this); } } _stroqs.Add(stroq); _textStroqs.Add(stroq); } Redraw(); IList<InkRecognitionResult> result = await _textRecognizer.Recognize(_textStroqs); _queryStrings.Clear(); foreach (InkRecognitionResult inkRecognitionResult in result) { IReadOnlyList<string> candidates = inkRecognitionResult.GetTextCandidates(); if (_xyAxis != null) { XyAxisLabelPosition axisAnnotationPosition = _xyAxis.GetLabelPosition(inkRecognitionResult.BoundingRect); if (axisAnnotationPosition != XyAxisLabelPosition.None) { _axisAnnotations[axisAnnotationPosition] = ValidateText(candidates); OnAxisChange(this); } } else { _queryStrings.Add(candidates[0].ToLower()); Rect bbbb = stroq.BoundingRect; string str = ""; foreach (Point p in stroq.Points) { double x = (p.X - bbbb.X)/bbbb.Width; double y = (p.Y - bbbb.Y)/bbbb.Height; str += (x + ":" + y + ","); } } } if (_queryStrings.Count > 0) OnTextChange(this); }
public static float[] OldSelfIntersections(this Stroq s) { return(s.OldStroke().SelfIntersections); }
private void StroqChanged(Stroq s, int i) { StroqChanged(s); }
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); }