private void OnDataSourceReplaced(DataSource prevDataSource, DataSource currDataSource)
		{
			if (prevDataSource != null)
				prevDataSource.Changed -= DataSource_OnChanged;
			if (currDataSource != null)
				currDataSource.Changed += DataSource_OnChanged;

			wrapper = new UniformField2DWrapper(DataSource.Data);
		}
        private void OnDataSourceReplaced(DataSource prevDataSource, DataSource currDataSource)
        {
            if (prevDataSource != null)
            {
                prevDataSource.Changed -= DataSource_OnChanged;
            }
            if (currDataSource != null)
            {
                currDataSource.Changed += DataSource_OnChanged;
            }

            wrapper = new UniformField2DWrapper(DataSource.Data);
        }
		protected override void RebuildUI()
		{
			if (DataSource == null) return;
			if (Plotter == null) return;
			if (Palette == null) return;

			int width = DataSource.Width;
			int height = DataSource.Height;
			fieldWrapper = new UniformField2DWrapper(DataSource.Data);
			var coordinate = SectionCoordinate;

			var minMaxLength = DataSource.GetMinMaxLength();

			PointCollection points = new PointCollection(width + 2);

			var palette = Palette;
			int[] pixels = new int[width];
			for (int ix = 0; ix < width; ix++)
			{
				double x = ix;
				var value = fieldWrapper.GetVector(x / (double)width, coordinate / (double)width);
				double length = value.Length;
				if (length.IsNaN())
					length = minMaxLength.Min;

				double ratio = (length - minMaxLength.Min) / minMaxLength.GetLength();
				if (ratio < 0)
					ratio = 0;
				if (ratio > 1)
					ratio = 1;
				points.Add(new Point(x, 1 - ratio));

				var color = palette.GetColor(ratio);
				pixels[ix] = color.ToArgb();
			}

			points.Add(new Point(width, 1));
			points.Add(new Point(0, 1));

			polygon.Points = points;
			var paletteBmp = BitmapFrame.Create(width, 1, 96, 96, PixelFormats.Bgra32, null, pixels, (width * PixelFormats.Bgra32.BitsPerPixel + 7) / 8);
			var brush = new ImageBrush(paletteBmp);
			polygon.Fill = brush;
		}
		protected override void RebuildUI()
		{
			if (DataSource == null) return;
			if (Plotter == null) return;
			if (Palette == null) return;

			int width = DataSource.Width;
			int height = DataSource.Height;
			fieldWrapper = new UniformField2DWrapper(DataSource.Data);
			var coordinate = SectionCoordinate;

			var minMaxLength = DataSource.GetMinMaxLength();

			PointCollection points = new PointCollection(height + 2);

			var palette = Palette;
			int[] pixels = new int[height];
			for (int iy = 0; iy < height; iy++)
			{
				double y = iy;
				var value = fieldWrapper.GetVector(coordinate / (double)height, y / (double)height);
				double length = value.Length;
				if (length.IsNaN())
					length = minMaxLength.Min;

				double ratio = (length - minMaxLength.Min) / minMaxLength.GetLength();
				if (ratio < 0)
					ratio = 0;
				if (ratio > 1)
					ratio = 1;
				points.Add(new Point(ratio, height - y));

				var color = palette.GetColor(ratio);
				pixels[iy] = color.ToArgb();
			}

			points.Add(new Point(0, 0));
			points.Add(new Point(0, height));

			polygon.Points = points;
			var paletteBmp = BitmapFrame.Create(1, height, 96, 96, PixelFormats.Pbgra32, null, pixels, (1 * PixelFormats.Pbgra32.BitsPerPixel + 7) / 8);
			var brush = new ImageBrush(paletteBmp);
			polygon.Fill = brush;
		}
        protected override void RebuildUI()
        {
            if (Plotter == null)
            {
                return;
            }
            if (DataSource == null)
            {
                return;
            }

            width        = DataSource.Width;
            height       = DataSource.Height;
            fieldWrapper = new UniformField2DWrapper(DataSource.Data);

            bounds           = DataSource.Grid.GetGridBounds();
            particleVelocity = (width + height) * 0.0001;
            Viewport2D.SetContentBounds(this, bounds);

            UpdateParticles(width, height);
        }
Ejemplo n.º 6
0
        protected override void RebuildUI()
        {
            if (DataSource == null)
            {
                return;
            }
            if (Plotter == null)
            {
                return;
            }
            if (Palette == null)
            {
                return;
            }

            int width  = DataSource.Width;
            int height = DataSource.Height;

            fieldWrapper = new UniformField2DWrapper(DataSource.Data);
            var coordinate = SectionCoordinate;

            var minMaxLength = DataSource.GetMinMaxLength();

            PointCollection points = new PointCollection(width + 2);

            var palette = Palette;

            int[] pixels = new int[width];
            for (int ix = 0; ix < width; ix++)
            {
                double x      = ix;
                var    value  = fieldWrapper.GetVector(x / width, coordinate / width);
                double length = value.Length;
                if (length.IsNaN())
                {
                    length = minMaxLength.Min;
                }

                double ratio = (length - minMaxLength.Min) / minMaxLength.GetLength();
                if (ratio < 0)
                {
                    ratio = 0;
                }
                if (ratio > 1)
                {
                    ratio = 1;
                }
                points.Add(new Point(x, 1 - ratio));

                var color = palette.GetColor(ratio);
                pixels[ix] = color.ToArgb();
            }

            points.Add(new Point(width, 1));
            points.Add(new Point(0, 1));

            polygon.Points = points;
            var paletteBmp = BitmapFrame.Create(width, 1, 96, 96, PixelFormats.Bgra32, null, pixels, (width * PixelFormats.Bgra32.BitsPerPixel + 7) / 8);
            var brush      = new ImageBrush(paletteBmp);

            polygon.Fill = brush;
        }
		protected override void RebuildUI()
		{
			if (Plotter == null)
				return;
			if (DataSource == null)
				return;

			width = DataSource.Width;
			height = DataSource.Height;
			fieldWrapper = new UniformField2DWrapper(DataSource.Data);

			bounds = DataSource.Grid.GetGridBounds();
			particleVelocity = (width + height) * 0.0001;
			Viewport2D.SetContentBounds(this, bounds);

			UpdateParticles(width, height);
		}
        protected override void RebuildUI()
        {
            if (DataSource == null)
            {
                return;
            }
            if (Plotter == null)
            {
                return;
            }
            if (Palette == null)
            {
                return;
            }

            int width  = DataSource.Width;
            int height = DataSource.Height;

            fieldWrapper = new UniformField2DWrapper(DataSource.Data);
            var coordinate = SectionCoordinate;

            var minMaxLength = DataSource.GetMinMaxLength();

            PointCollection points = new PointCollection(height + 2);

            var palette = Palette;

            int[] pixels = new int[height];
            for (int iy = 0; iy < height; iy++)
            {
                double y      = iy;
                var    value  = fieldWrapper.GetVector(coordinate / (double)height, y / (double)height);
                double length = value.Length;
                if (length.IsNaN())
                {
                    length = minMaxLength.Min;
                }

                double ratio = (length - minMaxLength.Min) / minMaxLength.GetLength();
                if (ratio < 0)
                {
                    ratio = 0;
                }
                if (ratio > 1)
                {
                    ratio = 1;
                }
                points.Add(new Point(ratio, height - y));

                var color = palette.GetColor(ratio);
                pixels[iy] = color.ToArgb();
            }

            points.Add(new Point(0, 0));
            points.Add(new Point(0, height));

            polygon.Points = points;
            var paletteBmp = BitmapFrame.Create(1, height, 96, 96, PixelFormats.Pbgra32, null, pixels, (1 * PixelFormats.Pbgra32.BitsPerPixel + 7) / 8);
            var brush      = new ImageBrush(paletteBmp);

            polygon.Fill = brush;
        }