public override void Do(IDemoChartControl chartControl) { // Generate positions. Vector3F[] positions = DemoHelper.GenerateSinPoints(MapSize); // Creation of surface data presentation. var surface = new ValueSurface { // Data reader approach is used to improve performance for big data sets and their updates. Reader = new StructuredValueSurfaceDataReader( positions, // Surface positions. DemoHelper.ExtractZValues(positions, out OneAxisBounds valueBounds), // Surface values, for demo purposes values are extracted from Z position component, but in real world they are independent, size of array should be the same as for positions. MapSize, // Width and height are required for triangulation of structured grid. MapSize, valueBounds), //Bounds of value axes. // Set presentation option. PresentationType = ValueSurfacePresentationType.SolidAndWireframe, // Set name. Name = "Surface" }; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Setup chart data source. chartControl.DataSource = surface; } }
public override void Do(IDemoChartControl chartControl) { // Load bitmap image. var bitmapSource = new BitmapImage(new Uri(@"pack://application:,,,/Demo.Features;component/Resources/OldBronze.jpg")); // Setup the bitmap as enviroment image of the chart. chartControl.LitSphereBitmap = bitmapSource; // Generate surface mesh. Mesh mesh = GridHelper.GetStructuredParametricGridMesh((x, y) => new Vector3F(x, y, (float)(Math.Sin(x) * Math.Sin(x * x + y * y))), new Vector2F(-3f), new Vector2F(3f), SurfaceResolution, SurfaceResolution); // Create testing surface. var sphere = new Surface { // Set the sphere color. Color = Colors.DarkBlue, // Setup the surface mesh. SurfaceMesh = mesh, // Setup material that will reflect environment image. Material = new RenderMaterial(0.75f, 0.6f, 0.3f, 0f, 1f), // Set name. Name = "Surface" }; // Setup chart control options. chartControl.Axes.IsAxes3DVisible = true; // Setup chart control data source. chartControl.DataSource = sphere; }
public override void Do(IDemoChartControl chartControl) { // Generate positions. var positions = new Vector3F[PointsCount]; for (int i = 0; i < PointsCount; i++) { positions[i] = new Vector3F( (float)Random.NextDouble() * MaxRadius, (float)Random.NextDouble() * MaxRadius, (float)Random.NextDouble() * MaxRadius); } // Creation of data presentation. var points = new ValuePoints { // Reader can be reused and we can create several presentations for 1 reader. Reader = new DefaultPositionValueMaskDataReader( positions, // Points positions. DemoHelper.ExtractZValues(positions, out OneAxisBounds valueBounds), // Points values, for demo purposes values are extracted from Z position component, but in real world they are independent. valueBounds), // We must specify value axis bounds. // Set name. Name = "Points" }; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Set chart data source. chartControl.DataSource = points; } }
public override void Do(IDemoChartControl chartControl) { // Load bitmap image. var colorTextureSource = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Demo.Features;component/Resources/bump01.bmp")); float ratio = (float)colorTextureSource.PixelHeight / colorTextureSource.PixelWidth; // Create default reader for Wpf bitmap sources. var reader = new BitmapSourceRasterImage2DReader(colorTextureSource); // Create bump reader. var bumpReader = new BitmapSourceRasterImage2DReader(bumpTextureSource); // Create geometry for both raster data-s. var geometry = new RectTextureGeometry { Origin = Vector3F.Zero, DirectionX = Vector3F.UnitX, DirectionY = Vector3F.UnitY, Size = new Vector2F(1f, ratio) }; // Create non-bump raster data object. var rasterData = new RasterData { // Set image interpolation type. InterpolationType = RasterDataInterpolationType.Linear, // Set image reader. Reader = reader, // Set name. Name = "Default", // Set geometry Geometry = geometry }; // Create bump render data object. var bumpRasterData = new RasterData { // Set image interpolation type. InterpolationType = RasterDataInterpolationType.Linear, // Set image reader. Reader = reader, // Set bump image reader. BumpReader = bumpReader, // Set name. Name = "Bump", // Specify some material custom settings. Material = new RenderMaterial(0.25f, 0.6f, 0.6f, 0f, 0f), // Set geometry Geometry = geometry }; // Setup bump raster data offset matrix. bumpRasterData.Transform = Matrix4F.Translation(1.25f, 0, 0); // Setup chart data source. chartControl.DataSource = new RenderData[] { rasterData, bumpRasterData }; }
public override void Do(IDemoChartControl chartControl) { // Generate positions. Note: making Z and Y positions scaled. var positions = new Vector3F[PointsCount]; for (int i = 0; i < PointsCount; i++) { positions[i] = new Vector3F( (float)Random.NextDouble() * MaxRadius, (float)Random.NextDouble() * MaxRadius * ScalingY, (float)Random.NextDouble() * MaxRadius * ScalingZ); } // Creation of data presentation. var points = new SingleColorPoints { // Reader approach is used to improve performance for big data sets and their updates. Reader = new DefaultPositionMaskDataReader(positions), // Set points color. Color = Colors.DarkBlue, // Set name. Name = "Points" }; // Setup camera 3D aspect ratio. // Here we specify that we want to fit our data into [1; 1; 1] cube. chartControl.ContextView.Camera3D.AspectRatio = new AspectRatio(PreferableAxis.Z, new Vector3 <float?>(1, 1, 1)); // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Set chart data source. chartControl.DataSource = points; }
public override void Do(IDemoChartControl chartControl) { const float distToLarge = 0.5f; const float distToSmall = 1.0f; var largeCenters = new Vector3F[6]; var smallCenters = new Vector3F[6]; // Create positions. for (var i = 0; i < 6; i++) { var cos = (float)Math.Cos(Math.PI / 3 * i); var sin = (float)Math.Sin(Math.PI / 3 * i); largeCenters[i] = new Vector3F(cos * distToLarge, sin * distToLarge, 0); smallCenters[i] = new Vector3F(cos * distToSmall, sin * distToSmall, 0); } var list = new List <RenderData>(); AddAtoms(list, new[] { new AtomsDescription { Col = Colors.Purple, R = 0.57f, Positions = largeCenters }, new AtomsDescription { Col = Colors.Gold, R = 0.3f, Positions = smallCenters } }); // Show result. chartControl.Axes.IsAxes3DVisible = true; chartControl.DataSource = list; }
public override void Do(IDemoChartControl chartControl) { // Create custom data reader. var floatReader = new MyRasterDataReader(Width, Height, new OneAxisBounds(0, 1, 0, 0.1f)); // Create raster data object. var floatRasterData = new ValueRasterData { // Enable value linear interpolation. InterpolationType = RasterDataInterpolationType.Linear, // Set data reader. Reader = floatReader, // Set geometry. Geometry = new RectTextureGeometry { Origin = Vector3F.Zero, Size = new Vector2F(1f, 1f) }, // Set name. Name = "Image" }; // Setup view settings. chartControl.ContextView.Mode2D = true; chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos; // Set data source. chartControl.DataSource = new RenderData[] { floatRasterData }; // Start animation. animation.Start( (f) => f > 1 ? 0 : f, rf => floatReader.RandomizeValues(rf), 0, 0.00025f, 16); }
public override void Do(IDemoChartControl chartControl) { chartControl.Axes.IsAxes3DVisible = true; chartControl.DataSource = new Prism[] { new Prism { //Prism side should be defined in 2d space by convex polygon Side = new[] { new Vector2F(-0.5f, 0), new Vector2F(-0.5f, 1), new Vector2F(1, 1) }, //Vector that define translate between top and bottom sides BottomToTopVector = Vector3F.UnitZ, Color = Colors.Cyan, Transform = Matrix4F.RotationAxis(Vector3F.UnitY, -Math.PI / 4), Name = "Prism 1" }, new Prism { //Prism side should be defined in 2d space by convex polygon Side = new[] { new Vector2F(1, 0), new Vector2F(0.4f, 0.5f), new Vector2F(1) }, //Vector that define translate between top and bottom sides BottomToTopVector = new Vector3F(0.5f, 0.5f, 0.5f), Color = Colors.Blue, Name = "Prism 2" } }; }
public override void Do(IDemoChartControl chartControl) { // Create custom data reader. var dataReader = new CustomSeriesDataReader(PointCount); // Create series. var series = new Series { // Set data reader. Reader = dataReader, // Set series line color. Color = Colors.Blue, // Set series line thickness. Thickness = 2.0f, // Set series line pattern style. PatternStyle = PatternStyle.Solid, // Set series marker color. MarkerColor = Colors.Red, // Set series marker style. MarkerStyle = MarkerStyle.Cross, // Set name. Name = "Line" }; // Setup chart view settings. chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos; chartControl.ContextView.Mode2D = true; chartControl.ViewResetOptions.ResetOnDataChanged = false; // Setup chart data source. chartControl.DataSource = series; // Start animation. animationHelper.Start(value => value, value => dataReader.RandomizePoint(5f, 25), 0f, 0f, 25); }
public override void Do(IDemoChartControl chartControl) { var random = new Random(DateTime.Now.Millisecond); // Generate demo structured surface. Vector3F[] positions = DemoHelper.GenerateSinPoints(size); // Randomly remove points from that grid for irregular grid, only 30% will be taken from original grid. Vector3F[] irregularPositions = positions.Where(t => random.NextDouble() > 0.7).ToArray(); // Surface data presentation creation. var surface = new ValueSurface { // Reader can be reused and we can create several presentations for 1 reader. // Note: this reader provider default implementation, so feel free to implement your own logic. Reader = new IrregularValueSurfaceDataReader( irregularPositions, // Define surface points. DemoHelper.ExtractZValues(irregularPositions, out OneAxisBounds valueBounds), // Surface values, here they are equal to Z values . 2, // As data is irregular in 2D space we should specify exclude axis index for triangulation. valueBounds), //Value axis bounds. // Setup presentation option. PresentationType = ValueSurfacePresentationType.SolidAndWireframe, // Set name. Name = "Surface" }; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos; // Set data source. chartControl.DataSource = surface; } }
public override void Do(IDemoChartControl chartControl) { var points = new SingleColorPoints { // Reader approach is used to improve performance for big data sets and their updates. Reader = new DefaultPositionMaskDataReader(GetPoints()), // Set points color. Color = Colors.DarkBlue, // Set name. Name = "Points" }; // Setup chart settings. Note: for cylindrical system feel free to specify any axis as height axis. // Currently we're using Z as height axis. chartControl.Axes.IsAxes3DVisible = true; chartControl.Axes.CylindricalSettings.ZAxisAxisIndex = 2; chartControl.Axes.CoordinateSystem = CoordinateSystem.Cylindrical; // Setup several axis settings. chartControl.Axes.R.AxisThickness = 2.0f; chartControl.Axes.R.AxisColor = Colors.Red; chartControl.Axes.Phi.AxisThickness = 2.0f; chartControl.Axes.Phi.AxisColor = Colors.Green; chartControl.Axes.Z.AxisThickness = 2.0f; chartControl.Axes.Z.AxisColor = Colors.Blue; // Set chart data source. chartControl.DataSource = points; }
public override void Do(IDemoChartControl chartControl) { // Generate error bar data as a set of error points. ErrorPoint[] data = DemoDataHelper.GetStripData(-5, 5, PointCount, arg => new ErrorPoint( new Vector3F(arg, 0, 2 + (float)Math.Sin(arg) * (float)Math.Sin(arg)), (float)Math.Sin(arg * 21) / 15 - 0.1f, (float)Math.Sin(arg * 29) / 15 + 0.1f) ); // Create error bar render data. var errorBars = new ErrorBars { // Set data. Data = data, // Set color. Color = Colors.BlueViolet, // Set bar types. ErrorBarType = ErrorBarType.Bars, // Set type. Name = "Errors", }; chartControl.ContextView.Mode2D = true; chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosZPos; chartControl.DataSource = errorBars; }
public override void Do(IDemoChartControl chartControl) { // Create our widget. var distanceWidget = new DistanceWidget { Name = "Widget" }; // Bounding box. var boundingCube = new Cube { Size = new Vector3F(1f), Position = new Vector3F(0.5f), Color = Colors.Red, PresentationType = PrimitivePresentationType.Wireframe, Name = "Bounds" }; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Setup chart data source. chartControl.DataSource = new RenderData[] { boundingCube, distanceWidget }; }
public override void Do(IDemoChartControl chartControl) { var data = new List <Cube>(); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { var cube = new Cube { Position = new Vector3F(x, y, z), Size = new Vector3F(0.9f), Color = Colors.DarkBlue, Interactor = new MyDataInteractor(), IsLegendVisible = false, Name = "Cube " + z * 9 + y * 3 + x }; data.Add(cube); } } } chartControl.Axes.IsAxes3DVisible = false; chartControl.DataSource = data; }
public override void Do(IDemoChartControl chartControl) { // Generate positions. var positions = new Vector3F[PointsCount]; for (int i = 0; i < PointsCount; i++) { positions[i] = new Vector3F( (float)Random.NextDouble() * MaxRadius, (float)Random.NextDouble() * MaxRadius, (float)Random.NextDouble() * MaxRadius); } // Creation of data presentation. var points = new SingleColorPoints { // Reader approach is used to improve performance for big data sets and their updates. Reader = new DefaultPositionMaskDataReader(positions), // Set points color. Color = Colors.DarkBlue, // Set name. Name = "Points" }; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Set chart data source. chartControl.DataSource = points; }
public override void Do(IDemoChartControl chartControl) { const int pointsCount = 10_000; const float amplitude = 0.6f; chartControl.ContextView.Mode2D = true; // Generate points for line. var points = new Vector3F[pointsCount]; for (var i = 0; i < pointsCount; i++) { float scaledCoord = i / (float)pointsCount; points[i] = new Vector3F( scaledCoord, amplitude * (float)(Math.Cos(5 * 2 * Math.PI * scaledCoord) + 0.5f), amplitude * (float)(Math.Sin(5 * Math.PI * scaledCoord) + 0.5f)); } // Create line. chartControl.DataSource = new Line { Points = points, //If strip is true - than points are connected one by one, otherwise line list is used which means that pair of points is used to create one line segment. Strip = true, Thickness = 2f, Color = Colors.DarkBlue, Name = "Line" }; }
public override void Stop(IDemoChartControl chartControl) { // Don't forget to remove event listener when it's not required. chartControl.ActionController.RemoveHandler(eventListener); // Stop the animation. animationHelper.Stop(); }
public override void Do(IDemoChartControl chartControl) { chartControl.Axes.IsAxes3DVisible = true; chartControl.DataSource = new Cone[] { new Cone { //Cone direction Direction = Vector3F.UnitZ, Color = Colors.Cyan, //Position relative to base center Position = new Vector3F(), //Resolution for radial part of item. Means number of generated points Resolution = 20, //Height Height = 0.5f, //Base radius Radius = 0.5f, //Primitive presentation type PresentationType = PrimitivePresentationType.Solid, Name = "Cone 1" }, new Cone { //Cone direction Direction = -Vector3F.UnitZ, Color = Colors.Blue, //Position relative to base center Position = new Vector3F(0, 0, 1), //Resolution for radial part of item. Means number of generated points Resolution = 200, //Height Height = 0.5f, //Base radius Radius = 0.3f, //Primitive presentation type PresentationType = PrimitivePresentationType.Solid, Name = "Cone 2" }, new Cone { //Cone direction Direction = new Vector3F(0, 1, 0), Color = Colors.DarkBlue, //Position relative to base center Position = new Vector3F(0, -0.5f, 0.5f), //Resolution for radial part of item. Means number of generated points Resolution = 30, //Height Height = 0.5f, //Base radius Radius = 0.1f, //Primitive presentation type PresentationType = PrimitivePresentationType.Wireframe, Name = "Cone 3" }, }; }
public override void Do(IDemoChartControl chartControl) { // Demo volumetric binary data from resources. byte[] data = Properties.Resources.skull; // Size of data is the same in all 3 dimensions. var size = (int)Math.Round(Math.Pow(data.Length, 1d / 3d)); // Create default transfer function and customize it. var transferFunction = new DefaultTransferFunction1D( new [] { new Vector2DRef(0.2, 0.0), new Vector2DRef(0.2, 1.0), }); // Initialization of rendering technique. var rayCasting = new VolumeRayCasting { // Link to data. Several rendering techniques can use the same data. For reader we should specify link to binary data, slice size, and value axis bounds. // For dynamic updates of data you can implement your own reader, basic reader interface provide neccessary methods for updating separate data regions. // Byte, Short, Float types are supported. Reader = new ByteIntensityImage3DReader(data, size, size, new OneAxisBounds(data.Min(), data.Max())), // Geometry specify bounding box to that volume data will be fitted. Geometry can be more complex than just box. // Mostly it does nothave limits, you can specify even sphere. Geometry = new BoxVolumeGeometry { Origin = Vector3F.Zero, Size = new Vector3F(1f), }, // Interpolation type between voxels/ InterpolationType = VolumeInterpolationType.Linear, // Parameter for ray casting technique that will specify how much steps will be on a each ray. // Directly effects performance and render quality. By default it is calculated automatically. SamplingStepCount = size, // Threshold for transparent areas that will no be visible for hit testing. // 0 will increase picking performance due to item will be picked by bounding box. HitTestThreshold = 0.25f, // The same as HitTestThreshold, but for highlighting. This parameter was set just for demo purposes. HighlightThreshold = 0.25f, // Global value transparency scale. ValueScale = 0.25f, // Setup custom transfer function. TransferFunction1D = transferFunction, // Set name. Name = "Volume" }; // Setup highlight interactor. rayCasting.Interactor = new HighlightInteractor(rayCasting); // Decrease multisampling level to improve interaction experience. chartControl.Multisampling = Multisampling.Low2X; // Set chart data source. chartControl.DataSource = rayCasting; }
public override void Do(IDemoChartControl chartControl) { // Demo volumetric binary data from resources. byte[] data = Properties.Resources.skull; // Size of data is the same in all 3 dimensions. var size = (int)Math.Round(Math.Pow(data.Length, 1d / 3d)); // Very simple sphere generation algorithm. const int resolution = 50; const float r = 0.5f; var center = new Vector3F(0.5f); var vertex = new Vector3F[resolution * resolution]; int index = 0; for (var i = 0; i < resolution; i++) { // We use here inversed order due to triangle list indicies generation algorythm. // It is very important to use correct counterclockwise triangle indices generation for raycasting. for (int k = resolution - 1; k >= 0; k--) { var t = Math.PI * i / (resolution - 1); var f = Math.PI * 2 * k / (resolution - 1); vertex[index++] = new Vector3F((float)(r * Math.Sin(t) * Math.Cos(f)), (float)(r * Math.Sin(t) * Math.Sin(f)), (float)(r * Math.Cos(t))) + center; } } // Section geometry. var complexGeometry = new CustomVolumeGeometry(new VolumeMesh(vertex, vertex, GridHelper.GetStructuredTriangleListIndices(0, resolution, resolution, 1))); // Initialization of rendering technique. var rayCasting = new VolumeRayCasting { //Link to data. Several rendering techniques can use the same data. For reader we should specify link to binary data, slice size, and value axis bounds. //For dynamic updates of data you can implement your own reader, basic reader interface provide neccessary methods for updating separate data regions. //Byte, Short, Float types are supported. Reader = new ByteIntensityImage3DReader(data, size, size, new OneAxisBounds(data.Min(), data.Max())), Geometry = complexGeometry, //Interpolation type between voxels InterpolationType = VolumeInterpolationType.Linear, //Parameter for ray casting technique that will specify how much steps will be on a each ray. Directly effects performance and render quality. By default it is calculated automatically. SamplingStepCount = size, //Threshold for transparent areas that will no be visible for hit testing. 0 will increase picking performance due to item will be picked by bounding box. HitTestThreshold = 0.25f, //Global value transparency scale ValueScale = 0.5f }; // Decrease multisampling level to improve interaction experience. chartControl.Multisampling = Multisampling.Low2X; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Setup chart data source. chartControl.DataSource = rayCasting; }
public override void Do(IDemoChartControl chartControl) { // Enable 3D axes. chartControl.Axes.IsAxes3DVisible = true; // Setup data source. chartControl.DataSource = new MyMulticolorPrimitive { Name = "My object" }; }
public override void Do(IDemoChartControl chartControl) { List <RenderData> renderDatas = new List <RenderData>(); for (int i = 0; i < SeriesCount; i++) { // Create custom data reader. var dataReader = new CustomSeriesDataReader(PointCount, 1f, i); dataReaders.Add(dataReader); // Create series. Color4 color = DemoHelper.RandomizeColor(); var series = new Series { // Set data reader. Reader = dataReader, // Set series line color. Color = color, // Set series line thickness. Thickness = 2f, // Set series line pattern style. PatternStyle = PatternStyle.Solid, // Set series marker style. MarkerStyle = markers[i % markers.Length], // Set marker size. MarkerSize = 12, // Set marker color. MarkerColor = color, // Set name. Name = $"Line {i}" }; renderDatas.Add(series); } // Setup chart view settings. chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos; chartControl.ContextView.Mode2D = true; // Tell the chart that we wanna update view on bounds change. chartControl.ViewResetOptions.ResetOnDataChanged = true; // Setup chart data source. chartControl.DataSource = renderDatas; // Start animation. animationHelper.Start(value => value, value => { foreach (CustomSeriesDataReader dataReader in dataReaders) { dataReader.RandomizePoint(); } }, 0f, 0f, 25); }
public override void Do(IDemoChartControl chartControl) { chartControl.Axes.IsAxes3DVisible = true; chartControl.DataSource = new Disk[] { new Disk { //Resolution for radial part of item. Means number of generated points Resolution = 200, //Item position relative to center Position = new Vector3F(), Color = Colors.Cyan, //Item direction vector Direction = Vector3F.UnitZ, //Item radius Radius = 0.5f, //Item total height Height = 0.4f, Name = "Disk 1" }, new Disk { //Resolution for radial part of item. Means number of generated points Resolution = 20, //Item position relative to center Position = new Vector3F(0f, 0f, 0.3f), Color = Colors.Blue, //Item direction vector Direction = Vector3F.UnitX, //Item radius Radius = 0.1f, //Item height Height = 0.8f, Name = "Disk 2" }, new Disk { //Resolution for radial part of item. Means number of generated points Resolution = 100, //Item position relative to center Position = new Vector3F(0.2f, 0.2f, 0.5f), Color = Colors.DarkBlue, //Item direction vector Direction = new Vector3F(0.5f, 0.5f, 0.5f), //Item radius Radius = 0.2f, //Item height Height = 0.04f, PresentationType = PrimitivePresentationType.Wireframe, Name = "Disk 3" }, }; }
public override void Do(IDemoChartControl chartControl) { const int pointsCount = 1_000; const float amplitude = 0.6f; // Calculate points on line. var points = new Vector3F[pointsCount]; for (var i = 0; i < pointsCount; i++) { float scaledCoord = i / (float)pointsCount; points[i] = new Vector3F( scaledCoord, amplitude * (float)(Math.Cos(5 * 2 * Math.PI * scaledCoord) + 0.5f), amplitude * (float)(Math.Sin(5 * Math.PI * scaledCoord) + 0.5f)); } // Create line. var line = new Line { Points = points, Strip = true, Color = Colors.Blue, Thickness = 3, Name = "Main line" }; // Add labels. const int labelStep = 100; var renderData = new List <RenderData> { line }; int labelIndex = 0; for (var i = 0; i < pointsCount; i += labelStep) { renderData.Add(new Label { Text = (i / labelStep).ToString(), FontFamily = "Arial", FontSize = 18, Transform = Matrix4F.Translation(points[i]), Background = Colors.White, Name = $"Label {labelIndex++}" }); } // Show axes. chartControl.Axes.IsAxes3DVisible = true; // Show result. chartControl.DataSource = renderData.ToArray(); }
public override void Do(IDemoChartControl chartControl) { // Create check marker. var crossMarker = new CrossMarker { Name = "Marker", IsLegendVisible = false }; // Here we'll store our render datas and its snap targets. var snapTargets = new List <ISnapTarget>(); var renderDatas = new List <RenderData> { crossMarker }; ; // Create some visual data. for (int i = 0; i < Sizes.Length; i++) { // Generate vertices. Vector3F[] vertices = GetPositions(Sizes[i]); // Create series. Series series = GetSeries(vertices, ShapeColors[i]); series.Name = $"Series {i}"; renderDatas.Add(series); // Create line snap target. var lineSnapTarget = new LineSnapTarget(vertices, true) { // Specify vertex snap distance (measured in snap context distance units). VertexSnapDistance = 0.025f }; snapTargets.Add(lineSnapTarget); } // Create colletion snap target since we want to snap to several lines. var snapTarget = new CollectionSnapTarget(snapTargets); // Regsiter event listener. chartControl.ActionController.RegisterHandler(1, eventListener = new ChartEventListener(crossMarker, snapTarget)); // Setup chart view options. chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos; chartControl.ContextView.Mode2D = true; chartControl.ViewResetOptions.ResetOnDataChanged = false; // Setup chart data source. chartControl.DataSource = renderDatas; }
public override void Do(IDemoChartControl chartControl) { // Generates surface positions. const int resolution = 50; const float r = 0.5f; var center = new Vector3F(0.5f); var vertex = new Vector3F[resolution * resolution]; var index = 0; for (var i = 0; i < resolution; i++) { for (var k = 0; k < resolution; k++) { double t = Math.PI * i / (resolution - 1); double f = Math.PI * 2 * k / (resolution - 1); vertex[index++] = new Vector3F((float)(r * Math.Sin(t) * Math.Cos(f)), (float)(r * Math.Sin(t) * Math.Sin(f)), (float)(r * Math.Cos(t))) + center; } } // Section geometry. var complexGeometry = new CustomVolumeGeometry(new VolumeMesh(vertex, vertex, GridHelper.GetStructuredTriangleListIndices(0, resolution, resolution, 1))); // Demo volumetric binary data from resources. byte[] data = Properties.Resources.skull; // Size of data is the same in all 3 dimensions. var size = (int)Math.Round(Math.Pow(data.Length, 1d / 3d)); // Byte, Short, Float types are supported. var reader = new ByteIntensityImage3DReader(data, size, size, new OneAxisBounds(data.Min(), data.Max())); // Create volume section render data. var section = new VolumeSection { // Set section data reader. Reader = reader, // Set section geometry. Geometry = complexGeometry, // Set section interpolation type. InterpolationType = VolumeInterpolationType.Linear, // Set name. Name = "Section" }; // Enable 3D axis. chartControl.Axes.IsAxes3DVisible = true; // Set chart data source. chartControl.DataSource = new RenderData[] { section }; }
public override void Do(IDemoChartControl chartControl) { // Generate surface mesh. Mesh mesh = GridHelper.GetStructuredParametricGridMesh((x, y) => new Vector3F(x, y, (float)(Math.Sin(x) * Math.Sin(x * x + y * y))), new Vector2F(-3f), new Vector2F(3f), SurfaceResolution, SurfaceResolution); // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Set chart data soruce. chartControl.DataSource = new Surface { SurfaceMesh = mesh, Name = "Surface" }; }
public override void Do(IDemoChartControl chartControl) { // Adding some intersecting semi-transparent objects. var cube = new Cube { Position = new Vector3F(0.5f), Size = new Vector3F(1f), Color = new Color4(Colors.DarkBlue, 150), Name = "Cube" }; var sphere = new Sphere { Position = new Vector3F(0.5f), Radius = 0.6f, Color = new Color4(Colors.Green, 175), Name = "Sphere" }; var cone = new Cone { Color = new Color4(Colors.DarkRed, 225), Direction = new Vector3F(0, 0, 1), Height = 1.25f, Position = new Vector3F(0.5f), Name = "Cone" }; var disk = new Disk { Color = new Color4(Colors.Yellow, 125), Direction = new Vector3F(0, 0, 1), Height = 0.25f, Radius = 0.8f, Position = new Vector3F(0.5f, 0.5f, 1.15f), Name = "Disk" }; // Enable order-independent transparency technique. chartControl.IsOitEnabled = true; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; // Set chart data source. chartControl.DataSource = new RenderData[] { cube, sphere, cone, disk }; }
public override void Do(IDemoChartControl chartControl) { // Create mesh for rendering. We need a cube. Mesh cubeMesh = CubeMeshFactory.GenerateCube(); // Generates cube transformation matrixes and it's colors. Matrix4F[] transformations = new Matrix4F[TotalBarCount]; Color4[] colors = new Color4[TotalBarCount]; int index = 0; for (int x = 0; x < GridSize; x++) { for (int y = 0; y < GridSize; y++) { // Randomize block height. float height = (float)random.NextDouble() * MaxHeight; // Compute current bar transformation matrix. // Scaling matrix is used for size scaling. Translation matrix is used for positioning. transformations[index] = Matrix4F.Scaling(BlockSize, BlockSize, height) * Matrix4F.Translation(GridStep * x, GridStep * y, height / 2); // Randomize color. colors[index] = DemoHelper.RandomizeColor(); index++; } } // Create presentation object. var primitiveCollection = new MultiColorPrimitiveCollection { // Set mesh. Mesh = cubeMesh, // Set name. Name = "Bars", // Set custom material. Material = new RenderMaterial(0.35f, 0.5f, 0.6f, 0.0f, 0.0f) }; // Set transforms. primitiveCollection.SetTransformsAndColor(transformations, colors); // Set chart options. chartControl.Axes.IsAxes3DVisible = true; // Set data source. chartControl.DataSource = primitiveCollection; }
public override void Do(IDemoChartControl chartControl) { // Generate vertex positions. Vector3F[] positions = DemoHelper.GenerateSinPoints(Resolution); // Generates initial values (for this case extract it as Z coordinates of positions). initialValues = DemoHelper.ExtractZValues(positions, out OneAxisBounds valueRange); // Current values storage. var currentValues = new float[initialValues.Length]; Array.Copy(initialValues, currentValues, initialValues.Length); // Create value surface data reader. var reader = new StructuredValueSurfaceDataReader(positions, currentValues, Resolution, Resolution, valueRange); // Create value surface presentation data. var valueSurface = new ValueSurface { // Set data reader. Reader = reader, // Set presentation type. PresentationType = ValueSurfacePresentationType.Solid, // Set name. Name = "Surface" }; // Setup chart options. chartControl.Axes.IsAxes3DVisible = true; chartControl.ContextView.Mode2D = false; chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos; // Set chart data source. chartControl.DataSource = valueSurface; // Start animation. animationHelper.Start( argument => argument, argument => { // Generates new values and update reader with it. float[] randomizedValues = GenerateValues(argument, reader.ValueRange); reader.UpdateValues(randomizedValues, 0, reader.VertexCount, 0); }, 0, 0.025f * ((float)UpdateInterval / 16), UpdateInterval); }