public bool Consume(InkStroke inkStroke) { GeneralTransform gt = MainViewController.Instance.InkableScene.TransformToVisual(dxSurface); List <Windows.Foundation.Point> selectionPoints = inkStroke.Points.Select(p => gt.TransformPoint(p)). GetLineString().Buffer(1).Coordinates.Select(c => c.GetWindowsPoint()).ToList(); IList <Vec> convexHull = Convexhull.convexhull(selectionPoints); IGeometry convexHullPoly = convexHull.Select(vec => new Windows.Foundation.Point(vec.X, vec.Y)).ToList().GetPolygon(); List <FilterModel> hits = new List <FilterModel>(); foreach (var geom in _plotRendererContentProvider.HitTargets.Keys) { if (convexHullPoly.Intersects(geom)) { hits.Add(_plotRendererContentProvider.HitTargets[geom]); } } if (hits.Count > 0) { foreach (var valueComparison in hits[0].ValueComparisons) { Debug.WriteLine((valueComparison.AttributeTransformationModel.AttributeModel.RawName + " " + valueComparison.Value)); } HistogramOperationModel histogramOperationModel = (HistogramOperationModel)((HistogramOperationViewModel)DataContext).OperationModel; var vcs = hits.SelectMany(h => h.ValueComparisons).ToList(); var xAom = histogramOperationModel.GetAttributeUsageTransformationModel(AttributeUsage.X).First(); var yAom = histogramOperationModel.GetAttributeUsageTransformationModel(AttributeUsage.Y).First(); if (hits.Any(h => histogramOperationModel.FilterModels.Contains(h))) { histogramOperationModel.RemoveFilterModels(hits); } else { histogramOperationModel.AddFilterModels(hits); } } else { var bczhits = new List <BczBinMapModel>(); foreach (var geom in _plotRendererContentProvider.BczHitTargets.Keys) { if (convexHullPoly.Intersects(geom)) { bczhits.Add(_plotRendererContentProvider.BczHitTargets[geom]); } } if (bczhits.Count > 0) { _plotRendererContentProvider.UpdateBinSortings(bczhits); render(); } } return(true); }
public override bool EndSelection() { IList <Vec> convexHull = Convexhull.convexhull(_selectionPoints); IGeometry convexHullPoly = convexHull.Select(vec => new Windows.Foundation.Point(vec.X, vec.Y)).ToList().GetPolygon(); List <FilterModel> hits = new List <FilterModel>(); foreach (var geom in _plotRendererContentProvider.HitTargets.Keys) { if (convexHullPoly.Intersects(geom)) { hits.Add(_plotRendererContentProvider.HitTargets[geom]); } } if (hits.Count > 0) { foreach (var valueComparison in hits[0].ValueComparisons) { Debug.WriteLine((valueComparison.AttributeTransformationModel.AttributeModel.RawName + " " + valueComparison.Value)); } HistogramOperationModel histogramOperationModel = (HistogramOperationModel)((HistogramOperationViewModel)DataContext).OperationModel; if (hits.Any(h => histogramOperationModel.FilterModels.Contains(h))) { histogramOperationModel.RemoveFilterModels(hits); } else { histogramOperationModel.AddFilterModels(hits); } return(true); } var bczhits = new List <BczBinMapModel>(); foreach (var geom in _plotRendererContentProvider.BczHitTargets.Keys) { if (convexHullPoly.Intersects(geom)) { bczhits.Add(_plotRendererContentProvider.BczHitTargets[geom]); } } if (bczhits.Count > 0) { _plotRendererContentProvider.UpdateBinSortings(bczhits); render(); return(true); } return(false); }