/// <summary> /// Add Attribute To Dimension /// </summary> /// <param name="cubeDSV"></param> /// <param name="dim"></param> /// <param name="tableID"></param> /// <param name="colName"></param> /// <param name="attribID"></param> /// <param name="attribName"></param> /// <param name="type"></param> /// <param name="usage"></param> /// <param name="nameColumn"></param> /// <param name="visible"></param> /// <param name="AttHierEnabled"></param> /// <param name="orderby"></param> /// <param name="attDisplayFolder"></param> /// <param name="orderByAttName"></param> /// <param name="attType"></param> /// <param name="valueColumn"></param> /// <param name="valueColtype"></param> internal static void ADD_ATTRIBUTE_TO_DIMENSION( DB_SQLHELPER_BASE sqlHelper, DataSourceView cubeDSV, Dimension dim, String tableID, String colName, String attribID, String attribName, System.Data.OleDb.OleDbType type, AttributeUsage usage, String nameColumn, bool visible = true, bool AttHierEnabled = true, OrderBy orderby = OrderBy.Name, String attDisplayFolder = "", String orderByAttName = null, String attType = "Regular", String valueColumn = null, System.Data.OleDb.OleDbType valueColtype = System.Data.OleDb.OleDbType.Integer) { DimensionAttribute attr = dim.Attributes.FindByName(attribName); if (attr == null) { attr = dim.Attributes.Add(attribID); attr.Name = attribName; attr.Usage = usage; attr.Type = AttributeType.Regular; attr.AttributeHierarchyEnabled = AttHierEnabled; DataItem dataItem = CREATE_COLUMN_BINDING_DATA_ITEM(sqlHelper, cubeDSV, tableID, colName, type); attr.KeyColumns.Add(dataItem); attr.KeyColumns[0].DataType = type; attr.AttributeHierarchyVisible = visible; attr.OrderBy = orderby; if (nameColumn != colName && nameColumn != "") { DataItem nameColDataItem = CREATE_COLUMN_BINDING_DATA_ITEM(sqlHelper, cubeDSV, tableID, nameColumn, System.Data.OleDb.OleDbType.WChar); attr.NameColumn = nameColDataItem; } if (attDisplayFolder != null && attDisplayFolder != "") { attr.AttributeHierarchyDisplayFolder = attDisplayFolder; } if (orderByAttName != null && orderByAttName != "") { attr.OrderByAttributeID = orderByAttName; } if (valueColumn != null && valueColumn != "") { DataItem valueColDataItem = CREATE_COLUMN_BINDING_DATA_ITEM(sqlHelper, cubeDSV, tableID, valueColumn, valueColtype); attr.ValueColumn = valueColDataItem; } sqlHelper.ADD_MESSAGE_LOG( String.Format("Added attribute [{0}] to dimension [{1}]", attribName, dim.Name), MESSAGE_TYPE.ATTRIBUTE, MESSAGE_RESULT_TYPE.Succeed); } }
public static VertexAttribute CreateVec4(string name, bool packed, AttributeUsage usage) => packed ? new VertexAttribute() { Name = name, ComponentCount = 4, ComponentSize = 1, Type = VertexAttribPointerType.UnsignedByte, Normalized = true, Usage = usage } : new VertexAttribute() { Name = name, ComponentCount = 4, Usage = usage };
public VertexAttribute GetAttribute(AttributeUsage usage) { foreach (var attribute in vertexAttributes) { if (attribute.Usage == usage) { return(attribute); } } return(null); }
public List <VertexAttribute> GetAttributes(AttributeUsage usage) { var attributes = new List <VertexAttribute>(); foreach (var attribute in vertexAttributes) { if (attribute.Usage == usage) { attributes.Add(attribute); } } return(attributes); }
private static void ProcessAttributeUsage(this AttributeUsage attributeUsage) { ClassDeclaration classDeclaration = attributeUsage.Scope.GlobalClassSearch(attributeUsage.Name.Name); if (classDeclaration == null) { throw new ScopeException($"Attribute {attributeUsage.Name.Name} was not found"); } if (!classDeclaration.IsAttribute) { throw new ScopeException($"Class {attributeUsage.Name.Name} is not an attribute"); } AttributeDeclaration attributeDeclarationClass = classDeclaration.CastTo <AttributeDeclaration>(); CheckCallParameters(attributeUsage, attributeUsage.FunctionCallParameters, attributeDeclarationClass.ParameterNodes); }
//-------------------- public bool CreateDimensionAttributeForLevel(Dimension dimension, DataSourceView dataSourceView, String levelId, String levelName, String tableName, String keyColumn, String nameColumn, AttributeUsage attributeUsage, OrderBy orderBy, AttributeType attribType, bool visible) { if (dimension.Attributes == null) { return(false); } DimensionAttribute dimAttrib; if (!dimension.Attributes.Contains(levelId)) { dimAttrib = dimension.Attributes.Add(levelName, levelId); dimAttrib.Usage = attributeUsage; dimAttrib.OrderBy = orderBy; dimAttrib.Type = attribType; dimAttrib.AttributeHierarchyVisible = true;// visible; dimAttrib.AttributeHierarchyOptimizedState = OptimizationType.NotOptimized; dimAttrib.AttributeHierarchyOrdered = true; dimAttrib.IsAggregatable = true; //设置MembersWithDataCaption会导致当前粒度在子粒度中存在,形如"XXXX(All)",因此注释掉 //if (attributeUsage == AttributeUsage.Parent) //{ // dimAttrib.MembersWithDataCaption = "*(All)"; //} dimAttrib.MembersWithData = MembersWithData.NonLeafDataHidden; DataItem diKey = CreateDataItem(dataSourceView, tableName, keyColumn); dimAttrib.KeyColumns.Add(diKey); if (!String.IsNullOrEmpty(nameColumn)) { DataItem diName = CreateDataItem(dataSourceView, tableName, nameColumn); dimAttrib.NameColumn = diName; DataItem diValue = CreateDataItem(dataSourceView, tableName, nameColumn); dimAttrib.ValueColumn = diValue; } return(true); } return(true); }
//-------------------- public bool CreateDimensionAttributeForLevel(Dimension dimension, DataSourceView dataSourceView, String levelId, String levelName, String tableName, String keyColumn, String nameColumn, AttributeUsage attributeUsage, OrderBy orderBy, AttributeType attribType, bool visible) { if (dimension.Attributes == null) { return false; } DimensionAttribute dimAttrib; if (!dimension.Attributes.Contains(levelId)) { dimAttrib = dimension.Attributes.Add(levelName, levelId); dimAttrib.Usage = attributeUsage; dimAttrib.OrderBy = orderBy; dimAttrib.Type = attribType; dimAttrib.AttributeHierarchyVisible = true;// visible; dimAttrib.AttributeHierarchyOptimizedState = OptimizationType.NotOptimized; dimAttrib.AttributeHierarchyOrdered = true; dimAttrib.IsAggregatable = true; //设置MembersWithDataCaption会导致当前粒度在子粒度中存在,形如"XXXX(All)",因此注释掉 //if (attributeUsage == AttributeUsage.Parent) //{ // dimAttrib.MembersWithDataCaption = "*(All)"; //} dimAttrib.MembersWithData = MembersWithData.NonLeafDataHidden; DataItem diKey = CreateDataItem(dataSourceView, tableName, keyColumn); dimAttrib.KeyColumns.Add(diKey); if (!String.IsNullOrEmpty(nameColumn)) { DataItem diName = CreateDataItem(dataSourceView, tableName, nameColumn); dimAttrib.NameColumn = diName; DataItem diValue = CreateDataItem(dataSourceView, tableName, nameColumn); dimAttrib.ValueColumn = diValue; } return true; } return true; }
/// <exception cref="InvalidOperationException">already closed (by call to <see cref="Close"/>)</exception> public void DefineVertexAttribute(string name, int index, int components, VertexAttribPointerType attribType, AttributeUsage usage, bool normalized, int stride, int offset = 0) { if (Closed) { throw new InvalidOperationException("Type is Closed and is now immutable."); } Items[index] = new LayoutItem { Name = name, Components = components, AttribType = attribType, Usage = usage, Normalized = normalized, Stride = stride, Offset = offset }; }
public void Construct(CommonTree syntaxFunctionDeclaration) { //Name Name = syntaxFunctionDeclaration.GetChild(0).Text; //Modifiers var syntaxModifiers = syntaxFunctionDeclaration.GetChild(1).CastTo <CommonTree>(); if (syntaxModifiers.ChildCount > 0) { syntaxModifiers.Children.ForEach(mod => { if (mod.Text == Modifiers.Extern) { ModifiersList.Add(Modifier.Extern); } else if (mod.Text == Modifiers.Static) { ModifiersList.Add(Modifier.Static); } else { throw new Exception($"Modifier {mod.Text} is not defined"); } }); } //Attributes var syntaxAttributeUsages = syntaxFunctionDeclaration.GetChild(2).CastTo <CommonTree>(); if (syntaxAttributeUsages.ChildCount > 0) { syntaxAttributeUsages.Children.Cast <CommonTree>().ForEach(syntaxAttributeUsage => { AttributeUsage attributeUsage = new AttributeUsage(this, Scope); attributeUsage.Construct(syntaxAttributeUsage); AttributeUsages.Add(attributeUsage); }); } //ReturnType string strType = string.Empty; var syntaxReturnType = syntaxFunctionDeclaration.GetChild(3).CastTo <CommonTree>(); syntaxReturnType.Children.ForEach(node => strType += node.Text); //ReturnType = TreeHelper.GetReturnType(syntaxFunctionDeclaration.GetChild(1).GetChild(0).Text); ReturnType = TreeHelper.GetReturnType(strType); //Parameters var syntaxParametersNode = syntaxFunctionDeclaration.GetChild(4).CastTo <CommonTree>(); if (syntaxParametersNode.ChildCount > 0) { syntaxParametersNode.Children.Cast <CommonTree>() .ForEach(syntaxParameter => { FunctionVariableDeclarationParameter functionVariableDeclarationParameter = new FunctionVariableDeclarationParameter(this, Scope); ParameterNodes.Add(functionVariableDeclarationParameter); // Scope.AddVariable(functionDeclarationParameter); functionVariableDeclarationParameter.Construct(syntaxParameter); }); } //Statements var syntaxFunctionBody = syntaxFunctionDeclaration.GetChild(5).CastTo <CommonTree>(); //StatemenBlock = TreeHelper.GetStatements(this, Scope, syntaxStatementBlock) // .First().CastTo<BlockStatement>(); if (syntaxFunctionBody.ChildCount > 0) { StatementBlock = new BlockStatement(this, Scope, false); StatementBlock.Construct(syntaxFunctionBody.GetChild(0).CastTo <CommonTree>()); } }
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; }
public ObservableCollection <AttributeTransformationModel> GetAttributeUsageTransformationModel( AttributeUsage attributeUsage) { return(_attributeUsageTransformationModels[attributeUsage]); }
public void RemoveAttributeUsageTransformationModel(AttributeUsage attributeUsage, AttributeTransformationModel attributeTransformationModel) { _attributeUsageTransformationModels[attributeUsage].Remove(attributeTransformationModel); }
public void AddAttributeUsageTransformationModel(AttributeUsage attributeUsage, AttributeTransformationModel attributeTransformationModel) { _attributeUsageTransformationModels[attributeUsage].Add(attributeTransformationModel); }
internal ElementInfos( ElementTypes ElementType, AttributeUsage[] AttributeUsages) { this.AttributeUsages = AttributeUsages; this.ElementType = ElementType; }
public virtual void DrawContext(AttributeData data, bool showRemove = false, bool isRoot = true) { if (this.labelRect.AddWidth(20).Clicked(1)) { this.contextOpen = true; GenericMenu menu = new GenericMenu(); AttributeMode mode = this.attribute.info.mode; AttributeUsage usage = data.usage; bool advanced = EditorPref.Get <bool>(data.path + "Advanced"); MenuFunction toggleAdvanced = () => { EditorPref.Set <bool>(data.path + "Advanced", !advanced); }; MenuFunction removeAttribute = () => { this.attribute.Remove(data); }; MenuFunction modeNormal = () => { this.attribute.info.mode = AttributeMode.Normal; }; MenuFunction modeLinked = () => { this.attribute.info.mode = AttributeMode.Linked; }; MenuFunction modeFormula = () => { this.attribute.info.mode = AttributeMode.Formula; }; MenuFunction modeGroup = () => { this.attribute.info.mode = AttributeMode.Group; }; MenuFunction usageDirect = () => { data.usage = AttributeUsage.Direct; data.referencePath = ""; data.referenceID = ""; data.reference = null; }; MenuFunction usageShaped = () => { data.usage = AttributeUsage.Shaped; }; MenuFunction fixType = () => { this.SwapType(0, typeof(DataType), this.attribute.defaultSet); }; bool normal = this.attribute.info.mode == AttributeMode.Normal; if (this.attribute.locked) { menu.AddDisabledItem(new GUIContent("Attribute Locked")); menu.ShowAsContext(); return; } if (isRoot || mode.Matches("Normal", "Linked")) { if (mode.Matches("Normal", "Linked") && usage.Matches("Shaped") && this.attribute.canAdvanced) { menu.AddItem(new GUIContent("Advanced"), advanced, toggleAdvanced); menu.AddSeparator("/"); } if (this.attribute.canDirect) { menu.AddItem(new GUIContent("Direct"), normal && (usage == AttributeUsage.Direct), fixType + modeNormal + usageDirect); } if (this.attribute.canShape) { menu.AddItem(new GUIContent("Shaped"), normal && (usage == AttributeUsage.Shaped), fixType + modeNormal + usageShaped); } if (this.attribute.canLink) { menu.AddItem(new GUIContent("Linked"), (mode == AttributeMode.Linked), fixType + modeLinked + usageShaped); } menu.AddSeparator("/"); if (this.attribute.canFormula) { menu.AddItem(new GUIContent("Formula"), (mode == AttributeMode.Formula), modeFormula); } if (this.attribute.canGroup) { menu.AddItem(new GUIContent("Group"), (mode == AttributeMode.Group), modeGroup); } } else if (mode.Matches("Formula")) { menu.AddItem(new GUIContent("Advanced"), advanced, toggleAdvanced); this.DrawTypeMenu(data, menu); menu.AddSeparator("/"); if (this.attribute.canDirect) { menu.AddItem(new GUIContent("Direct"), usage == AttributeUsage.Direct, usageDirect); } if (this.attribute.canShape) { menu.AddItem(new GUIContent("Shaped"), usage == AttributeUsage.Shaped, usageShaped); } } if (showRemove) { if (!mode.Matches("Group")) { menu.AddSeparator("/"); } menu.AddItem(new GUIContent("Remove"), false, removeAttribute); } menu.ShowAsContext(); } if (this.contextOpen && Event.current.button == 0) { this.dirty = true; this.contextOpen = false; } }