void PlotRenderer_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { if (args.NewValue != null) { (DataContext as HistogramOperationViewModel).OperationModel.OperationModelUpdated -= OperationModelUpdated; (DataContext as HistogramOperationViewModel).OperationModel.OperationModelUpdated += OperationModelUpdated; (DataContext as HistogramOperationViewModel).OperationModel.PropertyChanged -= OperationModel_PropertyChanged; (DataContext as HistogramOperationViewModel).OperationModel.PropertyChanged += OperationModel_PropertyChanged; var result = (DataContext as HistogramOperationViewModel).OperationModel.Result; if (result != null) { loadResult(result); render(); } else { HistogramOperationModel operationModel = (HistogramOperationModel)((OperationViewModel)DataContext).OperationModel; if (!operationModel.GetAttributeUsageTransformationModel(AttributeUsage.X).Any() && !operationModel.GetAttributeUsageTransformationModel(AttributeUsage.Y).Any()) { viewBox.Visibility = Visibility.Visible; } } } }
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); }
void OperationModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { HistogramOperationModel operationModel = (HistogramOperationModel)((OperationViewModel)DataContext).OperationModel; if (e.PropertyName == operationModel.GetPropertyName(() => operationModel.Result)) { var result = (DataContext as HistogramOperationViewModel).OperationModel.Result; if (result != null) { loadResult(result); render(); } } }
private void MainPage_KeyDown(object sender, KeyRoutedEventArgs e) { var state = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control); if ((state & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) { if (e.Key == VirtualKey.Q) { MainViewController.Instance.MainModel.SampleSize = MainViewController.Instance.MainModel.SampleSize + 100; Debug.WriteLine("SampleSize : " + MainViewController.Instance.MainModel.SampleSize); msgTextBlock.Text = "SampleSize : " + MainViewController.Instance.MainModel.SampleSize; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.A) { MainViewController.Instance.MainModel.SampleSize = Math.Max(MainViewController.Instance.MainModel.SampleSize - 100, 1.0); Debug.WriteLine("SampleSize : " + MainViewController.Instance.MainModel.SampleSize); msgTextBlock.Text = "SampleSize : " + MainViewController.Instance.MainModel.SampleSize; msgTextBlock.Opacity = 1; _messageTimer.Start(); } if (e.Key == VirtualKey.W) { MainViewController.Instance.MainModel.ThrottleInMillis = MainViewController.Instance.MainModel.ThrottleInMillis + 300.0; Debug.WriteLine("Throttle : " + MainViewController.Instance.MainModel.ThrottleInMillis); msgTextBlock.Text = "Throttle : " + MainViewController.Instance.MainModel.ThrottleInMillis; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.S) { MainViewController.Instance.MainModel.ThrottleInMillis = Math.Max(MainViewController.Instance.MainModel.ThrottleInMillis - 300.0, 0.0); Debug.WriteLine("Throttle : " + MainViewController.Instance.MainModel.ThrottleInMillis); msgTextBlock.Text = "Throttle : " + MainViewController.Instance.MainModel.ThrottleInMillis; msgTextBlock.Opacity = 1; _messageTimer.Start(); } if (e.Key == VirtualKey.E) { MainViewController.Instance.MainModel.NrOfXBins = MainViewController.Instance.MainModel.NrOfXBins + 1; Debug.WriteLine("NrOfXBins : " + MainViewController.Instance.MainModel.NrOfXBins); msgTextBlock.Text = "NrOfXBins : " + MainViewController.Instance.MainModel.NrOfXBins; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.D) { MainViewController.Instance.MainModel.NrOfXBins = Math.Max(MainViewController.Instance.MainModel.NrOfXBins - 1, 1.0); Debug.WriteLine("NrOfXBins : " + MainViewController.Instance.MainModel.NrOfXBins); msgTextBlock.Text = "NrOfXBins : " + MainViewController.Instance.MainModel.NrOfXBins; msgTextBlock.Opacity = 1; _messageTimer.Start(); } if (e.Key == VirtualKey.R) { MainViewController.Instance.MainModel.NrOfYBins = MainViewController.Instance.MainModel.NrOfYBins + 1; Debug.WriteLine("NrOfYBins : " + MainViewController.Instance.MainModel.NrOfYBins); msgTextBlock.Text = "NrOfYBins : " + MainViewController.Instance.MainModel.NrOfYBins; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.F) { MainViewController.Instance.MainModel.NrOfYBins = Math.Max(MainViewController.Instance.MainModel.NrOfYBins - 1, 1.0); Debug.WriteLine("NrOfYBins : " + MainViewController.Instance.MainModel.NrOfYBins); msgTextBlock.Text = "NrOfYBins : " + MainViewController.Instance.MainModel.NrOfYBins; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.L) { MainViewController.Instance.LoadCatalog(); } if (e.Key == VirtualKey.Number1) { MainViewController.Instance.MainModel.GraphRenderOption = GraphRenderOptions.Grid; Debug.WriteLine("GraphRenderOption : " + MainViewController.Instance.MainModel.GraphRenderOption); msgTextBlock.Text = "GraphRenderOption : " + MainViewController.Instance.MainModel.GraphRenderOption; msgTextBlock.Opacity = 1; _messageTimer.Start(); } if (e.Key == VirtualKey.Number2) { MainViewController.Instance.MainModel.GraphRenderOption = GraphRenderOptions.Cell; Debug.WriteLine("GraphRenderOption : " + MainViewController.Instance.MainModel.GraphRenderOption); msgTextBlock.Text = "GraphRenderOption : " + MainViewController.Instance.MainModel.GraphRenderOption; msgTextBlock.Opacity = 1; _messageTimer.Start(); } if (e.Key == VirtualKey.V) { MainViewController.Instance.MainModel.Verbose = !MainViewController.Instance.MainModel.Verbose; Debug.WriteLine("Verbose : " + MainViewController.Instance.MainModel.Verbose); msgTextBlock.Text = "Verbose : " + MainViewController.Instance.MainModel.Verbose; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.H) { MainViewController.Instance.MainModel.IsDefaultHypothesisEnabled = !MainViewController.Instance.MainModel.IsDefaultHypothesisEnabled; Debug.WriteLine("IsDefaultHypothesisEnabled : " + MainViewController.Instance.MainModel.IsDefaultHypothesisEnabled); msgTextBlock.Text = "IsDefaultHypothesisEnabled : " + MainViewController.Instance.MainModel.IsDefaultHypothesisEnabled; msgTextBlock.Opacity = 1; _messageTimer.Start(); } else if (e.Key == VirtualKey.U) { MainViewController.Instance.MainModel.IsUnknownUnknownEnabled = !MainViewController.Instance.MainModel.IsUnknownUnknownEnabled; Debug.WriteLine("IsUnknownUnknownEnabled : " + MainViewController.Instance.MainModel.IsUnknownUnknownEnabled); msgTextBlock.Text = "IsUnknownUnknownEnabled : " + MainViewController.Instance.MainModel.IsUnknownUnknownEnabled; msgTextBlock.Opacity = 1; _messageTimer.Start(); } if (e.Key == VirtualKey.T) { var q1 = new HistogramOperationModel(MainViewController.Instance.MainModel.SchemaModel); var q2 = new HistogramOperationModel(MainViewController.Instance.MainModel.SchemaModel); q1.FilterModels.Add(new FilterModel()); var lm = new FilterLinkModel(); lm.FromOperationModel = q1; lm.ToOperationModel = q2; q1.LinkModels.Add(lm); q2.LinkModels.Add(lm); var tt = q1.Clone(); } if (e.Key == VirtualKey.P) { Debug.WriteLine("Render Fingers / Pen : " + MainViewController.Instance.MainModel.RenderFingersAndPen); MainViewController.Instance.MainModel.RenderFingersAndPen = !MainViewController.Instance.MainModel.RenderFingersAndPen; msgTextBlock.Text = "Fingers / Pen : " + MainViewController.Instance.MainModel.RenderFingersAndPen; msgTextBlock.Opacity = 1; _messageTimer.Start(); } } }
public static HistogramOperationParameters GetHistogramOperationParameters(HistogramOperationModel model, int sampleSize) { var psm = model.SchemaModel as IDEASchemaModel; var filter = ""; var filterModels = new List <FilterModel>(); filter = FilterModel.GetFilterModelsRecursive(model, new List <IFilterProviderOperationModel>(), filterModels, true); var brushes = new List <string>(); foreach (var brushOperationModel in model.BrushOperationModels) { filterModels = new List <FilterModel>(); var brush = ""; if ((brushOperationModel as IFilterProviderOperationModel).FilterModels.Any()) { brush = FilterModel.GetFilterModelsRecursive(brushOperationModel, new List <IFilterProviderOperationModel>(), filterModels, false); } brushes.Add(brush); } var nrOfBins = new List <double>(); nrOfBins = new[] { MainViewController.Instance.MainModel.NrOfXBins, MainViewController.Instance.MainModel.NrOfYBins }.Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.Group).Select(qom => MainViewController.Instance.MainModel.NrOfGroupBins)).ToList(); if ((model.GetAttributeUsageTransformationModel(AttributeUsage.X).First().AttributeModel.RawName == "long") || (model.GetAttributeUsageTransformationModel(AttributeUsage.X).First().AttributeModel.RawName == "lat")) { nrOfBins[0] = 20; } if ((model.GetAttributeUsageTransformationModel(AttributeUsage.Y).First().AttributeModel.RawName == "long") || (model.GetAttributeUsageTransformationModel(AttributeUsage.Y).First().AttributeModel.RawName == "lat")) { nrOfBins[0] = 20; } var aggregates = model.GetAttributeUsageTransformationModel(AttributeUsage.Value).Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue)).Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.X).Where(aom => aom.AggregateFunction != AggregateFunction.None)).Concat( model.GetAttributeUsageTransformationModel(AttributeUsage.Y).Where(aom => aom.AggregateFunction != AggregateFunction.None)).Distinct().ToList(); var xIom = model.GetAttributeUsageTransformationModel(AttributeUsage.X).FirstOrDefault(); var yIom = model.GetAttributeUsageTransformationModel(AttributeUsage.Y).FirstOrDefault(); var xBinning = xIom.AggregateFunction == AggregateFunction.None ? new EquiWidthBinningParameters { Dimension = xIom.AttributeModel.Index, RequestedNrOfBins = MainViewController.Instance.MainModel.NrOfXBins, } : (BinningParameters) new SingleBinBinningParameters { Dimension = xIom.AttributeModel.Index }; var yBinning = yIom.AggregateFunction == AggregateFunction.None ? new EquiWidthBinningParameters { Dimension = yIom.AttributeModel.Index, RequestedNrOfBins = MainViewController.Instance.MainModel.NrOfYBins } : (BinningParameters) new SingleBinBinningParameters { Dimension = yIom.AttributeModel.Index }; AggregateParameters sortAggregateParam = null; var aggregateParameters = new List <AggregateParameters>(); foreach (var agg in aggregates) { AggregateParameters aggParam = null; if (agg.AggregateFunction == AggregateFunction.Avg) { aggParam = new AverageAggregateParameters { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } else if (agg.AggregateFunction == AggregateFunction.Count) { aggParam = new CountAggregateParameters { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } else if (agg.AggregateFunction == AggregateFunction.Sum) { aggParam = new SumAggregateParameters() { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } else if (agg.AggregateFunction == AggregateFunction.SumE) { aggParam = new SumEstimationAggregateParameters() { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }; } aggregateParameters.Add(aggParam); if (agg == model.GetAttributeUsageTransformationModel(AttributeUsage.Value).Concat(model.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue)).FirstOrDefault()) { sortAggregateParam = aggParam; } aggregateParameters.Add(new MarginAggregateParameters { Dimension = agg.AttributeModel.Index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension, AggregateFunction = agg.AggregateFunction.ToString() }); } var kdeDatatypes = new[] { InputDataTypeConstants.INT, InputDataTypeConstants.FLOAT }.ToList(); var globalAggregates = new List <AggregateParameters>(); foreach (var index in new[] { xIom, yIom }.Where(a => kdeDatatypes.Contains((a.AttributeModel as AttributeFieldModel).InputDataType)).Select(a => a.AttributeModel.Index).Distinct()) { globalAggregates.Add(new KDEAggregateParameters { Dimension = index, NrOfSamples = 50, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }); globalAggregates.Add(new CountAggregateParameters { Dimension = index, DistinctDimension = psm.RootOriginModel.DatasetConfiguration.Schema.DistinctDimension }); } var parameters = new HistogramOperationParameters { AdapterName = psm.RootOriginModel.DatasetConfiguration.Schema.RawName, Filter = filter, Brushes = brushes, BinningParameters = Extensions.Yield(xBinning, yBinning).ToList(), SampleStreamBlockSize = sampleSize, PerBinAggregateParameters = aggregateParameters, SortPerBinAggregateParameter = sortAggregateParam, GlobalAggregateParameters = globalAggregates }; return(parameters); }
public static EmpiricalDistOperationParameters GetEmpiricalDistOperationParameters(HistogramOperationModel m1, HistogramOperationModel m2, int sampleSize) { var psm = m1.SchemaModel as IDEASchemaModel; var filter1 = ""; var filterModels = new List <FilterModel>(); filter1 = FilterModel.GetFilterModelsRecursive(m1, new List <IFilterProviderOperationModel>(), filterModels, true); var filter2 = ""; filterModels = new List <FilterModel>(); filter2 = FilterModel.GetFilterModelsRecursive(m2, new List <IFilterProviderOperationModel>(), filterModels, true); var m1Iom = m1.GetAttributeUsageTransformationModel(AttributeUsage.X).FirstOrDefault(); var m2Iom = m2.GetAttributeUsageTransformationModel(AttributeUsage.X).FirstOrDefault(); var parameters = new EmpiricalDistOperationParameters() { AdapterName = psm.RootOriginModel.DatasetConfiguration.Schema.RawName, Filter = FilterModel.And(filter1, filter2), Attrs = new[] { m1Iom, m2Iom }.Select(a => a.AttributeModel.RawName).ToList(), SampleStreamBlockSize = sampleSize, KeepSamples = false }; return(parameters); }
public static HistogramOperationViewModel CreateDefaultHistogramOperationViewModel(SchemaModel schemaModel, AttributeModel attributeModel, Pt position) { var histogramOperationModel = new HistogramOperationModel(schemaModel); var histogramOperationViewModel = new HistogramOperationViewModel(histogramOperationModel); histogramOperationViewModel.Position = position; addAttachmentViewModels(histogramOperationViewModel); // axis attachment view models createAxisMenu(histogramOperationViewModel, AttachmentOrientation.Bottom, AttributeUsage.X, new Vec(200, 50), 0, true, false); createAxisMenu(histogramOperationViewModel, AttachmentOrientation.Left, AttributeUsage.Y, new Vec(50, 200), 270, false, true); createRightHistogramMenu(histogramOperationViewModel); createTopHistogramMenu(histogramOperationViewModel); if ((attributeModel != null) && attributeModel is AttributeFieldModel) { var inputFieldModel = attributeModel as AttributeFieldModel; if (inputFieldModel.InputVisualizationType == InputVisualizationTypeConstants.ENUM) { histogramOperationModel.VisualizationType = VisualizationType.plot; var x = new AttributeTransformationModel(inputFieldModel); x.AggregateFunction = AggregateFunction.None; var value = new AttributeTransformationModel(inputFieldModel); value.AggregateFunction = AggregateFunction.Count; var y = new AttributeTransformationModel(inputFieldModel); y.AggregateFunction = AggregateFunction.Count; if (attributeModel.VisualizationHints.Contains(VisualizationHint.DefaultFlipAxis)) { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, y); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, x); } else { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, x); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, y); } histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value); } else if (inputFieldModel.InputVisualizationType == InputVisualizationTypeConstants.NUMERIC) { histogramOperationModel.VisualizationType = VisualizationType.plot; var x = new AttributeTransformationModel(inputFieldModel); x.AggregateFunction = AggregateFunction.None; var value = new AttributeTransformationModel(inputFieldModel); value.AggregateFunction = AggregateFunction.Count; var y = new AttributeTransformationModel(inputFieldModel); y.AggregateFunction = AggregateFunction.Count; if (attributeModel.VisualizationHints.Contains(VisualizationHint.DefaultFlipAxis)) { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, y); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, x); } else { histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, x); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.Y, y); } histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value); } else if (inputFieldModel.InputVisualizationType == InputVisualizationTypeConstants.GEOGRAPHY) { } else { histogramOperationModel.VisualizationType = VisualizationType.table; var x = new AttributeTransformationModel(inputFieldModel); histogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.X, x); } } else { histogramOperationModel.VisualizationType = VisualizationType.plot; } return(histogramOperationViewModel); }
public HistogramOperationViewModel(HistogramOperationModel histogramOperationModel) : base(histogramOperationModel) { }