/// <summary> /// Generates the points from source. /// </summary> public override void GeneratePointsFromSource() { base.GeneratePointsFromSource(); OpenValues = this.GetReflectionValues(this.OpenPath, PointsSource, OpenValues, false); CloseValues = this.GetReflectionValues(this.ClosePath, PointsSource, CloseValues, false); ErrorValues = this.GetReflectionValues(this.ErrorPath, PointsSource, ErrorValues, false); if (ErrorValues != null && ErrorValues.Count > 0) { int i = 0; var openValues = new List <double>(); var closeValues = new List <double>(); foreach (var errorValue in ErrorValues) { double h = HighValues[i++]; openValues.Add(h - errorValue); closeValues.Add(h + errorValue); } this.openPoints = GetPointsFromValues(XValues, openValues); this.closePoints = GetPointsFromValues(XValues, closeValues); } else { if (OpenValues != null && OpenValues.Count > 0) { this.openPoints = GetPointsFromValues(XValues, OpenValues); } if (CloseValues != null && CloseValues.Count > 0) { this.closePoints = GetPointsFromValues(XValues, CloseValues); } } }
private void SparrowButton_Click_1(object sender, RoutedEventArgs e) { _viewModel = new DataGenerator(); Collection = _viewModel.Generate(); stopWatch.Start(); ((LineSeries)(Chart.Series[0])).Points = Collection; }
/// <summary> /// Converts from the specified value to the intended conversion type of the converter. /// </summary> /// <param name="context">An object that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param> /// <param name="value">The value to convert to the type of this converter.</param> /// <returns> /// The converted value. /// </returns> public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { List <string> result = ((string)value).Split(',').ToList(); for (int j = 0; j < result.Count; j++) { var point = result[j]; if (string.IsNullOrEmpty(point)) { result[j] = "0"; } } if (result.Count % 2 != 0) { result.Add("0"); } PointsCollection collection = new PointsCollection(); for (int i = 0; i < result.Count; i += 2) { collection.Add(new ChartPoint() { XValue = double.Parse(result[i].ToString(CultureInfo.InvariantCulture)), YValue = double.Parse(result[i + 1].ToString(CultureInfo.InvariantCulture)) }); } return(collection); }
internal EffectPluginContext(IPluginConfiguration configuration, int elapsedMilliseconds, int xCount = 10, int yHeight = 10) : base(configuration) { ElapsedMilliseconds = elapsedMilliseconds; PointsCollection = new PointsCollection(xCount, yHeight); }
internal void SetPointsCollection(PointsCollection pointsCollection) { lock (pointsCollection) { this.pointsCollection = pointsCollection; } }
internal void RemovePoints(List <Point> points) { foreach (var point in points) { if (PointsCollection.Contains(point)) { PointsCollection.Remove(point); } } }
public void RemoveSelectedPoints() { var temp = PointsCollection.Where(c => c.Selected).ToList(); foreach (var point in temp) { PointsCollection.Remove(point); } Refresh(); }
/// <summary> /// Gets the points from values. /// </summary> /// <param name="xValues">The x values.</param> /// <param name="yValues">The y values.</param> /// <returns></returns> protected PointsCollection GetPointsFromValues(List <double> xValues, List <double> yValues) { PointsCollection tempPoints = new PointsCollection(); for (int i = 0; (i < xValues.Count && i < yValues.Count); i++) { ChartPoint point = new ChartPoint() { XValue = xValues[i], YValue = yValues[i] }; tempPoints.Add(point); } return(tempPoints); }
/// <summary> /// Generates the points from source. /// </summary> public override void GeneratePointsFromSource() { base.GeneratePointsFromSource(); OpenValues = this.GetReflectionValues(this.OpenPath, PointsSource, OpenValues, false); CloseValues = this.GetReflectionValues(this.ClosePath, PointsSource, CloseValues, false); if (OpenValues != null && OpenValues.Count > 0) { this.openPoints = GetPointsFromValues(XValues, OpenValues); } if (CloseValues != null && CloseValues.Count > 0) { this.closePoints = GetPointsFromValues(XValues, CloseValues); } }
public void SetData(short[] data) { PointsCollection = new PointsCollection(); for (int i = 0; i < data.Length; i++) { PointsCollection.Add(new DoublePoint() { Data = i, Value = data[i] }); } ((LineSeries)(Chart.Series[0])).Points = PointsCollection; }
/// <summary> /// Converts from the specified value to the intended conversion type of the converter. /// </summary> /// <param name="context">An object that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param> /// <param name="value">The value to convert to the type of this converter.</param> /// <returns> /// The converted value. /// </returns> public override object ConvertFrom(ITypeDescriptorContext context,System.Globalization.CultureInfo culture, object value) { List<string> result = ((string)value).Split(',').ToList(); for (int j=0;j<result.Count;j++) { var point = result[j]; if (string.IsNullOrEmpty(point)) result[j] = "0"; } if (result.Count % 2 != 0) result.Add("0"); PointsCollection collection = new PointsCollection(); for (int i = 0; i < result.Count; i += 2) { collection.Add(new ChartPoint() { XValue = double.Parse(result[i].ToString(CultureInfo.InvariantCulture)), YValue = double.Parse(result[i + 1].ToString(CultureInfo.InvariantCulture)) }); } return collection; }
public GeneticAlgorithmParametersViewModel() { _geneticAlgorithm = new CubeGraphGeneticAlgorithm(Graph.FromFile(@"..\..\GraphData.txt")); _startGeneticAlgorithmCommand = new Command <object>((mockParams) => { new Task(() => { _geneticAlgorithm.Execute(_geneticParameters, (progress) => ProgressValue = progress); var averageFitness = new PointsCollection(); var maxFitness = new PointsCollection(); var minFitness = new PointsCollection(); var maxPoints = _geneticAlgorithm.History.Select((historyItem) => new DoublePoint() { Data = historyItem.Generation, Value = historyItem.BestOrganismFitness }); foreach (var point in maxPoints) { maxFitness.Add(point); } var minPoints = _geneticAlgorithm.History.Select((historyItem) => new DoublePoint() { Data = historyItem.Generation, Value = historyItem.WorstOrganismFitness }); foreach (var point in minPoints) { minFitness.Add(point); } var averagePoints = _geneticAlgorithm.History.Select((historyItem) => new DoublePoint() { Data = historyItem.Generation, Value = historyItem.AverageOrganismFitness }); foreach (var point in averagePoints) { averageFitness.Add(point); } AverageFitness = averageFitness; MinFitness = minFitness; MaxFitness = maxFitness; NotifyPropertyChanged(() => MaxGridValue); }).Start(); }); }
public PointsCollection Generate() { PointsCollection collection = new PointsCollection(); DateTime date = new DateTime(2009, 1, 1); double value = 1000; for (int i = 0; i < this.DataCount; i++) { collection.Add(new DoublePoint() { Data = i, Value = value }); if (randomNumber.NextDouble() > .5) { value += randomNumber.NextDouble(); } else { value -= randomNumber.NextDouble(); } } return collection; }
public void InitializeChart(int[] values) { chart.YAxis.MaxValue = values.Max() + (values.Max() * 0.05); chart.XAxis.MaxValue = values.Length; chart.XAxis.MinorTicksCount = values.Length / 8; SeriesCollection series = new SeriesCollection() { new ColumnSeries() }; var points = new PointsCollection(); for (int i = 0; i < values.Length; i++) { points.Add(new DoublePoint() { Data = i, Value = values[i] }); } series[0].Points = points; chart.Series = series; }
/// <summary> /// Generates the points from source. /// </summary> public virtual void GeneratePointsFromSource() { Chart.ActualCategoryValues.Clear(); XValues = this.GetReflectionValues(this.XPath, PointsSource, XValues, false); YValues = this.GetReflectionValues(this.LowPath, PointsSource, YValues, false); if (YValues == null || YValues.Count == 0) { YValues = (new double[XValues.Count]).ToList(); } LowValues = YValues; lowPoints = new PointsCollection(); if (XValues != null && XValues.Count > 0) { this.lowPoints = GetPointsFromValues(XValues, YValues); } XValues = this.GetReflectionValues(this.XPath, PointsSource, XValues, false); YValues = this.GetReflectionValues(this.HighPath, PointsSource, YValues, false); if (XValues != null && XValues.Count > 0) { this.Points = GetPointsFromValues(XValues, YValues); } HighValues = YValues; }
public PointsCollection Generate() { PointsCollection collection = new PointsCollection(); DateTime date = new DateTime(2009, 1, 1); double value = 1000; for (int i = 0; i < this.DataCount; i++) { collection.Add(new DoublePoint() { Data = i, Value = value }); if (randomNumber.NextDouble() > .5) { value += randomNumber.NextDouble(); } else { value -= randomNumber.NextDouble(); } } return(collection); }
public GeometryStar() { this.NTH = 31; this.NPH = 51; this.pontosCartesianos = new PointsCollection(); }
public void setSecondaryPoints(PointsCollection p) { this.secondary.setPontos(p); }
public void setPrimaryPoints(PointsCollection p) { this.primary.setPontos(p); }
internal void FixInitialPointsCollection() { initialPointsCollection = PointsCollection; }
internal void SetPointsCollection(PointsCollection pointsCollection) { PointsCollection = pointsCollection; }
public void setPontos(PointsCollection pontos) { this.pontosCartesianos = pontos; }
internal void ResetToInitialPointsCollection() { PointsCollection = initialPointsCollection; }
public void AddPoint(Point point) { PointsCollection.Add(point); }
public void DrawBezierCurveStereoscopy(Matrix4d transformacja, ObservableCollection <Point> Points) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); GL.Begin(BeginMode.Lines); GL.Color3(0.6, 0.0, 0.0); int j = 0; ObservableCollection <Point> temp = new ObservableCollection <Point>(); ObservableCollection <Point> transformedProjectedPoints = new ObservableCollection <Point>(); foreach (var p in Points) { var a = projekcjaRight.Multiply(transformacja.Multiply(p)); transformedProjectedPoints.Add(new Point(a.X, a.Y, a.Z)); } foreach (var p in transformedProjectedPoints) { j++; temp.Add(p); if (j % 4 == 0 || p == transformedProjectedPoints.Last()) { double divisions = GetDivisions(temp); var point = Casteljeu(temp, 0); for (double t = divisions / 2; t <= 1; t += divisions / 2) { GL.Vertex2(point.X, point.Y); point = Casteljeu(temp, t); GL.Vertex2(point.X, point.Y); } temp.Clear(); temp.Add(p); j = 1; } } GL.Color3(0.0, 0.0, 0.6); j = 0; ObservableCollection <Point> temp2 = new ObservableCollection <Point>(); foreach (var p in Points) { j++; temp2.Add(p); if (j % 4 == 0 || p == PointsCollection.Last()) { double divisions = GetDivisions(transformacja, temp2); var point = Casteljeu(temp2, 0); var windowCoordinates = projekcjaLeft.Multiply(transformacja.Multiply(point)); for (double t = divisions / 2; t <= 1; t += divisions / 2) { GL.Vertex2(windowCoordinates.X, windowCoordinates.Y); point = Casteljeu(temp2, t); windowCoordinates = projekcjaLeft.Multiply(transformacja.Multiply(point)); GL.Vertex2(windowCoordinates.X, windowCoordinates.Y); } temp2.Clear(); temp2.Add(p); j = 1; } } GL.End(); }
public void cleanPontos() { this.pontosCartesianos = new PointsCollection(); }
protected PointsCollection GetPointsFromValues(List<double> xValues,List<double> yValues) { PointsCollection tempPoints = new PointsCollection(); for (int i = 0; (i < xValues.Count && i < yValues.Count); i++) { ChartPoint point = new ChartPoint() { XValue = xValues[i], YValue = yValues[i] }; tempPoints.Add(point); } return tempPoints; }
/// <summary> /// Generates the points from source. /// </summary> public virtual void GeneratePointsFromSource() { XValues = this.GetReflectionValues(this.XPath, PointsSource, XValues, false); YValues = this.GetReflectionValues(this.LowPath, PointsSource, YValues, false); LowValues = YValues; lowPoints = new PointsCollection(); if (XValues != null && XValues.Count > 0) { this.lowPoints = GetPointsFromValues(XValues, YValues); } XValues = this.GetReflectionValues(this.XPath, PointsSource, XValues, false); YValues = this.GetReflectionValues(this.HighPath, PointsSource, YValues, false); if (XValues != null && XValues.Count > 0) { this.Points = GetPointsFromValues(XValues, YValues); } HighValues = YValues; }
private void RunProcessingPluginChain(IProcessingPluginChain processingPluginChain, CancellationToken cancellationToken) { foreach (var inputDevice in processingPluginChain.InputDevices) { inputDevice.Plugin.Run(inputDevice.Context); } foreach (var effect in processingPluginChain.EffectPluginChain.Effects) { ((EffectPluginContext)effect.Context).FixInitialPointsCollection(); } var processingStopwatch = new Stopwatch(); processingStopwatch.Start(); var throttleMilliseconds = 100; long timeOfLastUpdateMilliseconds = 0; while (!cancellationToken.IsCancellationRequested) { PointsCollection effectChange = null; var chainedOutputContexts = new List <Tuple <IPluginDependency, IPluginContext> >(); foreach (var effect in processingPluginChain.EffectPluginChain.Effects) { var context = (EffectPluginContext)effect.Context; context.ResetToInitialPointsCollection(); foreach (var chainedOutputContext in chainedOutputContexts.Where(coc => coc.Item1.DependentPlugin == effect.Plugin)) { var output = chainedOutputContext.Item2.GetOutput(chainedOutputContext.Item1.SourcePluginOutputName); effect.Context.SetInput(chainedOutputContext.Item1.DependentPluginInputName, output); } if (effectChange != null) { context.PointsCollection = effectChange; } context.ElapsedMilliseconds = processingStopwatch.ElapsedMilliseconds; effect.Plugin.Run(context); foreach (var chainedOutput in processingPluginChain.PluginDependencies.Where(pd => pd.DependentPlugin == effect.Plugin)) { chainedOutputContexts.Add(new Tuple <IPluginDependency, IPluginContext>(chainedOutput, context)); } effectChange = context.PointsCollection; } effectChange.CompletePointOperations(); foreach (var outputDevice in processingPluginChain.OutputDevices) { var context = (OutputDevicePluginContext)outputDevice.Context; context.SetPointsCollection(effectChange); outputDevice.Plugin.Run(context); } while (processingStopwatch.ElapsedMilliseconds < timeOfLastUpdateMilliseconds + throttleMilliseconds) { continue; } timeOfLastUpdateMilliseconds = processingStopwatch.ElapsedMilliseconds; } }