simpleVisualisationAxis GetVisualisationAxisType(Visualisation v) { if (v.theVisualizationObject.X_AXIS != null && v.theVisualizationObject.Y_AXIS == null && v.theVisualizationObject.Z_AXIS == null) { return(simpleVisualisationAxis.X); } else if (v.theVisualizationObject.X_AXIS == null && v.theVisualizationObject.Y_AXIS != null && v.theVisualizationObject.Z_AXIS == null) { return(simpleVisualisationAxis.Y); } else if (v.theVisualizationObject.X_AXIS == null && v.theVisualizationObject.Y_AXIS == null && v.theVisualizationObject.Z_AXIS != null) { return(simpleVisualisationAxis.Z); } else if (v.theVisualizationObject.X_AXIS != null && v.theVisualizationObject.Y_AXIS != null && v.theVisualizationObject.Z_AXIS == null) { return(simpleVisualisationAxis.XY); } else if (v.theVisualizationObject.X_AXIS != null && v.theVisualizationObject.Y_AXIS == null && v.theVisualizationObject.Z_AXIS != null) { return(simpleVisualisationAxis.XZ); } else if (v.theVisualizationObject.X_AXIS == null && v.theVisualizationObject.Y_AXIS != null && v.theVisualizationObject.Z_AXIS != null) { return(simpleVisualisationAxis.YZ); } else if (v.theVisualizationObject.X_AXIS != null && v.theVisualizationObject.Y_AXIS != null && v.theVisualizationObject.Z_AXIS != null) { return(simpleVisualisationAxis.XYZ); } else { return(simpleVisualisationAxis.NONE); } }
/// <summary> /// Initialises the axis. /// </summary> /// <param name="srcData"></param> /// <param name="attributeFilter"></param> /// <param name="visualisation"></param> public void Initialise(DataSource srcData, AttributeFilter attributeFilter, Visualisation visualisation) { AttributeFilter = attributeFilter; dataSource = srcData; int idx = Array.IndexOf(srcData.Select(m => m.Identifier).ToArray(), attributeFilter.Attribute); SourceIndex = idx; name = "Axis " + srcData[idx].Identifier; attributeLabel.text = srcData[idx].Identifier; visualisationReference = visualisation; axisTickLabelPrefab.SetActive(false); UpdateAxisAttribute(attributeFilter.Attribute); }
void CalculateCorners(Visualisation v, ref Vector3 ftl, ref Vector3 ftr, ref Vector3 fbl, ref Vector3 fbr, ref Vector3 btl, ref Vector3 btr, ref Vector3 bbl, ref Vector3 bbr) { switch (GetVisualisationAxisType(v)) { case simpleVisualisationAxis.NONE: break; case simpleVisualisationAxis.X: CalculateCorners3(v.theVisualizationObject.X_AXIS.GetComponent <Axis>(), v.theVisualizationObject.X_AXIS.GetComponent <Axis>(), v.theVisualizationObject.X_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; case simpleVisualisationAxis.Y: CalculateCorners3(v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; case simpleVisualisationAxis.Z: CalculateCorners3(v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; case simpleVisualisationAxis.XY: CalculateCorners3(v.theVisualizationObject.X_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; case simpleVisualisationAxis.XZ: CalculateCorners3(v.theVisualizationObject.X_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; case simpleVisualisationAxis.YZ: CalculateCorners3(v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; case simpleVisualisationAxis.XYZ: CalculateCorners3(v.theVisualizationObject.X_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Y_AXIS.GetComponent <Axis>(), v.theVisualizationObject.Z_AXIS.GetComponent <Axis>(), ref ftl, ref ftr, ref fbl, ref fbr, ref btl, ref btr, ref bbl, ref bbr); break; default: break; } ftl = v.transform.TransformPoint(v.transform.InverseTransformVector((ftl))); ftr = v.transform.TransformPoint(v.transform.InverseTransformVector((ftr))); fbl = v.transform.TransformPoint(v.transform.InverseTransformVector((fbl))); fbr = v.transform.TransformPoint(v.transform.InverseTransformVector((fbr))); btl = v.transform.TransformPoint(v.transform.InverseTransformVector((btl))); btr = v.transform.TransformPoint(v.transform.InverseTransformVector((btr))); bbl = v.transform.TransformPoint(v.transform.InverseTransformVector((bbl))); bbr = v.transform.TransformPoint(v.transform.InverseTransformVector((bbr))); }
/// <summary> /// Draw the inspector and update Visualisation when a property changes /// </summary> public override void OnInspectorGUI() { AbstractVisualisation.PropertyType?dirtyFlags = null; Visualisation targetVisualisation = (Visualisation)serializedObject.targetObject; serializedObject.Update(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(uidProperty); EditorGUI.EndDisabledGroup(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(dataSourceProperty); if (EditorGUI.EndChangeCheck()) { loadData(); targetVisualisation.xScatterplotMatrixDimensions = dimensions.Select(x => new DimensionFilter { Attribute = x }).ToArray(); targetVisualisation.yScatterplotMatrixDimensions = dimensions.Select(x => new DimensionFilter { Attribute = x }).ToArray(); targetVisualisation.zScatterplotMatrixDimensions = dimensions.Select(x => new DimensionFilter { Attribute = x }).ToArray(); targetVisualisation.parallelCoordinatesDimensions = dimensions.Select(x => new DimensionFilter { Attribute = x }).ToArray(); } if (dataSourceProperty.objectReferenceValue != null) { //Check if changing the visualisation type EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(visualisationTypeProperty); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.VisualisationType; } //int visType = visualisationTypeProperty.intValue; //EnumPopup("Visualisation Type", Enum.GetNames(typeof(AbstractViualisation.VisualisationTypes)), ref visType); //visualisationTypeProperty.intValue = visType; EditorGUI.indentLevel++; // switch ((AbstractViualisation.VisualisationTypes)visualisationTypeProperty.intValue) switch (targetVisualisation.visualisationType) { case AbstractVisualisation.VisualisationTypes.SCATTERPLOT: ShowSimpleVisualisationMenu(ref dirtyFlags); break; case AbstractVisualisation.VisualisationTypes.SCATTERPLOT_MATRIX: ShowScatterplotMatrixMenu(ref dirtyFlags); break; case AbstractVisualisation.VisualisationTypes.PARALLEL_COORDINATES: ShowParallelCoordinatesMenu(ref dirtyFlags); break; case AbstractVisualisation.VisualisationTypes.GRAPH_LAYOUT: break; default: break; } EditorGUI.indentLevel--; EditorGUILayout.Space(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(geometryProperty); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.GeometryType; } if (EnumPopup("Colour dimension", dimensions.ToArray(), colourDimensionProperty)) { dirtyFlags = AbstractVisualisation.PropertyType.Colour; colorPaletteDimensionProperty.stringValue = "Undefined"; colourPaletteProperty.ClearArray(); colourPaletteProperty.arraySize = 0; } if (EnumPopup("Bind Colour palette", dimensions.ToArray(), colorPaletteDimensionProperty)) { if (colorPaletteDimensionProperty.stringValue != "Undefined") { int nbPaletteCategories = dataSource.getNumberOfCategories(colorPaletteDimensionProperty.stringValue); float[] uniqueValues = dataSource[colorPaletteDimensionProperty.stringValue].MetaData.categories; colourPaletteProperty.ClearArray(); colourPaletteProperty.arraySize = nbPaletteCategories; colourDimensionProperty.stringValue = "Undefined"; } } if (colorPaletteDimensionProperty.stringValue != "Undefined" && colorPaletteDimensionProperty.stringValue != "") { EditorGUI.BeginChangeCheck(); float[] paletteValues = dataSource[colorPaletteDimensionProperty.stringValue].MetaData.categories; int nbPaletteCategories = paletteValues.Length; EditorGUI.indentLevel += 1; for (int i = 0; i < nbPaletteCategories; i++) { EditorGUILayout.PropertyField( colourPaletteProperty.GetArrayElementAtIndex(i), new GUIContent(dataSource.getOriginalValue(paletteValues[i], colorPaletteDimensionProperty.stringValue).ToString()) ); } EditorGUI.indentLevel -= 1; if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.Colour; } } if (EnumPopup("Blending Mode Source", Enum.GetNames(typeof(UnityEngine.Rendering.BlendMode)), blendingModeSourceProperty)) { dirtyFlags = AbstractVisualisation.PropertyType.BlendSourceMode; } if (EnumPopup("Blending Mode Destination", Enum.GetNames(typeof(UnityEngine.Rendering.BlendMode)), blendingModeDestinationProperty)) { dirtyFlags = AbstractVisualisation.PropertyType.BlendDestinationMode; } if (colourDimensionProperty.stringValue != "" && colourDimensionProperty.stringValue != "Undefined") { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(colourGradientProperty); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.Colour; } } else { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(colourProperty); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.Colour; } } if (EnumPopup("Size dimension", dimensions.ToArray(), sizeDimensionProperty)) { dirtyFlags = AbstractVisualisation.PropertyType.Size; } if (EnumPopup("Linking dimension", dimensions.ToArray(), linkingDimensionProperty)) { dirtyFlags = AbstractVisualisation.PropertyType.LinkingDimension; } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(attributeFiltersProperty, true); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.AttributeFiltering; } // Size EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(sizeProperty); EditorGUILayout.PropertyField(minSizeProperty); EditorGUILayout.PropertyField(maxSizeProperty); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.SizeValues; } // Visualisation dimensions EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(widthProperty); EditorGUILayout.PropertyField(heightProperty); EditorGUILayout.PropertyField(depthProperty); if (EditorGUI.EndChangeCheck()) { dirtyFlags = AbstractVisualisation.PropertyType.Scaling; } // Update the options for this visualisation serializedObject.ApplyModifiedProperties(); if (dirtyFlags == AbstractVisualisation.PropertyType.VisualisationType) { targetVisualisation.CreateVisualisation((AbstractVisualisation.VisualisationTypes)visualisationTypeProperty.intValue); } else if (dirtyFlags != null) { targetVisualisation.updateViewProperties(dirtyFlags.Value); } }
void OnEnable() { uidProperty = serializedObject.FindProperty("uid"); dataSourceProperty = serializedObject.FindProperty("dataSource"); geometryProperty = serializedObject.FindProperty("geometry"); colourProperty = serializedObject.FindProperty("colour"); sizeProperty = serializedObject.FindProperty("size"); xDimensionProperty = serializedObject.FindProperty("xDimension"); yDimensionProperty = serializedObject.FindProperty("yDimension"); zDimensionProperty = serializedObject.FindProperty("zDimension"); colourDimensionProperty = serializedObject.FindProperty("colourDimension"); colourPaletteProperty = serializedObject.FindProperty("coloursPalette"); colourGradientProperty = serializedObject.FindProperty("dimensionColour"); blendingModeSourceProperty = serializedObject.FindProperty("blendingModeSource"); blendingModeDestinationProperty = serializedObject.FindProperty("blendingModeDestination"); sizeDimensionProperty = serializedObject.FindProperty("sizeDimension"); minSizeProperty = serializedObject.FindProperty("minSize"); maxSizeProperty = serializedObject.FindProperty("maxSize"); linkingDimensionProperty = serializedObject.FindProperty("linkingDimension"); visualisationTypeProperty = serializedObject.FindProperty("visualisationType"); attributeFiltersProperty = serializedObject.FindProperty("attributeFilters"); colorPaletteDimensionProperty = serializedObject.FindProperty("colorPaletteDimension"); widthProperty = serializedObject.FindProperty("width"); heightProperty = serializedObject.FindProperty("height"); depthProperty = serializedObject.FindProperty("depth"); xScatterplotMatrixDimensionsProperty = serializedObject.FindProperty("xScatterplotMatrixDimensions"); yScatterplotMatrixDimensionsProperty = serializedObject.FindProperty("yScatterplotMatrixDimensions"); zScatterplotMatrixDimensionsProperty = serializedObject.FindProperty("zScatterplotMatrixDimensions"); parallelCoordinatesDimensionsProperty = serializedObject.FindProperty("parallelCoordinatesDimensions"); scatterplotMatrixListX = new UnityEditorInternal.ReorderableList( serializedObject, xScatterplotMatrixDimensionsProperty, true, true, true, true); scatterplotMatrixListY = new UnityEditorInternal.ReorderableList( serializedObject, yScatterplotMatrixDimensionsProperty, true, true, true, true); scatterplotMatrixListZ = new UnityEditorInternal.ReorderableList( serializedObject, zScatterplotMatrixDimensionsProperty, true, true, true, true); dimensionsListParallelCoordinates = new UnityEditorInternal.ReorderableList( serializedObject, parallelCoordinatesDimensionsProperty, true, true, true, true ); scatterplotMatrixListX.onAddCallback = (UnityEditorInternal.ReorderableList list) => { Visualisation targetVisualisation = (Visualisation)serializedObject.targetObject; Array.Resize(ref targetVisualisation.xScatterplotMatrixDimensions, targetVisualisation.xScatterplotMatrixDimensions.Length + 1); EditorUtility.SetDirty(serializedObject.targetObject); }; scatterplotMatrixListY.onAddCallback = (UnityEditorInternal.ReorderableList list) => { Visualisation targetVisualisation = (Visualisation)serializedObject.targetObject; Array.Resize(ref targetVisualisation.yScatterplotMatrixDimensions, targetVisualisation.yScatterplotMatrixDimensions.Length + 1); EditorUtility.SetDirty(serializedObject.targetObject); }; scatterplotMatrixListZ.onAddCallback = (UnityEditorInternal.ReorderableList list) => { Visualisation targetVisualisation = (Visualisation)serializedObject.targetObject; Array.Resize(ref targetVisualisation.zScatterplotMatrixDimensions, targetVisualisation.zScatterplotMatrixDimensions.Length + 1); EditorUtility.SetDirty(serializedObject.targetObject); }; dimensionsListParallelCoordinates.onAddCallback = (UnityEditorInternal.ReorderableList list) => { Visualisation targetVisualisation = (Visualisation)serializedObject.targetObject; Array.Resize(ref targetVisualisation.parallelCoordinatesDimensions, targetVisualisation.parallelCoordinatesDimensions.Length + 1); EditorUtility.SetDirty(serializedObject.targetObject); }; dimensionsListParallelCoordinates.drawElementCallback = drawDimensionFilterElementParalleCoordinates; scatterplotMatrixListX.drawElementCallback = drawDimensionFilterElementscatterplotMatrixListX; scatterplotMatrixListY.drawElementCallback = drawDimensionFilterElementscatterplotMatrixListY; scatterplotMatrixListZ.drawElementCallback = drawDimensionFilterElementscatterplotMatrixListZ; dimensionsListParallelCoordinates.elementHeight = EditorGUIUtility.singleLineHeight * 4f; scatterplotMatrixListX.elementHeight = EditorGUIUtility.singleLineHeight * 4f; scatterplotMatrixListY.elementHeight = EditorGUIUtility.singleLineHeight * 4f; scatterplotMatrixListZ.elementHeight = EditorGUIUtility.singleLineHeight * 4f; dimensionsListParallelCoordinates.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Parallel Coordinate Plot Dimensions"); }; scatterplotMatrixListX.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "X Scatterplot Matrix dimensions"); }; scatterplotMatrixListY.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Y Scatterplot Matrix dimensions"); }; scatterplotMatrixListZ.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Z Scatterplot Matrix dimensions"); }; if (dataSourceProperty != null) { dataSource = (DataSource)dataSourceProperty.objectReferenceValue; if (dataSource != null) { if (dataSource.IsLoaded) { loadData(); } else { dataSource.onLoad += OnDataSourceLoad; if (!dataSource.IsLoaded) { dataSource.load(); } } } } }
public void UpdateProperties(AbstractVisualisation.PropertyType propertyType, Visualisation v) { legend = ""; if (v.colourDimension != "Undefined") { gradientColorLineRenderer.gameObject.SetActive(true); legend += "Colour: " + v.colourDimension + "\n"; SetGradientColor(v.dimensionColour); } if (v.sizeDimension != "Undefined") { legend += "Size: " + v.sizeDimension + "\n"; } if (v.linkingDimension != "Undefined") { legend += "Linking Attribute: " + v.linkingDimension + "\n"; } if (v.colorPaletteDimension != "Undefined") { gradientColorLineRenderer.gameObject.SetActive(false); legend += "Colour: " + v.colorPaletteDimension + "\n"; float[] uniqueValues = v.dataSource[v.colorPaletteDimension].MetaData.categories; string[] stringValues = new string[uniqueValues.Length]; for (int i = 0; i < uniqueValues.Length; i++) { stringValues[i] = v.dataSource.getOriginalValue(uniqueValues[i], v.colorPaletteDimension).ToString(); } for (int i = 0; i < v.coloursPalette.Length; i++) { legend += "<color=#" + ColorUtility.ToHtmlStringRGB(v.coloursPalette[i]) + "> *** </color>" + stringValues[i] + "\n"; } } Legend.text = legend; }
public void UpdateProperties(AbstractVisualisation.PropertyType propertyType, Visualisation v) { legend = ""; // Facet by if (v.attributeFilters != null && v.attributeFilters.Length > 0 && v.attributeFilters[0].Attribute != "Undefined") { legend += "<b>Facet By:</b> " + v.attributeFilters[0].Attribute + "\n"; } // Size by if (v.sizeDimension != "Undefined") { legend += "<b>Size By:</b> " + v.sizeDimension + "\n"; } // Linking dimension if (v.linkingDimension != "Undefined") { legend += "<b>Linking Attribute:<b> " + v.linkingDimension + "\n"; } // Visualisation can only have a color dimension or a color palette dimension, not both // Color by if (v.colourDimension != "Undefined") { gradientColorLineRenderer.gameObject.SetActive(true); legend += "<b>Colour By:</b> " + v.colourDimension + "\n"; SetGradientColor(v.dimensionColour); } // Color palette else if (v.colorPaletteDimension != "Undefined") { gradientColorLineRenderer.gameObject.SetActive(false); legend += "<b>Colour:</b> " + v.colorPaletteDimension + "\n"; List <float> categories = v.dataSource[v.colorPaletteDimension].MetaData.categories.ToList(); string[] values = new string[categories.Count]; for (int i = 0; i < categories.Count; i++) { values[i] = v.dataSource.getOriginalValue(categories[i], v.colorPaletteDimension).ToString(); } // Sort categories List <float> sortedCategories = categories.OrderBy(x => x).ToList(); for (int i = 0; i < v.coloursPalette.Length; i++) { int idx = categories.IndexOf(sortedCategories[i]); legend += "<color=#" + ColorUtility.ToHtmlStringRGB(v.coloursPalette[idx]) + "> ||||| </color>" + values[idx] + "\n"; } } // Hide the gradient if no color by if (v.colourDimension == "Undefined") { gradientColorLineRenderer.gameObject.SetActive(false); } Legend.text = legend; }