private void Create2DVisualisation(int i, int j)
        {
            ViewBuilder builder = new ViewBuilder(geometryToMeshTopology(creationConfiguration.Geometry), "Scatterplot Matrix");

            builder.initialiseDataView(visualisationReference.dataSource.DataCount);

            builder.setDataDimension(visualisationReference.dataSource[visualisationReference.xScatterplotMatrixDimensions[i].Attribute].Data, ViewBuilder.VIEW_DIMENSION.X);
            builder.setDataDimension(visualisationReference.dataSource[visualisationReference.yScatterplotMatrixDimensions[j].Attribute].Data, ViewBuilder.VIEW_DIMENSION.Y);

            View v = ApplyGeometryAndRendering(creationConfiguration, ref builder);

            //destroy the view to clean the big mesh

            if (v != null)
            {
                v.transform.localPosition = new Vector3(i * xPadding, j * yPadding, 0);
                v.transform.SetParent(transform, false);
                viewList.Add(v);
            }
        }
Esempio n. 2
0
        // ******************************
        // SPECIFIC VISUALISATION METHODS
        // ******************************

        private View CreateSimpleVisualisation(CreationConfiguration configuration)
        {
            if (visualisationReference.dataSource != null)
            {
                if (!visualisationReference.dataSource.IsLoaded)
                {
                    visualisationReference.dataSource.load();
                }

                ViewBuilder builder = new ViewBuilder(geometryToMeshTopology(configuration.Geometry), "Simple Visualisation");

                if ((visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.X)] != null) ||
                    (visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.Y)] != null) ||
                    (visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.Z)] != null))
                {
                    builder.initialiseDataView(visualisationReference.dataSource.DataCount);

                    if (visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.X)] != null)
                    {
                        builder.setDataDimension(visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.X)].Data, ViewBuilder.VIEW_DIMENSION.X);
                    }
                    if (visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.Y)] != null)
                    {
                        builder.setDataDimension(visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.Y)].Data, ViewBuilder.VIEW_DIMENSION.Y);
                    }
                    if (visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.Z)] != null)
                    {
                        builder.setDataDimension(visualisationReference.dataSource[getAxis(configuration.Axies, CreationConfiguration.Axis.Z)].Data, ViewBuilder.VIEW_DIMENSION.Z);
                    }

                    //destroy the view to clean the big mesh
                    destroyView();

                    //return the appropriate geometry view
                    return(ApplyGeometryAndRendering(creationConfiguration, ref builder));
                }
            }

            return(null);
        }
Esempio n. 3
0
        public void LinkVisualisations()
        {
            View pv = GetComponentInChildren <View>();

            if (pv != null)
            {
                DestroyImmediate(pv.gameObject);
            }

            ViewBuilder viewLinked;

            Vector3[]    vSource = visualisationSource.theVisualizationObject.viewList[0].GetPositions(); // bigMesh.getBigMeshVertices();
            Vector3[]    vDest   = visualisationTarget.theVisualizationObject.viewList[0].GetPositions(); // bigMesh.getBigMeshVertices();
            List <Color> colors  = new List <Color>();

            Color[] cSource = visualisationSource.theVisualizationObject.viewList[0].GetColors(); // bigMesh.getColors();
            Color[] cDest   = visualisationTarget.theVisualizationObject.viewList[0].GetColors(); // bigMesh.getColors();

            List <Vector3> vertexBuffer = new List <Vector3>();
            List <int>     indexBuffer  = new List <int>();

            List <float>   positionsLocalX = new List <float>();
            List <float>   positionsLocalY = new List <float>();
            List <float>   positionsLocalZ = new List <float>();
            List <Vector3> normalsBuffer   = new List <Vector3>();

            for (int i = 0; i < vSource.Length; i++)
            {
                positionsLocalX.Add((vSource[i]).x);
                positionsLocalX.Add((vDest[i]).x);
                positionsLocalY.Add((vSource[i]).y);
                positionsLocalY.Add((vDest[i]).y);
                positionsLocalZ.Add((vSource[i]).z);
                positionsLocalZ.Add((vDest[i]).z);

                colors.Add(cSource[i]);
                colors.Add(cDest[i]);

                normalsBuffer.Add(new Vector3((float)i, 0, 0));
                normalsBuffer.Add(new Vector3((float)i, 0, 1));
            }

            for (int i = 0; i < positionsLocalX.Count; i += 2)
            {
                indexBuffer.Add(i);
                indexBuffer.Add(i + 1);
            }

            viewLinked = new ViewBuilder(MeshTopology.Lines, "Linked Visualisation");
            viewLinked.initialiseDataView(positionsLocalX.Count);
            viewLinked.setDataDimension(positionsLocalX.ToArray(), ViewBuilder.VIEW_DIMENSION.X);
            viewLinked.setDataDimension(positionsLocalY.ToArray(), ViewBuilder.VIEW_DIMENSION.Y);
            viewLinked.setDataDimension(positionsLocalZ.ToArray(), ViewBuilder.VIEW_DIMENSION.Z);

            viewLinked.Indices = indexBuffer;
            viewLinked.updateView();
            view = viewLinked.apply(this.gameObject, linkerMaterial);
            view.SetColors(colors.ToArray());
            view.SetAllChannels(normalsBuffer.ToArray());

            view.RecalculateBounds();

            transform.position = Vector3.zero;
            GetComponentInChildren <View>().transform.position = Vector3.zero;
        }
Esempio n. 4
0
        public override void CreateVisualisation()
        {
            if (visualisationReference.parallelCoordinatesDimensions.Length > 1 && visualisationReference.parallelCoordinatesDimensions.None(x => x == null || x.Attribute == "Undefined"))
            {
                viewList.Clear();
                destroyView();

                ViewBuilder viewParallel;

                List <float> positionsLocalX = new List <float>();
                List <float> positionsLocalY = new List <float>();
                List <float> positionsLocalZ = new List <float>();
                List <int>   indices         = new List <int>();

                for (int i = 0; i < visualisationReference.parallelCoordinatesDimensions.Length; i++)
                {
                    if (visualisationReference.parallelCoordinatesDimensions[i] != null && visualisationReference.parallelCoordinatesDimensions[i].Attribute != "Undefined")
                    {
                        float[] positions = visualisationReference.dataSource[visualisationReference.parallelCoordinatesDimensions[i].Attribute].Data;
                        for (int k = 0; k < positions.Length; k++)
                        {
                            positionsLocalX.Add((float)GameObject_Axes_Holders[i].transform.localPosition.x);
                            positionsLocalY.Add(positions[k] + (float)GameObject_Axes_Holders[i].transform.localPosition.y);
                            positionsLocalZ.Add((float)GameObject_Axes_Holders[i].transform.localPosition.z);
                        }
                    }
                }

                //build indices
                for (int i = 0; i < visualisationReference.dataSource.DataCount; i++)
                {
                    for (int j = 0; j < visualisationReference.parallelCoordinatesDimensions.Length - 1; j++)
                    {
                        indices.Add(j * visualisationReference.dataSource.DataCount + i);
                        indices.Add((j + 1) * visualisationReference.dataSource.DataCount + i);
                    }
                }

                int[] lineLength = new int[visualisationReference.dataSource.DataCount];
                for (int i = 0; i < visualisationReference.dataSource.DataCount; i++)
                {
                    lineLength[i] = visualisationReference.parallelCoordinatesDimensions.Length;
                }

                viewParallel = new ViewBuilder(MeshTopology.Lines, "parallel coordinates");
                viewParallel.initialiseDataView(positionsLocalX.Count);
                viewParallel.setDataDimension(positionsLocalX.ToArray(), ViewBuilder.VIEW_DIMENSION.X);
                viewParallel.setDataDimension(positionsLocalY.ToArray(), ViewBuilder.VIEW_DIMENSION.Y);
                viewParallel.setDataDimension(positionsLocalZ.ToArray(), ViewBuilder.VIEW_DIMENSION.Z);
                viewParallel.Indices    = indices;
                viewParallel.LineLength = lineLength.ToList();
                Material mt = new Material(Shader.Find("IATK/PCPShader"));
                mt.renderQueue = 3000;
                viewParallel.updateView();
                View v = viewParallel.apply(gameObject, mt);

                viewList.Add(v);

                //Creation configuration management
                if (creationConfiguration == null)
                {
                    creationConfiguration = new CreationConfiguration();
                }

                creationConfiguration.VisualisationType             = AbstractVisualisation.VisualisationTypes.PARALLEL_COORDINATES;
                creationConfiguration.parallelCoordinatesDimensions = visualisationReference.parallelCoordinatesDimensions;
                creationConfiguration.colour           = visualisationReference.colour;
                creationConfiguration.ColourDimension  = visualisationReference.colourDimension;
                creationConfiguration.colourKeys       = visualisationReference.dimensionColour;
                creationConfiguration.Geometry         = visualisationReference.geometry;
                creationConfiguration.LinkingDimension = visualisationReference.linkingDimension;
                creationConfiguration.SizeDimension    = visualisationReference.sizeDimension;
                creationConfiguration.Axies            = new Dictionary <CreationConfiguration.Axis, string>();

                //restore properties
                UpdateVisualisation(AbstractVisualisation.PropertyType.Colour);
                UpdateVisualisation(AbstractVisualisation.PropertyType.Size);
                UpdateVisualisation(AbstractVisualisation.PropertyType.SizeValues);
            }
        }
        /// <summary>
        /// returns a View with the specific geometry configuration
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="builder"></param>
        /// <returns></returns>
        protected View ApplyGeometryAndRendering(CreationConfiguration configuration, ref ViewBuilder builder)
        {
            Material mt = null;

            switch (configuration.Geometry)
            {
            case AbstractVisualisation.GeometryType.Undefined:
                return(null);

            case AbstractVisualisation.GeometryType.Points:
                builder.createIndicesPointTopology();
                mt             = new Material(Shader.Find("IATK/OutlineDots"));
                mt.mainTexture = Resources.Load("circle-outline-basic") as Texture2D;
                mt.renderQueue = 3000;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Lines:
                if (visualisationReference.linkingDimension == "Undefined")
                {
                    throw new UnityException("The linking field 'Linkinfield' is undefined. Please select a linking field");
                }
                builder.createIndicesLinkedTopology(visualisationReference.dataSource[visualisationReference.linkingDimension].Data, visualisationReference.dataSource[visualisationReference.xDimension.Attribute].Data);
                mt             = new Material(Shader.Find("IATK/LinesShader"));
                mt.renderQueue = 3000;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Quads:
                builder.createIndicesPointTopology();
                mt             = new Material(Shader.Find("IATK/Quads"));
                mt.renderQueue = 3000;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.LinesAndDots:

                if (visualisationReference.linkingDimension == "Undefined")
                {
                    throw new UnityException("The linking field 'Linkinfield' is undefined. Please select a linking field");
                }
                builder.createIndicesLinkedTopology(visualisationReference.dataSource[visualisationReference.linkingDimension].Data, visualisationReference.dataSource[visualisationReference.xDimension.Attribute].Data);
                mt             = new Material(Shader.Find("IATK/LineAndDotsShader"));
                mt.renderQueue = 3000;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Cubes:
                builder.createIndicesPointTopology();     // createIndicesLinkedTopology(dataSource[linkingDimension].Data);
                mt             = new Material(Shader.Find("IATK/CubeShader"));
                mt.renderQueue = 3000;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Bars:
                builder.createIndicesPointTopology();     // createIndicesLinkedTopology(dataSource[linkingDimension].Data);
                mt             = new Material(Shader.Find("IATK/BarShader"));
                mt.renderQueue = 3000;

                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Spheres:
                builder.createIndicesPointTopology();     // createIndicesLinkedTopology(dataSource[linkingDimension].Data);
                mt             = new Material(Shader.Find("IATK/SphereShader"));
                mt.mainTexture = Resources.Load("sphere-texture") as Texture2D;
                mt.renderQueue = 3000;
                return(builder.updateView().
                       apply(gameObject, mt));

            default:
                return(null);
            }
        }
        /// <summary>
        /// returns a View with the specific geometry configuration
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="builder"></param>
        /// <returns></returns>
        protected View ApplyGeometryAndRendering(CreationConfiguration configuration, ref ViewBuilder builder)
        {
            Material mt = null;

            switch (configuration.Geometry)
            {
            case AbstractVisualisation.GeometryType.Undefined:
                return(null);

            case AbstractVisualisation.GeometryType.Points:
                builder.createIndicesPointTopology();
                mt                  = new Material(Shader.Find("IATK/OutlineDots"));
                mt.mainTexture      = Resources.Load("circle-outline-basic") as Texture2D;
                mt.renderQueue      = 3000;
                mt.enableInstancing = true;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Lines:
                if (visualisationReference.graphDimension != "Undefined")
                {
                    CSVDataSource csvds = (CSVDataSource)(visualisationReference.dataSource);
                    builder.createIndicesGraphTopology(csvds.GraphEdges);
                    mt                  = new Material(Shader.Find("IATK/LinesShader"));
                    mt.renderQueue      = 3000;
                    mt.enableInstancing = true;
                    return(builder.updateView().
                           apply(gameObject, mt));
                }
                else
                if (visualisationReference.linkingDimension != "Undefined")
                {
                    builder.createIndicesConnectedLineTopology(visualisationReference.dataSource[visualisationReference.linkingDimension].Data);
                    mt                  = new Material(Shader.Find("IATK/LinesShader"));
                    mt.renderQueue      = 3000;
                    mt.enableInstancing = true;
                    return(builder.updateView().
                           apply(gameObject, mt));
                }
                else
                {
                    throw new UnityException("'Linkinfield' or 'GraphDimension' is undefined. Please select a linking field or a graph dimension");
                }
                break;

            case AbstractVisualisation.GeometryType.Quads:
                builder.createIndicesPointTopology();
                mt                  = new Material(Shader.Find("IATK/Quads"));
                mt.renderQueue      = 3000;
                mt.enableInstancing = true;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.LinesAndDots:
                if (visualisationReference.graphDimension != "Undefined")
                {
                    CSVDataSource csvds = (CSVDataSource)(visualisationReference.dataSource);
                    builder.createIndicesGraphTopology(csvds.GraphEdges);
                    mt                  = new Material(Shader.Find("IATK/LineAndDotsShader"));
                    mt.renderQueue      = 3000;
                    mt.enableInstancing = true;
                    return(builder.updateView().
                           apply(gameObject, mt));
                }
                if (visualisationReference.linkingDimension != "Undefined")
                {
                    builder.createIndicesConnectedLineTopology(visualisationReference.dataSource[visualisationReference.linkingDimension].Data);
                    mt                  = new Material(Shader.Find("IATK/LineAndDotsShader"));
                    mt.renderQueue      = 3000;
                    mt.enableInstancing = true;
                    return(builder.updateView().
                           apply(gameObject, mt));
                }
                else
                {
                    throw new UnityException("'Linkinfield' or 'GraphDimension' is undefined. Please select a linking field or a graph dimension");
                }


            case AbstractVisualisation.GeometryType.Cubes:
                builder.createIndicesPointTopology();     // createIndicesLinkedTopology(dataSource[linkingDimension].Data);
                mt                  = new Material(Shader.Find("IATK/CubeShader"));
                mt.renderQueue      = 3000;
                mt.enableInstancing = true;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Bars:
                builder.createIndicesPointTopology();     // createIndicesLinkedTopology(dataSource[linkingDimension].Data);
                mt                  = new Material(Shader.Find("IATK/BarShader"));
                mt.renderQueue      = 3000;
                mt.enableInstancing = true;
                return(builder.updateView().
                       apply(gameObject, mt));

            case AbstractVisualisation.GeometryType.Spheres:
                builder.createIndicesPointTopology();     // createIndicesLinkedTopology(dataSource[linkingDimension].Data);
                mt                  = new Material(Shader.Find("IATK/SphereShader"));
                mt.mainTexture      = Resources.Load("sphere-texture") as Texture2D;
                mt.renderQueue      = 3000;
                mt.enableInstancing = true;
                return(builder.updateView().
                       apply(gameObject, mt));

            default:
                return(null);
            }
        }