public static AggregateKey CreateAggregateKey(AttributeTransformationModel iom, HistogramResult histogramResult,
                                               int brushIndex)
 {
     return(new AggregateKey
     {
         AggregateParameterIndex = histogramResult.GetAggregateParametersIndex(createAggregateParameters(iom)),
         BrushIndex = brushIndex
     });
 }
 public static AggregateKey CreateAggregateKey(AttributeTransformationModel iom,
                                               SingleDimensionAggregateParameters aggParameters, HistogramResult histogramResult, int brushIndex)
 {
     aggParameters.Dimension = iom.AttributeModel.Index;
     return(new AggregateKey
     {
         AggregateParameterIndex = histogramResult.GetAggregateParametersIndex(aggParameters),
         BrushIndex = brushIndex
     });
 }
Example #3
0
 public void RemoveAttributeTransformationModel(AttributeTransformationModel attributeTransformationModel)
 {
     foreach (var key in _attributeUsageTransformationModels.Keys)
     {
         if (_attributeUsageTransformationModels[key].Any(aom => aom == attributeTransformationModel))
         {
             RemoveAttributeUsageTransformationModel(key, attributeTransformationModel);
         }
     }
 }
 private static AggregateParameters createAggregateParameters(AttributeTransformationModel iom)
 {
     if (iom.AggregateFunction == AggregateFunction.Count)
     {
         return new CountAggregateParameters {
                    Dimension = iom.AttributeModel.Index
         }
     }
     ;
     if (iom.AggregateFunction == AggregateFunction.Avg)
     {
         return new AverageAggregateParameters {
                    Dimension = iom.AttributeModel.Index
         }
     }
     ;
     if (iom.AggregateFunction == AggregateFunction.Max)
     {
         return new MaxAggregateParameters {
                    Dimension = iom.AttributeModel.Index
         }
     }
     ;
     if (iom.AggregateFunction == AggregateFunction.Min)
     {
         return new MinAggregateParameters {
                    Dimension = iom.AttributeModel.Index
         }
     }
     ;
     if (iom.AggregateFunction == AggregateFunction.Sum)
     {
         return new SumAggregateParameters {
                    Dimension = iom.AttributeModel.Index
         }
     }
     ;
     if (iom.AggregateFunction == AggregateFunction.Count)
     {
         return new CountAggregateParameters {
                    Dimension = iom.AttributeModel.Index
         }
     }
     ;
     if (iom.AggregateFunction == AggregateFunction.SumE)
     {
         return new SumEstimationAggregateParameters()
                {
                    Dimension = iom.AttributeModel.Index
                }
     }
     ;
     return(null);
 }
 public AttributeTransformationViewModelEventArgs(AttributeTransformationModel attributeTransformationModel, Rct bounds)
 {
     AttributeTransformationModel = attributeTransformationModel;
     Bounds = bounds;
 }
 public ValueComparison(AttributeTransformationModel aom, Predicate predicate, object value)
 {
     AttributeTransformationModel = aom;
     Value     = value;
     Predicate = predicate;
 }
Example #7
0
        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);
        }
Example #8
0
        private static void createAxisMenu(HistogramOperationViewModel histogramOperationViewModel, AttachmentOrientation attachmentOrientation,
                                           AttributeUsage axis, Vec size, double textAngle, bool isWidthBoundToParent, bool isHeightBoundToParent)
        {
            var attachmentViewModel =
                histogramOperationViewModel.AttachementViewModels.First(
                    avm => avm.AttachmentOrientation == attachmentOrientation);

            var menuViewModel = new MenuViewModel
            {
                AttachmentOrientation = attachmentViewModel.AttachmentOrientation,
                NrColumns             = attachmentOrientation == AttachmentOrientation.Bottom ? 5 : 2,
                NrRows = attachmentOrientation == AttachmentOrientation.Bottom ? 2 : 5
            };

            var menuItem = new MenuItemViewModel
            {
                MenuViewModel         = menuViewModel,
                Row                   = 0,
                ColumnSpan            = attachmentOrientation == AttachmentOrientation.Bottom ? 5 : 1,
                RowSpan               = attachmentOrientation == AttachmentOrientation.Bottom ? 1 : 5,
                Column                = attachmentOrientation == AttachmentOrientation.Bottom ? 0 : 1,
                Size                  = size,
                Position              = histogramOperationViewModel.Position,
                TargetSize            = size,
                IsAlwaysDisplayed     = true,
                IsWidthBoundToParent  = isWidthBoundToParent,
                IsHeightBoundToParent = isHeightBoundToParent
            };
            var attr1 = new AttributeTransformationMenuItemViewModel
            {
                TextAngle = textAngle,
                TextBrush = new SolidColorBrush(Helpers.GetColorFromString("#29aad5"))
            };

            histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(axis).CollectionChanged += (sender, args) =>
            {
                var coll = sender as ObservableCollection <AttributeTransformationModel>;
                var attributeTransformationModel = coll.FirstOrDefault();
                attr1.Label = attributeTransformationModel == null ? "" : attributeTransformationModel.GetLabel();
                attr1.AttributeTransformationViewModel = new AttributeTransformationViewModel(histogramOperationViewModel, coll.FirstOrDefault());

                if (attributeTransformationModel != null)
                {
                    attributeTransformationModel.PropertyChanged += (sender2, args2) =>
                    {
                        attr1.Label = (sender2 as AttributeTransformationModel).GetLabel();
                    };
                }

                // remove old ones first
                foreach (var mvm in menuViewModel.MenuItemViewModels.Where(mvm => mvm.MenuItemComponentViewModel is ToggleMenuItemComponentViewModel).ToArray())
                {
                    menuViewModel.MenuItemViewModels.Remove(mvm);
                }

                var aom = attr1.AttributeTransformationViewModel.AttributeTransformationModel;
                var aggregateFunctions = new[] { AggregateFunction.None, AggregateFunction.Count }.ToList();
                if (aom != null)
                {
                    if (((AttributeFieldModel)aom.AttributeModel).InputDataType == InputDataTypeConstants.INT ||
                        (((AttributeFieldModel)aom.AttributeModel).InputDataType == InputDataTypeConstants.FLOAT))
                    {
                        aggregateFunctions.Add(AggregateFunction.Avg);
                        aggregateFunctions.Add(AggregateFunction.Sum);
                        if (MainViewController.Instance.MainModel.IsUnknownUnknownEnabled)
                        {
                            aggregateFunctions.Add(AggregateFunction.SumE);
                        }
                    }

                    var toggles = new List <ToggleMenuItemComponentViewModel>();
                    var items   = new List <MenuItemViewModel>();

                    var count = 0;
                    foreach (var aggregationFunction in aggregateFunctions)
                    {
                        var toggleMenuItem = new MenuItemViewModel
                        {
                            MenuViewModel = menuViewModel,
                            Row           = attachmentOrientation == AttachmentOrientation.Bottom ? 1 : count,
                            RowSpan       = 0,
                            Position      = histogramOperationViewModel.Position,
                            Column        = attachmentOrientation == AttachmentOrientation.Bottom ? count : 0,
                            Size          = new Vec(32, 32),
                            TargetSize    = new Vec(32, 32)
                        };
                        //toggleMenuItem.Position = attachmentItemViewModel.Position;
                        var toggle = new ToggleMenuItemComponentViewModel
                        {
                            Label     = aggregationFunction.ToString(),
                            IsChecked = aom.AggregateFunction == aggregationFunction
                        };
                        toggles.Add(toggle);
                        toggleMenuItem.MenuItemComponentViewModel = toggle;
                        toggleMenuItem.MenuItemComponentViewModel.PropertyChanged += (sender2, args2) =>
                        {
                            var model = sender2 as ToggleMenuItemComponentViewModel;
                            if (args2.PropertyName == model.GetPropertyName(() => model.IsChecked))
                            {
                                if (model.IsChecked)
                                {
                                    aom.AggregateFunction = aggregationFunction;
                                    foreach (var tg in model.OtherToggles)
                                    {
                                        tg.IsChecked = false;
                                    }
                                }
                            }
                        };
                        menuViewModel.MenuItemViewModels.Add(toggleMenuItem);
                        items.Add(toggleMenuItem);
                        count++;
                    }

                    foreach (var mi in items)
                    {
                        (mi.MenuItemComponentViewModel as ToggleMenuItemComponentViewModel).OtherToggles.AddRange(toggles.Where(ti => ti != mi.MenuItemComponentViewModel));
                    }
                }
            };
            attr1.TappedTriggered  = () => { attachmentViewModel.ActiveStopwatch.Restart(); };
            attr1.DroppedTriggered = attributeTransformationModel =>
            {
                var otherAxis     = axis == AttributeUsage.X ? AttributeUsage.Y : AttributeUsage.X;
                var existingModel = histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(axis).Any() ?
                                    histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(axis).First() : null;
                var existingOtherModel = histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(otherAxis).Any() ?
                                         histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(otherAxis).First() : null;
                var swapAxes = existingModel != null && existingOtherModel.AttributeModel == attributeTransformationModel.AttributeModel &&
                               existingOtherModel.AggregateFunction == attributeTransformationModel.AggregateFunction;

                if (existingModel != null)
                {
                    histogramOperationViewModel.HistogramOperationModel.RemoveAttributeUsageTransformationModel(axis, existingModel);
                }
                if (!histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue).Any())
                {
                    var value = new AttributeTransformationModel(attributeTransformationModel.AttributeModel);
                    value.AggregateFunction = AggregateFunction.Count;
                    histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value);
                }
                histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(axis, attributeTransformationModel);
                attachmentViewModel.ActiveStopwatch.Restart();
                if (swapAxes)
                {
                    histogramOperationViewModel.HistogramOperationModel.RemoveAttributeUsageTransformationModel(otherAxis, existingOtherModel);
                    if (!histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue).Any())
                    {
                        var value = new AttributeTransformationModel(attributeTransformationModel.AttributeModel);
                        value.AggregateFunction = AggregateFunction.Count;
                        histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value);
                    }
                    histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(otherAxis, existingModel);
                }
            };

            menuItem.MenuItemComponentViewModel = attr1;
            menuViewModel.MenuItemViewModels.Add(menuItem);
            attachmentViewModel.MenuViewModel = menuViewModel;
        }
Example #9
0
 public void RemoveAttributeUsageTransformationModel(AttributeUsage attributeUsage,
                                                     AttributeTransformationModel attributeTransformationModel)
 {
     _attributeUsageTransformationModels[attributeUsage].Remove(attributeTransformationModel);
 }
Example #10
0
 public void AddAttributeUsageTransformationModel(AttributeUsage attributeUsage,
                                                  AttributeTransformationModel attributeTransformationModel)
 {
     _attributeUsageTransformationModels[attributeUsage].Add(attributeTransformationModel);
 }
 public AttributeTransformationViewModel(OperationViewModel operationViewModel, AttributeTransformationModel attributeTransformationModel)
 {
     OperationViewModel           = operationViewModel;
     AttributeTransformationModel = attributeTransformationModel;
 }
 public void FireDropped(Rct bounds, AttributeTransformationModel attributeTransformationModel)
 {
     AttributeTransformationViewModelDropped?.Invoke(this, new AttributeTransformationViewModelEventArgs(attributeTransformationModel, bounds));
 }